Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to solve the following differential equation:

delta = -(1/r D[#, r] + D[#, {r, 2}] - # l^2/r^2) &;
    g[r]] + (B l + B^2 r^2/4) g[r] == en g[
    r], g[r], r]

The solution proposed by Mathematica is okay yet one can find an alternative, less complex representation with Whittaker functions. Is it possible to force Mathematica to use a certain type of function as a solution of a differential equation? We do not impose any boundary conditions.

In this specific problem one can always use a transformation rule for the confluent hypergeometric function, for instance

rule = HypergeometricU[a_, b_, z_] -> 
  E^(z/2) z^(-b/2) WhittakerW[b/2 - a, (b - 1)/2, z];

but this is just a workaround. Perhaps there is a more elegant way.


For instance, consider the harmonic oscillator equation

DSolve[-y''[x] == y[x], y[x], x]
{{y[x] -> C[1] Cos[x] + C[2] Sin[x]}}

Is it possible to force a solution with exponential functions? Of course, the replacement rule can be used but perhaps there is a deeper solution.

{{y[x] -> C[1] Exp[I x] + C[2] Exp[-I x]}}

It would be great if Mathematica could provide a list of exemplary solutions (but this is just wishful thinking:-).

share|improve this question
Side comment: even FullSimplify[DSolve[…], TransformationFunctions -> {Automatic, # /. rule &}] doesn't return solution with WhittakkerW. (Though I personally don't have any experience with this option.) – Akater May 8 '14 at 15:49
Righ, this doesn't work (sorry, I have no time to check why, gotta go in a sec). If you tried applying my rule to the output of DSolve, then there should be a substitution. – Gregory Rut May 8 '14 at 16:20
@GregoryRut This might be an interesting question, however you should explain more clearly what you expect to get. This rule works fine and it might be easily demeonstrated that's true, however the system finds a combination of LaguerreL and WhittakerW more complicated than combnations of hypergeometric functions with Pochhammer. – Artes May 8 '14 at 16:31
@GregoryRut You still haven't posed precisely your question. Appropriate initial condition in principle can provide an adequate function (solution). However if you don't want specify initial conditions you could evaluate e.g. Collect[TrigToExp[C[1] Cos[x] + C[2] Sin[x]], E^(I x)], but in general it depends on case by case basis. – Artes May 9 '14 at 10:45
AFAIK there is no way to specify preferred functions for the output of DSolve. Your "workaround" of explicitly applying the desired transformation rule is probably the best solution. – Simon Woods May 9 '14 at 12:43

I am not sure if this would be what you want, but using ComplexityFunction well as TransformationFunctioncan get you somewhere.

cf[expr_] := 100 Count[expr, _HypergeometricU, {0, Infinity}] + LeafCount[expr]
tf[expr_] := expr /. HypergeometricU[a_, b_, z_] :>
              E^(z/2) z^(-b/2) WhittakerW[b/2 - a, (b - 1)/2, z]

FullSimplify[sol, ComplexityFunction -> cf, 
 TransformationFunctions -> {Automatic, tf}]

(* (2^(l/2) (r^2)^((
 1 + l)/2) (Sqrt[2] E^((B r^2)/4)
     C[2] LaguerreL[-((B + en)/(2 B)), l, -((B r^2)/2)] + 
   2^((2 + l)/2) (-B r^2)^(1/2 (-1 - l))
     C[1] WhittakerW[1/2 (-(en/B) + l), l/2, -((B r^2)/2)]))/r *)

You need to make HypergeometricU[a,b,z] more "complex" than E^(z/2) z^(-b/2) WhittakerW[b/2 - a, (b - 1)/2, z] in order to force FullSimplify to consider "moving" in that direction.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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