Partial derivative with respect to x^2

16 visualizaciones (últimos 30 días)
Yadavindu
Yadavindu el 18 de Nov. de 2022
Comentada: VBBV el 20 de En. de 2023
Suppose I have a function f
f = (x^5*y^3+ z^2*x^2+y*x) / (x^3*y+x*y)
how do I take derivative of this function with respect to x^2.
I have used diff(f, x^2) but it is returning an error.
syms x y z
f= (x^5*y^3+ z^2*x^2+y*x) / (x^3*y+x*y)
f = 
diff(f,x^2)
Error using sym/diff
Second argument must be a variable or a nonnegative integer specifying the number of differentiations.

Respuestas (3)

David Goodmanson
David Goodmanson el 18 de Nov. de 2022
Editada: David Goodmanson el 18 de Nov. de 2022
Hi Yadavindu,
df/d(x^2) = (df/dx) / (d(x^2)/dx) = (df/dx) / (2*x)
which you can code up without the issue you are seeing.
  5 comentarios
Yadavindu
Yadavindu el 18 de Nov. de 2022
so the code would be
syms x y z
f= (x^5*y^3+ z^2*x^2+y*x) / (x^3*y+x*y)
f = 
f1=diff(f,x)
f1 = 
f2= f1/(2*x)
f2 = 
David Goodmanson
David Goodmanson el 18 de Nov. de 2022
yes, although you could write it in one line and toss in a simplify:
syms x y z
f= (x^5*y^3+ z^2*x^2+y*x) / (x^3*y+x*y);
f1 = simplify(diff(f,x)/(2*x))
f1 = (2*x^5*y^3 + 4*x^3*y^3 - x^2*z^2 - 2*x*y + z^2)/(2*x*y*(x^2 + 1)^2)

Iniciar sesión para comentar.


KSSV
KSSV el 18 de Nov. de 2022
syms x y z
f= (x^5*y^3+ z^2*x^2+y*x) / (x^3*y+x*y)
f = 
dfdx = diff(f,x)
dfdx = 
dfdx2 = diff(dfdx,x)
dfdx2 = 
  1 comentario
Yadavindu
Yadavindu el 18 de Nov. de 2022
Thank you for your reply, however I think, if I take derivative of d(df\dx)\dx = (d^2(f) \ (dx)(dx)) will give double partial derivative rather my question was whether there exist any direct way to calculate (df / d(x^2)).

Iniciar sesión para comentar.


VBBV
VBBV el 18 de Nov. de 2022
Editada: VBBV el 18 de Nov. de 2022
syms x y z t
f= (x^5*y^3+ z^2*x^2+y*x) / (x^3*y+x*y)
f = 
% t = x^2 % assume x = sqrt(t)
F = subs(f,x,sqrt(t))
F = 
y = diff(F,t)
y = 
Y = subs(y,t,x^2) % back substitute with x
Y = 
  3 comentarios
Yadavindu
Yadavindu el 18 de Nov. de 2022
Thank you for your reply
VBBV
VBBV el 20 de En. de 2023
If it solved your problem (which i hope it did) pls accept the answer.

Iniciar sesión para comentar.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by