dsolve gives wrong equations?

조회 수: 5 (최근 30일)
daniel slama
daniel slama 2022년 6월 18일
댓글: daniel slama 2022년 6월 19일
hey all!
so i'm trying to learn how dsolve and I know i'm doing something incorrectly but i don't know exactly what.
it could just be that everything is in order but i am just bad at math lol.
anyway, examples are below/ would love some help.
>> syms y(x)
>> dsolve(diff(y)==y+sin(x))
ans =
C1*exp(x) - (2^(1/2)*cos(x - pi/4))/2 %should'nt the correct answer be -1/2*cos(t)-1/2*sin(t)+exp(t)*C1?
e.g 2:
syms y(x)
>> dsolve((diff(y))^2+y^2==1)
ans =
(exp(C1*1i - x*1i)*(exp(- C1*2i + x*2i) + 1))/2 %shoud'nt these two be sin(s-C1) and -sin(s-C1)?
(exp(C2*1i + x*1i)*(exp(- C2*2i - x*2i) + 1))/2
1 %legit
-1 %legit

채택된 답변

Torsten
Torsten 2022년 6월 18일
편집: Torsten 2022년 6월 18일
There are often several ways to write a function. But it seems to me that your S2 solutions are not independent.
syms y(x) C1
S1 = dsolve(diff(y)==y+sin(x))
S1 = 
S2 = -1/2*cos(x)-1/2*sin(x)+exp(x)*C1
S2 = 
res1 = simplify(diff(S1,x)-S1-sin(x))
res1 = 
0
res2 = simplify(diff(S2,x)-S2-sin(x))
res2 = 
0
S1 = dsolve((diff(y))^2+y^2==1)
S1 = 
S2 = [sin(x-C1) ;-sin(x-C1)]
S2 = 
res1 = simplify(diff(S1,x).^2+S1.^2-1)
res1 = 
res2 = simplify(diff(S2,x).^2+S2.^2-1)
res2 = 
  댓글 수: 1
daniel slama
daniel slama 2022년 6월 19일
damn, TYSM.
i never would have figured this out on my own

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by