
(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
(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) (+ 1.0 (/ (- (* 2.0 (/ (* b b) a)) 4.0) a))))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = pow(a, 4.0) * (1.0 + (((2.0 * ((b * b) / a)) - 4.0) / a));
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = Math.pow(a, 4.0) * (1.0 + (((2.0 * ((b * b) / a)) - 4.0) / a));
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = math.pow(a, 4.0) * (1.0 + (((2.0 * ((b * b) / a)) - 4.0) / a)) return tmp
function code(a, b) t_0 = Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = Float64((a ^ 4.0) * Float64(1.0 + Float64(Float64(Float64(2.0 * Float64(Float64(b * b) / a)) - 4.0) / a))); end return tmp end
function tmp_2 = code(a, b) t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = (a ^ 4.0) * (1.0 + (((2.0 * ((b * b) / a)) - 4.0) / a)); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] * N[(1.0 + N[(N[(N[(2.0 * N[(N[(b * b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] - 4.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0 + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} \cdot \left(1 + \frac{2 \cdot \frac{b \cdot b}{a} - 4}{a}\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%
Simplified7.7%
Taylor expanded in a around -inf 100.0%
mul-1-neg100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in b around inf 100.0%
unpow2100.0%
Applied egg-rr100.0%
Final simplification99.9%
(FPCore (a b)
:precision binary64
(if (<= a -460000000000.0)
(pow a 4.0)
(if (<= a -1.12e-235)
(+ (* (* b b) 12.0) -1.0)
(if (<= a -9e-264)
(pow b 4.0)
(if (<= a 1.6e+25)
(+ -1.0 (* 4.0 (* (* b b) (+ a 3.0))))
(pow a 4.0))))))
double code(double a, double b) {
double tmp;
if (a <= -460000000000.0) {
tmp = pow(a, 4.0);
} else if (a <= -1.12e-235) {
tmp = ((b * b) * 12.0) + -1.0;
} else if (a <= -9e-264) {
tmp = pow(b, 4.0);
} else if (a <= 1.6e+25) {
tmp = -1.0 + (4.0 * ((b * b) * (a + 3.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 <= (-460000000000.0d0)) then
tmp = a ** 4.0d0
else if (a <= (-1.12d-235)) then
tmp = ((b * b) * 12.0d0) + (-1.0d0)
else if (a <= (-9d-264)) then
tmp = b ** 4.0d0
else if (a <= 1.6d+25) then
tmp = (-1.0d0) + (4.0d0 * ((b * b) * (a + 3.0d0)))
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -460000000000.0) {
tmp = Math.pow(a, 4.0);
} else if (a <= -1.12e-235) {
tmp = ((b * b) * 12.0) + -1.0;
} else if (a <= -9e-264) {
tmp = Math.pow(b, 4.0);
} else if (a <= 1.6e+25) {
tmp = -1.0 + (4.0 * ((b * b) * (a + 3.0)));
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -460000000000.0: tmp = math.pow(a, 4.0) elif a <= -1.12e-235: tmp = ((b * b) * 12.0) + -1.0 elif a <= -9e-264: tmp = math.pow(b, 4.0) elif a <= 1.6e+25: tmp = -1.0 + (4.0 * ((b * b) * (a + 3.0))) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -460000000000.0) tmp = a ^ 4.0; elseif (a <= -1.12e-235) tmp = Float64(Float64(Float64(b * b) * 12.0) + -1.0); elseif (a <= -9e-264) tmp = b ^ 4.0; elseif (a <= 1.6e+25) tmp = Float64(-1.0 + Float64(4.0 * Float64(Float64(b * b) * Float64(a + 3.0)))); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -460000000000.0) tmp = a ^ 4.0; elseif (a <= -1.12e-235) tmp = ((b * b) * 12.0) + -1.0; elseif (a <= -9e-264) tmp = b ^ 4.0; elseif (a <= 1.6e+25) tmp = -1.0 + (4.0 * ((b * b) * (a + 3.0))); else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -460000000000.0], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, -1.12e-235], N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, -9e-264], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, 1.6e+25], N[(-1.0 + N[(4.0 * N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -460000000000:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq -1.12 \cdot 10^{-235}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\mathbf{elif}\;a \leq -9 \cdot 10^{-264}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq 1.6 \cdot 10^{+25}:\\
\;\;\;\;-1 + 4 \cdot \left(\left(b \cdot b\right) \cdot \left(a + 3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -4.6e11 or 1.6e25 < a Initial program 43.1%
associate--l+43.1%
fma-define43.1%
sqr-neg43.1%
fma-define43.1%
distribute-rgt-in43.1%
sqr-neg43.1%
distribute-rgt-in43.1%
fma-define43.1%
sqr-neg43.1%
Simplified47.6%
Taylor expanded in a around inf 93.9%
if -4.6e11 < a < -1.11999999999999995e-235Initial program 96.6%
associate--l+96.6%
fma-define96.6%
sqr-neg96.6%
fma-define96.6%
distribute-rgt-in96.6%
sqr-neg96.6%
distribute-rgt-in96.6%
fma-define96.6%
sqr-neg96.6%
Simplified96.6%
fma-define96.6%
add-cbrt-cube86.0%
pow386.0%
pow-pow86.0%
fma-define86.0%
add-sqr-sqrt86.0%
pow286.0%
fma-define86.0%
hypot-define86.0%
metadata-eval86.0%
Applied egg-rr86.0%
hypot-undefine86.0%
unpow286.0%
unpow286.0%
+-commutative86.0%
unpow286.0%
unpow286.0%
hypot-define86.0%
Simplified86.0%
Taylor expanded in b around 0 73.5%
Taylor expanded in a around 0 74.5%
unpow223.8%
Applied egg-rr74.5%
if -1.11999999999999995e-235 < a < -9.0000000000000001e-264Initial program 99.6%
associate--l+99.6%
fma-define99.6%
sqr-neg99.6%
fma-define99.6%
distribute-rgt-in99.6%
sqr-neg99.6%
distribute-rgt-in99.6%
fma-define99.6%
sqr-neg99.6%
Simplified99.6%
Taylor expanded in b around inf 87.9%
if -9.0000000000000001e-264 < a < 1.6e25Initial 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%
add-cbrt-cube95.1%
pow395.1%
pow-pow95.1%
fma-define95.1%
add-sqr-sqrt95.1%
pow295.1%
fma-define95.1%
hypot-define95.1%
metadata-eval95.1%
Applied egg-rr95.1%
hypot-undefine95.1%
unpow295.1%
unpow295.1%
+-commutative95.1%
unpow295.1%
unpow295.1%
hypot-define95.1%
Simplified95.1%
Taylor expanded in b around 0 82.8%
Taylor expanded in a around 0 76.6%
sub-neg76.6%
+-commutative76.6%
associate-*r*76.6%
distribute-rgt-out79.2%
metadata-eval79.2%
distribute-lft-in79.2%
associate-*l*79.2%
*-commutative79.2%
associate-*r*79.2%
metadata-eval79.2%
+-commutative79.2%
+-commutative79.2%
Simplified79.2%
unpow220.2%
Applied egg-rr79.2%
Final simplification84.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1000000000.0) (- -1.0 (* (pow a 2.0) (- (* a (- 4.0 a)) 4.0))) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1000000000.0) {
tmp = -1.0 - (pow(a, 2.0) * ((a * (4.0 - 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 * b) <= 1000000000.0d0) then
tmp = (-1.0d0) - ((a ** 2.0d0) * ((a * (4.0d0 - 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 * b) <= 1000000000.0) {
tmp = -1.0 - (Math.pow(a, 2.0) * ((a * (4.0 - a)) - 4.0));
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1000000000.0: tmp = -1.0 - (math.pow(a, 2.0) * ((a * (4.0 - a)) - 4.0)) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1000000000.0) tmp = Float64(-1.0 - Float64((a ^ 2.0) * Float64(Float64(a * Float64(4.0 - a)) - 4.0))); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1000000000.0) tmp = -1.0 - ((a ^ 2.0) * ((a * (4.0 - a)) - 4.0)); else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1000000000.0], N[(-1.0 - N[(N[Power[a, 2.0], $MachinePrecision] * N[(N[(a * N[(4.0 - a), $MachinePrecision]), $MachinePrecision] - 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 1000000000:\\
\;\;\;\;-1 - {a}^{2} \cdot \left(a \cdot \left(4 - a\right) - 4\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 1e9Initial program 85.0%
associate--l+85.0%
fma-define85.0%
sqr-neg85.0%
fma-define85.0%
distribute-rgt-in85.0%
sqr-neg85.0%
distribute-rgt-in85.0%
fma-define85.0%
sqr-neg85.0%
Simplified85.0%
fma-define85.0%
add-cbrt-cube76.6%
pow376.6%
pow-pow76.6%
fma-define76.6%
add-sqr-sqrt76.6%
pow276.6%
fma-define76.6%
hypot-define76.6%
metadata-eval76.6%
Applied egg-rr76.6%
hypot-undefine76.6%
unpow276.6%
unpow276.6%
+-commutative76.6%
unpow276.6%
unpow276.6%
hypot-define76.6%
Simplified76.6%
Taylor expanded in b around 0 75.8%
Taylor expanded in b around 0 75.4%
Taylor expanded in a around 0 98.7%
if 1e9 < (*.f64 b b) Initial program 65.1%
associate--l+65.1%
fma-define65.1%
sqr-neg65.1%
fma-define65.1%
distribute-rgt-in65.1%
sqr-neg65.1%
distribute-rgt-in65.1%
fma-define65.1%
sqr-neg65.1%
Simplified68.8%
Taylor expanded in b around inf 92.2%
Final simplification95.3%
(FPCore (a b) :precision binary64 (if (<= (* b b) 0.001) (+ (* 4.0 (pow a 2.0)) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.001) {
tmp = (4.0 * pow(a, 2.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) <= 0.001d0) then
tmp = (4.0d0 * (a ** 2.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) <= 0.001) {
tmp = (4.0 * Math.pow(a, 2.0)) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 0.001: tmp = (4.0 * math.pow(a, 2.0)) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 0.001) tmp = Float64(Float64(4.0 * (a ^ 2.0)) + -1.0); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 0.001) tmp = (4.0 * (a ^ 2.0)) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.001], N[(N[(4.0 * N[Power[a, 2.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.001:\\
\;\;\;\;4 \cdot {a}^{2} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 1e-3Initial program 84.8%
associate--l+84.8%
fma-define84.8%
sqr-neg84.8%
fma-define84.8%
distribute-rgt-in84.8%
sqr-neg84.8%
distribute-rgt-in84.8%
fma-define84.8%
sqr-neg84.8%
Simplified84.8%
fma-define84.8%
add-cbrt-cube77.0%
pow377.0%
pow-pow77.0%
fma-define77.0%
add-sqr-sqrt77.0%
pow277.0%
fma-define77.0%
hypot-define77.0%
metadata-eval77.0%
Applied egg-rr77.0%
hypot-undefine77.0%
unpow277.0%
unpow277.0%
+-commutative77.0%
unpow277.0%
unpow277.0%
hypot-define77.0%
Simplified77.0%
Taylor expanded in b around 0 76.8%
Taylor expanded in b around 0 76.6%
Taylor expanded in a around 0 73.6%
if 1e-3 < (*.f64 b b) Initial program 65.6%
associate--l+65.6%
fma-define65.6%
sqr-neg65.6%
fma-define65.6%
distribute-rgt-in65.6%
sqr-neg65.6%
distribute-rgt-in65.6%
fma-define65.6%
sqr-neg65.6%
Simplified69.2%
Taylor expanded in b around inf 91.0%
Final simplification82.9%
(FPCore (a b) :precision binary64 (if (or (<= a -8500000000000.0) (not (<= a 1.6e+25))) (pow a 4.0) (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -8500000000000.0) || !(a <= 1.6e+25)) {
tmp = pow(a, 4.0);
} else {
tmp = ((b * b) * 12.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 <= (-8500000000000.0d0)) .or. (.not. (a <= 1.6d+25))) then
tmp = a ** 4.0d0
else
tmp = ((b * b) * 12.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -8500000000000.0) || !(a <= 1.6e+25)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = ((b * b) * 12.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -8500000000000.0) or not (a <= 1.6e+25): tmp = math.pow(a, 4.0) else: tmp = ((b * b) * 12.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -8500000000000.0) || !(a <= 1.6e+25)) tmp = a ^ 4.0; else tmp = Float64(Float64(Float64(b * b) * 12.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -8500000000000.0) || ~((a <= 1.6e+25))) tmp = a ^ 4.0; else tmp = ((b * b) * 12.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -8500000000000.0], N[Not[LessEqual[a, 1.6e+25]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8500000000000 \lor \neg \left(a \leq 1.6 \cdot 10^{+25}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\end{array}
\end{array}
if a < -8.5e12 or 1.6e25 < a Initial program 43.1%
associate--l+43.1%
fma-define43.1%
sqr-neg43.1%
fma-define43.1%
distribute-rgt-in43.1%
sqr-neg43.1%
distribute-rgt-in43.1%
fma-define43.1%
sqr-neg43.1%
Simplified47.6%
Taylor expanded in a around inf 93.9%
if -8.5e12 < a < 1.6e25Initial program 98.5%
associate--l+98.5%
fma-define98.5%
sqr-neg98.5%
fma-define98.5%
distribute-rgt-in98.5%
sqr-neg98.5%
distribute-rgt-in98.5%
fma-define98.5%
sqr-neg98.5%
Simplified98.5%
fma-define98.5%
add-cbrt-cube90.2%
pow390.2%
pow-pow90.2%
fma-define90.2%
add-sqr-sqrt90.2%
pow290.2%
fma-define90.2%
hypot-define90.2%
metadata-eval90.2%
Applied egg-rr90.2%
hypot-undefine90.2%
unpow290.2%
unpow290.2%
+-commutative90.2%
unpow290.2%
unpow290.2%
hypot-define90.2%
Simplified90.2%
Taylor expanded in b around 0 75.3%
Taylor expanded in a around 0 73.9%
unpow220.7%
Applied egg-rr73.9%
Final simplification82.5%
(FPCore (a b) :precision binary64 (if (or (<= a -4000000000000.0) (not (<= a 2.4e+25))) (* (* a a) (+ 4.0 (* a (- a 4.0)))) (+ (* (* b b) 12.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -4000000000000.0) || !(a <= 2.4e+25)) {
tmp = (a * a) * (4.0 + (a * (a - 4.0)));
} else {
tmp = ((b * b) * 12.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 <= (-4000000000000.0d0)) .or. (.not. (a <= 2.4d+25))) then
tmp = (a * a) * (4.0d0 + (a * (a - 4.0d0)))
else
tmp = ((b * b) * 12.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -4000000000000.0) || !(a <= 2.4e+25)) {
tmp = (a * a) * (4.0 + (a * (a - 4.0)));
} else {
tmp = ((b * b) * 12.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -4000000000000.0) or not (a <= 2.4e+25): tmp = (a * a) * (4.0 + (a * (a - 4.0))) else: tmp = ((b * b) * 12.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -4000000000000.0) || !(a <= 2.4e+25)) tmp = Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a - 4.0)))); else tmp = Float64(Float64(Float64(b * b) * 12.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -4000000000000.0) || ~((a <= 2.4e+25))) tmp = (a * a) * (4.0 + (a * (a - 4.0))); else tmp = ((b * b) * 12.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -4000000000000.0], N[Not[LessEqual[a, 2.4e+25]], $MachinePrecision]], N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4000000000000 \lor \neg \left(a \leq 2.4 \cdot 10^{+25}\right):\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a - 4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 12 + -1\\
\end{array}
\end{array}
if a < -4e12 or 2.39999999999999996e25 < a Initial program 43.1%
associate--l+43.1%
fma-define43.1%
sqr-neg43.1%
fma-define43.1%
distribute-rgt-in43.1%
sqr-neg43.1%
distribute-rgt-in43.1%
fma-define43.1%
sqr-neg43.1%
Simplified47.6%
Taylor expanded in a around -inf 99.2%
mul-1-neg99.2%
mul-1-neg99.2%
Simplified99.2%
Taylor expanded in b around 0 93.9%
associate-*r/93.9%
metadata-eval93.9%
Simplified93.9%
Taylor expanded in a around 0 93.8%
unpow293.8%
Applied egg-rr93.8%
if -4e12 < a < 2.39999999999999996e25Initial program 98.5%
associate--l+98.5%
fma-define98.5%
sqr-neg98.5%
fma-define98.5%
distribute-rgt-in98.5%
sqr-neg98.5%
distribute-rgt-in98.5%
fma-define98.5%
sqr-neg98.5%
Simplified98.5%
fma-define98.5%
add-cbrt-cube90.2%
pow390.2%
pow-pow90.2%
fma-define90.2%
add-sqr-sqrt90.2%
pow290.2%
fma-define90.2%
hypot-define90.2%
metadata-eval90.2%
Applied egg-rr90.2%
hypot-undefine90.2%
unpow290.2%
unpow290.2%
+-commutative90.2%
unpow290.2%
unpow290.2%
hypot-define90.2%
Simplified90.2%
Taylor expanded in b around 0 75.3%
Taylor expanded in a around 0 73.9%
unpow220.7%
Applied egg-rr73.9%
Final simplification82.5%
(FPCore (a b) :precision binary64 (+ (* (* b b) 12.0) -1.0))
double code(double a, double b) {
return ((b * b) * 12.0) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((b * b) * 12.0d0) + (-1.0d0)
end function
public static double code(double a, double b) {
return ((b * b) * 12.0) + -1.0;
}
def code(a, b): return ((b * b) * 12.0) + -1.0
function code(a, b) return Float64(Float64(Float64(b * b) * 12.0) + -1.0) end
function tmp = code(a, b) tmp = ((b * b) * 12.0) + -1.0; end
code[a_, b_] := N[(N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(b \cdot b\right) \cdot 12 + -1
\end{array}
Initial program 74.5%
associate--l+74.5%
fma-define74.5%
sqr-neg74.5%
fma-define74.5%
distribute-rgt-in74.5%
sqr-neg74.5%
distribute-rgt-in74.5%
fma-define74.5%
sqr-neg74.5%
Simplified76.4%
fma-define76.4%
add-cbrt-cube67.4%
pow367.4%
pow-pow67.4%
fma-define67.4%
add-sqr-sqrt67.4%
pow267.4%
fma-define67.4%
hypot-define67.4%
metadata-eval67.4%
Applied egg-rr67.4%
hypot-undefine67.4%
unpow267.4%
unpow267.4%
+-commutative67.4%
unpow267.4%
unpow267.4%
hypot-define67.4%
Simplified67.4%
Taylor expanded in b around 0 59.0%
Taylor expanded in a around 0 52.0%
unpow254.7%
Applied egg-rr52.0%
Final simplification52.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 74.5%
associate--l+74.5%
fma-define74.5%
sqr-neg74.5%
fma-define74.5%
distribute-rgt-in74.5%
sqr-neg74.5%
distribute-rgt-in74.5%
fma-define74.5%
sqr-neg74.5%
Simplified76.4%
fma-define76.4%
add-cbrt-cube67.4%
pow367.4%
pow-pow67.4%
fma-define67.4%
add-sqr-sqrt67.4%
pow267.4%
fma-define67.4%
hypot-define67.4%
metadata-eval67.4%
Applied egg-rr67.4%
hypot-undefine67.4%
unpow267.4%
unpow267.4%
+-commutative67.4%
unpow267.4%
unpow267.4%
hypot-define67.4%
Simplified67.4%
Taylor expanded in b around 0 59.0%
Taylor expanded in a around 0 52.0%
Taylor expanded in b around 0 23.0%
herbie shell --seed 2024092
(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))