Solve first order linear equation using DSolve?

Posted 6 months ago
1331 Views
|
15 Replies
|
4 Total Likes
|
 I tried to solve the first order linear equation with mathematica, but I failed to get the right answer, which I got by hand. Can you tell me why I am wrong? thanks very much!the question: DSolve[{y'[t] == (I*w0 - R)*y[t] + B*r/2*(Exp [I*w*t] + Exp [-I*w*t]), y == 0}, y == 0}, y[t],t] the wrong answer i got: correct the question: the answer is right !!! just not the form I expected. {{y -> Function[{t}, (B E^(t (-R + I w0)) r (-2 R + E^(t (R - I (w + w0))) R + E^(2 I t w + t (R - I (w + w0))) R + I E^(t (R - I (w + w0))) w - I E^(2 I t w + t (R - I (w + w0))) w + 2 I w0 - I E^(t (R - I (w + w0))) w0 - I E^(2 I t w + t (R - I (w + w0))) w0))/(2 (R - I w - I w0) (R + I w - I w0))]}} the right answer: correct the question: the answer I expected and calculated by hand.  Answer
15 Replies
Sort By:
Posted 6 months ago
 Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1STThe rules explain how to format your code properly. If you do not format code, it may become corrupted and useless to other members. Please EDIT your post and make sure code blocks start on a new paragraph and look framed and colored like this. int = Integrate[1/(x^3 - 1), x]; Map[Framed, int, Infinity]  Answer
Posted 6 months ago Answer
Posted 6 months ago
 There is something wrong with your "right answer". It satisfies neither the differential equation nor the initial condition. Answer
Posted 6 months ago
 Thanks for pointing out mistakes. I am not rigorous. but it satisfied the differential equation if you calculate by hand. I have got the form I expected. I confused the general solution and special solution. In:= ODE = {y'[t] == (I*w0 - R)*y[t] + B/2*r*(Exp[I*w*t] + Exp[-I*w*t])}; sol = DSolve[ODE, y, t] // FullSimplify Out:={{y -> Function[{t}, 1/2 B E^(t (-R + I w0) + t (R - I (w + w0))) r (E^(2 I t w)/(R + I (w - w0)) + 1/(R - I (w + w0))) + E^(t (-R + I w0)) C]}} In:= Simplify[1/2 B E^(t (-R + I w0) + t (R - I (w + w0))) r (E^(2 I t w)/(R + I (w - w0)) + 1/(R - I (w + w0)))] Out:= 1/2 B E^(-I t w) r (E^(2 I t w)/(R + I (w - w0)) + 1/(R - I (w + w0))) Answer
Posted 6 months ago
 ODE = {y'[t] == (I*w0 - R)*y[t] + B/2*r*(Exp[I*w*t] + Exp[-I*w*t]), y == 0}; sol = DSolve[ODE, y, t] // FullSimplify ODE /. sol // FullSimplify(*Check if Mathematica solution is correct. OK is correct. *) (* {{True, True}} *) YOURSsolution = {{y -> Function[{t}, (B*r)/2*(Exp[I w t]/(R + I*(w - w0)) + Exp[-I w t]/( R - I (w - w0)))]}}; ODE /. YOURSsolution // FullSimplify(*Check if Yours solution is correct. It's seems is Not Correct !.Is not TRUE *) (* {{(B E^(-I t w) r w0)/(I R + w - w0) == 0, (B r R)/(R^2 + (w - w0)^2) == 0}} *) Answer
Posted 6 months ago
 I appreciate your return. thanks very much. I got the form answer by the code. I think i only want the special solution。 Answer
Posted 6 months ago
 DSolve gives In:= ysol = y /. DSolve[{y'[t] == (I*w0 - R)*y[t] + B*r/2*(Exp[I*w*t] + Exp[-I*w*t]), y == 0}, y, t][[1, 1]] Out= Function[{t}, (B E^(t (-R + I w0)) r (-2 R + E^(t (R - I (w + w0))) R + E^(2 I t w + t (R - I (w + w0))) R + I E^(t (R - I (w + w0))) w - I E^(2 I t w + t (R - I (w + w0))) w + 2 I w0 - I E^(t (R - I (w + w0))) w0 - I E^(2 I t w + t (R - I (w + w0))) w0))/(2 (R^2 + w^2 - 2 I R w0 - w0^2))] with In:= ysol Out= 0 and In:= test = FullSimplify[ D[ysol[t], t] - ((I*w0 - R)*ysol[t] + B*r/2*(Exp[I*w*t] + Exp[-I*w*t])) // ExpToTrig, Element[{B, r, R, w, w0}, Reals]] Out= 0 So ysol is a solution to your problem with real B, r, R , w and w0 Answer
Posted 6 months ago
 Thanks for your complete return. if I use the code below ,I can got the answer I expected. In:= ODE = {y'[t] == (I*w0 - R)*y[t] + B/2*r*(Exp[I*w*t] + Exp[-I*w*t])}; sol = DSolve[ODE, y, t] // FullSimplify Out:={{y -> Function[{t}, 1/2 B E^(t (-R + I w0) + t (R - I (w + w0))) r (E^(2 I t w)/(R + I (w - w0)) + 1/(R - I (w + w0))) + E^(t (-R + I w0)) C]}} In:= Simplify[1/2 B E^(t (-R + I w0) + t (R - I (w + w0))) r (E^(2 I t w)/(R + I (w - w0)) + 1/(R - I (w + w0)))] Out:= 1/2 B E^(-I t w) r (E^(2 I t w)/(R + I (w - w0)) + 1/(R - I (w + w0))) but I still confuse why my expected answer is wrong when I instead the eqution with it. ODE = {y'[t] == (I*w0 - R)*y[t] + B/2*r*(Exp[I*w*t] + Exp[-I*w*t])}; sol = DSolve[ODE, y, t] // FullSimplifyere YOURSsolution = {{y -> Function[{t}, (B*r)/ 2*(Exp[I w t]/(R + I*(w - w0)) + Exp[-I w t]/(R - I (w - w0)))]}}; ODE /. YOURSsolution // FullSimplify Answer
Posted 6 months ago
 What exactly is your problem???As Mariusz pointed out your solution YOURSsolution In:= YOURSsolution[t] Out= 1/2 B r (E^(-I t w)/(R - I (w - w0)) + E^(I t w)/( R + I (w - w0))) is NOT a solution for your ODE In:= FullSimplify[ODE /. y -> YOURSsolution] Out= {(B E^(-I t w) r w0)/(I R + w - w0) == 0} (but ysol is : In:= FullSimplify[ODE /. y -> ysol] Out= {True} )nor does it fulfill your initial condition as Mariusz has already pointed out In:= YOURSsolution // FullSimplify Out= (B r R)/(R^2 + (w - w0)^2) So, what is your question?By the way, ysol is generally a solution without the restrictions mentioned before In:= test = FullSimplify[ D[ysol[t], t] - ((I*w0 - R)*ysol[t] + B*r/2*(Exp[I*w*t] + Exp[-I*w*t]))] Out= 0 Answer
Posted 6 months ago
 Thanks for your return again. My problem is that I want to get the solution form of YOURSsolution when I solve the equation with Mathematica. I have known that ysol is generally a solution. I think YOURSsolution is a special solution. I have solved the problem by the code that I posted. thanks~ Answer
Posted 6 months ago
 I want to get the solution form of YOURSsolution What does that mean? I think YOURSsolution is a special solution. YOURSsolution is NOT a solution to your ODE. Why do you have this idea? Answer
Posted 6 months ago
 Happy new year! The question came from formula derivation of a dissertation. YOURSsolution is exactly the answer the dissertation get. So I want to get the same answer by Mathematica. By dropping E^(t (-R + I w0)) C]}} from the answer derivated from Mathematica, I get the same answer I expected.I think YOURSsolution is a special solution by dropping C, maybe what I thought is wrong. But it satisfied ODE if you calculate by hand. the answer can make the right of the equation equal to the left. I don't know the reason... Answer
Posted 6 months ago
 Happy new year! The question came from formula derivation of a dissertation. YOURSsolution is exactly the answer the dissertation get. So I want to get the same answer by Mathematica. By dropping E^(t (-R + I w0)) C]}} from the answer derivated from Mathematica, I get the same answer I expected.I think YOURSsolution is a special solution by dropping C, maybe what I thought is wrong. But it satisfied ODE if you calculate by hand. the answer can make the right of the equation equal to the left. I don't know the reason... Answer
Posted 6 months ago
 NO!!!YOURSsolution is NOT a solution of ODE, even if calculated by hand, and it does NOT fulfill YOURSsolution[ 0 ] == 0. In:= YOURSsolution /. t -> 0 % // FullSimplify Out= 1/2 B r (1/(R - I (w - w0)) + 1/(R + I (w - w0))) Out= (B r R)/(R^2 + (w - w0)^2) You may drop the condition y[ 0 ] == 0 in your ODE to get ysol1 = y /. DSolve[{y'[t] == (I*w0 - R)*y[t] + B*r/2*(Exp[I*w*t] + Exp[-I*w*t])}, y, t][[1, 1]] Then drop, as you wanted to, C ysol2 = ysol1 /. C -> 0 But In:= ysol2 Out= 1/2 B r (1/(R + I (w - w0)) + 1/(R - I (w + w0))) That is NOT what you wanted.ysol2 is a solution of ODE In:= ysol2'[t] == (I*w0 - R)*ysol2[t] + B*r/2*(Exp[I*w*t] + Exp[-I*w*t]) // FullSimplify Out= True ysol2 looks very similar to YOURSsolution (but remember: it does not fulfill your initial condition) In:= (B r)/2 (2/(B r) ysol2[t] // Simplify // Expand) Out= 1/2 B r (E^(I t w)/(R + I (w - w0)) + E^(-I t w)/( R - I (w + w0))) but it is not the same In:= ysol2[t] - YOURSsolution // FullSimplify Out= (I B E^(-I t w) r w0)/((R - I w)^2 + w0^2) Look at the signs in the w / w0 terms , I have the suspicion that there is a typo in that dissertation. Answer
Posted 6 months ago
 thanks for your detailed reply. I appreciate that you are so responsible and warm!!! ysol2 is a solution of ODE, I can not agree with you more. thanks!!! Answer