How do I find second order implicit differentiation (d2y/dx2) of a function in MATLAB

6 visualizaciones (últimos 30 días)
Hello, I'm able to find 1st order (dy/dx) of a function, but if I try to do the process again on dy/dx it doesn't work to find d2y/dx2. I'm curious if anyone knows what the problem is or how to find d2y/dx2. I have a feeling that the problem is that I get dy/dx in terms of x and y(x) and not x and y, but I can't seem to change y(x) back to y when I use the sub command. This is the code:
syms x y DY DF y(x)
F=x^2+y^2==1;
dy=diff(y);
dx=diff(F,x);
DF=subs(dx,dy,DY);
dydx1=solve(DF,DY);
dydx=simplify(dydx1)
Gets the correct answer for dydx. I'd like to find d2y/dx2 now. The answer for d2y/dx2 is:
d2ydx2=-(x^2+y^2)/y^3
d2ydx2(x) = 
Aslo, using dydx = -Fx/Fy doesn't work for 1st order, unless more code is needed.
% F=x^2+y^2-1; dydx1=-diff(F,x)/diff(F,y); dydx=simplify(dydx1)
dydx(x) = 
Thank you.

Respuesta aceptada

Walter Roberson
Walter Roberson el 29 de Mayo de 2025
Movida: Walter Roberson el 29 de Mayo de 2025
syms x y DY DF y(x)
F=x^2+y^2==1;
dy=diff(y);
dx=diff(F,x);
DF=subs(dx,dy,DY);
dydx1=solve(DF,DY);
dydx=simplify(dydx1)
dydx = 
temp = diff(dydx, x)
temp = 
simplify(subs(temp, diff(y), dydx))
ans = 
  1 comentario
rezheen
rezheen el 29 de Mayo de 2025
Editada: rezheen el 29 de Mayo de 2025
Walter,
I added a little more to the code you provided to change back from y(x) to y and it works. Thank you!
d2ydx2=simplify(subs(temp, diff(y), dydx));
d2ydx2=subs(d2ydx2,y,'y')

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by