# Revision history [back]

### 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 -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

### 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 -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 Functions: edit: def Y_fnc_py(x,l,m,y_max): return y_maxgen_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 -2sqrt(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) 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 would like to be able to both print and plot doesn't display the equation using gen_legendre_P.
well Help much appreciated thank you

### 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 -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: edit: Functions:
edit:

    def Y_fnc_py(x,l,m,y_max):
return y_maxgen_legendre_P(l,m,cos(x))
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 -2sqrt(Y_fnc_py(x,y_max,l,m))sin(x)cos(x)^3 -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)


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 you

 4 No.4 Revision tmonteil 22038 ●25 ●157 ●407 http://wiki.sagemath.o...

### 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 -2My(x)sin(x)*cos(x)^3 -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. 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)^
-2*sqrt(Y_fnc(x,y_max,l,m))*sin(x)*cos(x)^3

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:
edit:

    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)


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 you