-
Notifications
You must be signed in to change notification settings - Fork 0
/
exponential_inverse.sf
28 lines (20 loc) · 1.01 KB
/
exponential_inverse.sf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/ruby
# Author: Trizen
# Date: 27 March 2023
# https://github.com/trizen
# Examples on how to use the `lgrt(x)` function for computing the inverse of exponential functions.
# Where `lgrt(n)` is defined as:
# lgrt(x^x) = x
func exponential_inverse(n, a=1, b=1, c=1, d=0) {
lgrt((n/c)**(a/b)) * b / a + d
}
var n = 100
say exponential_inverse(n.factorial, 1, Num.e, sqrt(Num.tau), -1/2) # inverse of factorial(n)
say exponential_inverse(n.bernreal.abs, 1, Num.e * Num.tau, 2*Num.tau, -1/2) # inverse of abs(Bernoulli(n))
say exponential_inverse(n**n * Num.e**n, Num.e, 1)
say exponential_inverse(n**n / Num.e**n, 1, Num.e)
say exponential_inverse(n**n / Num.e**n * 2**n, 2, Num.e)
say exponential_inverse(n**n * Num.e**n * 2**n, 2 * Num.e, 1)
say exponential_inverse(sqrt(2*Num.pi)**n * (n/Num.e)**n, sqrt(2*Num.pi), Num.e)
say exponential_inverse((n/Num.e)**n / sqrt(2*Num.pi)**n, 1, sqrt(2*Num.pi) * Num.e)
say exponential_inverse(sqrt(2*Num.pi)**n / (n/Num.e)**n, -1, sqrt(2*Num.pi) * Num.e).abs