필터 지우기
필터 지우기

Differential Equation Solution incorrect with matlab compared to maple

조회 수: 2 (최근 30일)
Ramses Young
Ramses Young 2022년 3월 6일
편집: Paul 2022년 3월 6일
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에서 Calculus에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by