
(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 10 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)))
(t_2 (* n (/ (+ (* t_0 100.0) -100.0) i))))
(if (<= t_1 -5e-43)
t_2
(if (<= t_1 0.0)
(* (/ (expm1 (* n (log1p (/ i n)))) i) (* n 100.0))
(if (<= t_1 INFINITY) t_2 (* 100.0 (/ n (+ 1.0 (* i -0.5)))))))))
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 t_2 = n * (((t_0 * 100.0) + -100.0) / i);
double tmp;
if (t_1 <= -5e-43) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = (expm1((n * log1p((i / n)))) / i) * (n * 100.0);
} else if (t_1 <= ((double) INFINITY)) {
tmp = t_2;
} else {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
}
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 t_2 = n * (((t_0 * 100.0) + -100.0) / i);
double tmp;
if (t_1 <= -5e-43) {
tmp = t_2;
} else if (t_1 <= 0.0) {
tmp = (Math.expm1((n * Math.log1p((i / n)))) / i) * (n * 100.0);
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_2;
} else {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
}
return tmp;
}
def code(i, n): t_0 = math.pow((1.0 + (i / n)), n) t_1 = (t_0 + -1.0) / (i / n) t_2 = n * (((t_0 * 100.0) + -100.0) / i) tmp = 0 if t_1 <= -5e-43: tmp = t_2 elif t_1 <= 0.0: tmp = (math.expm1((n * math.log1p((i / n)))) / i) * (n * 100.0) elif t_1 <= math.inf: tmp = t_2 else: tmp = 100.0 * (n / (1.0 + (i * -0.5))) 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)) t_2 = Float64(n * Float64(Float64(Float64(t_0 * 100.0) + -100.0) / i)) tmp = 0.0 if (t_1 <= -5e-43) tmp = t_2; elseif (t_1 <= 0.0) tmp = Float64(Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i) * Float64(n * 100.0)); elseif (t_1 <= Inf) tmp = t_2; else tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); 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]}, Block[{t$95$2 = N[(n * N[(N[(N[(t$95$0 * 100.0), $MachinePrecision] + -100.0), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-43], t$95$2, If[LessEqual[t$95$1, 0.0], N[(N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision] * N[(n * 100.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], t$95$2, N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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}}\\
t_2 := n \cdot \frac{t_0 \cdot 100 + -100}{i}\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{-43}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i} \cdot \left(n \cdot 100\right)\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -5.00000000000000019e-43 or -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.2%
associate-/r/99.2%
associate-*r*99.2%
*-commutative99.2%
associate-*r/99.3%
sub-neg99.3%
distribute-lft-in99.5%
metadata-eval99.5%
metadata-eval99.5%
metadata-eval99.5%
fma-def99.3%
metadata-eval99.3%
Simplified99.3%
fma-udef99.5%
*-commutative99.5%
Applied egg-rr99.5%
if -5.00000000000000019e-43 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0Initial program 27.8%
*-commutative27.8%
associate-/r/27.3%
associate-*l*27.3%
sub-neg27.3%
metadata-eval27.3%
Simplified27.3%
*-un-lft-identity27.3%
metadata-eval27.3%
sub-neg27.3%
add-exp-log27.3%
expm1-def27.3%
log-pow37.4%
log1p-udef98.2%
Applied egg-rr98.2%
*-lft-identity98.2%
Simplified98.2%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
associate-/r/1.9%
sub-neg1.9%
metadata-eval1.9%
Simplified1.9%
Taylor expanded in n around inf 1.9%
associate-/l*1.9%
expm1-def76.3%
Simplified76.3%
Taylor expanded in i around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification98.7%
(FPCore (i n) :precision binary64 (if (or (<= n -2.8) (not (<= n 1.3e+15))) (* 100.0 (/ n (/ i (expm1 i)))) (/ (* n 100.0) (+ 1.0 (* i (+ -0.5 (/ 0.5 n)))))))
double code(double i, double n) {
double tmp;
if ((n <= -2.8) || !(n <= 1.3e+15)) {
tmp = 100.0 * (n / (i / expm1(i)));
} else {
tmp = (n * 100.0) / (1.0 + (i * (-0.5 + (0.5 / n))));
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -2.8) || !(n <= 1.3e+15)) {
tmp = 100.0 * (n / (i / Math.expm1(i)));
} else {
tmp = (n * 100.0) / (1.0 + (i * (-0.5 + (0.5 / n))));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -2.8) or not (n <= 1.3e+15): tmp = 100.0 * (n / (i / math.expm1(i))) else: tmp = (n * 100.0) / (1.0 + (i * (-0.5 + (0.5 / n)))) return tmp
function code(i, n) tmp = 0.0 if ((n <= -2.8) || !(n <= 1.3e+15)) tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i)))); else tmp = Float64(Float64(n * 100.0) / Float64(1.0 + Float64(i * Float64(-0.5 + Float64(0.5 / n))))); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -2.8], N[Not[LessEqual[n, 1.3e+15]], $MachinePrecision]], N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] / N[(1.0 + N[(i * N[(-0.5 + N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.8 \lor \neg \left(n \leq 1.3 \cdot 10^{+15}\right):\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{n \cdot 100}{1 + i \cdot \left(-0.5 + \frac{0.5}{n}\right)}\\
\end{array}
\end{array}
if n < -2.7999999999999998 or 1.3e15 < n Initial program 32.5%
associate-/r/33.0%
sub-neg33.0%
metadata-eval33.0%
Simplified33.0%
Taylor expanded in n around inf 49.3%
associate-/l*49.3%
expm1-def91.9%
Simplified91.9%
if -2.7999999999999998 < n < 1.3e15Initial program 31.6%
*-commutative31.6%
associate-/r/31.0%
sub-neg31.0%
metadata-eval31.0%
associate-*r*31.0%
*-commutative31.0%
clear-num31.0%
un-div-inv31.0%
metadata-eval31.0%
sub-neg31.0%
add-exp-log31.0%
expm1-def31.0%
log-pow47.4%
log1p-udef88.0%
Applied egg-rr88.0%
Taylor expanded in i around 0 84.7%
sub-neg84.7%
associate-*r/84.7%
metadata-eval84.7%
metadata-eval84.7%
Simplified84.7%
Final simplification88.9%
(FPCore (i n)
:precision binary64
(if (<= n -2.05e+210)
(/ (* 100.0 (* i n)) i)
(if (<= n -2.8e-196)
(* 100.0 (/ n (+ 1.0 (* i -0.5))))
(if (<= n 1.95e-159) 0.0 (+ (* n 100.0) (* (* i n) 50.0))))))
double code(double i, double n) {
double tmp;
if (n <= -2.05e+210) {
tmp = (100.0 * (i * n)) / i;
} else if (n <= -2.8e-196) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 1.95e-159) {
tmp = 0.0;
} else {
tmp = (n * 100.0) + ((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 (n <= (-2.05d+210)) then
tmp = (100.0d0 * (i * n)) / i
else if (n <= (-2.8d-196)) then
tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
else if (n <= 1.95d-159) then
tmp = 0.0d0
else
tmp = (n * 100.0d0) + ((i * n) * 50.0d0)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -2.05e+210) {
tmp = (100.0 * (i * n)) / i;
} else if (n <= -2.8e-196) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 1.95e-159) {
tmp = 0.0;
} else {
tmp = (n * 100.0) + ((i * n) * 50.0);
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -2.05e+210: tmp = (100.0 * (i * n)) / i elif n <= -2.8e-196: tmp = 100.0 * (n / (1.0 + (i * -0.5))) elif n <= 1.95e-159: tmp = 0.0 else: tmp = (n * 100.0) + ((i * n) * 50.0) return tmp
function code(i, n) tmp = 0.0 if (n <= -2.05e+210) tmp = Float64(Float64(100.0 * Float64(i * n)) / i); elseif (n <= -2.8e-196) tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); elseif (n <= 1.95e-159) tmp = 0.0; else tmp = Float64(Float64(n * 100.0) + Float64(Float64(i * n) * 50.0)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -2.05e+210) tmp = (100.0 * (i * n)) / i; elseif (n <= -2.8e-196) tmp = 100.0 * (n / (1.0 + (i * -0.5))); elseif (n <= 1.95e-159) tmp = 0.0; else tmp = (n * 100.0) + ((i * n) * 50.0); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -2.05e+210], N[(N[(100.0 * N[(i * n), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision], If[LessEqual[n, -2.8e-196], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.95e-159], 0.0, N[(N[(n * 100.0), $MachinePrecision] + N[(N[(i * n), $MachinePrecision] * 50.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.05 \cdot 10^{+210}:\\
\;\;\;\;\frac{100 \cdot \left(i \cdot n\right)}{i}\\
\mathbf{elif}\;n \leq -2.8 \cdot 10^{-196}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\mathbf{elif}\;n \leq 1.95 \cdot 10^{-159}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100 + \left(i \cdot n\right) \cdot 50\\
\end{array}
\end{array}
if n < -2.05e210Initial program 24.7%
Taylor expanded in n around inf 56.7%
associate-*r/56.6%
expm1-def95.7%
Simplified95.7%
Taylor expanded in i around 0 76.7%
*-commutative76.7%
Simplified76.7%
if -2.05e210 < n < -2.7999999999999998e-196Initial program 37.4%
associate-/r/37.5%
sub-neg37.5%
metadata-eval37.5%
Simplified37.5%
Taylor expanded in n around inf 36.7%
associate-/l*36.7%
expm1-def78.6%
Simplified78.6%
Taylor expanded in i around 0 55.5%
*-commutative55.5%
Simplified55.5%
if -2.7999999999999998e-196 < n < 1.94999999999999988e-159Initial program 56.2%
*-commutative56.2%
associate-/r/54.6%
associate-*l*54.6%
sub-neg54.6%
metadata-eval54.6%
Simplified54.6%
Taylor expanded in i around 0 87.8%
Taylor expanded in i around 0 87.8%
if 1.94999999999999988e-159 < n Initial program 20.8%
associate-/r/21.2%
sub-neg21.2%
metadata-eval21.2%
Simplified21.2%
Taylor expanded in n around inf 32.7%
associate-/l*32.7%
expm1-def88.7%
Simplified88.7%
Taylor expanded in i around 0 76.2%
Final simplification70.8%
(FPCore (i n)
:precision binary64
(if (<= n -2.8e+211)
(/ (* 100.0 (* i n)) i)
(if (<= n 1.96)
(/ (* n 100.0) (+ 1.0 (* i (+ -0.5 (/ 0.5 n)))))
(+ (* n 100.0) (* (* i n) 50.0)))))
double code(double i, double n) {
double tmp;
if (n <= -2.8e+211) {
tmp = (100.0 * (i * n)) / i;
} else if (n <= 1.96) {
tmp = (n * 100.0) / (1.0 + (i * (-0.5 + (0.5 / n))));
} else {
tmp = (n * 100.0) + ((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 (n <= (-2.8d+211)) then
tmp = (100.0d0 * (i * n)) / i
else if (n <= 1.96d0) then
tmp = (n * 100.0d0) / (1.0d0 + (i * ((-0.5d0) + (0.5d0 / n))))
else
tmp = (n * 100.0d0) + ((i * n) * 50.0d0)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -2.8e+211) {
tmp = (100.0 * (i * n)) / i;
} else if (n <= 1.96) {
tmp = (n * 100.0) / (1.0 + (i * (-0.5 + (0.5 / n))));
} else {
tmp = (n * 100.0) + ((i * n) * 50.0);
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -2.8e+211: tmp = (100.0 * (i * n)) / i elif n <= 1.96: tmp = (n * 100.0) / (1.0 + (i * (-0.5 + (0.5 / n)))) else: tmp = (n * 100.0) + ((i * n) * 50.0) return tmp
function code(i, n) tmp = 0.0 if (n <= -2.8e+211) tmp = Float64(Float64(100.0 * Float64(i * n)) / i); elseif (n <= 1.96) tmp = Float64(Float64(n * 100.0) / Float64(1.0 + Float64(i * Float64(-0.5 + Float64(0.5 / n))))); else tmp = Float64(Float64(n * 100.0) + Float64(Float64(i * n) * 50.0)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -2.8e+211) tmp = (100.0 * (i * n)) / i; elseif (n <= 1.96) tmp = (n * 100.0) / (1.0 + (i * (-0.5 + (0.5 / n)))); else tmp = (n * 100.0) + ((i * n) * 50.0); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -2.8e+211], N[(N[(100.0 * N[(i * n), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision], If[LessEqual[n, 1.96], N[(N[(n * 100.0), $MachinePrecision] / N[(1.0 + N[(i * N[(-0.5 + N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(n * 100.0), $MachinePrecision] + N[(N[(i * n), $MachinePrecision] * 50.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.8 \cdot 10^{+211}:\\
\;\;\;\;\frac{100 \cdot \left(i \cdot n\right)}{i}\\
\mathbf{elif}\;n \leq 1.96:\\
\;\;\;\;\frac{n \cdot 100}{1 + i \cdot \left(-0.5 + \frac{0.5}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100 + \left(i \cdot n\right) \cdot 50\\
\end{array}
\end{array}
if n < -2.8e211Initial program 24.7%
Taylor expanded in n around inf 56.7%
associate-*r/56.6%
expm1-def95.7%
Simplified95.7%
Taylor expanded in i around 0 76.7%
*-commutative76.7%
Simplified76.7%
if -2.8e211 < n < 1.96Initial program 37.2%
*-commutative37.2%
associate-/r/36.9%
sub-neg36.9%
metadata-eval36.9%
associate-*r*36.9%
*-commutative36.9%
clear-num36.9%
un-div-inv36.9%
metadata-eval36.9%
sub-neg36.9%
add-exp-log36.9%
expm1-def36.9%
log-pow44.5%
log1p-udef84.6%
Applied egg-rr84.6%
Taylor expanded in i around 0 71.7%
sub-neg71.7%
associate-*r/71.7%
metadata-eval71.7%
metadata-eval71.7%
Simplified71.7%
if 1.96 < n Initial program 24.8%
associate-/r/25.5%
sub-neg25.5%
metadata-eval25.5%
Simplified25.5%
Taylor expanded in n around inf 41.7%
associate-/l*41.7%
expm1-def93.7%
Simplified93.7%
Taylor expanded in i around 0 77.2%
Final simplification73.9%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* n (+ 100.0 (* i 50.0)))))
(if (<= n -5.8e+102)
t_0
(if (<= n -2.45e-185)
(* 100.0 (/ i (/ i n)))
(if (<= n 4.2e-159) 0.0 t_0)))))
double code(double i, double n) {
double t_0 = n * (100.0 + (i * 50.0));
double tmp;
if (n <= -5.8e+102) {
tmp = t_0;
} else if (n <= -2.45e-185) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 4.2e-159) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
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 = n * (100.0d0 + (i * 50.0d0))
if (n <= (-5.8d+102)) then
tmp = t_0
else if (n <= (-2.45d-185)) then
tmp = 100.0d0 * (i / (i / n))
else if (n <= 4.2d-159) then
tmp = 0.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double i, double n) {
double t_0 = n * (100.0 + (i * 50.0));
double tmp;
if (n <= -5.8e+102) {
tmp = t_0;
} else if (n <= -2.45e-185) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 4.2e-159) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = n * (100.0 + (i * 50.0)) tmp = 0 if n <= -5.8e+102: tmp = t_0 elif n <= -2.45e-185: tmp = 100.0 * (i / (i / n)) elif n <= 4.2e-159: tmp = 0.0 else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(n * Float64(100.0 + Float64(i * 50.0))) tmp = 0.0 if (n <= -5.8e+102) tmp = t_0; elseif (n <= -2.45e-185) tmp = Float64(100.0 * Float64(i / Float64(i / n))); elseif (n <= 4.2e-159) tmp = 0.0; else tmp = t_0; end return tmp end
function tmp_2 = code(i, n) t_0 = n * (100.0 + (i * 50.0)); tmp = 0.0; if (n <= -5.8e+102) tmp = t_0; elseif (n <= -2.45e-185) tmp = 100.0 * (i / (i / n)); elseif (n <= 4.2e-159) tmp = 0.0; else tmp = t_0; end tmp_2 = tmp; end
code[i_, n_] := Block[{t$95$0 = N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -5.8e+102], t$95$0, If[LessEqual[n, -2.45e-185], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 4.2e-159], 0.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{if}\;n \leq -5.8 \cdot 10^{+102}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq -2.45 \cdot 10^{-185}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 4.2 \cdot 10^{-159}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if n < -5.8000000000000005e102 or 4.1999999999999998e-159 < n Initial program 26.5%
associate-/r/27.0%
associate-*r*27.0%
*-commutative27.0%
associate-*r/27.0%
sub-neg27.0%
distribute-lft-in27.0%
metadata-eval27.0%
metadata-eval27.0%
metadata-eval27.0%
fma-def27.0%
metadata-eval27.0%
Simplified27.0%
Taylor expanded in n around inf 41.7%
*-commutative41.7%
fma-neg41.7%
metadata-eval41.7%
Simplified41.7%
Taylor expanded in i around 0 67.5%
*-commutative67.5%
Simplified67.5%
if -5.8000000000000005e102 < n < -2.4500000000000001e-185Initial program 30.7%
Taylor expanded in i around 0 10.6%
+-commutative10.6%
Simplified10.6%
Taylor expanded in i around 0 61.4%
if -2.4500000000000001e-185 < n < 4.1999999999999998e-159Initial program 56.0%
*-commutative56.0%
associate-/r/54.5%
associate-*l*54.5%
sub-neg54.5%
metadata-eval54.5%
Simplified54.5%
Taylor expanded in i around 0 86.0%
Taylor expanded in i around 0 86.0%
Final simplification69.0%
(FPCore (i n)
:precision binary64
(if (<= n -5e+102)
(* (* i n) (/ 100.0 i))
(if (<= n -2.45e-185)
(* 100.0 (/ i (/ i n)))
(if (<= n 3e-159) 0.0 (* n (+ 100.0 (* i 50.0)))))))
double code(double i, double n) {
double tmp;
if (n <= -5e+102) {
tmp = (i * n) * (100.0 / i);
} else if (n <= -2.45e-185) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 3e-159) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-5d+102)) then
tmp = (i * n) * (100.0d0 / i)
else if (n <= (-2.45d-185)) then
tmp = 100.0d0 * (i / (i / n))
else if (n <= 3d-159) then
tmp = 0.0d0
else
tmp = n * (100.0d0 + (i * 50.0d0))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -5e+102) {
tmp = (i * n) * (100.0 / i);
} else if (n <= -2.45e-185) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 3e-159) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -5e+102: tmp = (i * n) * (100.0 / i) elif n <= -2.45e-185: tmp = 100.0 * (i / (i / n)) elif n <= 3e-159: tmp = 0.0 else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= -5e+102) tmp = Float64(Float64(i * n) * Float64(100.0 / i)); elseif (n <= -2.45e-185) tmp = Float64(100.0 * Float64(i / Float64(i / n))); elseif (n <= 3e-159) tmp = 0.0; else tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -5e+102) tmp = (i * n) * (100.0 / i); elseif (n <= -2.45e-185) tmp = 100.0 * (i / (i / n)); elseif (n <= 3e-159) tmp = 0.0; else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -5e+102], N[(N[(i * n), $MachinePrecision] * N[(100.0 / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -2.45e-185], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3e-159], 0.0, N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -5 \cdot 10^{+102}:\\
\;\;\;\;\left(i \cdot n\right) \cdot \frac{100}{i}\\
\mathbf{elif}\;n \leq -2.45 \cdot 10^{-185}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 3 \cdot 10^{-159}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -5e102Initial program 38.6%
Taylor expanded in n around inf 60.5%
associate-*r/60.4%
expm1-def89.8%
Simplified89.8%
Taylor expanded in i around 0 50.1%
*-commutative50.1%
Simplified50.1%
associate-/l*50.1%
associate-/r/50.0%
Applied egg-rr50.0%
if -5e102 < n < -2.4500000000000001e-185Initial program 30.7%
Taylor expanded in i around 0 10.6%
+-commutative10.6%
Simplified10.6%
Taylor expanded in i around 0 61.4%
if -2.4500000000000001e-185 < n < 3.00000000000000009e-159Initial program 56.0%
*-commutative56.0%
associate-/r/54.5%
associate-*l*54.5%
sub-neg54.5%
metadata-eval54.5%
Simplified54.5%
Taylor expanded in i around 0 86.0%
Taylor expanded in i around 0 86.0%
if 3.00000000000000009e-159 < n Initial program 20.8%
associate-/r/21.2%
associate-*r*21.2%
*-commutative21.2%
associate-*r/21.2%
sub-neg21.2%
distribute-lft-in21.3%
metadata-eval21.3%
metadata-eval21.3%
metadata-eval21.3%
fma-def21.2%
metadata-eval21.2%
Simplified21.2%
Taylor expanded in n around inf 32.7%
*-commutative32.7%
fma-neg32.7%
metadata-eval32.7%
Simplified32.7%
Taylor expanded in i around 0 76.2%
*-commutative76.2%
Simplified76.2%
Final simplification69.1%
(FPCore (i n)
:precision binary64
(if (<= n -5e+102)
(/ (* 100.0 (* i n)) i)
(if (<= n -3.7e-184)
(* 100.0 (/ i (/ i n)))
(if (<= n 5.1e-160) 0.0 (* n (+ 100.0 (* i 50.0)))))))
double code(double i, double n) {
double tmp;
if (n <= -5e+102) {
tmp = (100.0 * (i * n)) / i;
} else if (n <= -3.7e-184) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 5.1e-160) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-5d+102)) then
tmp = (100.0d0 * (i * n)) / i
else if (n <= (-3.7d-184)) then
tmp = 100.0d0 * (i / (i / n))
else if (n <= 5.1d-160) then
tmp = 0.0d0
else
tmp = n * (100.0d0 + (i * 50.0d0))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -5e+102) {
tmp = (100.0 * (i * n)) / i;
} else if (n <= -3.7e-184) {
tmp = 100.0 * (i / (i / n));
} else if (n <= 5.1e-160) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -5e+102: tmp = (100.0 * (i * n)) / i elif n <= -3.7e-184: tmp = 100.0 * (i / (i / n)) elif n <= 5.1e-160: tmp = 0.0 else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= -5e+102) tmp = Float64(Float64(100.0 * Float64(i * n)) / i); elseif (n <= -3.7e-184) tmp = Float64(100.0 * Float64(i / Float64(i / n))); elseif (n <= 5.1e-160) tmp = 0.0; else tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -5e+102) tmp = (100.0 * (i * n)) / i; elseif (n <= -3.7e-184) tmp = 100.0 * (i / (i / n)); elseif (n <= 5.1e-160) tmp = 0.0; else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -5e+102], N[(N[(100.0 * N[(i * n), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision], If[LessEqual[n, -3.7e-184], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 5.1e-160], 0.0, N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -5 \cdot 10^{+102}:\\
\;\;\;\;\frac{100 \cdot \left(i \cdot n\right)}{i}\\
\mathbf{elif}\;n \leq -3.7 \cdot 10^{-184}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 5.1 \cdot 10^{-160}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -5e102Initial program 38.6%
Taylor expanded in n around inf 60.5%
associate-*r/60.4%
expm1-def89.8%
Simplified89.8%
Taylor expanded in i around 0 50.1%
*-commutative50.1%
Simplified50.1%
if -5e102 < n < -3.6999999999999999e-184Initial program 30.7%
Taylor expanded in i around 0 10.6%
+-commutative10.6%
Simplified10.6%
Taylor expanded in i around 0 61.4%
if -3.6999999999999999e-184 < n < 5.1e-160Initial program 56.0%
*-commutative56.0%
associate-/r/54.5%
associate-*l*54.5%
sub-neg54.5%
metadata-eval54.5%
Simplified54.5%
Taylor expanded in i around 0 86.0%
Taylor expanded in i around 0 86.0%
if 5.1e-160 < n Initial program 20.8%
associate-/r/21.2%
associate-*r*21.2%
*-commutative21.2%
associate-*r/21.2%
sub-neg21.2%
distribute-lft-in21.3%
metadata-eval21.3%
metadata-eval21.3%
metadata-eval21.3%
fma-def21.2%
metadata-eval21.2%
Simplified21.2%
Taylor expanded in n around inf 32.7%
*-commutative32.7%
fma-neg32.7%
metadata-eval32.7%
Simplified32.7%
Taylor expanded in i around 0 76.2%
*-commutative76.2%
Simplified76.2%
Final simplification69.1%
(FPCore (i n)
:precision binary64
(if (<= n -3e+211)
(/ (* 100.0 (* i n)) i)
(if (<= n -1.5e-196)
(* 100.0 (/ n (+ 1.0 (* i -0.5))))
(if (<= n 7.5e-158) 0.0 (* n (+ 100.0 (* i 50.0)))))))
double code(double i, double n) {
double tmp;
if (n <= -3e+211) {
tmp = (100.0 * (i * n)) / i;
} else if (n <= -1.5e-196) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 7.5e-158) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-3d+211)) then
tmp = (100.0d0 * (i * n)) / i
else if (n <= (-1.5d-196)) then
tmp = 100.0d0 * (n / (1.0d0 + (i * (-0.5d0))))
else if (n <= 7.5d-158) then
tmp = 0.0d0
else
tmp = n * (100.0d0 + (i * 50.0d0))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -3e+211) {
tmp = (100.0 * (i * n)) / i;
} else if (n <= -1.5e-196) {
tmp = 100.0 * (n / (1.0 + (i * -0.5)));
} else if (n <= 7.5e-158) {
tmp = 0.0;
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -3e+211: tmp = (100.0 * (i * n)) / i elif n <= -1.5e-196: tmp = 100.0 * (n / (1.0 + (i * -0.5))) elif n <= 7.5e-158: tmp = 0.0 else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= -3e+211) tmp = Float64(Float64(100.0 * Float64(i * n)) / i); elseif (n <= -1.5e-196) tmp = Float64(100.0 * Float64(n / Float64(1.0 + Float64(i * -0.5)))); elseif (n <= 7.5e-158) tmp = 0.0; else tmp = Float64(n * Float64(100.0 + Float64(i * 50.0))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -3e+211) tmp = (100.0 * (i * n)) / i; elseif (n <= -1.5e-196) tmp = 100.0 * (n / (1.0 + (i * -0.5))); elseif (n <= 7.5e-158) tmp = 0.0; else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -3e+211], N[(N[(100.0 * N[(i * n), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision], If[LessEqual[n, -1.5e-196], N[(100.0 * N[(n / N[(1.0 + N[(i * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 7.5e-158], 0.0, N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3 \cdot 10^{+211}:\\
\;\;\;\;\frac{100 \cdot \left(i \cdot n\right)}{i}\\
\mathbf{elif}\;n \leq -1.5 \cdot 10^{-196}:\\
\;\;\;\;100 \cdot \frac{n}{1 + i \cdot -0.5}\\
\mathbf{elif}\;n \leq 7.5 \cdot 10^{-158}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -3e211Initial program 24.7%
Taylor expanded in n around inf 56.7%
associate-*r/56.6%
expm1-def95.7%
Simplified95.7%
Taylor expanded in i around 0 76.7%
*-commutative76.7%
Simplified76.7%
if -3e211 < n < -1.5e-196Initial program 37.4%
associate-/r/37.5%
sub-neg37.5%
metadata-eval37.5%
Simplified37.5%
Taylor expanded in n around inf 36.7%
associate-/l*36.7%
expm1-def78.6%
Simplified78.6%
Taylor expanded in i around 0 55.5%
*-commutative55.5%
Simplified55.5%
if -1.5e-196 < n < 7.5e-158Initial program 56.2%
*-commutative56.2%
associate-/r/54.6%
associate-*l*54.6%
sub-neg54.6%
metadata-eval54.6%
Simplified54.6%
Taylor expanded in i around 0 87.8%
Taylor expanded in i around 0 87.8%
if 7.5e-158 < n Initial program 20.8%
associate-/r/21.2%
associate-*r*21.2%
*-commutative21.2%
associate-*r/21.2%
sub-neg21.2%
distribute-lft-in21.3%
metadata-eval21.3%
metadata-eval21.3%
metadata-eval21.3%
fma-def21.2%
metadata-eval21.2%
Simplified21.2%
Taylor expanded in n around inf 32.7%
*-commutative32.7%
fma-neg32.7%
metadata-eval32.7%
Simplified32.7%
Taylor expanded in i around 0 76.2%
*-commutative76.2%
Simplified76.2%
Final simplification70.8%
(FPCore (i n) :precision binary64 (if (or (<= n -2.6e-183) (not (<= n 5.9e-158))) (* n 100.0) 0.0))
double code(double i, double n) {
double tmp;
if ((n <= -2.6e-183) || !(n <= 5.9e-158)) {
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 <= (-2.6d-183)) .or. (.not. (n <= 5.9d-158))) 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 <= -2.6e-183) || !(n <= 5.9e-158)) {
tmp = n * 100.0;
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -2.6e-183) or not (n <= 5.9e-158): tmp = n * 100.0 else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if ((n <= -2.6e-183) || !(n <= 5.9e-158)) tmp = Float64(n * 100.0); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -2.6e-183) || ~((n <= 5.9e-158))) tmp = n * 100.0; else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -2.6e-183], N[Not[LessEqual[n, 5.9e-158]], $MachinePrecision]], N[(n * 100.0), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.6 \cdot 10^{-183} \lor \neg \left(n \leq 5.9 \cdot 10^{-158}\right):\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -2.5999999999999999e-183 or 5.9000000000000002e-158 < n Initial program 27.7%
Taylor expanded in i around 0 52.5%
*-commutative52.5%
Simplified52.5%
if -2.5999999999999999e-183 < n < 5.9000000000000002e-158Initial program 56.0%
*-commutative56.0%
associate-/r/54.5%
associate-*l*54.5%
sub-neg54.5%
metadata-eval54.5%
Simplified54.5%
Taylor expanded in i around 0 86.0%
Taylor expanded in i around 0 86.0%
Final simplification57.7%
(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 32.1%
*-commutative32.1%
associate-/r/32.2%
associate-*l*32.2%
sub-neg32.2%
metadata-eval32.2%
Simplified32.2%
Taylor expanded in i around 0 18.7%
Taylor expanded in i around 0 18.7%
Final simplification18.7%
(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 2024018
(FPCore (i n)
:name "Compound Interest"
:precision binary64
:herbie-target
(* 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))))