Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
some more easy doctest fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dimpase committed Oct 28, 2016
1 parent a4bf716 commit 62b5825
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/sage/combinat/combinat.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def euler_number(n, algorithm='flint'):
sage: [euler_number(i) for i in range(10)]
[1, 0, -1, 0, 5, 0, -61, 0, 1385, 0]
sage: maxima.eval("taylor (2/(exp(x)+exp(-x)), x, 0, 10)")
'1-x^2/2+5*x^4/24-61*x^6/720+277*x^8/8064-50521*x^10/3628800'
'1-x^2/2+(5*x^4)/24-(61*x^6)/720+(277*x^8)/8064-(50521*x^10)/3628800'
sage: [euler_number(i)/factorial(i) for i in range(11)]
[1, 0, -1/2, 0, 5/24, 0, -61/720, 0, 277/8064, 0, -50521/3628800]
sage: euler_number(-1)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/functions/trig.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ def __init__(self):
This is consistent with Python and Maxima::
sage: maxima.atan2(1,-1)
3*%pi/4
(3*%pi)/4
sage: math.atan2(1,-1)
2.356194490192345
Expand Down
4 changes: 2 additions & 2 deletions src/sage/interfaces/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,9 +1290,9 @@ def _add_(self, right):
The Maxima variable ``x`` is different from the Sage symbolic variable::
sage: (f+maxima.cos(x))
cos(_SAGE_VAR_x)+sin(x)
sin(x)+cos(_SAGE_VAR_x)
sage: (f+maxima.cos(y))
cos(_SAGE_VAR_y)+sin(x)
sin(x)+cos(_SAGE_VAR_y)
Note that you may get unexpected results when calling symbolic expressions
and not explicitly giving the variables::
Expand Down
32 changes: 16 additions & 16 deletions src/sage/interfaces/maxima.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
sage: f.expand()
x^6*y^3+9*x^4*y^3+27*x^2*y^3+27*y^3+3*x^5*y^2+18*x^3*y^2+27*x*y^2+3*x^4*y+9*x^2*y+x^3
sage: f.subst('x=5/z')
(5/z+25*y/z^2+3*y)^3
(5/z+(25*y)/z^2+3*y)^3
sage: g = f.subst('x=5/z')
sage: h = g.ratsimp(); h
(27*y^3*z^6+135*y^2*z^5+(675*y^3+225*y)*z^4+(2250*y^2+125)*z^3+(5625*y^3+1875*y)*z^2+9375*y^2*z+15625*y^3)/z^6
Expand All @@ -161,19 +161,19 @@
sage: eqn = maxima(['a+b*c=1', 'b-a*c=0', 'a+b=5'])
sage: s = eqn.solve('[a,b,c]'); s
[[a=(25*sqrt(79)*%i+25)/(6*sqrt(79)*%i-34),b=(5*sqrt(79)*%i+5)/(sqrt(79)*%i+11),c=(sqrt(79)*%i+1)/10],[a=(25*sqrt(79)*%i-25)/(6*sqrt(79)*%i+34),b=(5*sqrt(79)*%i-5)/(sqrt(79)*%i-11),c=-(sqrt(79)*%i-1)/10]]
[[a=50/(sqrt(79)*%i+11),b=(5*sqrt(79)*%i+5)/(sqrt(79)*%i+11),c=(sqrt(79)*%i+1)/10],[a=-50/(sqrt(79)*%i-11),b=(5*sqrt(79)*%i-5)/(sqrt(79)*%i-11),c=-(sqrt(79)*%i-1)/10]]
Here is an example of solving an algebraic equation::
sage: maxima('x^2+y^2=1').solve('y')
[y=-sqrt(1-x^2),y=sqrt(1-x^2)]
sage: maxima('x^2 + y^2 = (x^2 - y^2)/sqrt(x^2 + y^2)').solve('y')
[y=-sqrt((-y^2-x^2)*sqrt(y^2+x^2)+x^2),y=sqrt((-y^2-x^2)*sqrt(y^2+x^2)+x^2)]
[y=-sqrt(((-y^2)-x^2)*sqrt(y^2+x^2)+x^2),y=sqrt(((-y^2)-x^2)*sqrt(y^2+x^2)+x^2)]
You can even nicely typeset the solution in latex::
sage: latex(s)
\left[ \left[ a={{25\,\sqrt{79}\,i+25}\over{6\,\sqrt{79}\,i-34}} , b={{5\,\sqrt{79}\,i+5}\over{\sqrt{79}\,i+11}} , c={{\sqrt{79}\,i+1 }\over{10}} \right] , \left[ a={{25\,\sqrt{79}\,i-25}\over{6\, \sqrt{79}\,i+34}} , b={{5\,\sqrt{79}\,i-5}\over{\sqrt{79}\,i-11}} , c=-{{\sqrt{79}\,i-1}\over{10}} \right] \right]
\left[ \left[ a={{50}\over{\sqrt{79}\,i+11}} , b={{5\,\sqrt{79}\,i+ 5}\over{\sqrt{79}\,i+11}} , c={{\sqrt{79}\,i+1}\over{10}} \right] , \left[ a=-{{50}\over{\sqrt{79}\,i-11}} , b={{5\,\sqrt{79}\,i-5 }\over{\sqrt{79}\,i-11}} , c=-{{\sqrt{79}\,i-1}\over{10}} \right] \right]
To have the above appear onscreen via ``xdvi``, type
``view(s)``. (TODO: For OS X should create pdf output
Expand All @@ -199,7 +199,7 @@
sage: f.diff('x')
k*x^3*%e^(k*x)*sin(w*x)+3*x^2*%e^(k*x)*sin(w*x)+w*x^3*%e^(k*x)*cos(w*x)
sage: f.integrate('x')
(((k*w^6+3*k^3*w^4+3*k^5*w^2+k^7)*x^3+(3*w^6+3*k^2*w^4-3*k^4*w^2-3*k^6)*x^2+(-18*k*w^4-12*k^3*w^2+6*k^5)*x-6*w^4+36*k^2*w^2-6*k^4)*%e^(k*x)*sin(w*x)+((-w^7-3*k^2*w^5-3*k^4*w^3-k^6*w)*x^3+(6*k*w^5+12*k^3*w^3+6*k^5*w)*x^2+(6*w^5-12*k^2*w^3-18*k^4*w)*x-24*k*w^3+24*k^3*w)*%e^(k*x)*cos(w*x))/(w^8+4*k^2*w^6+6*k^4*w^4+4*k^6*w^2+k^8)
(((k*w^6+3*k^3*w^4+3*k^5*w^2+k^7)*x^3+(3*w^6+3*k^2*w^4-3*k^4*w^2-3*k^6)*x^2+((-18*k*w^4)-12*k^3*w^2+6*k^5)*x-6*w^4+36*k^2*w^2-6*k^4)*%e^(k*x)*sin(w*x)+(((-w^7)-3*k^2*w^5-3*k^4*w^3-k^6*w)*x^3+(6*k*w^5+12*k^3*w^3+6*k^5*w)*x^2+(6*w^5-12*k^2*w^3-18*k^4*w)*x-24*k*w^3+24*k^3*w)*%e^(k*x)*cos(w*x))/(w^8+4*k^2*w^6+6*k^4*w^4+4*k^6*w^2+k^8)
::
Expand All @@ -208,12 +208,12 @@
1
sage: g = maxima('f/sinh(k*x)^4')
sage: g.taylor('x', 0, 3)
f/(k^4*x^4)-2*f/(3*k^2*x^2)+11*f/45-62*k^2*f*x^2/945
x+x^3/6+(3*x^5)/40+(5*x^7)/112+(35*x^9)/1152
::
sage: maxima.taylor('asin(x)','x',0, 10)
x+x^3/6+3*x^5/40+5*x^7/112+35*x^9/1152
x+x^3/6+(3*x^5)/40+(5*x^7)/112+(35*x^9)/1152
Examples involving matrices
---------------------------
Expand Down Expand Up @@ -253,7 +253,7 @@
sage: _ = maxima.eval("f(t) := t*sin(t)")
sage: maxima("laplace(f(t),t,s)")
2*s/(s^2+1)^2
(2*s)/(s^2+1)^2
::
Expand All @@ -270,7 +270,7 @@
sage: _ = maxima.eval("f(t) := t^5*exp(t)*sin(t)")
sage: maxima("laplace(f(t),t,s)")
360*(2*s-2)/(s^2-2*s+2)^4-480*(2*s-2)^3/(s^2-2*s+2)^5+120*(2*s-2)^5/(s^2-2*s+2)^6
(360*(2*s-2))/(s^2-2*s+2)^4-(480*(2*s-2)^3)/(s^2-2*s+2)^5+(120*(2*s-2)^5)/(s^2-2*s+2)^6
sage: print(maxima("laplace(f(t),t,s)"))
3 5
360 (2 s - 2) 480 (2 s - 2) 120 (2 s - 2)
Expand All @@ -286,17 +286,17 @@
::
sage: maxima("laplace(diff(x(t),t,2),t,s)")
-%at('diff(x(t),t,1),t=0)+s^2*'laplace(x(t),t,s)-x(0)*s
(-%at('diff(x(t),t,1),t=0))+s^2*'laplace(x(t),t,s)-x(0)*s
It is difficult to read some of these without the 2d
representation::
sage: print(maxima("laplace(diff(x(t),t,2),t,s)"))
!
d ! 2
- -- (x(t))! + s laplace(x(t), t, s) - x(0) s
dt !
!t = 0
!
d ! 2
(- -- (x(t))! ) + s laplace(x(t), t, s) - x(0) s
dt !
!t = 0
Even better, use
``view(maxima("laplace(diff(x(t),t,2),t,s)"))`` to see
Expand Down Expand Up @@ -679,7 +679,7 @@ def _expect_expr(self, expr=None, timeout=None):
sage: maxima.assume('a>0')
[a>0]
sage: maxima('integrate(1/(x^3*(a+b*x)^(1/3)),x)')
-b^2*log((b*x+a)^(2/3)+a^(1/3)*(b*x+a)^(1/3)+a^(2/3))/(9*a^(7/3))+2*b^2*atan((2*(b*x+a)^(1/3)+a^(1/3))/(sqrt(3)*a^(1/3)))/(3^(3/2)*a^(7/3))+2*b^2*log((b*x+a)^(1/3)-a^(1/3))/(9*a^(7/3))+(4*b^2*(b*x+a)^(5/3)-7*a*b^2*(b*x+a)^(2/3))/(6*a^2*(b*x+a)^2-12*a^3*(b*x+a)+6*a^4)
(-(b^2*log((b*x+a)^(2/3)+a^(1/3)*(b*x+a)^(1/3)+a^(2/3)))/(9*a^(7/3)))+(2*b^2*atan((2*(b*x+a)^(1/3)+a^(1/3))/(sqrt(3)*a^(1/3))))/(3^(3/2)*a^(7/3))+(2*b^2*log((b*x+a)^(1/3)-a^(1/3)))/(9*a^(7/3))+(4*b^2*(b*x+a)^(5/3)-7*a*b^2*(b*x+a)^(2/3))/(6*a^2*(b*x+a)^2-12*a^3*(b*x+a)+6*a^4)
sage: maxima('integrate(x^n,x)')
Traceback (most recent call last):
...
Expand Down

0 comments on commit 62b5825

Please sign in to comment.