Skip to main content
gamedev.net
🔒 Locked

Quick math question

Started by Sagar_Indurkhya May 20, 2006 at 7:22 PM 6 replies 1k views
Original Post
Sagar_Indurkhya
Sagar_Indurkhya
How do I take the partial derivative of a function with respect to another function? Suppose I have function f(x,y). Lets suppose that values of x are actually the result of some function g, and values of y come from a function h. Is there a way to differentiate with respect to functions like df/dh rather than df/d(some variable) as usually done?
cutthepeace
cutthepeace
So I'm guessing z = f(x,y) where x=g(t) and y=h(t)?
--If so, then it's a chain rule: dz/dt = (∂f/∂x)(dx/dt) + (∂f/∂y)(dy/dt)

If x and y are functions of more than one var, like say x=g(s,t) and y=h(s,t)
--Then: (∂z/∂s) = (∂z/∂x)(∂x/∂s) + (∂z/∂y)(∂y/∂s)
--And : (∂z/∂t) = (∂z/∂t)(∂x/∂t) + (∂z/∂y)(∂y/∂t)
Sagar_Indurkhya
Sagar_Indurkhya
Quote:
Original post by cutthepeace
So I'm guessing z = f(x,y) where x=g(t) and y=h(t)?
--If so, then it's a chain rule: dz/dt = (∂f/∂x)(dx/dt) + (∂f/∂y)(dy/dt)

If x and y are functions of more than one var, like say x=g(s,t) and y=h(s,t)
--Then: (∂z/∂s) = (∂z/∂x)(∂x/∂s) + (∂z/∂y)(∂y/∂s)
--And : (∂z/∂t) = (∂z/∂t)(∂x/∂t) + (∂z/∂y)(∂y/∂t)



No no, I already thought about this approach, but in fact, x = some function of multiple variable, and each of those variables are functions of multiple variables, etc etc. So basically if you sat down and tried to expand the original function you would have to expand forever because there is no end. So instead I want to just take the partial w/ respect to the input function rather than the variable.
etothex
etothex
You can't just use the standard chain rule, you have to use its generalization, the Jacobian matrix. For example:

the jacobian matrix of a function f: R^2->R^2 f(x, y) = ( a(x, y), b(x, y) ) is Jf =

[  ∂a/∂x ∂a/∂y   ∂b/∂x ∂b/∂y ]


The Chain Rule, then, can be expressed compactly as:

Jg o f = Jf * Jg

The values of the derivatives can then be read from the jacobian for g o f.

Similarly, derivatives functions f:R^m->R^n can be generalized as m*n jacobian matrices. You can see that this simplifies to the standard chain rule.

It's difficult to give proper mathematical justification for this without linear algebra - but put simply, the jacobian matrix is a transformation between tangent spaces of the two functions.

You can see in your case, if you wish to compose two functions f:R^2->R^2 and g:R^2->R^2 the composition g o f would be also R^2->R^2 and the jacobian matrix for f, g, and g o f would be a 2x2 matrix.

feel free to ask for clarification. jacobians are one of the more difficult concepts of differential vector calculus.

[Edited by - etothex on May 21, 2006 2:57:25 AM]
Sagar_Indurkhya
Sagar_Indurkhya
Quote:
Original post by etothex
You can't just use the standard chain rule, you have to use its generalization, the Jacobian matrix. For example:

the jacobian matrix of a function f: R^2->R^2 f(x, y) = ( a(x, y), b(x, y) ) is Jf =

[  ∂a/∂x ∂a/∂y   ∂b/∂x ∂b/∂y ]


The Chain Rule, then, can be expressed compactly as:

Jg o f = Jg * Jf

The values of the derivatives can then be read from the jacobian for g o f.

Similarly, derivatives functions f:R^m->R^n can be generalized as m*n jacobian matrices. You can see that this simplifies to the standard chain rule.

It's difficult to give proper mathematical justification for this without linear algebra - but put simply, the jacobian matrix is a transformation between tangent spaces of the two functions.

You can see in your case, if you wish to compose two functions f:R^2->R^2 and g:R^2->R^2 the composition g o f would be also R^2->R^2 and the jacobian matrix for f, g, and g o f would be a 2x2 matrix.

feel free to ask for clarification. jacobians are one of the more difficult concepts of differential vector calculus.


Ok, you got me thinking... here is my problem essentially:

I have a function f(x,y) where x is some function and y is some function. Both x and y are multivariable functions that depend on other functions, and so on. Eventually some functions in this tree will depend on t. So I'm debating whether I need the directional derivative/gradient(I don't know what direction I would take it in, and i'm not sure if i want the gradient). I want to know df/dt, but I'm having trouble grasping how to approach this.

BTW, this is not a homework problem, its for a research project in math. My background is multivariable calculus and half of linear algebra(still taking it).

I'm interested in learning more about the jacobian but I was wondering you could recommend some good sources to read about them? I have studied them a little in multivariable, but we rushed through them so we only used them when making transformation of coordinate systems to make integration easier.



Way Walker
Way Walker
Quote:
Original post by Sagar_Indurkhya
No no, I already thought about this approach, but in fact, x = some function of multiple variable, and each of those variables are functions of multiple variables, etc etc. So basically if you sat down and tried to expand the original function you would have to expand forever because there is no end. So instead I want to just take the partial w/ respect to the input function rather than the variable.


You can differentiate w.r.t. a function. It's like with an Arrhenius relationship we say that some quantity f is "proportional to" e^(-Q/kT). This is no different than saying that the derivative of f w.r.t. e^(-Q/kt) is constant.

f = A e^(-Q/kT)
df/d[e^(-Q/kT)] = A

But it sounds like you may have some sort of recursion of variables that makes it a little trickier. Your vagueness makes it hard to offer good advice.
etothex
etothex
Quote:
Original post by Sagar_Indurkhya
Ok, you got me thinking... here is my problem essentially:

I have a function f(x,y) where x is some function and y is some function. Both x and y are multivariable functions that depend on other functions, and so on. Eventually some functions in this tree will depend on t. So I'm debating whether I need the directional derivative/gradient(I don't know what direction I would take it in, and i'm not sure if i want the gradient). I want to know df/dt, but I'm having trouble grasping how to approach this.


Assuming all functions eventually end up as functions of t, you can find the total derivative df/dt by the method shown above by repeated application of the jacobian multiplication. I'll do an example.

Assume:
f:R^2->R
f(x,y) (i.e., is a real valued function)

g:R^2->R^2
g(u, v)

h:R->R^2
h(t)

We have the associated jacobian matrices for each function: Jf, Jg, Jh, which are respectively equal to:

Jf = [  ∂f/∂x  ∂f/∂y  ]  (1x2 matrix)Jg = [  ∂g1/∂u ∂g1/∂v    (2x2 matrix)        ∂g2/∂u ∂g2/∂v ]  note that g = (g1, g2) vectorJh = [  ∂h1/∂t      (2x1 matrix)         ∂h2/∂t ]    h = (h1, h2) vector


Now you wish to find the Jacobian matrix of the composition of all 3 functions, h o g o f. It is simply:

Jh o g o f = Jf * Jg * Jh

Note that this is a (1x2 matrix) * (2x2 matrix) * (2x1 matrix). The row/columns of the matrix multiplication always work out because the functions inputs and outputs match up If you tried to compose a function with 2 inputs and a function with 3 outputs, the jacobians won't work.

Further note that the result is a 1x1 matrix, which is:

[  ∂f/∂t ]


But since the distinction between ∂f/∂t and df/dt is purely notational here (since f is purely a function of t in the end), you now have your complete derivative df/dt. Note that in practice, this may have other variables such as x, y, u, v, etc; you merely need to substitute from the initial functions into the result to get df/dt purely in terms of t.

Quote:

BTW, this is not a homework problem, its for a research project in math. My background is multivariable calculus and half of linear algebra(still taking it).

I'm interested in learning more about the jacobian but I was wondering you could recommend some good sources to read about them? I have studied them a little in multivariable, but we rushed through them so we only used them when making transformation of coordinate systems to make integration easier.


good for you, linear algebra is (IMHO) more fundamental and powerful than calculus even, it is very useful in infinitely different ways in math, science, and engineering.

Unfortunately I don't know of many good resources on the jacobian. Wikipedia and PlanetMath provide some details, and Mathworld (at wolfram) has some though it's disappointingly little. Even my standard reference for all things calculus (Calculus, by Stewart) glosses over the Jacobian.

I would start at the links on the wikipedia page and go from there with google. Good luck :) Feel free to reply or PM me with more questions.

EDIT: In this (and the above) post I messed up the order of matrix multiplication. All fixed now.

[Edited by - etothex on May 21, 2006 2:50:00 AM]
mnansgar
mnansgar
This is getting into some more advanced math, but you might want to look into Functional Derivatives as well. There are some good examples in the Wikipedia entry.
h20, member of WFG 0 A.D.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.