
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 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 * (b * b))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) - 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[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\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 (* b b))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 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 * (b * b))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) - 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[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
\end{array}
(FPCore (a b) :precision binary64 (+ (+ (pow (+ (* a a) (* b b)) 2.0) (* (* b b) 4.0)) -1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 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 = ((((a * a) + (b * b)) ** 2.0d0) + ((b * b) * 4.0d0)) + (-1.0d0)
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + ((b * b) * 4.0)) + -1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + ((b * b) * 4.0)) + -1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(Float64(b * b) * 4.0)) + -1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + ((b * b) * 4.0)) + -1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + \left(b \cdot b\right) \cdot 4\right) + -1
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (a b)
:precision binary64
(if (<= a 5.4e-273)
(pow b 4.0)
(if (<= a 3.2e-43)
(+ (* (* b b) 4.0) -1.0)
(if (<= a 1e+68) (pow b 4.0) (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= 5.4e-273) {
tmp = pow(b, 4.0);
} else if (a <= 3.2e-43) {
tmp = ((b * b) * 4.0) + -1.0;
} else if (a <= 1e+68) {
tmp = pow(b, 4.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 <= 5.4d-273) then
tmp = b ** 4.0d0
else if (a <= 3.2d-43) then
tmp = ((b * b) * 4.0d0) + (-1.0d0)
else if (a <= 1d+68) then
tmp = b ** 4.0d0
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 5.4e-273) {
tmp = Math.pow(b, 4.0);
} else if (a <= 3.2e-43) {
tmp = ((b * b) * 4.0) + -1.0;
} else if (a <= 1e+68) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 5.4e-273: tmp = math.pow(b, 4.0) elif a <= 3.2e-43: tmp = ((b * b) * 4.0) + -1.0 elif a <= 1e+68: tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= 5.4e-273) tmp = b ^ 4.0; elseif (a <= 3.2e-43) tmp = Float64(Float64(Float64(b * b) * 4.0) + -1.0); elseif (a <= 1e+68) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 5.4e-273) tmp = b ^ 4.0; elseif (a <= 3.2e-43) tmp = ((b * b) * 4.0) + -1.0; elseif (a <= 1e+68) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 5.4e-273], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, 3.2e-43], N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, 1e+68], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 5.4 \cdot 10^{-273}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq 3.2 \cdot 10^{-43}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 4 + -1\\
\mathbf{elif}\;a \leq 10^{+68}:\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 5.39999999999999969e-273 or 3.19999999999999985e-43 < a < 9.99999999999999953e67Initial program 99.9%
Taylor expanded in a around 0 79.1%
Taylor expanded in b around inf 58.9%
if 5.39999999999999969e-273 < a < 3.19999999999999985e-43Initial program 99.9%
Taylor expanded in a around inf 76.0%
Taylor expanded in a around 0 76.0%
pow276.0%
Applied egg-rr76.0%
if 9.99999999999999953e67 < a Initial program 100.0%
Taylor expanded in a around inf 100.0%
Taylor expanded in a around inf 100.0%
Final simplification69.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 0.02) (+ (pow a 4.0) -1.0) (+ (* b (+ (pow b 3.0) (* b 4.0))) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.02) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = (b * (pow(b, 3.0) + (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 ((b * b) <= 0.02d0) then
tmp = (a ** 4.0d0) + (-1.0d0)
else
tmp = (b * ((b ** 3.0d0) + (b * 4.0d0))) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 0.02) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = (b * (Math.pow(b, 3.0) + (b * 4.0))) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 0.02: tmp = math.pow(a, 4.0) + -1.0 else: tmp = (b * (math.pow(b, 3.0) + (b * 4.0))) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 0.02) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64(Float64(b * Float64((b ^ 3.0) + Float64(b * 4.0))) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 0.02) tmp = (a ^ 4.0) + -1.0; else tmp = (b * ((b ^ 3.0) + (b * 4.0))) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.02], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(b * N[(N[Power[b, 3.0], $MachinePrecision] + N[(b * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.02:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left({b}^{3} + b \cdot 4\right) + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 0.0200000000000000004Initial program 100.0%
Taylor expanded in a around inf 99.2%
Taylor expanded in b around 0 98.4%
if 0.0200000000000000004 < (*.f64 b b) Initial program 99.9%
Taylor expanded in a around 0 94.8%
metadata-eval94.8%
pow-sqr94.7%
pow294.7%
pow294.7%
associate-*r*94.7%
pow394.7%
Applied egg-rr94.7%
associate-*r*94.7%
distribute-rgt-out94.7%
*-commutative94.7%
Applied egg-rr94.7%
Final simplification96.3%
(FPCore (a b) :precision binary64 (if (<= (* b b) 0.02) (+ (pow a 4.0) -1.0) (+ (* b (* b (fma b b 4.0))) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.02) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = (b * (b * fma(b, b, 4.0))) + -1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 0.02) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64(Float64(b * Float64(b * fma(b, b, 4.0))) + -1.0); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.02], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $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}\;b \cdot b \leq 0.02:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 4\right)\right) + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 0.0200000000000000004Initial program 100.0%
Taylor expanded in a around inf 99.2%
Taylor expanded in b around 0 98.4%
if 0.0200000000000000004 < (*.f64 b b) Initial program 99.9%
Taylor expanded in a around 0 94.8%
metadata-eval94.8%
pow-sqr94.7%
pow294.7%
pow294.7%
associate-*r*94.7%
pow394.7%
Applied egg-rr94.7%
associate-*r*94.7%
distribute-rgt-out94.7%
*-commutative94.7%
Applied egg-rr94.7%
cube-mult94.7%
unpow294.7%
distribute-lft-out94.7%
unpow294.7%
fma-define94.7%
Applied egg-rr94.7%
Final simplification96.3%
(FPCore (a b) :precision binary64 (if (<= a 1.3e-7) (+ (* b (+ (pow b 3.0) (* b 4.0))) -1.0) (+ (+ (* (* b b) 4.0) (pow a 4.0)) -1.0)))
double code(double a, double b) {
double tmp;
if (a <= 1.3e-7) {
tmp = (b * (pow(b, 3.0) + (b * 4.0))) + -1.0;
} else {
tmp = (((b * b) * 4.0) + pow(a, 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 <= 1.3d-7) then
tmp = (b * ((b ** 3.0d0) + (b * 4.0d0))) + (-1.0d0)
else
tmp = (((b * b) * 4.0d0) + (a ** 4.0d0)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 1.3e-7) {
tmp = (b * (Math.pow(b, 3.0) + (b * 4.0))) + -1.0;
} else {
tmp = (((b * b) * 4.0) + Math.pow(a, 4.0)) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 1.3e-7: tmp = (b * (math.pow(b, 3.0) + (b * 4.0))) + -1.0 else: tmp = (((b * b) * 4.0) + math.pow(a, 4.0)) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (a <= 1.3e-7) tmp = Float64(Float64(b * Float64((b ^ 3.0) + Float64(b * 4.0))) + -1.0); else tmp = Float64(Float64(Float64(Float64(b * b) * 4.0) + (a ^ 4.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 1.3e-7) tmp = (b * ((b ^ 3.0) + (b * 4.0))) + -1.0; else tmp = (((b * b) * 4.0) + (a ^ 4.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 1.3e-7], N[(N[(b * N[(N[Power[b, 3.0], $MachinePrecision] + N[(b * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.3 \cdot 10^{-7}:\\
\;\;\;\;b \cdot \left({b}^{3} + b \cdot 4\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(b \cdot b\right) \cdot 4 + {a}^{4}\right) + -1\\
\end{array}
\end{array}
if a < 1.29999999999999999e-7Initial program 99.9%
Taylor expanded in a around 0 85.2%
metadata-eval85.2%
pow-sqr85.2%
pow285.2%
pow285.2%
associate-*r*85.2%
pow385.2%
Applied egg-rr85.2%
associate-*r*85.2%
distribute-rgt-out85.2%
*-commutative85.2%
Applied egg-rr85.2%
if 1.29999999999999999e-7 < a Initial program 100.0%
Taylor expanded in a around inf 92.5%
Final simplification87.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+17) (+ (pow a 4.0) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+17) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = pow(b, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 5d+17) then
tmp = (a ** 4.0d0) + (-1.0d0)
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+17) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+17: tmp = math.pow(a, 4.0) + -1.0 else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+17) tmp = Float64((a ^ 4.0) + -1.0); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+17) tmp = (a ^ 4.0) + -1.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+17], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+17}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 5e17Initial program 100.0%
Taylor expanded in a around inf 97.0%
Taylor expanded in b around 0 95.9%
if 5e17 < (*.f64 b b) Initial program 99.9%
Taylor expanded in a around 0 96.0%
Taylor expanded in b around inf 96.0%
Final simplification95.9%
(FPCore (a b) :precision binary64 (if (<= a 4.7e+33) (+ (* (* b b) 4.0) -1.0) (pow a 4.0)))
double code(double a, double b) {
double tmp;
if (a <= 4.7e+33) {
tmp = ((b * b) * 4.0) + -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.7d+33) then
tmp = ((b * b) * 4.0d0) + (-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.7e+33) {
tmp = ((b * b) * 4.0) + -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 4.7e+33: tmp = ((b * b) * 4.0) + -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= 4.7e+33) tmp = Float64(Float64(Float64(b * b) * 4.0) + -1.0); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 4.7e+33) tmp = ((b * b) * 4.0) + -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 4.7e+33], N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 4.7 \cdot 10^{+33}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 4 + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 4.6999999999999998e33Initial program 99.9%
Taylor expanded in a around inf 80.2%
Taylor expanded in a around 0 60.1%
pow260.1%
Applied egg-rr60.1%
if 4.6999999999999998e33 < a Initial program 100.0%
Taylor expanded in a around inf 94.9%
Taylor expanded in a around inf 91.4%
Final simplification66.8%
(FPCore (a b) :precision binary64 (if (<= (* b b) 0.00023) -1.0 (* (* b b) 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.00023) {
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) <= 0.00023d0) 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) <= 0.00023) {
tmp = -1.0;
} else {
tmp = (b * b) * 4.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 0.00023: tmp = -1.0 else: tmp = (b * b) * 4.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 0.00023) 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) <= 0.00023) tmp = -1.0; else tmp = (b * b) * 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.00023], -1.0, N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.00023:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot 4\\
\end{array}
\end{array}
if (*.f64 b b) < 2.3000000000000001e-4Initial program 100.0%
Taylor expanded in a around 0 55.3%
Taylor expanded in b around 0 53.7%
if 2.3000000000000001e-4 < (*.f64 b b) Initial program 99.9%
Taylor expanded in a around inf 71.8%
Taylor expanded in b around inf 51.6%
pow251.6%
Applied egg-rr51.6%
Final simplification52.5%
(FPCore (a b) :precision binary64 (+ (* (* b b) 4.0) -1.0))
double code(double a, double b) {
return ((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) * 4.0d0) + (-1.0d0)
end function
public static double code(double a, double b) {
return ((b * b) * 4.0) + -1.0;
}
def code(a, b): return ((b * b) * 4.0) + -1.0
function code(a, b) return Float64(Float64(Float64(b * b) * 4.0) + -1.0) end
function tmp = code(a, b) tmp = ((b * b) * 4.0) + -1.0; end
code[a_, b_] := N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(b \cdot b\right) \cdot 4 + -1
\end{array}
Initial program 99.9%
Taylor expanded in a around inf 83.3%
Taylor expanded in a around 0 52.8%
pow252.8%
Applied egg-rr52.8%
Final simplification52.8%
(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 99.9%
Taylor expanded in a around 0 77.4%
Taylor expanded in b around 0 23.1%
herbie shell --seed 2024131
(FPCore (a b)
:name "Bouland and Aaronson, Equation (26)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))