differential equation with mixed linear and log derivatives - proper setting

3 ビュー (過去 30 日間)
PatrizioGraziosi
PatrizioGraziosi 2020 年 6 月 17 日
コメント済み: Ameer Hamza 2020 年 6 月 17 日
Hello everybody,
I'd like to solve for y = y(x) the following equation
that contains derivatives on both x and log(x).
When I input the equation as
syms y(x) f
eq = diff( log(y), log(x) ) + diff( log(diff(y,x)), log(x) ) + diff( y, log(x) )*log(x) + y ...
== 1 + f;
I always get an error about the log in the differentiation
Second argument must be a variable or a nonnegative integer specifying the number of
differentiations.
I have tried to input it as a system of equations
syms y(x,z) f
eq1 = diff( log(y), x ) + diff( log(diff(y,z)), x ) + diff( y, x )*x + y ...
== 1 + f;
eq2 = x == log(z);
But when I try to solve it
odes = [eq1;eq2];
sol = dsolve(odes);
I get an error that
Symbolic ODEs must have exactly one independent variable.
I'm likely doing something wrong in managing the equations.
Can someone help me, please?
Thanks,
Patrizio

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 6 月 17 日
編集済み: Ameer Hamza 2020 年 6 月 17 日
Using chain-rule, we can write
Therefore, the equation can be written as
syms y(x) f
eq = diff(log(y),x)*1/diff(log(x),x) + diff(log(diff(y,x)),x)*1/diff(log(x),x) + ...
diff(y,x)*1/diff(log(x),x)*log(x) + y ...
== 1 + f;
sol = dsolve(eq);
The symbolic solution is
>> sol
sol =
((2*C2*x^y + C2*f*x^y - C2*x^y*y + 2*C1*x^f*x^2)/(x^y*(f - y + 2)))^(1/2)
-((2*C2*x^y + C2*f*x^y - C2*x^y*y + 2*C1*x^f*x^2)/(x^y*(f - y + 2)))^(1/2)
For numerical solution, try this
syms y(x) f
eq = diff(log(y),x)*1/diff(log(x),x) + diff(log(diff(y,x)),x)*1/diff(log(x),x) + ...
diff(y,x)*1/diff(log(x),x)*log(x) + y ...
== 1 + f;
eq2 = odeToVectorField(eq);
odeFun = matlabFunction(eq2, 'Vars', {'x', 'Y', 'f'});
xspan = [0.1 10];
xs = 0.1:0.001:10;
fv = rand(size(xs));
ffun = @(x) interp1(xs, fv, x);
ic = [1; 2];
[t, y] = ode45(@(x, y) odeFun(x, y, ffun(x)), xspan, ic);
plot(t, y);
  4 件のコメント
PatrizioGraziosi
PatrizioGraziosi 2020 年 6 月 17 日
Brilliant! This is what I couldn't understand, that ic(2) is y', sorry, and many thanks for your support!
Ameer Hamza
Ameer Hamza 2020 年 6 月 17 日
I am glad to be of help!

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

その他の回答 (1 件)

David Goodmanson
David Goodmanson 2020 年 6 月 17 日
編集済み: David Goodmanson 2020 年 6 月 17 日
Hi Patrezio,
d(log(x)) = dx/x, and you can insert that result in three locations to obtain
eq1 = x*diff( log(y), x) + x*diff( log(diff(y,x)), x) + x*diff( y, x)*log(x) + y == 1+f;
z = dsolve(eq1)
Warning: Unable to find explicit solution. Returning implicit solution instead.
> In dsolve (line 197)
solve([((C2 + f*y^2 + 2*y^2 - y^3)/(2*C1))^(1/(f - y + 2)) - x == 0, 1 < y - f], y) union ...
solve([((C2 + f*y^2 + 2*y^2 - y^3)/(2*C1))^(1/(f - y + 2)) - x == 0, ~1 < y - f], y)
There is no explicit solution for y(x), but there is a solution for x as a function of y. The solution is a union of two complementary regions of y, but if you are finding x as a function of y, that fact appears not to matter.
  1 件のコメント
PatrizioGraziosi
PatrizioGraziosi 2020 年 6 月 17 日
編集済み: PatrizioGraziosi 2020 年 6 月 17 日
Hi David,
thank you!
Sure if I find a x as a function of y is fine, however, I find
syms y(x) f
eq = diff(log(y),x)*x + diff(log(diff(y,x)),x)*x + ...
diff(y,x)*x*log(x) + y ...
== 1 + f;
sol = dsolve(eq)
sol =
((2*C2*x^y + C2*f*x^y - C2*x^y*y + 2*C1*x^f*x^2)/(x^y*(f - y + 2)))^(1/2)
-((2*C2*x^y + C2*f*x^y - C2*x^y*y + 2*C1*x^f*x^2)/(x^y*(f - y + 2)))^(1/2)
which is specified in a different way from yours...

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

カテゴリ

Help Center および File ExchangeNumeric Solvers についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by