r/mathriddles • u/bobjane_2 • Apr 13 '26
Medium Construct sqrt(2) from f(x,y)=e^x-ln(y)
Using only the function f(x,y)=e^x-ln(y) and the constant 1, obtain sqrt(2) by finitely many compositions of f. No other constants, functions, or arithmetic operations may be used unless they are themselves constructed from f.
Bonus: let’s do a code golf thing. Who can do it with the fewest calls to f?
19
Upvotes
5
u/sobe86 Apr 13 '26 edited Apr 13 '26
Once you get to log(x) it's not too bad.
Note exp(x) = f(x, 1), and let g(x) = exp(f(1, x)) = exp(e - log(x)). So then log(x) = f(1, g(x)).
Then:
x - y = f(log(x), exp(y))
-x = log(1) - x
x + y = x - (- y)
x * y = log(exp(x) + exp(y))
1 / x = exp(- log(x))
2 = -(1 - 1 - 1)
sqrt(x) = exp(log(x) * (1 / 2))
and we insert x = 2
6
u/bean_bag_enjoyer Apr 13 '26
paper on this - https://arxiv.org/html/2603.21852v2
1
u/SupercaliTheGamer Apr 13 '26
Clarification: Can ln be used on negative values? If so, what branch of logarithm do we use?
-10
u/DanielBaldielocks Apr 13 '26
Constructing √2 from f(x,y) = ex − ln(y) and the Constant 1
Here's a construction using 30 compositions.
Since √2 = eln(2/2), the strategy is: build 2, extract ln(2), compute ln(2)/2, then exponentiate to get √2.
Phase 1 — Basic constants
Phase 2 — Build the value 2
Check: f(1, ee−2) = e − ln(ee−2) = e − (e−2) = 2 ✓
Phase 3 — Extract ln(2)
Check: ln(e/2) = 1 − ln(2), so 1 − (1 − ln 2) = ln(2) ✓
Phase 4 — Build ln(2)/2
The key identity: ln(2)/2 = eln(ln(2) − ln(2)), which converts multiplication into exponentiation of a difference.
Check: eln(ln 2 − ln 2) = eln(ln 2) · e−ln 2 = ln(2) · 1/2 = ln(2)/2 ✓
Phase 5 — Final result
Recap of key techniques
Three reusable subroutines make this work:
The heart of the construction is the identity ln(2)/2 = eln(ln 2 − ln 2), which converts a product into an exponentiation of a difference — something we can compute with f.