
(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 10 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 5e+67) (+ -1.0 t_0) (+ (pow (hypot a b) 4.0) -1.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 <= 5e+67) {
tmp = -1.0 + t_0;
} else {
tmp = pow(hypot(a, b), 4.0) + -1.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 <= 5e+67) {
tmp = -1.0 + t_0;
} else {
tmp = Math.pow(Math.hypot(a, b), 4.0) + -1.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 <= 5e+67: tmp = -1.0 + t_0 else: tmp = math.pow(math.hypot(a, b), 4.0) + -1.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 <= 5e+67) tmp = Float64(-1.0 + t_0); else tmp = Float64((hypot(a, b) ^ 4.0) + -1.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 <= 5e+67) tmp = -1.0 + t_0; else tmp = (hypot(a, b) ^ 4.0) + -1.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, 5e+67], N[(-1.0 + t$95$0), $MachinePrecision], N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + -1.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 5 \cdot 10^{+67}:\\
\;\;\;\;-1 + t_0\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + -1\\
\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))))) < 4.99999999999999976e67Initial program 99.9%
if 4.99999999999999976e67 < (+.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 63.7%
associate--l+63.7%
Simplified70.1%
add-cube-cbrt70.1%
pow370.1%
fma-udef63.8%
associate-*l*63.8%
fma-def66.1%
Applied egg-rr66.1%
Taylor expanded in a around 0 73.4%
unpow1/3100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
fma-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in b around 0 100.0%
Final simplification100.0%
(FPCore (a b) :precision binary64 (+ (pow (hypot a b) 4.0) (pow (cbrt (fma b (* b 12.0) -1.0)) 3.0)))
double code(double a, double b) {
return pow(hypot(a, b), 4.0) + pow(cbrt(fma(b, (b * 12.0), -1.0)), 3.0);
}
function code(a, b) return Float64((hypot(a, b) ^ 4.0) + (cbrt(fma(b, Float64(b * 12.0), -1.0)) ^ 3.0)) end
code[a_, b_] := N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[Power[N[Power[N[(b * N[(b * 12.0), $MachinePrecision] + -1.0), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + {\left(\sqrt[3]{\mathsf{fma}\left(b, b \cdot 12, -1\right)}\right)}^{3}
\end{array}
Initial program 74.9%
associate--l+74.9%
Simplified79.3%
add-cube-cbrt79.3%
pow379.3%
fma-udef75.0%
associate-*l*75.0%
fma-def76.5%
Applied egg-rr76.5%
Taylor expanded in a around 0 52.7%
unpow1/399.2%
*-commutative99.2%
unpow299.2%
associate-*l*99.2%
fma-neg99.2%
metadata-eval99.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) (- 1.0 a)) (* (* b b) (+ a 3.0)))))))
(if (<= t_0 INFINITY) (+ -1.0 t_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 = -1.0 + t_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 = -1.0 + t_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 = -1.0 + t_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(-1.0 + t_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 = -1.0 + t_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[(-1.0 + t$95$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:\\
\;\;\;\;-1 + t_0\\
\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.9%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) Initial program 0.0%
associate--l+0.0%
Simplified17.2%
add-cube-cbrt17.2%
pow317.2%
fma-udef0.0%
associate-*l*0.0%
fma-def6.3%
Applied egg-rr6.3%
Taylor expanded in a around inf 91.1%
Final simplification97.7%
(FPCore (a b)
:precision binary64
(if (<= a -3.3e+44)
(pow a 4.0)
(if (<= a 38000.0)
(+ -1.0 (+ (pow b 4.0) (* b (* b 12.0))))
(+ -1.0 (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -3.3e+44) {
tmp = pow(a, 4.0);
} else if (a <= 38000.0) {
tmp = -1.0 + (pow(b, 4.0) + (b * (b * 12.0)));
} else {
tmp = -1.0 + 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 <= (-3.3d+44)) then
tmp = a ** 4.0d0
else if (a <= 38000.0d0) then
tmp = (-1.0d0) + ((b ** 4.0d0) + (b * (b * 12.0d0)))
else
tmp = (-1.0d0) + (a ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -3.3e+44) {
tmp = Math.pow(a, 4.0);
} else if (a <= 38000.0) {
tmp = -1.0 + (Math.pow(b, 4.0) + (b * (b * 12.0)));
} else {
tmp = -1.0 + Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -3.3e+44: tmp = math.pow(a, 4.0) elif a <= 38000.0: tmp = -1.0 + (math.pow(b, 4.0) + (b * (b * 12.0))) else: tmp = -1.0 + math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -3.3e+44) tmp = a ^ 4.0; elseif (a <= 38000.0) tmp = Float64(-1.0 + Float64((b ^ 4.0) + Float64(b * Float64(b * 12.0)))); else tmp = Float64(-1.0 + (a ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -3.3e+44) tmp = a ^ 4.0; elseif (a <= 38000.0) tmp = -1.0 + ((b ^ 4.0) + (b * (b * 12.0))); else tmp = -1.0 + (a ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -3.3e+44], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 38000.0], N[(-1.0 + N[(N[Power[b, 4.0], $MachinePrecision] + N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.3 \cdot 10^{+44}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 38000:\\
\;\;\;\;-1 + \left({b}^{4} + b \cdot \left(b \cdot 12\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{4}\\
\end{array}
\end{array}
if a < -3.30000000000000013e44Initial program 51.9%
associate--l+51.9%
Simplified73.1%
add-cube-cbrt73.1%
pow373.1%
fma-udef51.9%
associate-*l*51.9%
fma-def59.6%
Applied egg-rr59.6%
Taylor expanded in a around inf 94.6%
if -3.30000000000000013e44 < a < 38000Initial program 97.1%
sub-neg97.1%
fma-def97.1%
fma-def97.1%
+-commutative97.1%
metadata-eval97.1%
Simplified97.1%
Taylor expanded in a around 0 83.9%
+-commutative83.9%
+-commutative83.9%
associate-+l+83.9%
+-commutative83.9%
associate-*r*83.9%
distribute-rgt-out96.1%
metadata-eval96.1%
distribute-lft-in96.1%
unpow296.1%
distribute-rgt-in96.1%
metadata-eval96.1%
Simplified96.1%
Taylor expanded in a around 0 98.9%
*-commutative98.9%
unpow298.9%
associate-*l*98.9%
Simplified98.9%
if 38000 < a Initial program 45.1%
sub-neg45.1%
fma-def45.1%
fma-def49.7%
+-commutative49.7%
metadata-eval49.7%
Simplified49.7%
Taylor expanded in a around inf 86.1%
Final simplification94.8%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e-19) (+ -1.0 (* 4.0 (* a a))) (if (<= (* b b) 5e+149) (pow a 4.0) (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e-19) {
tmp = -1.0 + (4.0 * (a * a));
} else if ((b * b) <= 5e+149) {
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 * b) <= 1d-19) then
tmp = (-1.0d0) + (4.0d0 * (a * a))
else if ((b * b) <= 5d+149) 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 * b) <= 1e-19) {
tmp = -1.0 + (4.0 * (a * a));
} else if ((b * b) <= 5e+149) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e-19: tmp = -1.0 + (4.0 * (a * a)) elif (b * b) <= 5e+149: tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e-19) tmp = Float64(-1.0 + Float64(4.0 * Float64(a * a))); elseif (Float64(b * b) <= 5e+149) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e-19) tmp = -1.0 + (4.0 * (a * a)); elseif ((b * b) <= 5e+149) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e-19], N[(-1.0 + N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(b * b), $MachinePrecision], 5e+149], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{-19}:\\
\;\;\;\;-1 + 4 \cdot \left(a \cdot a\right)\\
\mathbf{elif}\;b \cdot b \leq 5 \cdot 10^{+149}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 9.9999999999999998e-20Initial program 88.7%
sub-neg88.7%
fma-def88.7%
fma-def88.7%
+-commutative88.7%
metadata-eval88.7%
Simplified88.7%
Taylor expanded in b around 0 88.8%
unpow288.8%
Simplified88.8%
Taylor expanded in a around 0 77.2%
unpow277.2%
Simplified77.2%
if 9.9999999999999998e-20 < (*.f64 b b) < 4.9999999999999999e149Initial program 63.7%
associate--l+63.7%
Simplified69.2%
add-cube-cbrt69.2%
pow369.2%
fma-udef64.1%
associate-*l*64.1%
fma-def69.2%
Applied egg-rr69.2%
Taylor expanded in a around inf 60.3%
if 4.9999999999999999e149 < (*.f64 b b) Initial program 63.4%
associate--l+63.4%
Simplified72.3%
add-cube-cbrt72.3%
pow372.3%
fma-udef63.4%
associate-*l*63.4%
fma-def65.3%
Applied egg-rr65.3%
Taylor expanded in b around inf 100.0%
Final simplification83.6%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+149) (+ -1.0 (pow a 4.0)) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+149) {
tmp = -1.0 + 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 * b) <= 5d+149) then
tmp = (-1.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) <= 5e+149) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+149: tmp = -1.0 + math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+149) tmp = Float64(-1.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) <= 5e+149) tmp = -1.0 + (a ^ 4.0); else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+149], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+149}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 4.9999999999999999e149Initial program 82.4%
sub-neg82.4%
fma-def82.4%
fma-def82.4%
+-commutative82.4%
metadata-eval82.4%
Simplified82.4%
Taylor expanded in a around inf 88.9%
if 4.9999999999999999e149 < (*.f64 b b) Initial program 63.4%
associate--l+63.4%
Simplified72.3%
add-cube-cbrt72.3%
pow372.3%
fma-udef63.4%
associate-*l*63.4%
fma-def65.3%
Applied egg-rr65.3%
Taylor expanded in b around inf 100.0%
Final simplification93.3%
(FPCore (a b) :precision binary64 (if (<= a -3.3e+44) (pow a 4.0) (if (<= a 35000.0) (+ -1.0 (* b (* b 12.0))) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -3.3e+44) {
tmp = pow(a, 4.0);
} else if (a <= 35000.0) {
tmp = -1.0 + (b * (b * 12.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 <= (-3.3d+44)) then
tmp = a ** 4.0d0
else if (a <= 35000.0d0) then
tmp = (-1.0d0) + (b * (b * 12.0d0))
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -3.3e+44) {
tmp = Math.pow(a, 4.0);
} else if (a <= 35000.0) {
tmp = -1.0 + (b * (b * 12.0));
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -3.3e+44: tmp = math.pow(a, 4.0) elif a <= 35000.0: tmp = -1.0 + (b * (b * 12.0)) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -3.3e+44) tmp = a ^ 4.0; elseif (a <= 35000.0) tmp = Float64(-1.0 + Float64(b * Float64(b * 12.0))); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -3.3e+44) tmp = a ^ 4.0; elseif (a <= 35000.0) tmp = -1.0 + (b * (b * 12.0)); else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -3.3e+44], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 35000.0], N[(-1.0 + N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.3 \cdot 10^{+44}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 35000:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 12\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -3.30000000000000013e44 or 35000 < a Initial program 48.1%
associate--l+48.1%
Simplified57.7%
add-cube-cbrt57.7%
pow357.7%
fma-udef48.3%
associate-*l*48.3%
fma-def51.7%
Applied egg-rr51.7%
Taylor expanded in a around inf 89.9%
if -3.30000000000000013e44 < a < 35000Initial program 97.1%
sub-neg97.1%
fma-def97.1%
fma-def97.1%
+-commutative97.1%
metadata-eval97.1%
Simplified97.1%
Taylor expanded in a around 0 83.9%
+-commutative83.9%
+-commutative83.9%
associate-+l+83.9%
+-commutative83.9%
associate-*r*83.9%
distribute-rgt-out96.1%
metadata-eval96.1%
distribute-lft-in96.1%
unpow296.1%
distribute-rgt-in96.1%
metadata-eval96.1%
Simplified96.1%
Taylor expanded in b around 0 72.9%
+-commutative72.9%
fma-def72.9%
*-commutative72.9%
unpow272.9%
associate-*l*72.9%
Simplified72.9%
Taylor expanded in a around 0 75.9%
unpow275.9%
*-commutative75.9%
associate-*l*75.9%
Simplified75.9%
Final simplification82.2%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+296) (+ -1.0 (* 4.0 (* a a))) (+ -1.0 (* b (* b 12.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+296) {
tmp = -1.0 + (4.0 * (a * a));
} else {
tmp = -1.0 + (b * (b * 12.0));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 1d+296) then
tmp = (-1.0d0) + (4.0d0 * (a * a))
else
tmp = (-1.0d0) + (b * (b * 12.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+296) {
tmp = -1.0 + (4.0 * (a * a));
} else {
tmp = -1.0 + (b * (b * 12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e+296: tmp = -1.0 + (4.0 * (a * a)) else: tmp = -1.0 + (b * (b * 12.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e+296) tmp = Float64(-1.0 + Float64(4.0 * Float64(a * a))); else tmp = Float64(-1.0 + Float64(b * Float64(b * 12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e+296) tmp = -1.0 + (4.0 * (a * a)); else tmp = -1.0 + (b * (b * 12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+296], N[(-1.0 + N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+296}:\\
\;\;\;\;-1 + 4 \cdot \left(a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 12\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 9.99999999999999981e295Initial program 78.4%
sub-neg78.4%
fma-def78.4%
fma-def78.9%
+-commutative78.9%
metadata-eval78.9%
Simplified78.9%
Taylor expanded in b around 0 66.6%
unpow266.6%
Simplified66.6%
Taylor expanded in a around 0 61.0%
unpow261.0%
Simplified61.0%
if 9.99999999999999981e295 < (*.f64 b b) Initial program 64.6%
sub-neg64.6%
fma-def64.6%
fma-def67.7%
+-commutative67.7%
metadata-eval67.7%
Simplified67.7%
Taylor expanded in a around 0 49.2%
+-commutative49.2%
+-commutative49.2%
associate-+l+49.2%
+-commutative49.2%
associate-*r*49.2%
distribute-rgt-out75.4%
metadata-eval75.4%
distribute-lft-in75.4%
unpow275.4%
distribute-rgt-in75.4%
metadata-eval75.4%
Simplified75.4%
Taylor expanded in b around 0 74.0%
+-commutative74.0%
fma-def74.0%
*-commutative74.0%
unpow274.0%
associate-*l*74.0%
Simplified74.0%
Taylor expanded in a around 0 97.4%
unpow297.4%
*-commutative97.4%
associate-*l*97.4%
Simplified97.4%
Final simplification70.2%
(FPCore (a b) :precision binary64 (+ -1.0 (* 4.0 (* a a))))
double code(double a, double b) {
return -1.0 + (4.0 * (a * a));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + (4.0d0 * (a * a))
end function
public static double code(double a, double b) {
return -1.0 + (4.0 * (a * a));
}
def code(a, b): return -1.0 + (4.0 * (a * a))
function code(a, b) return Float64(-1.0 + Float64(4.0 * Float64(a * a))) end
function tmp = code(a, b) tmp = -1.0 + (4.0 * (a * a)); end
code[a_, b_] := N[(-1.0 + N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + 4 \cdot \left(a \cdot a\right)
\end{array}
Initial program 74.9%
sub-neg74.9%
fma-def74.9%
fma-def76.1%
+-commutative76.1%
metadata-eval76.1%
Simplified76.1%
Taylor expanded in b around 0 55.1%
unpow255.1%
Simplified55.1%
Taylor expanded in a around 0 50.0%
unpow250.0%
Simplified50.0%
Final simplification50.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.9%
sub-neg74.9%
fma-def74.9%
fma-def76.1%
+-commutative76.1%
metadata-eval76.1%
Simplified76.1%
Taylor expanded in a around 0 56.4%
+-commutative56.4%
+-commutative56.4%
associate-+l+56.4%
+-commutative56.4%
associate-*r*56.4%
distribute-rgt-out63.1%
metadata-eval63.1%
distribute-lft-in63.1%
unpow263.1%
distribute-rgt-in63.1%
metadata-eval63.1%
Simplified63.1%
Taylor expanded in b around 0 27.1%
Final simplification27.1%
herbie shell --seed 2023258
(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))