
(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 14 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 (- INFINITY))
(* 100.0 (/ (+ (pow (/ i n) n) -1.0) (/ i n)))
(if (<= t_1 0.0)
(/ 100.0 (/ (/ i n) (expm1 (* n (log1p (/ i n))))))
(if (<= t_1 INFINITY)
(* 100.0 (- (* t_0 (/ n i)) (/ n i)))
(* n 100.0))))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = 100.0 * ((pow((i / n), n) + -1.0) / (i / n));
} else if (t_1 <= 0.0) {
tmp = 100.0 / ((i / n) / expm1((n * log1p((i / n)))));
} else if (t_1 <= ((double) INFINITY)) {
tmp = 100.0 * ((t_0 * (n / i)) - (n / i));
} else {
tmp = n * 100.0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = 100.0 * ((Math.pow((i / n), n) + -1.0) / (i / n));
} else if (t_1 <= 0.0) {
tmp = 100.0 / ((i / n) / Math.expm1((n * Math.log1p((i / n)))));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = 100.0 * ((t_0 * (n / i)) - (n / i));
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): t_0 = math.pow((1.0 + (i / n)), n) t_1 = (t_0 + -1.0) / (i / n) tmp = 0 if t_1 <= -math.inf: tmp = 100.0 * ((math.pow((i / n), n) + -1.0) / (i / n)) elif t_1 <= 0.0: tmp = 100.0 / ((i / n) / math.expm1((n * math.log1p((i / n))))) elif t_1 <= math.inf: tmp = 100.0 * ((t_0 * (n / i)) - (n / i)) else: tmp = n * 100.0 return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(100.0 * Float64(Float64((Float64(i / n) ^ n) + -1.0) / Float64(i / n))); elseif (t_1 <= 0.0) tmp = Float64(100.0 / Float64(Float64(i / n) / expm1(Float64(n * log1p(Float64(i / n)))))); elseif (t_1 <= Inf) tmp = Float64(100.0 * Float64(Float64(t_0 * Float64(n / i)) - Float64(n / i))); else tmp = Float64(n * 100.0); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-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$1, 0.0], N[(100.0 / N[(N[(i / n), $MachinePrecision] / N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(100.0 * N[(N[(t$95$0 * N[(n / i), $MachinePrecision]), $MachinePrecision] - N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t\_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;100 \cdot \frac{{\left(\frac{i}{n}\right)}^{n} + -1}{\frac{i}{n}}\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{100}{\frac{\frac{i}{n}}{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;100 \cdot \left(t\_0 \cdot \frac{n}{i} - \frac{n}{i}\right)\\
\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 20.2%
associate-/r/20.0%
associate-*r*20.0%
*-commutative20.0%
associate-*r/20.0%
sub-neg20.0%
distribute-lft-in20.1%
metadata-eval20.1%
metadata-eval20.1%
metadata-eval20.1%
fma-define20.0%
metadata-eval20.0%
Simplified20.0%
*-commutative20.0%
fma-undefine20.1%
*-commutative20.1%
associate-/r/20.2%
metadata-eval20.2%
metadata-eval20.2%
distribute-rgt-in20.2%
sub-neg20.2%
associate-*r/20.2%
clear-num20.2%
un-div-inv20.2%
add-exp-log20.2%
expm1-define20.2%
log-pow30.4%
log1p-define99.6%
Applied egg-rr99.6%
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 97.2%
div-sub97.2%
clear-num97.2%
sub-neg97.2%
div-inv97.2%
clear-num97.2%
Applied egg-rr97.2%
sub-neg97.2%
Simplified97.2%
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.9%
associate-*r*1.9%
*-commutative1.9%
associate-*r/1.9%
sub-neg1.9%
distribute-lft-in1.9%
metadata-eval1.9%
metadata-eval1.9%
metadata-eval1.9%
fma-define1.9%
metadata-eval1.9%
Simplified1.9%
Taylor expanded in i around 0 80.6%
*-commutative80.6%
Simplified80.6%
Final simplification95.5%
(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-49)
(* t_1 100.0)
(if (<= t_1 0.0)
(* 100.0 (* n (/ (expm1 (* n (log1p (/ i n)))) i)))
(if (<= t_1 INFINITY)
(* 100.0 (- (* t_0 (/ n i)) (/ n i)))
(* n 100.0))))))
double code(double i, double n) {
double t_0 = pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= -1e-49) {
tmp = t_1 * 100.0;
} else if (t_1 <= 0.0) {
tmp = 100.0 * (n * (expm1((n * log1p((i / n)))) / i));
} else if (t_1 <= ((double) INFINITY)) {
tmp = 100.0 * ((t_0 * (n / i)) - (n / i));
} else {
tmp = n * 100.0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = Math.pow((1.0 + (i / n)), n);
double t_1 = (t_0 + -1.0) / (i / n);
double tmp;
if (t_1 <= -1e-49) {
tmp = t_1 * 100.0;
} else if (t_1 <= 0.0) {
tmp = 100.0 * (n * (Math.expm1((n * Math.log1p((i / n)))) / i));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = 100.0 * ((t_0 * (n / i)) - (n / i));
} else {
tmp = n * 100.0;
}
return tmp;
}
def code(i, n): t_0 = math.pow((1.0 + (i / n)), n) t_1 = (t_0 + -1.0) / (i / n) tmp = 0 if t_1 <= -1e-49: tmp = t_1 * 100.0 elif t_1 <= 0.0: tmp = 100.0 * (n * (math.expm1((n * math.log1p((i / n)))) / i)) elif t_1 <= math.inf: tmp = 100.0 * ((t_0 * (n / i)) - (n / i)) else: tmp = n * 100.0 return tmp
function code(i, n) t_0 = Float64(1.0 + Float64(i / n)) ^ n t_1 = Float64(Float64(t_0 + -1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= -1e-49) tmp = Float64(t_1 * 100.0); elseif (t_1 <= 0.0) tmp = Float64(100.0 * Float64(n * Float64(expm1(Float64(n * log1p(Float64(i / n)))) / i))); elseif (t_1 <= Inf) tmp = Float64(100.0 * Float64(Float64(t_0 * Float64(n / i)) - Float64(n / i))); else tmp = Float64(n * 100.0); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + -1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e-49], N[(t$95$1 * 100.0), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(100.0 * N[(n * N[(N[(Exp[N[(n * N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(100.0 * N[(N[(t$95$0 * N[(n / i), $MachinePrecision]), $MachinePrecision] - N[(n / i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * 100.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(1 + \frac{i}{n}\right)}^{n}\\
t_1 := \frac{t\_0 + -1}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-49}:\\
\;\;\;\;t\_1 \cdot 100\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(n \cdot \mathsf{log1p}\left(\frac{i}{n}\right)\right)}{i}\right)\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;100 \cdot \left(t\_0 \cdot \frac{n}{i} - \frac{n}{i}\right)\\
\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)) < -9.99999999999999936e-50Initial program 100.0%
if -9.99999999999999936e-50 < (/.f64 (-.f64 (pow.f64 (+.f64 #s(literal 1 binary64) (/.f64 i n)) n) #s(literal 1 binary64)) (/.f64 i n)) < -0.0Initial program 18.8%
associate-/r/18.7%
add-exp-log18.7%
expm1-define18.7%
log-pow29.1%
log1p-define99.0%
Applied egg-rr99.0%
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 97.2%
div-sub97.2%
clear-num97.2%
sub-neg97.2%
div-inv97.2%
clear-num97.2%
Applied egg-rr97.2%
sub-neg97.2%
Simplified97.2%
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.9%
associate-*r*1.9%
*-commutative1.9%
associate-*r/1.9%
sub-neg1.9%
distribute-lft-in1.9%
metadata-eval1.9%
metadata-eval1.9%
metadata-eval1.9%
fma-define1.9%
metadata-eval1.9%
Simplified1.9%
Taylor expanded in i around 0 80.6%
*-commutative80.6%
Simplified80.6%
Final simplification95.1%
(FPCore (i n) :precision binary64 (if (or (<= n -1.3e-243) (not (<= n 1.2e-112))) (* 100.0 (* n (/ (expm1 i) i))) (/ 0.0 (/ i n))))
double code(double i, double n) {
double tmp;
if ((n <= -1.3e-243) || !(n <= 1.2e-112)) {
tmp = 100.0 * (n * (expm1(i) / i));
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if ((n <= -1.3e-243) || !(n <= 1.2e-112)) {
tmp = 100.0 * (n * (Math.expm1(i) / i));
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -1.3e-243) or not (n <= 1.2e-112): tmp = 100.0 * (n * (math.expm1(i) / i)) else: tmp = 0.0 / (i / n) return tmp
function code(i, n) tmp = 0.0 if ((n <= -1.3e-243) || !(n <= 1.2e-112)) tmp = Float64(100.0 * Float64(n * Float64(expm1(i) / i))); else tmp = Float64(0.0 / Float64(i / n)); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -1.3e-243], N[Not[LessEqual[n, 1.2e-112]], $MachinePrecision]], N[(100.0 * N[(n * 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.3 \cdot 10^{-243} \lor \neg \left(n \leq 1.2 \cdot 10^{-112}\right):\\
\;\;\;\;100 \cdot \left(n \cdot \frac{\mathsf{expm1}\left(i\right)}{i}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -1.2999999999999999e-243 or 1.2e-112 < n Initial program 20.0%
Taylor expanded in n around inf 34.1%
*-commutative34.1%
associate-/l*34.1%
expm1-define87.8%
Simplified87.8%
if -1.2999999999999999e-243 < n < 1.2e-112Initial program 38.5%
associate-*r/38.5%
sub-neg38.5%
distribute-rgt-in38.5%
metadata-eval38.5%
metadata-eval38.5%
Simplified38.5%
Taylor expanded in n around inf 29.0%
Taylor expanded in i around 0 64.7%
Final simplification84.0%
(FPCore (i n) :precision binary64 (if (or (<= n -4.6e-244) (not (<= n 1.2e-111))) (* n (/ (* 100.0 (expm1 i)) i)) (/ 0.0 (/ i n))))
double code(double i, double n) {
double tmp;
if ((n <= -4.6e-244) || !(n <= 1.2e-111)) {
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 <= -4.6e-244) || !(n <= 1.2e-111)) {
tmp = n * ((100.0 * Math.expm1(i)) / i);
} else {
tmp = 0.0 / (i / n);
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -4.6e-244) or not (n <= 1.2e-111): 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 <= -4.6e-244) || !(n <= 1.2e-111)) tmp = Float64(n * Float64(Float64(100.0 * expm1(i)) / i)); else tmp = Float64(0.0 / Float64(i / n)); end return tmp end
code[i_, n_] := If[Or[LessEqual[n, -4.6e-244], N[Not[LessEqual[n, 1.2e-111]], $MachinePrecision]], N[(n * N[(N[(100.0 * N[(Exp[i] - 1), $MachinePrecision]), $MachinePrecision] / i), $MachinePrecision]), $MachinePrecision], N[(0.0 / N[(i / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -4.6 \cdot 10^{-244} \lor \neg \left(n \leq 1.2 \cdot 10^{-111}\right):\\
\;\;\;\;n \cdot \frac{100 \cdot \mathsf{expm1}\left(i\right)}{i}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -4.6e-244 or 1.2e-111 < n Initial program 20.0%
associate-/r/20.2%
associate-*r*20.2%
*-commutative20.2%
associate-*r/20.2%
sub-neg20.2%
distribute-lft-in20.2%
metadata-eval20.2%
metadata-eval20.2%
metadata-eval20.2%
fma-define20.2%
metadata-eval20.2%
Simplified20.2%
Taylor expanded in n around inf 34.1%
sub-neg34.1%
metadata-eval34.1%
metadata-eval34.1%
distribute-lft-in34.1%
metadata-eval34.1%
sub-neg34.1%
expm1-define87.7%
Simplified87.7%
if -4.6e-244 < n < 1.2e-111Initial program 38.5%
associate-*r/38.5%
sub-neg38.5%
distribute-rgt-in38.5%
metadata-eval38.5%
metadata-eval38.5%
Simplified38.5%
Taylor expanded in n around inf 29.0%
Taylor expanded in i around 0 64.7%
Final simplification83.9%
(FPCore (i n)
:precision binary64
(if (or (<= n -20500.0) (not (<= n 1.7)))
(*
n
(+
100.0
(* i (+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667)))))))
(* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -20500.0) || !(n <= 1.7)) {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
} 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 <= (-20500.0d0)) .or. (.not. (n <= 1.7d0))) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * (16.666666666666668d0 + (i * 4.166666666666667d0))))))
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 <= -20500.0) || !(n <= 1.7)) {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -20500.0) or not (n <= 1.7): tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))) else: tmp = 100.0 * (i / (i / n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -20500.0) || !(n <= 1.7)) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * Float64(16.666666666666668 + Float64(i * 4.166666666666667))))))); 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 <= -20500.0) || ~((n <= 1.7))) tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))); else tmp = 100.0 * (i / (i / n)); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -20500.0], N[Not[LessEqual[n, 1.7]], $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], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -20500 \lor \neg \left(n \leq 1.7\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot \left(16.666666666666668 + i \cdot 4.166666666666667\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -20500 or 1.69999999999999996 < n Initial program 18.6%
associate-/r/19.1%
associate-*r*19.1%
*-commutative19.1%
associate-*r/19.1%
sub-neg19.1%
distribute-lft-in19.1%
metadata-eval19.1%
metadata-eval19.1%
metadata-eval19.1%
fma-define19.1%
metadata-eval19.1%
Simplified19.1%
Taylor expanded in n around inf 41.2%
sub-neg41.2%
metadata-eval41.2%
metadata-eval41.2%
distribute-lft-in41.2%
metadata-eval41.2%
sub-neg41.2%
expm1-define93.5%
Simplified93.5%
Taylor expanded in i around 0 73.4%
*-commutative73.4%
Simplified73.4%
if -20500 < n < 1.69999999999999996Initial program 29.7%
Taylor expanded in i around 0 68.0%
Final simplification71.2%
(FPCore (i n)
:precision binary64
(if (<= n -112000.0)
(*
100.0
(*
n
(+
1.0
(* i (+ 0.5 (* i (+ 0.16666666666666666 (* i 0.041666666666666664))))))))
(if (<= n 1.7)
(* 100.0 (/ i (/ i n)))
(*
n
(+
100.0
(* i (+ 50.0 (* i (+ 16.666666666666668 (* i 4.166666666666667))))))))))
double code(double i, double n) {
double tmp;
if (n <= -112000.0) {
tmp = 100.0 * (n * (1.0 + (i * (0.5 + (i * (0.16666666666666666 + (i * 0.041666666666666664)))))));
} else if (n <= 1.7) {
tmp = 100.0 * (i / (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 <= (-112000.0d0)) then
tmp = 100.0d0 * (n * (1.0d0 + (i * (0.5d0 + (i * (0.16666666666666666d0 + (i * 0.041666666666666664d0)))))))
else if (n <= 1.7d0) then
tmp = 100.0d0 * (i / (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 <= -112000.0) {
tmp = 100.0 * (n * (1.0 + (i * (0.5 + (i * (0.16666666666666666 + (i * 0.041666666666666664)))))));
} else if (n <= 1.7) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667))))));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -112000.0: tmp = 100.0 * (n * (1.0 + (i * (0.5 + (i * (0.16666666666666666 + (i * 0.041666666666666664))))))) elif n <= 1.7: tmp = 100.0 * (i / (i / n)) else: tmp = n * (100.0 + (i * (50.0 + (i * (16.666666666666668 + (i * 4.166666666666667)))))) return tmp
function code(i, n) tmp = 0.0 if (n <= -112000.0) tmp = Float64(100.0 * Float64(n * Float64(1.0 + Float64(i * Float64(0.5 + Float64(i * Float64(0.16666666666666666 + Float64(i * 0.041666666666666664)))))))); elseif (n <= 1.7) tmp = Float64(100.0 * Float64(i / Float64(i / n))); else tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * Float64(16.666666666666668 + Float64(i * 4.166666666666667))))))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -112000.0) tmp = 100.0 * (n * (1.0 + (i * (0.5 + (i * (0.16666666666666666 + (i * 0.041666666666666664))))))); elseif (n <= 1.7) tmp = 100.0 * (i / (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, -112000.0], N[(100.0 * N[(n * N[(1.0 + N[(i * N[(0.5 + N[(i * N[(0.16666666666666666 + N[(i * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.7], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * N[(16.666666666666668 + N[(i * 4.166666666666667), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -112000:\\
\;\;\;\;100 \cdot \left(n \cdot \left(1 + i \cdot \left(0.5 + i \cdot \left(0.16666666666666666 + i \cdot 0.041666666666666664\right)\right)\right)\right)\\
\mathbf{elif}\;n \leq 1.7:\\
\;\;\;\;100 \cdot \frac{i}{\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 < -112000Initial program 17.9%
Taylor expanded in n around inf 35.4%
*-commutative35.4%
associate-/l*35.3%
expm1-define93.3%
Simplified93.3%
Taylor expanded in i around 0 71.6%
*-commutative71.6%
Simplified71.6%
if -112000 < n < 1.69999999999999996Initial program 29.7%
Taylor expanded in i around 0 68.0%
if 1.69999999999999996 < n Initial program 19.7%
associate-/r/20.2%
associate-*r*20.2%
*-commutative20.2%
associate-*r/20.2%
sub-neg20.2%
distribute-lft-in20.2%
metadata-eval20.2%
metadata-eval20.2%
metadata-eval20.2%
fma-define20.2%
metadata-eval20.2%
Simplified20.2%
Taylor expanded in n around inf 49.4%
sub-neg49.4%
metadata-eval49.4%
metadata-eval49.4%
distribute-lft-in49.4%
metadata-eval49.4%
sub-neg49.4%
expm1-define93.8%
Simplified93.8%
Taylor expanded in i around 0 75.8%
*-commutative75.8%
Simplified75.8%
Final simplification71.3%
(FPCore (i n) :precision binary64 (if (or (<= n -740000.0) (not (<= n 1.6))) (* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668))))) (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -740000.0) || !(n <= 1.6)) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} 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 <= (-740000.0d0)) .or. (.not. (n <= 1.6d0))) then
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
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 <= -740000.0) || !(n <= 1.6)) {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -740000.0) or not (n <= 1.6): tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) else: tmp = 100.0 * (i / (i / n)) return tmp
function code(i, n) tmp = 0.0 if ((n <= -740000.0) || !(n <= 1.6)) tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); 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 <= -740000.0) || ~((n <= 1.6))) tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); else tmp = 100.0 * (i / (i / n)); end tmp_2 = tmp; end
code[i_, n_] := If[Or[LessEqual[n, -740000.0], N[Not[LessEqual[n, 1.6]], $MachinePrecision]], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -740000 \lor \neg \left(n \leq 1.6\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -7.4e5 or 1.6000000000000001 < n Initial program 18.6%
associate-/r/19.1%
associate-*r*19.1%
*-commutative19.1%
associate-*r/19.1%
sub-neg19.1%
distribute-lft-in19.1%
metadata-eval19.1%
metadata-eval19.1%
metadata-eval19.1%
fma-define19.1%
metadata-eval19.1%
Simplified19.1%
Taylor expanded in n around inf 41.2%
sub-neg41.2%
metadata-eval41.2%
metadata-eval41.2%
distribute-lft-in41.2%
metadata-eval41.2%
sub-neg41.2%
expm1-define93.5%
Simplified93.5%
Taylor expanded in i around 0 69.8%
*-commutative69.8%
Simplified69.8%
if -7.4e5 < n < 1.6000000000000001Initial program 29.7%
Taylor expanded in i around 0 68.0%
Final simplification69.1%
(FPCore (i n)
:precision binary64
(if (<= n -750.0)
(* 100.0 (* n (+ 1.0 (* i (+ 0.5 (* i 0.16666666666666666))))))
(if (<= n 1.8)
(* 100.0 (/ i (/ i n)))
(* n (+ 100.0 (* i (+ 50.0 (* i 16.666666666666668))))))))
double code(double i, double n) {
double tmp;
if (n <= -750.0) {
tmp = 100.0 * (n * (1.0 + (i * (0.5 + (i * 0.16666666666666666)))));
} else if (n <= 1.8) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-750.0d0)) then
tmp = 100.0d0 * (n * (1.0d0 + (i * (0.5d0 + (i * 0.16666666666666666d0)))))
else if (n <= 1.8d0) then
tmp = 100.0d0 * (i / (i / n))
else
tmp = n * (100.0d0 + (i * (50.0d0 + (i * 16.666666666666668d0))))
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (n <= -750.0) {
tmp = 100.0 * (n * (1.0 + (i * (0.5 + (i * 0.16666666666666666)))));
} else if (n <= 1.8) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668))));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -750.0: tmp = 100.0 * (n * (1.0 + (i * (0.5 + (i * 0.16666666666666666))))) elif n <= 1.8: tmp = 100.0 * (i / (i / n)) else: tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))) return tmp
function code(i, n) tmp = 0.0 if (n <= -750.0) tmp = Float64(100.0 * Float64(n * Float64(1.0 + Float64(i * Float64(0.5 + Float64(i * 0.16666666666666666)))))); elseif (n <= 1.8) tmp = Float64(100.0 * Float64(i / Float64(i / n))); else tmp = Float64(n * Float64(100.0 + Float64(i * Float64(50.0 + Float64(i * 16.666666666666668))))); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (n <= -750.0) tmp = 100.0 * (n * (1.0 + (i * (0.5 + (i * 0.16666666666666666))))); elseif (n <= 1.8) tmp = 100.0 * (i / (i / n)); else tmp = n * (100.0 + (i * (50.0 + (i * 16.666666666666668)))); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[n, -750.0], N[(100.0 * N[(n * N[(1.0 + N[(i * N[(0.5 + N[(i * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.8], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(n * N[(100.0 + N[(i * N[(50.0 + N[(i * 16.666666666666668), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -750:\\
\;\;\;\;100 \cdot \left(n \cdot \left(1 + i \cdot \left(0.5 + i \cdot 0.16666666666666666\right)\right)\right)\\
\mathbf{elif}\;n \leq 1.8:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot \left(50 + i \cdot 16.666666666666668\right)\right)\\
\end{array}
\end{array}
if n < -750Initial program 17.9%
Taylor expanded in n around inf 35.4%
*-commutative35.4%
associate-/l*35.3%
expm1-define93.3%
Simplified93.3%
Taylor expanded in i around 0 70.3%
*-commutative70.3%
Simplified70.3%
if -750 < n < 1.80000000000000004Initial program 29.7%
Taylor expanded in i around 0 68.0%
if 1.80000000000000004 < n Initial program 19.7%
associate-/r/20.2%
associate-*r*20.2%
*-commutative20.2%
associate-*r/20.2%
sub-neg20.2%
distribute-lft-in20.2%
metadata-eval20.2%
metadata-eval20.2%
metadata-eval20.2%
fma-define20.2%
metadata-eval20.2%
Simplified20.2%
Taylor expanded in n around inf 49.4%
sub-neg49.4%
metadata-eval49.4%
metadata-eval49.4%
distribute-lft-in49.4%
metadata-eval49.4%
sub-neg49.4%
expm1-define93.8%
Simplified93.8%
Taylor expanded in i around 0 69.1%
*-commutative69.1%
Simplified69.1%
Final simplification69.1%
(FPCore (i n) :precision binary64 (if (or (<= n -128000.0) (not (<= n 1.45))) (* n (+ 100.0 (* i 50.0))) (* 100.0 (/ i (/ i n)))))
double code(double i, double n) {
double tmp;
if ((n <= -128000.0) || !(n <= 1.45)) {
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 <= (-128000.0d0)) .or. (.not. (n <= 1.45d0))) 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 <= -128000.0) || !(n <= 1.45)) {
tmp = n * (100.0 + (i * 50.0));
} else {
tmp = 100.0 * (i / (i / n));
}
return tmp;
}
def code(i, n): tmp = 0 if (n <= -128000.0) or not (n <= 1.45): 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 <= -128000.0) || !(n <= 1.45)) 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 <= -128000.0) || ~((n <= 1.45))) 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, -128000.0], N[Not[LessEqual[n, 1.45]], $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 -128000 \lor \neg \left(n \leq 1.45\right):\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\mathbf{else}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\end{array}
\end{array}
if n < -128000 or 1.44999999999999996 < n Initial program 18.6%
Taylor expanded in n around inf 41.3%
*-commutative41.3%
associate-/l*41.2%
expm1-define93.5%
Simplified93.5%
Taylor expanded in i around 0 65.5%
+-commutative65.5%
associate-*r*65.5%
distribute-rgt-in65.5%
*-commutative65.5%
Simplified65.5%
if -128000 < n < 1.44999999999999996Initial program 29.7%
Taylor expanded in i around 0 68.0%
Final simplification66.5%
(FPCore (i n) :precision binary64 (if (<= n -720000.0) (+ (* n 100.0) (* 50.0 (* i n))) (if (<= n 1.5) (* 100.0 (/ i (/ i n))) (* n (+ 100.0 (* i 50.0))))))
double code(double i, double n) {
double tmp;
if (n <= -720000.0) {
tmp = (n * 100.0) + (50.0 * (i * n));
} else if (n <= 1.5) {
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 <= (-720000.0d0)) then
tmp = (n * 100.0d0) + (50.0d0 * (i * n))
else if (n <= 1.5d0) 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 <= -720000.0) {
tmp = (n * 100.0) + (50.0 * (i * n));
} else if (n <= 1.5) {
tmp = 100.0 * (i / (i / n));
} else {
tmp = n * (100.0 + (i * 50.0));
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -720000.0: tmp = (n * 100.0) + (50.0 * (i * n)) elif n <= 1.5: 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 <= -720000.0) tmp = Float64(Float64(n * 100.0) + Float64(50.0 * Float64(i * n))); elseif (n <= 1.5) 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 <= -720000.0) tmp = (n * 100.0) + (50.0 * (i * n)); elseif (n <= 1.5) 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, -720000.0], N[(N[(n * 100.0), $MachinePrecision] + N[(50.0 * N[(i * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.5], 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 -720000:\\
\;\;\;\;n \cdot 100 + 50 \cdot \left(i \cdot n\right)\\
\mathbf{elif}\;n \leq 1.5:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \left(100 + i \cdot 50\right)\\
\end{array}
\end{array}
if n < -7.2e5Initial program 17.9%
Taylor expanded in n around inf 35.4%
*-commutative35.4%
associate-/l*35.3%
expm1-define93.3%
Simplified93.3%
Taylor expanded in i around 0 66.4%
if -7.2e5 < n < 1.5Initial program 29.7%
Taylor expanded in i around 0 68.0%
if 1.5 < n Initial program 19.7%
Taylor expanded in n around inf 49.4%
*-commutative49.4%
associate-/l*49.5%
expm1-define93.8%
Simplified93.8%
Taylor expanded in i around 0 64.2%
+-commutative64.2%
associate-*r*64.2%
distribute-rgt-in64.2%
*-commutative64.2%
Simplified64.2%
Final simplification66.5%
(FPCore (i n) :precision binary64 (if (<= i -1e+66) (* 100.0 (/ i (/ i n))) (if (<= i 11500000000.0) (* n 100.0) (* i (* n 50.0)))))
double code(double i, double n) {
double tmp;
if (i <= -1e+66) {
tmp = 100.0 * (i / (i / n));
} else if (i <= 11500000000.0) {
tmp = n * 100.0;
} else {
tmp = i * (n * 50.0);
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= (-1d+66)) then
tmp = 100.0d0 * (i / (i / n))
else if (i <= 11500000000.0d0) then
tmp = n * 100.0d0
else
tmp = i * (n * 50.0d0)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -1e+66) {
tmp = 100.0 * (i / (i / n));
} else if (i <= 11500000000.0) {
tmp = n * 100.0;
} else {
tmp = i * (n * 50.0);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -1e+66: tmp = 100.0 * (i / (i / n)) elif i <= 11500000000.0: tmp = n * 100.0 else: tmp = i * (n * 50.0) return tmp
function code(i, n) tmp = 0.0 if (i <= -1e+66) tmp = Float64(100.0 * Float64(i / Float64(i / n))); elseif (i <= 11500000000.0) tmp = Float64(n * 100.0); else tmp = Float64(i * Float64(n * 50.0)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -1e+66) tmp = 100.0 * (i / (i / n)); elseif (i <= 11500000000.0) tmp = n * 100.0; else tmp = i * (n * 50.0); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -1e+66], N[(100.0 * N[(i / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 11500000000.0], N[(n * 100.0), $MachinePrecision], N[(i * N[(n * 50.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -1 \cdot 10^{+66}:\\
\;\;\;\;100 \cdot \frac{i}{\frac{i}{n}}\\
\mathbf{elif}\;i \leq 11500000000:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;i \cdot \left(n \cdot 50\right)\\
\end{array}
\end{array}
if i < -9.99999999999999945e65Initial program 66.2%
Taylor expanded in i around 0 35.2%
if -9.99999999999999945e65 < i < 1.15e10Initial program 8.6%
associate-/r/9.1%
associate-*r*9.1%
*-commutative9.1%
associate-*r/9.1%
sub-neg9.1%
distribute-lft-in9.1%
metadata-eval9.1%
metadata-eval9.1%
metadata-eval9.1%
fma-define9.1%
metadata-eval9.1%
Simplified9.1%
Taylor expanded in i around 0 80.4%
*-commutative80.4%
Simplified80.4%
if 1.15e10 < i Initial program 35.5%
associate-/r/35.7%
associate-*r*35.7%
*-commutative35.7%
associate-*r/35.7%
sub-neg35.7%
distribute-lft-in35.7%
metadata-eval35.7%
metadata-eval35.7%
metadata-eval35.7%
fma-define35.7%
metadata-eval35.7%
Simplified35.7%
Taylor expanded in i around 0 30.1%
*-commutative30.1%
associate-*r/30.1%
metadata-eval30.1%
Simplified30.1%
Taylor expanded in n around 0 30.2%
Taylor expanded in i around inf 30.2%
Taylor expanded in n around inf 30.7%
*-commutative30.7%
Simplified30.7%
(FPCore (i n) :precision binary64 (if (<= i 11500000000.0) (* n 100.0) (* i (* n 50.0))))
double code(double i, double n) {
double tmp;
if (i <= 11500000000.0) {
tmp = n * 100.0;
} else {
tmp = i * (n * 50.0);
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= 11500000000.0d0) then
tmp = n * 100.0d0
else
tmp = i * (n * 50.0d0)
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= 11500000000.0) {
tmp = n * 100.0;
} else {
tmp = i * (n * 50.0);
}
return tmp;
}
def code(i, n): tmp = 0 if i <= 11500000000.0: tmp = n * 100.0 else: tmp = i * (n * 50.0) return tmp
function code(i, n) tmp = 0.0 if (i <= 11500000000.0) tmp = Float64(n * 100.0); else tmp = Float64(i * Float64(n * 50.0)); end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= 11500000000.0) tmp = n * 100.0; else tmp = i * (n * 50.0); end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, 11500000000.0], N[(n * 100.0), $MachinePrecision], N[(i * N[(n * 50.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq 11500000000:\\
\;\;\;\;n \cdot 100\\
\mathbf{else}:\\
\;\;\;\;i \cdot \left(n \cdot 50\right)\\
\end{array}
\end{array}
if i < 1.15e10Initial program 19.4%
associate-/r/19.6%
associate-*r*19.6%
*-commutative19.6%
associate-*r/19.6%
sub-neg19.6%
distribute-lft-in19.6%
metadata-eval19.6%
metadata-eval19.6%
metadata-eval19.6%
fma-define19.6%
metadata-eval19.6%
Simplified19.6%
Taylor expanded in i around 0 66.3%
*-commutative66.3%
Simplified66.3%
if 1.15e10 < i Initial program 35.5%
associate-/r/35.7%
associate-*r*35.7%
*-commutative35.7%
associate-*r/35.7%
sub-neg35.7%
distribute-lft-in35.7%
metadata-eval35.7%
metadata-eval35.7%
metadata-eval35.7%
fma-define35.7%
metadata-eval35.7%
Simplified35.7%
Taylor expanded in i around 0 30.1%
*-commutative30.1%
associate-*r/30.1%
metadata-eval30.1%
Simplified30.1%
Taylor expanded in n around 0 30.2%
Taylor expanded in i around inf 30.2%
Taylor expanded in n around inf 30.7%
*-commutative30.7%
Simplified30.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 23.0%
associate-/r/23.2%
associate-*r*23.2%
*-commutative23.2%
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%
Taylor expanded in i around 0 52.5%
*-commutative52.5%
Simplified52.5%
(FPCore (i n) :precision binary64 (* i -50.0))
double code(double i, double n) {
return i * -50.0;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = i * (-50.0d0)
end function
public static double code(double i, double n) {
return i * -50.0;
}
def code(i, n): return i * -50.0
function code(i, n) return Float64(i * -50.0) end
function tmp = code(i, n) tmp = i * -50.0; end
code[i_, n_] := N[(i * -50.0), $MachinePrecision]
\begin{array}{l}
\\
i \cdot -50
\end{array}
Initial program 23.0%
associate-/r/23.2%
associate-*r*23.2%
*-commutative23.2%
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%
Taylor expanded in i around 0 57.1%
*-commutative57.1%
associate-*r/57.1%
metadata-eval57.1%
Simplified57.1%
Taylor expanded in n around 0 2.9%
*-commutative2.9%
Simplified2.9%
(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 2024149
(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))))