# Solving functional equations in Mathematica

I am trying to solve functional equations in Mathematica, but got nowhere. Just a simple example: $$f(x+y)^2=f(x)^2+f(y)^2$$ for all $x,y \in R$, assuming f is a real-valued function.

How should I approach this problem in Mathematica ?

-
RSolve is supposed to be able to solve functional equations, but I could not use it on the above, may be I am not setting it up right. But you can google RSolve in documentaion center, they have some examples. reference.wolfram.com/mathematica/ref/RSolve.html – Nasser Aug 28 '13 at 16:29
@Nasser where do you see that? I only see that it is capable of solving difference equations. – rcollyer Aug 28 '13 at 16:35
@rcollyer, it said : Solve a functional equation: and the OP is asking for Solve a functional equation So, I simply posted a link. I did not say it can do the one being asked for or not. It is right there on the page, down near the last example. May be the terminology is not clear. – Nasser Aug 28 '13 at 16:38
@Nasser I see it now. My mistake. Likely, it can only be used in some special cases as I don't see much in the way of further discussion on the topic. – rcollyer Aug 28 '13 at 16:44

## 1 Answer

At first we should try to envision what kind of function it might be. We need no computer system for that. So let's start with assumptons: $f$ is a real valued function on the real domain. Therefore we have: $$f(x+0)^2=f(x)^2+f(0)^2$$ thus $$f(0)=0$$ Then $$f(x-x)^2=f(x)^2+f(-x)^2$$ it implies $$0=f(x)^2+f(-x)^2$$ Sum of two non-negative numbers is zero ($f$ is real valued function), therefore for all $x$ $$f(x)=0$$

We need no Mathematica functionality for this conclusion.

Edit

Assuming that we need certain functions of the system the problem is more involved and can be analyzed on a case by case basis. At first, basically it depends on the functional relations to be solved. Then we should choose appropriately the class of functions where we can search for solutions.
Although mathematically speaking the above problem is quite simple it appears to be much more difficult for computer systems when no assumption on class of functions is given.

Assuming, that we are looking for polynomial functions there is e.g. SolveAlways working nicely for lower order polynomials. It finds however many dulicates (in our case) of the same solutions and for this reason it couldn't work directly for higher order polynomials. Define e.g. a univariate n-th order polynomial:

f[x_, n_] := Total @ Array[ a[#] x^# &  , n + 1, 0]


and among this class the following function yields all solutions (with multiplicity counting):

sol[n_] := With[{ sol = SolveAlways[ f[x + y, n]^2 == f[x, n]^2 + f[y, n]^2, {x, y}]},
{ DeleteDuplicates @ #, Length @ #}& @ sol]


for third order polynomials:

sol[3]

{{{a[0] -> 0, a[1] -> 0, a[2] -> 0, a[3] -> 0}}, 6}


while for e.g. seventh order polynomials:

sol[7]

{{{a[0] -> 0, a[1] -> 0, a[2] -> 0, a[3] -> 0, a[4] -> 0, a[5] -> 0,
a[6] -> 0, a[7] -> 0}}, 720}


We might find other ways but this one demonstrates clearly what kind of problems we encounter.

-
as an aside, if f does not have to be real then f-> Function[x,I^(-1-(I Log[x])/\[Pi])] is a possible solution. – chuy Aug 28 '13 at 19:14
which of course is an overcomplicated way to write -I Sqrt[x]... – chuy Aug 28 '13 at 19:24