
(FPCore (i n) :precision binary64 (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))
double code(double i, double n) {
return 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 100.0d0 * ((((1.0d0 + (i / n)) ** n) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
return 100.0 * ((Math.pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
def code(i, n): return 100.0 * ((math.pow((1.0 + (i / n)), n) - 1.0) / (i / n))
function code(i, n) return Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n))) end
function tmp = code(i, n) tmp = 100.0 * ((((1.0 + (i / n)) ^ n) - 1.0) / (i / n)); end
code[i_, n_] := N[(100.0 * N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (i n) :precision binary64 (* 100.0 (/ (- (pow (+ 1.0 (/ i n)) n) 1.0) (/ i n))))
double code(double i, double n) {
return 100.0 * ((pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 100.0d0 * ((((1.0d0 + (i / n)) ** n) - 1.0d0) / (i / n))
end function
public static double code(double i, double n) {
return 100.0 * ((Math.pow((1.0 + (i / n)), n) - 1.0) / (i / n));
}
def code(i, n): return 100.0 * ((math.pow((1.0 + (i / n)), n) - 1.0) / (i / n))
function code(i, n) return Float64(100.0 * Float64(Float64((Float64(1.0 + Float64(i / n)) ^ n) - 1.0) / Float64(i / n))) end
function tmp = code(i, n) tmp = 100.0 * ((((1.0 + (i / n)) ^ n) - 1.0) / (i / n)); end
code[i_, n_] := N[(100.0 * N[(N[(N[Power[N[(1.0 + N[(i / n), $MachinePrecision]), $MachinePrecision], n], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
100 \cdot \frac{{\left(1 + \frac{i}{n}\right)}^{n} - 1}{\frac{i}{n}}
\end{array}
(FPCore (i n)
:precision binary64
(let* ((t_0 (+ (/ i n) 1.0))
(t_1 (/ (- (pow t_0 n) 1.0) (/ i n)))
(t_2 (pow t_0 (* 0.5 n))))
(if (<= t_1 0.0)
(/ (* (expm1 (* (log1p (/ i n)) n)) 100.0) (/ i n))
(if (<= t_1 INFINITY)
(* (* (/ 100.0 i) (fma t_2 t_2 -1.0)) n)
(* 100.0 n)))))
double code(double i, double n) {
double t_0 = (i / n) + 1.0;
double t_1 = (pow(t_0, n) - 1.0) / (i / n);
double t_2 = pow(t_0, (0.5 * n));
double tmp;
if (t_1 <= 0.0) {
tmp = (expm1((log1p((i / n)) * n)) * 100.0) / (i / n);
} else if (t_1 <= ((double) INFINITY)) {
tmp = ((100.0 / i) * fma(t_2, t_2, -1.0)) * n;
} else {
tmp = 100.0 * n;
}
return tmp;
}
function code(i, n) t_0 = Float64(Float64(i / n) + 1.0) t_1 = Float64(Float64((t_0 ^ n) - 1.0) / Float64(i / n)) t_2 = t_0 ^ Float64(0.5 * n) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(Float64(expm1(Float64(log1p(Float64(i / n)) * n)) * 100.0) / Float64(i / n)); elseif (t_1 <= Inf) tmp = Float64(Float64(Float64(100.0 / i) * fma(t_2, t_2, -1.0)) * n); else tmp = Float64(100.0 * n); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(N[(i / n), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Power[t$95$0, n], $MachinePrecision] - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[t$95$0, N[(0.5 * n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(N[(N[(Exp[N[(N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision] * n), $MachinePrecision]] - 1), $MachinePrecision] * 100.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[(100.0 / i), $MachinePrecision] * N[(t$95$2 * t$95$2 + -1.0), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision], N[(100.0 * n), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{i}{n} + 1\\
t_1 := \frac{{t\_0}^{n} - 1}{\frac{i}{n}}\\
t_2 := {t\_0}^{\left(0.5 \cdot n\right)}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n\right) \cdot 100}{\frac{i}{n}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\left(\frac{100}{i} \cdot \mathsf{fma}\left(t\_2, t\_2, -1\right)\right) \cdot n\\
\mathbf{else}:\\
\;\;\;\;100 \cdot n\\
\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)) < -0.0Initial program 23.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6423.4
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f6498.6
Applied rewrites98.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.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f64N/A
lower-/.f6468.2
Applied rewrites68.2%
lift-expm1.f64N/A
lift-*.f64N/A
lift-log1p.f64N/A
pow-to-expN/A
lift-/.f64N/A
sub-negN/A
lift-/.f64N/A
+-commutativeN/A
lift-+.f64N/A
sqr-powN/A
lower-fma.f64N/A
Applied rewrites97.8%
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%
Taylor expanded in i around 0
lower-*.f6471.5
Applied rewrites71.5%
Final simplification93.7%
(FPCore (i n)
:precision binary64
(let* ((t_0 (pow (+ (/ i n) 1.0) n)) (t_1 (/ (- t_0 1.0) (/ i n))))
(if (<= t_1 0.0)
(/ (* (expm1 (* (log1p (/ i n)) n)) 100.0) (/ i n))
(if (<= t_1 INFINITY) (* (/ (fma t_0 100.0 -100.0) i) n) (* 100.0 n)))))
double code(double i, double n) {
double t_0 = pow(((i / n) + 1.0), n);
double t_1 = (t_0 - 1.0) / (i / n);
double tmp;
if (t_1 <= 0.0) {
tmp = (expm1((log1p((i / n)) * n)) * 100.0) / (i / n);
} else if (t_1 <= ((double) INFINITY)) {
tmp = (fma(t_0, 100.0, -100.0) / i) * n;
} else {
tmp = 100.0 * n;
}
return tmp;
}
function code(i, n) t_0 = Float64(Float64(i / n) + 1.0) ^ n t_1 = Float64(Float64(t_0 - 1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(Float64(expm1(Float64(log1p(Float64(i / n)) * n)) * 100.0) / Float64(i / n)); elseif (t_1 <= Inf) tmp = Float64(Float64(fma(t_0, 100.0, -100.0) / i) * n); else tmp = Float64(100.0 * n); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(N[(i / n), $MachinePrecision] + 1.0), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(N[(N[(Exp[N[(N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision] * n), $MachinePrecision]] - 1), $MachinePrecision] * 100.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[(t$95$0 * 100.0 + -100.0), $MachinePrecision] / i), $MachinePrecision] * n), $MachinePrecision], N[(100.0 * n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\frac{i}{n} + 1\right)}^{n}\\
t_1 := \frac{t\_0 - 1}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n\right) \cdot 100}{\frac{i}{n}}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_0, 100, -100\right)}{i} \cdot n\\
\mathbf{else}:\\
\;\;\;\;100 \cdot n\\
\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)) < -0.0Initial program 23.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f6423.4
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f6498.6
Applied rewrites98.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.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f64N/A
lower-/.f6468.2
Applied rewrites68.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6468.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.1
Applied rewrites68.1%
lift-*.f64N/A
*-commutativeN/A
lift-expm1.f64N/A
lift-*.f64N/A
lift-log1p.f64N/A
pow-to-expN/A
+-commutativeN/A
lift-+.f64N/A
sqr-powN/A
sqr-powN/A
lift-pow.f64N/A
sub-negN/A
distribute-rgt-inN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites97.7%
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%
Taylor expanded in i around 0
lower-*.f6471.5
Applied rewrites71.5%
Final simplification93.7%
(FPCore (i n)
:precision binary64
(let* ((t_0 (pow (+ (/ i n) 1.0) n)) (t_1 (/ (- t_0 1.0) (/ i n))))
(if (<= t_1 0.0)
(* (/ (* (expm1 (* (log1p (/ i n)) n)) 100.0) i) n)
(if (<= t_1 INFINITY) (* (/ (fma t_0 100.0 -100.0) i) n) (* 100.0 n)))))
double code(double i, double n) {
double t_0 = pow(((i / n) + 1.0), n);
double t_1 = (t_0 - 1.0) / (i / n);
double tmp;
if (t_1 <= 0.0) {
tmp = ((expm1((log1p((i / n)) * n)) * 100.0) / i) * n;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (fma(t_0, 100.0, -100.0) / i) * n;
} else {
tmp = 100.0 * n;
}
return tmp;
}
function code(i, n) t_0 = Float64(Float64(i / n) + 1.0) ^ n t_1 = Float64(Float64(t_0 - 1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(Float64(Float64(expm1(Float64(log1p(Float64(i / n)) * n)) * 100.0) / i) * n); elseif (t_1 <= Inf) tmp = Float64(Float64(fma(t_0, 100.0, -100.0) / i) * n); else tmp = Float64(100.0 * n); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(N[(i / n), $MachinePrecision] + 1.0), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(N[(N[(N[(Exp[N[(N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision] * n), $MachinePrecision]] - 1), $MachinePrecision] * 100.0), $MachinePrecision] / i), $MachinePrecision] * n), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[(t$95$0 * 100.0 + -100.0), $MachinePrecision] / i), $MachinePrecision] * n), $MachinePrecision], N[(100.0 * n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\frac{i}{n} + 1\right)}^{n}\\
t_1 := \frac{t\_0 - 1}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n\right) \cdot 100}{i} \cdot n\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_0, 100, -100\right)}{i} \cdot n\\
\mathbf{else}:\\
\;\;\;\;100 \cdot n\\
\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)) < -0.0Initial program 23.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f64N/A
lower-/.f6497.5
Applied rewrites97.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6498.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.0
Applied rewrites98.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.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f64N/A
lower-/.f6468.2
Applied rewrites68.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6468.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.1
Applied rewrites68.1%
lift-*.f64N/A
*-commutativeN/A
lift-expm1.f64N/A
lift-*.f64N/A
lift-log1p.f64N/A
pow-to-expN/A
+-commutativeN/A
lift-+.f64N/A
sqr-powN/A
sqr-powN/A
lift-pow.f64N/A
sub-negN/A
distribute-rgt-inN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites97.7%
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%
Taylor expanded in i around 0
lower-*.f6471.5
Applied rewrites71.5%
Final simplification93.2%
(FPCore (i n)
:precision binary64
(let* ((t_0 (pow (+ (/ i n) 1.0) n)) (t_1 (/ (- t_0 1.0) (/ i n))))
(if (<= t_1 0.0)
(* (/ (expm1 (* (log1p (/ i n)) n)) i) (* 100.0 n))
(if (<= t_1 INFINITY) (* (/ (fma t_0 100.0 -100.0) i) n) (* 100.0 n)))))
double code(double i, double n) {
double t_0 = pow(((i / n) + 1.0), n);
double t_1 = (t_0 - 1.0) / (i / n);
double tmp;
if (t_1 <= 0.0) {
tmp = (expm1((log1p((i / n)) * n)) / i) * (100.0 * n);
} else if (t_1 <= ((double) INFINITY)) {
tmp = (fma(t_0, 100.0, -100.0) / i) * n;
} else {
tmp = 100.0 * n;
}
return tmp;
}
function code(i, n) t_0 = Float64(Float64(i / n) + 1.0) ^ n t_1 = Float64(Float64(t_0 - 1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(Float64(expm1(Float64(log1p(Float64(i / n)) * n)) / i) * Float64(100.0 * n)); elseif (t_1 <= Inf) tmp = Float64(Float64(fma(t_0, 100.0, -100.0) / i) * n); else tmp = Float64(100.0 * n); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(N[(i / n), $MachinePrecision] + 1.0), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(N[(N[(Exp[N[(N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision] * n), $MachinePrecision]] - 1), $MachinePrecision] / i), $MachinePrecision] * N[(100.0 * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[(t$95$0 * 100.0 + -100.0), $MachinePrecision] / i), $MachinePrecision] * n), $MachinePrecision], N[(100.0 * n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\frac{i}{n} + 1\right)}^{n}\\
t_1 := \frac{t\_0 - 1}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n\right)}{i} \cdot \left(100 \cdot n\right)\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_0, 100, -100\right)}{i} \cdot n\\
\mathbf{else}:\\
\;\;\;\;100 \cdot n\\
\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)) < -0.0Initial program 23.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f64N/A
*-commutativeN/A
lower-*.f6497.9
Applied rewrites97.9%
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.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f64N/A
lower-/.f6468.2
Applied rewrites68.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6468.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.1
Applied rewrites68.1%
lift-*.f64N/A
*-commutativeN/A
lift-expm1.f64N/A
lift-*.f64N/A
lift-log1p.f64N/A
pow-to-expN/A
+-commutativeN/A
lift-+.f64N/A
sqr-powN/A
sqr-powN/A
lift-pow.f64N/A
sub-negN/A
distribute-rgt-inN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites97.7%
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%
Taylor expanded in i around 0
lower-*.f6471.5
Applied rewrites71.5%
Final simplification93.2%
(FPCore (i n)
:precision binary64
(let* ((t_0 (pow (+ (/ i n) 1.0) n)) (t_1 (/ (- t_0 1.0) (/ i n))))
(if (<= t_1 0.0)
(* (* (/ 100.0 i) (expm1 (* (log1p (/ i n)) n))) n)
(if (<= t_1 INFINITY) (* (/ (fma t_0 100.0 -100.0) i) n) (* 100.0 n)))))
double code(double i, double n) {
double t_0 = pow(((i / n) + 1.0), n);
double t_1 = (t_0 - 1.0) / (i / n);
double tmp;
if (t_1 <= 0.0) {
tmp = ((100.0 / i) * expm1((log1p((i / n)) * n))) * n;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (fma(t_0, 100.0, -100.0) / i) * n;
} else {
tmp = 100.0 * n;
}
return tmp;
}
function code(i, n) t_0 = Float64(Float64(i / n) + 1.0) ^ n t_1 = Float64(Float64(t_0 - 1.0) / Float64(i / n)) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(Float64(Float64(100.0 / i) * expm1(Float64(log1p(Float64(i / n)) * n))) * n); elseif (t_1 <= Inf) tmp = Float64(Float64(fma(t_0, 100.0, -100.0) / i) * n); else tmp = Float64(100.0 * n); end return tmp end
code[i_, n_] := Block[{t$95$0 = N[Power[N[(N[(i / n), $MachinePrecision] + 1.0), $MachinePrecision], n], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 - 1.0), $MachinePrecision] / N[(i / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(N[(N[(100.0 / i), $MachinePrecision] * N[(Exp[N[(N[Log[1 + N[(i / n), $MachinePrecision]], $MachinePrecision] * n), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(N[(t$95$0 * 100.0 + -100.0), $MachinePrecision] / i), $MachinePrecision] * n), $MachinePrecision], N[(100.0 * n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\frac{i}{n} + 1\right)}^{n}\\
t_1 := \frac{t\_0 - 1}{\frac{i}{n}}\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;\left(\frac{100}{i} \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{i}{n}\right) \cdot n\right)\right) \cdot n\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_0, 100, -100\right)}{i} \cdot n\\
\mathbf{else}:\\
\;\;\;\;100 \cdot n\\
\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)) < -0.0Initial program 23.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f64N/A
lower-/.f6497.5
Applied rewrites97.5%
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.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f64N/A
lower-/.f6468.2
Applied rewrites68.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6468.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.1
Applied rewrites68.1%
lift-*.f64N/A
*-commutativeN/A
lift-expm1.f64N/A
lift-*.f64N/A
lift-log1p.f64N/A
pow-to-expN/A
+-commutativeN/A
lift-+.f64N/A
sqr-powN/A
sqr-powN/A
lift-pow.f64N/A
sub-negN/A
distribute-rgt-inN/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
Applied rewrites97.7%
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%
Taylor expanded in i around 0
lower-*.f6471.5
Applied rewrites71.5%
Final simplification92.8%
(FPCore (i n) :precision binary64 (if (<= n -3.5e-188) (* (* (expm1 i) (/ 100.0 i)) n) (if (<= n 3.5e-105) 0.0 (* (* (/ (expm1 i) i) 100.0) n))))
double code(double i, double n) {
double tmp;
if (n <= -3.5e-188) {
tmp = (expm1(i) * (100.0 / i)) * n;
} else if (n <= 3.5e-105) {
tmp = 0.0;
} else {
tmp = ((expm1(i) / i) * 100.0) * n;
}
return tmp;
}
public static double code(double i, double n) {
double tmp;
if (n <= -3.5e-188) {
tmp = (Math.expm1(i) * (100.0 / i)) * n;
} else if (n <= 3.5e-105) {
tmp = 0.0;
} else {
tmp = ((Math.expm1(i) / i) * 100.0) * n;
}
return tmp;
}
def code(i, n): tmp = 0 if n <= -3.5e-188: tmp = (math.expm1(i) * (100.0 / i)) * n elif n <= 3.5e-105: tmp = 0.0 else: tmp = ((math.expm1(i) / i) * 100.0) * n return tmp
function code(i, n) tmp = 0.0 if (n <= -3.5e-188) tmp = Float64(Float64(expm1(i) * Float64(100.0 / i)) * n); elseif (n <= 3.5e-105) tmp = 0.0; else tmp = Float64(Float64(Float64(expm1(i) / i) * 100.0) * n); end return tmp end
code[i_, n_] := If[LessEqual[n, -3.5e-188], N[(N[(N[(Exp[i] - 1), $MachinePrecision] * N[(100.0 / i), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision], If[LessEqual[n, 3.5e-105], 0.0, N[(N[(N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision] * 100.0), $MachinePrecision] * n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.5 \cdot 10^{-188}:\\
\;\;\;\;\left(\mathsf{expm1}\left(i\right) \cdot \frac{100}{i}\right) \cdot n\\
\mathbf{elif}\;n \leq 3.5 \cdot 10^{-105}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\mathsf{expm1}\left(i\right)}{i} \cdot 100\right) \cdot n\\
\end{array}
\end{array}
if n < -3.5e-188Initial program 21.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f64N/A
lower-/.f6478.9
Applied rewrites78.9%
Taylor expanded in n around inf
lower-expm1.f6487.8
Applied rewrites87.8%
if -3.5e-188 < n < 3.5e-105Initial program 43.2%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lift-/.f64N/A
clear-numN/A
sub-negN/A
div-invN/A
lift-/.f64N/A
clear-numN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6443.2
Applied rewrites43.2%
Taylor expanded in i around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
lower-/.f6471.7
Applied rewrites71.7%
Taylor expanded in i around 0
Applied rewrites71.7%
if 3.5e-105 < n Initial program 19.3%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6490.2
Applied rewrites90.2%
(FPCore (i n) :precision binary64 (let* ((t_0 (* (* (/ (expm1 i) i) 100.0) n))) (if (<= n -3.5e-188) t_0 (if (<= n 3.5e-105) 0.0 t_0))))
double code(double i, double n) {
double t_0 = ((expm1(i) / i) * 100.0) * n;
double tmp;
if (n <= -3.5e-188) {
tmp = t_0;
} else if (n <= 3.5e-105) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double i, double n) {
double t_0 = ((Math.expm1(i) / i) * 100.0) * n;
double tmp;
if (n <= -3.5e-188) {
tmp = t_0;
} else if (n <= 3.5e-105) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(i, n): t_0 = ((math.expm1(i) / i) * 100.0) * n tmp = 0 if n <= -3.5e-188: tmp = t_0 elif n <= 3.5e-105: tmp = 0.0 else: tmp = t_0 return tmp
function code(i, n) t_0 = Float64(Float64(Float64(expm1(i) / i) * 100.0) * n) tmp = 0.0 if (n <= -3.5e-188) tmp = t_0; elseif (n <= 3.5e-105) tmp = 0.0; else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(N[(N[(N[(Exp[i] - 1), $MachinePrecision] / i), $MachinePrecision] * 100.0), $MachinePrecision] * n), $MachinePrecision]}, If[LessEqual[n, -3.5e-188], t$95$0, If[LessEqual[n, 3.5e-105], 0.0, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{\mathsf{expm1}\left(i\right)}{i} \cdot 100\right) \cdot n\\
\mathbf{if}\;n \leq -3.5 \cdot 10^{-188}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 3.5 \cdot 10^{-105}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -3.5e-188 or 3.5e-105 < n Initial program 20.3%
Taylor expanded in n around inf
associate-/l*N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6488.9
Applied rewrites88.9%
if -3.5e-188 < n < 3.5e-105Initial program 43.2%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lift-/.f64N/A
clear-numN/A
sub-negN/A
div-invN/A
lift-/.f64N/A
clear-numN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6443.2
Applied rewrites43.2%
Taylor expanded in i around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
lower-/.f6471.7
Applied rewrites71.7%
Taylor expanded in i around 0
Applied rewrites71.7%
(FPCore (i n)
:precision binary64
(let* ((t_0
(*
(fma
(fma (fma 4.166666666666667 i 16.666666666666668) i 50.0)
i
100.0)
n)))
(if (<= n -8.5e-131) t_0 (if (<= n 3.5e-105) 0.0 t_0))))
double code(double i, double n) {
double t_0 = fma(fma(fma(4.166666666666667, i, 16.666666666666668), i, 50.0), i, 100.0) * n;
double tmp;
if (n <= -8.5e-131) {
tmp = t_0;
} else if (n <= 3.5e-105) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
function code(i, n) t_0 = Float64(fma(fma(fma(4.166666666666667, i, 16.666666666666668), i, 50.0), i, 100.0) * n) tmp = 0.0 if (n <= -8.5e-131) tmp = t_0; elseif (n <= 3.5e-105) tmp = 0.0; else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(N[(N[(N[(4.166666666666667 * i + 16.666666666666668), $MachinePrecision] * i + 50.0), $MachinePrecision] * i + 100.0), $MachinePrecision] * n), $MachinePrecision]}, If[LessEqual[n, -8.5e-131], t$95$0, If[LessEqual[n, 3.5e-105], 0.0, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(4.166666666666667, i, 16.666666666666668\right), i, 50\right), i, 100\right) \cdot n\\
\mathbf{if}\;n \leq -8.5 \cdot 10^{-131}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 3.5 \cdot 10^{-105}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -8.50000000000000013e-131 or 3.5e-105 < n Initial program 19.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f64N/A
lower-/.f6479.4
Applied rewrites79.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6479.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6479.3
Applied rewrites79.3%
Taylor expanded in n around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6489.4
Applied rewrites89.4%
Taylor expanded in i around 0
Applied rewrites69.0%
if -8.50000000000000013e-131 < n < 3.5e-105Initial program 43.5%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lift-/.f64N/A
clear-numN/A
sub-negN/A
div-invN/A
lift-/.f64N/A
clear-numN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6443.6
Applied rewrites43.6%
Taylor expanded in i around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
lower-/.f6468.5
Applied rewrites68.5%
Taylor expanded in i around 0
Applied rewrites68.5%
(FPCore (i n) :precision binary64 (let* ((t_0 (* (fma (fma 16.666666666666668 i 50.0) i 100.0) n))) (if (<= n -8.5e-131) t_0 (if (<= n 3.5e-105) 0.0 t_0))))
double code(double i, double n) {
double t_0 = fma(fma(16.666666666666668, i, 50.0), i, 100.0) * n;
double tmp;
if (n <= -8.5e-131) {
tmp = t_0;
} else if (n <= 3.5e-105) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
function code(i, n) t_0 = Float64(fma(fma(16.666666666666668, i, 50.0), i, 100.0) * n) tmp = 0.0 if (n <= -8.5e-131) tmp = t_0; elseif (n <= 3.5e-105) tmp = 0.0; else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(N[(N[(16.666666666666668 * i + 50.0), $MachinePrecision] * i + 100.0), $MachinePrecision] * n), $MachinePrecision]}, If[LessEqual[n, -8.5e-131], t$95$0, If[LessEqual[n, 3.5e-105], 0.0, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\mathsf{fma}\left(16.666666666666668, i, 50\right), i, 100\right) \cdot n\\
\mathbf{if}\;n \leq -8.5 \cdot 10^{-131}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 3.5 \cdot 10^{-105}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -8.50000000000000013e-131 or 3.5e-105 < n Initial program 19.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f64N/A
lower-/.f6479.4
Applied rewrites79.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6479.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6479.3
Applied rewrites79.3%
Taylor expanded in n around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6489.4
Applied rewrites89.4%
Taylor expanded in i around 0
Applied rewrites66.7%
if -8.50000000000000013e-131 < n < 3.5e-105Initial program 43.5%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lift-/.f64N/A
clear-numN/A
sub-negN/A
div-invN/A
lift-/.f64N/A
clear-numN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6443.6
Applied rewrites43.6%
Taylor expanded in i around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
lower-/.f6468.5
Applied rewrites68.5%
Taylor expanded in i around 0
Applied rewrites68.5%
(FPCore (i n) :precision binary64 (let* ((t_0 (* (fma 50.0 i 100.0) n))) (if (<= n -8.5e-131) t_0 (if (<= n 3.5e-105) 0.0 t_0))))
double code(double i, double n) {
double t_0 = fma(50.0, i, 100.0) * n;
double tmp;
if (n <= -8.5e-131) {
tmp = t_0;
} else if (n <= 3.5e-105) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
function code(i, n) t_0 = Float64(fma(50.0, i, 100.0) * n) tmp = 0.0 if (n <= -8.5e-131) tmp = t_0; elseif (n <= 3.5e-105) tmp = 0.0; else tmp = t_0; end return tmp end
code[i_, n_] := Block[{t$95$0 = N[(N[(50.0 * i + 100.0), $MachinePrecision] * n), $MachinePrecision]}, If[LessEqual[n, -8.5e-131], t$95$0, If[LessEqual[n, 3.5e-105], 0.0, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(50, i, 100\right) \cdot n\\
\mathbf{if}\;n \leq -8.5 \cdot 10^{-131}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 3.5 \cdot 10^{-105}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -8.50000000000000013e-131 or 3.5e-105 < n Initial program 19.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
pow-to-expN/A
lower-expm1.f64N/A
lower-*.f64N/A
lift-+.f64N/A
lower-log1p.f64N/A
lower-/.f6479.4
Applied rewrites79.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f6479.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6479.3
Applied rewrites79.3%
Taylor expanded in n around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-expm1.f6489.4
Applied rewrites89.4%
Taylor expanded in i around 0
Applied rewrites62.6%
if -8.50000000000000013e-131 < n < 3.5e-105Initial program 43.5%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lift-/.f64N/A
clear-numN/A
sub-negN/A
div-invN/A
lift-/.f64N/A
clear-numN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6443.6
Applied rewrites43.6%
Taylor expanded in i around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
lower-/.f6468.5
Applied rewrites68.5%
Taylor expanded in i around 0
Applied rewrites68.5%
(FPCore (i n) :precision binary64 (if (<= i -5e+35) 0.0 (if (<= i 0.225) (* 100.0 n) 0.0)))
double code(double i, double n) {
double tmp;
if (i <= -5e+35) {
tmp = 0.0;
} else if (i <= 0.225) {
tmp = 100.0 * n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
real(8) :: tmp
if (i <= (-5d+35)) then
tmp = 0.0d0
else if (i <= 0.225d0) then
tmp = 100.0d0 * n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double i, double n) {
double tmp;
if (i <= -5e+35) {
tmp = 0.0;
} else if (i <= 0.225) {
tmp = 100.0 * n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(i, n): tmp = 0 if i <= -5e+35: tmp = 0.0 elif i <= 0.225: tmp = 100.0 * n else: tmp = 0.0 return tmp
function code(i, n) tmp = 0.0 if (i <= -5e+35) tmp = 0.0; elseif (i <= 0.225) tmp = Float64(100.0 * n); else tmp = 0.0; end return tmp end
function tmp_2 = code(i, n) tmp = 0.0; if (i <= -5e+35) tmp = 0.0; elseif (i <= 0.225) tmp = 100.0 * n; else tmp = 0.0; end tmp_2 = tmp; end
code[i_, n_] := If[LessEqual[i, -5e+35], 0.0, If[LessEqual[i, 0.225], N[(100.0 * n), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;i \leq -5 \cdot 10^{+35}:\\
\;\;\;\;0\\
\mathbf{elif}\;i \leq 0.225:\\
\;\;\;\;100 \cdot n\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if i < -5.00000000000000021e35 or 0.225000000000000006 < i Initial program 41.5%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lift-/.f64N/A
clear-numN/A
sub-negN/A
div-invN/A
lift-/.f64N/A
clear-numN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6441.6
Applied rewrites41.6%
Taylor expanded in i around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
lower-/.f6427.3
Applied rewrites27.3%
Taylor expanded in i around 0
Applied rewrites27.3%
if -5.00000000000000021e35 < i < 0.225000000000000006Initial program 10.5%
Taylor expanded in i around 0
lower-*.f6481.3
Applied rewrites81.3%
(FPCore (i n) :precision binary64 0.0)
double code(double i, double n) {
return 0.0;
}
real(8) function code(i, n)
real(8), intent (in) :: i
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double i, double n) {
return 0.0;
}
def code(i, n): return 0.0
function code(i, n) return 0.0 end
function tmp = code(i, n) tmp = 0.0; end
code[i_, n_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 24.7%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
lift-/.f64N/A
clear-numN/A
sub-negN/A
div-invN/A
lift-/.f64N/A
clear-numN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6424.7
Applied rewrites24.7%
Taylor expanded in i around 0
associate-*r/N/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
metadata-evalN/A
lower-/.f6417.8
Applied rewrites17.8%
Taylor expanded in i around 0
Applied rewrites17.8%
(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 2024249
(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))))