Second order ODE (mupad)
显示 更早的评论
What's wrong??? How can i run this basic program?
% Solve 2nd order ODE
clc;clear all;
syms y(x) k
eq='(1-x^2)*D2y - 2*x*Dy +(1+k)*k*y=0';
ic='y(0)=0, Dy(0)=1'; % Initial conditions
y=dsolve(eq, ic,'x')
k=2;
y=subs(y)
Messages :(R2014a)
Error using mupadmex
Error in MuPAD command: The first argument must not be negative. [orthpoly::legendre]
Error in sym/subs>mupadsubs (line 139)
G = mupadmex('symobj::fullsubs',F.s,X2,Y2);
Error in sym/subs (line 124)
G = mupadsubs(F,X,Y);
Error in dsolve_legendre1 (line 10)
y=subs(y)
采纳的回答
更多回答(1 个)
Walter Roberson
2017-11-20
In R2014a, if you dsolve() with symbolic k then the solution that you get for y is
-orthpoly::legendre(- ((2*k + 1)^2)^(1/2)/2 - 1/2, x)*int(1/((y^2 - 1)*orthpoly::legendre(- ((2*k + 1)^2)^(1/2)/2 - 1/2, y)^2), y, 0, x)*orthpoly::legendre(- ((2*k + 1)^2)^(1/2)/2 - 1/2, 0)
Here, orthpoly::legendre is a reference to an MuPAD routine to calculate legendre polynomials.
Unfortunately when you subs in any real-valued k in that expression, the first argument to orthpoly::legendre becomes negative, and MuPAD does not like to compute that, leading to the error you see.
cvklpstunc showed computing with a specific numeric k: that works where using symbolic k and substituting in later does not.
This is a limitation in the R2014a symbolic engine. It is overcome in some later version.
类别
在 帮助中心 和 File Exchange 中查找有关 Numeric Solvers 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!