Fist of all, I'm a programmer, not a mathematician, and I'm sorry for my non native English. And I'm sorry if the question is not appropriate, it is my first time here. Or if the question has no answer.
I am writing a very complex program in the Scheme language and I'm stuck in a problem. I need a function that satisfies the following condition:
First condition
$$ f(x, y) = f(x^{-1}, y^{-1})^{-1} \tag{1} $$
Well, I know that $f=\times$ or $f=\div$, e.g., can satisfies it.
For example:
if $f=\times$ and
if $x = 5$ and $y = 8$ then:
$$ f(x, y) = f(x^{-1}, y^{-1})^{-1} = 40 $$
But I have an extra condition, which makes it difficult:
Second condition
The result of $f(x, y)$ should be aprox. the simple average between them. I.e.:
$$ f(x, y) \approx average(x, y) \tag{2} $$
Example:
if $x = 5$ and $y = 8$ then $f(x, y) \approx 6+\frac{1}{2}$
Or, at least something between $x$ and $y$, i.e.:
$$ min(x, y) < f(x, y) < max(x, y) \tag{2} $$
So, because of that second condition, I can now discard $f=\times$ and $f=\div$.
$average$ itself does not work as well:
For example:
if $f=average$ and
if $x = 5$ and $y = 8$ then:
$$ average(x, y) = 6+\frac{1}{2} $$ $$ average(x^{-1}, y^{-1})^{-1} = 6+\frac{2}{13} $$ so $$ average(x, y) \neq average(x^{-1}, y^{-1})^{-1} $$
I have no idea how to solve it the right way, so I did some trial and error. The best I got was this:
$$ f = average\left(average(x, y), average(x^{-1}, y^{-1})^{-1} \right) $$
The distance between $f(x, y)$ and $f(x^{-1}, y^{-1})^{-1}$ is lower than if I use the $average$, but it is not zero yet. Also, it works fine to small numbers like $5$ and $8$, but if I try $x=123$ and $y=888$ e.g., it starts to get too far from the average, although satisfying the condition $min(x, y) < f(x, y) < max(x, y)$, what is fair for me in last case.
In Scheme language (R5RS) this following function should return #t for any rational number $x > 0$ and $y > 0$ given the right fn I am looking for:
(define satisfies (lambda (fn x y)
(and (= (fn x y)
(/ 1 (fn (/ 1 x)
(/ 1 y))))
(= (fn x y) (fn y x))
(> (fn x y) (min x y))
(< (fn x y) (max x y)))))
Is it possible to solve something like that? Is that too specific? Where should I start?
Thank you.
** LATE EDIT **
Third condition
$$ f(x, y) = f(y, x) \tag{3} $$
Fourth condition (nice to have)
$$ f(x, y) \in \mathbb{Q} \tag{4} $$
Known facts
- $x \approx y$
- $x \in \mathbb{Q}$
- $y \in \mathbb{Q}$
- $x > 0$
- $y > 0$
My final solution
Thanks to @DanielV and @Macavity:
$$ f(x, y) = \mathbb{R}\to\mathbb{Q}(\sqrt{xy}) \tag{a} $$
$$ f(x, y) = \mathbb{R}\to\mathbb{Q}(\sqrt{x^{-1}y^{-1}})^{-1} \tag{b} $$
if $min(x, y) < min(x^{-1}, y^{-1})$ then use $(a)$ else $(b)$
Assume in this solution:
- $\sqrt{n}$ is a grotesque approximation $\in \mathbb{R}$ of the real root.
- $\mathbb{R}\to\mathbb{Q}(x)$ is a function that converts a $\mathbb{R}$ number into $\mathbb{Q}$ number (losing precision, of course). Equivalent to
inexact->exactfunction in Scheme language.
You found that
$$f(x, y) = x^{-1}y^{-1} \tag{1}$$
and
$$f(x, y) = x^1y^1 \tag{2}$$
satisfies
$$f(x, y) = f(x^{-1}, y^{-1})^{-1} \tag{3}$$
So the next thing I would check is:
$$f(x, y) = x^ay^b \tag{4}$$
If you put (4) into (3) you see that it satisfies the condition also. So we try to find
$$x^ay^b \approx \frac 12 x + \frac 12 y$$
Consider when $x\approx y$, you get:
$$x^{a+b} \approx x^1$$ $$a+b \approx 1$$
So you can approximate your function by
$$f(x, y) = x^ay^{1-a}$$
If you expect $x \approx y$ you can choose $a = 1/2$ for a good approximation: $\boxed{f(x, y) = \sqrt{xy}}$. If you expect $x \not \approx y$, such as $x = ky$ you can solve:
$$x^a(kx)^{b} = \frac 12 x + \frac 12 kx$$ $$k^bx^{a + b} = \left(\frac 12 + \frac 12 k\right)x^1$$
$$\begin{cases} k^b = \frac 12 + \frac 12 k \\ a + b = 1 \end{cases}$$
$$\begin{cases} \ln\left(k^b\right) = \ln\left(\frac{1 + k}{2}\right) \\ a = 1 - b \end{cases}$$
$$\begin{cases} b = \frac{\ln(1 + k) - \ln(2)}{\ln(k)} \\ a = 1 - b \end{cases}$$
So if you assume $x \approx ky$ you can create:
$$\boxed{\begin{align} &f(x, y) = x^ay^b \\ &\text{ for } b = \frac{\ln(1 + k) - \ln(2)}{\ln(k)} \text{ and } a = 1 - b\end{align}}$$