how to solve this differential equation system symbolically?

9 Ansichten (letzte 30 Tage)

Akzeptierte Antwort

John D'Errico
John D'Errico am 1 Mai 2022
Bearbeitet: John D'Errico am 1 Mai 2022
This seems like a homework problem. But Walter has already given an answer, that I think is not helpful, since dsolve will fail when applied directly. And since the problem is insufficiently defined to be a good homework problem, I might conjecture it is not in fact homework.
syms y(t) x(t) f(t)
dy = diff(y);
E1 = x + dy == f;
E2 = diff(x) + y == diff(f);
First, differentiate E1, subtracting E2 from that.
E3 = simplify(diff(E1) - E2)
E3(t) = 
As you can see, x(t) and f(t) have been completely eliminated from the result. However, now we can solve for y(t).
y(t) = dsolve(E3,y(0) == 0, dy(0) == 1)
y(t) = 
In fact, if you think about it, note that this is a well known function : the hyperbolic sine function.
y = rewrite(y,'sinh')
y(t) = 
Now that we have y(t), return to equations E1 and E2.
E1 = subs(E1)
E1(t) = 
From this we see that x(t) and f(t) are simply related, differening only by that cosh(t) term.
E2 = subs(E2)
E2(t) = 
The problem is, at this point you are now stuck. Lacking f(t) or y(t), you cannot find the other. What is worse, We see that now E1 and E2 are actually the same pieces of information, since we can derive E2 from E1. That is, just differentiate both sides of E1, and look to see what you get.
diff(E1)
ans(t) = 
SURPRISE! Differentiating E1 yields E2.
The point is, you lack sufficient information to solve the problem, even though you can solve for y(t). So perhaps that is the point of this assignment, IF it is one. Anyway, since the problem already had an answer, I might as well have written this.
  1 Kommentar
Walter Roberson
Walter Roberson am 1 Mai 2022
The approach I used worked fine. I tested with MATLAB Online before I posted. I didn't post the code because it is obvious that it is an assignment.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 1 Mai 2022
Create the symbols and the two equations. dsolve() the pair of equations without boundary conditions, getting out a struct with a definition for x and y. Take the y and substitute t = 0 to get y(0) and equate that to the known value. Take the y and differentiate and substitute t = 0 to get y'(0) and equate that to the known value. You now have a pair of simultaneous equations relating the constants of the differential equations.
  6 Kommentare
Paul
Paul am 2 Mai 2022
Bearbeitet: Paul am 2 Mai 2022
But diff(f) is in the equations and is not "plain", so I'm curious why dsolve() chose to solve for x and y, instead of x and f, or y and f, if dsolve() could have done so.
Walter Roberson
Walter Roberson am 3 Mai 2022
Good question. I wonder if it used symvar or equivalent and choose the first two. I seem to recall that solve() chooses variables starting from x y z (or X Y Z) first

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by