Hi: I find out that integral_steps in sympy.integrals.manualintegrate can print out the exact step about how sympy integrate an expression. However the answer is pretty unreadable. For example:
import sympy x=sympy.symbols('x',real=True) e,m,w=sympy.symbols('e,m,w',positive=True) sympy.manualintegrate.integral_steps(sympy.sqrt(2*e*m-(x*m*w)**2),x) the output is: TrigSubstitutionRule(theta=_theta, func=sqrt(2)*sqrt(e)*sin(_theta)/(sqrt(m)*w), rewritten=2*e*cos(_theta)**2/w, substep=ConstantTimesRule(constant=2*e/w, other=cos(_theta)**2, substep=RewriteRule(rewritten=cos(2*_theta)/2 + 1/2, substep=AddRule(substeps=[ConstantTimesRule(constant=1/2, other=cos(2*_theta), substep=URule(u_var=_u, u_func=2*_theta, constant=1/2, substep=ConstantTimesRule(constant=1/2, other=cos(_u), substep=TrigRule(func='cos', arg=_u, context=cos(_u), symbol=_u), context=cos(_u), symbol=_u), context=cos(2*_theta), symbol=_theta), context=cos(2*_theta)/2, symbol=_theta), ConstantRule(constant=1/2, context=1/2, symbol=_theta)], context=cos(2*_theta)/2 + 1/2, symbol=_theta), context=cos(_theta)**2, symbol=_theta), context=2*e*cos(_theta)**2/w, symbol=_theta), restriction=And(x < sqrt(2)*sqrt(e)/(sqrt(m)*w), x > -sqrt(2)*sqrt(e)/(sqrt(m)*w)), context=sqrt(2*e*m - m**2*w**2*x**2), symbol=x) It is hard to read and understand. Although sympy gamma can output the integrate step more clearly, but sympy gamma just support an expression. If the expression depends on context, it is totally useless. The manualintegrate.py said sympy gamma use https://github.com/sympy/sympy_gamma/blob/master/app/logic/intsteps.py to output integrate step. So I try import intsteps intsteps.print_html_steps(sympy.sqrt(2*e*m-(x*m*w)**2),x) the output is still ugly: '<ol>\n <p>TrigSubstitutionRule(theta=_theta, func=sqrt(2)*sqrt(e)*sin(_theta)/(sqrt(m)*w), rewritten=2*e*cos(_theta)**2/w, substep=ConstantTimesRule(constant=2*e/w, other=cos(_theta)**2, substep=RewriteRule(rewritten=cos(2*_theta)/2 + 1/2, substep=AddRule(substeps=[ConstantTimesRule(constant=1/2, other=cos(2*_theta), substep=URule(u_var=_u, u_func=2*_theta, constant=1/2, substep=ConstantTimesRule(constant=1/2, other=cos(_u), substep=TrigRule(func=\'cos\', arg=_u, context=cos(_u), symbol=_u), context=cos(_u), symbol=_u), context=cos(2*_theta), symbol=_theta), context=cos(2*_theta)/2, symbol=_theta), ConstantRule(constant=1/2, context=1/2, symbol=_theta)], context=cos(2*_theta)/2 + 1/2, symbol=_theta), context=cos(_theta)**2, symbol=_theta), context=2*e*cos(_theta)**2/w, symbol=_theta), restriction=And(x < sqrt(2)*sqrt(e)/(sqrt(m)*w), x > -sqrt(2)*sqrt(e)/(sqrt(m)*w)), context=sqrt(2*e*m - m**2*w**2*x**2), symbol=x)</p>\n<li>\n <p>Now simplify:</p>\n <p><script type="math/tex; mode=display">\\begin{cases} \\frac{e}{w} \\operatorname{asin}{\\left (\\frac{\\sqrt{2} \\sqrt{m} w x}{2 \\sqrt{e}} \\right )} + \\frac{\\sqrt{m} x}{2} \\sqrt{2 e - m w^{2} x^{2}} & \\text{for}\\: x > - \\frac{\\sqrt{2} \\sqrt{e}}{\\sqrt{m} w} \\wedge x < \\frac{\\sqrt{2} \\sqrt{e}}{\\sqrt{m} w} \\end{cases}</script></p>\n</li>\n<li>\n <p>Add the constant of integration:</p>\n <p><script type="math/tex; mode=display">\\begin{cases} \\frac{e}{w} \\operatorname{asin}{\\left (\\frac{\\sqrt{2} \\sqrt{m} w x}{2 \\sqrt{e}} \\right )} + \\frac{\\sqrt{m} x}{2} \\sqrt{2 e - m w^{2} x^{2}} & \\text{for}\\: x > - \\frac{\\sqrt{2} \\sqrt{e}}{\\sqrt{m} w} \\wedge x < \\frac{\\sqrt{2} \\sqrt{e}}{\\sqrt{m} w} \\end{cases}+ \\mathrm{constant}</script></p>\n</li>\n</ol>\n<hr/>\n <p>The answer is:</p>\n <p><script type="math/tex; mode=display">\\begin{cases} \\frac{e}{w} \\operatorname{asin}{\\left (\\frac{\\sqrt{2} \\sqrt{m} w x}{2 \\sqrt{e}} \\right )} + \\frac{\\sqrt{m} x}{2} \\sqrt{2 e - m w^{2} x^{2}} & \\text{for}\\: x > - \\frac{\\sqrt{2} \\sqrt{e}}{\\sqrt{m} w} \\wedge x < \\frac{\\sqrt{2} \\sqrt{e}}{\\sqrt{m} w} \\end{cases}+ \\mathrm{constant}</script></p>' So how to get a more readable output of integral_steps in ipython3? -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at https://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/85ab1562-9ef5-4422-af3d-4268fc047847%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.