
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 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) * (1.0 - (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) * (1.0d0 - (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) * (1.0 - (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) * (1.0 - (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(1.0 - 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) * (1.0 - (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[(1.0 - N[(3.0 * a), $MachinePrecision]), $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(1 - 3 \cdot a\right)\right)\right) - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 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) (- 1.0 (* 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) * (1.0 - (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) * (1.0d0 - (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) * (1.0 - (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) * (1.0 - (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(1.0 - 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) * (1.0 - (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[(1.0 - N[(3.0 * a), $MachinePrecision]), $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(1 - 3 \cdot a\right)\right)\right) - 1
\end{array}
(FPCore (a b) :precision binary64 (+ (fma 2.0 (* b (* b (* a a))) (+ (pow b 4.0) (pow a 4.0))) (+ (* 4.0 (* b b)) -1.0)))
double code(double a, double b) {
return fma(2.0, (b * (b * (a * a))), (pow(b, 4.0) + pow(a, 4.0))) + ((4.0 * (b * b)) + -1.0);
}
function code(a, b) return Float64(fma(2.0, Float64(b * Float64(b * Float64(a * a))), Float64((b ^ 4.0) + (a ^ 4.0))) + Float64(Float64(4.0 * Float64(b * b)) + -1.0)) end
code[a_, b_] := N[(N[(2.0 * N[(b * N[(b * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[b, 4.0], $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(2, b \cdot \left(b \cdot \left(a \cdot a\right)\right), {b}^{4} + {a}^{4}\right) + \left(4 \cdot \left(b \cdot b\right) + -1\right)
\end{array}
Initial program 72.5%
associate--l+72.5%
fma-def72.5%
Simplified73.3%
Taylor expanded in a around 0 64.1%
fma-def64.1%
+-commutative64.1%
*-commutative64.1%
unpow264.1%
associate-*l*73.4%
unpow273.4%
Simplified73.4%
Taylor expanded in a around 0 99.2%
unpow299.2%
Simplified99.2%
Final simplification99.2%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))))
(if (<= t_0 INFINITY) (+ t_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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = 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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = 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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = 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(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0)))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = 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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = 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[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[Power[a, 4.0], $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(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;t_0 + -1\\
\mathbf{else}:\\
\;\;\;\;{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 1 (*.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 1 (*.f64 3 a)))))) Initial program 0.0%
associate--l+0.0%
fma-def0.0%
Simplified2.9%
Taylor expanded in a around inf 96.0%
Final simplification98.8%
(FPCore (a b)
:precision binary64
(if (<= (* b b) 5e-196)
(+ (pow a 4.0) -1.0)
(+
(pow b 4.0)
(+ (pow a 4.0) (+ (* (* b b) (+ 4.0 (* 2.0 (* a a)))) -1.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-196) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = pow(b, 4.0) + (pow(a, 4.0) + (((b * b) * (4.0 + (2.0 * (a * a)))) + -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) <= 5d-196) then
tmp = (a ** 4.0d0) + (-1.0d0)
else
tmp = (b ** 4.0d0) + ((a ** 4.0d0) + (((b * b) * (4.0d0 + (2.0d0 * (a * a)))) + (-1.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-196) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = Math.pow(b, 4.0) + (Math.pow(a, 4.0) + (((b * b) * (4.0 + (2.0 * (a * a)))) + -1.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e-196: tmp = math.pow(a, 4.0) + -1.0 else: tmp = math.pow(b, 4.0) + (math.pow(a, 4.0) + (((b * b) * (4.0 + (2.0 * (a * a)))) + -1.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e-196) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64((b ^ 4.0) + Float64((a ^ 4.0) + Float64(Float64(Float64(b * b) * Float64(4.0 + Float64(2.0 * Float64(a * a)))) + -1.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e-196) tmp = (a ^ 4.0) + -1.0; else tmp = (b ^ 4.0) + ((a ^ 4.0) + (((b * b) * (4.0 + (2.0 * (a * a)))) + -1.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e-196], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[Power[a, 4.0], $MachinePrecision] + N[(N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(2.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-196}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + \left({a}^{4} + \left(\left(b \cdot b\right) \cdot \left(4 + 2 \cdot \left(a \cdot a\right)\right) + -1\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 5.0000000000000005e-196Initial program 84.9%
associate--l+84.9%
fma-def84.9%
Simplified84.9%
Taylor expanded in a around 0 77.5%
fma-def77.5%
+-commutative77.5%
*-commutative77.5%
unpow277.5%
associate-*l*85.0%
unpow285.0%
Simplified85.0%
Taylor expanded in a around 0 98.4%
unpow298.4%
Simplified98.4%
Taylor expanded in b around 0 98.4%
if 5.0000000000000005e-196 < (*.f64 b b) Initial program 66.9%
associate--l+66.9%
fma-def66.9%
Simplified68.0%
Taylor expanded in a around 0 57.9%
fma-def57.9%
+-commutative57.9%
*-commutative57.9%
unpow257.9%
associate-*l*68.2%
unpow268.2%
Simplified68.2%
Taylor expanded in a around 0 99.5%
unpow299.5%
Simplified99.5%
Taylor expanded in b around 0 99.5%
associate--l+99.5%
associate--l+99.5%
unpow299.5%
unpow299.5%
Simplified99.5%
Final simplification99.2%
(FPCore (a b)
:precision binary64
(if (<= a -0.3)
(+ (pow a 4.0) -1.0)
(if (<= a 6.5e-22)
(+ (* 4.0 (* b b)) (+ (pow b 4.0) -1.0))
(+ (pow a 4.0) (+ (* (+ a 1.0) (* (* a a) 4.0)) -1.0)))))
double code(double a, double b) {
double tmp;
if (a <= -0.3) {
tmp = pow(a, 4.0) + -1.0;
} else if (a <= 6.5e-22) {
tmp = (4.0 * (b * b)) + (pow(b, 4.0) + -1.0);
} else {
tmp = pow(a, 4.0) + (((a + 1.0) * ((a * a) * 4.0)) + -1.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-0.3d0)) then
tmp = (a ** 4.0d0) + (-1.0d0)
else if (a <= 6.5d-22) then
tmp = (4.0d0 * (b * b)) + ((b ** 4.0d0) + (-1.0d0))
else
tmp = (a ** 4.0d0) + (((a + 1.0d0) * ((a * a) * 4.0d0)) + (-1.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -0.3) {
tmp = Math.pow(a, 4.0) + -1.0;
} else if (a <= 6.5e-22) {
tmp = (4.0 * (b * b)) + (Math.pow(b, 4.0) + -1.0);
} else {
tmp = Math.pow(a, 4.0) + (((a + 1.0) * ((a * a) * 4.0)) + -1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -0.3: tmp = math.pow(a, 4.0) + -1.0 elif a <= 6.5e-22: tmp = (4.0 * (b * b)) + (math.pow(b, 4.0) + -1.0) else: tmp = math.pow(a, 4.0) + (((a + 1.0) * ((a * a) * 4.0)) + -1.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -0.3) tmp = Float64((a ^ 4.0) + -1.0); elseif (a <= 6.5e-22) tmp = Float64(Float64(4.0 * Float64(b * b)) + Float64((b ^ 4.0) + -1.0)); else tmp = Float64((a ^ 4.0) + Float64(Float64(Float64(a + 1.0) * Float64(Float64(a * a) * 4.0)) + -1.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -0.3) tmp = (a ^ 4.0) + -1.0; elseif (a <= 6.5e-22) tmp = (4.0 * (b * b)) + ((b ^ 4.0) + -1.0); else tmp = (a ^ 4.0) + (((a + 1.0) * ((a * a) * 4.0)) + -1.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -0.3], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, 6.5e-22], N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + N[(N[(N[(a + 1.0), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.3:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{elif}\;a \leq 6.5 \cdot 10^{-22}:\\
\;\;\;\;4 \cdot \left(b \cdot b\right) + \left({b}^{4} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + \left(\left(a + 1\right) \cdot \left(\left(a \cdot a\right) \cdot 4\right) + -1\right)\\
\end{array}
\end{array}
if a < -0.299999999999999989Initial program 40.4%
associate--l+40.4%
fma-def40.4%
Simplified43.3%
Taylor expanded in a around 0 43.5%
fma-def43.5%
+-commutative43.5%
*-commutative43.5%
unpow243.5%
associate-*l*43.5%
unpow243.5%
Simplified43.5%
Taylor expanded in a around 0 97.6%
unpow297.6%
Simplified97.6%
Taylor expanded in b around 0 92.3%
if -0.299999999999999989 < a < 6.50000000000000043e-22Initial program 99.8%
associate--l+99.8%
fma-def99.8%
Simplified99.8%
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%
fma-udef100.0%
Applied egg-rr100.0%
if 6.50000000000000043e-22 < a Initial program 56.6%
associate--l+56.6%
fma-def56.6%
Simplified56.6%
Taylor expanded in b around 0 93.6%
associate--l+93.6%
associate-*r*93.6%
unpow293.6%
Simplified93.6%
Final simplification96.2%
(FPCore (a b) :precision binary64 (if (<= a -0.3) (+ (pow a 4.0) -1.0) (if (<= a 3.5e+21) (+ (* 4.0 (* b b)) (+ (pow b 4.0) -1.0)) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -0.3) {
tmp = pow(a, 4.0) + -1.0;
} else if (a <= 3.5e+21) {
tmp = (4.0 * (b * b)) + (pow(b, 4.0) + -1.0);
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-0.3d0)) then
tmp = (a ** 4.0d0) + (-1.0d0)
else if (a <= 3.5d+21) then
tmp = (4.0d0 * (b * b)) + ((b ** 4.0d0) + (-1.0d0))
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -0.3) {
tmp = Math.pow(a, 4.0) + -1.0;
} else if (a <= 3.5e+21) {
tmp = (4.0 * (b * b)) + (Math.pow(b, 4.0) + -1.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -0.3: tmp = math.pow(a, 4.0) + -1.0 elif a <= 3.5e+21: tmp = (4.0 * (b * b)) + (math.pow(b, 4.0) + -1.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -0.3) tmp = Float64((a ^ 4.0) + -1.0); elseif (a <= 3.5e+21) tmp = Float64(Float64(4.0 * Float64(b * b)) + Float64((b ^ 4.0) + -1.0)); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -0.3) tmp = (a ^ 4.0) + -1.0; elseif (a <= 3.5e+21) tmp = (4.0 * (b * b)) + ((b ^ 4.0) + -1.0); else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -0.3], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, 3.5e+21], N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.3:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{elif}\;a \leq 3.5 \cdot 10^{+21}:\\
\;\;\;\;4 \cdot \left(b \cdot b\right) + \left({b}^{4} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -0.299999999999999989Initial program 40.4%
associate--l+40.4%
fma-def40.4%
Simplified43.3%
Taylor expanded in a around 0 43.5%
fma-def43.5%
+-commutative43.5%
*-commutative43.5%
unpow243.5%
associate-*l*43.5%
unpow243.5%
Simplified43.5%
Taylor expanded in a around 0 97.6%
unpow297.6%
Simplified97.6%
Taylor expanded in b around 0 92.3%
if -0.299999999999999989 < a < 3.5e21Initial program 99.1%
associate--l+99.1%
fma-def99.1%
Simplified99.1%
Taylor expanded in a around 0 98.9%
associate--l+98.9%
fma-def98.9%
unpow298.9%
sub-neg98.9%
metadata-eval98.9%
Simplified98.9%
fma-udef98.9%
Applied egg-rr98.9%
if 3.5e21 < a Initial program 53.3%
associate--l+53.3%
fma-def53.3%
Simplified53.3%
Taylor expanded in a around inf 94.5%
Final simplification96.1%
(FPCore (a b)
:precision binary64
(if (<= a -19000000000000.0)
(pow a 4.0)
(if (<= a -9.2e-249)
(pow b 4.0)
(if (<= a 1.2e-246)
-1.0
(if (<= a 2.2e-113) (pow b 4.0) (if (<= a 0.42) -1.0 (pow a 4.0)))))))
double code(double a, double b) {
double tmp;
if (a <= -19000000000000.0) {
tmp = pow(a, 4.0);
} else if (a <= -9.2e-249) {
tmp = pow(b, 4.0);
} else if (a <= 1.2e-246) {
tmp = -1.0;
} else if (a <= 2.2e-113) {
tmp = pow(b, 4.0);
} else if (a <= 0.42) {
tmp = -1.0;
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-19000000000000.0d0)) then
tmp = a ** 4.0d0
else if (a <= (-9.2d-249)) then
tmp = b ** 4.0d0
else if (a <= 1.2d-246) then
tmp = -1.0d0
else if (a <= 2.2d-113) then
tmp = b ** 4.0d0
else if (a <= 0.42d0) then
tmp = -1.0d0
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -19000000000000.0) {
tmp = Math.pow(a, 4.0);
} else if (a <= -9.2e-249) {
tmp = Math.pow(b, 4.0);
} else if (a <= 1.2e-246) {
tmp = -1.0;
} else if (a <= 2.2e-113) {
tmp = Math.pow(b, 4.0);
} else if (a <= 0.42) {
tmp = -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -19000000000000.0: tmp = math.pow(a, 4.0) elif a <= -9.2e-249: tmp = math.pow(b, 4.0) elif a <= 1.2e-246: tmp = -1.0 elif a <= 2.2e-113: tmp = math.pow(b, 4.0) elif a <= 0.42: tmp = -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -19000000000000.0) tmp = a ^ 4.0; elseif (a <= -9.2e-249) tmp = b ^ 4.0; elseif (a <= 1.2e-246) tmp = -1.0; elseif (a <= 2.2e-113) tmp = b ^ 4.0; elseif (a <= 0.42) tmp = -1.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -19000000000000.0) tmp = a ^ 4.0; elseif (a <= -9.2e-249) tmp = b ^ 4.0; elseif (a <= 1.2e-246) tmp = -1.0; elseif (a <= 2.2e-113) tmp = b ^ 4.0; elseif (a <= 0.42) tmp = -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -19000000000000.0], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, -9.2e-249], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, 1.2e-246], -1.0, If[LessEqual[a, 2.2e-113], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, 0.42], -1.0, N[Power[a, 4.0], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -19000000000000:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq -9.2 \cdot 10^{-249}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq 1.2 \cdot 10^{-246}:\\
\;\;\;\;-1\\
\mathbf{elif}\;a \leq 2.2 \cdot 10^{-113}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq 0.42:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -1.9e13 or 0.419999999999999984 < a Initial program 45.6%
associate--l+45.6%
fma-def45.6%
Simplified47.2%
Taylor expanded in a around inf 93.8%
if -1.9e13 < a < -9.1999999999999993e-249 or 1.1999999999999999e-246 < a < 2.20000000000000004e-113Initial program 99.8%
associate--l+99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in b around inf 65.6%
if -9.1999999999999993e-249 < a < 1.1999999999999999e-246 or 2.20000000000000004e-113 < a < 0.419999999999999984Initial program 99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in b around 0 69.9%
associate--l+69.9%
associate-*r*69.9%
unpow269.9%
Simplified69.9%
Taylor expanded in a around 0 68.9%
Final simplification80.4%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+65) (+ (pow a 4.0) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+65) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = 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) <= 1d+65) then
tmp = (a ** 4.0d0) + (-1.0d0)
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+65) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e+65: tmp = math.pow(a, 4.0) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e+65) tmp = Float64((a ^ 4.0) + -1.0); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e+65) tmp = (a ^ 4.0) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+65], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+65}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 9.9999999999999999e64Initial program 83.4%
associate--l+83.4%
fma-def83.4%
Simplified83.4%
Taylor expanded in a around 0 79.1%
fma-def79.1%
+-commutative79.1%
*-commutative79.1%
unpow279.1%
associate-*l*83.6%
unpow283.6%
Simplified83.6%
Taylor expanded in a around 0 98.4%
unpow298.4%
Simplified98.4%
Taylor expanded in b around 0 94.2%
if 9.9999999999999999e64 < (*.f64 b b) Initial program 60.5%
associate--l+60.5%
fma-def60.5%
Simplified62.2%
Taylor expanded in b around inf 93.9%
Final simplification94.1%
(FPCore (a b) :precision binary64 (if (<= a -2.5) (pow a 4.0) (if (<= a 0.42) -1.0 (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -2.5) {
tmp = pow(a, 4.0);
} else if (a <= 0.42) {
tmp = -1.0;
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-2.5d0)) then
tmp = a ** 4.0d0
else if (a <= 0.42d0) then
tmp = -1.0d0
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -2.5) {
tmp = Math.pow(a, 4.0);
} else if (a <= 0.42) {
tmp = -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -2.5: tmp = math.pow(a, 4.0) elif a <= 0.42: tmp = -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -2.5) tmp = a ^ 4.0; elseif (a <= 0.42) tmp = -1.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -2.5) tmp = a ^ 4.0; elseif (a <= 0.42) tmp = -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -2.5], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 0.42], -1.0, N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.5:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 0.42:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -2.5 or 0.419999999999999984 < a Initial program 45.6%
associate--l+45.6%
fma-def45.6%
Simplified47.2%
Taylor expanded in a around inf 93.8%
if -2.5 < a < 0.419999999999999984Initial program 99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in b around 0 47.4%
associate--l+47.4%
associate-*r*47.4%
unpow247.4%
Simplified47.4%
Taylor expanded in a around 0 45.8%
Final simplification70.0%
(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 72.5%
associate--l+72.5%
fma-def72.5%
Simplified73.3%
Taylor expanded in b around 0 54.8%
associate--l+54.8%
associate-*r*54.8%
unpow254.8%
Simplified54.8%
Taylor expanded in a around 0 23.1%
Final simplification23.1%
herbie shell --seed 2023176
(FPCore (a b)
:name "Bouland and Aaronson, Equation (25)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))) 1.0))