Differential Equation Solution incorrect with matlab compared to maple
1 次查看(过去 30 天)
显示 更早的评论
Hello everyone, currently I am trying to solve a differential equation relating to a beam problem, the problem I am having is that is seems maple gives better results for the exact solution than matlab does, in fact, the solution i am getting from matlab is pretty unusable.
I have a feeling the issue is with my code, of course, but I cannot seem to find it.
Here is the differential equation:
EI = 10000*[2-(x/L)] , q = 40 * (x/L)^2, and L = 10
Here is the result of maple code
as well as it's plot
Here is the code I am running, as can be seen in wSol(x), it is imaginary, which is pretty contrary to what Maple provides.
syms x w(x)
L=10;
q0=40;
a0=10000;
M1=-1000;
Q1=-100;
q=q0*(x/L)^2;
EI=a0*(2-(x/L));
Dw = diff(w,x) ;
D2w = diff(w,x,2);
D3w = diff(w,x,3);
deq = diff(EI*diff(w,x,2),x,2)==q;
cond1 = w(0)==0;
cond2 = Dw(0)==0;
cond3 = D2w(L)==M1/subs(EI,L);
cond4 = D3w(L)==(Q1-(subs(diff(EI,x),L)*M1/subs(EI,L)))/subs(EI,L);
conds=[cond1 cond2 cond3 cond4]
wSol(x) = dsolve(deq,conds)
0 个评论
采纳的回答
Paul
2022-3-6
编辑:Paul
2022-3-6
The Maple solution does include imaginary terms, like 5*pi*1i/3, but we'll show that those terms cancel out on the interval of interest.
syms x real % in case this has an impact
syms w(x)
L=10;
q0=40;
a0=10000;
M1=-1000;
Q1=-100;
q=q0*(x/L)^2;
EI=a0*(2-(x/L));
Dw = diff(w,x) ;
D2w = diff(w,x,2);
D3w = diff(w,x,3);
deq = diff(EI*diff(w,x,2),x,2)==q;
cond1 = w(0)==0;
cond2 = Dw(0)==0;
cond3 = D2w(L)==M1/subs(EI,L);
cond4 = D3w(L)==(Q1-(subs(diff(EI,x),L)*M1/subs(EI,L)))/subs(EI,L);
conds=[cond1 cond2 cond3 cond4]
wSol(x) = dsolve(deq,conds)
The solution contains a term of the form:
term = (x-20)*(5*sym(pi)*1i/3 - 5*log(x-20)/3)
or focusing only on the term in the parentheses after multiplying by 3/5
term = sym(pi)*1i - log(x-20)
Over the solutions interval of interest, 0 <= x <= L, the argumument to the log function is negative real. Using the rule for log of a negative number: log(x-20) = log(20-x) + i * pi. So we have
term = - log(20-x)
and the imaginary part disappears. So make that assumption explicitly and simplify the solution.
assume(0 <= x <= L) % only care about the solution over this interval
wSol(x) = simplify(expand(wSol(x))) % expand and simplify the solution using the assumption
fplot(wSol(x),[0 L]) % looks like the Maple plot
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Number Theory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!