
(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 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) (- 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
(let* ((t_0
(+
(pow (+ (* b b) (* a a)) 2.0)
(* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))))
(if (<= t_0 INFINITY)
(+ t_0 -1.0)
(* (* a a) (+ (fma 2.0 (* b b) 4.0) (* a (+ a 4.0)))))))
double code(double a, double b) {
double t_0 = pow(((b * b) + (a * a)), 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 = (a * a) * (fma(2.0, (b * b), 4.0) + (a * (a + 4.0)));
}
return tmp;
}
function code(a, b) t_0 = Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 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(Float64(a * a) * Float64(fma(2.0, Float64(b * b), 4.0) + Float64(a * Float64(a + 4.0)))); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $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[(a * a), $MachinePrecision] * N[(N[(2.0 * N[(b * b), $MachinePrecision] + 4.0), $MachinePrecision] + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(b \cdot b + a \cdot a\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}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(\mathsf{fma}\left(2, b \cdot b, 4\right) + a \cdot \left(a + 4\right)\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.8%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (+.f64 1 a)) (*.f64 (*.f64 b b) (-.f64 1 (*.f64 3 a)))))) Initial program 0.0%
associate--l+0.0%
fma-def0.0%
Simplified4.3%
Taylor expanded in a around 0 4.3%
+-commutative4.3%
associate-+r+4.3%
fma-def4.3%
*-commutative4.3%
unpow24.3%
unpow24.3%
Simplified4.3%
Taylor expanded in a around inf 43.5%
+-commutative43.5%
*-commutative43.5%
cube-mult43.5%
unpow243.5%
associate-*r*43.5%
unpow243.5%
associate-+l+43.5%
*-commutative43.5%
metadata-eval43.5%
pow-sqr43.5%
*-commutative43.5%
unpow243.5%
associate-*l*43.5%
distribute-lft-out100.0%
distribute-lft-out100.0%
unpow2100.0%
Simplified100.0%
Final simplification99.8%
(FPCore (a b) :precision binary64 (+ (+ (+ (* 2.0 (pow (* b a) 2.0)) (pow b 4.0)) (pow a 4.0)) (+ (* 4.0 (* b b)) -1.0)))
double code(double a, double b) {
return (((2.0 * pow((b * a), 2.0)) + pow(b, 4.0)) + pow(a, 4.0)) + ((4.0 * (b * b)) + -1.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (((2.0d0 * ((b * a) ** 2.0d0)) + (b ** 4.0d0)) + (a ** 4.0d0)) + ((4.0d0 * (b * b)) + (-1.0d0))
end function
public static double code(double a, double b) {
return (((2.0 * Math.pow((b * a), 2.0)) + Math.pow(b, 4.0)) + Math.pow(a, 4.0)) + ((4.0 * (b * b)) + -1.0);
}
def code(a, b): return (((2.0 * math.pow((b * a), 2.0)) + math.pow(b, 4.0)) + math.pow(a, 4.0)) + ((4.0 * (b * b)) + -1.0)
function code(a, b) return Float64(Float64(Float64(Float64(2.0 * (Float64(b * a) ^ 2.0)) + (b ^ 4.0)) + (a ^ 4.0)) + Float64(Float64(4.0 * Float64(b * b)) + -1.0)) end
function tmp = code(a, b) tmp = (((2.0 * ((b * a) ^ 2.0)) + (b ^ 4.0)) + (a ^ 4.0)) + ((4.0 * (b * b)) + -1.0); end
code[a_, b_] := N[(N[(N[(N[(2.0 * N[Power[N[(b * a), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision] + N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(2 \cdot {\left(b \cdot a\right)}^{2} + {b}^{4}\right) + {a}^{4}\right) + \left(4 \cdot \left(b \cdot b\right) + -1\right)
\end{array}
Initial program 72.9%
associate--l+72.9%
fma-def72.9%
Simplified74.0%
Taylor expanded in a around 0 63.3%
+-commutative63.3%
associate-+r+63.3%
fma-def63.3%
*-commutative63.3%
unpow263.3%
unpow263.3%
Simplified63.3%
Taylor expanded in a around 0 85.8%
unpow285.8%
Simplified85.8%
fma-udef85.8%
unswap-sqr99.4%
pow299.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (a b) :precision binary64 (if (or (<= a -1.4e+22) (not (<= a 4.5e+17))) (* (* a a) (+ (fma 2.0 (* b b) 4.0) (* a (+ a 4.0)))) (+ (+ (pow b 4.0) (* 4.0 (* b b))) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -1.4e+22) || !(a <= 4.5e+17)) {
tmp = (a * a) * (fma(2.0, (b * b), 4.0) + (a * (a + 4.0)));
} else {
tmp = (pow(b, 4.0) + (4.0 * (b * b))) + -1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if ((a <= -1.4e+22) || !(a <= 4.5e+17)) tmp = Float64(Float64(a * a) * Float64(fma(2.0, Float64(b * b), 4.0) + Float64(a * Float64(a + 4.0)))); else tmp = Float64(Float64((b ^ 4.0) + Float64(4.0 * Float64(b * b))) + -1.0); end return tmp end
code[a_, b_] := If[Or[LessEqual[a, -1.4e+22], N[Not[LessEqual[a, 4.5e+17]], $MachinePrecision]], N[(N[(a * a), $MachinePrecision] * N[(N[(2.0 * N[(b * b), $MachinePrecision] + 4.0), $MachinePrecision] + N[(a * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[b, 4.0], $MachinePrecision] + N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.4 \cdot 10^{+22} \lor \neg \left(a \leq 4.5 \cdot 10^{+17}\right):\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(\mathsf{fma}\left(2, b \cdot b, 4\right) + a \cdot \left(a + 4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right) + -1\\
\end{array}
\end{array}
if a < -1.4e22 or 4.5e17 < a Initial program 41.4%
associate--l+41.4%
fma-def41.4%
Simplified43.9%
Taylor expanded in a around 0 34.7%
+-commutative34.7%
associate-+r+34.7%
fma-def34.7%
*-commutative34.7%
unpow234.7%
unpow234.7%
Simplified34.7%
Taylor expanded in a around inf 65.0%
+-commutative65.0%
*-commutative65.0%
cube-mult65.0%
unpow265.0%
associate-*r*65.0%
unpow265.0%
associate-+l+65.0%
*-commutative65.0%
metadata-eval65.0%
pow-sqr64.9%
*-commutative64.9%
unpow264.9%
associate-*l*64.9%
distribute-lft-out97.9%
distribute-lft-out97.9%
unpow297.9%
Simplified97.9%
if -1.4e22 < a < 4.5e17Initial program 99.8%
associate--l+99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in a around 0 87.7%
+-commutative87.7%
associate-+r+87.7%
fma-def87.7%
*-commutative87.7%
unpow287.7%
unpow287.7%
Simplified87.7%
Taylor expanded in a around 0 87.7%
sub-neg87.7%
associate-+r+87.7%
+-commutative87.7%
associate-*r*87.7%
distribute-rgt-out98.5%
metadata-eval98.5%
associate-*r*98.5%
metadata-eval98.5%
distribute-lft-in98.5%
+-commutative98.5%
unpow298.5%
distribute-lft-in98.5%
metadata-eval98.5%
associate-*r*98.5%
metadata-eval98.5%
*-commutative98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in a around 0 98.5%
Final simplification98.3%
(FPCore (a b) :precision binary64 (if (<= a -4.2e+30) (pow a 4.0) (if (<= a 6.4e+69) (+ (+ (pow b 4.0) (* 4.0 (* b b))) -1.0) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -4.2e+30) {
tmp = pow(a, 4.0);
} else if (a <= 6.4e+69) {
tmp = (pow(b, 4.0) + (4.0 * (b * b))) + -1.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 <= (-4.2d+30)) then
tmp = a ** 4.0d0
else if (a <= 6.4d+69) then
tmp = ((b ** 4.0d0) + (4.0d0 * (b * b))) + (-1.0d0)
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -4.2e+30) {
tmp = Math.pow(a, 4.0);
} else if (a <= 6.4e+69) {
tmp = (Math.pow(b, 4.0) + (4.0 * (b * b))) + -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -4.2e+30: tmp = math.pow(a, 4.0) elif a <= 6.4e+69: tmp = (math.pow(b, 4.0) + (4.0 * (b * b))) + -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -4.2e+30) tmp = a ^ 4.0; elseif (a <= 6.4e+69) tmp = Float64(Float64((b ^ 4.0) + Float64(4.0 * Float64(b * b))) + -1.0); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -4.2e+30) tmp = a ^ 4.0; elseif (a <= 6.4e+69) tmp = ((b ^ 4.0) + (4.0 * (b * b))) + -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -4.2e+30], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 6.4e+69], N[(N[(N[Power[b, 4.0], $MachinePrecision] + N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.2 \cdot 10^{+30}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 6.4 \cdot 10^{+69}:\\
\;\;\;\;\left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -4.2e30 or 6.3999999999999997e69 < a Initial program 39.9%
associate--l+39.9%
fma-def39.9%
Simplified42.7%
Taylor expanded in a around inf 95.8%
if -4.2e30 < a < 6.3999999999999997e69Initial program 95.8%
associate--l+95.8%
fma-def95.8%
Simplified95.8%
Taylor expanded in a around 0 84.7%
+-commutative84.7%
associate-+r+84.7%
fma-def84.7%
*-commutative84.7%
unpow284.7%
unpow284.7%
Simplified84.7%
Taylor expanded in a around 0 81.5%
sub-neg81.5%
associate-+r+81.5%
+-commutative81.5%
associate-*r*81.5%
distribute-rgt-out91.5%
metadata-eval91.5%
associate-*r*91.5%
metadata-eval91.5%
distribute-lft-in91.5%
+-commutative91.5%
unpow291.5%
distribute-lft-in91.5%
metadata-eval91.5%
associate-*r*91.5%
metadata-eval91.5%
*-commutative91.5%
metadata-eval91.5%
Simplified91.5%
Taylor expanded in a around 0 95.4%
Final simplification95.6%
(FPCore (a b) :precision binary64 (if (or (<= a -2e+30) (not (<= a 2.45e+70))) (pow a 4.0) (+ -1.0 (* b (* b (fma b b 4.0))))))
double code(double a, double b) {
double tmp;
if ((a <= -2e+30) || !(a <= 2.45e+70)) {
tmp = pow(a, 4.0);
} else {
tmp = -1.0 + (b * (b * fma(b, b, 4.0)));
}
return tmp;
}
function code(a, b) tmp = 0.0 if ((a <= -2e+30) || !(a <= 2.45e+70)) tmp = a ^ 4.0; else tmp = Float64(-1.0 + Float64(b * Float64(b * fma(b, b, 4.0)))); end return tmp end
code[a_, b_] := If[Or[LessEqual[a, -2e+30], N[Not[LessEqual[a, 2.45e+70]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(-1.0 + N[(b * N[(b * N[(b * b + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2 \cdot 10^{+30} \lor \neg \left(a \leq 2.45 \cdot 10^{+70}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 4\right)\right)\\
\end{array}
\end{array}
if a < -2e30 or 2.45000000000000014e70 < a Initial program 39.9%
associate--l+39.9%
fma-def39.9%
Simplified42.7%
Taylor expanded in a around inf 95.8%
if -2e30 < a < 2.45000000000000014e70Initial program 95.8%
associate--l+95.8%
fma-def95.8%
Simplified95.8%
Taylor expanded in a around 0 84.7%
+-commutative84.7%
associate-+r+84.7%
fma-def84.7%
*-commutative84.7%
unpow284.7%
unpow284.7%
Simplified84.7%
Taylor expanded in a around 0 87.8%
unpow287.8%
Simplified87.8%
fma-udef87.8%
unswap-sqr99.1%
pow299.1%
Applied egg-rr99.1%
Taylor expanded in a around 0 95.4%
associate--l+95.4%
unpow295.4%
*-commutative95.4%
associate-*r*95.4%
fma-neg95.4%
metadata-eval95.4%
fma-udef95.4%
associate-+l+95.4%
metadata-eval95.4%
pow-sqr95.3%
unpow295.3%
unpow295.3%
associate-*r*95.3%
distribute-lft-in95.3%
associate-*l*95.3%
fma-def95.3%
Simplified95.3%
Final simplification95.5%
(FPCore (a b) :precision binary64 (if (or (<= a -8e+31) (not (<= a 4.2e+69))) (pow a 4.0) (+ -1.0 (* (* b b) (+ 4.0 (* b b))))))
double code(double a, double b) {
double tmp;
if ((a <= -8e+31) || !(a <= 4.2e+69)) {
tmp = pow(a, 4.0);
} else {
tmp = -1.0 + ((b * b) * (4.0 + (b * b)));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-8d+31)) .or. (.not. (a <= 4.2d+69))) then
tmp = a ** 4.0d0
else
tmp = (-1.0d0) + ((b * b) * (4.0d0 + (b * b)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -8e+31) || !(a <= 4.2e+69)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = -1.0 + ((b * b) * (4.0 + (b * b)));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -8e+31) or not (a <= 4.2e+69): tmp = math.pow(a, 4.0) else: tmp = -1.0 + ((b * b) * (4.0 + (b * b))) return tmp
function code(a, b) tmp = 0.0 if ((a <= -8e+31) || !(a <= 4.2e+69)) tmp = a ^ 4.0; else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(4.0 + Float64(b * b)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -8e+31) || ~((a <= 4.2e+69))) tmp = a ^ 4.0; else tmp = -1.0 + ((b * b) * (4.0 + (b * b))); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -8e+31], N[Not[LessEqual[a, 4.2e+69]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -8 \cdot 10^{+31} \lor \neg \left(a \leq 4.2 \cdot 10^{+69}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\
\end{array}
\end{array}
if a < -7.9999999999999997e31 or 4.2000000000000003e69 < a Initial program 39.9%
associate--l+39.9%
fma-def39.9%
Simplified42.7%
Taylor expanded in a around inf 95.8%
if -7.9999999999999997e31 < a < 4.2000000000000003e69Initial program 95.8%
associate--l+95.8%
fma-def95.8%
Simplified95.8%
Taylor expanded in a around 0 84.7%
+-commutative84.7%
associate-+r+84.7%
fma-def84.7%
*-commutative84.7%
unpow284.7%
unpow284.7%
Simplified84.7%
Taylor expanded in a around 0 81.5%
sub-neg81.5%
associate-+r+81.5%
+-commutative81.5%
associate-*r*81.5%
distribute-rgt-out91.5%
metadata-eval91.5%
associate-*r*91.5%
metadata-eval91.5%
distribute-lft-in91.5%
+-commutative91.5%
unpow291.5%
distribute-lft-in91.5%
metadata-eval91.5%
associate-*r*91.5%
metadata-eval91.5%
*-commutative91.5%
metadata-eval91.5%
Simplified91.5%
Taylor expanded in a around 0 95.4%
metadata-eval95.4%
pow-sqr95.3%
pow295.3%
pow295.3%
distribute-lft-out95.3%
Applied egg-rr95.3%
Final simplification95.5%
(FPCore (a b) :precision binary64 (if (or (<= a -6.5e+153) (not (<= a 6.5e+153))) (+ -1.0 (* 4.0 (* a a))) (+ -1.0 (* (* b b) (+ 4.0 (* b b))))))
double code(double a, double b) {
double tmp;
if ((a <= -6.5e+153) || !(a <= 6.5e+153)) {
tmp = -1.0 + (4.0 * (a * a));
} else {
tmp = -1.0 + ((b * b) * (4.0 + (b * b)));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-6.5d+153)) .or. (.not. (a <= 6.5d+153))) then
tmp = (-1.0d0) + (4.0d0 * (a * a))
else
tmp = (-1.0d0) + ((b * b) * (4.0d0 + (b * b)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -6.5e+153) || !(a <= 6.5e+153)) {
tmp = -1.0 + (4.0 * (a * a));
} else {
tmp = -1.0 + ((b * b) * (4.0 + (b * b)));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -6.5e+153) or not (a <= 6.5e+153): tmp = -1.0 + (4.0 * (a * a)) else: tmp = -1.0 + ((b * b) * (4.0 + (b * b))) return tmp
function code(a, b) tmp = 0.0 if ((a <= -6.5e+153) || !(a <= 6.5e+153)) tmp = Float64(-1.0 + Float64(4.0 * Float64(a * a))); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(4.0 + Float64(b * b)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -6.5e+153) || ~((a <= 6.5e+153))) tmp = -1.0 + (4.0 * (a * a)); else tmp = -1.0 + ((b * b) * (4.0 + (b * b))); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -6.5e+153], N[Not[LessEqual[a, 6.5e+153]], $MachinePrecision]], N[(-1.0 + N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6.5 \cdot 10^{+153} \lor \neg \left(a \leq 6.5 \cdot 10^{+153}\right):\\
\;\;\;\;-1 + 4 \cdot \left(a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\
\end{array}
\end{array}
if a < -6.49999999999999972e153 or 6.49999999999999972e153 < a Initial program 30.5%
associate--l+30.5%
fma-def30.5%
Simplified30.5%
Taylor expanded in b around 0 54.2%
associate--l+54.2%
associate-*r*54.2%
unpow254.2%
Simplified54.2%
Taylor expanded in a around 0 54.2%
distribute-lft-out54.2%
unpow254.2%
cube-mult54.2%
unpow254.2%
distribute-lft-in54.2%
fma-neg54.2%
metadata-eval54.2%
distribute-lft-in54.2%
unpow254.2%
distribute-rgt1-in54.2%
*-commutative54.2%
unpow254.2%
fma-udef54.2%
associate-*l*54.2%
associate-*r*54.2%
*-commutative54.2%
*-commutative54.2%
distribute-lft1-in54.2%
fma-udef54.2%
Simplified54.2%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
if -6.49999999999999972e153 < a < 6.49999999999999972e153Initial program 85.6%
associate--l+85.6%
fma-def85.6%
Simplified87.1%
Taylor expanded in a around 0 78.7%
+-commutative78.7%
associate-+r+78.7%
fma-def78.7%
*-commutative78.7%
unpow278.7%
unpow278.7%
Simplified78.7%
Taylor expanded in a around 0 67.3%
sub-neg67.3%
associate-+r+67.3%
+-commutative67.3%
associate-*r*67.3%
distribute-rgt-out74.9%
metadata-eval74.9%
associate-*r*74.9%
metadata-eval74.9%
distribute-lft-in74.9%
+-commutative74.9%
unpow274.9%
distribute-lft-in74.9%
metadata-eval74.9%
associate-*r*74.9%
metadata-eval74.9%
*-commutative74.9%
metadata-eval74.9%
Simplified74.9%
Taylor expanded in a around 0 83.0%
metadata-eval83.0%
pow-sqr82.9%
pow282.9%
pow282.9%
distribute-lft-out82.9%
Applied egg-rr82.9%
Final simplification86.8%
(FPCore (a b) :precision binary64 (if (or (<= a -7e+153) (not (<= a -1.76e-289))) (+ -1.0 (* 4.0 (* a a))) (+ -1.0 (* a (* (* b b) -12.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -7e+153) || !(a <= -1.76e-289)) {
tmp = -1.0 + (4.0 * (a * a));
} else {
tmp = -1.0 + (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 ((a <= (-7d+153)) .or. (.not. (a <= (-1.76d-289)))) then
tmp = (-1.0d0) + (4.0d0 * (a * a))
else
tmp = (-1.0d0) + (a * ((b * b) * (-12.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -7e+153) || !(a <= -1.76e-289)) {
tmp = -1.0 + (4.0 * (a * a));
} else {
tmp = -1.0 + (a * ((b * b) * -12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -7e+153) or not (a <= -1.76e-289): tmp = -1.0 + (4.0 * (a * a)) else: tmp = -1.0 + (a * ((b * b) * -12.0)) return tmp
function code(a, b) tmp = 0.0 if ((a <= -7e+153) || !(a <= -1.76e-289)) tmp = Float64(-1.0 + Float64(4.0 * Float64(a * a))); else tmp = Float64(-1.0 + Float64(a * Float64(Float64(b * b) * -12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -7e+153) || ~((a <= -1.76e-289))) tmp = -1.0 + (4.0 * (a * a)); else tmp = -1.0 + (a * ((b * b) * -12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -7e+153], N[Not[LessEqual[a, -1.76e-289]], $MachinePrecision]], N[(-1.0 + N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(a * N[(N[(b * b), $MachinePrecision] * -12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -7 \cdot 10^{+153} \lor \neg \left(a \leq -1.76 \cdot 10^{-289}\right):\\
\;\;\;\;-1 + 4 \cdot \left(a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + a \cdot \left(\left(b \cdot b\right) \cdot -12\right)\\
\end{array}
\end{array}
if a < -6.9999999999999998e153 or -1.7600000000000001e-289 < a Initial program 63.6%
associate--l+63.6%
fma-def63.6%
Simplified63.6%
Taylor expanded in b around 0 56.9%
associate--l+56.9%
associate-*r*56.9%
unpow256.9%
Simplified56.9%
Taylor expanded in a around 0 50.9%
distribute-lft-out50.9%
unpow250.9%
cube-mult50.9%
unpow250.9%
distribute-lft-in50.9%
fma-neg50.9%
metadata-eval50.9%
distribute-lft-in50.9%
unpow250.9%
distribute-rgt1-in50.9%
*-commutative50.9%
unpow250.9%
fma-udef50.9%
associate-*l*50.9%
associate-*r*50.9%
*-commutative50.9%
*-commutative50.9%
distribute-lft1-in50.9%
fma-udef50.9%
Simplified50.9%
Taylor expanded in a around 0 61.0%
unpow261.0%
Simplified61.0%
if -6.9999999999999998e153 < a < -1.7600000000000001e-289Initial program 87.6%
associate--l+87.6%
fma-def87.6%
Simplified90.7%
Taylor expanded in a around 0 82.8%
+-commutative82.8%
associate-+r+82.8%
fma-def82.8%
*-commutative82.8%
unpow282.8%
unpow282.8%
Simplified82.8%
Taylor expanded in a around 0 78.2%
sub-neg78.2%
associate-+r+78.2%
+-commutative78.2%
associate-*r*78.2%
distribute-rgt-out78.2%
metadata-eval78.2%
associate-*r*78.2%
metadata-eval78.2%
distribute-lft-in78.2%
+-commutative78.2%
unpow278.2%
distribute-lft-in78.2%
metadata-eval78.2%
associate-*r*78.2%
metadata-eval78.2%
*-commutative78.2%
metadata-eval78.2%
Simplified78.2%
Taylor expanded in a around inf 59.6%
*-commutative59.6%
unpow259.6%
associate-*l*59.6%
*-commutative59.6%
Simplified59.6%
Final simplification60.5%
(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 72.9%
associate--l+72.9%
fma-def72.9%
Simplified74.0%
Taylor expanded in b around 0 53.6%
associate--l+53.6%
associate-*r*53.6%
unpow253.6%
Simplified53.6%
Taylor expanded in a around 0 44.5%
distribute-lft-out44.5%
unpow244.5%
cube-mult44.5%
unpow244.5%
distribute-lft-in44.5%
fma-neg44.5%
metadata-eval44.5%
distribute-lft-in44.5%
unpow244.5%
distribute-rgt1-in44.5%
*-commutative44.5%
unpow244.5%
fma-udef44.5%
associate-*l*44.5%
associate-*r*44.5%
*-commutative44.5%
*-commutative44.5%
distribute-lft1-in44.5%
fma-udef44.5%
Simplified44.5%
Taylor expanded in a around 0 51.4%
unpow251.4%
Simplified51.4%
Final simplification51.4%
(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 72.9%
associate--l+72.9%
fma-def72.9%
Simplified74.0%
Taylor expanded in b around 0 53.6%
associate--l+53.6%
associate-*r*53.6%
unpow253.6%
Simplified53.6%
Taylor expanded in a around 0 26.9%
Final simplification26.9%
herbie shell --seed 2023200
(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))