
(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 7 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 (let* ((t_0 (pow (hypot a b) 4.0)) (t_1 (* 4.0 (pow a 3.0)))) (if (<= a 6.2e+14) (+ t_0 (- -1.0 t_1)) (+ (+ t_0 t_1) -1.0))))
double code(double a, double b) {
double t_0 = pow(hypot(a, b), 4.0);
double t_1 = 4.0 * pow(a, 3.0);
double tmp;
if (a <= 6.2e+14) {
tmp = t_0 + (-1.0 - t_1);
} else {
tmp = (t_0 + t_1) + -1.0;
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(Math.hypot(a, b), 4.0);
double t_1 = 4.0 * Math.pow(a, 3.0);
double tmp;
if (a <= 6.2e+14) {
tmp = t_0 + (-1.0 - t_1);
} else {
tmp = (t_0 + t_1) + -1.0;
}
return tmp;
}
def code(a, b): t_0 = math.pow(math.hypot(a, b), 4.0) t_1 = 4.0 * math.pow(a, 3.0) tmp = 0 if a <= 6.2e+14: tmp = t_0 + (-1.0 - t_1) else: tmp = (t_0 + t_1) + -1.0 return tmp
function code(a, b) t_0 = hypot(a, b) ^ 4.0 t_1 = Float64(4.0 * (a ^ 3.0)) tmp = 0.0 if (a <= 6.2e+14) tmp = Float64(t_0 + Float64(-1.0 - t_1)); else tmp = Float64(Float64(t_0 + t_1) + -1.0); end return tmp end
function tmp_2 = code(a, b) t_0 = hypot(a, b) ^ 4.0; t_1 = 4.0 * (a ^ 3.0); tmp = 0.0; if (a <= 6.2e+14) tmp = t_0 + (-1.0 - t_1); else tmp = (t_0 + t_1) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision]}, Block[{t$95$1 = N[(4.0 * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, 6.2e+14], N[(t$95$0 + N[(-1.0 - t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 + t$95$1), $MachinePrecision] + -1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}\\
t_1 := 4 \cdot {a}^{3}\\
\mathbf{if}\;a \leq 6.2 \cdot 10^{+14}:\\
\;\;\;\;t_0 + \left(-1 - t_1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t_0 + t_1\right) + -1\\
\end{array}
\end{array}
if a < 6.2e14Initial program 87.9%
associate--l+87.9%
fma-def87.9%
sqr-neg87.9%
fma-def87.9%
distribute-rgt-in87.9%
sqr-neg87.9%
distribute-rgt-in87.9%
fma-def87.9%
sqr-neg87.9%
Simplified87.9%
fma-def87.9%
expm1-log1p-u86.8%
expm1-udef86.8%
add-sqr-sqrt86.8%
pow286.8%
hypot-def86.8%
Applied egg-rr86.8%
expm1-def86.8%
expm1-log1p87.9%
unpow287.9%
pow-sqr88.0%
metadata-eval88.0%
Simplified88.0%
Taylor expanded in a around inf 99.1%
mul-1-neg99.1%
Simplified99.1%
if 6.2e14 < a Initial program 31.9%
associate--l+31.9%
fma-def31.9%
sqr-neg31.9%
fma-def31.9%
distribute-rgt-in31.9%
sqr-neg31.9%
distribute-rgt-in31.9%
fma-def31.9%
sqr-neg31.9%
Simplified35.5%
fma-def35.5%
expm1-log1p-u33.9%
expm1-udef33.9%
add-sqr-sqrt33.9%
pow233.9%
hypot-def33.9%
Applied egg-rr33.9%
expm1-def33.9%
expm1-log1p35.5%
unpow235.5%
pow-sqr35.7%
metadata-eval35.7%
Simplified35.7%
Taylor expanded in a around inf 32.1%
mul-1-neg32.1%
Simplified32.1%
associate-+r-32.1%
add-sqr-sqrt0.0%
sqrt-unprod91.8%
sqr-neg91.8%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
Final simplification99.3%
(FPCore (a b) :precision binary64 (if (<= a -2e+102) (pow a 4.0) (+ (+ (pow (hypot a b) 4.0) (* 4.0 (pow a 3.0))) -1.0)))
double code(double a, double b) {
double tmp;
if (a <= -2e+102) {
tmp = pow(a, 4.0);
} else {
tmp = (pow(hypot(a, b), 4.0) + (4.0 * pow(a, 3.0))) + -1.0;
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -2e+102) {
tmp = Math.pow(a, 4.0);
} else {
tmp = (Math.pow(Math.hypot(a, b), 4.0) + (4.0 * Math.pow(a, 3.0))) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -2e+102: tmp = math.pow(a, 4.0) else: tmp = (math.pow(math.hypot(a, b), 4.0) + (4.0 * math.pow(a, 3.0))) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (a <= -2e+102) tmp = a ^ 4.0; else tmp = Float64(Float64((hypot(a, b) ^ 4.0) + Float64(4.0 * (a ^ 3.0))) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -2e+102) tmp = a ^ 4.0; else tmp = ((hypot(a, b) ^ 4.0) + (4.0 * (a ^ 3.0))) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -2e+102], N[Power[a, 4.0], $MachinePrecision], N[(N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(4.0 * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2 \cdot 10^{+102}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + 4 \cdot {a}^{3}\right) + -1\\
\end{array}
\end{array}
if a < -1.99999999999999995e102Initial program 61.5%
associate--l+61.5%
fma-def61.5%
sqr-neg61.5%
fma-def61.5%
distribute-rgt-in61.5%
sqr-neg61.5%
distribute-rgt-in61.5%
fma-def61.5%
sqr-neg61.5%
Simplified61.5%
Taylor expanded in a around inf 100.0%
if -1.99999999999999995e102 < a Initial program 78.2%
associate--l+78.2%
fma-def78.2%
sqr-neg78.2%
fma-def78.2%
distribute-rgt-in78.2%
sqr-neg78.2%
distribute-rgt-in78.2%
fma-def78.2%
sqr-neg78.2%
Simplified79.1%
fma-def79.1%
expm1-log1p-u77.7%
expm1-udef77.7%
add-sqr-sqrt77.7%
pow277.7%
hypot-def77.7%
Applied egg-rr77.7%
expm1-def77.7%
expm1-log1p79.1%
unpow279.1%
pow-sqr79.2%
metadata-eval79.2%
Simplified79.2%
Taylor expanded in a around inf 81.7%
mul-1-neg81.7%
Simplified81.7%
associate-+r-81.7%
add-sqr-sqrt60.8%
sqrt-unprod95.7%
sqr-neg95.7%
sqrt-unprod72.0%
add-sqr-sqrt98.7%
Applied egg-rr98.7%
Final simplification98.9%
(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) (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 = 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 = 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 = 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 = 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 = 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[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(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}:\\
\;\;\;\;{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.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%
associate--l+0.0%
fma-def0.0%
sqr-neg0.0%
fma-def0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
fma-def0.0%
sqr-neg0.0%
Simplified3.2%
Taylor expanded in a around inf 92.4%
Final simplification98.0%
(FPCore (a b)
:precision binary64
(if (<= a -2.05e+70)
(pow a 4.0)
(if (<= a -6.6e-37)
(pow b 4.0)
(if (<= a -2.3e-89)
-1.0
(if (<= a -6.6e-197)
(pow b 4.0)
(if (<= a -2.35e-275)
-1.0
(if (<= a 2.45e-210)
(pow b 4.0)
(if (<= a 2e-39)
-1.0
(if (<= a 1.55e+32) (pow b 4.0) (pow a 4.0))))))))))
double code(double a, double b) {
double tmp;
if (a <= -2.05e+70) {
tmp = pow(a, 4.0);
} else if (a <= -6.6e-37) {
tmp = pow(b, 4.0);
} else if (a <= -2.3e-89) {
tmp = -1.0;
} else if (a <= -6.6e-197) {
tmp = pow(b, 4.0);
} else if (a <= -2.35e-275) {
tmp = -1.0;
} else if (a <= 2.45e-210) {
tmp = pow(b, 4.0);
} else if (a <= 2e-39) {
tmp = -1.0;
} else if (a <= 1.55e+32) {
tmp = pow(b, 4.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.05d+70)) then
tmp = a ** 4.0d0
else if (a <= (-6.6d-37)) then
tmp = b ** 4.0d0
else if (a <= (-2.3d-89)) then
tmp = -1.0d0
else if (a <= (-6.6d-197)) then
tmp = b ** 4.0d0
else if (a <= (-2.35d-275)) then
tmp = -1.0d0
else if (a <= 2.45d-210) then
tmp = b ** 4.0d0
else if (a <= 2d-39) then
tmp = -1.0d0
else if (a <= 1.55d+32) then
tmp = b ** 4.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.05e+70) {
tmp = Math.pow(a, 4.0);
} else if (a <= -6.6e-37) {
tmp = Math.pow(b, 4.0);
} else if (a <= -2.3e-89) {
tmp = -1.0;
} else if (a <= -6.6e-197) {
tmp = Math.pow(b, 4.0);
} else if (a <= -2.35e-275) {
tmp = -1.0;
} else if (a <= 2.45e-210) {
tmp = Math.pow(b, 4.0);
} else if (a <= 2e-39) {
tmp = -1.0;
} else if (a <= 1.55e+32) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -2.05e+70: tmp = math.pow(a, 4.0) elif a <= -6.6e-37: tmp = math.pow(b, 4.0) elif a <= -2.3e-89: tmp = -1.0 elif a <= -6.6e-197: tmp = math.pow(b, 4.0) elif a <= -2.35e-275: tmp = -1.0 elif a <= 2.45e-210: tmp = math.pow(b, 4.0) elif a <= 2e-39: tmp = -1.0 elif a <= 1.55e+32: tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -2.05e+70) tmp = a ^ 4.0; elseif (a <= -6.6e-37) tmp = b ^ 4.0; elseif (a <= -2.3e-89) tmp = -1.0; elseif (a <= -6.6e-197) tmp = b ^ 4.0; elseif (a <= -2.35e-275) tmp = -1.0; elseif (a <= 2.45e-210) tmp = b ^ 4.0; elseif (a <= 2e-39) tmp = -1.0; elseif (a <= 1.55e+32) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -2.05e+70) tmp = a ^ 4.0; elseif (a <= -6.6e-37) tmp = b ^ 4.0; elseif (a <= -2.3e-89) tmp = -1.0; elseif (a <= -6.6e-197) tmp = b ^ 4.0; elseif (a <= -2.35e-275) tmp = -1.0; elseif (a <= 2.45e-210) tmp = b ^ 4.0; elseif (a <= 2e-39) tmp = -1.0; elseif (a <= 1.55e+32) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -2.05e+70], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, -6.6e-37], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, -2.3e-89], -1.0, If[LessEqual[a, -6.6e-197], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, -2.35e-275], -1.0, If[LessEqual[a, 2.45e-210], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, 2e-39], -1.0, If[LessEqual[a, 1.55e+32], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.05 \cdot 10^{+70}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq -6.6 \cdot 10^{-37}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq -2.3 \cdot 10^{-89}:\\
\;\;\;\;-1\\
\mathbf{elif}\;a \leq -6.6 \cdot 10^{-197}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq -2.35 \cdot 10^{-275}:\\
\;\;\;\;-1\\
\mathbf{elif}\;a \leq 2.45 \cdot 10^{-210}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq 2 \cdot 10^{-39}:\\
\;\;\;\;-1\\
\mathbf{elif}\;a \leq 1.55 \cdot 10^{+32}:\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -2.0500000000000001e70 or 1.54999999999999997e32 < a Initial program 43.4%
associate--l+43.4%
fma-def43.4%
sqr-neg43.4%
fma-def43.4%
distribute-rgt-in43.4%
sqr-neg43.4%
distribute-rgt-in43.4%
fma-def43.4%
sqr-neg43.4%
Simplified45.4%
Taylor expanded in a around inf 97.6%
if -2.0500000000000001e70 < a < -6.59999999999999964e-37 or -2.3e-89 < a < -6.5999999999999995e-197 or -2.3499999999999999e-275 < a < 2.4499999999999999e-210 or 1.99999999999999986e-39 < a < 1.54999999999999997e32Initial program 93.9%
associate--l+93.9%
fma-def93.9%
sqr-neg93.9%
fma-def93.9%
distribute-rgt-in93.9%
sqr-neg93.9%
distribute-rgt-in93.9%
fma-def93.9%
sqr-neg93.9%
Simplified93.9%
Taylor expanded in b around inf 66.6%
if -6.59999999999999964e-37 < a < -2.3e-89 or -6.5999999999999995e-197 < a < -2.3499999999999999e-275 or 2.4499999999999999e-210 < a < 1.99999999999999986e-39Initial program 100.0%
associate--l+100.0%
fma-def100.0%
sqr-neg100.0%
fma-def100.0%
distribute-rgt-in100.0%
sqr-neg100.0%
distribute-rgt-in100.0%
fma-def100.0%
sqr-neg100.0%
Simplified100.0%
Taylor expanded in b around 0 74.3%
Taylor expanded in a around 0 74.3%
Final simplification80.9%
(FPCore (a b) :precision binary64 (if (or (<= a -2.8e+70) (not (<= a 2.2e+30))) (pow a 4.0) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -2.8e+70) || !(a <= 2.2e+30)) {
tmp = pow(a, 4.0);
} else {
tmp = pow(b, 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 <= (-2.8d+70)) .or. (.not. (a <= 2.2d+30))) then
tmp = a ** 4.0d0
else
tmp = (b ** 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -2.8e+70) || !(a <= 2.2e+30)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -2.8e+70) or not (a <= 2.2e+30): tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -2.8e+70) || !(a <= 2.2e+30)) tmp = a ^ 4.0; else tmp = Float64((b ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -2.8e+70) || ~((a <= 2.2e+30))) tmp = a ^ 4.0; else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -2.8e+70], N[Not[LessEqual[a, 2.2e+30]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.8 \cdot 10^{+70} \lor \neg \left(a \leq 2.2 \cdot 10^{+30}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if a < -2.7999999999999999e70 or 2.2e30 < a Initial program 43.4%
associate--l+43.4%
fma-def43.4%
sqr-neg43.4%
fma-def43.4%
distribute-rgt-in43.4%
sqr-neg43.4%
distribute-rgt-in43.4%
fma-def43.4%
sqr-neg43.4%
Simplified45.4%
Taylor expanded in a around inf 97.6%
if -2.7999999999999999e70 < a < 2.2e30Initial program 96.6%
associate--l+96.6%
fma-def96.6%
sqr-neg96.6%
fma-def96.6%
distribute-rgt-in96.6%
sqr-neg96.6%
distribute-rgt-in96.6%
fma-def96.6%
sqr-neg96.6%
Simplified96.6%
fma-def96.6%
expm1-log1p-u95.2%
expm1-udef95.2%
add-sqr-sqrt95.2%
pow295.2%
hypot-def95.2%
Applied egg-rr95.2%
expm1-def95.2%
expm1-log1p96.6%
unpow296.6%
pow-sqr96.8%
metadata-eval96.8%
Simplified96.8%
Taylor expanded in a around inf 98.8%
mul-1-neg98.8%
Simplified98.8%
Taylor expanded in a around 0 92.8%
Final simplification94.7%
(FPCore (a b) :precision binary64 (if (or (<= a -0.41) (not (<= a 2.4))) (pow a 4.0) -1.0))
double code(double a, double b) {
double tmp;
if ((a <= -0.41) || !(a <= 2.4)) {
tmp = pow(a, 4.0);
} else {
tmp = -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.41d0)) .or. (.not. (a <= 2.4d0))) then
tmp = a ** 4.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -0.41) || !(a <= 2.4)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -0.41) or not (a <= 2.4): tmp = math.pow(a, 4.0) else: tmp = -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -0.41) || !(a <= 2.4)) tmp = a ^ 4.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -0.41) || ~((a <= 2.4))) tmp = a ^ 4.0; else tmp = -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -0.41], N[Not[LessEqual[a, 2.4]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.41 \lor \neg \left(a \leq 2.4\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if a < -0.409999999999999976 or 2.39999999999999991 < a Initial program 50.5%
associate--l+50.5%
fma-def50.5%
sqr-neg50.5%
fma-def50.5%
distribute-rgt-in50.5%
sqr-neg50.5%
distribute-rgt-in50.5%
fma-def50.5%
sqr-neg50.5%
Simplified52.1%
Taylor expanded in a around inf 84.4%
if -0.409999999999999976 < a < 2.39999999999999991Initial program 99.9%
associate--l+99.9%
fma-def99.9%
sqr-neg99.9%
fma-def99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
fma-def99.9%
sqr-neg99.9%
Simplified99.9%
Taylor expanded in b around 0 54.5%
Taylor expanded in a around 0 53.9%
Final simplification68.9%
(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 75.6%
associate--l+75.6%
fma-def75.6%
sqr-neg75.6%
fma-def75.6%
distribute-rgt-in75.6%
sqr-neg75.6%
distribute-rgt-in75.6%
fma-def75.6%
sqr-neg75.6%
Simplified76.4%
Taylor expanded in b around 0 54.9%
Taylor expanded in a around 0 27.7%
Final simplification27.7%
herbie shell --seed 2023339
(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))