Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Your code doesn't do what you probaby mean to do. Sequentially, your function :

  • computes integrate(f, x) (using Sage's default integrator), then

  • creates a Fricas object representing this integral, and returns it

Your code then tries to pretty_print this fricas object, which fails (the error message is pretty specific...).

A couple suggestions :

  • Integrating via Fricas is more easily done by integrate(x, f, algorithm="fricas"), which returns the Sage object representing the Fricas value returned by Fricas' integrator.

  • You can also do this manually with fricas.integrate(*map(fricas, (f, x))).sage(), which returns -((x - 1)*log(x - 1) - (x - 1)*log(x) + 1)/(x - 1).

Quite intentionally, I leave the necessary explanations of this syntax to your explorations of Python and Sage documentations...

  • The effect of pretty_print may be platform-dependent but also object-dependant...

HTH,

Your code doesn't do what you probaby mean to do. Sequentially, your function :

  • computes integrate(f, x) (using Sage's default integrator), then

  • creates a Fricas object representing this integral, and returns it

Your code then tries to pretty_print this fricas object, which fails (the error message is pretty specific...).

A couple suggestions :

  • Integrating via Fricas is more easily done by integrate(x, f, integrate(f, x, algorithm="fricas"), which returns the Sage object representing the Fricas value returned by Fricas' integrator.integrator. (EDIT : typo fixed).

  • You can also do this manually with fricas.integrate(*map(fricas, (f, x))).sage(), which returns -((x - 1)*log(x - 1) - (x - 1)*log(x) + 1)/(x - 1).

Quite intentionally, I leave the necessary explanations of this syntax to your explorations of Python and Sage documentations...

  • The effect of pretty_print may be platform-dependent but also object-dependant...

HTH,

Your code doesn't do what you probaby mean to do. Sequentially, your function :

  • computes integrate(f, x) (using Sage's default integrator), then

  • creates a Fricas object representing this integral, and returns it

Your code then tries to pretty_print this fricas object, which fails (the error message is pretty specific...).

A couple suggestions :

  • Integrating via Fricas is more easily done by integrate(f, x, algorithm="fricas"), which returns the Sage object representing the Fricas value returned by Fricas' integrator. (EDIT : typo fixed).

  • You can also do this manually with fricas.integrate(*map(fricas, (f, x))).sage(), which returns -((x - 1)*log(x - 1) - (x - 1)*log(x) + 1)/(x - 1).

Quite intentionally, I leave the necessary explanations of this syntax to your explorations of Python and Sage documentations...

  • The effect of pretty_print may be platform-dependent but also object-dependant...

EDIT : On Sagemath 9.8.beta4 running locally, I get :

sage: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:f = 1/(x*(x-1)^2)
:print("default          : ",f.integrate(x))
:print("maxima           : ",f.integrate(x, algorithm="maxima"))
:print("giac             : ",f.integrate(x, algorithm="giac"))
:print("sympy            : ",f.integrate(x, algorithm="sympy"))
:print("mathematica_free : ",f.integrate(x, algorithm="mathematica_free"))
:print("fricas           : ",f.integrate(x, algorithm="fricas"))
:--
default          :  -1/(x - 1) - log(x - 1) + log(x)
maxima           :  -1/(x - 1) - log(x - 1) + log(x)
giac             :  -1/(x - 1) + log(abs(-1/(x - 1) - 1))
sympy            :  -1/(x - 1) - log(x - 1) + log(x)
mathematica_free :  -1/(x - 1) - log(x - 1) + log(x)
fricas           :  -((x - 1)*log(x - 1) - (x - 1)*log(x) + 1)/(x - 1)

On SageCell on 2022-12-06, reults are similar for default, maxima, giac and sympy integrators ; fricas fails and mathematica_free "never" returns.

HTH,