
(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 8 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 b a) 4.0)
(+ (* 4.0 (fma (* a a) (- 1.0 a) (* b (* b (+ a 3.0))))) -1.0))
(* (pow a 3.0) (- 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(b, a), 4.0) + ((4.0 * fma((a * a), (1.0 - a), (b * (b * (a + 3.0))))) + -1.0);
} else {
tmp = pow(a, 3.0) * (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(b, a) ^ 4.0) + Float64(Float64(4.0 * fma(Float64(a * a), Float64(1.0 - a), Float64(b * Float64(b * Float64(a + 3.0))))) + -1.0)); else tmp = Float64((a ^ 3.0) * Float64(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[b ^ 2 + a ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision] + N[(b * N[(b * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[a, 3.0], $MachinePrecision] * N[(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(b, a\right)\right)}^{4} + \left(4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, b \cdot \left(b \cdot \left(a + 3\right)\right)\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{3} \cdot \left(a - 4\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (-.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (+.f64 #s(literal 3 binary64) a))))) < +inf.0Initial program 99.8%
associate--l+99.8%
fma-define99.8%
sqr-neg99.8%
fma-define99.8%
distribute-rgt-in99.8%
sqr-neg99.8%
distribute-rgt-in99.8%
fma-define99.8%
sqr-neg99.8%
Simplified99.8%
fma-define99.8%
unpow299.8%
+-commutative99.8%
distribute-lft-in85.9%
fma-define85.9%
add-sqr-sqrt85.9%
pow285.9%
fma-define85.9%
hypot-define85.9%
pow285.9%
fma-define85.9%
add-sqr-sqrt85.9%
pow285.9%
fma-define85.9%
hypot-define85.9%
pow285.9%
Applied egg-rr85.9%
distribute-lft-out99.8%
+-commutative99.8%
rem-square-sqrt99.8%
unpow299.8%
unpow299.8%
hypot-undefine99.8%
unpow299.8%
unpow299.8%
hypot-undefine99.8%
unpow299.8%
pow-sqr100.0%
hypot-undefine100.0%
unpow2100.0%
unpow2100.0%
+-commutative100.0%
unpow2100.0%
unpow2100.0%
hypot-define100.0%
metadata-eval100.0%
Simplified100.0%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (-.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (+.f64 #s(literal 3 binary64) a))))) Initial program 0.0%
associate--l+0.0%
fma-define0.0%
sqr-neg0.0%
fma-define0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
fma-define0.0%
sqr-neg0.0%
Simplified6.5%
Taylor expanded in a around inf 98.4%
associate-*r/98.4%
metadata-eval98.4%
Simplified98.4%
Taylor expanded in a around 0 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) (* (pow a 3.0) (- 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, 3.0) * (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, 3.0) * (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, 3.0) * (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((a ^ 3.0) * Float64(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 ^ 3.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[(N[Power[a, 3.0], $MachinePrecision] * N[(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}:\\
\;\;\;\;{a}^{3} \cdot \left(a - 4\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (-.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (+.f64 #s(literal 3 binary64) a))))) < +inf.0Initial program 99.8%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (-.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (+.f64 #s(literal 3 binary64) a))))) Initial program 0.0%
associate--l+0.0%
fma-define0.0%
sqr-neg0.0%
fma-define0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
fma-define0.0%
sqr-neg0.0%
Simplified6.5%
Taylor expanded in a around inf 98.4%
associate-*r/98.4%
metadata-eval98.4%
Simplified98.4%
Taylor expanded in a around 0 98.4%
Final simplification99.5%
(FPCore (a b)
:precision binary64
(if (<= b 4.3e-175)
-1.0
(if (<= b 7.4e-124)
(pow a 4.0)
(if (<= b 1.25e-69) -1.0 (if (<= b 4e+59) (pow a 4.0) (pow b 4.0))))))
double code(double a, double b) {
double tmp;
if (b <= 4.3e-175) {
tmp = -1.0;
} else if (b <= 7.4e-124) {
tmp = pow(a, 4.0);
} else if (b <= 1.25e-69) {
tmp = -1.0;
} else if (b <= 4e+59) {
tmp = pow(a, 4.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 <= 4.3d-175) then
tmp = -1.0d0
else if (b <= 7.4d-124) then
tmp = a ** 4.0d0
else if (b <= 1.25d-69) then
tmp = -1.0d0
else if (b <= 4d+59) then
tmp = a ** 4.0d0
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 4.3e-175) {
tmp = -1.0;
} else if (b <= 7.4e-124) {
tmp = Math.pow(a, 4.0);
} else if (b <= 1.25e-69) {
tmp = -1.0;
} else if (b <= 4e+59) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 4.3e-175: tmp = -1.0 elif b <= 7.4e-124: tmp = math.pow(a, 4.0) elif b <= 1.25e-69: tmp = -1.0 elif b <= 4e+59: tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 4.3e-175) tmp = -1.0; elseif (b <= 7.4e-124) tmp = a ^ 4.0; elseif (b <= 1.25e-69) tmp = -1.0; elseif (b <= 4e+59) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 4.3e-175) tmp = -1.0; elseif (b <= 7.4e-124) tmp = a ^ 4.0; elseif (b <= 1.25e-69) tmp = -1.0; elseif (b <= 4e+59) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 4.3e-175], -1.0, If[LessEqual[b, 7.4e-124], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[b, 1.25e-69], -1.0, If[LessEqual[b, 4e+59], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.3 \cdot 10^{-175}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 7.4 \cdot 10^{-124}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;b \leq 1.25 \cdot 10^{-69}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 4 \cdot 10^{+59}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 4.29999999999999998e-175 or 7.3999999999999998e-124 < b < 1.25000000000000008e-69Initial program 78.5%
associate--l+78.5%
fma-define78.5%
sqr-neg78.5%
fma-define78.5%
distribute-rgt-in78.5%
sqr-neg78.5%
distribute-rgt-in78.5%
fma-define78.5%
sqr-neg78.5%
Simplified79.7%
fma-define79.7%
unpow279.7%
+-commutative79.7%
distribute-lft-in69.4%
fma-define69.4%
add-sqr-sqrt69.4%
pow269.4%
fma-define69.4%
hypot-define69.4%
pow269.4%
fma-define69.4%
add-sqr-sqrt69.4%
pow269.4%
fma-define69.4%
hypot-define69.4%
pow269.4%
Applied egg-rr69.4%
distribute-lft-out79.7%
+-commutative79.7%
rem-square-sqrt79.7%
unpow279.7%
unpow279.7%
hypot-undefine79.7%
unpow279.7%
unpow279.7%
hypot-undefine79.7%
unpow279.7%
pow-sqr79.9%
hypot-undefine79.9%
unpow279.9%
unpow279.9%
+-commutative79.9%
unpow279.9%
unpow279.9%
hypot-define79.9%
metadata-eval79.9%
Simplified79.9%
Taylor expanded in a around inf 82.5%
mul-1-neg82.5%
Simplified82.5%
Taylor expanded in a around 0 67.4%
Taylor expanded in b around 0 37.0%
if 4.29999999999999998e-175 < b < 7.3999999999999998e-124 or 1.25000000000000008e-69 < b < 3.99999999999999989e59Initial program 67.4%
associate--l+67.4%
fma-define67.4%
sqr-neg67.4%
fma-define67.4%
distribute-rgt-in67.4%
sqr-neg67.4%
distribute-rgt-in67.4%
fma-define67.4%
sqr-neg67.4%
Simplified67.4%
Taylor expanded in a around inf 71.5%
if 3.99999999999999989e59 < b Initial program 72.4%
associate--l+72.4%
fma-define72.4%
sqr-neg72.4%
fma-define72.4%
distribute-rgt-in72.4%
sqr-neg72.4%
distribute-rgt-in72.4%
fma-define72.4%
sqr-neg72.4%
Simplified75.8%
Taylor expanded in b around inf 100.0%
(FPCore (a b)
:precision binary64
(if (<= a -1.02e+14)
(pow a 4.0)
(if (<= a 2700000.0)
(+ (pow b 4.0) -1.0)
(* (pow a 4.0) (- 1.0 (/ 4.0 a))))))
double code(double a, double b) {
double tmp;
if (a <= -1.02e+14) {
tmp = pow(a, 4.0);
} else if (a <= 2700000.0) {
tmp = pow(b, 4.0) + -1.0;
} else {
tmp = pow(a, 4.0) * (1.0 - (4.0 / a));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-1.02d+14)) then
tmp = a ** 4.0d0
else if (a <= 2700000.0d0) then
tmp = (b ** 4.0d0) + (-1.0d0)
else
tmp = (a ** 4.0d0) * (1.0d0 - (4.0d0 / a))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.02e+14) {
tmp = Math.pow(a, 4.0);
} else if (a <= 2700000.0) {
tmp = Math.pow(b, 4.0) + -1.0;
} else {
tmp = Math.pow(a, 4.0) * (1.0 - (4.0 / a));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.02e+14: tmp = math.pow(a, 4.0) elif a <= 2700000.0: tmp = math.pow(b, 4.0) + -1.0 else: tmp = math.pow(a, 4.0) * (1.0 - (4.0 / a)) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.02e+14) tmp = a ^ 4.0; elseif (a <= 2700000.0) tmp = Float64((b ^ 4.0) + -1.0); else tmp = Float64((a ^ 4.0) * Float64(1.0 - Float64(4.0 / a))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.02e+14) tmp = a ^ 4.0; elseif (a <= 2700000.0) tmp = (b ^ 4.0) + -1.0; else tmp = (a ^ 4.0) * (1.0 - (4.0 / a)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.02e+14], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 2700000.0], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 - N[(4.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.02 \cdot 10^{+14}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 2700000:\\
\;\;\;\;{b}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} \cdot \left(1 - \frac{4}{a}\right)\\
\end{array}
\end{array}
if a < -1.02e14Initial program 69.6%
associate--l+69.6%
fma-define69.6%
sqr-neg69.6%
fma-define69.6%
distribute-rgt-in69.6%
sqr-neg69.6%
distribute-rgt-in69.6%
fma-define69.6%
sqr-neg69.6%
Simplified69.6%
Taylor expanded in a around inf 95.4%
if -1.02e14 < a < 2.7e6Initial program 99.2%
associate--l+99.2%
fma-define99.2%
sqr-neg99.2%
fma-define99.2%
distribute-rgt-in99.2%
sqr-neg99.2%
distribute-rgt-in99.2%
fma-define99.2%
sqr-neg99.2%
Simplified99.2%
fma-define99.2%
unpow299.2%
+-commutative99.2%
distribute-lft-in84.0%
fma-define84.0%
add-sqr-sqrt84.0%
pow284.0%
fma-define84.0%
hypot-define84.0%
pow284.0%
fma-define84.0%
add-sqr-sqrt84.0%
pow284.0%
fma-define84.0%
hypot-define84.0%
pow284.0%
Applied egg-rr84.0%
distribute-lft-out99.2%
+-commutative99.2%
rem-square-sqrt99.2%
unpow299.2%
unpow299.2%
hypot-undefine99.2%
unpow299.2%
unpow299.2%
hypot-undefine99.2%
unpow299.2%
pow-sqr99.3%
hypot-undefine99.3%
unpow299.3%
unpow299.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-define99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in a around inf 98.9%
mul-1-neg98.9%
Simplified98.9%
Taylor expanded in a around 0 98.6%
if 2.7e6 < a Initial program 30.6%
associate--l+30.6%
fma-define30.6%
sqr-neg30.6%
fma-define30.6%
distribute-rgt-in30.6%
sqr-neg30.6%
distribute-rgt-in30.6%
fma-define30.6%
sqr-neg30.6%
Simplified36.7%
Taylor expanded in a around inf 92.7%
associate-*r/92.7%
metadata-eval92.7%
Simplified92.7%
Final simplification96.4%
(FPCore (a b) :precision binary64 (if (<= a -1.75e+15) (pow a 4.0) (if (<= a 270000000.0) (+ (pow b 4.0) -1.0) (* (pow a 3.0) (- a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -1.75e+15) {
tmp = pow(a, 4.0);
} else if (a <= 270000000.0) {
tmp = pow(b, 4.0) + -1.0;
} else {
tmp = pow(a, 3.0) * (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 <= (-1.75d+15)) then
tmp = a ** 4.0d0
else if (a <= 270000000.0d0) then
tmp = (b ** 4.0d0) + (-1.0d0)
else
tmp = (a ** 3.0d0) * (a - 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1.75e+15) {
tmp = Math.pow(a, 4.0);
} else if (a <= 270000000.0) {
tmp = Math.pow(b, 4.0) + -1.0;
} else {
tmp = Math.pow(a, 3.0) * (a - 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.75e+15: tmp = math.pow(a, 4.0) elif a <= 270000000.0: tmp = math.pow(b, 4.0) + -1.0 else: tmp = math.pow(a, 3.0) * (a - 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.75e+15) tmp = a ^ 4.0; elseif (a <= 270000000.0) tmp = Float64((b ^ 4.0) + -1.0); else tmp = Float64((a ^ 3.0) * Float64(a - 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.75e+15) tmp = a ^ 4.0; elseif (a <= 270000000.0) tmp = (b ^ 4.0) + -1.0; else tmp = (a ^ 3.0) * (a - 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.75e+15], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 270000000.0], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 3.0], $MachinePrecision] * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.75 \cdot 10^{+15}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 270000000:\\
\;\;\;\;{b}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{3} \cdot \left(a - 4\right)\\
\end{array}
\end{array}
if a < -1.75e15Initial program 69.6%
associate--l+69.6%
fma-define69.6%
sqr-neg69.6%
fma-define69.6%
distribute-rgt-in69.6%
sqr-neg69.6%
distribute-rgt-in69.6%
fma-define69.6%
sqr-neg69.6%
Simplified69.6%
Taylor expanded in a around inf 95.4%
if -1.75e15 < a < 2.7e8Initial program 99.2%
associate--l+99.2%
fma-define99.2%
sqr-neg99.2%
fma-define99.2%
distribute-rgt-in99.2%
sqr-neg99.2%
distribute-rgt-in99.2%
fma-define99.2%
sqr-neg99.2%
Simplified99.2%
fma-define99.2%
unpow299.2%
+-commutative99.2%
distribute-lft-in84.0%
fma-define84.0%
add-sqr-sqrt84.0%
pow284.0%
fma-define84.0%
hypot-define84.0%
pow284.0%
fma-define84.0%
add-sqr-sqrt84.0%
pow284.0%
fma-define84.0%
hypot-define84.0%
pow284.0%
Applied egg-rr84.0%
distribute-lft-out99.2%
+-commutative99.2%
rem-square-sqrt99.2%
unpow299.2%
unpow299.2%
hypot-undefine99.2%
unpow299.2%
unpow299.2%
hypot-undefine99.2%
unpow299.2%
pow-sqr99.3%
hypot-undefine99.3%
unpow299.3%
unpow299.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-define99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in a around inf 98.9%
mul-1-neg98.9%
Simplified98.9%
Taylor expanded in a around 0 98.6%
if 2.7e8 < a Initial program 30.6%
associate--l+30.6%
fma-define30.6%
sqr-neg30.6%
fma-define30.6%
distribute-rgt-in30.6%
sqr-neg30.6%
distribute-rgt-in30.6%
fma-define30.6%
sqr-neg30.6%
Simplified36.7%
Taylor expanded in a around inf 92.7%
associate-*r/92.7%
metadata-eval92.7%
Simplified92.7%
Taylor expanded in a around 0 92.6%
Final simplification96.4%
(FPCore (a b) :precision binary64 (if (or (<= a -105000000000.0) (not (<= a 2300000000.0))) (pow a 4.0) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -105000000000.0) || !(a <= 2300000000.0)) {
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 <= (-105000000000.0d0)) .or. (.not. (a <= 2300000000.0d0))) 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 <= -105000000000.0) || !(a <= 2300000000.0)) {
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 <= -105000000000.0) or not (a <= 2300000000.0): 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 <= -105000000000.0) || !(a <= 2300000000.0)) 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 <= -105000000000.0) || ~((a <= 2300000000.0))) tmp = a ^ 4.0; else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -105000000000.0], N[Not[LessEqual[a, 2300000000.0]], $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 -105000000000 \lor \neg \left(a \leq 2300000000\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if a < -1.05e11 or 2.3e9 < a Initial program 48.1%
associate--l+48.1%
fma-define48.1%
sqr-neg48.1%
fma-define48.1%
distribute-rgt-in48.1%
sqr-neg48.1%
distribute-rgt-in48.1%
fma-define48.1%
sqr-neg48.1%
Simplified51.5%
Taylor expanded in a around inf 93.5%
if -1.05e11 < a < 2.3e9Initial program 99.2%
associate--l+99.2%
fma-define99.2%
sqr-neg99.2%
fma-define99.2%
distribute-rgt-in99.2%
sqr-neg99.2%
distribute-rgt-in99.2%
fma-define99.2%
sqr-neg99.2%
Simplified99.2%
fma-define99.2%
unpow299.2%
+-commutative99.2%
distribute-lft-in84.0%
fma-define84.0%
add-sqr-sqrt84.0%
pow284.0%
fma-define84.0%
hypot-define84.0%
pow284.0%
fma-define84.0%
add-sqr-sqrt84.0%
pow284.0%
fma-define84.0%
hypot-define84.0%
pow284.0%
Applied egg-rr84.0%
distribute-lft-out99.2%
+-commutative99.2%
rem-square-sqrt99.2%
unpow299.2%
unpow299.2%
hypot-undefine99.2%
unpow299.2%
unpow299.2%
hypot-undefine99.2%
unpow299.2%
pow-sqr99.3%
hypot-undefine99.3%
unpow299.3%
unpow299.3%
+-commutative99.3%
unpow299.3%
unpow299.3%
hypot-define99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in a around inf 98.9%
mul-1-neg98.9%
Simplified98.9%
Taylor expanded in a around 0 98.6%
Final simplification96.2%
(FPCore (a b) :precision binary64 (if (or (<= a -2.5e-9) (not (<= a 2.4))) (pow a 4.0) -1.0))
double code(double a, double b) {
double tmp;
if ((a <= -2.5e-9) || !(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 <= (-2.5d-9)) .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 <= -2.5e-9) || !(a <= 2.4)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -2.5e-9) 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 <= -2.5e-9) || !(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 <= -2.5e-9) || ~((a <= 2.4))) tmp = a ^ 4.0; else tmp = -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -2.5e-9], 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 -2.5 \cdot 10^{-9} \lor \neg \left(a \leq 2.4\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if a < -2.5000000000000001e-9 or 2.39999999999999991 < a Initial program 49.8%
associate--l+49.8%
fma-define49.8%
sqr-neg49.8%
fma-define49.8%
distribute-rgt-in49.8%
sqr-neg49.8%
distribute-rgt-in49.8%
fma-define49.8%
sqr-neg49.8%
Simplified53.0%
Taylor expanded in a around inf 89.4%
if -2.5000000000000001e-9 < a < 2.39999999999999991Initial program 99.9%
associate--l+99.9%
fma-define99.9%
sqr-neg99.9%
fma-define99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
fma-define99.9%
sqr-neg99.9%
Simplified99.9%
fma-define99.9%
unpow299.9%
+-commutative99.9%
distribute-lft-in84.0%
fma-define84.0%
add-sqr-sqrt84.0%
pow284.0%
fma-define84.0%
hypot-define84.0%
pow284.0%
fma-define84.0%
add-sqr-sqrt84.0%
pow284.0%
fma-define84.0%
hypot-define84.0%
pow284.0%
Applied egg-rr84.0%
distribute-lft-out99.9%
+-commutative99.9%
rem-square-sqrt99.9%
unpow299.9%
unpow299.9%
hypot-undefine99.9%
unpow299.9%
unpow299.9%
hypot-undefine99.9%
unpow299.9%
pow-sqr100.0%
hypot-undefine100.0%
unpow2100.0%
unpow2100.0%
+-commutative100.0%
unpow2100.0%
unpow2100.0%
hypot-define100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in a around inf 99.2%
mul-1-neg99.2%
Simplified99.2%
Taylor expanded in a around 0 99.2%
Taylor expanded in b around 0 50.4%
Final simplification69.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 75.7%
associate--l+75.7%
fma-define75.7%
sqr-neg75.7%
fma-define75.7%
distribute-rgt-in75.7%
sqr-neg75.7%
distribute-rgt-in75.7%
fma-define75.7%
sqr-neg75.7%
Simplified77.2%
fma-define77.2%
unpow277.2%
+-commutative77.2%
distribute-lft-in66.7%
fma-define66.7%
add-sqr-sqrt66.7%
pow266.7%
fma-define66.7%
hypot-define66.7%
pow266.7%
fma-define66.7%
add-sqr-sqrt66.7%
pow266.7%
fma-define66.7%
hypot-define66.7%
pow266.7%
Applied egg-rr66.7%
distribute-lft-out77.2%
+-commutative77.2%
rem-square-sqrt77.2%
unpow277.2%
unpow277.2%
hypot-undefine77.2%
unpow277.2%
unpow277.2%
hypot-undefine77.2%
unpow277.2%
pow-sqr77.3%
hypot-undefine77.3%
unpow277.3%
unpow277.3%
+-commutative77.3%
unpow277.3%
unpow277.3%
hypot-define77.3%
metadata-eval77.3%
Simplified77.3%
Taylor expanded in a around inf 81.8%
mul-1-neg81.8%
Simplified81.8%
Taylor expanded in a around 0 69.6%
Taylor expanded in b around 0 26.3%
herbie shell --seed 2024093
(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))