
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 + a)) + ((b * b) * (1.0d0 - (3.0d0 * a)))))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 + a)) + Float64(Float64(b * b) * Float64(1.0 - Float64(3.0 * a)))))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 + a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (((a * a) * (1.0d0 + a)) + ((b * b) * (1.0d0 - (3.0d0 * a)))))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 + a)) + Float64(Float64(b * b) * Float64(1.0 - Float64(3.0 * a)))))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (1.0 + a)) + ((b * b) * (1.0 - (3.0 * a)))))) - 1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 + a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1
\end{array}
(FPCore (a b) :precision binary64 (if (<= a -2e+106) (pow a 4.0) (+ (pow (hypot a b) 4.0) (+ (* 4.0 (* a (* a a))) -1.0))))
double code(double a, double b) {
double tmp;
if (a <= -2e+106) {
tmp = pow(a, 4.0);
} else {
tmp = pow(hypot(a, b), 4.0) + ((4.0 * (a * (a * a))) + -1.0);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= -2e+106) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(Math.hypot(a, b), 4.0) + ((4.0 * (a * (a * a))) + -1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -2e+106: tmp = math.pow(a, 4.0) else: tmp = math.pow(math.hypot(a, b), 4.0) + ((4.0 * (a * (a * a))) + -1.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -2e+106) tmp = a ^ 4.0; else tmp = Float64((hypot(a, b) ^ 4.0) + Float64(Float64(4.0 * Float64(a * Float64(a * a))) + -1.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -2e+106) tmp = a ^ 4.0; else tmp = (hypot(a, b) ^ 4.0) + ((4.0 * (a * (a * a))) + -1.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -2e+106], N[Power[a, 4.0], $MachinePrecision], N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(N[(4.0 * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2 \cdot 10^{+106}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \left(4 \cdot \left(a \cdot \left(a \cdot a\right)\right) + -1\right)\\
\end{array}
\end{array}
if a < -2.00000000000000018e106Initial program 0.0%
associate--l+0.0%
fma-def0.0%
Simplified4.4%
Taylor expanded in a around inf 100.0%
if -2.00000000000000018e106 < a Initial program 85.1%
associate--l+85.1%
fma-def85.1%
Simplified85.1%
fma-def85.1%
add-sqr-sqrt85.1%
hypot-udef85.1%
hypot-udef85.1%
pow-prod-down85.1%
pow-prod-up85.2%
metadata-eval85.2%
expm1-log1p-u83.4%
expm1-udef83.4%
Applied egg-rr83.4%
expm1-def83.4%
expm1-log1p85.2%
Simplified85.2%
Taylor expanded in a around inf 98.4%
unpow398.4%
Applied egg-rr98.4%
Final simplification98.7%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))))
(if (<= t_0 INFINITY)
(+ t_0 -1.0)
(+ (pow a 4.0) (+ (* 4.0 (* a a)) -1.0)))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = pow(a, 4.0) + ((4.0 * (a * a)) + -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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = Math.pow(a, 4.0) + ((4.0 * (a * a)) + -1.0);
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = math.pow(a, 4.0) + ((4.0 * (a * a)) + -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(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0)))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = Float64((a ^ 4.0) + Float64(Float64(4.0 * Float64(a * a)) + -1.0)); end return tmp end
function tmp_2 = code(a, b) t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = (a ^ 4.0) + ((4.0 * (a * a)) + -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[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + N[(N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] + -1.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(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;t_0 + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + \left(4 \cdot \left(a \cdot a\right) + -1\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (+.f64 1 a)) (*.f64 (*.f64 b b) (-.f64 1 (*.f64 3 a)))))) < +inf.0Initial program 99.7%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (+.f64 1 a)) (*.f64 (*.f64 b b) (-.f64 1 (*.f64 3 a)))))) Initial program 0.0%
associate--l+0.0%
fma-def0.0%
Simplified2.6%
Taylor expanded in b around 0 35.9%
associate--l+35.9%
associate-*r*35.9%
unpow235.9%
Simplified35.9%
Taylor expanded in a around 0 95.1%
unpow295.1%
Simplified95.1%
Final simplification98.4%
(FPCore (a b) :precision binary64 (if (<= (* b b) 400000000.0) (+ (pow a 4.0) (+ (* 4.0 (* a a)) -1.0)) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 400000000.0) {
tmp = pow(a, 4.0) + ((4.0 * (a * a)) + -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) <= 400000000.0d0) then
tmp = (a ** 4.0d0) + ((4.0d0 * (a * a)) + (-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) <= 400000000.0) {
tmp = Math.pow(a, 4.0) + ((4.0 * (a * a)) + -1.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 400000000.0: tmp = math.pow(a, 4.0) + ((4.0 * (a * a)) + -1.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 400000000.0) tmp = Float64((a ^ 4.0) + Float64(Float64(4.0 * Float64(a * a)) + -1.0)); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 400000000.0) tmp = (a ^ 4.0) + ((4.0 * (a * a)) + -1.0); else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 400000000.0], N[(N[Power[a, 4.0], $MachinePrecision] + N[(N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 400000000:\\
\;\;\;\;{a}^{4} + \left(4 \cdot \left(a \cdot a\right) + -1\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 4e8Initial program 76.7%
associate--l+76.6%
fma-def76.6%
Simplified76.6%
Taylor expanded in b around 0 77.5%
associate--l+77.5%
associate-*r*77.5%
unpow277.5%
Simplified77.5%
Taylor expanded in a around 0 97.1%
unpow297.1%
Simplified97.1%
if 4e8 < (*.f64 b b) Initial program 63.0%
associate--l+63.0%
fma-def63.0%
Simplified64.6%
Taylor expanded in b around inf 92.9%
Final simplification95.1%
(FPCore (a b)
:precision binary64
(let* ((t_0 (+ -1.0 (* 4.0 (+ (* a a) (* a (* a a)))))))
(if (<= a -2.4)
(pow a 4.0)
(if (<= a -3e-101)
t_0
(if (<= a -5.4e-155)
(* a (* b (* b -12.0)))
(if (<= a 0.08) t_0 (pow a 4.0)))))))
double code(double a, double b) {
double t_0 = -1.0 + (4.0 * ((a * a) + (a * (a * a))));
double tmp;
if (a <= -2.4) {
tmp = pow(a, 4.0);
} else if (a <= -3e-101) {
tmp = t_0;
} else if (a <= -5.4e-155) {
tmp = a * (b * (b * -12.0));
} else if (a <= 0.08) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = (-1.0d0) + (4.0d0 * ((a * a) + (a * (a * a))))
if (a <= (-2.4d0)) then
tmp = a ** 4.0d0
else if (a <= (-3d-101)) then
tmp = t_0
else if (a <= (-5.4d-155)) then
tmp = a * (b * (b * (-12.0d0)))
else if (a <= 0.08d0) then
tmp = t_0
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = -1.0 + (4.0 * ((a * a) + (a * (a * a))));
double tmp;
if (a <= -2.4) {
tmp = Math.pow(a, 4.0);
} else if (a <= -3e-101) {
tmp = t_0;
} else if (a <= -5.4e-155) {
tmp = a * (b * (b * -12.0));
} else if (a <= 0.08) {
tmp = t_0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): t_0 = -1.0 + (4.0 * ((a * a) + (a * (a * a)))) tmp = 0 if a <= -2.4: tmp = math.pow(a, 4.0) elif a <= -3e-101: tmp = t_0 elif a <= -5.4e-155: tmp = a * (b * (b * -12.0)) elif a <= 0.08: tmp = t_0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) t_0 = Float64(-1.0 + Float64(4.0 * Float64(Float64(a * a) + Float64(a * Float64(a * a))))) tmp = 0.0 if (a <= -2.4) tmp = a ^ 4.0; elseif (a <= -3e-101) tmp = t_0; elseif (a <= -5.4e-155) tmp = Float64(a * Float64(b * Float64(b * -12.0))); elseif (a <= 0.08) tmp = t_0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) t_0 = -1.0 + (4.0 * ((a * a) + (a * (a * a)))); tmp = 0.0; if (a <= -2.4) tmp = a ^ 4.0; elseif (a <= -3e-101) tmp = t_0; elseif (a <= -5.4e-155) tmp = a * (b * (b * -12.0)); elseif (a <= 0.08) tmp = t_0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(-1.0 + N[(4.0 * N[(N[(a * a), $MachinePrecision] + N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -2.4], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, -3e-101], t$95$0, If[LessEqual[a, -5.4e-155], N[(a * N[(b * N[(b * -12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 0.08], t$95$0, N[Power[a, 4.0], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 + 4 \cdot \left(a \cdot a + a \cdot \left(a \cdot a\right)\right)\\
\mathbf{if}\;a \leq -2.4:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq -3 \cdot 10^{-101}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;a \leq -5.4 \cdot 10^{-155}:\\
\;\;\;\;a \cdot \left(b \cdot \left(b \cdot -12\right)\right)\\
\mathbf{elif}\;a \leq 0.08:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -2.39999999999999991 or 0.0800000000000000017 < a Initial program 42.7%
associate--l+42.7%
fma-def42.7%
Simplified44.2%
Taylor expanded in a around inf 90.4%
if -2.39999999999999991 < a < -3.0000000000000003e-101 or -5.39999999999999962e-155 < a < 0.0800000000000000017Initial program 99.8%
associate--l+99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in b around 0 50.3%
associate--l+50.2%
associate-*r*50.2%
unpow250.2%
Simplified50.2%
Taylor expanded in a around 0 48.8%
sub-neg48.8%
distribute-lft-out48.8%
metadata-eval48.8%
unpow248.8%
Simplified48.8%
unpow397.3%
Applied egg-rr48.8%
if -3.0000000000000003e-101 < a < -5.39999999999999962e-155Initial program 100.0%
associate--l+100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in b around inf 78.4%
*-commutative78.4%
fma-def78.4%
unpow278.4%
+-commutative78.4%
+-commutative78.4%
fma-def78.4%
unpow278.4%
distribute-lft-in78.4%
metadata-eval78.4%
associate-*r*78.4%
metadata-eval78.4%
Simplified78.4%
Taylor expanded in a around inf 67.9%
associate-*r*67.9%
*-commutative67.9%
associate-*r*67.9%
distribute-rgt-out67.9%
*-commutative67.9%
+-commutative67.9%
unpow267.9%
unpow267.9%
associate-*r*67.9%
*-commutative67.9%
distribute-rgt-out67.9%
*-commutative67.9%
Simplified67.9%
Taylor expanded in a around 0 67.9%
unpow267.9%
Simplified67.9%
Taylor expanded in a around 0 67.9%
*-commutative67.9%
unpow267.9%
associate-*l*78.4%
associate-*r*78.4%
Simplified78.4%
Final simplification71.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 400000000.0) (+ (* 4.0 (* a a)) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 400000000.0) {
tmp = (4.0 * (a * a)) + -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) <= 400000000.0d0) then
tmp = (4.0d0 * (a * a)) + (-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) <= 400000000.0) {
tmp = (4.0 * (a * a)) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 400000000.0: tmp = (4.0 * (a * a)) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 400000000.0) tmp = Float64(Float64(4.0 * Float64(a * a)) + -1.0); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 400000000.0) tmp = (4.0 * (a * a)) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 400000000.0], N[(N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 400000000:\\
\;\;\;\;4 \cdot \left(a \cdot a\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 4e8Initial program 76.7%
associate--l+76.6%
fma-def76.6%
Simplified76.6%
Taylor expanded in b around 0 77.5%
associate--l+77.5%
associate-*r*77.5%
unpow277.5%
Simplified77.5%
Taylor expanded in a around 0 58.4%
sub-neg58.4%
distribute-lft-out58.4%
metadata-eval58.4%
unpow258.4%
Simplified58.4%
Taylor expanded in a around 0 73.9%
unpow273.9%
Simplified73.9%
if 4e8 < (*.f64 b b) Initial program 63.0%
associate--l+63.0%
fma-def63.0%
Simplified64.6%
Taylor expanded in b around inf 92.9%
Final simplification82.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e-34) (+ (* 4.0 (* a a)) -1.0) (* 2.0 (* b (* b (* a a))))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e-34) {
tmp = (4.0 * (a * a)) + -1.0;
} else {
tmp = 2.0 * (b * (b * (a * a)));
}
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-34) then
tmp = (4.0d0 * (a * a)) + (-1.0d0)
else
tmp = 2.0d0 * (b * (b * (a * a)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 1e-34) {
tmp = (4.0 * (a * a)) + -1.0;
} else {
tmp = 2.0 * (b * (b * (a * a)));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e-34: tmp = (4.0 * (a * a)) + -1.0 else: tmp = 2.0 * (b * (b * (a * a))) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e-34) tmp = Float64(Float64(4.0 * Float64(a * a)) + -1.0); else tmp = Float64(2.0 * Float64(b * Float64(b * Float64(a * a)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e-34) tmp = (4.0 * (a * a)) + -1.0; else tmp = 2.0 * (b * (b * (a * a))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e-34], N[(N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(2.0 * N[(b * N[(b * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{-34}:\\
\;\;\;\;4 \cdot \left(a \cdot a\right) + -1\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 9.99999999999999928e-35Initial program 77.6%
associate--l+77.6%
fma-def77.6%
Simplified77.6%
Taylor expanded in b around 0 78.5%
associate--l+78.5%
associate-*r*78.5%
unpow278.5%
Simplified78.5%
Taylor expanded in a around 0 59.0%
sub-neg59.0%
distribute-lft-out59.0%
metadata-eval59.0%
unpow259.0%
Simplified59.0%
Taylor expanded in a around 0 74.0%
unpow274.0%
Simplified74.0%
if 9.99999999999999928e-35 < (*.f64 b b) Initial program 62.3%
associate--l+62.3%
fma-def62.3%
Simplified63.9%
Taylor expanded in b around inf 97.4%
*-commutative97.4%
fma-def97.4%
unpow297.4%
+-commutative97.4%
+-commutative97.4%
fma-def97.4%
unpow297.4%
distribute-lft-in97.4%
metadata-eval97.4%
associate-*r*97.4%
metadata-eval97.4%
Simplified97.4%
Taylor expanded in a around inf 57.4%
*-commutative57.4%
unpow257.4%
associate-*l*49.3%
unpow249.3%
Simplified49.3%
Final simplification61.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e-34) (+ (* 4.0 (* a a)) -1.0) (* (* b b) (* (* a a) 2.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e-34) {
tmp = (4.0 * (a * a)) + -1.0;
} else {
tmp = (b * b) * ((a * a) * 2.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-34) then
tmp = (4.0d0 * (a * a)) + (-1.0d0)
else
tmp = (b * b) * ((a * a) * 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 1e-34) {
tmp = (4.0 * (a * a)) + -1.0;
} else {
tmp = (b * b) * ((a * a) * 2.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e-34: tmp = (4.0 * (a * a)) + -1.0 else: tmp = (b * b) * ((a * a) * 2.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e-34) tmp = Float64(Float64(4.0 * Float64(a * a)) + -1.0); else tmp = Float64(Float64(b * b) * Float64(Float64(a * a) * 2.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e-34) tmp = (4.0 * (a * a)) + -1.0; else tmp = (b * b) * ((a * a) * 2.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e-34], N[(N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{-34}:\\
\;\;\;\;4 \cdot \left(a \cdot a\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(\left(a \cdot a\right) \cdot 2\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 9.99999999999999928e-35Initial program 77.6%
associate--l+77.6%
fma-def77.6%
Simplified77.6%
Taylor expanded in b around 0 78.5%
associate--l+78.5%
associate-*r*78.5%
unpow278.5%
Simplified78.5%
Taylor expanded in a around 0 59.0%
sub-neg59.0%
distribute-lft-out59.0%
metadata-eval59.0%
unpow259.0%
Simplified59.0%
Taylor expanded in a around 0 74.0%
unpow274.0%
Simplified74.0%
if 9.99999999999999928e-35 < (*.f64 b b) Initial program 62.3%
associate--l+62.3%
fma-def62.3%
Simplified63.9%
Taylor expanded in b around inf 97.4%
*-commutative97.4%
fma-def97.4%
unpow297.4%
+-commutative97.4%
+-commutative97.4%
fma-def97.4%
unpow297.4%
distribute-lft-in97.4%
metadata-eval97.4%
associate-*r*97.4%
metadata-eval97.4%
Simplified97.4%
Taylor expanded in a around inf 57.4%
associate-*r*57.4%
unpow257.4%
unpow257.4%
Simplified57.4%
Final simplification65.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 7.5e-28) -1.0 (* -12.0 (* a (* b b)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 7.5e-28) {
tmp = -1.0;
} else {
tmp = -12.0 * (a * (b * b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 7.5d-28) then
tmp = -1.0d0
else
tmp = (-12.0d0) * (a * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 7.5e-28) {
tmp = -1.0;
} else {
tmp = -12.0 * (a * (b * b));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 7.5e-28: tmp = -1.0 else: tmp = -12.0 * (a * (b * b)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 7.5e-28) tmp = -1.0; else tmp = Float64(-12.0 * Float64(a * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 7.5e-28) tmp = -1.0; else tmp = -12.0 * (a * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 7.5e-28], -1.0, N[(-12.0 * N[(a * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 7.5 \cdot 10^{-28}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;-12 \cdot \left(a \cdot \left(b \cdot b\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 7.5000000000000003e-28Initial program 77.6%
associate--l+77.6%
fma-def77.6%
Simplified77.6%
Taylor expanded in b around 0 78.5%
associate--l+78.5%
associate-*r*78.5%
unpow278.5%
Simplified78.5%
Taylor expanded in a around 0 43.2%
if 7.5000000000000003e-28 < (*.f64 b b) Initial program 62.3%
associate--l+62.3%
fma-def62.3%
Simplified63.9%
Taylor expanded in b around inf 97.4%
*-commutative97.4%
fma-def97.4%
unpow297.4%
+-commutative97.4%
+-commutative97.4%
fma-def97.4%
unpow297.4%
distribute-lft-in97.4%
metadata-eval97.4%
associate-*r*97.4%
metadata-eval97.4%
Simplified97.4%
Taylor expanded in a around inf 26.8%
associate-*r*26.8%
*-commutative26.8%
associate-*r*26.8%
distribute-rgt-out56.4%
*-commutative56.4%
+-commutative56.4%
unpow256.4%
unpow256.4%
associate-*r*56.4%
*-commutative56.4%
distribute-rgt-out56.4%
*-commutative56.4%
Simplified56.4%
Taylor expanded in a around 0 28.1%
unpow228.1%
Simplified28.1%
Final simplification35.8%
(FPCore (a b) :precision binary64 (if (<= b 2.7e-14) -1.0 (* a (* b (* b -12.0)))))
double code(double a, double b) {
double tmp;
if (b <= 2.7e-14) {
tmp = -1.0;
} else {
tmp = a * (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 <= 2.7d-14) then
tmp = -1.0d0
else
tmp = a * (b * (b * (-12.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 2.7e-14) {
tmp = -1.0;
} else {
tmp = a * (b * (b * -12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 2.7e-14: tmp = -1.0 else: tmp = a * (b * (b * -12.0)) return tmp
function code(a, b) tmp = 0.0 if (b <= 2.7e-14) tmp = -1.0; else tmp = Float64(a * Float64(b * Float64(b * -12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 2.7e-14) tmp = -1.0; else tmp = a * (b * (b * -12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 2.7e-14], -1.0, N[(a * N[(b * N[(b * -12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.7 \cdot 10^{-14}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(b \cdot \left(b \cdot -12\right)\right)\\
\end{array}
\end{array}
if b < 2.6999999999999999e-14Initial program 73.2%
associate--l+73.2%
fma-def73.2%
Simplified74.2%
Taylor expanded in b around 0 57.8%
associate--l+57.8%
associate-*r*57.8%
unpow257.8%
Simplified57.8%
Taylor expanded in a around 0 27.6%
if 2.6999999999999999e-14 < b Initial program 57.0%
associate--l+57.0%
fma-def57.0%
Simplified57.0%
Taylor expanded in b around inf 100.0%
*-commutative100.0%
fma-def100.0%
unpow2100.0%
+-commutative100.0%
+-commutative100.0%
fma-def100.0%
unpow2100.0%
distribute-lft-in100.0%
metadata-eval100.0%
associate-*r*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in a around inf 27.0%
associate-*r*27.0%
*-commutative27.0%
associate-*r*27.0%
distribute-rgt-out65.8%
*-commutative65.8%
+-commutative65.8%
unpow265.8%
unpow265.8%
associate-*r*65.8%
*-commutative65.8%
distribute-rgt-out65.8%
*-commutative65.8%
Simplified65.8%
Taylor expanded in a around 0 29.2%
unpow229.2%
Simplified29.2%
Taylor expanded in a around 0 29.2%
*-commutative29.2%
unpow229.2%
associate-*l*29.2%
associate-*r*29.2%
Simplified29.2%
Final simplification27.9%
(FPCore (a b) :precision binary64 (if (<= b 1.06e+203) (+ (* 4.0 (* a a)) -1.0) (* -12.0 (* a (* b b)))))
double code(double a, double b) {
double tmp;
if (b <= 1.06e+203) {
tmp = (4.0 * (a * a)) + -1.0;
} else {
tmp = -12.0 * (a * (b * b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 1.06d+203) then
tmp = (4.0d0 * (a * a)) + (-1.0d0)
else
tmp = (-12.0d0) * (a * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 1.06e+203) {
tmp = (4.0 * (a * a)) + -1.0;
} else {
tmp = -12.0 * (a * (b * b));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.06e+203: tmp = (4.0 * (a * a)) + -1.0 else: tmp = -12.0 * (a * (b * b)) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.06e+203) tmp = Float64(Float64(4.0 * Float64(a * a)) + -1.0); else tmp = Float64(-12.0 * Float64(a * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.06e+203) tmp = (4.0 * (a * a)) + -1.0; else tmp = -12.0 * (a * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.06e+203], N[(N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(-12.0 * N[(a * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.06 \cdot 10^{+203}:\\
\;\;\;\;4 \cdot \left(a \cdot a\right) + -1\\
\mathbf{else}:\\
\;\;\;\;-12 \cdot \left(a \cdot \left(b \cdot b\right)\right)\\
\end{array}
\end{array}
if b < 1.05999999999999994e203Initial program 70.1%
associate--l+70.1%
fma-def70.1%
Simplified71.0%
Taylor expanded in b around 0 55.0%
associate--l+55.0%
associate-*r*55.0%
unpow255.0%
Simplified55.0%
Taylor expanded in a around 0 41.7%
sub-neg41.7%
distribute-lft-out41.7%
metadata-eval41.7%
unpow241.7%
Simplified41.7%
Taylor expanded in a around 0 53.4%
unpow253.4%
Simplified53.4%
if 1.05999999999999994e203 < b Initial program 70.0%
associate--l+70.0%
fma-def70.0%
Simplified70.0%
Taylor expanded in b around inf 100.0%
*-commutative100.0%
fma-def100.0%
unpow2100.0%
+-commutative100.0%
+-commutative100.0%
fma-def100.0%
unpow2100.0%
distribute-lft-in100.0%
metadata-eval100.0%
associate-*r*100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in a around inf 30.0%
associate-*r*30.0%
*-commutative30.0%
associate-*r*30.0%
distribute-rgt-out65.0%
*-commutative65.0%
+-commutative65.0%
unpow265.0%
unpow265.0%
associate-*r*65.0%
*-commutative65.0%
distribute-rgt-out65.0%
*-commutative65.0%
Simplified65.0%
Taylor expanded in a around 0 40.0%
unpow240.0%
Simplified40.0%
Final simplification52.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 70.1%
associate--l+70.1%
fma-def70.1%
Simplified70.9%
Taylor expanded in b around 0 53.1%
associate--l+53.1%
associate-*r*53.1%
unpow253.1%
Simplified53.1%
Taylor expanded in a around 0 22.5%
Final simplification22.5%
herbie shell --seed 2023256
(FPCore (a b)
:name "Bouland and Aaronson, Equation (25)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))) 1.0))