
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 - a)) + ((b * b) * (3.0d0 + a))))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(3.0 + a))))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(3.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 - a)) + ((b * b) * (3.0d0 + a))))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(3.0 + a))))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(3.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\end{array}
(FPCore (a b) :precision binary64 (+ (+ (pow (sqrt (hypot a b)) 8.0) (* b (* b 12.0))) -1.0))
double code(double a, double b) {
return (pow(sqrt(hypot(a, b)), 8.0) + (b * (b * 12.0))) + -1.0;
}
public static double code(double a, double b) {
return (Math.pow(Math.sqrt(Math.hypot(a, b)), 8.0) + (b * (b * 12.0))) + -1.0;
}
def code(a, b): return (math.pow(math.sqrt(math.hypot(a, b)), 8.0) + (b * (b * 12.0))) + -1.0
function code(a, b) return Float64(Float64((sqrt(hypot(a, b)) ^ 8.0) + Float64(b * Float64(b * 12.0))) + -1.0) end
function tmp = code(a, b) tmp = ((sqrt(hypot(a, b)) ^ 8.0) + (b * (b * 12.0))) + -1.0; end
code[a_, b_] := N[(N[(N[Power[N[Sqrt[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision]], $MachinePrecision], 8.0], $MachinePrecision] + N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\sqrt{\mathsf{hypot}\left(a, b\right)}\right)}^{8} + b \cdot \left(b \cdot 12\right)\right) + -1
\end{array}
Initial program 74.8%
sub-neg74.8%
fma-def74.8%
fma-def77.6%
+-commutative77.6%
metadata-eval77.6%
Simplified77.6%
fma-def77.6%
metadata-eval77.6%
sqrt-pow277.7%
hypot-udef77.7%
add-sqr-sqrt77.4%
unpow-prod-down77.4%
Applied egg-rr77.4%
pow-sqr77.4%
metadata-eval77.4%
Simplified77.4%
Taylor expanded in a around 0 99.1%
unpow299.1%
associate-*r*99.1%
Simplified99.1%
Taylor expanded in b around 0 99.1%
unpow299.1%
*-commutative99.1%
associate-*r*99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))))
(if (<= t_0 INFINITY)
(+ -1.0 t_0)
(+ -1.0 (* (* a a) (+ (* a a) (* 4.0 (- 1.0 a))))))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = -1.0 + t_0;
} else {
tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a))));
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = -1.0 + t_0;
} else {
tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a))));
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))) tmp = 0 if t_0 <= math.inf: tmp = -1.0 + t_0 else: tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a)))) return tmp
function code(a, b) t_0 = Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(-1.0 + t_0); else tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(Float64(a * a) + Float64(4.0 * Float64(1.0 - a))))); end return tmp end
function tmp_2 = code(a, b) t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = -1.0 + t_0; else tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a)))); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(-1.0 + t$95$0), $MachinePrecision], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + N[(4.0 * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;-1 + t_0\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 4 \cdot \left(1 - a\right)\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) < +inf.0Initial program 99.8%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def10.9%
+-commutative10.9%
metadata-eval10.9%
Simplified10.9%
Taylor expanded in b around 0 25.4%
associate-*r*25.4%
unpow225.4%
Simplified25.4%
sqr-pow25.4%
metadata-eval25.4%
pow225.4%
metadata-eval25.4%
pow225.4%
fma-def25.4%
*-commutative25.4%
Applied egg-rr25.4%
fma-udef25.4%
associate-*r*25.4%
distribute-rgt-out94.2%
Applied egg-rr94.2%
Final simplification98.4%
(FPCore (a b) :precision binary64 (if (<= (* b b) 10000000.0) (+ -1.0 (* (* a a) (+ (* a a) (* 4.0 (- 1.0 a))))) (+ -1.0 (+ (* 12.0 (* b b)) (pow b 4.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 10000000.0) {
tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a))));
} else {
tmp = -1.0 + ((12.0 * (b * b)) + pow(b, 4.0));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 10000000.0d0) then
tmp = (-1.0d0) + ((a * a) * ((a * a) + (4.0d0 * (1.0d0 - a))))
else
tmp = (-1.0d0) + ((12.0d0 * (b * b)) + (b ** 4.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 10000000.0) {
tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a))));
} else {
tmp = -1.0 + ((12.0 * (b * b)) + Math.pow(b, 4.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 10000000.0: tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a)))) else: tmp = -1.0 + ((12.0 * (b * b)) + math.pow(b, 4.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 10000000.0) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(Float64(a * a) + Float64(4.0 * Float64(1.0 - a))))); else tmp = Float64(-1.0 + Float64(Float64(12.0 * Float64(b * b)) + (b ^ 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 10000000.0) tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a)))); else tmp = -1.0 + ((12.0 * (b * b)) + (b ^ 4.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 10000000.0], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + N[(4.0 * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(12.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10000000:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 4 \cdot \left(1 - a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(12 \cdot \left(b \cdot b\right) + {b}^{4}\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1e7Initial program 85.7%
sub-neg85.7%
fma-def85.7%
fma-def85.7%
+-commutative85.7%
metadata-eval85.7%
Simplified85.7%
Taylor expanded in b around 0 84.5%
associate-*r*84.5%
unpow284.5%
Simplified84.5%
sqr-pow84.4%
metadata-eval84.4%
pow284.4%
metadata-eval84.4%
pow284.4%
fma-def84.4%
*-commutative84.4%
Applied egg-rr84.4%
fma-udef84.4%
associate-*r*84.4%
distribute-rgt-out98.6%
Applied egg-rr98.6%
if 1e7 < (*.f64 b b) Initial program 64.1%
sub-neg64.1%
fma-def64.1%
fma-def69.6%
+-commutative69.6%
metadata-eval69.6%
Simplified69.6%
Taylor expanded in a around 0 64.8%
associate-+r+64.8%
associate-*r*64.8%
distribute-rgt-out77.2%
metadata-eval77.2%
distribute-lft-in77.2%
unpow277.2%
distribute-rgt-in77.2%
metadata-eval77.2%
Simplified77.2%
Taylor expanded in a around 0 90.5%
unpow290.5%
Simplified90.5%
Final simplification94.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1000000000000.0) (+ -1.0 (* (* a a) (+ (* a a) (* 4.0 (- 1.0 a))))) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1000000000000.0) {
tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a))));
} else {
tmp = -1.0 + pow(b, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 1000000000000.0d0) then
tmp = (-1.0d0) + ((a * a) * ((a * a) + (4.0d0 * (1.0d0 - a))))
else
tmp = (-1.0d0) + (b ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 1000000000000.0) {
tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a))));
} else {
tmp = -1.0 + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1000000000000.0: tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a)))) else: tmp = -1.0 + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1000000000000.0) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(Float64(a * a) + Float64(4.0 * Float64(1.0 - a))))); else tmp = Float64(-1.0 + (b ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1000000000000.0) tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a)))); else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1000000000000.0], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + N[(4.0 * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 1000000000000:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 4 \cdot \left(1 - a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 1e12Initial program 85.2%
sub-neg85.2%
fma-def85.2%
fma-def85.2%
+-commutative85.2%
metadata-eval85.2%
Simplified85.2%
Taylor expanded in b around 0 83.2%
associate-*r*83.2%
unpow283.2%
Simplified83.2%
sqr-pow83.1%
metadata-eval83.1%
pow283.1%
metadata-eval83.1%
pow283.1%
fma-def83.1%
*-commutative83.1%
Applied egg-rr83.1%
fma-udef83.1%
associate-*r*83.1%
distribute-rgt-out97.9%
Applied egg-rr97.9%
if 1e12 < (*.f64 b b) Initial program 64.4%
sub-neg64.4%
fma-def64.4%
fma-def69.9%
+-commutative69.9%
metadata-eval69.9%
Simplified69.9%
Taylor expanded in b around inf 91.1%
Final simplification94.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 10000000.0) (+ -1.0 (* (* a a) (+ (* a a) (* 4.0 (- 1.0 a))))) (+ -1.0 (* (* b b) (+ 12.0 (* b b))))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 10000000.0) {
tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a))));
} else {
tmp = -1.0 + ((b * b) * (12.0 + (b * b)));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 10000000.0d0) then
tmp = (-1.0d0) + ((a * a) * ((a * a) + (4.0d0 * (1.0d0 - a))))
else
tmp = (-1.0d0) + ((b * b) * (12.0d0 + (b * b)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 10000000.0) {
tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a))));
} else {
tmp = -1.0 + ((b * b) * (12.0 + (b * b)));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 10000000.0: tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a)))) else: tmp = -1.0 + ((b * b) * (12.0 + (b * b))) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 10000000.0) tmp = Float64(-1.0 + Float64(Float64(a * a) * Float64(Float64(a * a) + Float64(4.0 * Float64(1.0 - a))))); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(12.0 + Float64(b * b)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 10000000.0) tmp = -1.0 + ((a * a) * ((a * a) + (4.0 * (1.0 - a)))); else tmp = -1.0 + ((b * b) * (12.0 + (b * b))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 10000000.0], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + N[(4.0 * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(12.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10000000:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 4 \cdot \left(1 - a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(12 + b \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1e7Initial program 85.7%
sub-neg85.7%
fma-def85.7%
fma-def85.7%
+-commutative85.7%
metadata-eval85.7%
Simplified85.7%
Taylor expanded in b around 0 84.5%
associate-*r*84.5%
unpow284.5%
Simplified84.5%
sqr-pow84.4%
metadata-eval84.4%
pow284.4%
metadata-eval84.4%
pow284.4%
fma-def84.4%
*-commutative84.4%
Applied egg-rr84.4%
fma-udef84.4%
associate-*r*84.4%
distribute-rgt-out98.6%
Applied egg-rr98.6%
if 1e7 < (*.f64 b b) Initial program 64.1%
sub-neg64.1%
fma-def64.1%
fma-def69.6%
+-commutative69.6%
metadata-eval69.6%
Simplified69.6%
Taylor expanded in a around 0 64.8%
associate-+r+64.8%
associate-*r*64.8%
distribute-rgt-out77.2%
metadata-eval77.2%
distribute-lft-in77.2%
unpow277.2%
distribute-rgt-in77.2%
metadata-eval77.2%
Simplified77.2%
Taylor expanded in a around 0 90.5%
unpow290.5%
Simplified90.5%
+-commutative90.5%
sqr-pow90.3%
metadata-eval90.3%
pow290.3%
metadata-eval90.3%
pow290.3%
distribute-rgt-out90.3%
Applied egg-rr90.3%
Final simplification94.4%
(FPCore (a b) :precision binary64 (if (or (<= a -7e+153) (not (<= a 6.8e+153))) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) (+ 12.0 (* b b))))))
double code(double a, double b) {
double tmp;
if ((a <= -7e+153) || !(a <= 6.8e+153)) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * (12.0 + (b * b)));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-7d+153)) .or. (.not. (a <= 6.8d+153))) then
tmp = (-1.0d0) + ((a * a) * 4.0d0)
else
tmp = (-1.0d0) + ((b * b) * (12.0d0 + (b * b)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -7e+153) || !(a <= 6.8e+153)) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * (12.0 + (b * b)));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -7e+153) or not (a <= 6.8e+153): tmp = -1.0 + ((a * a) * 4.0) else: tmp = -1.0 + ((b * b) * (12.0 + (b * b))) return tmp
function code(a, b) tmp = 0.0 if ((a <= -7e+153) || !(a <= 6.8e+153)) tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(12.0 + Float64(b * b)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -7e+153) || ~((a <= 6.8e+153))) tmp = -1.0 + ((a * a) * 4.0); else tmp = -1.0 + ((b * b) * (12.0 + (b * b))); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -7e+153], N[Not[LessEqual[a, 6.8e+153]], $MachinePrecision]], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(12.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -7 \cdot 10^{+153} \lor \neg \left(a \leq 6.8 \cdot 10^{+153}\right):\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(12 + b \cdot b\right)\\
\end{array}
\end{array}
if a < -6.9999999999999998e153 or 6.7999999999999995e153 < a Initial program 27.1%
sub-neg27.1%
fma-def27.1%
fma-def27.1%
+-commutative27.1%
metadata-eval27.1%
Simplified27.1%
Taylor expanded in b around 0 45.8%
associate-*r*45.8%
unpow245.8%
Simplified45.8%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
if -6.9999999999999998e153 < a < 6.7999999999999995e153Initial program 89.1%
sub-neg89.1%
fma-def89.1%
fma-def92.7%
+-commutative92.7%
metadata-eval92.7%
Simplified92.7%
Taylor expanded in a around 0 70.3%
associate-+r+70.3%
associate-*r*70.3%
distribute-rgt-out78.5%
metadata-eval78.5%
distribute-lft-in78.5%
unpow278.5%
distribute-rgt-in78.5%
metadata-eval78.5%
Simplified78.5%
Taylor expanded in a around 0 83.0%
unpow283.0%
Simplified83.0%
+-commutative83.0%
sqr-pow82.9%
metadata-eval82.9%
pow282.9%
metadata-eval82.9%
pow282.9%
distribute-rgt-out82.9%
Applied egg-rr82.9%
Final simplification86.8%
(FPCore (a b) :precision binary64 (if (<= b 1.5e+89) (+ -1.0 (* (* a a) 4.0)) (* (+ a 3.0) (* (* b b) 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 1.5e+89) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = (a + 3.0) * ((b * b) * 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 1.5d+89) then
tmp = (-1.0d0) + ((a * a) * 4.0d0)
else
tmp = (a + 3.0d0) * ((b * b) * 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 1.5e+89) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = (a + 3.0) * ((b * b) * 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.5e+89: tmp = -1.0 + ((a * a) * 4.0) else: tmp = (a + 3.0) * ((b * b) * 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.5e+89) tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); else tmp = Float64(Float64(a + 3.0) * Float64(Float64(b * b) * 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.5e+89) tmp = -1.0 + ((a * a) * 4.0); else tmp = (a + 3.0) * ((b * b) * 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.5e+89], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(a + 3.0), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.5 \cdot 10^{+89}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;\left(a + 3\right) \cdot \left(\left(b \cdot b\right) \cdot 4\right)\\
\end{array}
\end{array}
if b < 1.50000000000000006e89Initial program 76.9%
sub-neg76.9%
fma-def76.9%
fma-def78.9%
+-commutative78.9%
metadata-eval78.9%
Simplified78.9%
Taylor expanded in b around 0 60.8%
associate-*r*60.8%
unpow260.8%
Simplified60.8%
Taylor expanded in a around 0 57.5%
unpow257.5%
Simplified57.5%
if 1.50000000000000006e89 < b Initial program 65.2%
sub-neg65.2%
fma-def65.2%
fma-def71.7%
+-commutative71.7%
metadata-eval71.7%
Simplified71.7%
fma-def71.7%
metadata-eval71.7%
sqrt-pow271.7%
hypot-udef71.7%
add-sqr-sqrt71.7%
unpow-prod-down71.7%
Applied egg-rr71.7%
pow-sqr71.7%
metadata-eval71.7%
Simplified71.7%
Taylor expanded in b around inf 71.0%
+-commutative71.0%
unpow271.0%
associate-*l*71.0%
Simplified71.0%
Taylor expanded in b around inf 71.0%
unpow271.0%
associate-*r*71.0%
*-commutative71.0%
Simplified71.0%
Final simplification59.9%
(FPCore (a b) :precision binary64 (if (<= b 1.35e+127) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* 4.0 (* b (* b 3.0))))))
double code(double a, double b) {
double tmp;
if (b <= 1.35e+127) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + (4.0 * (b * (b * 3.0)));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 1.35d+127) then
tmp = (-1.0d0) + ((a * a) * 4.0d0)
else
tmp = (-1.0d0) + (4.0d0 * (b * (b * 3.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 1.35e+127) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + (4.0 * (b * (b * 3.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.35e+127: tmp = -1.0 + ((a * a) * 4.0) else: tmp = -1.0 + (4.0 * (b * (b * 3.0))) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.35e+127) tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); else tmp = Float64(-1.0 + Float64(4.0 * Float64(b * Float64(b * 3.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.35e+127) tmp = -1.0 + ((a * a) * 4.0); else tmp = -1.0 + (4.0 * (b * (b * 3.0))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.35e+127], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(4.0 * N[(b * N[(b * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.35 \cdot 10^{+127}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + 4 \cdot \left(b \cdot \left(b \cdot 3\right)\right)\\
\end{array}
\end{array}
if b < 1.3500000000000001e127Initial program 75.7%
sub-neg75.7%
fma-def75.7%
fma-def77.5%
+-commutative77.5%
metadata-eval77.5%
Simplified77.5%
Taylor expanded in b around 0 58.1%
associate-*r*58.1%
unpow258.1%
Simplified58.1%
Taylor expanded in a around 0 57.2%
unpow257.2%
Simplified57.2%
if 1.3500000000000001e127 < b Initial program 69.4%
sub-neg69.4%
fma-def69.4%
fma-def77.8%
+-commutative77.8%
metadata-eval77.8%
Simplified77.8%
fma-def77.8%
metadata-eval77.8%
sqrt-pow277.8%
hypot-udef77.8%
add-sqr-sqrt77.8%
unpow-prod-down77.8%
Applied egg-rr77.8%
pow-sqr77.8%
metadata-eval77.8%
Simplified77.8%
Taylor expanded in b around inf 76.1%
+-commutative76.1%
unpow276.1%
associate-*l*76.1%
Simplified76.1%
Taylor expanded in a around 0 84.8%
Final simplification61.1%
(FPCore (a b) :precision binary64 (if (<= b 3100.0) -1.0 (* a (* (* b b) 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 3100.0) {
tmp = -1.0;
} else {
tmp = a * ((b * b) * 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 3100.0d0) then
tmp = -1.0d0
else
tmp = a * ((b * b) * 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 3100.0) {
tmp = -1.0;
} else {
tmp = a * ((b * b) * 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 3100.0: tmp = -1.0 else: tmp = a * ((b * b) * 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 3100.0) tmp = -1.0; else tmp = Float64(a * Float64(Float64(b * b) * 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 3100.0) tmp = -1.0; else tmp = a * ((b * b) * 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 3100.0], -1.0, N[(a * N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3100:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(\left(b \cdot b\right) \cdot 4\right)\\
\end{array}
\end{array}
if b < 3100Initial program 77.4%
sub-neg77.4%
fma-def77.4%
fma-def79.5%
+-commutative79.5%
metadata-eval79.5%
Simplified79.5%
Taylor expanded in a around 0 56.5%
associate-+r+56.5%
associate-*r*56.5%
distribute-rgt-out60.7%
metadata-eval60.7%
distribute-lft-in60.7%
unpow260.7%
distribute-rgt-in60.7%
metadata-eval60.7%
Simplified60.7%
Taylor expanded in b around 0 35.7%
if 3100 < b Initial program 67.5%
sub-neg67.5%
fma-def67.5%
fma-def72.1%
+-commutative72.1%
metadata-eval72.1%
Simplified72.1%
fma-def72.1%
metadata-eval72.1%
sqrt-pow272.3%
hypot-udef72.3%
add-sqr-sqrt71.9%
unpow-prod-down71.8%
Applied egg-rr71.8%
pow-sqr71.9%
metadata-eval71.9%
Simplified71.9%
Taylor expanded in b around inf 51.7%
+-commutative51.7%
unpow251.7%
associate-*l*51.7%
Simplified51.7%
Taylor expanded in a around inf 38.1%
unpow238.1%
associate-*r*38.1%
*-commutative38.1%
associate-*l*38.1%
Simplified38.1%
Final simplification36.3%
(FPCore (a b) :precision binary64 (if (<= b 6.4e+88) (+ -1.0 (* (* a a) 4.0)) (* a (* (* b b) 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 6.4e+88) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = a * ((b * b) * 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 6.4d+88) then
tmp = (-1.0d0) + ((a * a) * 4.0d0)
else
tmp = a * ((b * b) * 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 6.4e+88) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = a * ((b * b) * 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 6.4e+88: tmp = -1.0 + ((a * a) * 4.0) else: tmp = a * ((b * b) * 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 6.4e+88) tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); else tmp = Float64(a * Float64(Float64(b * b) * 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 6.4e+88) tmp = -1.0 + ((a * a) * 4.0); else tmp = a * ((b * b) * 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 6.4e+88], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(a * N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.4 \cdot 10^{+88}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(\left(b \cdot b\right) \cdot 4\right)\\
\end{array}
\end{array}
if b < 6.3999999999999997e88Initial program 76.9%
sub-neg76.9%
fma-def76.9%
fma-def78.9%
+-commutative78.9%
metadata-eval78.9%
Simplified78.9%
Taylor expanded in b around 0 60.8%
associate-*r*60.8%
unpow260.8%
Simplified60.8%
Taylor expanded in a around 0 57.5%
unpow257.5%
Simplified57.5%
if 6.3999999999999997e88 < b Initial program 65.2%
sub-neg65.2%
fma-def65.2%
fma-def71.7%
+-commutative71.7%
metadata-eval71.7%
Simplified71.7%
fma-def71.7%
metadata-eval71.7%
sqrt-pow271.7%
hypot-udef71.7%
add-sqr-sqrt71.7%
unpow-prod-down71.7%
Applied egg-rr71.7%
pow-sqr71.7%
metadata-eval71.7%
Simplified71.7%
Taylor expanded in b around inf 71.0%
+-commutative71.0%
unpow271.0%
associate-*l*71.0%
Simplified71.0%
Taylor expanded in a around inf 52.7%
unpow252.7%
associate-*r*52.7%
*-commutative52.7%
associate-*l*52.7%
Simplified52.7%
Final simplification56.6%
(FPCore (a b) :precision binary64 -1.0)
double code(double a, double b) {
return -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = -1.0d0
end function
public static double code(double a, double b) {
return -1.0;
}
def code(a, b): return -1.0
function code(a, b) return -1.0 end
function tmp = code(a, b) tmp = -1.0; end
code[a_, b_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 74.8%
sub-neg74.8%
fma-def74.8%
fma-def77.6%
+-commutative77.6%
metadata-eval77.6%
Simplified77.6%
Taylor expanded in a around 0 59.9%
associate-+r+59.9%
associate-*r*59.9%
distribute-rgt-out66.1%
metadata-eval66.1%
distribute-lft-in66.1%
unpow266.1%
distribute-rgt-in66.1%
metadata-eval66.1%
Simplified66.1%
Taylor expanded in b around 0 26.8%
Final simplification26.8%
herbie shell --seed 2023200
(FPCore (a b)
:name "Bouland and Aaronson, Equation (24)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))