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:-).

  • 1
    $\begingroup$ 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.) $\endgroup$
    – akater
    May 8, 2014 at 15:49
  • $\begingroup$ 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. $\endgroup$ May 8, 2014 at 16:20
  • 1
    $\begingroup$ @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. $\endgroup$
    – Artes
    May 8, 2014 at 16:31
  • 1
    $\begingroup$ @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. $\endgroup$
    – Artes
    May 9, 2014 at 10:45
  • 1
    $\begingroup$ 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. $\endgroup$ May 9, 2014 at 12:43

1 Answer 1


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.


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.