Solving Coupled Differential Equation

Hello,
I want to solve following differential equation:
(x^2+x+1) / (x^2+x) dx/dt + dy/dt = 1 with constraint x+x^2 = y+y^2
It involves derivatives of both x and y. How can I solve this in Matlab.
Thanks guys in advance!! Cheers

 採用された回答

Birdman
Birdman 2017 年 10 月 23 日

0 投票

syms y(t) x(t)
a=(x^2+x+1)/(x^2+x);
%%because of the constraint, x+x^2=y+y^2 ----> x+y=-1. Take the derivative wrt t and you will
%%find x_dot=-y_dot;
eqns=a*diff(x,t)-diff(x,t)==1;
X=dsolve(eqns,t)
Try this.

6 件のコメント

Harshit Agarwal
Harshit Agarwal 2017 年 10 月 23 日
Thanks for the quick answer!! really appreciate that.
How do you arrived at x+x^2=y+y^2 ----> x+y=-1 ? Shouldn't it be dx/dt*(1+2x)=dy/dt*(1+2y)?
Birdman
Birdman 2017 年 10 月 23 日
x-y=(y-x)*(y+x),
Division of x-y to y-x brings -1 and therefore;
x+y=-1
Steven Lord
Steven Lord 2017 年 10 月 23 日
x = 42;
y = 42;
L = x + x.^2;
R = y + y.^2;
isequal(L, R) % true
isequal(x+y, -1) % false
Be careful about dividing by 0.
Harshit Agarwal
Harshit Agarwal 2017 年 10 月 24 日
Well, my bad. Let's say if we cannot express dx explicitly in terms of dy, then how to solve this type of equations. For. e.g.,
(x^2+x+1) / (x^2+x) dx/dt + dy/dt = 1 with constraint x^2+y^2+xy=10 (or any constant)
Torsten
Torsten 2017 年 10 月 24 日
編集済み: Torsten 2017 年 10 月 24 日
Differentiate the algebraic equation with respect to t.
The differential equation and the differentiated algebraic equation then give you a linear system of equations in the unknowns dx/dt and dy/dt. Solve it explicitly for dx/dt and dy/dt and then use one of the standard ODE integrators.
Or write your system as
M*[dx/dt ; dy/dt] = f(t,x,y)
with
M = [(x^2+x+1)/(x^2+x) 1 ; 0 0]
f = [1 ; x^2+y^2+x*y-10]
and use ODE15S with the state-dependent mass matrix option.
Best wishes
Torsten.
David Goodmanson
David Goodmanson 2017 年 10 月 24 日
Why should x+x^2 = y+y^2 imply x+y = -1 only? x = y also works, in which case
eqns=a*diff(x,t)-diff(x,t)==1;
becomes
eqns=a*diff(x,t)+diff(x,t)==1;
in which case
Warning: Unable to find explicit solution. Returning implicit solution instead.
X = solve(2*x - 2*atanh(2*x + 1) == C2 + t, x)
Not as convenient as the first solution since t is given as a function of x rather than vice versa, but still a solution.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by