
(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 11 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 5000.0) (+ (* (* b b) 4.0) -1.0) (if (or (<= a 4.2e+30) (not (<= a 1.16e+52))) (pow a 4.0) (pow b 4.0))))
double code(double a, double b) {
double tmp;
if (a <= 5000.0) {
tmp = ((b * b) * 4.0) + -1.0;
} else if ((a <= 4.2e+30) || !(a <= 1.16e+52)) {
tmp = pow(a, 4.0);
} else {
tmp = pow(b, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= 5000.0d0) then
tmp = ((b * b) * 4.0d0) + (-1.0d0)
else if ((a <= 4.2d+30) .or. (.not. (a <= 1.16d+52))) then
tmp = a ** 4.0d0
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 5000.0) {
tmp = ((b * b) * 4.0) + -1.0;
} else if ((a <= 4.2e+30) || !(a <= 1.16e+52)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 5000.0: tmp = ((b * b) * 4.0) + -1.0 elif (a <= 4.2e+30) or not (a <= 1.16e+52): tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= 5000.0) tmp = Float64(Float64(Float64(b * b) * 4.0) + -1.0); elseif ((a <= 4.2e+30) || !(a <= 1.16e+52)) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 5000.0) tmp = ((b * b) * 4.0) + -1.0; elseif ((a <= 4.2e+30) || ~((a <= 1.16e+52))) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 5000.0], N[(N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision], If[Or[LessEqual[a, 4.2e+30], N[Not[LessEqual[a, 1.16e+52]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 5000:\\
\;\;\;\;\left(b \cdot b\right) \cdot 4 + -1\\
\mathbf{elif}\;a \leq 4.2 \cdot 10^{+30} \lor \neg \left(a \leq 1.16 \cdot 10^{+52}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if a < 5e3Initial program 99.9%
Taylor expanded in a around inf 82.1%
Taylor expanded in a around 0 61.5%
pow261.5%
Applied egg-rr61.5%
if 5e3 < a < 4.2e30 or 1.1599999999999999e52 < a Initial program 99.9%
Taylor expanded in a around inf 100.0%
Taylor expanded in a around inf 97.1%
Taylor expanded in a around inf 97.1%
if 4.2e30 < a < 1.1599999999999999e52Initial program 100.0%
Taylor expanded in a around 0 80.2%
Taylor expanded in b around inf 80.2%
Taylor expanded in b around inf 80.4%
Final simplification71.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e-6) (+ (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) <= 1e-6) {
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) <= 1d-6) 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) <= 1e-6) {
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) <= 1e-6: 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) <= 1e-6) 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) <= 1e-6) 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], 1e-6], 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 10^{-6}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left({b}^{3} + b \cdot 4\right) + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 9.99999999999999955e-7Initial program 100.0%
Taylor expanded in a around inf 100.0%
Taylor expanded in a around inf 100.0%
if 9.99999999999999955e-7 < (*.f64 b b) Initial program 99.9%
Taylor expanded in a around 0 89.7%
metadata-eval89.7%
pow-sqr89.5%
pow289.5%
pow289.5%
associate-*r*89.6%
pow389.6%
Applied egg-rr89.6%
associate-*r*89.6%
distribute-rgt-out89.6%
Applied egg-rr89.6%
Final simplification95.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e-6) (+ (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) <= 1e-6) {
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) <= 1e-6) 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], 1e-6], 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 10^{-6}:\\
\;\;\;\;{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) < 9.99999999999999955e-7Initial program 100.0%
Taylor expanded in a around inf 100.0%
Taylor expanded in a around inf 100.0%
if 9.99999999999999955e-7 < (*.f64 b b) Initial program 99.9%
Taylor expanded in a around 0 89.7%
metadata-eval89.7%
pow-sqr89.5%
pow289.5%
pow289.5%
associate-*r*89.6%
pow389.6%
Applied egg-rr89.6%
associate-*r*89.6%
distribute-rgt-out89.6%
Applied egg-rr89.6%
unpow389.6%
distribute-rgt-out89.6%
fma-define89.6%
Applied egg-rr89.6%
Final simplification95.1%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (* b b) 4.0)))
(if (<= a 5.6e-25)
(+ (+ t_0 (pow b 4.0)) -1.0)
(+ (+ t_0 (pow a 4.0)) -1.0))))
double code(double a, double b) {
double t_0 = (b * b) * 4.0;
double tmp;
if (a <= 5.6e-25) {
tmp = (t_0 + pow(b, 4.0)) + -1.0;
} else {
tmp = (t_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) :: t_0
real(8) :: tmp
t_0 = (b * b) * 4.0d0
if (a <= 5.6d-25) then
tmp = (t_0 + (b ** 4.0d0)) + (-1.0d0)
else
tmp = (t_0 + (a ** 4.0d0)) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = (b * b) * 4.0;
double tmp;
if (a <= 5.6e-25) {
tmp = (t_0 + Math.pow(b, 4.0)) + -1.0;
} else {
tmp = (t_0 + Math.pow(a, 4.0)) + -1.0;
}
return tmp;
}
def code(a, b): t_0 = (b * b) * 4.0 tmp = 0 if a <= 5.6e-25: tmp = (t_0 + math.pow(b, 4.0)) + -1.0 else: tmp = (t_0 + math.pow(a, 4.0)) + -1.0 return tmp
function code(a, b) t_0 = Float64(Float64(b * b) * 4.0) tmp = 0.0 if (a <= 5.6e-25) tmp = Float64(Float64(t_0 + (b ^ 4.0)) + -1.0); else tmp = Float64(Float64(t_0 + (a ^ 4.0)) + -1.0); end return tmp end
function tmp_2 = code(a, b) t_0 = (b * b) * 4.0; tmp = 0.0; if (a <= 5.6e-25) tmp = (t_0 + (b ^ 4.0)) + -1.0; else tmp = (t_0 + (a ^ 4.0)) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]}, If[LessEqual[a, 5.6e-25], N[(N[(t$95$0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(t$95$0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(b \cdot b\right) \cdot 4\\
\mathbf{if}\;a \leq 5.6 \cdot 10^{-25}:\\
\;\;\;\;\left(t\_0 + {b}^{4}\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 + {a}^{4}\right) + -1\\
\end{array}
\end{array}
if a < 5.59999999999999976e-25Initial program 99.9%
Taylor expanded in a around 0 82.1%
if 5.59999999999999976e-25 < a Initial program 99.9%
Taylor expanded in a around inf 97.5%
Final simplification86.6%
(FPCore (a b) :precision binary64 (if (<= a 5.6e-25) (+ (* 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 <= 5.6e-25) {
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 <= 5.6d-25) 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 <= 5.6e-25) {
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 <= 5.6e-25: 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 <= 5.6e-25) 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 <= 5.6e-25) 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, 5.6e-25], 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 5.6 \cdot 10^{-25}:\\
\;\;\;\;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 < 5.59999999999999976e-25Initial program 99.9%
Taylor expanded in a around 0 82.1%
metadata-eval82.1%
pow-sqr82.0%
pow282.0%
pow282.0%
associate-*r*82.1%
pow382.1%
Applied egg-rr82.1%
associate-*r*82.1%
distribute-rgt-out82.1%
Applied egg-rr82.1%
if 5.59999999999999976e-25 < a Initial program 99.9%
Taylor expanded in a around inf 97.5%
Final simplification86.6%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+26) (+ (pow a 4.0) -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+26) {
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) <= 2d+26) 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) <= 2e+26) {
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) <= 2e+26: 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) <= 2e+26) 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) <= 2e+26) 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], 2e+26], 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 2 \cdot 10^{+26}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 2.0000000000000001e26Initial program 99.9%
Taylor expanded in a around inf 97.6%
Taylor expanded in a around inf 97.2%
if 2.0000000000000001e26 < (*.f64 b b) Initial program 99.9%
Taylor expanded in a around 0 91.6%
Taylor expanded in b around inf 91.6%
Taylor expanded in b around inf 91.6%
Final simplification94.8%
(FPCore (a b) :precision binary64 (if (<= a 1600.0) (+ (* (* b b) 4.0) -1.0) (pow a 4.0)))
double code(double a, double b) {
double tmp;
if (a <= 1600.0) {
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 <= 1600.0d0) 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 <= 1600.0) {
tmp = ((b * b) * 4.0) + -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 1600.0: 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 <= 1600.0) 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 <= 1600.0) tmp = ((b * b) * 4.0) + -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 1600.0], 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 1600:\\
\;\;\;\;\left(b \cdot b\right) \cdot 4 + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 1600Initial program 99.9%
Taylor expanded in a around inf 82.1%
Taylor expanded in a around 0 61.5%
pow261.5%
Applied egg-rr61.5%
if 1600 < a Initial program 99.9%
Taylor expanded in a around inf 97.3%
Taylor expanded in a around inf 91.9%
Taylor expanded in a around inf 91.9%
Final simplification70.0%
(FPCore (a b) :precision binary64 (if (<= b 0.0009) -1.0 (* b (* b 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 0.0009) {
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 <= 0.0009d0) 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 <= 0.0009) {
tmp = -1.0;
} else {
tmp = b * (b * 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 0.0009: tmp = -1.0 else: tmp = b * (b * 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 0.0009) tmp = -1.0; else tmp = Float64(b * Float64(b * 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 0.0009) tmp = -1.0; else tmp = b * (b * 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 0.0009], -1.0, N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.0009:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot 4\right)\\
\end{array}
\end{array}
if b < 8.9999999999999998e-4Initial program 99.9%
Taylor expanded in a around 0 64.5%
Taylor expanded in b around 0 36.6%
if 8.9999999999999998e-4 < b Initial program 99.9%
Taylor expanded in a around inf 76.8%
Taylor expanded in a around 0 52.7%
Taylor expanded in b around inf 52.7%
*-commutative52.7%
unpow252.7%
metadata-eval52.7%
swap-sqr52.7%
unpow252.7%
Simplified52.7%
unpow-prod-down52.7%
pow252.7%
metadata-eval52.7%
*-commutative52.7%
associate-*r*52.7%
*-commutative52.7%
Applied egg-rr52.7%
Final simplification40.3%
(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 86.3%
Taylor expanded in a around 0 51.9%
pow251.9%
Applied egg-rr51.9%
Final simplification51.9%
(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 70.0%
Taylor expanded in b around 0 28.3%
herbie shell --seed 2024110
(FPCore (a b)
:name "Bouland and Aaronson, Equation (26)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))