Ask Your Question
2

partial derivatives

asked 2024-06-29 16:24:20 +0100

KingUncrowned gravatar image

updated 2024-06-30 12:32:22 +0100

I have the function $f(x,y,y')= \sqrt{1+y'(x)^2}$ from which I want to calculate $\frac{\partial f}{\partial y}$ as well as $\frac{\partial f}{\partial y'}$ and $\frac{d}{dx}\left(\frac{\partial f}{\partial y'}\right)$.

I tried using the SymbolicRing of Sagemath with

 x = SR.var('x')
 y = function('y')
 f = sqrt(1+y(x).diff(x,1)^2)

which only allows me to calculate $\frac{df}{dx}$. So I tried with the following sample

 x,y = SR.var('x,y')
 y = function('y')(x)
 y1 = y.diff(x,1)
 f(x,y,y1) = sqrt(1+y1^2)
 fy1 = f.diff(y1)
 fy = f.diff(y)
 dxfy1 = fy1.diff(x)

which works for calculating $\frac{\partial f}{\partial y}$ and $\frac{\partial f}{\partial y'}$, but not for $\frac{d}{dx}\left(\frac{\partial f}{\partial y'}\right)$. Because dxfy1 which stands for $\frac{d}{dx}\left(\frac{\partial f}{\partial y'}\right)$ returns 0 when it should return $\frac{y''}{\sqrt{1+y'(x)^2}^{3/2}}$.

Another unseccesful try would be

x,y = SR.var('x,y')
y = function('y')(x)
y1 = y.diff(x,1)
y1=function('y1')(x)
f(x,y,y1) = sqrt(1+y.diff(x)^2)
fy1(x,y,y1) = f.diff(y1); fy1
fy(x,y,y1) = f.diff(y); fy
fy1.diff(x)

I'd really appreciate any idea. Thanks in advance!

edit retag flag offensive close merge delete

Comments

is $y'$ a notation for $\frac{dy}{dx}$ ?

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2024-06-29 19:39:22 +0100 )edit

Nver mind : your code anwered for you.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2024-06-29 20:48:49 +0100 )edit

Yes, $y'$ stand for $\frac{dy}{dx}$. @Emmanuel Charpentier

KingUncrowned gravatar imageKingUncrowned ( 2024-06-30 00:16:09 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2024-06-29 20:51:56 +0100

Emmanuel Charpentier gravatar image

Since $y$ is a function of $x$, so is $y'$, and $f$ is a function of $x$ and $x$ alone : fixing $x$ fixes $y(x)$ and $y'(x)$.

End of story.

HTH,

edit flag offensive delete link more

Comments

But if I write f(x) = sqrt(1+y1^2) then f.diff(y) won't work. What can I do?

KingUncrowned gravatar imageKingUncrowned ( 2024-06-30 00:17:42 +0100 )edit

Write it correctly : when you write $f(x)=\sqrt{1+y'^2}$, you are eliding the real expression $f(x)=\sqrt{1+y'(x)^2}$, which reminds you that the only argument of $f$ if $x$ ; $y'$ is just a notation for some expression including $x$ which is fixed for a given $x$. Differentiating "with respect to $y'$" is nonsense.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2024-06-30 05:50:40 +0100 )edit

@Emmanuel Charperntier some days ago I thought like you, but in fact $f$ depends not only on the independent variable $x$ but also on the dependent functions $y$ and $y'$. So $\frac{\partial f}{\partial y'}$ makes sense with the solution [here] (https://math.stackexchange.com/questions/4938742/trouble-understanding-frac-partial-y-partial-y (https://math.stackexchange.com/questi...)). So definitely it is needed $f(x,y,y')$, problem comes when doing $\frac{d}{dx}\frac{\partial f}{\partial y'}$ in code.

KingUncrowned gravatar imageKingUncrowned ( 2024-06-30 12:24:55 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-06-29 16:24:20 +0100

Seen: 411 times

Last updated: Jun 30