
(FPCore (x1 x2)
:precision binary64
(let* ((t_0 (* (* 3.0 x1) x1))
(t_1 (+ (* x1 x1) 1.0))
(t_2 (/ (- (+ t_0 (* 2.0 x2)) x1) t_1)))
(+
x1
(+
(+
(+
(+
(*
(+
(* (* (* 2.0 x1) t_2) (- t_2 3.0))
(* (* x1 x1) (- (* 4.0 t_2) 6.0)))
t_1)
(* t_0 t_2))
(* (* x1 x1) x1))
x1)
(* 3.0 (/ (- (- t_0 (* 2.0 x2)) x1) t_1))))))
double code(double x1, double x2) {
double t_0 = (3.0 * x1) * x1;
double t_1 = (x1 * x1) + 1.0;
double t_2 = ((t_0 + (2.0 * x2)) - x1) / t_1;
return x1 + (((((((((2.0 * x1) * t_2) * (t_2 - 3.0)) + ((x1 * x1) * ((4.0 * t_2) - 6.0))) * t_1) + (t_0 * t_2)) + ((x1 * x1) * x1)) + x1) + (3.0 * (((t_0 - (2.0 * x2)) - x1) / t_1)));
}
real(8) function code(x1, x2)
real(8), intent (in) :: x1
real(8), intent (in) :: x2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = (3.0d0 * x1) * x1
t_1 = (x1 * x1) + 1.0d0
t_2 = ((t_0 + (2.0d0 * x2)) - x1) / t_1
code = x1 + (((((((((2.0d0 * x1) * t_2) * (t_2 - 3.0d0)) + ((x1 * x1) * ((4.0d0 * t_2) - 6.0d0))) * t_1) + (t_0 * t_2)) + ((x1 * x1) * x1)) + x1) + (3.0d0 * (((t_0 - (2.0d0 * x2)) - x1) / t_1)))
end function
public static double code(double x1, double x2) {
double t_0 = (3.0 * x1) * x1;
double t_1 = (x1 * x1) + 1.0;
double t_2 = ((t_0 + (2.0 * x2)) - x1) / t_1;
return x1 + (((((((((2.0 * x1) * t_2) * (t_2 - 3.0)) + ((x1 * x1) * ((4.0 * t_2) - 6.0))) * t_1) + (t_0 * t_2)) + ((x1 * x1) * x1)) + x1) + (3.0 * (((t_0 - (2.0 * x2)) - x1) / t_1)));
}
def code(x1, x2): t_0 = (3.0 * x1) * x1 t_1 = (x1 * x1) + 1.0 t_2 = ((t_0 + (2.0 * x2)) - x1) / t_1 return x1 + (((((((((2.0 * x1) * t_2) * (t_2 - 3.0)) + ((x1 * x1) * ((4.0 * t_2) - 6.0))) * t_1) + (t_0 * t_2)) + ((x1 * x1) * x1)) + x1) + (3.0 * (((t_0 - (2.0 * x2)) - x1) / t_1)))
function code(x1, x2) t_0 = Float64(Float64(3.0 * x1) * x1) t_1 = Float64(Float64(x1 * x1) + 1.0) t_2 = Float64(Float64(Float64(t_0 + Float64(2.0 * x2)) - x1) / t_1) return Float64(x1 + Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(2.0 * x1) * t_2) * Float64(t_2 - 3.0)) + Float64(Float64(x1 * x1) * Float64(Float64(4.0 * t_2) - 6.0))) * t_1) + Float64(t_0 * t_2)) + Float64(Float64(x1 * x1) * x1)) + x1) + Float64(3.0 * Float64(Float64(Float64(t_0 - Float64(2.0 * x2)) - x1) / t_1)))) end
function tmp = code(x1, x2) t_0 = (3.0 * x1) * x1; t_1 = (x1 * x1) + 1.0; t_2 = ((t_0 + (2.0 * x2)) - x1) / t_1; tmp = x1 + (((((((((2.0 * x1) * t_2) * (t_2 - 3.0)) + ((x1 * x1) * ((4.0 * t_2) - 6.0))) * t_1) + (t_0 * t_2)) + ((x1 * x1) * x1)) + x1) + (3.0 * (((t_0 - (2.0 * x2)) - x1) / t_1))); end
code[x1_, x2_] := Block[{t$95$0 = N[(N[(3.0 * x1), $MachinePrecision] * x1), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x1 * x1), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(t$95$0 + N[(2.0 * x2), $MachinePrecision]), $MachinePrecision] - x1), $MachinePrecision] / t$95$1), $MachinePrecision]}, N[(x1 + N[(N[(N[(N[(N[(N[(N[(N[(N[(2.0 * x1), $MachinePrecision] * t$95$2), $MachinePrecision] * N[(t$95$2 - 3.0), $MachinePrecision]), $MachinePrecision] + N[(N[(x1 * x1), $MachinePrecision] * N[(N[(4.0 * t$95$2), $MachinePrecision] - 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] + N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision] + N[(N[(x1 * x1), $MachinePrecision] * x1), $MachinePrecision]), $MachinePrecision] + x1), $MachinePrecision] + N[(3.0 * N[(N[(N[(t$95$0 - N[(2.0 * x2), $MachinePrecision]), $MachinePrecision] - x1), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(3 \cdot x1\right) \cdot x1\\
t_1 := x1 \cdot x1 + 1\\
t_2 := \frac{\left(t\_0 + 2 \cdot x2\right) - x1}{t\_1}\\
x1 + \left(\left(\left(\left(\left(\left(\left(2 \cdot x1\right) \cdot t\_2\right) \cdot \left(t\_2 - 3\right) + \left(x1 \cdot x1\right) \cdot \left(4 \cdot t\_2 - 6\right)\right) \cdot t\_1 + t\_0 \cdot t\_2\right) + \left(x1 \cdot x1\right) \cdot x1\right) + x1\right) + 3 \cdot \frac{\left(t\_0 - 2 \cdot x2\right) - x1}{t\_1}\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 20 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x1 x2)
:precision binary64
(let* ((t_0 (* (* 3.0 x1) x1))
(t_1 (+ (* x1 x1) 1.0))
(t_2 (/ (- (+ t_0 (* 2.0 x2)) x1) t_1)))
(+
x1
(+
(+
(+
(+
(*
(+
(* (* (* 2.0 x1) t_2) (- t_2 3.0))
(* (* x1 x1) (- (* 4.0 t_2) 6.0)))
t_1)
(* t_0 t_2))
(* (* x1 x1) x1))
x1)
(* 3.0 (/ (- (- t_0 (* 2.0 x2)) x1) t_1))))))
double code(double x1, double x2) {
double t_0 = (3.0 * x1) * x1;
double t_1 = (x1 * x1) + 1.0;
double t_2 = ((t_0 + (2.0 * x2)) - x1) / t_1;
return x1 + (((((((((2.0 * x1) * t_2) * (t_2 - 3.0)) + ((x1 * x1) * ((4.0 * t_2) - 6.0))) * t_1) + (t_0 * t_2)) + ((x1 * x1) * x1)) + x1) + (3.0 * (((t_0 - (2.0 * x2)) - x1) / t_1)));
}
real(8) function code(x1, x2)
real(8), intent (in) :: x1
real(8), intent (in) :: x2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = (3.0d0 * x1) * x1
t_1 = (x1 * x1) + 1.0d0
t_2 = ((t_0 + (2.0d0 * x2)) - x1) / t_1
code = x1 + (((((((((2.0d0 * x1) * t_2) * (t_2 - 3.0d0)) + ((x1 * x1) * ((4.0d0 * t_2) - 6.0d0))) * t_1) + (t_0 * t_2)) + ((x1 * x1) * x1)) + x1) + (3.0d0 * (((t_0 - (2.0d0 * x2)) - x1) / t_1)))
end function
public static double code(double x1, double x2) {
double t_0 = (3.0 * x1) * x1;
double t_1 = (x1 * x1) + 1.0;
double t_2 = ((t_0 + (2.0 * x2)) - x1) / t_1;
return x1 + (((((((((2.0 * x1) * t_2) * (t_2 - 3.0)) + ((x1 * x1) * ((4.0 * t_2) - 6.0))) * t_1) + (t_0 * t_2)) + ((x1 * x1) * x1)) + x1) + (3.0 * (((t_0 - (2.0 * x2)) - x1) / t_1)));
}
def code(x1, x2): t_0 = (3.0 * x1) * x1 t_1 = (x1 * x1) + 1.0 t_2 = ((t_0 + (2.0 * x2)) - x1) / t_1 return x1 + (((((((((2.0 * x1) * t_2) * (t_2 - 3.0)) + ((x1 * x1) * ((4.0 * t_2) - 6.0))) * t_1) + (t_0 * t_2)) + ((x1 * x1) * x1)) + x1) + (3.0 * (((t_0 - (2.0 * x2)) - x1) / t_1)))
function code(x1, x2) t_0 = Float64(Float64(3.0 * x1) * x1) t_1 = Float64(Float64(x1 * x1) + 1.0) t_2 = Float64(Float64(Float64(t_0 + Float64(2.0 * x2)) - x1) / t_1) return Float64(x1 + Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(2.0 * x1) * t_2) * Float64(t_2 - 3.0)) + Float64(Float64(x1 * x1) * Float64(Float64(4.0 * t_2) - 6.0))) * t_1) + Float64(t_0 * t_2)) + Float64(Float64(x1 * x1) * x1)) + x1) + Float64(3.0 * Float64(Float64(Float64(t_0 - Float64(2.0 * x2)) - x1) / t_1)))) end
function tmp = code(x1, x2) t_0 = (3.0 * x1) * x1; t_1 = (x1 * x1) + 1.0; t_2 = ((t_0 + (2.0 * x2)) - x1) / t_1; tmp = x1 + (((((((((2.0 * x1) * t_2) * (t_2 - 3.0)) + ((x1 * x1) * ((4.0 * t_2) - 6.0))) * t_1) + (t_0 * t_2)) + ((x1 * x1) * x1)) + x1) + (3.0 * (((t_0 - (2.0 * x2)) - x1) / t_1))); end
code[x1_, x2_] := Block[{t$95$0 = N[(N[(3.0 * x1), $MachinePrecision] * x1), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x1 * x1), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(t$95$0 + N[(2.0 * x2), $MachinePrecision]), $MachinePrecision] - x1), $MachinePrecision] / t$95$1), $MachinePrecision]}, N[(x1 + N[(N[(N[(N[(N[(N[(N[(N[(N[(2.0 * x1), $MachinePrecision] * t$95$2), $MachinePrecision] * N[(t$95$2 - 3.0), $MachinePrecision]), $MachinePrecision] + N[(N[(x1 * x1), $MachinePrecision] * N[(N[(4.0 * t$95$2), $MachinePrecision] - 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] + N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision] + N[(N[(x1 * x1), $MachinePrecision] * x1), $MachinePrecision]), $MachinePrecision] + x1), $MachinePrecision] + N[(3.0 * N[(N[(N[(t$95$0 - N[(2.0 * x2), $MachinePrecision]), $MachinePrecision] - x1), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(3 \cdot x1\right) \cdot x1\\
t_1 := x1 \cdot x1 + 1\\
t_2 := \frac{\left(t\_0 + 2 \cdot x2\right) - x1}{t\_1}\\
x1 + \left(\left(\left(\left(\left(\left(\left(2 \cdot x1\right) \cdot t\_2\right) \cdot \left(t\_2 - 3\right) + \left(x1 \cdot x1\right) \cdot \left(4 \cdot t\_2 - 6\right)\right) \cdot t\_1 + t\_0 \cdot t\_2\right) + \left(x1 \cdot x1\right) \cdot x1\right) + x1\right) + 3 \cdot \frac{\left(t\_0 - 2 \cdot x2\right) - x1}{t\_1}\right)
\end{array}
\end{array}
(FPCore (x1 x2)
:precision binary64
(let* ((t_0 (fma x1 (fma x1 3.0 -1.0) (* 2.0 x2)))
(t_1 (/ t_0 (fma x1 x1 1.0))))
(if (<= x1 -1.5e+64)
(+
x1
(*
(* x1 (* x1 (* x1 x1)))
(+
6.0
(/
(+ -3.0 (/ (+ (fma x2 8.0 -3.0) (/ (fma x2 12.0 -18.0) x1)) x1))
x1))))
(if (<= x1 5.8e+46)
(+
x1
(fma
(- (* x2 -2.0) x1)
3.0
(fma
(fma
x1
(* x1 (fma 4.0 t_1 -6.0))
(* (/ (* (* x1 2.0) t_0) (fma x1 x1 1.0)) (+ -3.0 t_1)))
(fma x1 x1 1.0)
(fma x1 (* (* x1 3.0) 3.0) (fma x1 (* x1 x1) x1)))))
(+
x1
(*
(pow x1 4.0)
(- 6.0 (/ (- 3.0 (/ (fma 4.0 (fma x2 2.0 -3.0) 9.0) x1)) x1))))))))
double code(double x1, double x2) {
double t_0 = fma(x1, fma(x1, 3.0, -1.0), (2.0 * x2));
double t_1 = t_0 / fma(x1, x1, 1.0);
double tmp;
if (x1 <= -1.5e+64) {
tmp = x1 + ((x1 * (x1 * (x1 * x1))) * (6.0 + ((-3.0 + ((fma(x2, 8.0, -3.0) + (fma(x2, 12.0, -18.0) / x1)) / x1)) / x1)));
} else if (x1 <= 5.8e+46) {
tmp = x1 + fma(((x2 * -2.0) - x1), 3.0, fma(fma(x1, (x1 * fma(4.0, t_1, -6.0)), ((((x1 * 2.0) * t_0) / fma(x1, x1, 1.0)) * (-3.0 + t_1))), fma(x1, x1, 1.0), fma(x1, ((x1 * 3.0) * 3.0), fma(x1, (x1 * x1), x1))));
} else {
tmp = x1 + (pow(x1, 4.0) * (6.0 - ((3.0 - (fma(4.0, fma(x2, 2.0, -3.0), 9.0) / x1)) / x1)));
}
return tmp;
}
function code(x1, x2) t_0 = fma(x1, fma(x1, 3.0, -1.0), Float64(2.0 * x2)) t_1 = Float64(t_0 / fma(x1, x1, 1.0)) tmp = 0.0 if (x1 <= -1.5e+64) tmp = Float64(x1 + Float64(Float64(x1 * Float64(x1 * Float64(x1 * x1))) * Float64(6.0 + Float64(Float64(-3.0 + Float64(Float64(fma(x2, 8.0, -3.0) + Float64(fma(x2, 12.0, -18.0) / x1)) / x1)) / x1)))); elseif (x1 <= 5.8e+46) tmp = Float64(x1 + fma(Float64(Float64(x2 * -2.0) - x1), 3.0, fma(fma(x1, Float64(x1 * fma(4.0, t_1, -6.0)), Float64(Float64(Float64(Float64(x1 * 2.0) * t_0) / fma(x1, x1, 1.0)) * Float64(-3.0 + t_1))), fma(x1, x1, 1.0), fma(x1, Float64(Float64(x1 * 3.0) * 3.0), fma(x1, Float64(x1 * x1), x1))))); else tmp = Float64(x1 + Float64((x1 ^ 4.0) * Float64(6.0 - Float64(Float64(3.0 - Float64(fma(4.0, fma(x2, 2.0, -3.0), 9.0) / x1)) / x1)))); end return tmp end
code[x1_, x2_] := Block[{t$95$0 = N[(x1 * N[(x1 * 3.0 + -1.0), $MachinePrecision] + N[(2.0 * x2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(x1 * x1 + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x1, -1.5e+64], N[(x1 + N[(N[(x1 * N[(x1 * N[(x1 * x1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(6.0 + N[(N[(-3.0 + N[(N[(N[(x2 * 8.0 + -3.0), $MachinePrecision] + N[(N[(x2 * 12.0 + -18.0), $MachinePrecision] / x1), $MachinePrecision]), $MachinePrecision] / x1), $MachinePrecision]), $MachinePrecision] / x1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x1, 5.8e+46], N[(x1 + N[(N[(N[(x2 * -2.0), $MachinePrecision] - x1), $MachinePrecision] * 3.0 + N[(N[(x1 * N[(x1 * N[(4.0 * t$95$1 + -6.0), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(x1 * 2.0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(x1 * x1 + 1.0), $MachinePrecision]), $MachinePrecision] * N[(-3.0 + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x1 * x1 + 1.0), $MachinePrecision] + N[(x1 * N[(N[(x1 * 3.0), $MachinePrecision] * 3.0), $MachinePrecision] + N[(x1 * N[(x1 * x1), $MachinePrecision] + x1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x1 + N[(N[Power[x1, 4.0], $MachinePrecision] * N[(6.0 - N[(N[(3.0 - N[(N[(4.0 * N[(x2 * 2.0 + -3.0), $MachinePrecision] + 9.0), $MachinePrecision] / x1), $MachinePrecision]), $MachinePrecision] / x1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(x1, \mathsf{fma}\left(x1, 3, -1\right), 2 \cdot x2\right)\\
t_1 := \frac{t\_0}{\mathsf{fma}\left(x1, x1, 1\right)}\\
\mathbf{if}\;x1 \leq -1.5 \cdot 10^{+64}:\\
\;\;\;\;x1 + \left(x1 \cdot \left(x1 \cdot \left(x1 \cdot x1\right)\right)\right) \cdot \left(6 + \frac{-3 + \frac{\mathsf{fma}\left(x2, 8, -3\right) + \frac{\mathsf{fma}\left(x2, 12, -18\right)}{x1}}{x1}}{x1}\right)\\
\mathbf{elif}\;x1 \leq 5.8 \cdot 10^{+46}:\\
\;\;\;\;x1 + \mathsf{fma}\left(x2 \cdot -2 - x1, 3, \mathsf{fma}\left(\mathsf{fma}\left(x1, x1 \cdot \mathsf{fma}\left(4, t\_1, -6\right), \frac{\left(x1 \cdot 2\right) \cdot t\_0}{\mathsf{fma}\left(x1, x1, 1\right)} \cdot \left(-3 + t\_1\right)\right), \mathsf{fma}\left(x1, x1, 1\right), \mathsf{fma}\left(x1, \left(x1 \cdot 3\right) \cdot 3, \mathsf{fma}\left(x1, x1 \cdot x1, x1\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x1 + {x1}^{4} \cdot \left(6 - \frac{3 - \frac{\mathsf{fma}\left(4, \mathsf{fma}\left(x2, 2, -3\right), 9\right)}{x1}}{x1}\right)\\
\end{array}
\end{array}
if x1 < -1.5000000000000001e64Initial program 25.0%
Taylor expanded in x1 around -inf
lower-*.f64N/A
lower-pow.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites100.0%
Applied rewrites94.2%
Applied rewrites100.0%
if -1.5000000000000001e64 < x1 < 5.8000000000000004e46Initial program 99.3%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6499.3
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6499.3
lift--.f64N/A
sub-negN/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6499.3
Applied rewrites99.3%
Taylor expanded in x1 around inf
Applied rewrites97.2%
Taylor expanded in x1 around 0
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6499.4
Applied rewrites99.4%
Applied rewrites99.7%
if 5.8000000000000004e46 < x1 Initial program 36.1%
Taylor expanded in x1 around -inf
lower-*.f64N/A
lower-pow.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
Applied rewrites100.0%
Final simplification99.8%
(FPCore (x1 x2)
:precision binary64
(let* ((t_0 (* x1 (* x1 x1)))
(t_1 (* x1 (* x1 3.0)))
(t_2 (+ (* x1 x1) 1.0))
(t_3 (/ (- (+ t_1 (* 2.0 x2)) x1) t_2))
(t_4 (* (* x1 2.0) t_3))
(t_5 (* (* x1 x1) (- (* t_3 4.0) 6.0))))
(if (<=
(+
x1
(+
(+ x1 (+ (+ (* t_2 (+ (* t_4 (- t_3 3.0)) t_5)) (* t_1 t_3)) t_0))
(* 3.0 (/ (- (- t_1 (* 2.0 x2)) x1) t_2))))
INFINITY)
(+
x1
(+
(+
x1
(+
t_0
(+
(*
t_2
(+
t_5
(*
t_4
(-
(/
1.0
(/ (fma x1 x1 1.0) (fma 2.0 x2 (fma x1 (* x1 3.0) (- x1)))))
3.0))))
(* t_1 3.0))))
(* 3.0 (- (* x2 -2.0) x1))))
(+ x1 (* 6.0 (* (* x1 x1) (* x1 x1)))))))
double code(double x1, double x2) {
double t_0 = x1 * (x1 * x1);
double t_1 = x1 * (x1 * 3.0);
double t_2 = (x1 * x1) + 1.0;
double t_3 = ((t_1 + (2.0 * x2)) - x1) / t_2;
double t_4 = (x1 * 2.0) * t_3;
double t_5 = (x1 * x1) * ((t_3 * 4.0) - 6.0);
double tmp;
if ((x1 + ((x1 + (((t_2 * ((t_4 * (t_3 - 3.0)) + t_5)) + (t_1 * t_3)) + t_0)) + (3.0 * (((t_1 - (2.0 * x2)) - x1) / t_2)))) <= ((double) INFINITY)) {
tmp = x1 + ((x1 + (t_0 + ((t_2 * (t_5 + (t_4 * ((1.0 / (fma(x1, x1, 1.0) / fma(2.0, x2, fma(x1, (x1 * 3.0), -x1)))) - 3.0)))) + (t_1 * 3.0)))) + (3.0 * ((x2 * -2.0) - x1)));
} else {
tmp = x1 + (6.0 * ((x1 * x1) * (x1 * x1)));
}
return tmp;
}
function code(x1, x2) t_0 = Float64(x1 * Float64(x1 * x1)) t_1 = Float64(x1 * Float64(x1 * 3.0)) t_2 = Float64(Float64(x1 * x1) + 1.0) t_3 = Float64(Float64(Float64(t_1 + Float64(2.0 * x2)) - x1) / t_2) t_4 = Float64(Float64(x1 * 2.0) * t_3) t_5 = Float64(Float64(x1 * x1) * Float64(Float64(t_3 * 4.0) - 6.0)) tmp = 0.0 if (Float64(x1 + Float64(Float64(x1 + Float64(Float64(Float64(t_2 * Float64(Float64(t_4 * Float64(t_3 - 3.0)) + t_5)) + Float64(t_1 * t_3)) + t_0)) + Float64(3.0 * Float64(Float64(Float64(t_1 - Float64(2.0 * x2)) - x1) / t_2)))) <= Inf) tmp = Float64(x1 + Float64(Float64(x1 + Float64(t_0 + Float64(Float64(t_2 * Float64(t_5 + Float64(t_4 * Float64(Float64(1.0 / Float64(fma(x1, x1, 1.0) / fma(2.0, x2, fma(x1, Float64(x1 * 3.0), Float64(-x1))))) - 3.0)))) + Float64(t_1 * 3.0)))) + Float64(3.0 * Float64(Float64(x2 * -2.0) - x1)))); else tmp = Float64(x1 + Float64(6.0 * Float64(Float64(x1 * x1) * Float64(x1 * x1)))); end return tmp end
code[x1_, x2_] := Block[{t$95$0 = N[(x1 * N[(x1 * x1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x1 * N[(x1 * 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x1 * x1), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(t$95$1 + N[(2.0 * x2), $MachinePrecision]), $MachinePrecision] - x1), $MachinePrecision] / t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(N[(x1 * 2.0), $MachinePrecision] * t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[(N[(x1 * x1), $MachinePrecision] * N[(N[(t$95$3 * 4.0), $MachinePrecision] - 6.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x1 + N[(N[(x1 + N[(N[(N[(t$95$2 * N[(N[(t$95$4 * N[(t$95$3 - 3.0), $MachinePrecision]), $MachinePrecision] + t$95$5), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * t$95$3), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] + N[(3.0 * N[(N[(N[(t$95$1 - N[(2.0 * x2), $MachinePrecision]), $MachinePrecision] - x1), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(x1 + N[(N[(x1 + N[(t$95$0 + N[(N[(t$95$2 * N[(t$95$5 + N[(t$95$4 * N[(N[(1.0 / N[(N[(x1 * x1 + 1.0), $MachinePrecision] / N[(2.0 * x2 + N[(x1 * N[(x1 * 3.0), $MachinePrecision] + (-x1)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(3.0 * N[(N[(x2 * -2.0), $MachinePrecision] - x1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x1 + N[(6.0 * N[(N[(x1 * x1), $MachinePrecision] * N[(x1 * x1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x1 \cdot \left(x1 \cdot x1\right)\\
t_1 := x1 \cdot \left(x1 \cdot 3\right)\\
t_2 := x1 \cdot x1 + 1\\
t_3 := \frac{\left(t\_1 + 2 \cdot x2\right) - x1}{t\_2}\\
t_4 := \left(x1 \cdot 2\right) \cdot t\_3\\
t_5 := \left(x1 \cdot x1\right) \cdot \left(t\_3 \cdot 4 - 6\right)\\
\mathbf{if}\;x1 + \left(\left(x1 + \left(\left(t\_2 \cdot \left(t\_4 \cdot \left(t\_3 - 3\right) + t\_5\right) + t\_1 \cdot t\_3\right) + t\_0\right)\right) + 3 \cdot \frac{\left(t\_1 - 2 \cdot x2\right) - x1}{t\_2}\right) \leq \infty:\\
\;\;\;\;x1 + \left(\left(x1 + \left(t\_0 + \left(t\_2 \cdot \left(t\_5 + t\_4 \cdot \left(\frac{1}{\frac{\mathsf{fma}\left(x1, x1, 1\right)}{\mathsf{fma}\left(2, x2, \mathsf{fma}\left(x1, x1 \cdot 3, -x1\right)\right)}} - 3\right)\right) + t\_1 \cdot 3\right)\right)\right) + 3 \cdot \left(x2 \cdot -2 - x1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x1 + 6 \cdot \left(\left(x1 \cdot x1\right) \cdot \left(x1 \cdot x1\right)\right)\\
\end{array}
\end{array}
if (+.f64 x1 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 (+.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) x1) (/.f64 (-.f64 (+.f64 (*.f64 (*.f64 #s(literal 3 binary64) x1) x1) (*.f64 #s(literal 2 binary64) x2)) x1) (+.f64 (*.f64 x1 x1) #s(literal 1 binary64)))) (-.f64 (/.f64 (-.f64 (+.f64 (*.f64 (*.f64 #s(literal 3 binary64) x1) x1) (*.f64 #s(literal 2 binary64) x2)) x1) (+.f64 (*.f64 x1 x1) #s(literal 1 binary64))) #s(literal 3 binary64))) (*.f64 (*.f64 x1 x1) (-.f64 (*.f64 #s(literal 4 binary64) (/.f64 (-.f64 (+.f64 (*.f64 (*.f64 #s(literal 3 binary64) x1) x1) (*.f64 #s(literal 2 binary64) x2)) x1) (+.f64 (*.f64 x1 x1) #s(literal 1 binary64)))) #s(literal 6 binary64)))) (+.f64 (*.f64 x1 x1) #s(literal 1 binary64))) (*.f64 (*.f64 (*.f64 #s(literal 3 binary64) x1) x1) (/.f64 (-.f64 (+.f64 (*.f64 (*.f64 #s(literal 3 binary64) x1) x1) (*.f64 #s(literal 2 binary64) x2)) x1) (+.f64 (*.f64 x1 x1) #s(literal 1 binary64))))) (*.f64 (*.f64 x1 x1) x1)) x1) (*.f64 #s(literal 3 binary64) (/.f64 (-.f64 (-.f64 (*.f64 (*.f64 #s(literal 3 binary64) x1) x1) (*.f64 #s(literal 2 binary64) x2)) x1) (+.f64 (*.f64 x1 x1) #s(literal 1 binary64)))))) < +inf.0Initial program 99.4%
lift-/.f64N/A
clear-numN/A
lower-/.f64N/A
lower-/.f6499.4
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6499.4
lift--.f64N/A
sub-negN/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6499.4
Applied rewrites99.4%
Taylor expanded in x1 around inf
Applied rewrites98.4%
Taylor expanded in x1 around 0
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6499.3
Applied rewrites99.3%
if +inf.0 < (+.f64 x1 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 (+.f64 (*.f64 (*.f64 (*.f64 #s(literal 2 binary64) x1) (/.f64 (-.f64 (+.f64 (*.f64 (*.f64 #s(literal 3 binary64) x1) x1) (*.f64 #s(literal 2 binary64) x2)) x1) (+.f64 (*.f64 x1 x1) #s(literal 1 binary64)))) (-.f64 (/.f64 (-.f64 (+.f64 (*.f64 (*.f64 #s(literal 3 binary64) x1) x1) (*.f64 #s(literal 2 binary64) x2)) x1) (+.f64 (*.f64 x1 x1) #s(literal 1 binary64))) #s(literal 3 binary64))) (*.f64 (*.f64 x1 x1) (-.f64 (*.f64 #s(literal 4 binary64) (/.f64 (-.f64 (+.f64 (*.f64 (*.f64 #s(literal 3 binary64) x1) x1) (*.f64 #s(literal 2 binary64) x2)) x1) (+.f64 (*.f64 x1 x1) #s(literal 1 binary64)))) #s(literal 6 binary64)))) (+.f64 (*.f64 x1 x1) #s(literal 1 binary64))) (*.f64 (*.f64 (*.f64 #s(literal 3 binary64) x1) x1) (/.f64 (-.f64 (+.f64 (*.f64 (*.f64 #s(literal 3 binary64) x1) x1) (*.f64 #s(literal 2 binary64) x2)) x1) (+.f64 (*.f64 x1 x1) #s(literal 1 binary64))))) (*.f64 (*.f64 x1 x1) x1)) x1) (*.f64 #s(literal 3 binary64) (/.f64 (-.f64 (-.f64 (*.f64 (*.f64 #s(literal 3 binary64) x1) x1) (*.f64 #s(literal 2 binary64) x2)) x1) (+.f64 (*.f64 x1 x1) #s(literal 1 binary64)))))) Initial program 0.0%
Taylor expanded in x1 around inf
lower-*.f64N/A
lower-pow.f6499.1
Applied rewrites99.1%
Applied rewrites99.1%
Final simplification99.3%
herbie shell --seed 2024223
(FPCore (x1 x2)
:name "Rosa's FloatVsDoubleBenchmark"
:precision binary64
(+ x1 (+ (+ (+ (+ (* (+ (* (* (* 2.0 x1) (/ (- (+ (* (* 3.0 x1) x1) (* 2.0 x2)) x1) (+ (* x1 x1) 1.0))) (- (/ (- (+ (* (* 3.0 x1) x1) (* 2.0 x2)) x1) (+ (* x1 x1) 1.0)) 3.0)) (* (* x1 x1) (- (* 4.0 (/ (- (+ (* (* 3.0 x1) x1) (* 2.0 x2)) x1) (+ (* x1 x1) 1.0))) 6.0))) (+ (* x1 x1) 1.0)) (* (* (* 3.0 x1) x1) (/ (- (+ (* (* 3.0 x1) x1) (* 2.0 x2)) x1) (+ (* x1 x1) 1.0)))) (* (* x1 x1) x1)) x1) (* 3.0 (/ (- (- (* (* 3.0 x1) x1) (* 2.0 x2)) x1) (+ (* x1 x1) 1.0))))))