Message Boards Message Boards

Symbolic substitution with differential equations?

This problem can be done by hand but I am just curious how to implement it in Mathematica. I would like to calculate a simple wronskian with a constraint expressed as a differential equation.

w=F'[x]G[x]-F[x]G'[x]

the derivative of the wronskian is:

w'=F''[x]G[x]-F[x]G''[x]

I would like to implement the constraint that: F''[x]=A F[x] and G''[x]=B G[x] that would make w' vanish. I thought I could simplify do that with Refine on w' so that:

Refine[w',Assumptions-> {F''[x]==A F[x],G''[x]=B G[x]}]

But it does not work. Any suggestion for the substitution that would make w' vanish?

JGuy

POSTED BY: Jean Guy Lussier
8 Replies

I get the desired result if I inverse the Conjugate and ComplexExpand commands:

PiecewiseExpand[Conjugate@ComplexExpand[h[x]], Element[x, Reals]]

It is like the ComplexExpand is ineffective... but change the result if it is done after the Conjugate.

POSTED BY: Jean Guy Lussier
Posted 8 years ago

It seems that PiecewiseExpand has problems with ComplexExpand: the input

h[x_] = Piecewise[{{I x, x > 0}}, 1 + I];
PiecewiseExpand[ComplexExpand[Conjugate[h[x]]]]

gives a result that looks wrong to me. I would expect the same output as

PiecewiseExpand[Conjugate[h[x]], Element[x, Reals]]
POSTED BY: Updating Name

The function for you is probably ComplexExpand. Unfortunately neither ComplexExpand nor Conjugate threads nicely over Piecewise (an oversight by Wofram?). Even Composition ignores Piecewise. You can force a function inside Piecewise with this utility:

piecewiseThread[comd_] := 
 HoldPattern[Piecewise[stuff_, dflt_]] :> 
  Piecewise[Map[{comd[#[[1]]], #[[2]]} &, stuff], comd[dflt]]

Then you can type

Wronskian[{f[x], f[x] /. piecewiseThread[Conjugate]} /. 
  piecewiseThread[ComplexExpand], x]

and get a nice formula.

POSTED BY: Gianluca Gorni
Posted 8 years ago

The function for you is probably ComplexExpand. Unfortunately neither ComplexExpand nor Conjugate threads nicely over Piecewise (an oversight by Wofram?). Even Composition ignores Piecewise. You can force a function inside Piecewise with this utility:

piecewiseThread[comd_] := 
 HoldPattern[Piecewise[stuff_, dflt_]] :> 
  Piecewise[Map[{comd[#[[1]]], #[[2]]} &, stuff], comd[dflt]]

Then you can type

Wronskian[{f[x], f[x] /. piecewiseThread[Conjugate]} /. 
  piecewiseThread[ComplexExpand], x]

and get a nice formula.

POSTED BY: Updating Name

Thank you for the functional programming tip! A month ago, I had no clue about Mathematica. Now I can't stop using it! Here is another problem I encountered (it is about plane waves in physics):

f[x_] := Piecewise[{{E^(I K x) + r E^(-I K x), x <= -a/2}, {t E^(I K x) , x >= a/2}}]

and I want to calculate the wronskian between the function f[a/2] and its conjugate f*[a/2]. I want the same also at x=-a/2. How would I do that with the Piecewise definition? The only way I could do the calculation is by typing it long explicitly (so I could not use the built-in Wronskian[] function):

wronskian=Refine[f[x], Assumptions -> {a > 0, x >= a/2}] D[Refine[Conjugate[f[x]], Assumptions -> {a > 0, x >= a/2}], x] -
Refine[Conjugate@f[x], Assumptions -> {a > 0, x >= a/2}] D[Refine[f[x], Assumptions -> {a > 0, x >= a/2}], x]

All my attempts in defining another function h[x]=Refine[...] do not work because I loose the x dependence of the function (all the parameters become equivalent and the derivative is not performed).

JGuy

POSTED BY: Jean Guy Lussier

Given that the Wronskian is a function of functions, it's probably more natural to define:

w[f_, g_][x_] := f'[x] g[x] - f[x] g'[x]
wd[f_, g_][x_] = D[w[f, g][x], x]              (* note the Set "=" here *) 

However, since version 7.0, Mathematica already has a built-in function Wronskian! Used in the form:

 Wronskian[{f[x], g[x]}, x]

And it generalizes from just two function-expression arguments to an arbitrary number. The docs include an application to using the method of variation of parameters.

(I guess one moral is that it's always a good idea to check the documentation first.)

POSTED BY: Murray Eisenberg

Thank you very much! I have tried:

w[f_[x_], g_[x_]] := D[f[x], x] g[x] - f[x] D[g[x], x]
derivativewronskian = D[w[h[x], k[x]], x]

Reduce[derivativewronskian ==  d[x] /. {D[h[x], {x,2}] -> (v - e0) h[x]/a, D[k[x], {x, 2}] -> (v - e0) k[x]/a}]

It nicely returned d[x]==0. Amazing! Thanks again!

JGuy

POSTED BY: Jean Guy Lussier
      Reduce[w'[x] == 0 /. {F''[x] -> a F[x], G''[x] -> b G[x]}, {a, b}]
(* b == a || F[x] == 0 || G[x] == 0  *)

(I've used lower case a and b lest you be tempted in another situation to try to use upper-case C, which has a reserved meaning.)

POSTED BY: Murray Eisenberg
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract