20
$\begingroup$

First, inline free form input can solve these equations:

But it seems no native Mathematica function can solve these, there is even an error page for equations of this form (nestdv).

Now my question is: Is this a function implemented only in Wolfram Alpha but not Mathematica? How can we solve these equations in Mathematica (natively)?

$\endgroup$
8
$\begingroup$

It doesn't seem there is a one line solution but we can adapt W|A to give a result similar to DSolve and friends.

fSolve[eq_Equal] := fSolve @ ToString@eq;

fSolve[eq_String] := Values[ WolframAlpha[
   "solve " <> eq, {"SolutionAsAFunctionalEquation", "FormulaData"}
 ]
] /. Hold[Equal[f_, d_]] :> f -> d /. {
   Subscript[\[ScriptC], n_] :> C[n], \[ScriptC] -> C[0]
}

fSolve["f[f[x]] == f[1 + x]"]
{f[x] -> 1 + x}
fSolve[f[f[x]] == x]
{{
  f[x] -> -x + C[0], 
  f[x] -> C[0]/x, 
  f[x] -> (-x + C[1])/(1 + x C[2]),
  f[x] -> 1/2 (x C[1] + Sqrt[-4 x^2 + C[1]^2 + C[2]]), 
  f[x] -> (-x^3 + C[0])^(1/3)
}} 
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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