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 -2My(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)^
Which results in:
[...]
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
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:
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)
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'
I can accomplish plotting by defining Python Functions but would like to be able to both print and plot the equation using gen_legendre_P.
Help much appreciated thank you