
(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
(if (<=
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))
INFINITY)
(+
(pow (hypot a b) 4.0)
(fma 4.0 (- (fma (* b b) (+ a 3.0) (* a a)) (pow a 3.0)) -1.0))
(+ -1.0 (pow a 4.0))))
double code(double a, double b) {
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) <= ((double) INFINITY)) {
tmp = pow(hypot(a, b), 4.0) + fma(4.0, (fma((b * b), (a + 3.0), (a * a)) - pow(a, 3.0)), -1.0);
} else {
tmp = -1.0 + pow(a, 4.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (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))))) <= Inf) tmp = Float64((hypot(a, b) ^ 4.0) + fma(4.0, Float64(fma(Float64(b * b), Float64(a + 3.0), Float64(a * a)) - (a ^ 3.0)), -1.0)); else tmp = Float64(-1.0 + (a ^ 4.0)); end return tmp end
code[a_, b_] := If[LessEqual[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], Infinity], N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision] - N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\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) \leq \infty:\\
\;\;\;\;{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - {a}^{3}, -1\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{4}\\
\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.9%
associate--l+99.8%
Simplified100.0%
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-def5.0%
+-commutative5.0%
metadata-eval5.0%
Simplified5.0%
Taylor expanded in a around inf 98.4%
Final simplification99.6%
(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) (+ t_0 -1.0) (+ -1.0 (pow a 4.0)))))
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 = t_0 + -1.0;
} else {
tmp = -1.0 + pow(a, 4.0);
}
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 = t_0 + -1.0;
} else {
tmp = -1.0 + Math.pow(a, 4.0);
}
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 = t_0 + -1.0 else: tmp = -1.0 + math.pow(a, 4.0) 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(t_0 + -1.0); else tmp = Float64(-1.0 + (a ^ 4.0)); 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 = t_0 + -1.0; else tmp = -1.0 + (a ^ 4.0); 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[(t$95$0 + -1.0), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $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:\\
\;\;\;\;t_0 + -1\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{4}\\
\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.9%
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-def5.0%
+-commutative5.0%
metadata-eval5.0%
Simplified5.0%
Taylor expanded in a around inf 98.4%
Final simplification99.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e-7) (+ -1.0 (pow a 4.0)) (+ -1.0 (+ (pow b 4.0) (* b (* b 12.0))))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-7) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + (pow(b, 4.0) + (b * (b * 12.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) <= 2d-7) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + ((b ** 4.0d0) + (b * (b * 12.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-7) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + (Math.pow(b, 4.0) + (b * (b * 12.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e-7: tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + (math.pow(b, 4.0) + (b * (b * 12.0))) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e-7) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64((b ^ 4.0) + Float64(b * Float64(b * 12.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e-7) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + ((b ^ 4.0) + (b * (b * 12.0))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e-7], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[Power[b, 4.0], $MachinePrecision] + N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{-7}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left({b}^{4} + b \cdot \left(b \cdot 12\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1.9999999999999999e-7Initial program 84.3%
sub-neg84.3%
fma-def84.3%
fma-def84.3%
+-commutative84.3%
metadata-eval84.3%
Simplified84.3%
Taylor expanded in a around inf 98.8%
if 1.9999999999999999e-7 < (*.f64 b b) Initial program 66.8%
sub-neg66.8%
fma-def66.8%
fma-def69.4%
+-commutative69.4%
metadata-eval69.4%
Simplified69.4%
Taylor expanded in a around 0 66.2%
associate-+r+66.2%
associate-*r*66.2%
distribute-rgt-out74.0%
metadata-eval74.0%
distribute-lft-in74.0%
+-commutative74.0%
unpow274.0%
distribute-lft-in74.0%
metadata-eval74.0%
Simplified74.0%
Taylor expanded in a around 0 92.5%
unpow292.5%
*-commutative92.5%
associate-*l*92.5%
Simplified92.5%
Final simplification96.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e-7) (+ -1.0 (pow a 4.0)) (+ -1.0 (* b (* b (fma b b 12.0))))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-7) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + (b * (b * fma(b, b, 12.0)));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e-7) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64(b * Float64(b * fma(b, b, 12.0)))); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e-7], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(b * N[(b * N[(b * b + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{-7}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 12\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1.9999999999999999e-7Initial program 84.3%
sub-neg84.3%
fma-def84.3%
fma-def84.3%
+-commutative84.3%
metadata-eval84.3%
Simplified84.3%
Taylor expanded in a around inf 98.8%
if 1.9999999999999999e-7 < (*.f64 b b) Initial program 66.8%
sub-neg66.8%
fma-def66.8%
fma-def69.4%
+-commutative69.4%
metadata-eval69.4%
Simplified69.4%
Taylor expanded in a around 0 66.2%
associate-+r+66.2%
associate-*r*66.2%
distribute-rgt-out74.0%
metadata-eval74.0%
distribute-lft-in74.0%
+-commutative74.0%
unpow274.0%
distribute-lft-in74.0%
metadata-eval74.0%
Simplified74.0%
Taylor expanded in a around 0 92.5%
unpow292.5%
*-commutative92.5%
associate-*l*92.5%
Simplified92.5%
Taylor expanded in b around 0 92.5%
unpow292.5%
metadata-eval92.5%
pow-sqr92.4%
unpow292.4%
unpow292.4%
distribute-rgt-in92.4%
associate-*l*92.5%
+-commutative92.5%
fma-udef92.5%
Simplified92.5%
Final simplification96.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e-7) (+ -1.0 (pow a 4.0)) (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-7) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.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) <= 2d-7) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + ((b * b) * ((b * b) + 12.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-7) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e-7: tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + ((b * b) * ((b * b) + 12.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e-7) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e-7) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + ((b * b) * ((b * b) + 12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e-7], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{-7}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1.9999999999999999e-7Initial program 84.3%
sub-neg84.3%
fma-def84.3%
fma-def84.3%
+-commutative84.3%
metadata-eval84.3%
Simplified84.3%
Taylor expanded in a around inf 98.8%
if 1.9999999999999999e-7 < (*.f64 b b) Initial program 66.8%
sub-neg66.8%
fma-def66.8%
fma-def69.4%
+-commutative69.4%
metadata-eval69.4%
Simplified69.4%
Taylor expanded in a around 0 66.2%
associate-+r+66.2%
associate-*r*66.2%
distribute-rgt-out74.0%
metadata-eval74.0%
distribute-lft-in74.0%
+-commutative74.0%
unpow274.0%
distribute-lft-in74.0%
metadata-eval74.0%
Simplified74.0%
Taylor expanded in a around 0 92.5%
unpow292.5%
*-commutative92.5%
associate-*l*92.5%
Simplified92.5%
+-commutative92.5%
associate-*r*92.5%
sqr-pow92.4%
metadata-eval92.4%
pow292.4%
metadata-eval92.4%
pow292.4%
distribute-lft-out92.4%
Applied egg-rr92.4%
Final simplification95.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e-15) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-15) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.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) <= 2d-15) then
tmp = (-1.0d0) + ((a * a) * 4.0d0)
else
tmp = (-1.0d0) + ((b * b) * ((b * b) + 12.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-15) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e-15: tmp = -1.0 + ((a * a) * 4.0) else: tmp = -1.0 + ((b * b) * ((b * b) + 12.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e-15) tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e-15) tmp = -1.0 + ((a * a) * 4.0); else tmp = -1.0 + ((b * b) * ((b * b) + 12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e-15], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{-15}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 2.0000000000000002e-15Initial program 84.1%
sub-neg84.1%
fma-def84.1%
fma-def84.1%
+-commutative84.1%
metadata-eval84.1%
Simplified84.1%
Taylor expanded in b around 0 84.2%
associate-*r*84.2%
unpow284.2%
Simplified84.2%
Taylor expanded in a around 0 73.7%
unpow273.7%
Simplified73.7%
if 2.0000000000000002e-15 < (*.f64 b b) Initial program 67.4%
sub-neg67.4%
fma-def67.4%
fma-def70.0%
+-commutative70.0%
metadata-eval70.0%
Simplified70.0%
Taylor expanded in a around 0 65.9%
associate-+r+65.9%
associate-*r*65.9%
distribute-rgt-out73.6%
metadata-eval73.6%
distribute-lft-in73.6%
+-commutative73.6%
unpow273.6%
distribute-lft-in73.6%
metadata-eval73.6%
Simplified73.6%
Taylor expanded in a around 0 91.8%
unpow291.8%
*-commutative91.8%
associate-*l*91.8%
Simplified91.8%
+-commutative91.8%
associate-*r*91.8%
sqr-pow91.7%
metadata-eval91.7%
pow291.7%
metadata-eval91.7%
pow291.7%
distribute-lft-out91.7%
Applied egg-rr91.7%
Final simplification81.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 4e+20) (+ -1.0 (* (* a a) 4.0)) (* (* b b) (+ (* b b) 1.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 4e+20) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = (b * b) * ((b * b) + 1.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) <= 4d+20) then
tmp = (-1.0d0) + ((a * a) * 4.0d0)
else
tmp = (b * b) * ((b * b) + 1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 4e+20) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = (b * b) * ((b * b) + 1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 4e+20: tmp = -1.0 + ((a * a) * 4.0) else: tmp = (b * b) * ((b * b) + 1.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 4e+20) tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); else tmp = Float64(Float64(b * b) * Float64(Float64(b * b) + 1.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 4e+20) tmp = -1.0 + ((a * a) * 4.0); else tmp = (b * b) * ((b * b) + 1.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 4e+20], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 4 \cdot 10^{+20}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + 1\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 4e20Initial program 84.5%
sub-neg84.5%
fma-def84.5%
fma-def84.5%
+-commutative84.5%
metadata-eval84.5%
Simplified84.5%
Taylor expanded in b around 0 81.6%
associate-*r*81.6%
unpow281.6%
Simplified81.6%
Taylor expanded in a around 0 71.2%
unpow271.2%
Simplified71.2%
if 4e20 < (*.f64 b b) Initial program 65.3%
sub-neg65.3%
fma-def65.3%
fma-def68.1%
+-commutative68.1%
metadata-eval68.1%
Simplified68.1%
Taylor expanded in b around inf 94.7%
sqr-pow94.6%
metadata-eval94.6%
pow294.6%
metadata-eval94.6%
pow294.6%
difference-of-sqr--194.6%
Applied egg-rr94.6%
Taylor expanded in b around inf 94.6%
unpow294.6%
Simplified94.6%
Final simplification81.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2.06e+282) (+ -1.0 (* (* a a) 4.0)) (* b b)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2.06e+282) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = 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) <= 2.06d+282) then
tmp = (-1.0d0) + ((a * a) * 4.0d0)
else
tmp = b * b
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2.06e+282) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = b * b;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2.06e+282: tmp = -1.0 + ((a * a) * 4.0) else: tmp = b * b return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2.06e+282) tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); else tmp = Float64(b * b); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2.06e+282) tmp = -1.0 + ((a * a) * 4.0); else tmp = b * b; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2.06e+282], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(b * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2.06 \cdot 10^{+282}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;b \cdot b\\
\end{array}
\end{array}
if (*.f64 b b) < 2.06e282Initial program 81.8%
sub-neg81.8%
fma-def81.8%
fma-def82.3%
+-commutative82.3%
metadata-eval82.3%
Simplified82.3%
Taylor expanded in b around 0 66.4%
associate-*r*66.4%
unpow266.4%
Simplified66.4%
Taylor expanded in a around 0 57.9%
unpow257.9%
Simplified57.9%
if 2.06e282 < (*.f64 b b) Initial program 57.9%
sub-neg57.9%
fma-def57.9%
fma-def61.4%
+-commutative61.4%
metadata-eval61.4%
Simplified61.4%
Taylor expanded in b around inf 100.0%
sqr-pow100.0%
metadata-eval100.0%
pow2100.0%
metadata-eval100.0%
pow2100.0%
difference-of-sqr--1100.0%
Applied egg-rr100.0%
Taylor expanded in b around inf 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in b around 0 96.8%
unpow296.8%
Simplified96.8%
Final simplification66.6%
(FPCore (a b) :precision binary64 (if (<= (* b b) 4e+281) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 4e+281) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * 12.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) <= 4d+281) then
tmp = (-1.0d0) + ((a * a) * 4.0d0)
else
tmp = (-1.0d0) + ((b * b) * 12.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 4e+281) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 4e+281: tmp = -1.0 + ((a * a) * 4.0) else: tmp = -1.0 + ((b * b) * 12.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 4e+281) tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); else tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 4e+281) tmp = -1.0 + ((a * a) * 4.0); else tmp = -1.0 + ((b * b) * 12.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 4e+281], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 4 \cdot 10^{+281}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\end{array}
\end{array}
if (*.f64 b b) < 4.0000000000000001e281Initial program 81.8%
sub-neg81.8%
fma-def81.8%
fma-def82.3%
+-commutative82.3%
metadata-eval82.3%
Simplified82.3%
Taylor expanded in b around 0 66.4%
associate-*r*66.4%
unpow266.4%
Simplified66.4%
Taylor expanded in a around 0 57.9%
unpow257.9%
Simplified57.9%
if 4.0000000000000001e281 < (*.f64 b b) Initial program 57.9%
associate--l+57.9%
Simplified57.9%
Taylor expanded in a around 0 100.0%
associate--l+100.0%
fma-def100.0%
unpow2100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in b around 0 96.8%
fma-udef96.8%
Applied egg-rr96.8%
Final simplification66.6%
(FPCore (a b) :precision binary64 (if (<= (* b b) 0.082) -1.0 (* b b)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.082) {
tmp = -1.0;
} else {
tmp = 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) <= 0.082d0) then
tmp = -1.0d0
else
tmp = b * b
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 0.082) {
tmp = -1.0;
} else {
tmp = b * b;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 0.082: tmp = -1.0 else: tmp = b * b return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 0.082) tmp = -1.0; else tmp = Float64(b * b); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 0.082) tmp = -1.0; else tmp = b * b; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.082], -1.0, N[(b * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.082:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;b \cdot b\\
\end{array}
\end{array}
if (*.f64 b b) < 0.0820000000000000034Initial program 84.5%
sub-neg84.5%
fma-def84.5%
fma-def84.5%
+-commutative84.5%
metadata-eval84.5%
Simplified84.5%
Taylor expanded in b around inf 43.6%
Taylor expanded in b around 0 43.6%
if 0.0820000000000000034 < (*.f64 b b) Initial program 66.2%
sub-neg66.2%
fma-def66.2%
fma-def68.9%
+-commutative68.9%
metadata-eval68.9%
Simplified68.9%
Taylor expanded in b around inf 90.7%
sqr-pow90.5%
metadata-eval90.5%
pow290.5%
metadata-eval90.5%
pow290.5%
difference-of-sqr--190.5%
Applied egg-rr90.5%
Taylor expanded in b around inf 90.7%
unpow290.7%
Simplified90.7%
Taylor expanded in b around 0 51.9%
unpow251.9%
Simplified51.9%
Final simplification47.3%
(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 76.5%
sub-neg76.5%
fma-def76.5%
fma-def77.6%
+-commutative77.6%
metadata-eval77.6%
Simplified77.6%
Taylor expanded in b around inf 64.4%
Taylor expanded in b around 0 24.7%
Final simplification24.7%
herbie shell --seed 2023172
(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))