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]
conds = 
wSol(x) = dsolve(deq,conds)
wSol(x) = 

采纳的回答

Paul
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]
conds = 
wSol(x) = dsolve(deq,conds)
wSol(x) = 
The solution contains a term of the form:
term = (x-20)*(5*sym(pi)*1i/3 - 5*log(x-20)/3)
term = 
or focusing only on the term in the parentheses after multiplying by 3/5
term = sym(pi)*1i - log(x-20)
term = 
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)
term = 
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
wSol(x) = 
fplot(wSol(x),[0 L]) % looks like the Maple plot
  2 个评论
Ramses Young
Ramses Young 2022-3-6
Wow that makes a lot of sense!!!
I can see how limiting the domain of interests affects the imaginary portion, but can you explain how using the simplify command makes it not have the imaginary part in it?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Number Theory 的更多信息

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by