Symbolic toolbox: symbolic function with a function as a "variable"

1 vue (au cours des 30 derniers jours)
Andrzej Miekina
Andrzej Miekina le 9 Jan 2020
Commenté : Andrzej Miekina le 13 Jan 2020
I tried to defined symbolic function with a function as a variable:
syms y(t)
syms f(t,y(t)) - but it dosn't work
and additionally
f(t,y(t))=diff(y(t))
script below is working
% LOCAL ACCURACY OF MIDPOINT METHOD
% FOR SOLVING ODE
syms f(t,z) y(t);syms h t;
assume(diff(y(t))==f(t,y(t))) % ODE to be solved
r(h)=y(0)-y(-h)-h*f(-h/2,y(-h)+(h/2)*f(-h,y(-h))); % error
r1=simplify(subs(diff(r,h),h,0)) % first derivative of error at t=0
r2=simplify(subs(diff(r,h,2),h,0))% second derivative of error at t=0
r3=simplify(subs(diff(r,h,3),h,0))% third derivative of error at t=0
has provided correct results (i.e. derivatives of error with respect h), but in an illegible form because the instruction "simplify" has ignored the key assumption:
assume(diff(y(t))==f(t,y(t)));
in the case of r1 and r2, the result should be 0...
  1 commentaire
Star Strider
Star Strider le 9 Jan 2020
I am not certain what you want to do.
See if the compose function helps.

Connectez-vous pour commenter.

Réponses (1)

Srivardhan Gadila
Srivardhan Gadila le 13 Jan 2020
You can define y, f & t as follows:
syms t y(t) f(t,y)
Then check for f as follows:
>> f(t,y)
ans =
f(t, y(t))
You may also refer to https://in.mathworks.com/help/symbolic/solve-a-single-differential-equation.html and related links, examples in the webpage.
  1 commentaire
Andrzej Miekina
Andrzej Miekina le 13 Jan 2020
Yes I found it and tried with compose
but how to assume that
f(t,y) == diff(y,t)

Connectez-vous pour commenter.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by