Opened 2 years ago
Last modified 3 months ago
#28415 needs_review enhancement
Step by step integration for educational use
Reported by:  mmarco  Owned by:  

Priority:  major  Milestone:  sage9.5 
Component:  symbolics  Keywords:  integration, education, sd110 
Cc:  nthiery, kcrisman, slelievre  Merged in:  
Authors:  Miguel Marco  Reviewers:  
Report Upstream:  N/A  Work issues:  
Branch:  u/mmarco/manualintegrate (Commits, GitHub, GitLab)  Commit:  ff07f9ad8e3ae9f668cfd99ac75026a913915f23 
Dependencies:  Stopgaps: 
Description (last modified by )
This branch implements a system to compute symbolic integrals step by step, trying to follow the rules that are taught to students to compute integrals by hand.
To compute the appropriate rules, it uses the sympy module manualintegrate
.
It is exposed to the user through a ManualIntegral
class, that can either be iterated to get hints on steps to follow:
sage: from sage.symbolic.integration.manual import ManualIntegral sage: M = ManualIntegral(exp(x)*sin(x), x) sage: M.hint() (u == sin(x), dv == e^x, du == cos(x), v == integrate(e^x, x), integrate(e^x*sin(x), x) == v*sin(x)  integrate(v*cos(x), x)) sage: M.hint() (integrate(e^x, x) == e^x,) sage: M.hint() (u == cos(x), dv == e^x, du == sin(x), v == integrate(e^x, x), integrate(cos(x)*e^x, x) == v*cos(x)  integrate(v*sin(x), x)) sage: M.hint() (integrate(e^x, x) == e^x,) sage: M.hint() (integrate(e^x*sin(x), x) == cos(x)*e^x + e^x*sin(x)  integrate(e^x*sin(x), x), 2*integrate(e^x*sin(x), x) == cos(x)*e^x + e^x*sin(x))
Also, all hints can be listed at once:
sage: M.all_hints() [(u == sin(x), dv == e^x, du == cos(x), v == integrate(e^x, x), integrate(e^x*sin(x), x) == v*sin(x)  integrate(v*cos(x), x)), (integrate(e^x, x) == e^x,), (u == cos(x), dv == e^x, du == sin(x), v == integrate(e^x, x), integrate(cos(x)*e^x, x) == v*cos(x)  integrate(v*sin(x), x)), (integrate(e^x, x) == e^x,), (integrate(e^x*sin(x), x) == cos(x)*e^x + e^x*sin(x)  integrate(e^x*sin(x), x), 2*integrate(e^x*sin(x), x) == cos(x)*e^x + e^x*sin(x))]
Change History (16)
comment:1 Changed 2 years ago by
 Branch set to u/mmarco/manualintegrate
comment:2 Changed 2 years ago by
 Commit set to 9824f80aee60f09d2e6faeaf30b3a7640c77107a
 Component changed from PLEASE CHANGE to symbolics
 Description modified (diff)
 Keywords integration education added
 Type changed from PLEASE CHANGE to enhancement
comment:3 Changed 2 years ago by
 Cc nthiery added
comment:4 Changed 2 years ago by
 Status changed from new to needs_review
comment:5 Changed 22 months ago by
 Milestone changed from sage8.9 to sage9.1
Ticket retargeted after milestone closed
comment:6 Changed 19 months ago by
I dont think this should be a default, because after all Sagemath should be like an aid to your calculations, and I dont think that giving the steps right away would help anyone learn. Moreover I think the modifications which can be made to this, of course at the higher levels can be stages of the steps, meaning that different stages reveal different levels of step, which eases the burden of understanding the exact calculation.
Moreover, I think instead of explicit details being given, we can reveal the steps to be of the format
 integrate sinx
 take the solution and judge its value in different equations
3 ....
comment:7 Changed 19 months ago by
 Milestone changed from sage9.1 to sage9.2
Batch modifying tickets that will likely not be ready for 9.1, based on a review of the ticket title, branch/review status, and last modification date.
comment:8 Changed 14 months ago by
 Milestone changed from sage9.2 to sage9.3
comment:9 Changed 14 months ago by
 Commit changed from 9824f80aee60f09d2e6faeaf30b3a7640c77107a to 1e6240e6fed4226b8de4b369715060298830ae58
comment:10 Changed 12 months ago by
 Cc crisman added
comment:11 Changed 12 months ago by
 Cc kcrisman slelievre added; crisman removed
comment:12 Changed 12 months ago by
 Keywords sd110 added
comment:13 Changed 12 months ago by
Hi  I was able to watch your your demo in full at https://bbb.imo.universiteparissaclay.fr/playback/presentation/2.0/playback.html?meetingId=13f0752852b2cf7dc1e08f807f73590c9a3f650d1604079987388
and have some thoughts that I don't recall othes expressed. The simplest and to me most immediate reaction after looking at the list of namedtuple output from sympy.integrals.manualintegrate
is to just give the names of the steps,
 integration by parts,
 variable substitution,
 integration under the integral (or Leibniz integration which was a favorite of R. Feynman).
As for your the question of how much to show, that might be handled by some sort of expanded or colapsed view or expanded view that typically exists for (HTML) lists.
But overall it feels like doing this is going to be a lot of work, and it is not clear to me which side this should go on. Probably a bit on the sympy side if it is not there.
Let me give some examples. I see that some of the namedtuples are
 Reciprocal Rule
 Urule
 Piecewise Rule
 Arccoth Rule
and so on. Somewhere there should be a way to get longer verbose descriptions of exactly what there rules mean. Just providing URL link to where the information could be found would be sufficient. Does such a thing currently exist?
As you point out, based on what the rule is there might be further operations or "hints" as you put it that might guide a student. I think the example you gave was substituion by parts and using the system's ability to do factorization to figure out all of the parts which could be tried. Factorization makes sense for only some rules, not all of them. And for other rules other kinds of things to focus on make sense.
So if you want to go down the route of providing only a first step hint and making the student explore from there, it seems like you'd need a mapping from namedtuple name to the kinds of ways to provide hints. And probably this should be done in sympy rather than sage.
comment:14 Changed 11 months ago by
 Commit changed from 1e6240e6fed4226b8de4b369715060298830ae58 to ff07f9ad8e3ae9f668cfd99ac75026a913915f23
Branch pushed to git repo; I updated commit sha1. New commits:
33e2667  First implementation

b3f0851  Complete docstrings and tests.

4970411  Improve ascii_art

59dad2b  Fix indentation error

d96784e  Make python3 style iterable

ff07f9a  Merge branch 'u/mmarco/manualintegrate' of git://trac.sagemath.org/sage into t/28415/manualintegrate

comment:15 Changed 7 months ago by
 Milestone changed from sage9.3 to sage9.4
Setting new milestone based on a cursory review of ticket status, priority, and last modification date.
comment:16 Changed 3 months ago by
 Milestone changed from sage9.4 to sage9.5
Setting a new milestone for this ticket based on a cursory review.
The user interface is maybe not very natural, but I couldn't figure out anything that was clearly better (right now the hints are just tuples of symbolic equations, I considered creating specific classes for this, but I am not sure it is a better solution).
Also, I am also not sure if the ManualIntegral? class should be imported by default (the name space is already bloated, but mostly, I am not sure if this is the kind of thing that you want to offer by default to students, or if it is preferable to offer it as some kind of 'optional' feature).
I would appreciate any comments obout these questions.
New commits:
First implementation
Complete docstrings and tests.