smilingbuddha
smilingbuddha

Reputation: 14670

Differentiating tuple valued functions in mathematica

How does one create and perform differentiation on tuple valued functions in Mathematica.

More specifically, I have the following functions, where R denotes the real line

f:R^2 -> R^3

g:R^3 -> R^3 

h: R^3 -> R^1

I want to consider the composition of these functions k:R^2 -> R^1 i.e. k= h(g(f(x,y))) and I want to find the derivatives k_x, k_y, k_xx, k_yy, k_xy

How can I do this in Mathematica?

Upvotes: 0

Views: 181

Answers (1)

Niki
Niki

Reputation: 15867

I'm assuming you don't have an expression for f,g,h, but you want the derivative of the composition in terms of derivatives of f,g,h.

You could always reduce the problem to single-valued functions, by using a definition like f[x_,y_] := {f1[x,y],f2[x,y],f3[x,y]}

For example:

f[x_, y_] := Through[{f1, f2, f3}[{x, y}]]
g[x_, y_, z_] := Through[{g1, g2, g3}[{x, y, z}]]

D[h @@ g @@ f[x, y], x]

Result:

(Derivative[{1, 0}][f3][{x, y}]*Derivative[{0, 0, 1}][g3][{f1[{x, y}], f2[{x, y}], f3[{x, y}]}] + 
   Derivative[{1, 0}][f2][{x, y}]*Derivative[{0, 1, 0}][g3][{f1[{x, y}], f2[{x, y}], f3[{x, y}]}] + 
   Derivative[{1, 0}][f1][{x, y}]*Derivative[{1, 0, 0}][g3][{f1[{x, y}], f2[{x, y}], f3[{x, y}]}])*
  Derivative[0, 0, 1][h][g1[{f1[{x, y}], f2[{x, y}], f3[{x, y}]}], g2[{f1[{x, y}], f2[{x, y}], f3[{x, y}]}], 
   g3[{f1[{x, y}], f2[{x, y}], f3[{x, y}]}]] + 
 (Derivative[{1, 0}][f3][{x, y}]*Derivative[{0, 0, 1}][g2][{f1[{x, y}], f2[{x, y}], f3[{x, y}]}] + 
   Derivative[{1, 0}][f2][{x, y}]*Derivative[{0, 1, 0}][g2][{f1[{x, y}], f2[{x, y}], f3[{x, y}]}] + 
   Derivative[{1, 0}][f1][{x, y}]*Derivative[{1, 0, 0}][g2][{f1[{x, y}], f2[{x, y}], f3[{x, y}]}])*
  Derivative[0, 1, 0][h][g1[{f1[{x, y}], f2[{x, y}], f3[{x, y}]}], g2[{f1[{x, y}], f2[{x, y}], f3[{x, y}]}], 
   g3[{f1[{x, y}], f2[{x, y}], f3[{x, y}]}]] + 
 (Derivative[{1, 0}][f3][{x, y}]*Derivative[{0, 0, 1}][g1][{f1[{x, y}], f2[{x, y}], f3[{x, y}]}] + 
   Derivative[{1, 0}][f2][{x, y}]*Derivative[{0, 1, 0}][g1][{f1[{x, y}], f2[{x, y}], f3[{x, y}]}] + 
   Derivative[{1, 0}][f1][{x, y}]*Derivative[{1, 0, 0}][g1][{f1[{x, y}], f2[{x, y}], f3[{x, y}]}])*
  Derivative[1, 0, 0][h][g1[{f1[{x, y}], f2[{x, y}], f3[{x, y}]}], g2[{f1[{x, y}], f2[{x, y}], f3[{x, y}]}], 
   g3[{f1[{x, y}], f2[{x, y}], f3[{x, y}]}]]

Upvotes: 1

Related Questions