
(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 11 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
(let* ((t_0 (pow (+ 1.0 (/ i n)) n)) (t_1 (/ (+ t_0 -1.0) (/ i n))))
(if (<= t_1 0.0)
(* 100.0 (/ (expm1 (* n (log1p (/ i n)))) (/ i n)))
(if (<= t_1 INFINITY) (* n (/ (fma 100.0 t_0 -100.0) i)) (* n 100.0)))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= 0.0) {
tmp = 100.0 * (expm1((n * log1p((i / n)))) / (i / n));
} else if (t_1 <= ((double) INFINITY)) {
tmp = n * (fma(100.0, t_0, -100.0) / i);
} else {
tmp = n * 100.0;
}
return tmp;
}
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(100.0 * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / Float64(i / n))); elseif (t_1 <= Inf) tmp = Float64(n * Float64(fma(100.0, t_0, -100.0) / i)); else tmp = Float64(n * 100.0); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(100.0 * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(n * N[(N[(100.0 * t$95$0 + -100.0), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t\_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;n \cdot \frac{\mathsf{fma}\left(100, t\_0, -100\right)}{i}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0Initial program 26.0%
sub-neg26.0%
metadata-eval26.0%
Applied egg-rr26.0%
metadata-eval26.0%
sub-neg26.0%
exp-to-pow24.0%
log1p-undefine45.2%
*-commutative45.2%
expm1-undefine97.7%
Simplified97.7%
if -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.7%
associate-/r/99.8%
associate-*r*99.9%
*-commutative99.9%
associate-*r/99.9%
sub-neg99.9%
distribute-lft-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
fma-define99.9%
metadata-eval99.9%
Simplified99.9%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
Taylor expanded in i around 0 86.1%
*-commutative86.1%
Simplified86.1%
Final simplification96.1%
(FPCore (i n)
:precision binary64
(let* ((t_0 (pow (+ 1.0 (/ i n)) n)) (t_1 (/ (+ t_0 -1.0) (/ i n))))
(if (<= t_1 0.0)
(* 100.0 (/ (expm1 (* n (log1p (/ i n)))) (/ i n)))
(if (<= t_1 INFINITY) (/ (+ -100.0 (* t_0 100.0)) (/ i n)) (* n 100.0)))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= 0.0) {
tmp = 100.0 * (expm1((n * log1p((i / n)))) / (i / n));
} else if (t_1 <= ((double) INFINITY)) {
tmp = (-100.0 + (t_0 * 100.0)) / (i / n);
} else {
tmp = n * 100.0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= 0.0) {
tmp = 100.0 * (Math.expm1((n * Math.log1p((i / n)))) / (i / n));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (-100.0 + (t_0 * 100.0)) / (i / n);
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): t_0 = math.pow((1.0 + (i / n)), n) t_1 = (t_0 + -1.0) / (i / n) tmp = 0 if t_1 <= 0.0: tmp = 100.0 * (math.expm1((n * math.log1p((i / n)))) / (i / n)) elif t_1 <= math.inf: tmp = (-100.0 + (t_0 * 100.0)) / (i / n) else: tmp = n * 100.0 return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(100.0 * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / Float64(i / n))); elseif (t_1 <= Inf) tmp = Float64(Float64(-100.0 + Float64(t_0 * 100.0)) / Float64(i / n)); else tmp = Float64(n * 100.0); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(100.0 * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(-100.0 + N[(t$95$0 * 100.0), $MachinePrecision]), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t\_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{\frac{i}{n}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{-100 + t\_0 \cdot 100}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0Initial program 26.0%
sub-neg26.0%
metadata-eval26.0%
Applied egg-rr26.0%
metadata-eval26.0%
sub-neg26.0%
exp-to-pow24.0%
log1p-undefine45.2%
*-commutative45.2%
expm1-undefine97.7%
Simplified97.7%
if -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.7%
associate-*r/99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
Taylor expanded in i around 0 86.1%
*-commutative86.1%
Simplified86.1%
Final simplification96.1%
(FPCore (i n) :precision binary64 (if (or (<= n -2e-193) (not (<= n 7.3e-214))) (* n (/ (* 100.0 (expm1 i)) i)) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -2e-193) || !(n <= 7.3e-214)) {
tmp = n * ((100.0 * expm1(i)) / i);
} else {
tmp = 0.0;
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -2e-193) || !(n <= 7.3e-214)) {
tmp = n * ((100.0 * Math.expm1(i)) / i);
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -2e-193) or not (n <= 7.3e-214): tmp = n * ((100.0 * math.expm1(i)) / i) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -2e-193) || !(n <= 7.3e-214)) tmp = Float64(n * Float64(Float64(100.0 * expm1(i)) / i)); else tmp = 0.0; end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -2e-193], N[Not[LessEqual[n, 7.3e-214]], $MachinePrecision]], N[(n * N[(N[(100.0 * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2 \cdot 10^{-193} \lor \neg \left(n \leq 7.3 \cdot 10^{-214}\right):\\
\;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -2.0000000000000001e-193 or 7.30000000000000029e-214 < n Initial program 22.9%
associate-/r/23.2%
associate-*r*23.2%
*-commutative23.2%
associate-*r/23.2%
sub-neg23.2%
distribute-lft-in23.2%
metadata-eval23.2%
metadata-eval23.2%
metadata-eval23.2%
fma-define23.2%
metadata-eval23.2%
Simplified23.2%
Taylor expanded in n around inf 35.7%
sub-neg35.7%
metadata-eval35.7%
metadata-eval35.7%
distribute-lft-in35.7%
metadata-eval35.7%
sub-neg35.7%
expm1-define86.2%
Simplified86.2%
if -2.0000000000000001e-193 < n < 7.30000000000000029e-214Initial program 73.1%
associate-*r/73.1%
sub-neg73.1%
distribute-rgt-in73.1%
metadata-eval73.1%
metadata-eval73.1%
Simplified73.1%
Taylor expanded in i around 0 90.3%
+-commutative90.3%
Simplified90.3%
Taylor expanded in i around 0 90.3%
Taylor expanded in i around 0 90.3%
Final simplification86.7%
(FPCore (i n) :precision binary64 (if (or (<= n -2.95e-192) (not (<= n 2.1e-214))) (* 100.0 (* n (/ (expm1 i) i))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -2.95e-192) || !(n <= 2.1e-214)) {
tmp = 100.0 * (n * (expm1(i) / i));
} else {
tmp = 0.0;
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -2.95e-192) || !(n <= 2.1e-214)) {
tmp = 100.0 * (n * (Math.expm1(i) / i));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -2.95e-192) or not (n <= 2.1e-214): tmp = 100.0 * (n * (math.expm1(i) / i)) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -2.95e-192) || !(n <= 2.1e-214)) tmp = Float64(100.0 * Float64(n * Float64(expm1(i) / i))); else tmp = 0.0; end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -2.95e-192], N[Not[LessEqual[n, 2.1e-214]], $MachinePrecision]], N[(100.0 * N[(n * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.95 \cdot 10^{-192} \lor \neg \left(n \leq 2.1 \cdot 10^{-214}\right):\\
\;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -2.9499999999999998e-192 or 2.09999999999999992e-214 < n Initial program 22.9%
Taylor expanded in n around inf 35.6%
*-commutative35.6%
associate-/l*35.6%
expm1-define86.3%
Simplified86.3%
if -2.9499999999999998e-192 < n < 2.09999999999999992e-214Initial program 73.1%
associate-*r/73.1%
sub-neg73.1%
distribute-rgt-in73.1%
metadata-eval73.1%
metadata-eval73.1%
Simplified73.1%
Taylor expanded in i around 0 90.3%
+-commutative90.3%
Simplified90.3%
Taylor expanded in i around 0 90.3%
Taylor expanded in i around 0 90.3%
Final simplification86.8%
(FPCore (i n)
:precision binary64
(if (<= i -2.15e-9)
(* 100.0 (/ (expm1 i) (/ i n)))
(*
n
(+
100.0
(* i (+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667)))))))))
double code(double i, double n) {
double tmp;
if (i <= -2.15e-9) {
tmp = 100.0 * (expm1(i) / (i / n));
} else {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (i <= -2.15e-9) {
tmp = 100.0 * (Math.expm1(i) / (i / n));
} else {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -2.15e-9: tmp = 100.0 * (math.expm1(i) / (i / n)) else: tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))) return tmp
function code(i, n) tmp = 0.0 if (i <= -2.15e-9) tmp = Float64(100.0 * Float64(expm1(i) / Float64(i / n))); else tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * Float64(16.666666666666668 + Float64(i * 4.166666666666667))))))); end return tmp end
code[i_, n_] := If[LessEqual[i, -2.15e-9], N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * N[(16.666666666666668 + N[(i * 4.166666666666667), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -2.15 \cdot 10^{-9}:\\
\;\;\;\;100 \cdot \frac{\mathsf{expm1}\left(i\right)}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)\\
\end{array}
\end{array}
if i < -2.14999999999999981e-9Initial program 57.7%
Taylor expanded in n around inf 85.7%
expm1-define85.7%
Simplified85.7%
if -2.14999999999999981e-9 < i Initial program 20.6%
associate-/r/21.0%
associate-*r*21.0%
*-commutative21.0%
associate-*r/21.0%
sub-neg21.0%
distribute-lft-in21.0%
metadata-eval21.0%
metadata-eval21.0%
metadata-eval21.0%
fma-define21.0%
metadata-eval21.0%
Simplified21.0%
Taylor expanded in n around inf 27.4%
sub-neg27.4%
metadata-eval27.4%
metadata-eval27.4%
distribute-lft-in27.4%
metadata-eval27.4%
sub-neg27.4%
expm1-define71.5%
Simplified71.5%
associate-/l*81.1%
*-commutative81.1%
*-commutative81.1%
associate-/l*80.2%
Applied egg-rr80.2%
Taylor expanded in i around 0 80.8%
*-commutative80.8%
Simplified80.8%
Final simplification81.9%
(FPCore (i n)
:precision binary64
(if (or (<= n -1.25e-191) (not (<= n 2.15e-214)))
(*
n
(+
100.0
(* i (+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667)))))))
0.0))
double code(double i, double n) {
double tmp;
if ((n <= -1.25e-191) || !(n <= 2.15e-214)) {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-1.25d-191)) .or. (.not. (n <= 2.15d-214))) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * (16.666666666666668d0 + (i * 4.166666666666667d0))))))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -1.25e-191) || !(n <= 2.15e-214)) {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.25e-191) or not (n <= 2.15e-214): tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.25e-191) || !(n <= 2.15e-214)) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * Float64(16.666666666666668 + Float64(i * 4.166666666666667))))))); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -1.25e-191) || ~((n <= 2.15e-214))) tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))); else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -1.25e-191], N[Not[LessEqual[n, 2.15e-214]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * N[(16.666666666666668 + N[(i * 4.166666666666667), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.25 \cdot 10^{-191} \lor \neg \left(n \leq 2.15 \cdot 10^{-214}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -1.25e-191 or 2.15e-214 < n Initial program 22.9%
associate-/r/23.2%
associate-*r*23.2%
*-commutative23.2%
associate-*r/23.2%
sub-neg23.2%
distribute-lft-in23.2%
metadata-eval23.2%
metadata-eval23.2%
metadata-eval23.2%
fma-define23.2%
metadata-eval23.2%
Simplified23.2%
Taylor expanded in n around inf 35.2%
sub-neg35.2%
metadata-eval35.2%
metadata-eval35.2%
distribute-lft-in35.2%
metadata-eval35.2%
sub-neg35.2%
expm1-define75.9%
Simplified75.9%
associate-/l*86.2%
*-commutative86.2%
*-commutative86.2%
associate-/l*85.4%
Applied egg-rr85.4%
Taylor expanded in i around 0 71.9%
*-commutative71.9%
Simplified71.9%
if -1.25e-191 < n < 2.15e-214Initial program 73.1%
associate-*r/73.1%
sub-neg73.1%
distribute-rgt-in73.1%
metadata-eval73.1%
metadata-eval73.1%
Simplified73.1%
Taylor expanded in i around 0 90.3%
+-commutative90.3%
Simplified90.3%
Taylor expanded in i around 0 90.3%
Taylor expanded in i around 0 90.3%
Final simplification74.0%
(FPCore (i n)
:precision binary64
(if (<= n -5.3e-191)
(* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668)))))
(if (<= n 1.15e-213)
0.0
(* 100.0 (* n (+ 1.0 (* i (+ 0.5 (* i 0.16666666666666666)))))))))
double code(double i, double n) {
double tmp;
if (n <= -5.3e-191) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= 1.15e-213) {
tmp = 0.0;
} else {
tmp = 100.0 * (n * (1.0 + (i * (0.5 + (i * 0.16666666666666666)))));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-5.3d-191)) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
else if (n <= 1.15d-213) then
tmp = 0.0d0
else
tmp = 100.0d0 * (n * (1.0d0 + (i * (0.5d0 + (i * 0.16666666666666666d0)))))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -5.3e-191) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= 1.15e-213) {
tmp = 0.0;
} else {
tmp = 100.0 * (n * (1.0 + (i * (0.5 + (i * 0.16666666666666666)))));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -5.3e-191: tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) elif n <= 1.15e-213: tmp = 0.0 else: tmp = 100.0 * (n * (1.0 + (i * (0.5 + (i * 0.16666666666666666))))) return tmp
function code(i, n) tmp = 0.0 if (n <= -5.3e-191) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); elseif (n <= 1.15e-213) tmp = 0.0; else tmp = Float64(100.0 * Float64(n * Float64(1.0 + Float64(i * Float64(0.5 + Float64(i * 0.16666666666666666)))))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -5.3e-191) tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); elseif (n <= 1.15e-213) tmp = 0.0; else tmp = 100.0 * (n * (1.0 + (i * (0.5 + (i * 0.16666666666666666))))); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -5.3e-191], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.15e-213], 0.0, N[(100.0 * N[(n * N[(1.0 + N[(i * N[(0.5 + N[(i * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -5.3 \cdot 10^{-191}:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{elif}\;n \leq 1.15 \cdot 10^{-213}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \left(n \cdot \left(1 + i \cdot \left(0.5 + i \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if n < -5.29999999999999985e-191Initial program 22.9%
associate-/r/23.2%
associate-*r*23.1%
*-commutative23.1%
associate-*r/23.2%
sub-neg23.2%
distribute-lft-in23.2%
metadata-eval23.2%
metadata-eval23.2%
metadata-eval23.2%
fma-define23.2%
metadata-eval23.2%
Simplified23.2%
Taylor expanded in n around inf 32.2%
sub-neg32.2%
metadata-eval32.2%
metadata-eval32.2%
distribute-lft-in32.2%
metadata-eval32.2%
sub-neg32.2%
expm1-define77.7%
Simplified77.7%
associate-/l*85.9%
*-commutative85.9%
*-commutative85.9%
associate-/l*85.9%
Applied egg-rr85.9%
Taylor expanded in i around 0 62.1%
*-commutative62.1%
Simplified62.1%
if -5.29999999999999985e-191 < n < 1.15000000000000001e-213Initial program 73.1%
associate-*r/73.1%
sub-neg73.1%
distribute-rgt-in73.1%
metadata-eval73.1%
metadata-eval73.1%
Simplified73.1%
Taylor expanded in i around 0 90.3%
+-commutative90.3%
Simplified90.3%
Taylor expanded in i around 0 90.3%
Taylor expanded in i around 0 90.3%
if 1.15000000000000001e-213 < n Initial program 22.9%
Taylor expanded in n around inf 38.3%
*-commutative38.3%
associate-/l*38.4%
expm1-define86.6%
Simplified86.6%
Taylor expanded in i around 0 73.6%
*-commutative73.6%
Simplified73.6%
Final simplification71.0%
(FPCore (i n) :precision binary64 (if (or (<= n -1.6e-191) (not (<= n 1.15e-213))) (* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668))))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -1.6e-191) || !(n <= 1.15e-213)) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-1.6d-191)) .or. (.not. (n <= 1.15d-213))) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -1.6e-191) || !(n <= 1.15e-213)) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.6e-191) or not (n <= 1.15e-213): tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.6e-191) || !(n <= 1.15e-213)) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -1.6e-191) || ~((n <= 1.15e-213))) tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -1.6e-191], N[Not[LessEqual[n, 1.15e-213]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.6 \cdot 10^{-191} \lor \neg \left(n \leq 1.15 \cdot 10^{-213}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -1.6000000000000002e-191 or 1.15000000000000001e-213 < n Initial program 22.9%
associate-/r/23.2%
associate-*r*23.2%
*-commutative23.2%
associate-*r/23.2%
sub-neg23.2%
distribute-lft-in23.2%
metadata-eval23.2%
metadata-eval23.2%
metadata-eval23.2%
fma-define23.2%
metadata-eval23.2%
Simplified23.2%
Taylor expanded in n around inf 35.2%
sub-neg35.2%
metadata-eval35.2%
metadata-eval35.2%
distribute-lft-in35.2%
metadata-eval35.2%
sub-neg35.2%
expm1-define75.9%
Simplified75.9%
associate-/l*86.2%
*-commutative86.2%
*-commutative86.2%
associate-/l*85.4%
Applied egg-rr85.4%
Taylor expanded in i around 0 68.5%
*-commutative68.5%
Simplified68.5%
if -1.6000000000000002e-191 < n < 1.15000000000000001e-213Initial program 73.1%
associate-*r/73.1%
sub-neg73.1%
distribute-rgt-in73.1%
metadata-eval73.1%
metadata-eval73.1%
Simplified73.1%
Taylor expanded in i around 0 90.3%
+-commutative90.3%
Simplified90.3%
Taylor expanded in i around 0 90.3%
Taylor expanded in i around 0 90.3%
Final simplification71.0%
(FPCore (i n) :precision binary64 (if (or (<= n -7e-192) (not (<= n 6.2e-214))) (* n (+ 100.0 (* i 50.0))) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -7e-192) || !(n <= 6.2e-214)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-7d-192)) .or. (.not. (n <= 6.2d-214))) then
tmp = n * (100.0d0 + (i * 50.0d0))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -7e-192) || !(n <= 6.2e-214)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -7e-192) or not (n <= 6.2e-214): tmp = n * (100.0 + (i * 50.0)) else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -7e-192) || !(n <= 6.2e-214)) tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -7e-192) || ~((n <= 6.2e-214))) tmp = n * (100.0 + (i * 50.0)); else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -7e-192], N[Not[LessEqual[n, 6.2e-214]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -7 \cdot 10^{-192} \lor \neg \left(n \leq 6.2 \cdot 10^{-214}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -7.00000000000000029e-192 or 6.20000000000000008e-214 < n Initial program 22.9%
Taylor expanded in n around inf 35.6%
*-commutative35.6%
associate-/l*35.6%
expm1-define86.3%
Simplified86.3%
Taylor expanded in i around 0 66.3%
+-commutative66.3%
associate-*r*66.3%
distribute-rgt-in66.3%
*-commutative66.3%
Simplified66.3%
if -7.00000000000000029e-192 < n < 6.20000000000000008e-214Initial program 73.1%
associate-*r/73.1%
sub-neg73.1%
distribute-rgt-in73.1%
metadata-eval73.1%
metadata-eval73.1%
Simplified73.1%
Taylor expanded in i around 0 90.3%
+-commutative90.3%
Simplified90.3%
Taylor expanded in i around 0 90.3%
Taylor expanded in i around 0 90.3%
Final simplification69.0%
(FPCore (i n) :precision binary64 (if (or (<= n -9.5e-192) (not (<= n 3.4e-215))) (* n 100.0) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -9.5e-192) || !(n <= 3.4e-215)) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
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-192)) .or. (.not. (n <= 3.4d-215))) then
tmp = n * 100.0d0
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -9.5e-192) || !(n <= 3.4e-215)) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -9.5e-192) or not (n <= 3.4e-215): tmp = n * 100.0 else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -9.5e-192) || !(n <= 3.4e-215)) tmp = Float64(n * 100.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -9.5e-192) || ~((n <= 3.4e-215))) tmp = n * 100.0; else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -9.5e-192], N[Not[LessEqual[n, 3.4e-215]], $MachinePrecision]], N[(n * 100.0), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -9.5 \cdot 10^{-192} \lor \neg \left(n \leq 3.4 \cdot 10^{-215}\right):\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -9.4999999999999996e-192 or 3.40000000000000001e-215 < n Initial program 22.9%
Taylor expanded in i around 0 55.6%
*-commutative55.6%
Simplified55.6%
if -9.4999999999999996e-192 < n < 3.40000000000000001e-215Initial program 73.1%
associate-*r/73.1%
sub-neg73.1%
distribute-rgt-in73.1%
metadata-eval73.1%
metadata-eval73.1%
Simplified73.1%
Taylor expanded in i around 0 90.3%
+-commutative90.3%
Simplified90.3%
Taylor expanded in i around 0 90.3%
Taylor expanded in i around 0 90.3%
Final simplification59.5%
(FPCore (i n) :precision binary64 0.0)
double code(double i, double n) {
return 0.0;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double i, double n) {
return 0.0;
}
def code(i, n): return 0.0
function code(i, n) return 0.0 end
function tmp = code(i, n) tmp = 0.0; end
code[i_, n_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 28.6%
associate-*r/28.6%
sub-neg28.6%
distribute-rgt-in28.6%
metadata-eval28.6%
metadata-eval28.6%
Simplified28.6%
Taylor expanded in i around 0 15.5%
+-commutative15.5%
Simplified15.5%
Taylor expanded in i around 0 15.7%
Taylor expanded in i around 0 16.0%
Final simplification16.0%
(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 2024055
(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))))