# Solving for a function?

I am trying to find an ‘elegant’ manner of expressing the need to solve equations of the form f[f[n]]=-n. I’ve been tackling this as a power series expansion but I would like to know whether I can bring Mathematica onto my side, and if so, how one would go about it.

I thank you for your patience.

• For the sake of intellectual honesty, the solution is f [ n ] = in. – James Junghanns Jul 22 '19 at 8:45
• So, What is the question? OK, first, welcome to Mma.SE. Please follow this advice: Start by taking the tour now and learning about asking and what's on-topic. Please edit your question to improve it, make ir more clear, show due diligence and give brief context including minimal working example of the code you have tried in formatted form. By doing all this you help us to help you and likely you will inspire great answers. – rhermans Jul 22 '19 at 8:49
• Perhaps InverseFunction might help: f[n]==f^(-1)[-n] – Ulrich Neumann Jul 22 '19 at 9:23
• That is an interesting question. However, it is too broad, even for pure math people. You need to be more specific on the class of functions your are interested in. For instance, you may be surprised that a real solution of $f(f(x))=exp(x)$ does exist. See this thread math.stackexchange.com/questions/2308409/… . However, there is no real solution to your equation as shown on mathoverflow mathoverflow.net/questions/17614/solving-ffx-gx . – yarchik Jul 22 '19 at 20:49
• Another way to look at your problem is to recall that the Hilbert transform $H$ of a function $x(t)$ defined as $H[x](t)=–\frac{1}{\pi}\int_{-\infty}^{\infty}\frac{x(\eta) d\eta}{t-\eta}$ has the functional property $H[H[x]]=-x$. Exactly what you are searching for. – yarchik Jul 22 '19 at 20:53

I've been tackling this as a power series expansion but I would like to know whether I can bring Mathematica onto my side...

You can use ComposeSeries[] + SolveAlways[] as an exploratory aid:

With[{n = 10}, (* expansion order *)
SolveAlways[ComposeSeries[#, #] &[Sum[C[k] x^k, {k, 1, n}] + O[x]^n] == -x, x]]
{{C[1] -> -I, C[2] -> 0, C[4] -> 0, C[5] -> 3/2 I C[3]^2, C[6] -> 0, C[8] -> 0,
C[9] -> 5/8 I (13 C[3]^4 + 8 C[3] C[7])},
{C[1] -> I, C[2] -> 0, C[4] -> 0, C[5] -> -(3/2) I C[3]^2, C[6] -> 0, C[8] -> 0,
C[9] -> -(5/8) I (13 C[3]^4 + 8 C[3] C[7])}}


Note that your particular solution $$ix$$ is covered by the second set of coefficients.