
(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 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) (+ 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 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 * 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 * 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 * t_0) + ((4.0 * (b * (b * 3.0))) + -1.0);
}
def code(a, b): t_0 = (a * a) + (b * b) return (t_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(t_0 * t_0) + Float64(Float64(4.0 * Float64(b * Float64(b * 3.0))) + -1.0)) end
function tmp = code(a, b) t_0 = (a * a) + (b * b); tmp = (t_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[(t$95$0 * t$95$0), $MachinePrecision] + N[(N[(4.0 * N[(b * N[(b * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot a + b \cdot b\\
t\_0 \cdot t\_0 + \left(4 \cdot \left(b \cdot \left(b \cdot 3\right)\right) + -1\right)
\end{array}
\end{array}
Initial program 74.8%
associate--l+N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
+-lowering-+.f64N/A
Simplified74.8%
Taylor expanded in a around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6499.1%
Simplified99.1%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* a (* a (+ (* a a) (* b (* b 2.0)))))))
(if (<= a -3.2)
t_0
(if (<= a 6100000.0) (+ (* (* b b) (+ (* b b) 12.0)) -1.0) t_0))))
double code(double a, double b) {
double t_0 = a * (a * ((a * a) + (b * (b * 2.0))));
double tmp;
if (a <= -3.2) {
tmp = t_0;
} else if (a <= 6100000.0) {
tmp = ((b * b) * ((b * b) + 12.0)) + -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) + (b * (b * 2.0d0))))
if (a <= (-3.2d0)) then
tmp = t_0
else if (a <= 6100000.0d0) then
tmp = ((b * b) * ((b * b) + 12.0d0)) + (-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) + (b * (b * 2.0))));
double tmp;
if (a <= -3.2) {
tmp = t_0;
} else if (a <= 6100000.0) {
tmp = ((b * b) * ((b * b) + 12.0)) + -1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b): t_0 = a * (a * ((a * a) + (b * (b * 2.0)))) tmp = 0 if a <= -3.2: tmp = t_0 elif a <= 6100000.0: tmp = ((b * b) * ((b * b) + 12.0)) + -1.0 else: tmp = t_0 return tmp
function code(a, b) t_0 = Float64(a * Float64(a * Float64(Float64(a * a) + Float64(b * Float64(b * 2.0))))) tmp = 0.0 if (a <= -3.2) tmp = t_0; elseif (a <= 6100000.0) tmp = Float64(Float64(Float64(b * b) * Float64(Float64(b * b) + 12.0)) + -1.0); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b) t_0 = a * (a * ((a * a) + (b * (b * 2.0)))); tmp = 0.0; if (a <= -3.2) tmp = t_0; elseif (a <= 6100000.0) tmp = ((b * b) * ((b * b) + 12.0)) + -1.0; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(a * N[(a * N[(N[(a * a), $MachinePrecision] + N[(b * N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -3.2], t$95$0, If[LessEqual[a, 6100000.0], N[(N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(a \cdot \left(a \cdot a + b \cdot \left(b \cdot 2\right)\right)\right)\\
\mathbf{if}\;a \leq -3.2:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 6100000:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + 12\right) + -1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -3.2000000000000002 or 6.1e6 < a Initial program 53.1%
associate--l+N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
+-lowering-+.f64N/A
Simplified53.1%
Taylor expanded in a around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6499.1%
Simplified99.1%
Taylor expanded in b around 0
Simplified99.1%
Taylor expanded in a around inf
Simplified97.1%
if -3.2000000000000002 < a < 6.1e6Initial program 99.9%
Taylor expanded in a around 0
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
+-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f6499.1%
Simplified99.1%
Final simplification98.0%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* a (* a (* a a)))))
(if (<= b 3.3e-214)
t_0
(if (<= b 6.8e-68)
-1.0
(if (<= b 680000000000.0) t_0 (* b (* b (* b b))))))))
double code(double a, double b) {
double t_0 = a * (a * (a * a));
double tmp;
if (b <= 3.3e-214) {
tmp = t_0;
} else if (b <= 6.8e-68) {
tmp = -1.0;
} else if (b <= 680000000000.0) {
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 <= 3.3d-214) then
tmp = t_0
else if (b <= 6.8d-68) then
tmp = -1.0d0
else if (b <= 680000000000.0d0) 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 <= 3.3e-214) {
tmp = t_0;
} else if (b <= 6.8e-68) {
tmp = -1.0;
} else if (b <= 680000000000.0) {
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 <= 3.3e-214: tmp = t_0 elif b <= 6.8e-68: tmp = -1.0 elif b <= 680000000000.0: 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 <= 3.3e-214) tmp = t_0; elseif (b <= 6.8e-68) tmp = -1.0; elseif (b <= 680000000000.0) 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 <= 3.3e-214) tmp = t_0; elseif (b <= 6.8e-68) tmp = -1.0; elseif (b <= 680000000000.0) 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, 3.3e-214], t$95$0, If[LessEqual[b, 6.8e-68], -1.0, If[LessEqual[b, 680000000000.0], 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 3.3 \cdot 10^{-214}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 6.8 \cdot 10^{-68}:\\
\;\;\;\;-1\\
\mathbf{elif}\;b \leq 680000000000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot \left(b \cdot b\right)\right)\\
\end{array}
\end{array}
if b < 3.2999999999999998e-214 or 6.80000000000000037e-68 < b < 6.8e11Initial program 78.2%
associate--l+N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
+-lowering-+.f64N/A
Simplified78.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.1%
Simplified51.1%
if 3.2999999999999998e-214 < b < 6.80000000000000037e-68Initial program 95.5%
Taylor expanded in a around 0
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
+-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f6463.0%
Simplified63.0%
Taylor expanded in b around 0
Simplified63.0%
if 6.8e11 < b Initial program 57.9%
associate--l+N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
+-lowering-+.f64N/A
Simplified57.9%
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-*.f6489.4%
Simplified89.4%
(FPCore (a b) :precision binary64 (if (<= (* b b) 10000000000.0) (+ (* a (* a (+ (* a a) (* 4.0 (- 1.0 a))))) -1.0) (* (* b b) (+ (* b b) (* (* a a) 2.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 10000000000.0) {
tmp = (a * (a * ((a * a) + (4.0 * (1.0 - a))))) + -1.0;
} else {
tmp = (b * b) * ((b * b) + ((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) <= 10000000000.0d0) then
tmp = (a * (a * ((a * a) + (4.0d0 * (1.0d0 - a))))) + (-1.0d0)
else
tmp = (b * b) * ((b * b) + ((a * a) * 2.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 10000000000.0) {
tmp = (a * (a * ((a * a) + (4.0 * (1.0 - a))))) + -1.0;
} else {
tmp = (b * b) * ((b * b) + ((a * a) * 2.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 10000000000.0: tmp = (a * (a * ((a * a) + (4.0 * (1.0 - a))))) + -1.0 else: tmp = (b * b) * ((b * b) + ((a * a) * 2.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 10000000000.0) tmp = Float64(Float64(a * Float64(a * Float64(Float64(a * a) + Float64(4.0 * Float64(1.0 - a))))) + -1.0); else tmp = Float64(Float64(b * b) * Float64(Float64(b * b) + Float64(Float64(a * a) * 2.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 10000000000.0) tmp = (a * (a * ((a * a) + (4.0 * (1.0 - a))))) + -1.0; else tmp = (b * b) * ((b * b) + ((a * a) * 2.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 10000000000.0], N[(N[(a * N[(a * N[(N[(a * a), $MachinePrecision] + N[(4.0 * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10000000000:\\
\;\;\;\;a \cdot \left(a \cdot \left(a \cdot a + 4 \cdot \left(1 - a\right)\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + \left(a \cdot a\right) \cdot 2\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1e10Initial program 86.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--.f6499.1%
Simplified99.1%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6499.2%
Applied egg-rr99.2%
if 1e10 < (*.f64 b b) Initial program 61.5%
associate--l+N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
+-lowering-+.f64N/A
Simplified61.5%
Taylor expanded in a around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6499.8%
Simplified99.8%
Taylor expanded in b around 0
Simplified99.8%
Taylor expanded in b around inf
distribute-rgt-inN/A
*-lft-identityN/A
metadata-evalN/A
pow-sqrN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
*-rgt-identityN/A
associate-*r/N/A
metadata-evalN/A
pow-sqrN/A
associate-*l*N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
*-lowering-*.f64N/A
Simplified96.0%
Final simplification97.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e-20) (+ (* (* a a) 4.0) -1.0) (if (<= (* b b) 1e+18) (* a (* a (* a a))) (* b (* b (* b b))))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e-20) {
tmp = ((a * a) * 4.0) + -1.0;
} else if ((b * b) <= 1e+18) {
tmp = a * (a * (a * a));
} 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) <= 5d-20) then
tmp = ((a * a) * 4.0d0) + (-1.0d0)
else if ((b * b) <= 1d+18) then
tmp = a * (a * (a * a))
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) <= 5e-20) {
tmp = ((a * a) * 4.0) + -1.0;
} else if ((b * b) <= 1e+18) {
tmp = a * (a * (a * a));
} else {
tmp = b * (b * (b * b));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e-20: tmp = ((a * a) * 4.0) + -1.0 elif (b * b) <= 1e+18: tmp = a * (a * (a * a)) else: tmp = b * (b * (b * b)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e-20) tmp = Float64(Float64(Float64(a * a) * 4.0) + -1.0); elseif (Float64(b * b) <= 1e+18) tmp = Float64(a * Float64(a * Float64(a * a))); 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) <= 5e-20) tmp = ((a * a) * 4.0) + -1.0; elseif ((b * b) <= 1e+18) tmp = a * (a * (a * a)); else tmp = b * (b * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e-20], N[(N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[N[(b * b), $MachinePrecision], 1e+18], N[(a * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-20}:\\
\;\;\;\;\left(a \cdot a\right) \cdot 4 + -1\\
\mathbf{elif}\;b \cdot b \leq 10^{+18}:\\
\;\;\;\;a \cdot \left(a \cdot \left(a \cdot a\right)\right)\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot \left(b \cdot b\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 4.9999999999999999e-20Initial program 86.2%
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.9%
Simplified99.9%
Taylor expanded in a around 0
Simplified78.3%
if 4.9999999999999999e-20 < (*.f64 b b) < 1e18Initial program 99.3%
associate--l+N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
+-lowering-+.f64N/A
Simplified99.3%
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-*.f6485.5%
Simplified85.5%
if 1e18 < (*.f64 b b) Initial program 60.8%
associate--l+N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
+-lowering-+.f64N/A
Simplified60.8%
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-*.f6490.8%
Simplified90.8%
Final simplification84.3%
(FPCore (a b) :precision binary64 (if (<= (* b b) 10000000000.0) (+ (* (* a a) (+ 4.0 (* a (+ a -4.0)))) -1.0) (* (* b b) (+ (* b b) (* (* a a) 2.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 10000000000.0) {
tmp = ((a * a) * (4.0 + (a * (a + -4.0)))) + -1.0;
} else {
tmp = (b * b) * ((b * b) + ((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) <= 10000000000.0d0) then
tmp = ((a * a) * (4.0d0 + (a * (a + (-4.0d0))))) + (-1.0d0)
else
tmp = (b * b) * ((b * b) + ((a * a) * 2.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 10000000000.0) {
tmp = ((a * a) * (4.0 + (a * (a + -4.0)))) + -1.0;
} else {
tmp = (b * b) * ((b * b) + ((a * a) * 2.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 10000000000.0: tmp = ((a * a) * (4.0 + (a * (a + -4.0)))) + -1.0 else: tmp = (b * b) * ((b * b) + ((a * a) * 2.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 10000000000.0) tmp = Float64(Float64(Float64(a * a) * Float64(4.0 + Float64(a * Float64(a + -4.0)))) + -1.0); else tmp = Float64(Float64(b * b) * Float64(Float64(b * b) + Float64(Float64(a * a) * 2.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 10000000000.0) tmp = ((a * a) * (4.0 + (a * (a + -4.0)))) + -1.0; else tmp = (b * b) * ((b * b) + ((a * a) * 2.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 10000000000.0], N[(N[(N[(a * a), $MachinePrecision] * N[(4.0 + N[(a * N[(a + -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10000000000:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + \left(a \cdot a\right) \cdot 2\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1e10Initial program 86.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--.f6499.1%
Simplified99.1%
Taylor expanded in a around 0
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f6499.2%
Simplified99.2%
if 1e10 < (*.f64 b b) Initial program 61.5%
associate--l+N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
+-lowering-+.f64N/A
Simplified61.5%
Taylor expanded in a around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6499.8%
Simplified99.8%
Taylor expanded in b around 0
Simplified99.8%
Taylor expanded in b around inf
distribute-rgt-inN/A
*-lft-identityN/A
metadata-evalN/A
pow-sqrN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
*-rgt-identityN/A
associate-*r/N/A
metadata-evalN/A
pow-sqrN/A
associate-*l*N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
*-lowering-*.f64N/A
Simplified96.0%
Final simplification97.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 10000000000.0) (+ (* a (* a (* a a))) -1.0) (* (* b b) (+ (* b b) (* (* a a) 2.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 10000000000.0) {
tmp = (a * (a * (a * a))) + -1.0;
} else {
tmp = (b * b) * ((b * b) + ((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) <= 10000000000.0d0) then
tmp = (a * (a * (a * a))) + (-1.0d0)
else
tmp = (b * b) * ((b * b) + ((a * a) * 2.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 10000000000.0) {
tmp = (a * (a * (a * a))) + -1.0;
} else {
tmp = (b * b) * ((b * b) + ((a * a) * 2.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 10000000000.0: tmp = (a * (a * (a * a))) + -1.0 else: tmp = (b * b) * ((b * b) + ((a * a) * 2.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 10000000000.0) tmp = Float64(Float64(a * Float64(a * Float64(a * a))) + -1.0); else tmp = Float64(Float64(b * b) * Float64(Float64(b * b) + Float64(Float64(a * a) * 2.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 10000000000.0) tmp = (a * (a * (a * a))) + -1.0; else tmp = (b * b) * ((b * b) + ((a * a) * 2.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 10000000000.0], N[(N[(a * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 10000000000:\\
\;\;\;\;a \cdot \left(a \cdot \left(a \cdot a\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + \left(a \cdot a\right) \cdot 2\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1e10Initial program 86.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-*.f6497.7%
Simplified97.7%
if 1e10 < (*.f64 b b) Initial program 61.5%
associate--l+N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
+-lowering-+.f64N/A
Simplified61.5%
Taylor expanded in a around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6499.8%
Simplified99.8%
Taylor expanded in b around 0
Simplified99.8%
Taylor expanded in b around inf
distribute-rgt-inN/A
*-lft-identityN/A
metadata-evalN/A
pow-sqrN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
*-rgt-identityN/A
associate-*r/N/A
metadata-evalN/A
pow-sqrN/A
associate-*l*N/A
rgt-mult-inverseN/A
*-rgt-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
*-lowering-*.f64N/A
Simplified96.0%
Final simplification96.9%
(FPCore (a b) :precision binary64 (let* ((t_0 (* a (* a (* a a))))) (if (<= a -0.42) t_0 (if (<= a 7.8e-38) -1.0 t_0))))
double code(double a, double b) {
double t_0 = a * (a * (a * a));
double tmp;
if (a <= -0.42) {
tmp = t_0;
} else if (a <= 7.8e-38) {
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.42d0)) then
tmp = t_0
else if (a <= 7.8d-38) 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.42) {
tmp = t_0;
} else if (a <= 7.8e-38) {
tmp = -1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b): t_0 = a * (a * (a * a)) tmp = 0 if a <= -0.42: tmp = t_0 elif a <= 7.8e-38: 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.42) tmp = t_0; elseif (a <= 7.8e-38) 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.42) tmp = t_0; elseif (a <= 7.8e-38) 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.42], t$95$0, If[LessEqual[a, 7.8e-38], -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.42:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;a \leq 7.8 \cdot 10^{-38}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if a < -0.419999999999999984 or 7.7999999999999998e-38 < a Initial program 55.4%
associate--l+N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
+-lowering-+.f64N/A
Simplified55.4%
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-*.f6485.7%
Simplified85.7%
if -0.419999999999999984 < a < 7.7999999999999998e-38Initial program 99.9%
Taylor expanded in a around 0
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
+-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f6499.0%
Simplified99.0%
Taylor expanded in b around 0
Simplified58.4%
(FPCore (a b) :precision binary64 (let* ((t_0 (+ (* a a) (* b b)))) (+ (* t_0 t_0) -1.0)))
double code(double a, double b) {
double t_0 = (a * a) + (b * b);
return (t_0 * t_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 * t_0) + (-1.0d0)
end function
public static double code(double a, double b) {
double t_0 = (a * a) + (b * b);
return (t_0 * t_0) + -1.0;
}
def code(a, b): t_0 = (a * a) + (b * b) return (t_0 * t_0) + -1.0
function code(a, b) t_0 = Float64(Float64(a * a) + Float64(b * b)) return Float64(Float64(t_0 * t_0) + -1.0) end
function tmp = code(a, b) t_0 = (a * a) + (b * b); tmp = (t_0 * t_0) + -1.0; end
code[a_, b_] := Block[{t$95$0 = N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$0 * t$95$0), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot a + b \cdot b\\
t\_0 \cdot t\_0 + -1
\end{array}
\end{array}
Initial program 74.8%
associate--l+N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
+-lowering-+.f64N/A
Simplified74.8%
Taylor expanded in a around 0
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6499.1%
Simplified99.1%
Taylor expanded in b around 0
Simplified98.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+18) (+ (* a (* a (* a a))) -1.0) (* b (* b (* b b)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+18) {
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) <= 1d+18) 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) <= 1e+18) {
tmp = (a * (a * (a * a))) + -1.0;
} else {
tmp = b * (b * (b * b));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 1e+18: 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) <= 1e+18) 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) <= 1e+18) 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], 1e+18], 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 10^{+18}:\\
\;\;\;\;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) < 1e18Initial program 86.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-*.f6497.7%
Simplified97.7%
if 1e18 < (*.f64 b b) Initial program 60.8%
associate--l+N/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
+-lowering-+.f64N/A
Simplified60.8%
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-*.f6490.8%
Simplified90.8%
Final simplification94.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 74.8%
Taylor expanded in a around 0
metadata-evalN/A
pow-sqrN/A
distribute-rgt-outN/A
+-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
*-lowering-*.f6467.9%
Simplified67.9%
Taylor expanded in b around 0
Simplified26.0%
herbie shell --seed 2024141
(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))