How do you set up an ode solver with a more than one function in the ode?

For example, if you have an ode such as a*df(t)/dt + b*dg(t)/dt + f(t) + g(t) + c = 0 that you'd like to solve and if you want to set one of the derivatives to be zero, how do you do that?
(By "ode solver" in the title I mean solve numerically.)

4 件のコメント

Sam Chak
Sam Chak 2023 年 10 月 8 日
Please correct me if I'm wrong. In your update, you mentioned that you want to numerically solve the ODE of this form:
I'm not so sure, but this form looks like the first-order "Exact differential equation," and I don't remember how to solve it on pen and paper. Suppose that , and . If and , then the equation is balanced:
.
L'O.G.
L'O.G. 2023 年 10 月 8 日
@Sam Chak Thanks, it is of that form, but this isn't necessarily going to be something that cancels. How do you solve this numerically using one of the ode solvers?
Walter Roberson
Walter Roberson 2023 年 10 月 8 日
Use ode15i
Sam Chak
Sam Chak 2023 年 10 月 9 日
I would like to suggest providing a specific example of this generic "Exact differential equation" form:
This would allow us to test which ODE solver might be suitable for solving it.

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

回答 (2 件)

Torsten
Torsten 2023 年 10 月 7 日
移動済み: Torsten 2023 年 10 月 7 日

0 投票

If you have two unknown functions (f and g), you need two equations.
syms f(t) g(t) a b c
df = diff(f);
dg = diff(g);
eqn = a*df + b*dg + f(t) + g(t) + c == 0
eqn(t) = 
sol = dsolve(eqn, g)
sol = struct with fields:
g: 0 f: exp(-t/a)*(C1 - c*exp(t/a))
eqn2 = subs(diff(sol.f), t, 0) == 0
eqn2 = 
constant_of_integration = setdiff( symvar(eqn2), [a b c])
constant_of_integration = 
solution_for_constant = solve(eqn2, constant_of_integration)
solution_for_constant = 
0
subs(subs(eqn, sol), constant_of_integration, solution_for_constant)
ans(t) = 
subs(sol, constant_of_integration, solution_for_constant)
ans = struct with fields:
g: 0 f: -c

カテゴリ

製品

リリース

R2021b

タグ

質問済み:

2023 年 10 月 7 日

コメント済み:

2023 年 10 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by