
(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 (+ (pow (+ (* b b) (* a a)) 2.0) (+ (* (* b b) 4.0) -1.0)))
double code(double a, double b) {
return pow(((b * b) + (a * a)), 2.0) + (((b * b) * 4.0) + -1.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (((b * b) + (a * a)) ** 2.0d0) + (((b * b) * 4.0d0) + (-1.0d0))
end function
public static double code(double a, double b) {
return Math.pow(((b * b) + (a * a)), 2.0) + (((b * b) * 4.0) + -1.0);
}
def code(a, b): return math.pow(((b * b) + (a * a)), 2.0) + (((b * b) * 4.0) + -1.0)
function code(a, b) return Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 2.0) + Float64(Float64(Float64(b * b) * 4.0) + -1.0)) end
function tmp = code(a, b) tmp = (((b * b) + (a * a)) ^ 2.0) + (((b * b) * 4.0) + -1.0); end
code[a_, b_] := N[(N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(b \cdot b + a \cdot a\right)}^{2} + \left(\left(b \cdot b\right) \cdot 4 + -1\right)
\end{array}
Initial program 75.3%
associate--l+75.3%
fma-def75.3%
Simplified76.4%
Taylor expanded in a around 0 99.2%
unpow299.2%
Simplified99.2%
fma-udef99.2%
+-commutative99.2%
Applied egg-rr99.2%
Final simplification99.2%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e-9) (+ (+ (* (* b b) 4.0) -1.0) (* (* a a) (* a a))) (+ (pow b 4.0) (* (* b b) (+ 4.0 (* (* a a) 2.0))))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e-9) {
tmp = (((b * b) * 4.0) + -1.0) + ((a * a) * (a * a));
} else {
tmp = pow(b, 4.0) + ((b * b) * (4.0 + ((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-9) then
tmp = (((b * b) * 4.0d0) + (-1.0d0)) + ((a * a) * (a * a))
else
tmp = (b ** 4.0d0) + ((b * b) * (4.0d0 + ((a * a) * 2.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 1e-9) {
tmp = (((b * b) * 4.0) + -1.0) + ((a * a) * (a * a));
} else {
tmp = Math.pow(b, 4.0) + ((b * b) * (4.0 + ((a * a) * 2.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e-9: tmp = (((b * b) * 4.0) + -1.0) + ((a * a) * (a * a)) else: tmp = math.pow(b, 4.0) + ((b * b) * (4.0 + ((a * a) * 2.0))) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e-9) tmp = Float64(Float64(Float64(Float64(b * b) * 4.0) + -1.0) + Float64(Float64(a * a) * Float64(a * a))); else tmp = Float64((b ^ 4.0) + Float64(Float64(b * b) * Float64(4.0 + Float64(Float64(a * a) * 2.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e-9) tmp = (((b * b) * 4.0) + -1.0) + ((a * a) * (a * a)); else tmp = (b ^ 4.0) + ((b * b) * (4.0 + ((a * a) * 2.0))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e-9], N[(N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(N[(a * a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{-9}:\\
\;\;\;\;\left(\left(b \cdot b\right) \cdot 4 + -1\right) + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + \left(b \cdot b\right) \cdot \left(4 + \left(a \cdot a\right) \cdot 2\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1.00000000000000006e-9Initial program 83.4%
associate--l+83.4%
fma-def83.4%
Simplified83.4%
Taylor expanded in a around 0 98.5%
unpow298.5%
Simplified98.5%
Taylor expanded in a around inf 98.5%
unpow298.5%
Simplified98.5%
unpow298.5%
Applied egg-rr98.5%
if 1.00000000000000006e-9 < (*.f64 b b) Initial program 68.0%
associate--l+68.0%
fma-def68.0%
Simplified70.2%
Taylor expanded in a around 0 99.9%
unpow299.9%
Simplified99.9%
Taylor expanded in b around inf 96.6%
unpow296.6%
unpow296.6%
Simplified96.6%
Final simplification97.5%
(FPCore (a b) :precision binary64 (if (or (<= a -2.5e+18) (not (<= a 195000000000.0))) (+ (+ (* (* b b) 4.0) -1.0) (* (* a a) (* a a))) (+ (* b (* b (fma b b 4.0))) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -2.5e+18) || !(a <= 195000000000.0)) {
tmp = (((b * b) * 4.0) + -1.0) + ((a * a) * (a * a));
} else {
tmp = (b * (b * fma(b, b, 4.0))) + -1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if ((a <= -2.5e+18) || !(a <= 195000000000.0)) tmp = Float64(Float64(Float64(Float64(b * b) * 4.0) + -1.0) + Float64(Float64(a * a) * Float64(a * a))); else tmp = Float64(Float64(b * Float64(b * fma(b, b, 4.0))) + -1.0); end return tmp end
code[a_, b_] := If[Or[LessEqual[a, -2.5e+18], N[Not[LessEqual[a, 195000000000.0]], $MachinePrecision]], N[(N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * N[(b * N[(b * b + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.5 \cdot 10^{+18} \lor \neg \left(a \leq 195000000000\right):\\
\;\;\;\;\left(\left(b \cdot b\right) \cdot 4 + -1\right) + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 4\right)\right) + -1\\
\end{array}
\end{array}
if a < -2.5e18 or 1.95e11 < a Initial program 48.3%
associate--l+48.3%
fma-def48.3%
Simplified50.8%
Taylor expanded in a around 0 99.8%
unpow299.8%
Simplified99.8%
Taylor expanded in a around inf 97.0%
unpow297.0%
Simplified97.0%
unpow297.0%
Applied egg-rr97.0%
if -2.5e18 < a < 1.95e11Initial program 99.8%
associate--l+99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in a around 0 98.7%
unpow298.7%
Simplified98.7%
Taylor expanded in a around 0 97.8%
unpow297.8%
Simplified97.8%
associate-+r-97.8%
unpow297.8%
distribute-rgt-out97.8%
Applied egg-rr97.8%
Taylor expanded in b around 0 97.9%
metadata-eval97.9%
pow-plus97.9%
unpow297.9%
associate-*r*97.9%
distribute-rgt-out97.9%
unpow397.8%
distribute-rgt-out97.8%
fma-udef97.8%
Simplified97.8%
Final simplification97.5%
(FPCore (a b) :precision binary64 (if (or (<= a -2.5e+18) (not (<= a 10500000000.0))) (+ (+ (* (* b b) 4.0) -1.0) (* (* a a) (* a a))) (+ (* (* b b) (+ (* b b) 4.0)) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -2.5e+18) || !(a <= 10500000000.0)) {
tmp = (((b * b) * 4.0) + -1.0) + ((a * a) * (a * a));
} else {
tmp = ((b * b) * ((b * b) + 4.0)) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-2.5d+18)) .or. (.not. (a <= 10500000000.0d0))) then
tmp = (((b * b) * 4.0d0) + (-1.0d0)) + ((a * a) * (a * a))
else
tmp = ((b * b) * ((b * b) + 4.0d0)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -2.5e+18) || !(a <= 10500000000.0)) {
tmp = (((b * b) * 4.0) + -1.0) + ((a * a) * (a * a));
} else {
tmp = ((b * b) * ((b * b) + 4.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -2.5e+18) or not (a <= 10500000000.0): tmp = (((b * b) * 4.0) + -1.0) + ((a * a) * (a * a)) else: tmp = ((b * b) * ((b * b) + 4.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -2.5e+18) || !(a <= 10500000000.0)) tmp = Float64(Float64(Float64(Float64(b * b) * 4.0) + -1.0) + Float64(Float64(a * a) * Float64(a * a))); else tmp = Float64(Float64(Float64(b * b) * Float64(Float64(b * b) + 4.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -2.5e+18) || ~((a <= 10500000000.0))) tmp = (((b * b) * 4.0) + -1.0) + ((a * a) * (a * a)); else tmp = ((b * b) * ((b * b) + 4.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -2.5e+18], N[Not[LessEqual[a, 10500000000.0]], $MachinePrecision]], N[(N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.5 \cdot 10^{+18} \lor \neg \left(a \leq 10500000000\right):\\
\;\;\;\;\left(\left(b \cdot b\right) \cdot 4 + -1\right) + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right) + -1\\
\end{array}
\end{array}
if a < -2.5e18 or 1.05e10 < a Initial program 48.3%
associate--l+48.3%
fma-def48.3%
Simplified50.8%
Taylor expanded in a around 0 99.8%
unpow299.8%
Simplified99.8%
Taylor expanded in a around inf 97.0%
unpow297.0%
Simplified97.0%
unpow297.0%
Applied egg-rr97.0%
if -2.5e18 < a < 1.05e10Initial program 99.8%
associate--l+99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in a around 0 98.7%
unpow298.7%
Simplified98.7%
Taylor expanded in a around 0 97.8%
unpow297.8%
Simplified97.8%
associate-+r-97.8%
unpow297.8%
distribute-rgt-out97.8%
Applied egg-rr97.8%
Final simplification97.5%
(FPCore (a b)
:precision binary64
(if (<= a -4.8e+21)
(* 2.0 (* b (* b (* a a))))
(if (<= a 3.6e+102)
(+ (* (* b b) (* b b)) -1.0)
(+ (* 4.0 (* (* a a) (+ a 1.0))) -1.0))))
double code(double a, double b) {
double tmp;
if (a <= -4.8e+21) {
tmp = 2.0 * (b * (b * (a * a)));
} else if (a <= 3.6e+102) {
tmp = ((b * b) * (b * b)) + -1.0;
} else {
tmp = (4.0 * ((a * a) * (a + 1.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 <= (-4.8d+21)) then
tmp = 2.0d0 * (b * (b * (a * a)))
else if (a <= 3.6d+102) then
tmp = ((b * b) * (b * b)) + (-1.0d0)
else
tmp = (4.0d0 * ((a * a) * (a + 1.0d0))) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -4.8e+21) {
tmp = 2.0 * (b * (b * (a * a)));
} else if (a <= 3.6e+102) {
tmp = ((b * b) * (b * b)) + -1.0;
} else {
tmp = (4.0 * ((a * a) * (a + 1.0))) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -4.8e+21: tmp = 2.0 * (b * (b * (a * a))) elif a <= 3.6e+102: tmp = ((b * b) * (b * b)) + -1.0 else: tmp = (4.0 * ((a * a) * (a + 1.0))) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (a <= -4.8e+21) tmp = Float64(2.0 * Float64(b * Float64(b * Float64(a * a)))); elseif (a <= 3.6e+102) tmp = Float64(Float64(Float64(b * b) * Float64(b * b)) + -1.0); else tmp = Float64(Float64(4.0 * Float64(Float64(a * a) * Float64(a + 1.0))) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -4.8e+21) tmp = 2.0 * (b * (b * (a * a))); elseif (a <= 3.6e+102) tmp = ((b * b) * (b * b)) + -1.0; else tmp = (4.0 * ((a * a) * (a + 1.0))) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -4.8e+21], N[(2.0 * N[(b * N[(b * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 3.6e+102], N[(N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.8 \cdot 10^{+21}:\\
\;\;\;\;2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)\\
\mathbf{elif}\;a \leq 3.6 \cdot 10^{+102}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right) + -1\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right)\right) + -1\\
\end{array}
\end{array}
if a < -4.8e21Initial program 32.2%
associate--l+32.2%
fma-def32.2%
Simplified37.0%
Taylor expanded in b around inf 59.2%
*-commutative59.2%
fma-def59.2%
unpow259.2%
+-commutative59.2%
+-commutative59.2%
fma-def59.2%
unpow259.2%
distribute-lft-in59.2%
metadata-eval59.2%
associate-*r*59.2%
metadata-eval59.2%
Simplified59.2%
Taylor expanded in a around inf 59.2%
unpow259.2%
unpow259.2%
associate-*r*59.2%
*-commutative59.2%
associate-*r*59.2%
Simplified59.2%
Taylor expanded in a around 0 59.2%
unpow259.2%
unpow259.2%
*-commutative59.2%
associate-*l*73.7%
Simplified73.7%
if -4.8e21 < a < 3.6000000000000002e102Initial program 97.1%
associate--l+97.1%
fma-def97.1%
Simplified97.1%
Taylor expanded in a around 0 98.7%
unpow298.7%
Simplified98.7%
Taylor expanded in a around 0 94.7%
unpow294.7%
Simplified94.7%
associate-+r-94.7%
unpow294.7%
distribute-rgt-out94.7%
Applied egg-rr94.7%
Taylor expanded in b around inf 94.2%
unpow294.2%
Simplified94.2%
if 3.6000000000000002e102 < a Initial program 63.0%
associate--l+63.0%
fma-def63.0%
Simplified63.0%
Taylor expanded in b around 0 100.0%
associate--l+100.0%
associate-*r*100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
sub-neg100.0%
unpow2100.0%
distribute-lft-out100.0%
metadata-eval100.0%
Simplified100.0%
cube-mult100.0%
distribute-rgt1-in100.0%
Applied egg-rr100.0%
Final simplification90.3%
(FPCore (a b)
:precision binary64
(if (<= a -4.8e+21)
(* 2.0 (* b (* b (* a a))))
(if (<= a 3.5e+102)
(+ (* (* b b) (+ (* b b) 4.0)) -1.0)
(+ (* 4.0 (* (* a a) (+ a 1.0))) -1.0))))
double code(double a, double b) {
double tmp;
if (a <= -4.8e+21) {
tmp = 2.0 * (b * (b * (a * a)));
} else if (a <= 3.5e+102) {
tmp = ((b * b) * ((b * b) + 4.0)) + -1.0;
} else {
tmp = (4.0 * ((a * a) * (a + 1.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 <= (-4.8d+21)) then
tmp = 2.0d0 * (b * (b * (a * a)))
else if (a <= 3.5d+102) then
tmp = ((b * b) * ((b * b) + 4.0d0)) + (-1.0d0)
else
tmp = (4.0d0 * ((a * a) * (a + 1.0d0))) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -4.8e+21) {
tmp = 2.0 * (b * (b * (a * a)));
} else if (a <= 3.5e+102) {
tmp = ((b * b) * ((b * b) + 4.0)) + -1.0;
} else {
tmp = (4.0 * ((a * a) * (a + 1.0))) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -4.8e+21: tmp = 2.0 * (b * (b * (a * a))) elif a <= 3.5e+102: tmp = ((b * b) * ((b * b) + 4.0)) + -1.0 else: tmp = (4.0 * ((a * a) * (a + 1.0))) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (a <= -4.8e+21) tmp = Float64(2.0 * Float64(b * Float64(b * Float64(a * a)))); elseif (a <= 3.5e+102) tmp = Float64(Float64(Float64(b * b) * Float64(Float64(b * b) + 4.0)) + -1.0); else tmp = Float64(Float64(4.0 * Float64(Float64(a * a) * Float64(a + 1.0))) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -4.8e+21) tmp = 2.0 * (b * (b * (a * a))); elseif (a <= 3.5e+102) tmp = ((b * b) * ((b * b) + 4.0)) + -1.0; else tmp = (4.0 * ((a * a) * (a + 1.0))) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -4.8e+21], N[(2.0 * N[(b * N[(b * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 3.5e+102], N[(N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.8 \cdot 10^{+21}:\\
\;\;\;\;2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)\\
\mathbf{elif}\;a \leq 3.5 \cdot 10^{+102}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right) + -1\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right)\right) + -1\\
\end{array}
\end{array}
if a < -4.8e21Initial program 32.2%
associate--l+32.2%
fma-def32.2%
Simplified37.0%
Taylor expanded in b around inf 59.2%
*-commutative59.2%
fma-def59.2%
unpow259.2%
+-commutative59.2%
+-commutative59.2%
fma-def59.2%
unpow259.2%
distribute-lft-in59.2%
metadata-eval59.2%
associate-*r*59.2%
metadata-eval59.2%
Simplified59.2%
Taylor expanded in a around inf 59.2%
unpow259.2%
unpow259.2%
associate-*r*59.2%
*-commutative59.2%
associate-*r*59.2%
Simplified59.2%
Taylor expanded in a around 0 59.2%
unpow259.2%
unpow259.2%
*-commutative59.2%
associate-*l*73.7%
Simplified73.7%
if -4.8e21 < a < 3.50000000000000011e102Initial program 97.1%
associate--l+97.1%
fma-def97.1%
Simplified97.1%
Taylor expanded in a around 0 98.7%
unpow298.7%
Simplified98.7%
Taylor expanded in a around 0 94.7%
unpow294.7%
Simplified94.7%
associate-+r-94.7%
unpow294.7%
distribute-rgt-out94.7%
Applied egg-rr94.7%
if 3.50000000000000011e102 < a Initial program 63.0%
associate--l+63.0%
fma-def63.0%
Simplified63.0%
Taylor expanded in b around 0 100.0%
associate--l+100.0%
associate-*r*100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
sub-neg100.0%
unpow2100.0%
distribute-lft-out100.0%
metadata-eval100.0%
Simplified100.0%
cube-mult100.0%
distribute-rgt1-in100.0%
Applied egg-rr100.0%
Final simplification90.6%
(FPCore (a b) :precision binary64 (if (or (<= a -2.4) (not (<= a 0.44))) (* 2.0 (* b (* b (* a a)))) (+ (* (* b b) 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -2.4) || !(a <= 0.44)) {
tmp = 2.0 * (b * (b * (a * a)));
} else {
tmp = ((b * b) * 4.0) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-2.4d0)) .or. (.not. (a <= 0.44d0))) then
tmp = 2.0d0 * (b * (b * (a * a)))
else
tmp = ((b * b) * 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -2.4) || !(a <= 0.44)) {
tmp = 2.0 * (b * (b * (a * a)));
} else {
tmp = ((b * b) * 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -2.4) or not (a <= 0.44): tmp = 2.0 * (b * (b * (a * a))) else: tmp = ((b * b) * 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -2.4) || !(a <= 0.44)) tmp = Float64(2.0 * Float64(b * Float64(b * Float64(a * a)))); else tmp = Float64(Float64(Float64(b * b) * 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -2.4) || ~((a <= 0.44))) tmp = 2.0 * (b * (b * (a * a))); else tmp = ((b * b) * 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -2.4], N[Not[LessEqual[a, 0.44]], $MachinePrecision]], N[(2.0 * N[(b * N[(b * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.4 \lor \neg \left(a \leq 0.44\right):\\
\;\;\;\;2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 4 + -1\\
\end{array}
\end{array}
if a < -2.39999999999999991 or 0.440000000000000002 < a Initial program 52.2%
associate--l+52.2%
fma-def52.2%
Simplified54.4%
Taylor expanded in b around inf 68.4%
*-commutative68.4%
fma-def68.4%
unpow268.4%
+-commutative68.4%
+-commutative68.4%
fma-def68.4%
unpow268.4%
distribute-lft-in68.4%
metadata-eval68.4%
associate-*r*68.4%
metadata-eval68.4%
Simplified68.4%
Taylor expanded in a around inf 63.5%
unpow263.5%
unpow263.5%
associate-*r*63.5%
*-commutative63.5%
associate-*r*63.5%
Simplified63.5%
Taylor expanded in a around 0 63.5%
unpow263.5%
unpow263.5%
*-commutative63.5%
associate-*l*74.1%
Simplified74.1%
if -2.39999999999999991 < a < 0.440000000000000002Initial program 99.9%
associate--l+99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in a around 0 99.3%
unpow299.3%
Simplified99.3%
Taylor expanded in a around 0 99.3%
unpow299.3%
Simplified99.3%
associate-+r-99.3%
unpow299.3%
distribute-rgt-out99.3%
Applied egg-rr99.3%
Taylor expanded in b around 0 75.4%
Final simplification74.7%
(FPCore (a b) :precision binary64 (if (or (<= a -4.8e+21) (not (<= a 7.8e+39))) (* 2.0 (* b (* b (* a a)))) (+ (* (* b b) (* b b)) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -4.8e+21) || !(a <= 7.8e+39)) {
tmp = 2.0 * (b * (b * (a * a)));
} else {
tmp = ((b * b) * (b * b)) + -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 <= (-4.8d+21)) .or. (.not. (a <= 7.8d+39))) then
tmp = 2.0d0 * (b * (b * (a * a)))
else
tmp = ((b * b) * (b * b)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -4.8e+21) || !(a <= 7.8e+39)) {
tmp = 2.0 * (b * (b * (a * a)));
} else {
tmp = ((b * b) * (b * b)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -4.8e+21) or not (a <= 7.8e+39): tmp = 2.0 * (b * (b * (a * a))) else: tmp = ((b * b) * (b * b)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -4.8e+21) || !(a <= 7.8e+39)) tmp = Float64(2.0 * Float64(b * Float64(b * Float64(a * a)))); else tmp = Float64(Float64(Float64(b * b) * Float64(b * b)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -4.8e+21) || ~((a <= 7.8e+39))) tmp = 2.0 * (b * (b * (a * a))); else tmp = ((b * b) * (b * b)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -4.8e+21], N[Not[LessEqual[a, 7.8e+39]], $MachinePrecision]], N[(2.0 * N[(b * N[(b * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.8 \cdot 10^{+21} \lor \neg \left(a \leq 7.8 \cdot 10^{+39}\right):\\
\;\;\;\;2 \cdot \left(b \cdot \left(b \cdot \left(a \cdot a\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right) + -1\\
\end{array}
\end{array}
if a < -4.8e21 or 7.8000000000000002e39 < a Initial program 47.0%
associate--l+47.0%
fma-def47.0%
Simplified49.5%
Taylor expanded in b around inf 68.1%
*-commutative68.1%
fma-def68.1%
unpow268.1%
+-commutative68.1%
+-commutative68.1%
fma-def68.1%
unpow268.1%
distribute-lft-in68.1%
metadata-eval68.1%
associate-*r*68.1%
metadata-eval68.1%
Simplified68.1%
Taylor expanded in a around inf 68.1%
unpow268.1%
unpow268.1%
associate-*r*68.1%
*-commutative68.1%
associate-*r*68.1%
Simplified68.1%
Taylor expanded in a around 0 68.1%
unpow268.1%
unpow268.1%
*-commutative68.1%
associate-*l*79.9%
Simplified79.9%
if -4.8e21 < a < 7.8000000000000002e39Initial program 99.8%
associate--l+99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in a around 0 98.6%
unpow298.6%
Simplified98.6%
Taylor expanded in a around 0 96.5%
unpow296.5%
Simplified96.5%
associate-+r-96.5%
unpow296.5%
distribute-rgt-out96.5%
Applied egg-rr96.5%
Taylor expanded in b around inf 95.9%
unpow295.9%
Simplified95.9%
Final simplification88.4%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+292) (+ (* a (* a 4.0)) -1.0) (* (* b b) 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+292) {
tmp = (a * (a * 4.0)) + -1.0;
} else {
tmp = (b * 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) <= 2d+292) then
tmp = (a * (a * 4.0d0)) + (-1.0d0)
else
tmp = (b * b) * 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+292) {
tmp = (a * (a * 4.0)) + -1.0;
} else {
tmp = (b * b) * 4.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+292: tmp = (a * (a * 4.0)) + -1.0 else: tmp = (b * b) * 4.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+292) tmp = Float64(Float64(a * Float64(a * 4.0)) + -1.0); else tmp = Float64(Float64(b * b) * 4.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+292) tmp = (a * (a * 4.0)) + -1.0; else tmp = (b * b) * 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+292], N[(N[(a * N[(a * 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+292}:\\
\;\;\;\;a \cdot \left(a \cdot 4\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 4\\
\end{array}
\end{array}
if (*.f64 b b) < 2e292Initial program 80.8%
associate--l+80.8%
fma-def80.8%
Simplified80.8%
Taylor expanded in b around 0 63.4%
associate--l+63.4%
associate-*r*63.4%
unpow263.4%
Simplified63.4%
Taylor expanded in a around 0 50.5%
sub-neg50.5%
unpow250.5%
distribute-lft-out50.5%
metadata-eval50.5%
Simplified50.5%
Taylor expanded in a around 0 60.4%
unpow260.4%
*-commutative60.4%
associate-*r*60.4%
Simplified60.4%
if 2e292 < (*.f64 b b) Initial program 59.7%
associate--l+59.7%
fma-def59.7%
Simplified64.2%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in a around inf 97.4%
unpow297.4%
Simplified97.4%
Taylor expanded in b around inf 97.4%
unpow297.4%
Simplified97.4%
Final simplification70.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 3.2e-7) -1.0 (* (* b b) 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 3.2e-7) {
tmp = -1.0;
} else {
tmp = (b * 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) <= 3.2d-7) then
tmp = -1.0d0
else
tmp = (b * b) * 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 3.2e-7) {
tmp = -1.0;
} else {
tmp = (b * b) * 4.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 3.2e-7: tmp = -1.0 else: tmp = (b * b) * 4.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 3.2e-7) tmp = -1.0; else tmp = Float64(Float64(b * b) * 4.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 3.2e-7) tmp = -1.0; else tmp = (b * b) * 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 3.2e-7], -1.0, N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 3.2 \cdot 10^{-7}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 4\\
\end{array}
\end{array}
if (*.f64 b b) < 3.2000000000000001e-7Initial program 83.4%
associate--l+83.4%
fma-def83.4%
Simplified83.4%
Taylor expanded in b around 0 83.1%
associate--l+83.1%
associate-*r*83.1%
unpow283.1%
Simplified83.1%
Taylor expanded in a around 0 49.0%
if 3.2000000000000001e-7 < (*.f64 b b) Initial program 68.0%
associate--l+68.0%
fma-def68.0%
Simplified70.2%
Taylor expanded in a around 0 99.9%
unpow299.9%
Simplified99.9%
Taylor expanded in a around inf 71.4%
unpow271.4%
Simplified71.4%
Taylor expanded in b around inf 51.4%
unpow251.4%
Simplified51.4%
Final simplification50.2%
(FPCore (a b) :precision binary64 -1.0)
double code(double a, double b) {
return -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = -1.0d0
end function
public static double code(double a, double b) {
return -1.0;
}
def code(a, b): return -1.0
function code(a, b) return -1.0 end
function tmp = code(a, b) tmp = -1.0; end
code[a_, b_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 75.3%
associate--l+75.3%
fma-def75.3%
Simplified76.4%
Taylor expanded in b around 0 51.4%
associate--l+51.4%
associate-*r*51.4%
unpow251.4%
Simplified51.4%
Taylor expanded in a around 0 23.5%
Final simplification23.5%
herbie shell --seed 2023249
(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))