
(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 12 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 -1e-89)
(/ (+ (* t_0 100.0) -100.0) (/ i n))
(if (<= t_1 0.0)
(* 100.0 (/ (expm1 (* n (log1p (/ i n)))) (/ i n)))
(if (<= t_1 INFINITY)
(* n (/ (+ -100.0 (* 100.0 (pow (/ i n) n))) i))
(/
n
(+ 0.01 (+ (* i -0.005) (* 0.0008333333333333334 (pow i 2.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 <= -1e-89) {
tmp = ((t_0 * 100.0) + -100.0) / (i / n);
} else if (t_1 <= 0.0) {
tmp = 100.0 * (expm1((n * log1p((i / n)))) / (i / n));
} else if (t_1 <= ((double) INFINITY)) {
tmp = n * ((-100.0 + (100.0 * pow((i / n), n))) / i);
} else {
tmp = n / (0.01 + ((i * -0.005) + (0.0008333333333333334 * pow(i, 2.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 <= -1e-89) {
tmp = ((t_0 * 100.0) + -100.0) / (i / n);
} else 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 = n * ((-100.0 + (100.0 * Math.pow((i / n), n))) / i);
} else {
tmp = n / (0.01 + ((i * -0.005) + (0.0008333333333333334 * Math.pow(i, 2.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 <= -1e-89: tmp = ((t_0 * 100.0) + -100.0) / (i / n) elif t_1 <= 0.0: tmp = 100.0 * (math.expm1((n * math.log1p((i / n)))) / (i / n)) elif t_1 <= math.inf: tmp = n * ((-100.0 + (100.0 * math.pow((i / n), n))) / i) else: tmp = n / (0.01 + ((i * -0.005) + (0.0008333333333333334 * math.pow(i, 2.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 <= -1e-89) tmp = Float64(Float64(Float64(t_0 * 100.0) + -100.0) / Float64(i / n)); elseif (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(Float64(-100.0 + Float64(100.0 * (Float64(i / n) ^ n))) / i)); else tmp = Float64(n / Float64(0.01 + Float64(Float64(i * -0.005) + Float64(0.0008333333333333334 * (i ^ 2.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, -1e-89], N[(N[(N[(t$95$0 * 100.0), $MachinePrecision] + -100.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 + N[(100.0 * N[Power[N[(i / n), $MachinePrecision], n], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(n / N[(0.01 + N[(N[(i * -0.005), $MachinePrecision] + N[(0.0008333333333333334 * N[Power[i, 2.0], $MachinePrecision]), $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}}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{-89}:\\
\;\;\;\;\frac{t_0 \cdot 100 + -100}{\frac{i}{n}}\\
\mathbf{elif}\;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{-100 + 100 \cdot {\left(\frac{i}{n}\right)}^{n}}{i}\\
\mathbf{else}:\\
\;\;\;\;\frac{n}{0.01 + \left(i \cdot -0.005 + 0.0008333333333333334 \cdot {i}^{2}\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -1.00000000000000004e-89Initial program 99.9%
associate-*r/100.0%
sub-neg100.0%
distribute-lft-in100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
if -1.00000000000000004e-89 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0Initial program 25.1%
*-un-lft-identity25.1%
add-exp-log25.1%
expm1-def25.1%
log-pow39.9%
log1p-udef99.6%
Applied egg-rr99.6%
*-lft-identity99.6%
Simplified99.6%
if -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.6%
associate-/r/99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*r/99.9%
sub-neg99.9%
distribute-lft-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
fma-def99.9%
metadata-eval99.9%
Simplified99.9%
fma-def99.9%
metadata-eval99.9%
metadata-eval99.9%
distribute-lft-in99.9%
sub-neg99.9%
*-commutative99.9%
add-exp-log99.9%
expm1-def99.9%
log-pow56.7%
log1p-udef56.7%
Applied egg-rr56.7%
Taylor expanded in i around inf 56.7%
associate-*r/56.7%
Simplified99.9%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
associate-/r/1.8%
associate-*r*1.8%
*-commutative1.8%
associate-*r/1.8%
sub-neg1.8%
distribute-lft-in1.8%
metadata-eval1.8%
metadata-eval1.8%
metadata-eval1.8%
fma-def1.8%
metadata-eval1.8%
Simplified1.8%
Taylor expanded in n around inf 1.8%
associate-/l*1.8%
*-commutative1.8%
fma-neg1.8%
metadata-eval1.8%
Simplified1.8%
Taylor expanded in i around 0 99.9%
Final simplification99.7%
(FPCore (i n)
:precision binary64
(let* ((t_0 (/ (+ (pow (+ 1.0 (/ i n)) n) -1.0) (/ i n))))
(if (<= t_0 -2e-303)
(* t_0 100.0)
(if (<= t_0 0.0)
(* n (* 100.0 (/ (expm1 i) i)))
(if (<= t_0 INFINITY)
(* n (/ (+ -100.0 (* 100.0 (pow (/ i n) n))) i))
(/
n
(+ 0.01 (+ (* i -0.005) (* 0.0008333333333333334 (pow i 2.0))))))))))
double code(double i, double n) {
double t_0 = (pow((1.0 + (i / n)), n) + -1.0) / (i / n);
double tmp;
if (t_0 <= -2e-303) {
tmp = t_0 * 100.0;
} else if (t_0 <= 0.0) {
tmp = n * (100.0 * (expm1(i) / i));
} else if (t_0 <= ((double) INFINITY)) {
tmp = n * ((-100.0 + (100.0 * pow((i / n), n))) / i);
} else {
tmp = n / (0.01 + ((i * -0.005) + (0.0008333333333333334 * pow(i, 2.0))));
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = (Math.pow((1.0 + (i / n)), n) + -1.0) / (i / n);
double tmp;
if (t_0 <= -2e-303) {
tmp = t_0 * 100.0;
} else if (t_0 <= 0.0) {
tmp = n * (100.0 * (Math.expm1(i) / i));
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = n * ((-100.0 + (100.0 * Math.pow((i / n), n))) / i);
} else {
tmp = n / (0.01 + ((i * -0.005) + (0.0008333333333333334 * Math.pow(i, 2.0))));
}
return tmp;
}
def code(i, n): t_0 = (math.pow((1.0 + (i / n)), n) + -1.0) / (i / n) tmp = 0 if t_0 <= -2e-303: tmp = t_0 * 100.0 elif t_0 <= 0.0: tmp = n * (100.0 * (math.expm1(i) / i)) elif t_0 <= math.inf: tmp = n * ((-100.0 + (100.0 * math.pow((i / n), n))) / i) else: tmp = n / (0.01 + ((i * -0.005) + (0.0008333333333333334 * math.pow(i, 2.0)))) return tmp
function code(i, n) t_0 = Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) + -1.0) / Float64(i / n)) tmp = 0.0 if (t_0 <= -2e-303) tmp = Float64(t_0 * 100.0); elseif (t_0 <= 0.0) tmp = Float64(n * Float64(100.0 * Float64(expm1(i) / i))); elseif (t_0 <= Inf) tmp = Float64(n * Float64(Float64(-100.0 + Float64(100.0 * (Float64(i / n) ^ n))) / i)); else tmp = Float64(n / Float64(0.01 + Float64(Float64(i * -0.005) + Float64(0.0008333333333333334 * (i ^ 2.0))))); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-303], N[(t$95$0 * 100.0), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(n * N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(n * N[(N[(-100.0 + N[(100.0 * N[Power[N[(i / n), $MachinePrecision], n], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(n / N[(0.01 + N[(N[(i * -0.005), $MachinePrecision] + N[(0.0008333333333333334 * N[Power[i, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{{\left(1 + \frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}}\\
\mathbf{if}\;t_0 \leq -2 \cdot 10^{-303}:\\
\;\;\;\;t_0 \cdot 100\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;n \cdot \frac{-100 + 100 \cdot {\left(\frac{i}{n}\right)}^{n}}{i}\\
\mathbf{else}:\\
\;\;\;\;\frac{n}{0.01 + \left(i \cdot -0.005 + 0.0008333333333333334 \cdot {i}^{2}\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -1.99999999999999986e-303Initial program 93.4%
if -1.99999999999999986e-303 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < -0.0Initial program 21.3%
associate-/r/20.7%
associate-*r*20.7%
*-commutative20.7%
associate-*r/20.7%
sub-neg20.7%
distribute-lft-in20.7%
metadata-eval20.7%
metadata-eval20.7%
metadata-eval20.7%
fma-def20.7%
metadata-eval20.7%
Simplified20.7%
fma-def20.7%
metadata-eval20.7%
metadata-eval20.7%
distribute-lft-in20.7%
sub-neg20.7%
*-commutative20.7%
add-exp-log20.7%
expm1-def20.7%
log-pow35.6%
log1p-udef98.6%
Applied egg-rr98.6%
Taylor expanded in n around inf 39.8%
expm1-def74.1%
Simplified74.1%
if -0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) < +inf.0Initial program 99.6%
associate-/r/99.8%
associate-*r*99.8%
*-commutative99.8%
associate-*r/99.9%
sub-neg99.9%
distribute-lft-in99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
fma-def99.9%
metadata-eval99.9%
Simplified99.9%
fma-def99.9%
metadata-eval99.9%
metadata-eval99.9%
distribute-lft-in99.9%
sub-neg99.9%
*-commutative99.9%
add-exp-log99.9%
expm1-def99.9%
log-pow56.7%
log1p-udef56.7%
Applied egg-rr56.7%
Taylor expanded in i around inf 56.7%
associate-*r/56.7%
Simplified99.9%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 1 (/.f64 i n)) n) 1) (/.f64 i n)) Initial program 0.0%
associate-/r/1.8%
associate-*r*1.8%
*-commutative1.8%
associate-*r/1.8%
sub-neg1.8%
distribute-lft-in1.8%
metadata-eval1.8%
metadata-eval1.8%
metadata-eval1.8%
fma-def1.8%
metadata-eval1.8%
Simplified1.8%
Taylor expanded in n around inf 1.8%
associate-/l*1.8%
*-commutative1.8%
fma-neg1.8%
metadata-eval1.8%
Simplified1.8%
Taylor expanded in i around 0 99.9%
Final simplification83.3%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (/ n (/ i (expm1 i))))))
(if (<= n -1.62e-201)
t_0
(if (<= n 7e-233)
(/ 0.0 (/ i n))
(if (<= n 1.08e-94) (* n (* 100.0 (* n (/ (log (/ i n)) i)))) t_0)))))
double code(double i, double n) {
double t_0 = 100.0 * (n / (i / expm1(i)));
double tmp;
if (n <= -1.62e-201) {
tmp = t_0;
} else if (n <= 7e-233) {
tmp = 0.0 / (i / n);
} else if (n <= 1.08e-94) {
tmp = n * (100.0 * (n * (log((i / n)) / i)));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = 100.0 * (n / (i / Math.expm1(i)));
double tmp;
if (n <= -1.62e-201) {
tmp = t_0;
} else if (n <= 7e-233) {
tmp = 0.0 / (i / n);
} else if (n <= 1.08e-94) {
tmp = n * (100.0 * (n * (Math.log((i / n)) / i)));
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = 100.0 * (n / (i / math.expm1(i))) tmp = 0 if n <= -1.62e-201: tmp = t_0 elif n <= 7e-233: tmp = 0.0 / (i / n) elif n <= 1.08e-94: tmp = n * (100.0 * (n * (math.log((i / n)) / i))) else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(100.0 * Float64(n / Float64(i / expm1(i)))) tmp = 0.0 if (n <= -1.62e-201) tmp = t_0; elseif (n <= 7e-233) tmp = Float64(0.0 / Float64(i / n)); elseif (n <= 1.08e-94) tmp = Float64(n * Float64(100.0 * Float64(n * Float64(log(Float64(i / n)) / i)))); else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -1.62e-201], t$95$0, If[LessEqual[n, 7e-233], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.08e-94], N[(n * N[(100.0 * N[(n * N[(N[Log[N[(i / n), $MachinePrecision]], $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{if}\;n \leq -1.62 \cdot 10^{-201}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 7 \cdot 10^{-233}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 1.08 \cdot 10^{-94}:\\
\;\;\;\;n \cdot \left(100 \cdot \left(n \cdot \frac{\log \left(\frac{i}{n}\right)}{i}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if n < -1.61999999999999992e-201 or 1.08e-94 < n Initial program 29.1%
Taylor expanded in n around inf 37.5%
*-commutative37.5%
associate-/l*37.5%
expm1-def82.1%
Simplified82.1%
if -1.61999999999999992e-201 < n < 6.99999999999999982e-233Initial program 65.5%
associate-*r/65.5%
sub-neg65.5%
distribute-lft-in65.5%
metadata-eval65.5%
metadata-eval65.5%
Simplified65.5%
Taylor expanded in i around 0 69.8%
*-commutative69.8%
Simplified69.8%
Taylor expanded in i around 0 83.4%
if 6.99999999999999982e-233 < n < 1.08e-94Initial program 22.4%
associate-/r/22.8%
associate-*r*22.8%
*-commutative22.8%
associate-*r/22.8%
sub-neg22.8%
distribute-lft-in22.8%
metadata-eval22.8%
metadata-eval22.8%
metadata-eval22.8%
fma-def22.8%
metadata-eval22.8%
Simplified22.8%
fma-def22.8%
metadata-eval22.8%
metadata-eval22.8%
distribute-lft-in22.8%
sub-neg22.8%
*-commutative22.8%
add-exp-log22.8%
expm1-def22.8%
log-pow68.7%
log1p-udef77.3%
Applied egg-rr77.3%
Taylor expanded in n around 0 88.1%
associate-/l*88.2%
mul-1-neg88.2%
sub-neg88.2%
log-div66.2%
Simplified66.2%
clear-num66.1%
associate-/r/66.2%
clear-num66.1%
Applied egg-rr66.1%
Final simplification80.9%
(FPCore (i n)
:precision binary64
(let* ((t_0 (* 100.0 (/ n (/ i (expm1 i))))))
(if (<= n -1.45e-201)
t_0
(if (<= n 7e-233)
(/ 0.0 (/ i n))
(if (<= n 1.08e-94) (* n (* 100.0 (/ n (/ i (log (/ i n)))))) t_0)))))
double code(double i, double n) {
double t_0 = 100.0 * (n / (i / expm1(i)));
double tmp;
if (n <= -1.45e-201) {
tmp = t_0;
} else if (n <= 7e-233) {
tmp = 0.0 / (i / n);
} else if (n <= 1.08e-94) {
tmp = n * (100.0 * (n / (i / log((i / n)))));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = 100.0 * (n / (i / Math.expm1(i)));
double tmp;
if (n <= -1.45e-201) {
tmp = t_0;
} else if (n <= 7e-233) {
tmp = 0.0 / (i / n);
} else if (n <= 1.08e-94) {
tmp = n * (100.0 * (n / (i / Math.log((i / n)))));
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = 100.0 * (n / (i / math.expm1(i))) tmp = 0 if n <= -1.45e-201: tmp = t_0 elif n <= 7e-233: tmp = 0.0 / (i / n) elif n <= 1.08e-94: tmp = n * (100.0 * (n / (i / math.log((i / n))))) else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(100.0 * Float64(n / Float64(i / expm1(i)))) tmp = 0.0 if (n <= -1.45e-201) tmp = t_0; elseif (n <= 7e-233) tmp = Float64(0.0 / Float64(i / n)); elseif (n <= 1.08e-94) tmp = Float64(n * Float64(100.0 * Float64(n / Float64(i / log(Float64(i / n)))))); else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -1.45e-201], t$95$0, If[LessEqual[n, 7e-233], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.08e-94], N[(n * N[(100.0 * N[(n / N[(i / N[Log[N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{if}\;n \leq -1.45 \cdot 10^{-201}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 7 \cdot 10^{-233}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{elif}\;n \leq 1.08 \cdot 10^{-94}:\\
\;\;\;\;n \cdot \left(100 \cdot \frac{n}{\frac{i}{\log \left(\frac{i}{n}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if n < -1.4500000000000001e-201 or 1.08e-94 < n Initial program 29.1%
Taylor expanded in n around inf 37.5%
*-commutative37.5%
associate-/l*37.5%
expm1-def82.1%
Simplified82.1%
if -1.4500000000000001e-201 < n < 6.99999999999999982e-233Initial program 65.5%
associate-*r/65.5%
sub-neg65.5%
distribute-lft-in65.5%
metadata-eval65.5%
metadata-eval65.5%
Simplified65.5%
Taylor expanded in i around 0 69.8%
*-commutative69.8%
Simplified69.8%
Taylor expanded in i around 0 83.4%
if 6.99999999999999982e-233 < n < 1.08e-94Initial program 22.4%
associate-/r/22.8%
associate-*r*22.8%
*-commutative22.8%
associate-*r/22.8%
sub-neg22.8%
distribute-lft-in22.8%
metadata-eval22.8%
metadata-eval22.8%
metadata-eval22.8%
fma-def22.8%
metadata-eval22.8%
Simplified22.8%
fma-def22.8%
metadata-eval22.8%
metadata-eval22.8%
distribute-lft-in22.8%
sub-neg22.8%
*-commutative22.8%
add-exp-log22.8%
expm1-def22.8%
log-pow68.7%
log1p-udef77.3%
Applied egg-rr77.3%
Taylor expanded in n around 0 88.1%
associate-/l*88.2%
mul-1-neg88.2%
sub-neg88.2%
log-div66.2%
Simplified66.2%
Final simplification80.9%
(FPCore (i n) :precision binary64 (if (or (<= n -1.2e-201) (not (<= n 8.6e-95))) (* n (* 100.0 (/ (expm1 i) i))) (/ 0.0 (/ i n))))
double code(double i, double n) {
double tmp;
if ((n <= -1.2e-201) || !(n <= 8.6e-95)) {
tmp = n * (100.0 * (expm1(i) / i));
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -1.2e-201) || !(n <= 8.6e-95)) {
tmp = n * (100.0 * (Math.expm1(i) / i));
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.2e-201) or not (n <= 8.6e-95): tmp = n * (100.0 * (math.expm1(i) / i)) else: tmp = 0.0 / (i / n) return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.2e-201) || !(n <= 8.6e-95)) tmp = Float64(n * Float64(100.0 * Float64(expm1(i) / i))); else tmp = Float64(0.0 / Float64(i / n)); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -1.2e-201], N[Not[LessEqual[n, 8.6e-95]], $MachinePrecision]], N[(n * N[(100.0 * N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.2 \cdot 10^{-201} \lor \neg \left(n \leq 8.6 \cdot 10^{-95}\right):\\
\;\;\;\;n \cdot \left(100 \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -1.20000000000000004e-201 or 8.59999999999999994e-95 < n Initial program 29.1%
associate-/r/29.5%
associate-*r*29.5%
*-commutative29.5%
associate-*r/29.5%
sub-neg29.5%
distribute-lft-in29.4%
metadata-eval29.4%
metadata-eval29.4%
metadata-eval29.4%
fma-def29.5%
metadata-eval29.5%
Simplified29.5%
fma-def29.4%
metadata-eval29.4%
metadata-eval29.4%
distribute-lft-in29.5%
sub-neg29.5%
*-commutative29.5%
add-exp-log29.5%
expm1-def29.5%
log-pow26.7%
log1p-udef73.5%
Applied egg-rr73.5%
Taylor expanded in n around inf 37.5%
expm1-def82.1%
Simplified82.1%
if -1.20000000000000004e-201 < n < 8.59999999999999994e-95Initial program 46.6%
associate-*r/46.6%
sub-neg46.6%
distribute-lft-in46.6%
metadata-eval46.6%
metadata-eval46.6%
Simplified46.6%
Taylor expanded in i around 0 49.0%
*-commutative49.0%
Simplified49.0%
Taylor expanded in i around 0 66.6%
Final simplification79.0%
(FPCore (i n) :precision binary64 (if (or (<= n -1.1e-201) (not (<= n 8.6e-95))) (* 100.0 (/ n (/ i (expm1 i)))) (/ 0.0 (/ i n))))
double code(double i, double n) {
double tmp;
if ((n <= -1.1e-201) || !(n <= 8.6e-95)) {
tmp = 100.0 * (n / (i / expm1(i)));
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -1.1e-201) || !(n <= 8.6e-95)) {
tmp = 100.0 * (n / (i / Math.expm1(i)));
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.1e-201) or not (n <= 8.6e-95): tmp = 100.0 * (n / (i / math.expm1(i))) else: tmp = 0.0 / (i / n) return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.1e-201) || !(n <= 8.6e-95)) tmp = Float64(100.0 * Float64(n / Float64(i / expm1(i)))); else tmp = Float64(0.0 / Float64(i / n)); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -1.1e-201], N[Not[LessEqual[n, 8.6e-95]], $MachinePrecision]], N[(100.0 * N[(n / N[(i / N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.1 \cdot 10^{-201} \lor \neg \left(n \leq 8.6 \cdot 10^{-95}\right):\\
\;\;\;\;100 \cdot \frac{n}{\frac{i}{\mathsf{expm1}\left(i\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -1.1e-201 or 8.59999999999999994e-95 < n Initial program 29.1%
Taylor expanded in n around inf 37.5%
*-commutative37.5%
associate-/l*37.5%
expm1-def82.1%
Simplified82.1%
if -1.1e-201 < n < 8.59999999999999994e-95Initial program 46.6%
associate-*r/46.6%
sub-neg46.6%
distribute-lft-in46.6%
metadata-eval46.6%
metadata-eval46.6%
Simplified46.6%
Taylor expanded in i around 0 49.0%
*-commutative49.0%
Simplified49.0%
Taylor expanded in i around 0 66.6%
Final simplification79.1%
(FPCore (i n) :precision binary64 (if (or (<= i -5e+50) (not (<= i 2e-18))) (* 100.0 (/ i (/ i n))) (* n 100.0)))
double code(double i, double n) {
double tmp;
if ((i <= -5e+50) || !(i <= 2e-18)) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = n * 100.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if ((i <= (-5d+50)) .or. (.not. (i <= 2d-18))) then
tmp = 100.0d0 * (i / (i / n))
else
tmp = n * 100.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((i <= -5e+50) || !(i <= 2e-18)) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): tmp = 0 if (i <= -5e+50) or not (i <= 2e-18): tmp = 100.0 * (i / (i / n)) else: tmp = n * 100.0 return tmp
function code(i, n) tmp = 0.0 if ((i <= -5e+50) || !(i <= 2e-18)) tmp = Float64(100.0 * Float64(i / Float64(i / n))); else tmp = Float64(n * 100.0); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((i <= -5e+50) || ~((i <= 2e-18))) tmp = 100.0 * (i / (i / n)); else tmp = n * 100.0; end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[i, -5e+50], N[Not[LessEqual[i, 2e-18]], $MachinePrecision]], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -5 \cdot 10^{+50} \lor \neg \left(i \leq 2 \cdot 10^{-18}\right):\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if i < -5e50 or 2.0000000000000001e-18 < i Initial program 58.0%
Taylor expanded in i around 0 21.7%
if -5e50 < i < 2.0000000000000001e-18Initial program 9.4%
Taylor expanded in i around 0 75.8%
*-commutative75.8%
Simplified75.8%
Final simplification50.0%
(FPCore (i n) :precision binary64 (if (or (<= n -19500000.0) (not (<= n 2.7e-22))) (* n (+ 100.0 (* i 50.0))) (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -19500000.0) || !(n <= 2.7e-22)) {
tmp = n * (100.0 + (i * 50.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 ((n <= (-19500000.0d0)) .or. (.not. (n <= 2.7d-22))) then
tmp = n * (100.0d0 + (i * 50.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 ((n <= -19500000.0) || !(n <= 2.7e-22)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -19500000.0) or not (n <= 2.7e-22): tmp = n * (100.0 + (i * 50.0)) else: tmp = 100.0 * (i / (i / n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -19500000.0) || !(n <= 2.7e-22)) tmp = Float64(n * Float64(100.0 + Float64(i * 50.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 ((n <= -19500000.0) || ~((n <= 2.7e-22))) tmp = n * (100.0 + (i * 50.0)); else tmp = 100.0 * (i / (i / n)); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -19500000.0], N[Not[LessEqual[n, 2.7e-22]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -19500000 \lor \neg \left(n \leq 2.7 \cdot 10^{-22}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -1.95e7 or 2.7000000000000002e-22 < n Initial program 29.3%
associate-/r/29.8%
associate-*r*29.8%
*-commutative29.8%
associate-*r/29.8%
sub-neg29.8%
distribute-lft-in29.8%
metadata-eval29.8%
metadata-eval29.8%
metadata-eval29.8%
fma-def29.8%
metadata-eval29.8%
Simplified29.8%
Taylor expanded in n around inf 44.5%
Taylor expanded in i around 0 58.9%
*-commutative58.9%
Simplified58.9%
if -1.95e7 < n < 2.7000000000000002e-22Initial program 37.8%
Taylor expanded in i around 0 52.7%
Final simplification56.5%
(FPCore (i n) :precision binary64 (if (<= n -3.1e-201) (/ n (+ 0.01 (* i -0.005))) (if (<= n 8.6e-95) (/ 0.0 (/ i n)) (* n (+ 100.0 (* i 50.0))))))
double code(double i, double n) {
double tmp;
if (n <= -3.1e-201) {
tmp = n / (0.01 + (i * -0.005));
} else if (n <= 8.6e-95) {
tmp = 0.0 / (i / n);
} 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 <= (-3.1d-201)) then
tmp = n / (0.01d0 + (i * (-0.005d0)))
else if (n <= 8.6d-95) then
tmp = 0.0d0 / (i / n)
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 <= -3.1e-201) {
tmp = n / (0.01 + (i * -0.005));
} else if (n <= 8.6e-95) {
tmp = 0.0 / (i / n);
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -3.1e-201: tmp = n / (0.01 + (i * -0.005)) elif n <= 8.6e-95: tmp = 0.0 / (i / n) else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= -3.1e-201) tmp = Float64(n / Float64(0.01 + Float64(i * -0.005))); elseif (n <= 8.6e-95) tmp = Float64(0.0 / Float64(i / n)); 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 <= -3.1e-201) tmp = n / (0.01 + (i * -0.005)); elseif (n <= 8.6e-95) tmp = 0.0 / (i / n); else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -3.1e-201], N[(n / N[(0.01 + N[(i * -0.005), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 8.6e-95], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.1 \cdot 10^{-201}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\
\mathbf{elif}\;n \leq 8.6 \cdot 10^{-95}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -3.0999999999999999e-201Initial program 31.9%
associate-/r/32.2%
associate-*r*32.2%
*-commutative32.2%
associate-*r/32.2%
sub-neg32.2%
distribute-lft-in32.1%
metadata-eval32.1%
metadata-eval32.1%
metadata-eval32.1%
fma-def32.2%
metadata-eval32.2%
Simplified32.2%
Taylor expanded in n around inf 33.1%
associate-/l*33.8%
*-commutative33.8%
fma-neg33.9%
metadata-eval33.9%
Simplified33.9%
Taylor expanded in i around 0 53.3%
*-commutative53.3%
Simplified53.3%
if -3.0999999999999999e-201 < n < 8.59999999999999994e-95Initial program 46.6%
associate-*r/46.6%
sub-neg46.6%
distribute-lft-in46.6%
metadata-eval46.6%
metadata-eval46.6%
Simplified46.6%
Taylor expanded in i around 0 49.0%
*-commutative49.0%
Simplified49.0%
Taylor expanded in i around 0 66.6%
if 8.59999999999999994e-95 < n Initial program 25.9%
associate-/r/26.3%
associate-*r*26.3%
*-commutative26.3%
associate-*r/26.3%
sub-neg26.3%
distribute-lft-in26.3%
metadata-eval26.3%
metadata-eval26.3%
metadata-eval26.3%
fma-def26.3%
metadata-eval26.3%
Simplified26.3%
Taylor expanded in n around inf 41.9%
Taylor expanded in i around 0 68.8%
*-commutative68.8%
Simplified68.8%
Final simplification61.6%
(FPCore (i n) :precision binary64 (if (<= n 4.9e-40) (/ n (+ 0.01 (* i -0.005))) (* n (+ 100.0 (* i 50.0)))))
double code(double i, double n) {
double tmp;
if (n <= 4.9e-40) {
tmp = n / (0.01 + (i * -0.005));
} 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 <= 4.9d-40) then
tmp = n / (0.01d0 + (i * (-0.005d0)))
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 <= 4.9e-40) {
tmp = n / (0.01 + (i * -0.005));
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= 4.9e-40: tmp = n / (0.01 + (i * -0.005)) else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= 4.9e-40) tmp = Float64(n / Float64(0.01 + Float64(i * -0.005))); 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 <= 4.9e-40) tmp = n / (0.01 + (i * -0.005)); else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, 4.9e-40], N[(n / N[(0.01 + N[(i * -0.005), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(i * 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 4.9 \cdot 10^{-40}:\\
\;\;\;\;\frac{n}{0.01 + i \cdot -0.005}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < 4.8999999999999997e-40Initial program 36.1%
associate-/r/35.9%
associate-*r*35.8%
*-commutative35.8%
associate-*r/35.9%
sub-neg35.9%
distribute-lft-in35.8%
metadata-eval35.8%
metadata-eval35.8%
metadata-eval35.8%
fma-def35.9%
metadata-eval35.9%
Simplified35.9%
Taylor expanded in n around inf 31.6%
associate-/l*32.1%
*-commutative32.1%
fma-neg32.1%
metadata-eval32.1%
Simplified32.1%
Taylor expanded in i around 0 51.6%
*-commutative51.6%
Simplified51.6%
if 4.8999999999999997e-40 < n Initial program 25.9%
associate-/r/26.4%
associate-*r*26.4%
*-commutative26.4%
associate-*r/26.4%
sub-neg26.4%
distribute-lft-in26.4%
metadata-eval26.4%
metadata-eval26.4%
metadata-eval26.4%
fma-def26.4%
metadata-eval26.4%
Simplified26.4%
Taylor expanded in n around inf 44.1%
Taylor expanded in i around 0 69.2%
*-commutative69.2%
Simplified69.2%
Final simplification57.8%
(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.5%
Taylor expanded in i around 0 48.2%
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.5%
Taylor expanded in i around 0 42.3%
*-commutative42.3%
Simplified42.3%
Final simplification42.3%
(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 2023333
(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))))