0
$\begingroup$

We have two variables $u_{1}$ and $u_{2}$ which are functions of $x,t$. That is, $u_{1}=u_{1}(x,t)$ and $u_{2}=u_{2}(x,t)$. Consider the the system of partial differential equations $$\frac{\partial u_{1}}{\partial x}=u_{2},\\\frac{\partial u_{2}}{\partial x}=\frac{\partial u_{1}}{\partial t}.$$

Next, consider the transformation $$w_{11}=u_{1},\quad w_{12}=\frac{u_{1}}{u_{2}}.$$ We need to compute $\frac{\partial w_{1k}}{\partial x}$ for $k=1,2$.

In Mathematica my process is very manual. I am basically using Mathematica to simplify the partial derivatives that I have found using pen and paper. The code is as follows.

(*f[k] denotes the partial derivative of u[k] with respect to x*)
(*g[1] denotes the partial derivative of u[1] with respect to t*)
f[1] = u[2];
f[2] = g[1];

trans = {u[1] -> w[1, 1], u[2] -> w[1, 1] w[1, 2]};

(*Denote y[1,1] as the partial derivative of w[1,1] with respect to x*)
z[1, 1] = f[1] /. trans

(*Denote y[1,2] as the partial derivative of w[1,2] with respect to x*)
(*Denote z[1,1] as the partial derivative of w[1,1] with respect to t*)
z[1, 2] = Factor[(u[2]^2 - u[1] g[1])/u[2]^2 /. trans] /. g[1]->g[1,1]

I would like to compute the partial derivatives of $w_{1k}$ using a single code as opposed to doing it separately. I tried using the built-in function $D[\;]$, but run into problems when defining, for example, $\frac{\partial u_{1}}{\partial x}=u_{2}$ using $D[\;]$. In Mathematica:

D[u[1][x, t], x] = u[2][x, t];

Set::write: Tag D in \!\(\*SubscriptBox[\(\[PartialD]\), \(x\)]\(\(u[1]\)[x, t]\)\) is Protected. >>

I guess my main problem is how to define the system $\frac{\partial u_{1}}{\partial x}=u_{2},\;\;\frac{\partial u_{2}}{\partial x}=\frac{\partial u_{1}}{\partial t}$ in Mathematica that will allow me to use $D[\;]$. Any help/suggestions will be appreciated.

$\endgroup$
0

1 Answer 1

1
$\begingroup$

First we define your system of equations:

eqns = {D[u1[x,t],x] == u2[x,t], D[u2[x,t],x] == D[u1[x,t],t]};

Then we solve your substitution for u1 and u2:

sub = Solve[{w11[x, t] == u1[x, t], w12[x, t] == u1[x, t]/u2[x, t]},
            {u1[x, t], u2[x, t]}]

(* {{u1[x, t] -> w11[x, t], u2[x, t] -> w11[x, t]/w12[x, t]}} *)

Then we transform the variables into the correct functional form:

sub = sub /. {(f_[var__] -> e_) :> (f -> Function[{var}, e])}

(* {{u1 -> Function[{x, t}, w11[x, t]],
     u2 -> Function[{x, t}, w11[x, t]/w12[x, t]]}} *)

Finally we can make the substitution:

eqns /. sub

( *{{Derivative[1, 0][w11][x, t] == w11[x, t]/w12[x, t], 
     Derivative[1, 0][w11][x, t]/w12[x, t] -
      (w11[x, t]*Derivative[1, 0][w12][x, t])/w12[x, t]^2 == 
      Derivative[0, 1][w11][x, t]}} *)

In order to interpret this result, you'll need to know a little about the Derivative operator. In a form like this:

Derivative[3][f]

It represents the third derivative of a function f with one argument. It does partial derivatives like this:

Derivative[3,2][g]

This represents g differentiated three times with respect to its first argument, and differentiated two times with respect to its second argument.

So, to take an example from your transformed system:

Derivative[1, 0][w11][x, t]

Is equivalent to:

$$ \frac{\partial w_{11}}{\partial x} $$

$\endgroup$
2
  • $\begingroup$ Thanks. For the UpSet how can I write the output produced by D[w11[x, t], x] (* u2[x, t] *) purely in terms of w11 and w12? $\endgroup$
    – Jack
    Apr 28, 2015 at 2:35
  • 1
    $\begingroup$ @Jack It wasn't clear to me that you wanted the whole system in terms of w11 and w12... I've changed my answer to hopefully do the transformation you want. $\endgroup$ Apr 28, 2015 at 3:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.