1 | initial version |
Sympy is used as an option for integration, sums, solving equations, for the Laplace function (and inverse), and perhaps more. Usually, the way to use it is with adding a algorithm = 'sympy'
option:
sage: var('k')
k
sage: sum(1/(1+k^2), k, -oo, oo)
-1/2*I*psi(I + 1) + 1/2*I*psi(-I + 1) - 1/2*I*psi(I) + 1/2*I*psi(-I)
sage: sum(1/(1+k^2), k, -oo, oo, algorithm = 'sympy')
pi/tanh(pi)
sage: solve(-2*x**3 + 4*x**2 - 2*x + 6 > 0, x)
[[x < 2.174559471365639]]
sage: solve(-2*x**3 + 4*x**2 - 2*x + 6 > 0, x, algorithm='sympy')
[x < 1/3*(1/2)^(1/3)*(9*sqrt(77) + 79)^(1/3) + 2/3*(1/2)^(2/3)/(9*sqrt(77) + 79)^(1/3) + 2/3]
sage: var('t, s')
(t, s)
sage: laplace(cos(t^2), t, s)
-(1/16*I - 1/16)*sqrt(2)*sqrt(pi)*cos(1/4*s^2)*erf(1/2*(-1)^(3/4)*s) - (1/16*I + 1/16)*sqrt(2)*sqrt(pi)*cos(1/4*s^2)*erf((1/4*I + 1/4)*sqrt(2)*s) - (1/16*I - 1/16)*sqrt(2)*sqrt(pi)*cos(1/4*s^2)*erf((1/4*I - 1/4)*sqrt(2)*s) - (1/16*I + 1/16)*sqrt(2)*sqrt(pi)*cos(1/4*s^2)*erf(1/2*I*sqrt(-I)*s) - (1/16*I + 1/16)*sqrt(2)*sqrt(pi)*erf(1/2*(-1)^(3/4)*s)*sin(1/4*s^2) - (1/16*I - 1/16)*sqrt(2)*sqrt(pi)*erf((1/4*I + 1/4)*sqrt(2)*s)*sin(1/4*s^2) - (1/16*I + 1/16)*sqrt(2)*sqrt(pi)*erf((1/4*I - 1/4)*sqrt(2)*s)*sin(1/4*s^2) - (1/16*I - 1/16)*sqrt(2)*sqrt(pi)*erf(1/2*I*sqrt(-I)*s)*sin(1/4*s^2) + 1/4*sqrt(2)*sqrt(pi)*cos(1/4*s^2) - 1/4*sqrt(2)*sqrt(pi)*sin(1/4*s^2)
sage: laplace(cos(t^2), t, s, algorithm='sympy')
(-1/2*sqrt(pi)*(sqrt(2)*cos(1/4*s^2)*fresnel_sin(1/2*sqrt(2)*s/sqrt(pi)) - sqrt(2)*fresnel_cos(1/2*sqrt(2)*s/sqrt(pi))*sin(1/4*s^2) - cos(1/4*pi + 1/4*s^2)),
0,
True)
2 | No.2 Revision |
Sympy is used as an option for integration, sums, solving equations, for the Laplace function (and inverse), and perhaps more. Usually, the way to use it is with adding a algorithm = 'sympy'
option:
sage: integral(sin(x)^2, x)
1/2*x - 1/4*sin(2*x)
sage: integral(sin(x)^2, x, algorithm='sympy')
-1/2*cos(x)*sin(x) + 1/2*x
sage: var('k')
k
sage: sum(1/(1+k^2), k, -oo, oo)
-1/2*I*psi(I + 1) + 1/2*I*psi(-I + 1) - 1/2*I*psi(I) + 1/2*I*psi(-I)
sage: sum(1/(1+k^2), k, -oo, oo, algorithm = 'sympy')
pi/tanh(pi)
sage: solve(-2*x**3 + 4*x**2 - 2*x + 6 > 0, x)
[[x < 2.174559471365639]]
sage: solve(-2*x**3 + 4*x**2 - 2*x + 6 > 0, x, algorithm='sympy')
[x < 1/3*(1/2)^(1/3)*(9*sqrt(77) + 79)^(1/3) + 2/3*(1/2)^(2/3)/(9*sqrt(77) + 79)^(1/3) + 2/3]
sage: var('t, s')
(t, s)
sage: laplace(cos(t^2), t, s)
-(1/16*I - 1/16)*sqrt(2)*sqrt(pi)*cos(1/4*s^2)*erf(1/2*(-1)^(3/4)*s) - (1/16*I + 1/16)*sqrt(2)*sqrt(pi)*cos(1/4*s^2)*erf((1/4*I + 1/4)*sqrt(2)*s) - (1/16*I - 1/16)*sqrt(2)*sqrt(pi)*cos(1/4*s^2)*erf((1/4*I - 1/4)*sqrt(2)*s) - (1/16*I + 1/16)*sqrt(2)*sqrt(pi)*cos(1/4*s^2)*erf(1/2*I*sqrt(-I)*s) - (1/16*I + 1/16)*sqrt(2)*sqrt(pi)*erf(1/2*(-1)^(3/4)*s)*sin(1/4*s^2) - (1/16*I - 1/16)*sqrt(2)*sqrt(pi)*erf((1/4*I + 1/4)*sqrt(2)*s)*sin(1/4*s^2) - (1/16*I + 1/16)*sqrt(2)*sqrt(pi)*erf((1/4*I - 1/4)*sqrt(2)*s)*sin(1/4*s^2) - (1/16*I - 1/16)*sqrt(2)*sqrt(pi)*erf(1/2*I*sqrt(-I)*s)*sin(1/4*s^2) + 1/4*sqrt(2)*sqrt(pi)*cos(1/4*s^2) - 1/4*sqrt(2)*sqrt(pi)*sin(1/4*s^2)
sage: laplace(cos(t^2), t, s, algorithm='sympy')
(-1/2*sqrt(pi)*(sqrt(2)*cos(1/4*s^2)*fresnel_sin(1/2*sqrt(2)*s/sqrt(pi)) - sqrt(2)*fresnel_cos(1/2*sqrt(2)*s/sqrt(pi))*sin(1/4*s^2) - cos(1/4*pi + 1/4*s^2)),
0,
True)
3 | No.3 Revision |
Sympy is used as an option for integration, sums, solving equations, for the Laplace function (and inverse), and perhaps more. Usually, the way to use it is with adding a algorithm = 'sympy'
option:
sage: integral(sin(x)^2, x)
1/2*x - 1/4*sin(2*x)
sage: integral(sin(x)^2, x, algorithm='sympy')
-1/2*cos(x)*sin(x) + 1/2*x
sage: var('k')
k
sage: sum(1/(1+k^2), k, -oo, oo)
-1/2*I*psi(I + 1) + 1/2*I*psi(-I + 1) - 1/2*I*psi(I) + 1/2*I*psi(-I)
sage: sum(1/(1+k^2), k, -oo, oo, algorithm = 'sympy')
pi/tanh(pi)
sage: solve(-2*x**3 + 4*x**2 - 2*x + 6 > 0, x)
[[x < 2.174559471365639]]
sage: solve(-2*x**3 + 4*x**2 - 2*x + 6 > 0, x, algorithm='sympy')
[x < 1/3*(1/2)^(1/3)*(9*sqrt(77) + 79)^(1/3) + 2/3*(1/2)^(2/3)/(9*sqrt(77) + 79)^(1/3) + 2/3]
sage: var('t, s')
(t, s)
sage: laplace(cos(t^2), t, s)
-(1/16*I - 1/16)*sqrt(2)*sqrt(pi)*cos(1/4*s^2)*erf(1/2*(-1)^(3/4)*s) - (1/16*I + 1/16)*sqrt(2)*sqrt(pi)*cos(1/4*s^2)*erf((1/4*I + 1/4)*sqrt(2)*s) - (1/16*I - 1/16)*sqrt(2)*sqrt(pi)*cos(1/4*s^2)*erf((1/4*I - 1/4)*sqrt(2)*s) - (1/16*I + 1/16)*sqrt(2)*sqrt(pi)*cos(1/4*s^2)*erf(1/2*I*sqrt(-I)*s) - (1/16*I + 1/16)*sqrt(2)*sqrt(pi)*erf(1/2*(-1)^(3/4)*s)*sin(1/4*s^2) - (1/16*I - 1/16)*sqrt(2)*sqrt(pi)*erf((1/4*I + 1/4)*sqrt(2)*s)*sin(1/4*s^2) - (1/16*I + 1/16)*sqrt(2)*sqrt(pi)*erf((1/4*I - 1/4)*sqrt(2)*s)*sin(1/4*s^2) - (1/16*I - 1/16)*sqrt(2)*sqrt(pi)*erf(1/2*I*sqrt(-I)*s)*sin(1/4*s^2) + 1/4*sqrt(2)*sqrt(pi)*cos(1/4*s^2) - 1/4*sqrt(2)*sqrt(pi)*sin(1/4*s^2)
sage: laplace(cos(t^2), t, s, algorithm='sympy')
(-1/2*sqrt(pi)*(sqrt(2)*cos(1/4*s^2)*fresnel_sin(1/2*sqrt(2)*s/sqrt(pi)) - sqrt(2)*fresnel_cos(1/2*sqrt(2)*s/sqrt(pi))*sin(1/4*s^2) - cos(1/4*pi + 1/4*s^2)),
0,
True)
Edit (answering some questions below)
regarding integration, various "algorithms" (a more appropriate wording would be "libraries" or "backends") are tested one after another until some provides an answer, hence sympy can be involved in the computation of some integrals even if you do not specify algorithm='sympy'
explicitely.
to search where sympy
is involved within Sage source code, you can open a terminal, go to the SAGE_ROOT/src/sage/
directory and run the command:
grep -R "sympy"
4 | No.4 Revision |
Sympy is used as an option for integration, sums, solving equations, for the Laplace function (and inverse), and perhaps more. Usually, the way to use it is with adding a algorithm = 'sympy'
option:
sage: integral(sin(x)^2, x)
1/2*x - 1/4*sin(2*x)
sage: integral(sin(x)^2, x, algorithm='sympy')
-1/2*cos(x)*sin(x) + 1/2*x
sage: var('k')
k
sage: sum(1/(1+k^2), k, -oo, oo)
-1/2*I*psi(I + 1) + 1/2*I*psi(-I + 1) - 1/2*I*psi(I) + 1/2*I*psi(-I)
sage: sum(1/(1+k^2), k, -oo, oo, algorithm = 'sympy')
pi/tanh(pi)
sage: solve(-2*x**3 + 4*x**2 - 2*x + 6 > 0, x)
[[x < 2.174559471365639]]
sage: solve(-2*x**3 + 4*x**2 - 2*x + 6 > 0, x, algorithm='sympy')
[x < 1/3*(1/2)^(1/3)*(9*sqrt(77) + 79)^(1/3) + 2/3*(1/2)^(2/3)/(9*sqrt(77) + 79)^(1/3) + 2/3]
sage: var('t, s')
(t, s)
sage: laplace(cos(t^2), t, s)
-(1/16*I - 1/16)*sqrt(2)*sqrt(pi)*cos(1/4*s^2)*erf(1/2*(-1)^(3/4)*s) - (1/16*I + 1/16)*sqrt(2)*sqrt(pi)*cos(1/4*s^2)*erf((1/4*I + 1/4)*sqrt(2)*s) - (1/16*I - 1/16)*sqrt(2)*sqrt(pi)*cos(1/4*s^2)*erf((1/4*I - 1/4)*sqrt(2)*s) - (1/16*I + 1/16)*sqrt(2)*sqrt(pi)*cos(1/4*s^2)*erf(1/2*I*sqrt(-I)*s) - (1/16*I + 1/16)*sqrt(2)*sqrt(pi)*erf(1/2*(-1)^(3/4)*s)*sin(1/4*s^2) - (1/16*I - 1/16)*sqrt(2)*sqrt(pi)*erf((1/4*I + 1/4)*sqrt(2)*s)*sin(1/4*s^2) - (1/16*I + 1/16)*sqrt(2)*sqrt(pi)*erf((1/4*I - 1/4)*sqrt(2)*s)*sin(1/4*s^2) - (1/16*I - 1/16)*sqrt(2)*sqrt(pi)*erf(1/2*I*sqrt(-I)*s)*sin(1/4*s^2) + 1/4*sqrt(2)*sqrt(pi)*cos(1/4*s^2) - 1/4*sqrt(2)*sqrt(pi)*sin(1/4*s^2)
sage: laplace(cos(t^2), t, s, algorithm='sympy')
(-1/2*sqrt(pi)*(sqrt(2)*cos(1/4*s^2)*fresnel_sin(1/2*sqrt(2)*s/sqrt(pi)) - sqrt(2)*fresnel_cos(1/2*sqrt(2)*s/sqrt(pi))*sin(1/4*s^2) - cos(1/4*pi + 1/4*s^2)),
0,
True)
Edit (answering some questions below)
regarding integration, by default various "algorithms" (a more appropriate wording would be "libraries" or "backends") are tested one after another until some provides an answer, hence sympy can be involved in the computation of some integrals even if you do not specify algorithm='sympy'
explicitely.
to search where sympy
is involved within Sage source code, you can open a terminal, go to the SAGE_ROOT/src/sage/
directory and run the command:
grep -R "sympy"