# Is there a function that gives the same result for a number and its reciprocal?

Is there a (non-piecewise, non-trivial) function where $f(x) = f(\frac{1}{x})$?

### Why?

It would be nice to compare ratios without worrying about the ordering of numerator and denominator. For example, I might want to know whether the "magnitude" of the ratio (maybe the "absolute ratio") of the widths of two objects is greater than $2$, but not care which is larger.

It occurred to me that there's a common solution for this problem when comparing the difference of two numbers: the square of a number is the same as the square of its opposite - $(a-b)^2=(b-a)^2$. This is really useful with Euclidean distances, because you don't have to worry about the order of subtraction or use absolute values. Can we get the same elegance for ratios?

Difference: $g(a-b)=g(b-a) \rightarrow g(x)=x^2$

Ratio: $f(\frac{a}{b})=f(\frac{b}{a}) \rightarrow f(x)=\ ?$

• $$f(x) = x + \frac{1}{x}$$ Nov 25, 2013 at 4:34
• For positive $x$, we have $(\ln(x))^2=(\ln(1/x))^2$. So $f(t)=(\ln(t))^2$ works. But it may not be what you are after. Nov 25, 2013 at 4:35
• $f(x) = x \times \frac1x$. Nov 25, 2013 at 4:40
• @StephenMontgomery-Smith that's not a very useful solution, but kudos for it anyway :) Nov 25, 2013 at 4:43
• Your use of $\Longrightarrow$ is very disconcerting. Nov 25, 2013 at 10:05

$$\frac{x}{x^2+1}$$ the inverse of Will Jagy's $x + \frac{1}{x}$.

I like $$x - \frac{1}{x} = \frac{x^2-1}{x}$$ because it contains sign information (input magnitude greater or less than one) that you may choose to ignore, and gives a nice zero for $x = \frac{1}{x} = \pm 1$. If you choose to take the absolute value of it (ignoring the sign) it gives you the desired $f(x) = f(\frac{1}{x})$

• For that matter, any $f(x) + f(\frac{1}{x})$, or $f(x)\cdot f(\frac{1}{x})$ Nov 25, 2013 at 4:59
• Oooh that's nice Nov 25, 2013 at 6:36
• ...or simply any $f(x+\frac1x)$ (or, if you want adamW's sign dependency, $f(x-\frac1x)$) Nov 25, 2013 at 10:38

For lack of a better idea, $f(x)=|\ln x|$.

$$\frac{1}{1 + x + \frac{1}{x}} = \frac{x}{x^2 + x + 1}$$ extends to the real analytic function written on the right. Notice that $x^2 + x + 1 = (x + \frac{1}{2})^2 + \frac{3}{4} \geq \frac{3}{4}.$

For lack of anything worse than this, $f(x)=(x - \frac{1}{x})^2$.

Let $f(x)$ be arbitrary for $-1\leqslant x\leqslant 1,$ and define $f(x):=f(1/x)$ otherwise.

• The question specifies "non-piecewise" Nov 25, 2013 at 16:17
• @Sparr: This definition includes the "non-piecewise" function specified in Will Jagy's answer as well as the first function in adam W's answer. (The other functions require a second statement to define them at $0.$) In fact, it includes all functions $f$ that satisfy $f(x)=f(1/x)$ for $x\neq 0.$ Nov 25, 2013 at 18:18
• one of the pieces of your function being non-piecewise does not make your function non-piecewise. pretty much the opposite, actually Nov 25, 2013 at 19:30
• @Sparr: Agreed. Nov 25, 2013 at 21:26

It works for any function $$f(x) = g(x, \frac{1}{x})$$ where $$g$$ is symmetric (i.e., $$g(x, y) = g(y, x)$$).

A simple example is to have $$g$$ be the addition operator, so $$f(x) = x + \frac{1}{x}$$.

• OP wants actual functions Nov 25, 2013 at 19:02