
(FPCore (i n) :precision binary64 (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))
double code(double i, double n) {
return 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 100.0d0 * ((((1.0d0 + (i / n)) ** n) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
return 100.0 * ((Math.pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
def code(i, n): return 100.0 * ((math.pow((1.0 + (i / n)), n) - 1.0) / (i / n))
function code(i, n) return Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n))) end
function tmp = code(i, n) tmp = 100.0 * ((((1.0 + (i / n)) ^ n) - 1.0) / (i / n)); end
code[i_, n_] := N[(100.0 * N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (i n) :precision binary64 (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))
double code(double i, double n) {
return 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 100.0d0 * ((((1.0d0 + (i / n)) ** n) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
return 100.0 * ((Math.pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
def code(i, n): return 100.0 * ((math.pow((1.0 + (i / n)), n) - 1.0) / (i / n))
function code(i, n) return Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n))) end
function tmp = code(i, n) tmp = 100.0 * ((((1.0 + (i / n)) ^ n) - 1.0) / (i / n)); end
code[i_, n_] := N[(100.0 * N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}
\end{array}
(FPCore (i n) :precision binary64 (* n (/ (* 100.0 (expm1 i)) i)))
double code(double i, double n) {
return n * ((100.0 * expm1(i)) / i);
}
public static double code(double i, double n) {
return n * ((100.0 * Math.expm1(i)) / i);
}
def code(i, n): return n * ((100.0 * math.expm1(i)) / i)
function code(i, n) return Float64(n * Float64(Float64(100.0 * expm1(i)) / i)) end
code[i_, n_] := N[(n * N[(N[(100.0 * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
n \cdot \frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}
\end{array}
Initial program 32.7%
associate-/r/32.8%
associate-*r*32.8%
*-commutative32.8%
associate-*r/32.8%
sub-neg32.8%
distribute-lft-in32.8%
metadata-eval32.8%
metadata-eval32.8%
metadata-eval32.8%
fma-define32.8%
metadata-eval32.8%
Simplified32.8%
Taylor expanded in n around inf 34.9%
sub-neg34.9%
metadata-eval34.9%
metadata-eval34.9%
distribute-lft-in35.0%
metadata-eval35.0%
sub-neg35.0%
expm1-define71.4%
Simplified71.4%
Final simplification71.4%
(FPCore (i n) :precision binary64 (if (<= n 0.13) (/ n (+ 0.01 (* i (- (* i 0.0008333333333333334) 0.005)))) (* 100.0 (/ (expm1 i) (/ i n)))))
double code(double i, double n) {
double tmp;
if (n <= 0.13) {
tmp = n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)));
} else {
tmp = 100.0 * (expm1(i) / (i / n));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (n <= 0.13) {
tmp = n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)));
} else {
tmp = 100.0 * (Math.expm1(i) / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= 0.13: tmp = n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005))) else: tmp = 100.0 * (math.expm1(i) / (i / n)) return tmp
function code(i, n) tmp = 0.0 if (n <= 0.13) tmp = Float64(n / Float64(0.01 + Float64(i * Float64(Float64(i * 0.0008333333333333334) - 0.005)))); else tmp = Float64(100.0 * Float64(expm1(i) / Float64(i / n))); end return tmp end
code[i_, n_] := If[LessEqual[n, 0.13], N[(n / N[(0.01 + N[(i * N[(N[(i * 0.0008333333333333334), $MachinePrecision] - 0.005), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 0.13:\\
\;\;\;\;\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < 0.13Initial program 32.7%
associate-/r/32.6%
associate-*r*32.6%
*-commutative32.6%
associate-*r/32.6%
sub-neg32.6%
distribute-lft-in32.6%
metadata-eval32.6%
metadata-eval32.6%
metadata-eval32.6%
fma-define32.6%
metadata-eval32.6%
Simplified32.6%
Taylor expanded in n around inf 31.6%
sub-neg31.6%
metadata-eval31.6%
metadata-eval31.6%
distribute-lft-in31.6%
metadata-eval31.6%
sub-neg31.6%
expm1-define65.0%
Simplified65.0%
clear-num65.1%
un-div-inv65.0%
*-un-lft-identity65.0%
times-frac65.0%
metadata-eval65.0%
Applied egg-rr65.0%
associate-*r/64.9%
Simplified64.9%
Taylor expanded in i around 0 65.8%
if 0.13 < n Initial program 32.9%
Taylor expanded in n around inf 42.9%
expm1-define62.9%
Simplified62.9%
Final simplification65.0%
(FPCore (i n) :precision binary64 (if (<= n -9.5e-105) (* n 100.0) (* 100.0 (* i (/ n i)))))
double code(double i, double n) {
double tmp;
if (n <= -9.5e-105) {
tmp = n * 100.0;
} else {
tmp = 100.0 * (i * (n / i));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-9.5d-105)) then
tmp = n * 100.0d0
else
tmp = 100.0d0 * (i * (n / i))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -9.5e-105) {
tmp = n * 100.0;
} else {
tmp = 100.0 * (i * (n / i));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -9.5e-105: tmp = n * 100.0 else: tmp = 100.0 * (i * (n / i)) return tmp
function code(i, n) tmp = 0.0 if (n <= -9.5e-105) tmp = Float64(n * 100.0); else tmp = Float64(100.0 * Float64(i * Float64(n / i))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -9.5e-105) tmp = n * 100.0; else tmp = 100.0 * (i * (n / i)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -9.5e-105], N[(n * 100.0), $MachinePrecision], N[(100.0 * N[(i * N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -9.5 \cdot 10^{-105}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(i \cdot \frac{n}{i}\right)\\
\end{array}
\end{array}
if n < -9.5000000000000002e-105Initial program 25.8%
Taylor expanded in i around 0 55.2%
*-commutative55.2%
Simplified55.2%
if -9.5000000000000002e-105 < n Initial program 37.0%
Taylor expanded in i around 0 32.5%
+-commutative32.5%
Simplified32.5%
div-inv32.5%
associate--l+48.9%
metadata-eval48.9%
+-rgt-identity48.9%
clear-num47.8%
Applied egg-rr47.8%
Final simplification50.6%
(FPCore (i n) :precision binary64 (if (<= n 1.55e+52) (* 100.0 (* i (/ n i))) (* 100.0 (+ n (* i -0.5)))))
double code(double i, double n) {
double tmp;
if (n <= 1.55e+52) {
tmp = 100.0 * (i * (n / i));
} else {
tmp = 100.0 * (n + (i * -0.5));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= 1.55d+52) then
tmp = 100.0d0 * (i * (n / i))
else
tmp = 100.0d0 * (n + (i * (-0.5d0)))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= 1.55e+52) {
tmp = 100.0 * (i * (n / i));
} else {
tmp = 100.0 * (n + (i * -0.5));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= 1.55e+52: tmp = 100.0 * (i * (n / i)) else: tmp = 100.0 * (n + (i * -0.5)) return tmp
function code(i, n) tmp = 0.0 if (n <= 1.55e+52) tmp = Float64(100.0 * Float64(i * Float64(n / i))); else tmp = Float64(100.0 * Float64(n + Float64(i * -0.5))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= 1.55e+52) tmp = 100.0 * (i * (n / i)); else tmp = 100.0 * (n + (i * -0.5)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, 1.55e+52], N[(100.0 * N[(i * N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(n + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 1.55 \cdot 10^{+52}:\\
\;\;\;\;100 \cdot \left(i \cdot \frac{n}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(n + i \cdot -0.5\right)\\
\end{array}
\end{array}
if n < 1.55e52Initial program 35.6%
Taylor expanded in i around 0 26.9%
+-commutative26.9%
Simplified26.9%
div-inv26.9%
associate--l+53.2%
metadata-eval53.2%
+-rgt-identity53.2%
clear-num52.3%
Applied egg-rr52.3%
if 1.55e52 < n Initial program 22.4%
Taylor expanded in i around 0 47.4%
associate-*r/47.4%
metadata-eval47.4%
Simplified47.4%
Taylor expanded in n around 0 20.4%
associate-*r/20.4%
associate-*l/20.4%
*-commutative20.4%
Simplified20.4%
Taylor expanded in i around 0 52.1%
*-commutative52.1%
Simplified52.1%
Final simplification52.2%
(FPCore (i n) :precision binary64 (if (<= i 6e-29) (* n 100.0) (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if (i <= 6e-29) {
tmp = n * 100.0;
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= 6d-29) then
tmp = n * 100.0d0
else
tmp = 100.0d0 * (i / (i / n))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= 6e-29) {
tmp = n * 100.0;
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 6e-29: tmp = n * 100.0 else: tmp = 100.0 * (i / (i / n)) return tmp
function code(i, n) tmp = 0.0 if (i <= 6e-29) tmp = Float64(n * 100.0); else tmp = Float64(100.0 * Float64(i / Float64(i / n))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= 6e-29) tmp = n * 100.0; else tmp = 100.0 * (i / (i / n)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, 6e-29], N[(n * 100.0), $MachinePrecision], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 6 \cdot 10^{-29}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\end{array}
\end{array}
if i < 6.0000000000000005e-29Initial program 27.7%
Taylor expanded in i around 0 58.3%
*-commutative58.3%
Simplified58.3%
if 6.0000000000000005e-29 < i Initial program 46.0%
Taylor expanded in i around 0 34.0%
Final simplification51.7%
(FPCore (i n) :precision binary64 (if (<= i -8.2e-46) (* 100.0 (/ i (/ i n))) (* 100.0 (/ (* n i) i))))
double code(double i, double n) {
double tmp;
if (i <= -8.2e-46) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = 100.0 * ((n * i) / i);
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= (-8.2d-46)) then
tmp = 100.0d0 * (i / (i / n))
else
tmp = 100.0d0 * ((n * i) / i)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -8.2e-46) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = 100.0 * ((n * i) / i);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -8.2e-46: tmp = 100.0 * (i / (i / n)) else: tmp = 100.0 * ((n * i) / i) return tmp
function code(i, n) tmp = 0.0 if (i <= -8.2e-46) tmp = Float64(100.0 * Float64(i / Float64(i / n))); else tmp = Float64(100.0 * Float64(Float64(n * i) / i)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -8.2e-46) tmp = 100.0 * (i / (i / n)); else tmp = 100.0 * ((n * i) / i); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -8.2e-46], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(N[(n * i), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -8.2 \cdot 10^{-46}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n \cdot i}{i}\\
\end{array}
\end{array}
if i < -8.1999999999999998e-46Initial program 60.2%
Taylor expanded in i around 0 32.4%
if -8.1999999999999998e-46 < i Initial program 22.2%
Taylor expanded in i around 0 17.8%
+-commutative17.8%
Simplified17.8%
*-un-lft-identity17.8%
div-inv17.8%
times-frac18.1%
associate--l+63.0%
metadata-eval63.0%
+-rgt-identity63.0%
Applied egg-rr63.0%
frac-times52.0%
div-inv52.1%
associate-*l/51.5%
clear-num51.0%
associate-*l/63.2%
Applied egg-rr63.2%
Final simplification54.7%
(FPCore (i n) :precision binary64 (/ n (+ 0.01 (* i (- (* i 0.0008333333333333334) 0.005)))))
double code(double i, double n) {
return n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = n / (0.01d0 + (i * ((i * 0.0008333333333333334d0) - 0.005d0)))
end function
public static double code(double i, double n) {
return n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)));
}
def code(i, n): return n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005)))
function code(i, n) return Float64(n / Float64(0.01 + Float64(i * Float64(Float64(i * 0.0008333333333333334) - 0.005)))) end
function tmp = code(i, n) tmp = n / (0.01 + (i * ((i * 0.0008333333333333334) - 0.005))); end
code[i_, n_] := N[(n / N[(0.01 + N[(i * N[(N[(i * 0.0008333333333333334), $MachinePrecision] - 0.005), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{n}{0.01 + i \cdot \left(i \cdot 0.0008333333333333334 - 0.005\right)}
\end{array}
Initial program 32.7%
associate-/r/32.8%
associate-*r*32.8%
*-commutative32.8%
associate-*r/32.8%
sub-neg32.8%
distribute-lft-in32.8%
metadata-eval32.8%
metadata-eval32.8%
metadata-eval32.8%
fma-define32.8%
metadata-eval32.8%
Simplified32.8%
Taylor expanded in n around inf 34.9%
sub-neg34.9%
metadata-eval34.9%
metadata-eval34.9%
distribute-lft-in35.0%
metadata-eval35.0%
sub-neg35.0%
expm1-define71.4%
Simplified71.4%
clear-num71.4%
un-div-inv71.3%
*-un-lft-identity71.3%
times-frac71.3%
metadata-eval71.3%
Applied egg-rr71.3%
associate-*r/71.2%
Simplified71.2%
Taylor expanded in i around 0 60.6%
Final simplification60.6%
(FPCore (i n) :precision binary64 (if (<= i 1.56e+29) (* n 100.0) (* 50.0 (* n i))))
double code(double i, double n) {
double tmp;
if (i <= 1.56e+29) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (n * i);
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= 1.56d+29) then
tmp = n * 100.0d0
else
tmp = 50.0d0 * (n * i)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= 1.56e+29) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (n * i);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 1.56e+29: tmp = n * 100.0 else: tmp = 50.0 * (n * i) return tmp
function code(i, n) tmp = 0.0 if (i <= 1.56e+29) tmp = Float64(n * 100.0); else tmp = Float64(50.0 * Float64(n * i)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= 1.56e+29) tmp = n * 100.0; else tmp = 50.0 * (n * i); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, 1.56e+29], N[(n * 100.0), $MachinePrecision], N[(50.0 * N[(n * i), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 1.56 \cdot 10^{+29}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;50 \cdot \left(n \cdot i\right)\\
\end{array}
\end{array}
if i < 1.5599999999999999e29Initial program 28.8%
Taylor expanded in i around 0 56.9%
*-commutative56.9%
Simplified56.9%
if 1.5599999999999999e29 < i Initial program 45.0%
associate-/r/45.3%
associate-*r*45.3%
*-commutative45.3%
associate-*r/45.3%
sub-neg45.3%
distribute-lft-in45.3%
metadata-eval45.3%
metadata-eval45.3%
metadata-eval45.3%
fma-define45.3%
metadata-eval45.3%
Simplified45.3%
Taylor expanded in n around inf 47.5%
sub-neg47.5%
metadata-eval47.5%
metadata-eval47.5%
distribute-lft-in47.5%
metadata-eval47.5%
sub-neg47.5%
expm1-define47.5%
Simplified47.5%
Taylor expanded in i around 0 34.7%
Taylor expanded in i around inf 34.7%
Final simplification51.5%
(FPCore (i n) :precision binary64 (if (<= i 1.56e+29) (* n 100.0) (* i (* n 50.0))))
double code(double i, double n) {
double tmp;
if (i <= 1.56e+29) {
tmp = n * 100.0;
} else {
tmp = i * (n * 50.0);
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= 1.56d+29) then
tmp = n * 100.0d0
else
tmp = i * (n * 50.0d0)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= 1.56e+29) {
tmp = n * 100.0;
} else {
tmp = i * (n * 50.0);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 1.56e+29: tmp = n * 100.0 else: tmp = i * (n * 50.0) return tmp
function code(i, n) tmp = 0.0 if (i <= 1.56e+29) tmp = Float64(n * 100.0); else tmp = Float64(i * Float64(n * 50.0)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= 1.56e+29) tmp = n * 100.0; else tmp = i * (n * 50.0); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, 1.56e+29], N[(n * 100.0), $MachinePrecision], N[(i * N[(n * 50.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 1.56 \cdot 10^{+29}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;i \cdot \left(n \cdot 50\right)\\
\end{array}
\end{array}
if i < 1.5599999999999999e29Initial program 28.8%
Taylor expanded in i around 0 56.9%
*-commutative56.9%
Simplified56.9%
if 1.5599999999999999e29 < i Initial program 45.0%
associate-/r/45.3%
associate-*r*45.3%
*-commutative45.3%
associate-*r/45.3%
sub-neg45.3%
distribute-lft-in45.3%
metadata-eval45.3%
metadata-eval45.3%
metadata-eval45.3%
fma-define45.3%
metadata-eval45.3%
Simplified45.3%
Taylor expanded in n around inf 47.5%
sub-neg47.5%
metadata-eval47.5%
metadata-eval47.5%
distribute-lft-in47.5%
metadata-eval47.5%
sub-neg47.5%
expm1-define47.5%
Simplified47.5%
Taylor expanded in i around 0 34.7%
Taylor expanded in i around inf 34.7%
*-commutative34.7%
associate-*r*34.7%
Simplified34.7%
Final simplification51.5%
(FPCore (i n) :precision binary64 (* n (+ 100.0 (* i 50.0))))
double code(double i, double n) {
return n * (100.0 + (i * 50.0));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = n * (100.0d0 + (i * 50.0d0))
end function
public static double code(double i, double n) {
return n * (100.0 + (i * 50.0));
}
def code(i, n): return n * (100.0 + (i * 50.0))
function code(i, n) return Float64(n * Float64(100.0 + Float64(i * 50.0))) end
function tmp = code(i, n) tmp = n * (100.0 + (i * 50.0)); end
code[i_, n_] := N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
n \cdot \left(100 + i \cdot 50\right)
\end{array}
Initial program 32.7%
associate-/r/32.8%
associate-*r*32.8%
*-commutative32.8%
associate-*r/32.8%
sub-neg32.8%
distribute-lft-in32.8%
metadata-eval32.8%
metadata-eval32.8%
metadata-eval32.8%
fma-define32.8%
metadata-eval32.8%
Simplified32.8%
Taylor expanded in n around inf 34.9%
sub-neg34.9%
metadata-eval34.9%
metadata-eval34.9%
distribute-lft-in35.0%
metadata-eval35.0%
sub-neg35.0%
expm1-define71.4%
Simplified71.4%
Taylor expanded in i around 0 52.2%
Final simplification52.2%
(FPCore (i n) :precision binary64 (/ n (+ 0.01 (* i -0.005))))
double code(double i, double n) {
return n / (0.01 + (i * -0.005));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = n / (0.01d0 + (i * (-0.005d0)))
end function
public static double code(double i, double n) {
return n / (0.01 + (i * -0.005));
}
def code(i, n): return n / (0.01 + (i * -0.005))
function code(i, n) return Float64(n / Float64(0.01 + Float64(i * -0.005))) end
function tmp = code(i, n) tmp = n / (0.01 + (i * -0.005)); end
code[i_, n_] := N[(n / N[(0.01 + N[(i * -0.005), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{n}{0.01 + i \cdot -0.005}
\end{array}
Initial program 32.7%
associate-/r/32.8%
associate-*r*32.8%
*-commutative32.8%
associate-*r/32.8%
sub-neg32.8%
distribute-lft-in32.8%
metadata-eval32.8%
metadata-eval32.8%
metadata-eval32.8%
fma-define32.8%
metadata-eval32.8%
Simplified32.8%
Taylor expanded in n around inf 34.9%
sub-neg34.9%
metadata-eval34.9%
metadata-eval34.9%
distribute-lft-in35.0%
metadata-eval35.0%
sub-neg35.0%
expm1-define71.4%
Simplified71.4%
clear-num71.4%
un-div-inv71.3%
*-un-lft-identity71.3%
times-frac71.3%
metadata-eval71.3%
Applied egg-rr71.3%
associate-*r/71.2%
Simplified71.2%
Taylor expanded in i around 0 59.5%
*-commutative59.5%
Simplified59.5%
Final simplification59.5%
(FPCore (i n) :precision binary64 (* i -50.0))
double code(double i, double n) {
return i * -50.0;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = i * (-50.0d0)
end function
public static double code(double i, double n) {
return i * -50.0;
}
def code(i, n): return i * -50.0
function code(i, n) return Float64(i * -50.0) end
function tmp = code(i, n) tmp = i * -50.0; end
code[i_, n_] := N[(i * -50.0), $MachinePrecision]
\begin{array}{l}
\\
i \cdot -50
\end{array}
Initial program 32.7%
Taylor expanded in i around 0 41.4%
associate-*r/41.4%
metadata-eval41.4%
Simplified41.4%
Taylor expanded in n around 0 2.7%
*-commutative2.7%
Simplified2.7%
Final simplification2.7%
(FPCore (i n) :precision binary64 (* n 100.0))
double code(double i, double n) {
return n * 100.0;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = n * 100.0d0
end function
public static double code(double i, double n) {
return n * 100.0;
}
def code(i, n): return n * 100.0
function code(i, n) return Float64(n * 100.0) end
function tmp = code(i, n) tmp = n * 100.0; end
code[i_, n_] := N[(n * 100.0), $MachinePrecision]
\begin{array}{l}
\\
n \cdot 100
\end{array}
Initial program 32.7%
Taylor expanded in i around 0 44.4%
*-commutative44.4%
Simplified44.4%
Final simplification44.4%
(FPCore (i n)
:precision binary64
(let* ((t_0 (+ 1.0 (/ i n))))
(*
100.0
(/
(-
(exp
(*
n
(if (== t_0 1.0)
(/ i n)
(/ (* (/ i n) (log t_0)) (- (+ (/ i n) 1.0) 1.0)))))
1.0)
(/ i n)))))
double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double tmp;
if (t_0 == 1.0) {
tmp = i / n;
} else {
tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0);
}
return 100.0 * ((exp((n * tmp)) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 + (i / n)
if (t_0 == 1.0d0) then
tmp = i / n
else
tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0d0) - 1.0d0)
end if
code = 100.0d0 * ((exp((n * tmp)) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double tmp;
if (t_0 == 1.0) {
tmp = i / n;
} else {
tmp = ((i / n) * Math.log(t_0)) / (((i / n) + 1.0) - 1.0);
}
return 100.0 * ((Math.exp((n * tmp)) - 1.0) / (i / n));
}
def code(i, n): t_0 = 1.0 + (i / n) tmp = 0 if t_0 == 1.0: tmp = i / n else: tmp = ((i / n) * math.log(t_0)) / (((i / n) + 1.0) - 1.0) return 100.0 * ((math.exp((n * tmp)) - 1.0) / (i / n))
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) tmp = 0.0 if (t_0 == 1.0) tmp = Float64(i / n); else tmp = Float64(Float64(Float64(i / n) * log(t_0)) / Float64(Float64(Float64(i / n) + 1.0) - 1.0)); end return Float64(100.0 * Float64(Float64(exp(Float64(n * tmp)) - 1.0) / Float64(i / n))) end
function tmp_2 = code(i, n) t_0 = 1.0 + (i / n); tmp = 0.0; if (t_0 == 1.0) tmp = i / n; else tmp = ((i / n) * log(t_0)) / (((i / n) + 1.0) - 1.0); end tmp_2 = 100.0 * ((exp((n * tmp)) - 1.0) / (i / n)); end
code[i_, n_] := Block[{t$95$0 = N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision]}, N[(100.0 * N[(N[(N[Exp[N[(n * If[Equal[t$95$0, 1.0], N[(i / n), $MachinePrecision], N[(N[(N[(i / n), $MachinePrecision] * N[Log[t$95$0], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(i / n), $MachinePrecision] + 1.0), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{i}{n}\\
100 \cdot \frac{e^{n \cdot \begin{array}{l}
\mathbf{if}\;t\_0 = 1:\\
\;\;\;\;\frac{i}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{i}{n} \cdot \log t\_0}{\left(\frac{i}{n} + 1\right) - 1}\\
\end{array}} - 1}{\frac{i}{n}}
\end{array}
\end{array}
herbie shell --seed 2024066
(FPCore (i n)
:name "Compound Interest"
:precision binary64
:alt
(* 100.0 (/ (- (exp (* n (if (== (+ 1.0 (/ i n)) 1.0) (/ i n) (/ (* (/ i n) (log (+ 1.0 (/ i n)))) (- (+ (/ i n) 1.0) 1.0))))) 1.0) (/ i n)))
(* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))