
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 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) * (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) * (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) * (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) * (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(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) * (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[(3.0 + a), $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(3 + a\right)\right)\right) - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 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) (+ 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) * (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) * (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) * (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) * (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(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) * (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[(3.0 + a), $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(3 + a\right)\right)\right) - 1
\end{array}
(FPCore (a b) :precision binary64 (let* ((t_0 (+ (* a a) (* b b)))) (+ (+ (/ t_0 (/ 1.0 t_0)) (* 4.0 (* (* b b) 3.0))) -1.0)))
double code(double a, double b) {
double t_0 = (a * a) + (b * b);
return ((t_0 / (1.0 / t_0)) + (4.0 * ((b * b) * 3.0))) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_0
t_0 = (a * a) + (b * b)
code = ((t_0 / (1.0d0 / t_0)) + (4.0d0 * ((b * b) * 3.0d0))) + (-1.0d0)
end function
public static double code(double a, double b) {
double t_0 = (a * a) + (b * b);
return ((t_0 / (1.0 / t_0)) + (4.0 * ((b * b) * 3.0))) + -1.0;
}
def code(a, b): t_0 = (a * a) + (b * b) return ((t_0 / (1.0 / t_0)) + (4.0 * ((b * b) * 3.0))) + -1.0
function code(a, b) t_0 = Float64(Float64(a * a) + Float64(b * b)) return Float64(Float64(Float64(t_0 / Float64(1.0 / t_0)) + Float64(4.0 * Float64(Float64(b * b) * 3.0))) + -1.0) end
function tmp = code(a, b) t_0 = (a * a) + (b * b); tmp = ((t_0 / (1.0 / t_0)) + (4.0 * ((b * b) * 3.0))) + -1.0; end
code[a_, b_] := Block[{t$95$0 = N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(t$95$0 / N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(N[(b * b), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot a + b \cdot b\\
\left(\frac{t\_0}{\frac{1}{t\_0}} + 4 \cdot \left(\left(b \cdot b\right) \cdot 3\right)\right) + -1
\end{array}
\end{array}
Initial program 75.7%
unpow2N/A
flip3-+N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
clear-numN/A
flip3-+N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
Applied egg-rr75.7%
Taylor expanded in a around 0
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6499.3%
Simplified99.3%
Final simplification99.3%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* a (* a (* a a)))))
(if (<= b 1.2e-272)
-1.0
(if (<= b 4.2e-191)
t_0
(if (<= b 9.5e-25) -1.0 (if (<= b 4.6e+46) t_0 (* b (* b (* b b)))))))))
double code(double a, double b) {
double t_0 = a * (a * (a * a));
double tmp;
if (b <= 1.2e-272) {
tmp = -1.0;
} else if (b <= 4.2e-191) {
tmp = t_0;
} else if (b <= 9.5e-25) {
tmp = -1.0;
} else if (b <= 4.6e+46) {
tmp = t_0;
} else {
tmp = b * (b * (b * b));
}
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 = a * (a * (a * a))
if (b <= 1.2d-272) then
tmp = -1.0d0
else if (b <= 4.2d-191) then
tmp = t_0
else if (b <= 9.5d-25) then
tmp = -1.0d0
else if (b <= 4.6d+46) then
tmp = t_0
else
tmp = b * (b * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = a * (a * (a * a));
double tmp;
if (b <= 1.2e-272) {
tmp = -1.0;
} else if (b <= 4.2e-191) {
tmp = t_0;
} else if (b <= 9.5e-25) {
tmp = -1.0;
} else if (b <= 4.6e+46) {
tmp = t_0;
} else {
tmp = b * (b * (b * b));
}
return tmp;
}
def code(a, b): t_0 = a * (a * (a * a)) tmp = 0 if b <= 1.2e-272: tmp = -1.0 elif b <= 4.2e-191: tmp = t_0 elif b <= 9.5e-25: tmp = -1.0 elif b <= 4.6e+46: tmp = t_0 else: tmp = b * (b * (b * b)) return tmp
function code(a, b) t_0 = Float64(a * Float64(a * Float64(a * a))) tmp = 0.0 if (b <= 1.2e-272) tmp = -1.0; elseif (b <= 4.2e-191) tmp = t_0; elseif (b <= 9.5e-25) tmp = -1.0; elseif (b <= 4.6e+46) tmp = t_0; else tmp = Float64(b * Float64(b * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) t_0 = a * (a * (a * a)); tmp = 0.0; if (b <= 1.2e-272) tmp = -1.0; elseif (b <= 4.2e-191) tmp = t_0; elseif (b <= 9.5e-25) tmp = -1.0; elseif (b <= 4.6e+46) tmp = t_0; else tmp = b * (b * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(a * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 1.2e-272], -1.0, If[LessEqual[b, 4.2e-191], t$95$0, If[LessEqual[b, 9.5e-25], -1.0, If[LessEqual[b, 4.6e+46], t$95$0, N[(b * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\mathbf{if}\;b \leq 1.2 \cdot 10^{-272}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 4.2 \cdot 10^{-191}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 9.5 \cdot 10^{-25}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 4.6 \cdot 10^{+46}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot \left(b \cdot b\right)\right)\\
\end{array}
\end{array}
if b < 1.19999999999999995e-272 or 4.19999999999999971e-191 < b < 9.50000000000000065e-25Initial program 76.6%
Taylor expanded in a around inf
metadata-evalN/A
pow-plusN/A
*-commutativeN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6479.1%
Simplified79.1%
Taylor expanded in a around 0
Simplified39.1%
if 1.19999999999999995e-272 < b < 4.19999999999999971e-191 or 9.50000000000000065e-25 < b < 4.6000000000000001e46Initial program 69.2%
Taylor expanded in a around inf
metadata-evalN/A
pow-plusN/A
*-commutativeN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6451.4%
Simplified51.4%
if 4.6000000000000001e46 < b Initial program 76.0%
Taylor expanded in b around inf
metadata-evalN/A
pow-sqrN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6498.1%
Simplified98.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2.5e+93) (+ (* (* a a) (+ 4.0 (* a (+ a -4.0)))) -1.0) (* b (* b (* b b)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2.5e+93) {
tmp = ((a * a) * (4.0 + (a * (a + -4.0)))) + -1.0;
} else {
tmp = b * (b * (b * b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2.5d+93) then
tmp = ((a * a) * (4.0d0 + (a * (a + (-4.0d0))))) + (-1.0d0)
else
tmp = b * (b * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2.5e+93) {
tmp = ((a * a) * (4.0 + (a * (a + -4.0)))) + -1.0;
} else {
tmp = b * (b * (b * b));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2.5e+93: tmp = ((a * a) * (4.0 + (a * (a + -4.0)))) + -1.0 else: tmp = b * (b * (b * b)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2.5e+93) tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + -4.0)))) + -1.0); else tmp = Float64(b * Float64(b * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2.5e+93) tmp = ((a * a) * (4.0 + (a * (a + -4.0)))) + -1.0; else tmp = b * (b * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2.5e+93], N[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(b * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2.5 \cdot 10^{+93}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot \left(b \cdot b\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 2.5000000000000001e93Initial program 81.6%
Taylor expanded in b around 0
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6497.1%
Simplified97.1%
Taylor expanded in a around 0
sub-negN/A
metadata-evalN/A
distribute-rgt-inN/A
unpow2N/A
*-rgt-identityN/A
*-rgt-identityN/A
rgt-mult-inverseN/A
associate-*r/N/A
*-rgt-identityN/A
associate-/l*N/A
unpow2N/A
*-lft-identityN/A
associate-*l/N/A
associate-*l*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
distribute-lft-inN/A
sub-negN/A
Simplified97.1%
if 2.5000000000000001e93 < (*.f64 b b) Initial program 67.0%
Taylor expanded in b around inf
metadata-evalN/A
pow-sqrN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6497.3%
Simplified97.3%
Final simplification97.2%
(FPCore (a b) :precision binary64 (let* ((t_0 (* a (* a (* a a))))) (if (<= a -0.41) t_0 (if (<= a 2.4) -1.0 t_0))))
double code(double a, double b) {
double t_0 = a * (a * (a * a));
double tmp;
if (a <= -0.41) {
tmp = t_0;
} else if (a <= 2.4) {
tmp = -1.0;
} else {
tmp = t_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 = a * (a * (a * a))
if (a <= (-0.41d0)) then
tmp = t_0
else if (a <= 2.4d0) then
tmp = -1.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = a * (a * (a * a));
double tmp;
if (a <= -0.41) {
tmp = t_0;
} else if (a <= 2.4) {
tmp = -1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b): t_0 = a * (a * (a * a)) tmp = 0 if a <= -0.41: tmp = t_0 elif a <= 2.4: tmp = -1.0 else: tmp = t_0 return tmp
function code(a, b) t_0 = Float64(a * Float64(a * Float64(a * a))) tmp = 0.0 if (a <= -0.41) tmp = t_0; elseif (a <= 2.4) tmp = -1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(a, b) t_0 = a * (a * (a * a)); tmp = 0.0; if (a <= -0.41) tmp = t_0; elseif (a <= 2.4) tmp = -1.0; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(a * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -0.41], t$95$0, If[LessEqual[a, 2.4], -1.0, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\mathbf{if}\;a \leq -0.41:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 2.4:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.409999999999999976 or 2.39999999999999991 < a Initial program 47.8%
Taylor expanded in a around inf
metadata-evalN/A
pow-plusN/A
*-commutativeN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6484.9%
Simplified84.9%
if -0.409999999999999976 < a < 2.39999999999999991Initial program 100.0%
Taylor expanded in a around inf
metadata-evalN/A
pow-plusN/A
*-commutativeN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6459.8%
Simplified59.8%
Taylor expanded in a around 0
Simplified59.8%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2.5e+93) (+ (* a (* a (* a a))) -1.0) (* b (* b (* b b)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2.5e+93) {
tmp = (a * (a * (a * a))) + -1.0;
} else {
tmp = b * (b * (b * b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2.5d+93) then
tmp = (a * (a * (a * a))) + (-1.0d0)
else
tmp = b * (b * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2.5e+93) {
tmp = (a * (a * (a * a))) + -1.0;
} else {
tmp = b * (b * (b * b));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2.5e+93: tmp = (a * (a * (a * a))) + -1.0 else: tmp = b * (b * (b * b)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2.5e+93) tmp = Float64(Float64(a * Float64(a * Float64(a * a))) + -1.0); else tmp = Float64(b * Float64(b * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2.5e+93) tmp = (a * (a * (a * a))) + -1.0; else tmp = b * (b * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2.5e+93], N[(N[(a * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(b * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2.5 \cdot 10^{+93}:\\
\;\;\;\;a \cdot \left(a \cdot \left(a \cdot a\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot \left(b \cdot b\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 2.5000000000000001e93Initial program 81.6%
Taylor expanded in a around inf
metadata-evalN/A
pow-plusN/A
*-commutativeN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6495.9%
Simplified95.9%
if 2.5000000000000001e93 < (*.f64 b b) Initial program 67.0%
Taylor expanded in b around inf
metadata-evalN/A
pow-sqrN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6497.3%
Simplified97.3%
Final simplification96.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+16) (+ (* (* a a) 4.0) -1.0) (* b (* b (* b b)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+16) {
tmp = ((a * a) * 4.0) + -1.0;
} else {
tmp = b * (b * (b * b));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 1d+16) then
tmp = ((a * a) * 4.0d0) + (-1.0d0)
else
tmp = b * (b * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+16) {
tmp = ((a * a) * 4.0) + -1.0;
} else {
tmp = b * (b * (b * b));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e+16: tmp = ((a * a) * 4.0) + -1.0 else: tmp = b * (b * (b * b)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1e+16) tmp = Float64(Float64(Float64(a * a) * 4.0) + -1.0); else tmp = Float64(b * Float64(b * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 1e+16) tmp = ((a * a) * 4.0) + -1.0; else tmp = b * (b * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1e+16], N[(N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision], N[(b * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10^{+16}:\\
\;\;\;\;\left(a \cdot a\right) \cdot 4 + -1\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot \left(b \cdot b\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1e16Initial program 81.5%
Taylor expanded in b around 0
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6499.0%
Simplified99.0%
Taylor expanded in a around 0
Simplified82.1%
if 1e16 < (*.f64 b b) Initial program 68.2%
Taylor expanded in b around inf
metadata-evalN/A
pow-sqrN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6494.0%
Simplified94.0%
Final simplification87.2%
(FPCore (a b) :precision binary64 (if (<= b 0.29) -1.0 (* b (* b 12.0))))
double code(double a, double b) {
double tmp;
if (b <= 0.29) {
tmp = -1.0;
} else {
tmp = b * (b * 12.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 0.29d0) then
tmp = -1.0d0
else
tmp = b * (b * 12.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 0.29) {
tmp = -1.0;
} else {
tmp = b * (b * 12.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 0.29: tmp = -1.0 else: tmp = b * (b * 12.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 0.29) tmp = -1.0; else tmp = Float64(b * Float64(b * 12.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 0.29) tmp = -1.0; else tmp = b * (b * 12.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 0.29], -1.0, N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.29:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot 12\right)\\
\end{array}
\end{array}
if b < 0.28999999999999998Initial program 75.7%
Taylor expanded in a around inf
metadata-evalN/A
pow-plusN/A
*-commutativeN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6481.4%
Simplified81.4%
Taylor expanded in a around 0
Simplified40.8%
if 0.28999999999999998 < b Initial program 75.9%
Taylor expanded in a around 0
+-commutativeN/A
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f6493.0%
Simplified93.0%
Taylor expanded in b around 0
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6458.5%
Simplified58.5%
Taylor expanded in b around inf
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6458.5%
Simplified58.5%
(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.7%
Taylor expanded in a around inf
metadata-evalN/A
pow-plusN/A
*-commutativeN/A
*-lowering-*.f64N/A
cube-multN/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6471.5%
Simplified71.5%
Taylor expanded in a around 0
Simplified32.3%
herbie shell --seed 2024191
(FPCore (a b)
:name "Bouland and Aaronson, Equation (24)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))