Skip to main content

wolfram alpha queries - Can Mathematica solve functional equations with nested variable?


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)?



Answer



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)
}}

Comments