
(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 15 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 (+ 1.0 (/ i n))) (t_1 (pow t_0 n)) (t_2 (/ (+ t_1 -1.0) (/ i n))))
(if (<= t_2 (- INFINITY))
(* 100.0 (/ (+ (pow (/ i n) n) -1.0) (/ i n)))
(if (<= t_2 0.0)
(* n (/ (* 100.0 (expm1 (* n (log1p (/ i n))))) i))
(if (<= t_2 INFINITY)
(/ (+ (* t_1 100.0) -100.0) (+ t_0 -1.0))
(* n 100.0))))))
double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double t_1 = pow(t_0, n);
double t_2 = (t_1 + -1.0) / (i / n);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = 100.0 * ((pow((i / n), n) + -1.0) / (i / n));
} else if (t_2 <= 0.0) {
tmp = n * ((100.0 * expm1((n * log1p((i / n))))) / i);
} else if (t_2 <= ((double) INFINITY)) {
tmp = ((t_1 * 100.0) + -100.0) / (t_0 + -1.0);
} else {
tmp = n * 100.0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double t_1 = Math.pow(t_0, n);
double t_2 = (t_1 + -1.0) / (i / n);
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = 100.0 * ((Math.pow((i / n), n) + -1.0) / (i / n));
} else if (t_2 <= 0.0) {
tmp = n * ((100.0 * Math.expm1((n * Math.log1p((i / n))))) / i);
} else if (t_2 <= Double.POSITIVE_INFINITY) {
tmp = ((t_1 * 100.0) + -100.0) / (t_0 + -1.0);
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): t_0 = 1.0 + (i / n) t_1 = math.pow(t_0, n) t_2 = (t_1 + -1.0) / (i / n) tmp = 0 if t_2 <= -math.inf: tmp = 100.0 * ((math.pow((i / n), n) + -1.0) / (i / n)) elif t_2 <= 0.0: tmp = n * ((100.0 * math.expm1((n * math.log1p((i / n))))) / i) elif t_2 <= math.inf: tmp = ((t_1 * 100.0) + -100.0) / (t_0 + -1.0) else: tmp = n * 100.0 return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) t_1 = t_0 ^ n t_2 = Float64(Float64(t_1 + -1.0) / Float64(i / n)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(100.0 * Float64(Float64((Float64(i / n) ^ n) + -1.0) / Float64(i / n))); elseif (t_2 <= 0.0) tmp = Float64(n * Float64(Float64(100.0 * expm1(Float64(n * log1p(Float64(i / n))))) / i)); elseif (t_2 <= Inf) tmp = Float64(Float64(Float64(t_1 * 100.0) + -100.0) / Float64(t_0 + -1.0)); else tmp = Float64(n * 100.0); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, n], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(100.0 * N[(N[(N[Power[N[(i / n), $MachinePrecision], n], $MachinePrecision] + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(n * N[(N[(100.0 * N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(N[(N[(t$95$1 * 100.0), $MachinePrecision] + -100.0), $MachinePrecision] / N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{i}{n}\\
t_1 := {t\_0}^{n}\\
t_2 := \frac{t\_1 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;100 \cdot \frac{{\left(\frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}}\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\frac{t\_1 \cdot 100 + -100}{t\_0 + -1}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < -inf.0Initial program 100.0%
Taylor expanded in i around inf 100.0%
if -inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < 0.0Initial program 27.3%
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-define27.0%
metadata-eval27.0%
Simplified27.0%
fma-undefine27.0%
metadata-eval27.0%
metadata-eval27.0%
distribute-lft-in27.0%
sub-neg27.0%
*-commutative27.0%
add-exp-log27.0%
expm1-define27.0%
log-pow37.1%
log1p-define98.2%
Applied egg-rr98.2%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < +inf.0Initial program 94.2%
associate-*r/94.3%
sub-neg94.3%
distribute-rgt-in94.2%
metadata-eval94.2%
metadata-eval94.2%
Simplified94.2%
expm1-log1p-u55.1%
log1p-define55.3%
expm1-undefine55.3%
add-exp-log94.4%
Applied egg-rr94.4%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.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-define1.8%
metadata-eval1.8%
Simplified1.8%
Taylor expanded in i around 0 71.6%
*-commutative71.6%
Simplified71.6%
Final simplification93.1%
(FPCore (i n)
:precision binary64
(let* ((t_0 (+ 1.0 (/ i n))) (t_1 (pow t_0 n)) (t_2 (/ (+ t_1 -1.0) (/ i n))))
(if (<= t_2 (- INFINITY))
(* 100.0 (/ (+ (pow (/ i n) n) -1.0) (/ i n)))
(if (<= t_2 0.0)
(* n (* (expm1 (* n (log1p (/ i n)))) (/ 100.0 i)))
(if (<= t_2 INFINITY)
(/ (+ (* t_1 100.0) -100.0) (+ t_0 -1.0))
(* n 100.0))))))
double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double t_1 = pow(t_0, n);
double t_2 = (t_1 + -1.0) / (i / n);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = 100.0 * ((pow((i / n), n) + -1.0) / (i / n));
} else if (t_2 <= 0.0) {
tmp = n * (expm1((n * log1p((i / n)))) * (100.0 / i));
} else if (t_2 <= ((double) INFINITY)) {
tmp = ((t_1 * 100.0) + -100.0) / (t_0 + -1.0);
} else {
tmp = n * 100.0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = 1.0 + (i / n);
double t_1 = Math.pow(t_0, n);
double t_2 = (t_1 + -1.0) / (i / n);
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = 100.0 * ((Math.pow((i / n), n) + -1.0) / (i / n));
} else if (t_2 <= 0.0) {
tmp = n * (Math.expm1((n * Math.log1p((i / n)))) * (100.0 / i));
} else if (t_2 <= Double.POSITIVE_INFINITY) {
tmp = ((t_1 * 100.0) + -100.0) / (t_0 + -1.0);
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): t_0 = 1.0 + (i / n) t_1 = math.pow(t_0, n) t_2 = (t_1 + -1.0) / (i / n) tmp = 0 if t_2 <= -math.inf: tmp = 100.0 * ((math.pow((i / n), n) + -1.0) / (i / n)) elif t_2 <= 0.0: tmp = n * (math.expm1((n * math.log1p((i / n)))) * (100.0 / i)) elif t_2 <= math.inf: tmp = ((t_1 * 100.0) + -100.0) / (t_0 + -1.0) else: tmp = n * 100.0 return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) t_1 = t_0 ^ n t_2 = Float64(Float64(t_1 + -1.0) / Float64(i / n)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(100.0 * Float64(Float64((Float64(i / n) ^ n) + -1.0) / Float64(i / n))); elseif (t_2 <= 0.0) tmp = Float64(n * Float64(expm1(Float64(n * log1p(Float64(i / n)))) * Float64(100.0 / i))); elseif (t_2 <= Inf) tmp = Float64(Float64(Float64(t_1 * 100.0) + -100.0) / Float64(t_0 + -1.0)); else tmp = Float64(n * 100.0); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, n], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(100.0 * N[(N[(N[Power[N[(i / n), $MachinePrecision], n], $MachinePrecision] + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(n * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] * N[(100.0 / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(N[(N[(t$95$1 * 100.0), $MachinePrecision] + -100.0), $MachinePrecision] / N[(t$95$0 + -1.0), $MachinePrecision]), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{i}{n}\\
t_1 := {t\_0}^{n}\\
t_2 := \frac{t\_1 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;100 \cdot \frac{{\left(\frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}}\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;n \cdot \left(\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right) \cdot \frac{100}{i}\right)\\
\mathbf{elif}\;t\_2 \leq \infty:\\
\;\;\;\;\frac{t\_1 \cdot 100 + -100}{t\_0 + -1}\\
\mathbf{else}:\\
\;\;\;\;n \cdot 100\\
\end{array}
\end{array}
if (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < -inf.0Initial program 100.0%
Taylor expanded in i around inf 100.0%
if -inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < 0.0Initial program 27.3%
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-define27.0%
metadata-eval27.0%
Simplified27.0%
fma-undefine27.0%
metadata-eval27.0%
metadata-eval27.0%
distribute-lft-in27.0%
sub-neg27.0%
*-commutative27.0%
add-exp-log27.0%
expm1-define27.0%
log-pow37.1%
log1p-define98.2%
Applied egg-rr98.2%
associate-*r/87.3%
Applied egg-rr87.3%
associate-/l*98.2%
associate-*r/97.8%
Simplified97.8%
if 0.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < +inf.0Initial program 94.2%
associate-*r/94.3%
sub-neg94.3%
distribute-rgt-in94.2%
metadata-eval94.2%
metadata-eval94.2%
Simplified94.2%
expm1-log1p-u55.1%
log1p-define55.3%
expm1-undefine55.3%
add-exp-log94.4%
Applied egg-rr94.4%
if +inf.0 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.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-define1.8%
metadata-eval1.8%
Simplified1.8%
Taylor expanded in i around 0 71.6%
*-commutative71.6%
Simplified71.6%
Final simplification92.8%
(FPCore (i n) :precision binary64 (if (or (<= n -6.4e-173) (not (<= n 6.5e-135))) (* n (* 100.0 (/ (expm1 i) i))) (/ 0.0 (/ i n))))
double code(double i, double n) {
double tmp;
if ((n <= -6.4e-173) || !(n <= 6.5e-135)) {
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 <= -6.4e-173) || !(n <= 6.5e-135)) {
tmp = n * (100.0 * (Math.expm1(i) / i));
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -6.4e-173) or not (n <= 6.5e-135): 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 <= -6.4e-173) || !(n <= 6.5e-135)) 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, -6.4e-173], N[Not[LessEqual[n, 6.5e-135]], $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 -6.4 \cdot 10^{-173} \lor \neg \left(n \leq 6.5 \cdot 10^{-135}\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 < -6.4e-173 or 6.50000000000000056e-135 < n Initial program 27.2%
associate-/r/27.2%
associate-*r*27.2%
*-commutative27.2%
associate-*r/27.2%
sub-neg27.2%
distribute-lft-in27.2%
metadata-eval27.2%
metadata-eval27.2%
metadata-eval27.2%
fma-define27.2%
metadata-eval27.2%
Simplified27.2%
Taylor expanded in n around inf 33.0%
associate-/l*34.0%
sub-neg34.0%
metadata-eval34.0%
metadata-eval34.0%
distribute-lft-in33.9%
metadata-eval33.9%
sub-neg33.9%
associate-*r/33.9%
*-commutative33.9%
expm1-define82.5%
Simplified82.5%
if -6.4e-173 < n < 6.50000000000000056e-135Initial program 51.8%
associate-*r/51.8%
sub-neg51.8%
distribute-rgt-in51.8%
metadata-eval51.8%
metadata-eval51.8%
Simplified51.8%
Taylor expanded in i around 0 77.4%
Final simplification81.6%
(FPCore (i n)
:precision binary64
(if (<= n -2.9e-167)
(+
(* n 100.0)
(*
i
(-
(+
(* n 50.0)
(*
i
(-
(+ (* n 16.666666666666668) (* 33.333333333333336 (/ 1.0 n)))
50.0)))
50.0)))
(if (<= n 3.4e-131)
(/ 0.0 (/ i n))
(*
n
(+
100.0
(* i (+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667))))))))))
double code(double i, double n) {
double tmp;
if (n <= -2.9e-167) {
tmp = (n * 100.0) + (i * (((n * 50.0) + (i * (((n * 16.666666666666668) + (33.333333333333336 * (1.0 / n))) - 50.0))) - 50.0));
} else if (n <= 3.4e-131) {
tmp = 0.0 / (i / n);
} else {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-2.9d-167)) then
tmp = (n * 100.0d0) + (i * (((n * 50.0d0) + (i * (((n * 16.666666666666668d0) + (33.333333333333336d0 * (1.0d0 / n))) - 50.0d0))) - 50.0d0))
else if (n <= 3.4d-131) then
tmp = 0.0d0 / (i / n)
else
tmp = n * (100.0d0 + (i * (50.0d0 + (i * (16.666666666666668d0 + (i * 4.166666666666667d0))))))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -2.9e-167) {
tmp = (n * 100.0) + (i * (((n * 50.0) + (i * (((n * 16.666666666666668) + (33.333333333333336 * (1.0 / n))) - 50.0))) - 50.0));
} else if (n <= 3.4e-131) {
tmp = 0.0 / (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 n <= -2.9e-167: tmp = (n * 100.0) + (i * (((n * 50.0) + (i * (((n * 16.666666666666668) + (33.333333333333336 * (1.0 / n))) - 50.0))) - 50.0)) elif n <= 3.4e-131: tmp = 0.0 / (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 (n <= -2.9e-167) tmp = Float64(Float64(n * 100.0) + Float64(i * Float64(Float64(Float64(n * 50.0) + Float64(i * Float64(Float64(Float64(n * 16.666666666666668) + Float64(33.333333333333336 * Float64(1.0 / n))) - 50.0))) - 50.0))); elseif (n <= 3.4e-131) tmp = Float64(0.0 / 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
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -2.9e-167) tmp = (n * 100.0) + (i * (((n * 50.0) + (i * (((n * 16.666666666666668) + (33.333333333333336 * (1.0 / n))) - 50.0))) - 50.0)); elseif (n <= 3.4e-131) tmp = 0.0 / (i / n); else tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -2.9e-167], N[(N[(n * 100.0), $MachinePrecision] + N[(i * N[(N[(N[(n * 50.0), $MachinePrecision] + N[(i * N[(N[(N[(n * 16.666666666666668), $MachinePrecision] + N[(33.333333333333336 * N[(1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 50.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.4e-131], N[(0.0 / N[(i / n), $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}\;n \leq -2.9 \cdot 10^{-167}:\\
\;\;\;\;n \cdot 100 + i \cdot \left(\left(n \cdot 50 + i \cdot \left(\left(n \cdot 16.666666666666668 + 33.333333333333336 \cdot \frac{1}{n}\right) - 50\right)\right) - 50\right)\\
\mathbf{elif}\;n \leq 3.4 \cdot 10^{-131}:\\
\;\;\;\;\frac{0}{\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 n < -2.90000000000000003e-167Initial program 31.1%
associate-/r/30.9%
associate-*r*30.8%
*-commutative30.8%
associate-*r/30.9%
sub-neg30.9%
distribute-lft-in30.8%
metadata-eval30.8%
metadata-eval30.8%
metadata-eval30.8%
fma-define30.9%
metadata-eval30.9%
Simplified30.9%
Taylor expanded in i around 0 56.8%
Taylor expanded in n around 0 38.5%
Taylor expanded in i around 0 58.6%
if -2.90000000000000003e-167 < n < 3.39999999999999995e-131Initial program 51.8%
associate-*r/51.8%
sub-neg51.8%
distribute-rgt-in51.8%
metadata-eval51.8%
metadata-eval51.8%
Simplified51.8%
Taylor expanded in i around 0 77.4%
if 3.39999999999999995e-131 < n Initial program 23.1%
associate-/r/23.3%
associate-*r*23.4%
*-commutative23.4%
associate-*r/23.3%
sub-neg23.3%
distribute-lft-in23.3%
metadata-eval23.3%
metadata-eval23.3%
metadata-eval23.3%
fma-define23.3%
metadata-eval23.3%
Simplified23.3%
fma-undefine23.3%
metadata-eval23.3%
metadata-eval23.3%
distribute-lft-in23.3%
sub-neg23.3%
*-commutative23.3%
add-exp-log23.3%
expm1-define23.3%
log-pow26.2%
log1p-define79.1%
Applied egg-rr79.1%
Taylor expanded in n around inf 35.3%
expm1-define83.9%
Simplified83.9%
Taylor expanded in i around 0 74.1%
*-commutative74.1%
Simplified74.1%
Final simplification68.1%
(FPCore (i n)
:precision binary64
(if (<= n -2.25e-166)
(* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668)))))
(if (<= n 7e-136)
(/ 0.0 (/ i n))
(*
n
(+
100.0
(* i (+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667))))))))))
double code(double i, double n) {
double tmp;
if (n <= -2.25e-166) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= 7e-136) {
tmp = 0.0 / (i / n);
} else {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-2.25d-166)) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
else if (n <= 7d-136) then
tmp = 0.0d0 / (i / n)
else
tmp = n * (100.0d0 + (i * (50.0d0 + (i * (16.666666666666668d0 + (i * 4.166666666666667d0))))))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -2.25e-166) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else if (n <= 7e-136) {
tmp = 0.0 / (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 n <= -2.25e-166: tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) elif n <= 7e-136: tmp = 0.0 / (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 (n <= -2.25e-166) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); elseif (n <= 7e-136) tmp = Float64(0.0 / 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
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -2.25e-166) tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); elseif (n <= 7e-136) tmp = 0.0 / (i / n); else tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -2.25e-166], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 7e-136], N[(0.0 / N[(i / n), $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}\;n \leq -2.25 \cdot 10^{-166}:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{elif}\;n \leq 7 \cdot 10^{-136}:\\
\;\;\;\;\frac{0}{\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 n < -2.2499999999999999e-166Initial program 31.1%
associate-/r/30.9%
associate-*r*30.8%
*-commutative30.8%
associate-*r/30.9%
sub-neg30.9%
distribute-lft-in30.8%
metadata-eval30.8%
metadata-eval30.8%
metadata-eval30.8%
fma-define30.9%
metadata-eval30.9%
Simplified30.9%
Taylor expanded in i around 0 56.8%
Taylor expanded in n around inf 58.1%
*-commutative58.1%
Simplified58.1%
if -2.2499999999999999e-166 < n < 7.00000000000000058e-136Initial program 51.8%
associate-*r/51.8%
sub-neg51.8%
distribute-rgt-in51.8%
metadata-eval51.8%
metadata-eval51.8%
Simplified51.8%
Taylor expanded in i around 0 77.4%
if 7.00000000000000058e-136 < n Initial program 23.1%
associate-/r/23.3%
associate-*r*23.4%
*-commutative23.4%
associate-*r/23.3%
sub-neg23.3%
distribute-lft-in23.3%
metadata-eval23.3%
metadata-eval23.3%
metadata-eval23.3%
fma-define23.3%
metadata-eval23.3%
Simplified23.3%
fma-undefine23.3%
metadata-eval23.3%
metadata-eval23.3%
distribute-lft-in23.3%
sub-neg23.3%
*-commutative23.3%
add-exp-log23.3%
expm1-define23.3%
log-pow26.2%
log1p-define79.1%
Applied egg-rr79.1%
Taylor expanded in n around inf 35.3%
expm1-define83.9%
Simplified83.9%
Taylor expanded in i around 0 74.1%
*-commutative74.1%
Simplified74.1%
Final simplification67.9%
(FPCore (i n) :precision binary64 (if (or (<= n -3.5e-162) (not (<= n 5.1e-133))) (* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668))))) (/ 0.0 (/ i n))))
double code(double i, double n) {
double tmp;
if ((n <= -3.5e-162) || !(n <= 5.1e-133)) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else {
tmp = 0.0 / (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 <= (-3.5d-162)) .or. (.not. (n <= 5.1d-133))) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
else
tmp = 0.0d0 / (i / n)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if ((n <= -3.5e-162) || !(n <= 5.1e-133)) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -3.5e-162) or not (n <= 5.1e-133): tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) else: tmp = 0.0 / (i / n) return tmp
function code(i, n) tmp = 0.0 if ((n <= -3.5e-162) || !(n <= 5.1e-133)) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); else tmp = Float64(0.0 / Float64(i / n)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if ((n <= -3.5e-162) || ~((n <= 5.1e-133))) tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); else tmp = 0.0 / (i / n); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -3.5e-162], N[Not[LessEqual[n, 5.1e-133]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.5 \cdot 10^{-162} \lor \neg \left(n \leq 5.1 \cdot 10^{-133}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -3.4999999999999999e-162 or 5.0999999999999999e-133 < n Initial program 27.2%
associate-/r/27.2%
associate-*r*27.2%
*-commutative27.2%
associate-*r/27.2%
sub-neg27.2%
distribute-lft-in27.2%
metadata-eval27.2%
metadata-eval27.2%
metadata-eval27.2%
fma-define27.2%
metadata-eval27.2%
Simplified27.2%
Taylor expanded in i around 0 63.4%
Taylor expanded in n around inf 64.1%
*-commutative64.1%
Simplified64.1%
if -3.4999999999999999e-162 < n < 5.0999999999999999e-133Initial program 51.8%
associate-*r/51.8%
sub-neg51.8%
distribute-rgt-in51.8%
metadata-eval51.8%
metadata-eval51.8%
Simplified51.8%
Taylor expanded in i around 0 77.4%
Final simplification66.6%
(FPCore (i n) :precision binary64 (if (or (<= n -780.0) (not (<= n 4.3e-48))) (* n (+ 100.0 (* i 50.0))) (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -780.0) || !(n <= 4.3e-48)) {
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 <= (-780.0d0)) .or. (.not. (n <= 4.3d-48))) 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 <= -780.0) || !(n <= 4.3e-48)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -780.0) or not (n <= 4.3e-48): 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 <= -780.0) || !(n <= 4.3e-48)) 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 <= -780.0) || ~((n <= 4.3e-48))) 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, -780.0], N[Not[LessEqual[n, 4.3e-48]], $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 -780 \lor \neg \left(n \leq 4.3 \cdot 10^{-48}\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -780 or 4.3e-48 < n Initial program 28.8%
associate-/r/29.1%
associate-*r*29.1%
*-commutative29.1%
associate-*r/29.2%
sub-neg29.2%
distribute-lft-in29.1%
metadata-eval29.1%
metadata-eval29.1%
metadata-eval29.1%
fma-define29.2%
metadata-eval29.2%
Simplified29.2%
fma-undefine29.1%
metadata-eval29.1%
metadata-eval29.1%
distribute-lft-in29.2%
sub-neg29.2%
*-commutative29.2%
add-exp-log29.2%
expm1-define29.2%
log-pow20.1%
log1p-define69.7%
Applied egg-rr69.7%
Taylor expanded in n around inf 40.7%
expm1-define89.6%
Simplified89.6%
Taylor expanded in i around 0 64.2%
*-commutative64.2%
Simplified64.2%
if -780 < n < 4.3e-48Initial program 36.8%
Taylor expanded in i around 0 59.9%
Final simplification62.6%
(FPCore (i n) :precision binary64 (if (or (<= n -900.0) (not (<= n 10.0))) (* 100.0 (/ (* i n) i)) (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -900.0) || !(n <= 10.0)) {
tmp = 100.0 * ((i * n) / i);
} 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 <= (-900.0d0)) .or. (.not. (n <= 10.0d0))) then
tmp = 100.0d0 * ((i * n) / i)
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 <= -900.0) || !(n <= 10.0)) {
tmp = 100.0 * ((i * n) / i);
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -900.0) or not (n <= 10.0): tmp = 100.0 * ((i * n) / i) else: tmp = 100.0 * (i / (i / n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -900.0) || !(n <= 10.0)) tmp = Float64(100.0 * Float64(Float64(i * n) / i)); 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 <= -900.0) || ~((n <= 10.0))) tmp = 100.0 * ((i * n) / i); else tmp = 100.0 * (i / (i / n)); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -900.0], N[Not[LessEqual[n, 10.0]], $MachinePrecision]], N[(100.0 * N[(N[(i * n), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -900 \lor \neg \left(n \leq 10\right):\\
\;\;\;\;100 \cdot \frac{i \cdot n}{i}\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -900 or 10 < n Initial program 29.6%
Taylor expanded in i around 0 30.6%
div-inv29.4%
clear-num29.5%
Applied egg-rr29.5%
associate-*r/61.6%
*-commutative61.6%
Simplified61.6%
if -900 < n < 10Initial program 34.9%
Taylor expanded in i around 0 62.0%
Final simplification61.8%
(FPCore (i n) :precision binary64 (if (<= n -1.15e-171) (* 100.0 (+ n (* 0.5 (* i n)))) (if (<= n 1.45e-134) (/ 0.0 (/ i n)) (* n (+ 100.0 (* i 50.0))))))
double code(double i, double n) {
double tmp;
if (n <= -1.15e-171) {
tmp = 100.0 * (n + (0.5 * (i * n)));
} else if (n <= 1.45e-134) {
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 <= (-1.15d-171)) then
tmp = 100.0d0 * (n + (0.5d0 * (i * n)))
else if (n <= 1.45d-134) 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 <= -1.15e-171) {
tmp = 100.0 * (n + (0.5 * (i * n)));
} else if (n <= 1.45e-134) {
tmp = 0.0 / (i / n);
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -1.15e-171: tmp = 100.0 * (n + (0.5 * (i * n))) elif n <= 1.45e-134: tmp = 0.0 / (i / n) else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= -1.15e-171) tmp = Float64(100.0 * Float64(n + Float64(0.5 * Float64(i * n)))); elseif (n <= 1.45e-134) 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 <= -1.15e-171) tmp = 100.0 * (n + (0.5 * (i * n))); elseif (n <= 1.45e-134) tmp = 0.0 / (i / n); else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -1.15e-171], N[(100.0 * N[(n + N[(0.5 * N[(i * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.45e-134], 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 -1.15 \cdot 10^{-171}:\\
\;\;\;\;100 \cdot \left(n + 0.5 \cdot \left(i \cdot n\right)\right)\\
\mathbf{elif}\;n \leq 1.45 \cdot 10^{-134}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -1.14999999999999989e-171Initial program 31.1%
Taylor expanded in i around 0 39.0%
associate-*r/39.0%
metadata-eval39.0%
Simplified39.0%
clear-num38.0%
inv-pow38.0%
Applied egg-rr38.0%
unpow-138.0%
Simplified38.0%
Taylor expanded in n around inf 37.7%
*-commutative37.7%
Simplified37.7%
Taylor expanded in i around 0 55.0%
if -1.14999999999999989e-171 < n < 1.44999999999999997e-134Initial program 51.8%
associate-*r/51.8%
sub-neg51.8%
distribute-rgt-in51.8%
metadata-eval51.8%
metadata-eval51.8%
Simplified51.8%
Taylor expanded in i around 0 77.4%
if 1.44999999999999997e-134 < n Initial program 23.1%
associate-/r/23.3%
associate-*r*23.4%
*-commutative23.4%
associate-*r/23.3%
sub-neg23.3%
distribute-lft-in23.3%
metadata-eval23.3%
metadata-eval23.3%
metadata-eval23.3%
fma-define23.3%
metadata-eval23.3%
Simplified23.3%
fma-undefine23.3%
metadata-eval23.3%
metadata-eval23.3%
distribute-lft-in23.3%
sub-neg23.3%
*-commutative23.3%
add-exp-log23.3%
expm1-define23.3%
log-pow26.2%
log1p-define79.1%
Applied egg-rr79.1%
Taylor expanded in n around inf 35.3%
expm1-define83.9%
Simplified83.9%
Taylor expanded in i around 0 67.7%
*-commutative67.7%
Simplified67.7%
Final simplification64.1%
(FPCore (i n) :precision binary64 (if (<= n -2700.0) (* 100.0 (+ n (* 0.5 (* i n)))) (if (<= n 7.5e-50) (* 100.0 (/ i (/ i n))) (* n (+ 100.0 (* i 50.0))))))
double code(double i, double n) {
double tmp;
if (n <= -2700.0) {
tmp = 100.0 * (n + (0.5 * (i * n)));
} else if (n <= 7.5e-50) {
tmp = 100.0 * (i / (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 <= (-2700.0d0)) then
tmp = 100.0d0 * (n + (0.5d0 * (i * n)))
else if (n <= 7.5d-50) then
tmp = 100.0d0 * (i / (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 <= -2700.0) {
tmp = 100.0 * (n + (0.5 * (i * n)));
} else if (n <= 7.5e-50) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -2700.0: tmp = 100.0 * (n + (0.5 * (i * n))) elif n <= 7.5e-50: tmp = 100.0 * (i / (i / n)) else: tmp = n * (100.0 + (i * 50.0)) return tmp
function code(i, n) tmp = 0.0 if (n <= -2700.0) tmp = Float64(100.0 * Float64(n + Float64(0.5 * Float64(i * n)))); elseif (n <= 7.5e-50) tmp = Float64(100.0 * Float64(i / 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 <= -2700.0) tmp = 100.0 * (n + (0.5 * (i * n))); elseif (n <= 7.5e-50) tmp = 100.0 * (i / (i / n)); else tmp = n * (100.0 + (i * 50.0)); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -2700.0], N[(100.0 * N[(n + N[(0.5 * N[(i * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 7.5e-50], N[(100.0 * N[(i / N[(i / n), $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 -2700:\\
\;\;\;\;100 \cdot \left(n + 0.5 \cdot \left(i \cdot n\right)\right)\\
\mathbf{elif}\;n \leq 7.5 \cdot 10^{-50}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -2700Initial program 32.6%
Taylor expanded in i around 0 32.9%
associate-*r/32.9%
metadata-eval32.9%
Simplified32.9%
clear-num31.5%
inv-pow31.5%
Applied egg-rr31.5%
unpow-131.5%
Simplified31.5%
Taylor expanded in n around inf 31.5%
*-commutative31.5%
Simplified31.5%
Taylor expanded in i around 0 55.1%
if -2700 < n < 7.5e-50Initial program 36.8%
Taylor expanded in i around 0 59.9%
if 7.5e-50 < n Initial program 25.1%
associate-/r/25.4%
associate-*r*25.4%
*-commutative25.4%
associate-*r/25.4%
sub-neg25.4%
distribute-lft-in25.3%
metadata-eval25.3%
metadata-eval25.3%
metadata-eval25.3%
fma-define25.4%
metadata-eval25.4%
Simplified25.4%
fma-undefine25.3%
metadata-eval25.3%
metadata-eval25.3%
distribute-lft-in25.4%
sub-neg25.4%
*-commutative25.4%
add-exp-log25.4%
expm1-define25.4%
log-pow21.0%
log1p-define76.7%
Applied egg-rr76.7%
Taylor expanded in n around inf 42.8%
expm1-define93.0%
Simplified93.0%
Taylor expanded in i around 0 73.0%
*-commutative73.0%
Simplified73.0%
(FPCore (i n) :precision binary64 (if (<= i -2e+106) (* 100.0 (/ i (/ i n))) (if (<= i 1e+95) (* n 100.0) (* 50.0 (* i n)))))
double code(double i, double n) {
double tmp;
if (i <= -2e+106) {
tmp = 100.0 * (i / (i / n));
} else if (i <= 1e+95) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= (-2d+106)) then
tmp = 100.0d0 * (i / (i / n))
else if (i <= 1d+95) then
tmp = n * 100.0d0
else
tmp = 50.0d0 * (i * n)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -2e+106) {
tmp = 100.0 * (i / (i / n));
} else if (i <= 1e+95) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -2e+106: tmp = 100.0 * (i / (i / n)) elif i <= 1e+95: tmp = n * 100.0 else: tmp = 50.0 * (i * n) return tmp
function code(i, n) tmp = 0.0 if (i <= -2e+106) tmp = Float64(100.0 * Float64(i / Float64(i / n))); elseif (i <= 1e+95) tmp = Float64(n * 100.0); else tmp = Float64(50.0 * Float64(i * n)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -2e+106) tmp = 100.0 * (i / (i / n)); elseif (i <= 1e+95) tmp = n * 100.0; else tmp = 50.0 * (i * n); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -2e+106], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 1e+95], N[(n * 100.0), $MachinePrecision], N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -2 \cdot 10^{+106}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{elif}\;i \leq 10^{+95}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;50 \cdot \left(i \cdot n\right)\\
\end{array}
\end{array}
if i < -2.00000000000000018e106Initial program 69.4%
Taylor expanded in i around 0 29.9%
if -2.00000000000000018e106 < i < 1.00000000000000002e95Initial program 16.5%
associate-/r/16.9%
associate-*r*16.9%
*-commutative16.9%
associate-*r/16.9%
sub-neg16.9%
distribute-lft-in16.9%
metadata-eval16.9%
metadata-eval16.9%
metadata-eval16.9%
fma-define16.9%
metadata-eval16.9%
Simplified16.9%
Taylor expanded in i around 0 69.0%
*-commutative69.0%
Simplified69.0%
if 1.00000000000000002e95 < i Initial program 54.7%
Taylor expanded in i around 0 40.2%
associate-*r/40.2%
metadata-eval40.2%
Simplified40.2%
clear-num40.2%
inv-pow40.2%
Applied egg-rr40.2%
unpow-140.2%
Simplified40.2%
Taylor expanded in n around inf 40.3%
*-commutative40.3%
Simplified40.3%
Taylor expanded in i around inf 35.6%
*-commutative35.6%
Simplified35.6%
Final simplification56.7%
(FPCore (i n) :precision binary64 (if (<= i -1.4e+105) (* 100.0 (* i (/ n i))) (if (<= i 1e+95) (* n 100.0) (* 50.0 (* i n)))))
double code(double i, double n) {
double tmp;
if (i <= -1.4e+105) {
tmp = 100.0 * (i * (n / i));
} else if (i <= 1e+95) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= (-1.4d+105)) then
tmp = 100.0d0 * (i * (n / i))
else if (i <= 1d+95) then
tmp = n * 100.0d0
else
tmp = 50.0d0 * (i * n)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -1.4e+105) {
tmp = 100.0 * (i * (n / i));
} else if (i <= 1e+95) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -1.4e+105: tmp = 100.0 * (i * (n / i)) elif i <= 1e+95: tmp = n * 100.0 else: tmp = 50.0 * (i * n) return tmp
function code(i, n) tmp = 0.0 if (i <= -1.4e+105) tmp = Float64(100.0 * Float64(i * Float64(n / i))); elseif (i <= 1e+95) tmp = Float64(n * 100.0); else tmp = Float64(50.0 * Float64(i * n)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -1.4e+105) tmp = 100.0 * (i * (n / i)); elseif (i <= 1e+95) tmp = n * 100.0; else tmp = 50.0 * (i * n); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -1.4e+105], N[(100.0 * N[(i * N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 1e+95], N[(n * 100.0), $MachinePrecision], N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -1.4 \cdot 10^{+105}:\\
\;\;\;\;100 \cdot \left(i \cdot \frac{n}{i}\right)\\
\mathbf{elif}\;i \leq 10^{+95}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;50 \cdot \left(i \cdot n\right)\\
\end{array}
\end{array}
if i < -1.4000000000000001e105Initial program 69.4%
Taylor expanded in i around 0 29.9%
div-inv29.9%
clear-num27.3%
Applied egg-rr27.3%
if -1.4000000000000001e105 < i < 1.00000000000000002e95Initial program 16.5%
associate-/r/16.9%
associate-*r*16.9%
*-commutative16.9%
associate-*r/16.9%
sub-neg16.9%
distribute-lft-in16.9%
metadata-eval16.9%
metadata-eval16.9%
metadata-eval16.9%
fma-define16.9%
metadata-eval16.9%
Simplified16.9%
Taylor expanded in i around 0 69.0%
*-commutative69.0%
Simplified69.0%
if 1.00000000000000002e95 < i Initial program 54.7%
Taylor expanded in i around 0 40.2%
associate-*r/40.2%
metadata-eval40.2%
Simplified40.2%
clear-num40.2%
inv-pow40.2%
Applied egg-rr40.2%
unpow-140.2%
Simplified40.2%
Taylor expanded in n around inf 40.3%
*-commutative40.3%
Simplified40.3%
Taylor expanded in i around inf 35.6%
*-commutative35.6%
Simplified35.6%
Final simplification56.3%
(FPCore (i n) :precision binary64 (if (<= i 1e+95) (* n 100.0) (* 50.0 (* i n))))
double code(double i, double n) {
double tmp;
if (i <= 1e+95) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= 1d+95) then
tmp = n * 100.0d0
else
tmp = 50.0d0 * (i * n)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= 1e+95) {
tmp = n * 100.0;
} else {
tmp = 50.0 * (i * n);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 1e+95: tmp = n * 100.0 else: tmp = 50.0 * (i * n) return tmp
function code(i, n) tmp = 0.0 if (i <= 1e+95) tmp = Float64(n * 100.0); else tmp = Float64(50.0 * Float64(i * n)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= 1e+95) tmp = n * 100.0; else tmp = 50.0 * (i * n); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, 1e+95], N[(n * 100.0), $MachinePrecision], N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 10^{+95}:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;50 \cdot \left(i \cdot n\right)\\
\end{array}
\end{array}
if i < 1.00000000000000002e95Initial program 26.0%
associate-/r/26.0%
associate-*r*26.1%
*-commutative26.1%
associate-*r/26.0%
sub-neg26.0%
distribute-lft-in26.0%
metadata-eval26.0%
metadata-eval26.0%
metadata-eval26.0%
fma-define26.0%
metadata-eval26.0%
Simplified26.0%
Taylor expanded in i around 0 57.3%
*-commutative57.3%
Simplified57.3%
if 1.00000000000000002e95 < i Initial program 54.7%
Taylor expanded in i around 0 40.2%
associate-*r/40.2%
metadata-eval40.2%
Simplified40.2%
clear-num40.2%
inv-pow40.2%
Applied egg-rr40.2%
unpow-140.2%
Simplified40.2%
Taylor expanded in n around inf 40.3%
*-commutative40.3%
Simplified40.3%
Taylor expanded in i around inf 35.6%
*-commutative35.6%
Simplified35.6%
Final simplification53.0%
(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 31.7%
associate-/r/31.8%
associate-*r*31.8%
*-commutative31.8%
associate-*r/31.8%
sub-neg31.8%
distribute-lft-in31.8%
metadata-eval31.8%
metadata-eval31.8%
metadata-eval31.8%
fma-define31.8%
metadata-eval31.8%
Simplified31.8%
Taylor expanded in i around 0 46.9%
*-commutative46.9%
Simplified46.9%
(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 31.7%
Taylor expanded in i around 0 41.5%
associate-*r/41.5%
metadata-eval41.5%
Simplified41.5%
Taylor expanded in n around 0 2.7%
*-commutative2.7%
Simplified2.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 2024188
(FPCore (i n)
:name "Compound Interest"
:precision binary64
:alt
(! :herbie-platform default (let ((lnbase (if (== (+ 1 (/ i n)) 1) (/ i n) (/ (* (/ i n) (log (+ 1 (/ i n)))) (- (+ (/ i n) 1) 1))))) (* 100 (/ (- (exp (* n lnbase)) 1) (/ i n)))))
(* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))