ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 22 Nov 2020 03:56:58 -0600Maxima needs a change of variable to succeed in an integralhttps://ask.sagemath.org/question/54347/maxima-needs-a-change-of-variable-to-succeed-in-an-integral/Hi
maxima is not able to integrate this below:
#solExt_0(y)=(((R^2-y^2)*asin(x/(sqrt(R-y)*sqrt(y+R)))+x*sqrt((-y^2)-x^2+R^2))/2 ).subs(x==-sqrt(2*R*y - 2*y^2))
#solExt_1(y)=(((R^2-y^2)*asin(x/(sqrt(R-y)*sqrt(y+R)))+x*sqrt((-y^2)-x^2+R^2))/2 ).subs(x==sqrt(2*R*y - 2*y^2))
#solExt=solExt_1-solExt_0
#show('must give : ',solExt )
var('x,y,R,T',domain='real')
Rnum=1
numL=[R==Rnum]
assume(T>0)
assume(T<=R)
#assume((y-R)*(y+R)<=0)
Iz=sqrt(R^2-y^2 - x^2)
xLow=-sqrt(2*R*y - 2*y^2)
xUp=sqrt(2*R*y - 2*y^2)
show(LatexExpr(r"\int_{"+"}^{"+"} "+latex(Iz))+"dx")
IxT=integrate(Iz(x),x,xLow,xUp)
but succeed with a variable change :
var('x,y,R,T',domain='real')
Rnum=1
numL=[R==Rnum]
assume(T>0)
assume(T<=R)
Iz(x)=sqrt(T - x^2)
xLow=-sqrt(2*R*y - 2*y^2)
xUp=sqrt(2*R*y - 2*y^2)
IxT=integrate(Iz(x),x)
Ix=(IxT.subs(T==R^2-y^2))
show(LatexExpr(r"\int_{"+latex(xLow)+"}^{"+latex(xUp)+"} "+latex(Iz.subs(T==R^2-y^2))+" = "+latex(Ix)))
but may be I need to add some assumes command for the 1st code?ortolljSun, 22 Nov 2020 03:56:58 -0600https://ask.sagemath.org/question/54347/solve maxima need to prechew equ to succeed (solve sympy ok)https://ask.sagemath.org/question/53100/solve-maxima-need-to-prechew-equ-to-succeed-solve-sympy-ok/ HI
Ubuntu 18.04 , Jupyter notebook SageMath 9.1
vL=['x','y','x_o','y_o','a','b']
varL=var(vL)
for v in varL :
assume(v,'real')
eq02=y - y_o == -b^2*(x - x_o)*x/(a^2*y)
eq2=x^2/a^2 + y^2/b^2 == 1
# here I need to prechew
eq03=eq02.multiply_both_sides(y/b^2).expand()
SmaximaPrechewed=solve([eq03,eq2],x,y)
show("solution maxima ok prechewed : ",SmaximaPrechewed)
SsympyNotPrechewed=solve([eq02,eq2],x,y,algorithm='sympy')
show("solution sympy ok : ",SsympyNotPrechewed)
SmaximaNotPrechewedKO=solve([eq02,eq2],x,y,algorithm='maxima')
show("solution maxima not preChewed KO : ",SmaximaNotPrechewedKO)ortolljWed, 19 Aug 2020 01:29:03 -0500https://ask.sagemath.org/question/53100/Stack overflow during symbolic manipulationshttps://ask.sagemath.org/question/52986/stack-overflow-during-symbolic-manipulations/I'm trying to evaluate this cursed integral (finite for $ 0 < a < 1 $):
$$\int_0^1 \frac{x}{\log{\left(ax+(1-x)^2\right)}}{\rm d}x$$
using Sagemath 9.0 and 9.1:
sage: a = var('a')
sage: assume(a>0)
sage: assume(a<1)
sage: f = integrate(x*log(1/(a*x+(1-x)^2)), x, 0, 1)
leads to
RuntimeError: ECL says: C-STACK overflow at size 1048576. Stack can probably be resized. Proceed with caution.
Sympy gives a result even without the assumptions (which is odd by itself):
sage: f = integrate(x*log(1/(a*x+(1-x)*(1-x))), x, 0, 1, algorithm='sympy')
$$\frac{1}{4} \{\left(a^{2} + \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 2\right)} \log\left(\frac{a^{2} + \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 4}{2 {\left(a - 2\right)}} + 1\right) - \frac{1}{4} {\left(a^{2} + \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 2\right)} \log\left(\frac{a^{2} + \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 4}{2 {\left(a - 2\right)}}\right) + \frac{1}{4} \{\left(a^{2} - \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 2\right)} \log\left(\frac{a^{2} - \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 4}{2 {\left(a - 2\right)}} + 1\right) - \frac{1}{4} {\left(a^{2} - \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 2\right)} \log\left(\frac{a^{2} - \sqrt{{\left(a - 4\right)} a} {\left(a - 2\right)} - 4 a + 4}{2 {\left(a - 2\right)}}\right) - \frac{1}{2} a + \frac{1}{2} \log\left(\frac{1}{a}\right) + \frac{3}{2}$$
But then problems continue:
sage: f.simplify_full()
RuntimeError: ECL says: C-STACK overflow at size 1048576. Stack can probably be resized. Proceed with caution.
But:
sage: f.expand().simplify_full()
$$
-\frac{1}{2} {\left(2 \pi - {\left(\pi - \arctan\left(\frac{\sqrt{-a + 4}}{\sqrt{a}}\right) + \arctan\left(\frac{\sqrt{a} \sqrt{-a + 4}}{a - 2}\right)\right)} a - 2 \arctan\left(\frac{\sqrt{-a + 4}}{\sqrt{a}}\right) + 2 \arctan\left(\frac{\sqrt{a} \sqrt{-a + 4}}{a - 2}\right)\right)} \sqrt{a} \sqrt{-a + 4} + \frac{1}{4} {\left(a^{2} - 4 a\right)} \log\left(a\right) - \frac{1}{2} a + \frac{3}{2}
$$
If I want to find the limit when $a\to 0$:
sage: f.limit(a=0)
RuntimeError: ECL says: C-STACK overflow at size 1048576. Stack can probably be resized. Proceed with caution.
and once again
sage: f.limit(a=0, algorithm="sympy")
$$-i \pi + \frac{3}{2}$$
Which is only true for $a<0$.
I previously found [this strange bug](https://ask.sagemath.org/question/48058/stack-overflow-in-boolean-test/) a while ago (fixed upstream, still present in Sagemath 9.1), this makes me think the assumption `assume(a>0)` is the root of it all, unfortunately it cannot be skipped to evaluate the integral properly.
Do you know when the updated version of Maxima will be included with Sagemath?
Do you think all these issues are linked to this old ticket or should it be investigated independently?
Florentin JaffredoThu, 13 Aug 2020 11:13:05 -0500https://ask.sagemath.org/question/52986/How to solve a differential equation of degree 5https://ask.sagemath.org/question/50475/how-to-solve-a-differential-equation-of-degree-5/I tried to solve this equation of degree 5:
$$\dfrac{d^{5}y}{dx^{5}}+5\dfrac{d^{4}y}{dx^{4}}-2\dfrac{d^{3}y}{dx^{3}}-10\dfrac{d^{2}y}{dx^{2}}+\dfrac{dy}{dx}+5y=0$$
with the following code:
x = var('x')
y = function('y')(x)
ED = diff(y,x,5)+5*diff(y,x,4)-2*diff(y,x,3)-10*diff(y,x,2)+diff(y,x)+5*y == 0
desolve(ED,y,contrib_ode=true).show()
This gave the following error:
NotImplementedError Traceback (most recent call last)
<ipython-input-9-c048996b444c> in <module>()
2 y = function('y')(x)
3 ED = diff(y,x,Integer(5))+Integer(5)*diff(y,x,Integer(4))-Integer(2)*diff(y,x,Integer(3))-Integer(10)*diff(y,x,Integer(2))+diff(y,x)+Integer(5)*y == Integer(0)
----> 4 desolve(ED,y,contrib_ode=true).show()
/opt/sagemath-8.6/local/lib/python2.7/site-packages/sage/calculus/desolvers.pyc in desolve(de, dvar, ics, ivar, show_method, contrib_ode, algorithm)
593 soln = P(cmd)
594 if str(soln).strip() == 'false':
--> 595 raise NotImplementedError("Maxima was unable to solve this ODE.")
596 else:
597 raise NotImplementedError("Maxima was unable to solve this ODE. Consider to set option contrib_ode to True.")
NotImplementedError: Maxima was unable to solve this ODE.
How can I solve that?SamuelThu, 02 Apr 2020 16:17:04 -0500https://ask.sagemath.org/question/50475/Wehre can i download maxima?https://ask.sagemath.org/question/47817/wehre-can-i-download-maxima/Can someone tell me where i can download maxima?di.namTue, 10 Sep 2019 09:01:55 -0500https://ask.sagemath.org/question/47817/How to increase ECL/maxima memory limits in SageMath?https://ask.sagemath.org/question/47203/how-to-increase-eclmaxima-memory-limits-in-sagemath/ I am looking for a symbolic solution of a linear system 10x10. The coefficients and the right-hand sides are symbolic expressions, and it is critical for my. After one hour run with ~5 GB memory consumption I get an error message:
"TypeError: ECL says: Memory limit reached. Please jump to an outer pointer, quit program and enlarge the memory limits before executing the program again."
My Windows-10 PC has 64 GB, so it is definitely not the physical memory limitation. According to my Google search results, there are deliberately tight default memory limits in the Embeddable Common Lisp (ECL), which is used in Maxima. This page
"https://trac.sagemath.org/ticket/6772"
suggests to increase the ECL heap size to 1 GB by adding a line
"(ext:set-limit 'ext:heap-size (* 1024 1024 1024))"
to the file "maxima/src/ecl-port.lisp". I have found this file under "C:\Program Files\SageMath 8.7\runtime\opt\sagemath-8.7\local\share\maxima\5.41.0\src" and added such line with the 8 GB limit (* 2048 2048 2048). This had absolutely no effect, the same error message appeared after the same run time.
I see two such questions answered in this forum. However both answers suggest to reformulate the original problem, which is not what I need. I will appreciate an explanation of how to increase the ECL memory limits in SageMath. Is there something like ".eclrc" configuration file in SageMath? May be, I have to install Maxima standalone and try it there?SevasThu, 18 Jul 2019 04:15:50 -0500https://ask.sagemath.org/question/47203/Is it possible to load a Maxima package into Sagemath?https://ask.sagemath.org/question/47129/is-it-possible-to-load-a-maxima-package-into-sagemath/ Hi,
I'm a Maxima user but I'm considering to start using SageMath. I need to work with Dirac matrices and there is a nice package for Maxima in this area. Is is possible to load a Maxima package into SageMath and use it ?
Thanks
AlfonsoAlfThu, 11 Jul 2019 19:41:33 -0500https://ask.sagemath.org/question/47129/Solutions step by step in sagemath with maximahttps://ask.sagemath.org/question/45586/solutions-step-by-step-in-sagemath-with-maxima/I know that maxima can show step by step solution of integral and maxima is also used inside sagemath in CoCalc. How can I show step by step solution in Cocalc?) and maxima is also used inside sagemath in CoCalc. How can I show step by step solution in Cocalc?asvFri, 01 Mar 2019 05:30:13 -0600https://ask.sagemath.org/question/45586/Combine plots with built-in Maxima, trajectory in Sage available?https://ask.sagemath.org/question/44995/combine-plots-with-built-in-maxima-trajectory-in-sage-available/I want to combine the following plots as one output figure:
maxima('plotdf(4*y/x+x*sqrt(y),[trajectory_at,1,1],[x,0,4],[y,0,10])')
maxima('plot2d(1/4*x^4*(log(x)+2)^2,[x,0,4],[y,0,10])')
How can I achieve that? However, if there is any way to output a trajectory by Sage directly, I would be very happy. With pure Sage, I've just achieved this so far:
plot_slope_field(4*y/x+x*sqrt(y),(x,0,4),(y,0,10),headaxislength=3,headlength=3)ThrashThu, 10 Jan 2019 13:45:43 -0600https://ask.sagemath.org/question/44995/Sage could be even more clever - How to force the use of 'sympy' backend for simplifying symbolic integrals?https://ask.sagemath.org/question/43392/sage-could-be-even-more-clever-how-to-force-the-use-of-sympy-backend-for-simplifying-symbolic-integrals/Hi there,
I have noticed the following problem:
sage: f = function('f')(x)
sage: var('h')
sage: integrate(exp(h)*exp(x)*f(x),x)
integrate(e^(h + x)*f(x), x)
The workaround seems to be using the `sympy` backend for symbolic integration
sage: integrate(exp(h)*exp(x)*f(x),x,algorithm='sympy')
e^h*integrate(e^x*f(x), x)
which always seems to be a good idea as I learned from @Emmanuel Charpentier over
[here](https://ask.sagemath.org/question/43287/solved-why-does-integratepsiyfyy-return-an-error-but-integratepsityftyy-works/?answer=43297#post-id-43297).
Now I would like to force the use of `algorith='sympy'` for simplifying these `integrate(...)` expressions globally.
Unfortunately, the `simplify()` command does not allow to set this option.
sage: integrate(exp(h)*exp(x)*f(x),x)
integrate(e^(h + x)*f(x), x)
sage: _.simplify()
integrate(e^(h + x)*f(x), x)
**TL;DR** How can I force sage to pull out these type of exponential constants from the integral with the `simplify()` command?
hausdorffThu, 16 Aug 2018 11:54:20 -0500https://ask.sagemath.org/question/43392/integrate results that are different from using maximahttps://ask.sagemath.org/question/43088/integrate-results-that-are-different-from-using-maxima/Update
------
Thanks to comment below by @rburing, it turned out to be the following setting `load(abs_integrate)` which sagemath is applying before calling Maxima that is causing this problem.
Maxima 5.41.0 http://maxima.sourceforge.net
using Lisp ECL 16.1.2
(%i1) domain:complex;
(%o1) complex
(%i2) display2d : false;
(%o2) false
(%i3) integrate (x*sqrt (cos (b*x + a)), x);
(%o3) 'integrate(x*sqrt(cos(b*x+a)),x)
(%i4) load(abs_integrate);
ARRSTORE: use_fast_arrays=false; allocate a new property hash table for $INTABLE2
(%o4) "/usr/share/maxima/5.41.0/share/contrib/integration/abs_integrate.mac"
(%i5) integrate (x*sqrt (cos (b*x + a)), x);
(%o5) (((1260*(b*x+a)*sin((5*(b*x+a))/2)+504*cos((5*(b*x+a))/2)
+2100*(b*x+a)*sin((3*(b*x+a))/2)
+1400*cos((3*(b*x+a))/2))
*false
-225*sin((7*(b*x+a))/2)+315*sin((5*(b*x+a))/2)+525*sin((3*(b*x+a))/2)
-1575*sin((b*x+a)/2))
/(1575*2^(5/2))
-(a*((6*sin((5*(b*x+a))/2)+10*sin((3*(b*x+a))/2))*false
-5*sin((3*(b*x+a))/2)+15*sin((b*x+a)/2)))
/(15*2^(3/2)))
/b^2
(%i6)
Therefore the question now becomes this: How could one tell Maxima, from inside SageMath to reverse the effect of the command `load(abs_integrate)`, since this is causing wrong antiderivatives to be generated in these cases. And what is the reason SageMath selected to set these settings before calling Maxima?
Or is there a way a user can control these settings that SageMath is issuing under the cover before using Maxima integrate?
ps. I do not know where the word `false` came from in the above antiderivative. This seems like a bug in Maxima, as it does not show in SageMath result.
Original question
-----------------
Hello;
I was going to make a bug entry on this, but thought to first check with the experts here, as I have a feeling I am missing something basic or making some mistake as I am newbie in SageMath and Maxima as well.
I am getting number of wrong antiderivatives from Sagemath intergate, using default algorithm (which should be Maxima), compared to using Maxima itself for same integral.
Using Maxima (and making sure to set domain to complex first), Maxima returns unevaluated for the same command, which is actually is the correct result, since these integrals are supposed to be non integrable and meant to test to see if CAS can determine this. However, sagemath, does return an antiderivative from Maxima.
Could someone please explain how sagemath managed to return such results, and from where it obtained it since Maxima itself does not return this result? In addition, I verified the SageMath result, and they all fail the verification I did.
Here are few examples of many I have:
Example 1
---------
SageMath version 8.3.rc1, Release Date: 2018-07-14
sage: var('x e a b f c d m');
sage: integrate ((d*sin (f*x + e) + c)^(3/2)*(b*sin (f*x + e) + a)^m, x)
1/9*(c^3*sin(9/2*f*x + 9/2*e) - 3*c^3*sin(3/2*f*x + 3/2*e))*2^(-m - 5/2)/f
The above is clearly wrong, since the anti dropped/missing the parameters `d,a,b` in the integrand.
in Maxima
Maxima 5.41.0 http://maxima.sourceforge.net
using Lisp ECL 16.1.2
(%i1) domain:complex$
(%i2) domain;
(%o2) complex
(%i3) integrate ((d*sin (f*x + e) + c)^(3/2)*(b*sin (f*x + e) + a)^m, x);
/
[ m 3/2
(%o3) I (b sin(f x + e) + a) (d sin(f x + e) + c) dx
]
/
Example 2
---------
sage: integrate(sqrt(d*sin (f*x + e) + c)*(b*sin (f*x + e) + a)^m, x,algorithm="maxima")
1/3*(c*sin(3/2*f*x + 3/2*e) - 3*c*sin(1/2*f*x + 1/2*e))*2^(-m - 3/2)/f
The above is clearly wrong, since the anti dropped/missing the parameters `d,a,b` in the integrand.
Using Maxima
(%i7) integrate (sqrt (d*sin (f*x + e) + c)*(b*sin (f*x + e) + a)^m, x);
/
[ m
(%o7) I (b sin(f x + e) + a) sqrt(d sin(f x + e) + c) dx
]
/
The above is the correct result, since this integral is supposed to be non integrable.
Example 3
---------
sage: integrate (x*sqrt (cos (b*x + a)), x,algorithm="maxima")
1/840*(70*sqrt(2)*a*(sin(3/2*b*x + 3/2*a) - 3*sin(1/2*b*x + 1/2*a)) - sqrt(2)*(15*sin(7/2*b*x + 7/2*a) - 21*sin(5/2*b*x + 5/2*a) - 35*sin(3/2*b*x + 3/2*a) + 105*sin(1/2*b*x + 1/2*a)))/b^2
The above result did not verify by differentiating the antiderivative.
Using Maxima
(%i9) integrate (x*sqrt (cos (b*x + a)), x);
/
[
(%o9) I x sqrt(cos(b x + a)) dx
]
/
The above is the correct result, since this integral is supposed to be non integrable.
example 4
---------
sage: integrate(x*cos(b*x + a)^(3/2), x, algorithm="maxima")
1/349920*(243*sqrt(2)*a*(3*sin(15/2*b*x + 15/2*a) + 5*sin(9/2*b*x + 9/2*a) - 30*sin(3/2*b*x + 3/2*a)) - 20*sqrt(2)*(2*(81*(b*x + a)^2 - 8)*cos(9/2*b*x + 9/2*a) - 162*(9*(b*x + a)^2 - 8)*cos(3/2*b*x + 3/2*a) + 9*(27*(b*x + a)^3 - 8*b*x - 8*a)*sin(9/2*b*x + 9/2*a) - 243*(3*(b*x + a)^3 - 8*b*x - 8*a)*sin(3/2*b*x + 3/2*a)))/b^2
The above result did not verify by differentiating the antiderivative.
Using Maxima
(%i10) integrate(x*cos(b*x + a)^(3/2), x);
/
[ 3/2
(%o10) I x cos(b x + a) dx
]
/
The above is the correct result, since this integral is supposed to be non integrable.
Example 5
---------
sage: integrate(cos (x)^(3/2)/x^3, x, algorithm="maxima")
-9/512*sqrt(2)*(25*gamma(-2, 15/2*I*x) + 9*gamma(-2, 9/2*I*x) - 2*gamma(-2, 3/2*I*x) - 2*gamma(-2, -3/2*I*x) + 9*gamma(-2, -9/2*I*x) + 25*gamma(-2, -15/2*I*x))
The above result did not verify by differentiating the antiderivative.
Maxima:
(%i11) integrate (cos (x)^(3/2)/x^3, x);
/ 3/2
[ cos(x)
(%o11) I --------- dx
] 3
/ x
The above is the correct result, since this integral is supposed to be non integrable.
Example 6
---------
sage: integrate(cos(d*x + c)^(7/3)/sqrt(b*cos(d*x + c) + a), x,algorithm="maxima")
1/6366178138320*2^(1/6)*(61213251330*cos(13/2*d*x + 13/2*c) - 72342933390*cos(11/2*d*x + 11/2*c) - 82321269030*cos(29/6*d*x + 29/6*c) + 140430400110*cos(17/6*d*x + 17/6*c) - 217028800170*cos(11/6*d*x + 11/6*c) - 341045257410*cos(7/6*d*x + 7/6*c) + 23405066685*sin(17/2*d*x + 17/2*c) - 26525742243*sin(15/2*d*x + 15/2*c) - 29113619535*sin(41/6*d*x + 41/6*c) + 41160634515*sin(29/6*d*x + 29/6*c) - 44209570405*sin(9/2*d*x + 9/2*c) - 51898191345*sin(23/6*d*x + 23/6*c) + 56840876235*sin(7/2*d*x + 7/2*c) - 62824126365*sin(19/6*d*x + 19/6*c) + 70215200055*sin(17/6*d*x + 17/6*c) + 1193658400935*sin(1/6*d*x + 1/6*c))/(a*d)
The above result did not verify by differentiating the antiderivative.
Maxima:
(%i12) integrate (cos (d*x + c)^(7/3)/sqrt (b*cos (d*x + c) + a), x);
/ 7/3
[ cos(d x + c)
(%o12) I ------------------------ dx
] sqrt(b cos(d x + c) + a)
/
The above is the correct result, since this integral is supposed to be non integrable.
Example 7
---------
sage: integrate(cos(d*x + c)^(2/3)/sqrt(b*cos(d*x + c) + a), x,algorithm="maxima")
-1/54264*2^(5/6)*(1071*cos(19/6*d*x + 19/6*c) + 1197*cos(17/6*d*x + 17/6*c) - 2261*cos(3/2*d*x + 3/2*c) - 2907*cos(7/6*d*x + 7/6*c) + 6783*cos(1/2*d*x + 1/2*c) + 20349*cos(1/6*d*x + 1/6*c))/(a*d)
The above result did not verify by differentiating the antiderivative.
Maxima:
(%i13) integrate (cos (d*x + c)^(2/3)/sqrt (b*cos (d*x + c) + a), x);
/ 2/3
[ cos(d x + c)
(%o13) I ------------------------ dx
] sqrt(b cos(d x + c) + a)
/
The above is the correct result, since this integral is supposed to be non integrable.
Example 8
---------
sage: var('B A f x e b a c m')
(B, A, f, x, e, b, a, c, m)
sage: integrate((B*cos(f*x+e)+A)*(b*cos(f*x+e)+a)^(3/2)*(c*cos(f*x+e))^m,x)
1/3465*(385*(a^3*c^m*sin(9/2*f*x + 9/2*e) - 3*a^3*c^m*sin(3/2*f*x + 3/2*e))*2^(-m - 5/2)*A + 4*(231*a^3*sin(15/2*f*x + 15/2*e) + 630*a^3*sin(11/2*f*x + 11/2*e) - 770*a^3*sin(9/2*f*x + 9/2*e) + 495*a^3*sin(7/2*f*x + 7/2*e) - 2079*a^3*sin(5/2*f*x + 5/2*e) + 1155*a^3*sin(3/2*f*x + 3/2*e))*2^(-m - 13/2)*B)/f
The above result did not verify by differentiating the antiderivative.
Maxima:
(%i15) integrate((B*cos(f*x+e)+A)*(b*cos(f*x+e)+a)^(3/2)*(c*cos(f*x+e))^m,x);
/
[ m 3/2
(%o15) I (c cos(f x + e)) (B cos(f x + e) + A) (b cos(f x + e) + a) dx
]
/
The above is the correct result, since this integral is supposed to be non integrable.
Example 9
---------
sage: integrate((B*cos(f*x+e)+A)*sqrt(b*cos(f*x+e)+a)*(c*cos(f*x+e))^m,x)
1/315*(105*(a*c^m*sin(3/2*f*x + 3/2*e) - 3*a*c^m*sin(1/2*f*x + 1/2*e))*2^(-m - 3/2)*A + (35*a*sin(9/2*f*x + 9/2*e) - 90*a*sin(7/2*f*x + 7/2*e) + 189*a*sin(5/2*f*x + 5/2*e) - 315*a*sin(3/2*f*x + 3/2*e) + 315*a*sin(1/2*f*x + 1/2*e))*2^(-m - 7/2)*B)/f
The above result did not verify by differentiating the antiderivative.
Maxima:
(%i16) integrate((B*cos(f*x+e)+A)*sqrt(b*cos(f*x+e)+a)*(c*cos(f*x+e))^m,x);
/
[ m
(%o16) I (c cos(f x + e)) (B cos(f x + e) + A) sqrt(b cos(f x + e) + a) dx
]
/
The above is the correct result, since this integral is supposed to be non integrable.
Example 10
----------
sage: integrate((B*cos(f*x+e)+A)*(b*cos(f*x+e)+a)^(3/2)*(c*sec(f*x+e))^m,x)
-1/2520*sqrt(2)*(35*2^m*A^3*a*sin(9/2*f*x + 9/2*e) + 630*(A^3*B - A^3*a)*2^m*log(cos(1/2*f*x + 1/2*e)^2 + sin(1/2*f*x + 1/2*e)^2 + 2*sin(1/2*f*x + 1/2*e) + 1) - 630*(A^3*B - A^3*a)*2^m*log(cos(1/2*f*x + 1/2*e)^2 + sin(1/2*f*x + 1/2*e)^2 - 2*sin(1/2*f*x + 1/2*e) + 1) + 45*(2*A^3*B - A^3*a)*2^m*sin(7/2*f*x + 7/2*e) - 63*(2*A^3*B - 3*A^3*a)*2^m*sin(5/2*f*x + 5/2*e) + 105*(4*A^3*B - 5*A^3*a)*2^m*sin(3/2*f*x + 3/2*e) - 630*(4*A^3*B - 3*A^3*a)*2^m*sin(1/2*f*x + 1/2*e))/f
The above result did not verify by differentiating the antiderivative.
Maxima:
(%i17) integrate((B*cos(f*x+e)+A)*(b*cos(f*x+e)+a)^(3/2)*(c*sec(f*x+e))^m,x);
/
[ 3/2 m
(%o17) I (B cos(f x + e) + A) (b cos(f x + e) + a) (c sec(f x + e)) dx
]
/
The above is the correct result, since this integral is supposed to be non integrable.
Example 11
----------
sage: integrate((B*cos(f*x+e)+A)*sqrt(b*cos(f*x+e)+a)*(c*sec(f*x+e))^m,x)
1/40*(20*sqrt(2)*(2^m*a*c^m*log(cos(1/2*f*x + 1/2*e)^2 + sin(1/2*f*x + 1/2*e)^2 + 2*sin(1/2*f*x + 1/2*e) + 1) - 2^m*a*c^m*log(cos(1/2*f*x + 1/2*e)^2 + sin(1/2*f*x + 1/2*e)^2 - 2*sin(1/2*f*x + 1/2*e) + 1) - 2^(m + 1)*a*c^m*sin(1/2*f*x + 1/2*e))*A + sqrt(2)*(5*2^(m + 2)*a*log(cos(1/2*f*x + 1/2*e)^2 + sin(1/2*f*x + 1/2*e)^2 + 2*sin(1/2*f*x + 1/2*e) + 1) - 5*2^(m + 2)*a*log(cos(1/2*f*x + 1/2*e)^2 + sin(1/2*f*x + 1/2*e)^2 - 2*sin(1/2*f*x + 1/2*e) + 1) - 2^(m + 1)*a*sin(5/2*f*x + 5/2*e) + 5*2^(m + 1)*a*sin(3/2*f*x + 3/2*e) - 15*2^(m + 2)*a*sin(1/2*f*x + 1/2*e))*B)/f
The above result did not verify by differentiating the antiderivative.
Maxima:
(%i18) integrate((B*cos(f*x+e)+A)*sqrt(b*cos(f*x+e)+a)*(c*sec(f*x+e))^m,x);
/
[ m
(%o18) I (B cos(f x + e) + A) sqrt(b cos(f x + e) + a) (c sec(f x + e)) dx
]
/
The above is the correct result, since this integral is supposed to be non integrable.NasserFri, 20 Jul 2018 19:40:43 -0500https://ask.sagemath.org/question/43088/how to use domain:complex$ command in sagemath for maxima?https://ask.sagemath.org/question/43064/how-to-use-domaincomplex-command-in-sagemath-for-maxima/A Basic question:
I need to run integrals in maxima using sagemath, but I need to set the domain to complex first, since default in maxima is real domain.
In Maxima itself, the command is
domain: complex$
I am newbie in Maxima and sagemath and could not find the answer googling so far. What command should one issue, from inside sagemath, before calling integrate, to tell maxima to use complex domain? What is the syntax to use?
I do not want to use assume command on some specific symbols, but I want to tell maxima to use the complex domain for all symbols involved.
Thank youNasserWed, 18 Jul 2018 05:06:02 -0500https://ask.sagemath.org/question/43064/SAGE - How to load a .mac filehttps://ask.sagemath.org/question/42759/sage-how-to-load-a-mac-file/ Dear community, I'm aware that SAGE has maxima inside. Since I have a set of `.mac` files that allow me to compute quantities from *Quantum Field Theory*, I'd like to know if they can be loaded in a SAGE (jupyter) session... and How?DoxWed, 27 Jun 2018 13:06:58 -0500https://ask.sagemath.org/question/42759/difference between calling maxima lib and maxima processhttps://ask.sagemath.org/question/42656/difference-between-calling-maxima-lib-and-maxima-process/This question came up after reading answer here [timeout-does-not-work-with-maxima-ok-with-others/](https://ask.sagemath.org/question/42644/timeout-does-not-work-with-maxima-ok-with-others/)
So I thought to make new question.
Why does the following return back from maxima right away, without hanging (it is unevaluated integral, which is OK, since it could not do it) but sage does not hang
sage: var('x')
sage: r=maxima(sqrt(x^2 + 1)*arctan(x)^2)
sage: r.integrate(x)
'integrate(sqrt(_SAGE_VAR_x^2+1)*atan(_SAGE_VAR_x)^2,_SAGE_VAR_x)
But when doing the following, it hangs
sage: integrate(sqrt(x^2 + 1)*arctan(x)^2,x,algorithm="maxima")
I understand now that the first call was to the maxima process. While the second was to the maxim lib linked to sage process itself?
But should not the maxima code be the same? Then why does the first call not hang, while the second one does?
I have expected both to hang.
Using SageMath version 8.3.beta5, Release Date: 2018-06-09NasserMon, 18 Jun 2018 18:01:54 -0500https://ask.sagemath.org/question/42656/how to run maxima code in Sage?https://ask.sagemath.org/question/40184/how-to-run-maxima-code-in-sage/I have the following code in maxima to calculate the laplacian of a function in parabolic coordinates.
assume(r≥0)$
assume(theta≥0,theta≤2*π)$
load(vect)$
derivabbrev:true$
scalefactors(parabolic)$
declare(f,scalar)$
depends(f,rest(parabolic))$
ev(express(laplacian(f)),diff,expand,factor);
What is the proper way to run those Maxima commands in SageMath?
Thanks,
DanieldanielvolinskiSat, 16 Dec 2017 09:47:28 -0600https://ask.sagemath.org/question/40184/How to trace Maxima failureshttps://ask.sagemath.org/question/38266/how-to-trace-maxima-failures/I often hit the "Detected access to protected memory ..." failure from maxima. In some cases it seems to go into a loop whereupon I receive the same message hundreds of times. I know which sage worksheet cell is failing, but cannot find what it is about that cell which causes the failure, because maxima does not tell me.
Is it possible to set up the worksheet so that this error is trapped and triggers a stack trace in sage/python?
sage: version()
'SageMath version 7.6, Release Date: 2017-03-25'
sage: Parallelism().set(nproc=2)
sage: var('rho12,rho13,rho23', domain='real')
sage: assume(rho12>0, rho13>0, rho23>0)
sage: var('r12,r13,r23', domain='real')
sage: var('m1 m2 m3', domain='real')
sage: var('mu12,mu13,mu23', domain='real')
sage: ####
sage: #assume(m1>0, m2>0, m3>0) # !! This is a Maxima killer (even though physically required)!
sage: m1=1; m2=1; m3=1
sage: # !! With 'assume' above and with ANY m1,m2,m3 in SR, we seg-fault and core-dump when computing the connection.
sage: ####
sage: mu12 = (m1*m2)/(m1+m2); mu23 = (m2*m3)/(m2+m3); mu13 = (m1*m3)/(m1+m3)
sage: # Contravariant metric tensor, per Turbiner et al., arXiv:1611.08157.
sage: Ginv = matrix([[2/mu12*rho12, 1/m1*(rho12+rho13-rho23), 1/m2*(rho12+rho23-rho13)],\
... [1/m1*(rho12+rho13-rho23), 2/mu13*rho13, 1/m3*(rho13+rho23-rho12)],\
... [1/m2*(rho12+rho23-rho13), 1/m3*(rho13+rho23-rho12), 2/mu23*rho23]])
sage: G = Ginv.inverse();
sage: # Begin manifold creation
sage: M = Manifold(1*3,'R^3',field='real',start_index=1)
sage: U = M.open_subset('U')
sage: Rho.<rho12,rho13,rho23> = U.chart();
sage: Rho.add_restrictions([rho12>0, rho13>0, rho23>0])
sage: Rho.add_restrictions([sqrt(rho23)<sqrt(rho12)+sqrt(rho13),\
... sqrt(rho13)<sqrt(rho12)+sqrt(rho23), sqrt(rho12)<sqrt(rho13)+sqrt(rho23)])
...
sage: g = M.riemannian_metric('g');
sage: g[:] = G[:].simplify_full()
sage: ginv = g.inverse()
sage: ### This will seg-fault and core-dump if ANY m1,m2,m3 are in SR, and the 'assume' statement active.
sage: nabla = g.connection()
sage: # Turbiner calculates the Ricci scalar.
sage: ### Attempting to do so here causes seg fault if all m1,m2,m3=1!
sage: # (Is this because of singularities at all boundaries of rho-space?
sage: # (Regardless, code should *never* crash.)
sage: Ric_g = g.ricci_scalar()Richard_LFri, 14 Jul 2017 14:37:51 -0500https://ask.sagemath.org/question/38266/Interactive solving differential equations with MAXIMA's desolvehttps://ask.sagemath.org/question/37553/interactive-solving-differential-equations-with-maximas-desolve/I am using Maxima's "desolve" to handle a system of linear differential equations.
During processing, Maxima arrives at an intermediate expression (in my case this is a complicated argument of a sqareroot)
that may be positive, negative or zero. Maxima asks me interactively if this expression is negative, positive or zero.
If I use "desolve" directly within the Maxima's notebook, I can give my answer interactively
(e.g., "pos") to Maxima. Consequently, Maxima can continue processing immediately.
Thus, in Maxima's notebook there is no need to use an 'assume' statement that includes
the whole complicate expression in question.
On the contrary, processing this system via Maxima's 'desolve ' at a sage's notebook is very inconvenient,
since, according to sage's documentation, one can answer such questions only via assumes given prior to 'desolve'.
Moreover, in the treated case Maxima ignores such 'assume'-statements.
Thus, solving my equation system at Maxima via sage turns out to be impossible.
Thus my question: Is it really impossible to answer Maxima's interactive questions via sage?
If not, one should implement this feature in future save-versions.
This would enable sage to solve linear differential equations that cannot be treated by sage up to now.
Here is a simlpe executable example for interactive working with Maxima.
(Members of Maxima's discussion forum gave this example to me for demonstration)
I tried to answer this question interactively at a sage- notebook.
Unfortunately, This leads to a deadlock in the sage-platform (version 7.4).
(%i1) integrate(x^a,x);
Is a equal to -1?
no;
(%o1) x^(a+1)/(a+1)
bekalphTue, 09 May 2017 09:48:50 -0500https://ask.sagemath.org/question/37553/Integrating Green's function and plotting.https://ask.sagemath.org/question/37531/integrating-greens-function-and-plotting/ Hi,
I am trying to integrate product of two Green's functions and plot the results using Maxima. The problem is that Green's functions have singularities.
$ I=\int_{-\infty}^{+\infty}dxG1(x)G2(x)(F1(x)-F2(x))$
and
$ G1(x) = \frac{1}{ (x-0.1)+0.5+0.00001i} $
$ G2(x) = \frac{1}{ (x-0.1)+0.5-0.00001i} $
$ F1(x) = \frac{1}{ 1+e^{\frac{x}{0.2}}}$
$ F2(x) = \frac{1}{ 1+e^{\frac{x+0.4}{0.2}}}$
When I use wxMaxima (CAS), it fails to integrate and it fails to plot the solution y. I know that the solution plot should look like a smoothed step function where rising edge should be at x=0.1.
Any suggestions how to code wxMaxima is appreciated.quackeeSat, 06 May 2017 11:02:05 -0500https://ask.sagemath.org/question/37531/Computing Riemann connection fails in Maximahttps://ask.sagemath.org/question/37355/computing-riemann-connection-fails-in-maxima/ Set up manifold with Riemann metric:
>'SageMath version 7.6, Release Date: 2017-03-25'
sage: M = Manifold(2,'R^2',field='real',start_index=1)
sage: c_Cart.<x1,x2> = M.chart();
sage: g = M.riemannian_metric('g');
sage: g[1,1],g[2,2] = 1,1;
sage: g.display()
g = dx1*dx1 + dx2*dx2
And a change of coordinates:
> sage: c_CM.<X,x> = M.chart();
sage: m1, m2 = var('m1 m2', domain='positive');
sage: m_CM = m1+m2; mu1 = m1/m_CM; mu2 = m2/m_CM; mu = m1*m2/m_CM
sage: # Restrictions in following line seem to make no difference ...
sage: ch_Cart_CM = c_Cart.transition_map(c_CM, [mu1*x1+mu2*x2, x1-x2], restrictions1 = x1!=x2, restrictions2 = x!=0)
sage: ch_Cart_CM;
Change of coordinates from Chart (R^2, (x1, x2)) to Chart (R^2, (X, x))
Now define a connection on g:
>sage: g.comp(c_CM.frame())[:]
[ 2 -(m1 - m2)/(m1 + m2)]
[ -(m1 - m2)/(m1 + m2) (m1^2 + m2^2)/(m1^2 + 2*m1*m2 + m2^2)]
And a connection on G:
>sage: G = M.riemannian_metric('G');
sage: G[:]= g.comp(c_CM.frame())[:]
sage: G.display()
G = 2 dx1*dx1 - (m1 - m2)/(m1 + m2) dx1*dx2 - (m1 - m2)/(m1 + m2) dx2*dx1 + (m1^2 + m2^2)/(m1^2 + 2*m1*m2 + m2^2) dx2*dx2
Everything appears to be fine. Let's try the Riemann connection:
>sage: g.connection()
Levi-Civita connection nabla_g associated with the Riemannian metric g on the 2-dimensional differentiable manifold R^2
Good. BUT
>sage: #G.connection() # blows up (in Maxima?) w/ "Detected access to protected memory ..."
Is there something wrong in the way G was defined, or are we limited by Maxima (whose ECL routines contain the message)?
Richard_LThu, 20 Apr 2017 18:58:07 -0500https://ask.sagemath.org/question/37355/Why does simplify break print_latex_func?https://ask.sagemath.org/question/37328/why-does-simplify-break-print_latex_func/Here's a minimal example of what I am talking about. Both print statements should return the same output in this scenario.
,var n x
def my_latex_print(self, *args):
return "a_{%s}" %(', '.join(map(latex, args)))
a=function('a',nargs=1,print_latex_func=my_latex_print)(n)
sexp=a(n=n+1)+a(n=n)
print latex(sexp)
sexp=simplify(expand(sexp))
print latex(sexp)
However, the outputs differ:
a_{n + 1} + a_{n}
a\left(n + 1\right) + a\left(n\right)
Of course simplify-expand may lead to a different expression, but that's not what I am concerned about. I am concerned about the representation of `a(n)` instead of `a_n` in the output.
My main question is: How can I recover `a_n` out of `sexp` at the end of my code?BjörnTue, 18 Apr 2017 21:17:36 -0500https://ask.sagemath.org/question/37328/Cannot get Maxima to run in terminal in OS10.11.6https://ask.sagemath.org/question/36239/cannot-get-maxima-to-run-in-terminal-in-os10116/I downloaded Sage-math-7.4.app for MacOSX (running El Capitan on 2016 Mac Book). Double clicked SageMath-7.4.app. I selected Terminal Session>Math>maxima . A terminal window appears with the following text:
Last login: Mon Jan 9 19:09:51 on ttys001 /Users/unlmath/Desktop/SAGE/SageMath-7.4.app/Contents/Resources/sage/sage --maxima; exit MacBook-Pro:~ unlmath$ /Users/unlmath/Desktop/SAGE/SageMath-7.4.app/Contents/Resources/sage/sage --maxima; exit ;;; Loading #P"/Users/unlmath/Desktop/SAGE/SageMath-7.4.app/Contents/Resources/sage/local/lib/ecl/sb-bsd-sockets.fas" ;;; Loading #P"/Users/unlmath/Desktop/SAGE/SageMath-7.4.app/Contents/Resources/sage/local/lib/ecl/sockets.fas"
Condition of type: END-OF-FILE Unexpected end of file on #<sequence-input stream="" 000000010b9691e0="">. No restarts available.
Top level.
>
As far as I can tell Maxima is not running. I'm not sure what is running at the ">" prompt. I haven't found anything on-line describing this problem. If I select Terminal Session>Math>gap it runs gap in the terminal, and if I select Terminal Session>sage it runs sage. Maxima behaves differently. I'd like to get it working.PastaMon, 09 Jan 2017 18:59:03 -0600https://ask.sagemath.org/question/36239/Any way to solve these simultaneous equations using Sage?https://ask.sagemath.org/question/36162/any-way-to-solve-these-simultaneous-equations-using-sage/Input is as following
1: var('E_0,E,gamma,c,v,m,m_0')
(E_0, E, gamma, c, v, m, m_0)
2: eq1 = gamma == 1/sqrt(1-v^2/c^2)
3: eq2 = m == gamma*m_0
4: eq3 = E == m*c^2
5: eq4 = E_0 == m_0*c^2
6: solve([eq1,eq2,eq3,eq4],v,m,m_0,gamma)
The expected solution for v is v = c * sqrt(1-E_0^2/E^2).
I get the following error message. I tried assuming all the variables to be positive and real, but get the same error message.
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-6-c0343319abfc> in <module>()
----> 1 solve([eq1,eq2,eq3,eq4],v,m,m_0,gamma)
/home/sage/sage-7.4/local/lib/python2.7/site-packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
863 s = []
864
--> 865 sol_list = string_to_list_of_solutions(repr(s))
866
867 # Relaxed form suggested by Mike Hansen (#8553):
/home/sage/sage-7.4/local/lib/python2.7/site-packages/sage/symbolic/relation.pyc in string_to_list_of_solutions(s)
538 from sage.structure.sequence import Sequence
539 from sage.calculus.calculus import symbolic_expression_from_maxima_string
--> 540 v = symbolic_expression_from_maxima_string(s, equals_sub=True)
541 return Sequence(v, universe=Objects(), cr_str=True)
542
/home/sage/sage-7.4/local/lib/python2.7/site-packages/sage/calculus/calculus.pyc in symbolic_expression_from_maxima_string(x, equals_sub, maxima)
1798 if len(x) == 0:
1799 raise RuntimeError("invalid symbolic expression -- ''")
-> 1800 maxima.set('_tmp_',x)
1801
1802 # This is inefficient since it so rarely is needed:
/home/sage/sage-7.4/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.pyc in set(self, var, value)
504 raise TypeError
505 cmd = '%s : %s$'%(var, value.rstrip(';'))
--> 506 self.eval(cmd)
507
508 def clear(self, var):
/home/sage/sage-7.4/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.pyc in _eval_line(self, line, locals, reformat, **kwds)
450 line = line[ind_dollar+1:]
451 if statement:
--> 452 maxima_eval("#$%s$" % statement)
453 if not reformat:
454 return result
/home/sage/sage-7.4/src/sage/libs/ecl.pyx in sage.libs.ecl.EclObject.__call__ (/home/sage/sage/src/build/cythonized/sage/libs/ecl.c:7698)()
793
794 """
--> 795 lispargs = EclObject(list(args))
796 return ecl_wrap(ecl_safe_apply(self.obj,(<EclObject>lispargs).obj))
797
/home/sage/sage-7.4/src/sage/libs/ecl.pyx in sage.libs.ecl.EclObject.__init__ (/home/sage/sage/src/build/cythonized/sage/libs/ecl.c:7221)()
658 """
659 if len(args) != 0:
--> 660 self.set_obj(python_to_ecl(args[0]))
661
662 def __reduce__(self):
/home/sage/sage-7.4/src/sage/libs/ecl.pyx in sage.libs.ecl.python_to_ecl (/home/sage/sage/src/build/cythonized/sage/libs/ecl.c:6254)()
473 return Cnil
474 else:
--> 475 L=cl_cons(python_to_ecl(pyobj[0]),Cnil)
476 ptr=L
477 for a in pyobj[1:]:
/home/sage/sage-7.4/src/sage/libs/ecl.pyx in sage.libs.ecl.python_to_ecl (/home/sage/sage/src/build/cythonized/sage/libs/ecl.c:5990)()
457 elif isinstance(pyobj,bytes):
458 s=<bytes>pyobj
--> 459 return ecl_safe_read_string(s)
460 elif isinstance(pyobj,Integer):
461 if pyobj >= MOST_NEGATIVE_FIXNUM and pyobj <= MOST_POSITIVE_FIXNUM:
/home/sage/sage-7.4/src/sage/libs/ecl.pyx in sage.libs.ecl.ecl_safe_read_string (/home/sage/sage/src/build/cythonized/sage/libs/ecl.c:5409)()
374 cdef cl_object o
375 o = ecl_cstring_to_base_string_or_nil(s)
--> 376 o = ecl_safe_funcall(read_from_string_clobj,o)
377 return o
378
/home/sage/sage-7.4/src/sage/libs/ecl.pyx in sage.libs.ecl.ecl_safe_funcall (/home/sage/sage/src/build/cythonized/sage/libs/ecl.c:5208)()
355 if ecl_nvalues > 1:
356 s = si_coerce_to_base_string(ecl_values(1))
--> 357 raise RuntimeError("ECL says: "+ecl_base_string_pointer_safe(s))
358 else:
359 return ecl_values(0)
RuntimeError: ECL says: THROW: The catch MACSYMA-QUIT is undefined.omoplataTue, 03 Jan 2017 20:05:25 -0600https://ask.sagemath.org/question/36162/Any way to solve this differential equation?https://ask.sagemath.org/question/36122/any-way-to-solve-this-differential-equation/ sage: x(t)=function('x')(t)
sage: x
t |--> x(t)
sage: g(v,c)=1/sqrt(1-v^2/c^2)
sage: g
(v, c) |--> 1/sqrt(-v^2/c^2 + 1)
sage: var('a')
a
sage: ode = g(diff(x,t))*diff(x,t) == a*t
sage: ode
t |--> diff(x(t), t)/sqrt(-diff(x(t), t)^2/c^2 + 1) == a*t
sage: desolve(ode,x)
Traceback (most recent call last):
...
ValueError: Unable to determine independent variable, please specify.
sage: desolve(ode,[x,t])
Traceback (most recent call last):
...
NotImplementedError: Maxima was unable to solve this ODE. Consider to set option contrib_ode to True.
sage: desolve(ode,[x,t],contrib_ode=True)
Traceback (most recent call last):
...
NotImplementedError: Maxima was unable to solve this ODE.
I can solve it by hand.
Mathematica can solve it. But I would very much prefer to learn to use Sage because it's open source.
It looks like it is Maxima that cannot solve it. But is it possible to make Sage invoke any other open source program than Maxima? Or use some trick in defining the problem that would allow Maxima to solve it?
Thank you.omoplataThu, 29 Dec 2016 13:15:36 -0600https://ask.sagemath.org/question/36122/solve maxima?https://ask.sagemath.org/question/36083/solve-maxima/The following in Jupyter (and sage cloud) produces the wrong output. I do have an (extremely similar) maxima batch file that works fine. I sort of presume that maxima "solve" is not really called. If needed I can provide all files and stuff; either link or inline. Or if the correct way to use maxima/solve isn't obvious I can shorten up the generation of the solve argument by direct assignment.
The last commented line is to prove that simpler problems yield the correct same answers in sagemath and maxima; when sagemath feels like.
jupyter:
******
%display latex
var('A B C D M r')
T =matrix([[A,B],[C,D]]);
m=1-2*M/r
G =matrix([[-m,0],[0,1/m]])
k = T.transpose()*G*T
eq1=k[0,0];
eq2=k[0,1];
eq3=k[1,0];
eq4=k[1,1];
eqd=A*D-B*C-1
eqd
sol=solve([eq1+m==0,eq3-sqrt(2*M/r)==0,eq4-1==0,eqd==0],[A,B,C,D]);
sol
####-comment---solve([eq1+m==0,eq3-sqrt(2*M/r)==0],[A,B])
****
Produces:
$\newcommand{\Bold}[1]{\mathbf{#1}}\left[-B C + A D - 1 = 0, A^{2} {\left(\frac{2 \cdot M}{r} - 1\right)} - \frac{C^{2}}{\frac{2 \cdot M}{r} - 1} - \frac{2 \, M}{r} + 1 = 0, A B {\left(\frac{2 \cdot M}{r} - 1\right)} - \frac{C D}{\frac{2 \cdot M}{r} - 1} - \sqrt{2} \sqrt{\frac{M}{r}} = 0, B^{2} {\left(\frac{2 \, M}{r} - 1\right)} - \frac{D^{2}}{\frac{2 \, M}{r} - 1} - 1 = 0\right]$
Whereas : a maxima script produces
${\\left[ \left[ A=-1 , B={{\sqrt{2} \cdot r \cdot \sqrt{{{M}\over{r}}}}\over{r-2\cdot M}} , C=0 , D=-1 \right] , \left[ A=1 , B=-{{\sqrt{2} \cdot r \cdot \sqrt{{{M}\over{r}}}}\over{r-2\cdot M}}, C=0 , D=1 \right] \right] }$
rrogersSat, 24 Dec 2016 09:28:49 -0600https://ask.sagemath.org/question/36083/declare a variable as *not* an integer for solvehttps://ask.sagemath.org/question/34876/declare-a-variable-as-not-an-integer-for-solve/ I am trying to solve symbolically a simple equation for x:
solve(x^K + d == R, x)
I am declaring these variables and assumptions:
var('K, d, R')
assume(K>0)
assume(K, 'real')
assume(R>0)
assume(R<1)
assumptions()
︡> [K > 0, K is real, R > 0, R < 1]
Yet when I run the solve, I obtain the following error:
> Error in lines 1-1
>
> Traceback (most recent call last):
>
> File
> "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/smc_sagews/sage_server.py",
> line 957, in execute
> exec compile(block+'\n', '', 'single') in namespace, locals
>
> ...
>
> File "/projects/sage/sage-7.3/local/lib/python2.7/site-packages/sage/interfaces/interface.py",
> line 671, in __init__
> raise TypeError(x)
>
> TypeError: Computation failed since Maxima requested additional constraints; using the 'assume' command before evaluation *may* help (example of legal syntax is 'assume(K>0)', see `assume?` for more details)
>
> **Is K an integer?**
Apparently, maxima is asking whether K is an integer? But I explicitly declared it 'real'!
How can I spell out to maxima that it should not assume that K is an integer?
ThanksAntoine-sacWed, 21 Sep 2016 04:11:14 -0500https://ask.sagemath.org/question/34876/Observation regarding integration with different algorithmshttps://ask.sagemath.org/question/32778/observation-regarding-integration-with-different-algorithms/I was going through some basic tutorials and noticed this interesting behavior.
integrate(exp(x)*sin(x) + exp(x)*cos(x), x)
with algorithm='maxima' gives
1/2*(cos(x) + sin(x))*e^x - 1/2*(cos(x) - sin(x))*e^x
rather than the simplified
e^x*sin(x)
given by algorithm='sympy'. It is the same when I use maxima or sympy by itself. Why is that? Why is maxima not simplifying the expression?saadFri, 11 Mar 2016 05:13:50 -0600https://ask.sagemath.org/question/32778/Why the Maxima worksheets is not rendering latex / MathJax?https://ask.sagemath.org/question/32453/why-the-maxima-worksheets-is-not-rendering-latex-mathjax/ I use Maxima with sagemath and do not know why the results are not rendered
sage: f(x):=x^2
f(x):=x^2
sage: integrate(f(x),x)
x^3/3jmarcellopereiraThu, 04 Feb 2016 13:10:41 -0600https://ask.sagemath.org/question/32453/Setting the conditions at t=0 for laplace transform with sage (instead of maxima)https://ask.sagemath.org/question/31713/setting-the-conditions-at-t0-for-laplace-transform-with-sage-instead-of-maxima/Hallo,
I am trying to calculate the laplace transform for the following differential equation with sage instead of maxima.
"m*'diff(x_f(t)+x_d(t),t,2)+d*'diff(x_d(t),t,1)+c*x_d(t)+Fext(t)=0"
But I do not find how to set the values in sage at t=0 for the functions x_d(t) and x_f(t). Before I did set it with maxima with
```
maxima.eval("atvalue(x_d(t), t=0, 0)$ atvalue('diff(x_d(t),t), t=0, 0)$");
maxima.eval("atvalue(x_f(t), t=0, 0)$ atvalue('diff(x_f(t),t), t=0, 0)$");
```
Basically, I am trying to use the sage laplace transfrom function instead of the sage-maxima function resulting in a nicer notebook without all the maxima.eval add maxima.-commands. I know that sage is using maxima for the transformation in the background.
BR Howil
howilSun, 20 Dec 2015 09:56:36 -0600https://ask.sagemath.org/question/31713/Legendre_P in symbolic function - recursion errorhttps://ask.sagemath.org/question/30276/legendre_p-in-symbolic-function-recursion-error/Hello,
Undergraduate Physics mathemtica->sage convert here trying to use sage for both symbolic substitution to print equations and to plot.
I have the equation `M_y^2 * cos(x)^4 -2*My(x)*sin(x)*cos(x)^3` and would like to see how this behaves when substituting different associated legendre polynomials for `My^2`. Code for this:
Y_fnc(x,y_max,l,m)=y_max*gen_legendre_P(l,m,cos(x))
f(x,y_max,l,m)=Y_fnc(x,y_max,l,m) * cos(x)^4 -2*sqrt(Y_fnc(x,y_max,l,m))*sin(x)*cos(x)^3
Which results in:
<code>
[...]
File "/home/ian/sage-6.8-x86_64-Linux/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 319, in symbol raise NotImplementedError("symbol")
RuntimeError: maximum recursion depth exceeded while calling a Python object
</code>
With example line of the truncated output being:
File "/home/ian/sage-6.8-x86_64-Linux/local/lib/python2.7/site-packages/sage/functions/orthogonal_polys.py", line 1239, in gen_legendre_P
return sqrt(1-x**2)*(((n-m+1)*x*gen_legendre_P(n,m-1,x)-(n+m-1)*gen_legendre_P(n-1,m-1,x))/(1-x**2))
I have also tried to use maxima.assoc_legendre_P but this doesn't work when I try to plot:
<pre>
Y_fnc(x,y_max,l,m)=y_max*maxima.assoc_legendre_P(l,m,cos(x))
f(x,y_max,l,m)=Y_fnc(x,y_max,l,m) * cos(x)^4 -2*sqrt(Y_fnc(x,y_max,l,m))*sin(x)*cos(x)^3
plot(f(x,1,2,0),0,2*pi)
</pre>
<code>
verbose 0 (2716: plot.py, generate_plot_points) WARNING: When plotting, failed to evaluate function at 200 points.
verbose 0 (2716: plot.py, generate_plot_points) Last error message: 'unable to simplify to float approximation'
</code>.
I can accomplish plotting by defining Python Functions:
edit:
<pre>
def Y_fnc_py(x,l,m,y_max):
return y_max*gen_legendre_P(l,m,cos(x))
def f(x,y_max,l,m):
return Y_fnc_py(x,y_max,l,m) * cos(x)^4 -2*sqrt(Y_fnc_py(x,y_max,l,m))*sin(x)*cos(x)^3
plot(f(x,y_max=2,l=1,m=1),0,2*pi)
</pre>
Works however this will not allow me print f(x,y_max,l=3,m=2) so I can easily write down the equation. So this allows me to plot easily but doesn't display the equation well
Help much appreciated thank youianhiMon, 26 Oct 2015 15:11:06 -0500https://ask.sagemath.org/question/30276/simplify_full() Maxima ECL errorhttps://ask.sagemath.org/question/26004/simplify_full-maxima-ecl-error/Hi all, the following code was working fine in 6.4.1 (I am using the AIIMS ppa in Ubuntu) and now after the 6.5 upgrade, it doesn't work anymore. Assume I have defined all variables.
u(t) = exp(-(t-t_0)^2/(2*sigma^2)) + exp(-(t-t_1)^2/(2*sigma^2)) ; u(t);
u_tilde = integral(u(t)*exp(-I*omega*t), t, -infinity, +infinity, hold=False).simplify_full(); u_tilde;
The problem is in simplify_full(). The erf function and their limits are not evaluated for some reason. I have a hunch this problem has been posted [before](http://ask.sagemath.org/question/25441/calculation-that-is-possible-in-sage-63-is-not-possible-in-sage-64/) but I am not sure. The full traceback is given below. Any help is appreciated.
Thanks
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-8-66e6236c7bf7> in <module>()
----> 1 u_tilde = integral(u(t)*exp(-I*omega*t), t, -infinity, +infinity, hold=False).simplify_full(); u_tilde;
/usr/lib/sagemath/src/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.simplify_full (build/cythonized/sage/symbolic/expression.cpp:40350)()
8258 """
8259 x = self
-> 8260 x = x.simplify_factorial()
8261 x = x.simplify_rectform()
8262 x = x.simplify_trig()
/usr/lib/sagemath/src/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression.simplify_factorial (build/cythonized/sage/symbolic/expression.cpp:43472)()
8729
8730 """
-> 8731 return self.parent()(self._maxima_().makefact().factcomb().minfactorial())
8732
8733 factorial_simplify = simplify_factorial
/usr/lib/sagemath/src/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._maxima_ (build/cythonized/sage/symbolic/expression.cpp:5512)()
582 # Maybe not such a great idea because the "default" interface is another one
583 from sage.calculus.calculus import maxima
--> 584 return super(Expression, self)._interface_(maxima)
585 else:
586 return super(Expression, self)._interface_(session)
/usr/lib/sagemath/src/sage/structure/sage_object.pyx in sage.structure.sage_object.SageObject._interface_ (build/cythonized/sage/structure/sage_object.c:5203)()
592 raise NotImplementedError, "coercion of object %s to %s not implemented:\n%s\n%s"%\
593 (repr(self), I)
--> 594 X = I(s)
595 if c:
596 try:
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in __call__(self, x, name)
197
198 if isinstance(x, basestring):
--> 199 return cls(self, x, name=name)
200 try:
201 return self._coerce_from_special_method(x)
/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/interfaces/interface.pyc in __init__(self, parent, value, is_name, name)
624 self._name = parent._create(value, name=name)
625 except (TypeError, RuntimeError, ValueError) as x:
--> 626 raise TypeError(x)
627
628 def _latex_(self):
TypeError: ECL says: Error executing code in Maxima:
Update: I would like to add that the latest version of sage 6.7 still has this problem. Any updates?NahsiNMon, 02 Mar 2015 16:38:48 -0600https://ask.sagemath.org/question/26004/