
(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 14 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 (hypot a b) 4.0) (fma b (* b 4.0) -1.0)))
double code(double a, double b) {
return pow(hypot(a, b), 4.0) + fma(b, (b * 4.0), -1.0);
}
function code(a, b) return Float64((hypot(a, b) ^ 4.0) + fma(b, Float64(b * 4.0), -1.0)) end
code[a_, b_] := N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(b * N[(b * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right)
\end{array}
Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.8%
associate-*r*99.9%
Simplified100.0%
Final simplification100.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 400000000.0) (+ (pow a 4.0) -1.0) (+ (pow b 4.0) (* (* b b) (+ 4.0 (* (* a a) 2.0))))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 400000000.0) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = pow(b, 4.0) + ((b * b) * (4.0 + ((a * a) * 2.0)));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 400000000.0d0) then
tmp = (a ** 4.0d0) + (-1.0d0)
else
tmp = (b ** 4.0d0) + ((b * b) * (4.0d0 + ((a * a) * 2.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 400000000.0) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = Math.pow(b, 4.0) + ((b * b) * (4.0 + ((a * a) * 2.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 400000000.0: tmp = math.pow(a, 4.0) + -1.0 else: tmp = math.pow(b, 4.0) + ((b * b) * (4.0 + ((a * a) * 2.0))) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 400000000.0) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64((b ^ 4.0) + Float64(Float64(b * b) * Float64(4.0 + Float64(Float64(a * a) * 2.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 400000000.0) tmp = (a ^ 4.0) + -1.0; else tmp = (b ^ 4.0) + ((b * b) * (4.0 + ((a * a) * 2.0))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 400000000.0], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(N[(a * a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 400000000:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + \left(b \cdot b\right) \cdot \left(4 + \left(a \cdot a\right) \cdot 2\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 4e8Initial program 99.9%
associate--l+99.9%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.9%
Simplified100.0%
Taylor expanded in b around 0 100.0%
if 4e8 < (*.f64 b b) Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
Simplified99.9%
Taylor expanded in b around inf 98.1%
*-commutative98.1%
unpow298.1%
unpow298.1%
Simplified98.1%
Final simplification99.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 400000000.0) (+ (pow a 4.0) -1.0) (+ (pow b 4.0) (* b (* b (* (* a a) 2.0))))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 400000000.0) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = pow(b, 4.0) + (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) <= 400000000.0d0) then
tmp = (a ** 4.0d0) + (-1.0d0)
else
tmp = (b ** 4.0d0) + (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) <= 400000000.0) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = Math.pow(b, 4.0) + (b * (b * ((a * a) * 2.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 400000000.0: tmp = math.pow(a, 4.0) + -1.0 else: tmp = math.pow(b, 4.0) + (b * (b * ((a * a) * 2.0))) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 400000000.0) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64((b ^ 4.0) + Float64(b * Float64(b * Float64(Float64(a * a) * 2.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 400000000.0) tmp = (a ^ 4.0) + -1.0; else tmp = (b ^ 4.0) + (b * (b * ((a * a) * 2.0))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 400000000.0], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + N[(b * N[(b * N[(N[(a * a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 400000000:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + b \cdot \left(b \cdot \left(\left(a \cdot a\right) \cdot 2\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 4e8Initial program 99.9%
associate--l+99.9%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.9%
Simplified100.0%
Taylor expanded in b around 0 100.0%
if 4e8 < (*.f64 b b) Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
Simplified99.9%
Taylor expanded in b around inf 98.1%
*-commutative98.1%
unpow298.1%
unpow298.1%
Simplified98.1%
Taylor expanded in a around inf 86.5%
associate-*r*86.5%
unpow286.5%
*-commutative86.5%
unpow286.5%
associate-*l*98.0%
Simplified98.0%
Final simplification99.0%
(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}
Initial program 99.9%
Final simplification99.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 400000000.0) (+ (pow a 4.0) -1.0) (+ (pow b 4.0) (* b (* b 4.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 400000000.0) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = pow(b, 4.0) + (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) <= 400000000.0d0) then
tmp = (a ** 4.0d0) + (-1.0d0)
else
tmp = (b ** 4.0d0) + (b * (b * 4.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 400000000.0) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = Math.pow(b, 4.0) + (b * (b * 4.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 400000000.0: tmp = math.pow(a, 4.0) + -1.0 else: tmp = math.pow(b, 4.0) + (b * (b * 4.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 400000000.0) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64((b ^ 4.0) + Float64(b * Float64(b * 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 400000000.0) tmp = (a ^ 4.0) + -1.0; else tmp = (b ^ 4.0) + (b * (b * 4.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 400000000.0], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 400000000:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + b \cdot \left(b \cdot 4\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 4e8Initial program 99.9%
associate--l+99.9%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.9%
Simplified100.0%
Taylor expanded in b around 0 100.0%
if 4e8 < (*.f64 b b) Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
Simplified99.9%
Taylor expanded in b around inf 98.1%
*-commutative98.1%
unpow298.1%
unpow298.1%
Simplified98.1%
Taylor expanded in a around 0 93.0%
unpow293.0%
associate-*r*93.0%
Simplified93.0%
Final simplification96.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 400000000.0) (+ (pow a 4.0) -1.0) (* b (* b (fma b b 4.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 400000000.0) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = b * (b * fma(b, b, 4.0));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 400000000.0) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64(b * Float64(b * fma(b, b, 4.0))); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 400000000.0], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(b * N[(b * N[(b * b + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 400000000:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 4\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 4e8Initial program 99.9%
associate--l+99.9%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.9%
Simplified100.0%
Taylor expanded in b around 0 100.0%
if 4e8 < (*.f64 b b) Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
Simplified99.9%
Taylor expanded in b around inf 98.1%
*-commutative98.1%
unpow298.1%
unpow298.1%
Simplified98.1%
Taylor expanded in a around 0 93.0%
unpow293.0%
associate-*r*93.0%
Simplified93.0%
sqr-pow93.0%
fma-def93.0%
metadata-eval93.0%
pow293.0%
metadata-eval93.0%
pow293.0%
*-commutative93.0%
*-commutative93.0%
Applied egg-rr93.0%
Taylor expanded in b around 0 93.0%
metadata-eval93.0%
pow-plus93.0%
unpow393.0%
associate-*r*93.0%
unpow293.0%
distribute-rgt-in93.0%
fma-udef93.0%
associate-*l*93.0%
Simplified93.0%
Final simplification96.6%
(FPCore (a b) :precision binary64 (if (<= (* b b) 400000000.0) (+ (pow a 4.0) -1.0) (+ (* 4.0 (* b b)) (* (* b b) (* b b)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 400000000.0) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = (4.0 * (b * b)) + ((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) <= 400000000.0d0) then
tmp = (a ** 4.0d0) + (-1.0d0)
else
tmp = (4.0d0 * (b * b)) + ((b * b) * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 400000000.0) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = (4.0 * (b * b)) + ((b * b) * (b * b));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 400000000.0: tmp = math.pow(a, 4.0) + -1.0 else: tmp = (4.0 * (b * b)) + ((b * b) * (b * b)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 400000000.0) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64(Float64(4.0 * Float64(b * b)) + Float64(Float64(b * b) * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 400000000.0) tmp = (a ^ 4.0) + -1.0; else tmp = (4.0 * (b * b)) + ((b * b) * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 400000000.0], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 400000000:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 4e8Initial program 99.9%
associate--l+99.9%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.9%
Simplified100.0%
Taylor expanded in b around 0 100.0%
if 4e8 < (*.f64 b b) Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
Simplified99.9%
Taylor expanded in b around inf 98.1%
*-commutative98.1%
unpow298.1%
unpow298.1%
Simplified98.1%
Taylor expanded in a around 0 93.0%
unpow293.0%
associate-*r*93.0%
Simplified93.0%
add-cube-cbrt92.7%
unpow-prod-down92.6%
fma-def92.6%
pow292.6%
*-commutative92.6%
*-commutative92.6%
Applied egg-rr92.6%
fma-udef92.6%
+-commutative92.6%
associate-*r*92.6%
*-commutative92.6%
sqr-pow92.6%
metadata-eval92.6%
pow-sqr92.6%
unpow292.6%
metadata-eval92.6%
associate-*l*92.6%
cube-unmult92.6%
Simplified92.8%
unpow392.8%
*-commutative92.8%
associate-*r*92.8%
swap-sqr92.8%
associate-*r*92.9%
add-cube-cbrt93.0%
associate-*r*93.0%
Applied egg-rr93.0%
Final simplification96.6%
(FPCore (a b)
:precision binary64
(if (<= (* a a) 2.5e-309)
-1.0
(if (<= (* a a) 3.5e-211)
(* 4.0 (* b b))
(if (<= (* a a) 1.0) -1.0 (* (* a a) (+ (* a a) 1.0))))))
double code(double a, double b) {
double tmp;
if ((a * a) <= 2.5e-309) {
tmp = -1.0;
} else if ((a * a) <= 3.5e-211) {
tmp = 4.0 * (b * b);
} else if ((a * a) <= 1.0) {
tmp = -1.0;
} else {
tmp = (a * a) * ((a * a) + 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 * a) <= 2.5d-309) then
tmp = -1.0d0
else if ((a * a) <= 3.5d-211) then
tmp = 4.0d0 * (b * b)
else if ((a * a) <= 1.0d0) then
tmp = -1.0d0
else
tmp = (a * a) * ((a * a) + 1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a * a) <= 2.5e-309) {
tmp = -1.0;
} else if ((a * a) <= 3.5e-211) {
tmp = 4.0 * (b * b);
} else if ((a * a) <= 1.0) {
tmp = -1.0;
} else {
tmp = (a * a) * ((a * a) + 1.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (a * a) <= 2.5e-309: tmp = -1.0 elif (a * a) <= 3.5e-211: tmp = 4.0 * (b * b) elif (a * a) <= 1.0: tmp = -1.0 else: tmp = (a * a) * ((a * a) + 1.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 2.5e-309) tmp = -1.0; elseif (Float64(a * a) <= 3.5e-211) tmp = Float64(4.0 * Float64(b * b)); elseif (Float64(a * a) <= 1.0) tmp = -1.0; else tmp = Float64(Float64(a * a) * Float64(Float64(a * a) + 1.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a * a) <= 2.5e-309) tmp = -1.0; elseif ((a * a) <= 3.5e-211) tmp = 4.0 * (b * b); elseif ((a * a) <= 1.0) tmp = -1.0; else tmp = (a * a) * ((a * a) + 1.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 2.5e-309], -1.0, If[LessEqual[N[(a * a), $MachinePrecision], 3.5e-211], N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * a), $MachinePrecision], 1.0], -1.0, N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 2.5 \cdot 10^{-309}:\\
\;\;\;\;-1\\
\mathbf{elif}\;a \cdot a \leq 3.5 \cdot 10^{-211}:\\
\;\;\;\;4 \cdot \left(b \cdot b\right)\\
\mathbf{elif}\;a \cdot a \leq 1:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a + 1\right)\\
\end{array}
\end{array}
if (*.f64 a a) < 2.5000000000000022e-309 or 3.5e-211 < (*.f64 a a) < 1Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
Simplified100.0%
Taylor expanded in b around 0 52.4%
Taylor expanded in a around 0 51.5%
if 2.5000000000000022e-309 < (*.f64 a a) < 3.5e-211Initial program 100.0%
associate--l+100.0%
unpow2100.0%
unpow1100.0%
sqr-pow100.0%
associate-*r*100.0%
Simplified100.0%
Taylor expanded in b around inf 72.7%
*-commutative72.7%
unpow272.7%
unpow272.7%
Simplified72.7%
Taylor expanded in a around 0 72.7%
unpow272.7%
associate-*r*72.7%
Simplified72.7%
Taylor expanded in b around 0 47.2%
unpow247.2%
Simplified47.2%
if 1 < (*.f64 a a) Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.8%
Simplified99.9%
Taylor expanded in b around 0 92.2%
metadata-eval92.2%
pow-sqr92.0%
pow292.0%
pow292.0%
difference-of-sqr-192.0%
Applied egg-rr92.0%
Taylor expanded in a around inf 91.3%
unpow291.3%
Simplified91.3%
Final simplification71.8%
(FPCore (a b) :precision binary64 (if (<= (* b b) 400000000.0) (* (+ (* a a) 1.0) (+ (+ a -1.0) (* a (+ a -1.0)))) (+ (* 4.0 (* b b)) (* (* b b) (* b b)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 400000000.0) {
tmp = ((a * a) + 1.0) * ((a + -1.0) + (a * (a + -1.0)));
} else {
tmp = (4.0 * (b * b)) + ((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) <= 400000000.0d0) then
tmp = ((a * a) + 1.0d0) * ((a + (-1.0d0)) + (a * (a + (-1.0d0))))
else
tmp = (4.0d0 * (b * b)) + ((b * b) * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 400000000.0) {
tmp = ((a * a) + 1.0) * ((a + -1.0) + (a * (a + -1.0)));
} else {
tmp = (4.0 * (b * b)) + ((b * b) * (b * b));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 400000000.0: tmp = ((a * a) + 1.0) * ((a + -1.0) + (a * (a + -1.0))) else: tmp = (4.0 * (b * b)) + ((b * b) * (b * b)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 400000000.0) tmp = Float64(Float64(Float64(a * a) + 1.0) * Float64(Float64(a + -1.0) + Float64(a * Float64(a + -1.0)))); else tmp = Float64(Float64(4.0 * Float64(b * b)) + Float64(Float64(b * b) * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 400000000.0) tmp = ((a * a) + 1.0) * ((a + -1.0) + (a * (a + -1.0))); else tmp = (4.0 * (b * b)) + ((b * b) * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 400000000.0], N[(N[(N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(a + -1.0), $MachinePrecision] + N[(a * N[(a + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 400000000:\\
\;\;\;\;\left(a \cdot a + 1\right) \cdot \left(\left(a + -1\right) + a \cdot \left(a + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 4e8Initial program 99.9%
associate--l+99.9%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.9%
Simplified100.0%
Taylor expanded in b around 0 100.0%
metadata-eval100.0%
pow-sqr99.8%
pow299.8%
pow299.8%
difference-of-sqr-199.8%
Applied egg-rr99.8%
difference-of-sqr-199.8%
sub-neg99.8%
metadata-eval99.8%
Applied egg-rr99.8%
*-commutative99.8%
+-commutative99.8%
distribute-lft-in99.8%
*-commutative99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
if 4e8 < (*.f64 b b) Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
Simplified99.9%
Taylor expanded in b around inf 98.1%
*-commutative98.1%
unpow298.1%
unpow298.1%
Simplified98.1%
Taylor expanded in a around 0 93.0%
unpow293.0%
associate-*r*93.0%
Simplified93.0%
add-cube-cbrt92.7%
unpow-prod-down92.6%
fma-def92.6%
pow292.6%
*-commutative92.6%
*-commutative92.6%
Applied egg-rr92.6%
fma-udef92.6%
+-commutative92.6%
associate-*r*92.6%
*-commutative92.6%
sqr-pow92.6%
metadata-eval92.6%
pow-sqr92.6%
unpow292.6%
metadata-eval92.6%
associate-*l*92.6%
cube-unmult92.6%
Simplified92.8%
unpow392.8%
*-commutative92.8%
associate-*r*92.8%
swap-sqr92.8%
associate-*r*92.9%
add-cube-cbrt93.0%
associate-*r*93.0%
Applied egg-rr93.0%
Final simplification96.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 4.5e+302) (* (+ (* a a) 1.0) (* (+ a -1.0) (+ a 1.0))) (* 4.0 (* b b))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 4.5e+302) {
tmp = ((a * a) + 1.0) * ((a + -1.0) * (a + 1.0));
} else {
tmp = 4.0 * (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) <= 4.5d+302) then
tmp = ((a * a) + 1.0d0) * ((a + (-1.0d0)) * (a + 1.0d0))
else
tmp = 4.0d0 * (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 4.5e+302) {
tmp = ((a * a) + 1.0) * ((a + -1.0) * (a + 1.0));
} else {
tmp = 4.0 * (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 4.5e+302: tmp = ((a * a) + 1.0) * ((a + -1.0) * (a + 1.0)) else: tmp = 4.0 * (b * b) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 4.5e+302) tmp = Float64(Float64(Float64(a * a) + 1.0) * Float64(Float64(a + -1.0) * Float64(a + 1.0))); else tmp = Float64(4.0 * Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 4.5e+302) tmp = ((a * a) + 1.0) * ((a + -1.0) * (a + 1.0)); else tmp = 4.0 * (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 4.5e+302], N[(N[(N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(a + -1.0), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 4.5 \cdot 10^{+302}:\\
\;\;\;\;\left(a \cdot a + 1\right) \cdot \left(\left(a + -1\right) \cdot \left(a + 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 4.5000000000000002e302Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.8%
Simplified99.9%
Taylor expanded in b around 0 80.6%
metadata-eval80.6%
pow-sqr80.5%
pow280.5%
pow280.5%
difference-of-sqr-180.5%
Applied egg-rr80.5%
difference-of-sqr-180.5%
sub-neg80.5%
metadata-eval80.5%
Applied egg-rr80.5%
if 4.5000000000000002e302 < (*.f64 b b) Initial program 100.0%
associate--l+100.0%
unpow2100.0%
unpow1100.0%
sqr-pow100.0%
associate-*r*100.0%
Simplified100.0%
Taylor expanded in b around inf 100.0%
*-commutative100.0%
unpow2100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
unpow2100.0%
associate-*r*100.0%
Simplified100.0%
Taylor expanded in b around 0 97.6%
unpow297.6%
Simplified97.6%
Final simplification85.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 75000000000.0) (* (+ (* a a) 1.0) (* (+ a -1.0) (+ a 1.0))) (+ (* 4.0 (* b b)) (* (* b b) (* b b)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 75000000000.0) {
tmp = ((a * a) + 1.0) * ((a + -1.0) * (a + 1.0));
} else {
tmp = (4.0 * (b * b)) + ((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) <= 75000000000.0d0) then
tmp = ((a * a) + 1.0d0) * ((a + (-1.0d0)) * (a + 1.0d0))
else
tmp = (4.0d0 * (b * b)) + ((b * b) * (b * b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 75000000000.0) {
tmp = ((a * a) + 1.0) * ((a + -1.0) * (a + 1.0));
} else {
tmp = (4.0 * (b * b)) + ((b * b) * (b * b));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 75000000000.0: tmp = ((a * a) + 1.0) * ((a + -1.0) * (a + 1.0)) else: tmp = (4.0 * (b * b)) + ((b * b) * (b * b)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 75000000000.0) tmp = Float64(Float64(Float64(a * a) + 1.0) * Float64(Float64(a + -1.0) * Float64(a + 1.0))); else tmp = Float64(Float64(4.0 * Float64(b * b)) + Float64(Float64(b * b) * Float64(b * b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 75000000000.0) tmp = ((a * a) + 1.0) * ((a + -1.0) * (a + 1.0)); else tmp = (4.0 * (b * b)) + ((b * b) * (b * b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 75000000000.0], N[(N[(N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(a + -1.0), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 75000000000:\\
\;\;\;\;\left(a \cdot a + 1\right) \cdot \left(\left(a + -1\right) \cdot \left(a + 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 7.5e10Initial program 99.9%
associate--l+99.9%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.9%
Simplified100.0%
Taylor expanded in b around 0 100.0%
metadata-eval100.0%
pow-sqr99.8%
pow299.8%
pow299.8%
difference-of-sqr-199.8%
Applied egg-rr99.8%
difference-of-sqr-199.8%
sub-neg99.8%
metadata-eval99.8%
Applied egg-rr99.8%
if 7.5e10 < (*.f64 b b) Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
Simplified99.9%
Taylor expanded in b around inf 98.1%
*-commutative98.1%
unpow298.1%
unpow298.1%
Simplified98.1%
Taylor expanded in a around 0 93.0%
unpow293.0%
associate-*r*93.0%
Simplified93.0%
add-cube-cbrt92.7%
unpow-prod-down92.6%
fma-def92.6%
pow292.6%
*-commutative92.6%
*-commutative92.6%
Applied egg-rr92.6%
fma-udef92.6%
+-commutative92.6%
associate-*r*92.6%
*-commutative92.6%
sqr-pow92.6%
metadata-eval92.6%
pow-sqr92.6%
unpow292.6%
metadata-eval92.6%
associate-*l*92.6%
cube-unmult92.6%
Simplified92.8%
unpow392.8%
*-commutative92.8%
associate-*r*92.8%
swap-sqr92.8%
associate-*r*92.9%
add-cube-cbrt93.0%
associate-*r*93.0%
Applied egg-rr93.0%
Final simplification96.6%
(FPCore (a b) :precision binary64 (if (<= (* b b) 4.5e+302) (* (+ (* a a) 1.0) (+ (* a a) -1.0)) (* 4.0 (* b b))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 4.5e+302) {
tmp = ((a * a) + 1.0) * ((a * a) + -1.0);
} else {
tmp = 4.0 * (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) <= 4.5d+302) then
tmp = ((a * a) + 1.0d0) * ((a * a) + (-1.0d0))
else
tmp = 4.0d0 * (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 4.5e+302) {
tmp = ((a * a) + 1.0) * ((a * a) + -1.0);
} else {
tmp = 4.0 * (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 4.5e+302: tmp = ((a * a) + 1.0) * ((a * a) + -1.0) else: tmp = 4.0 * (b * b) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 4.5e+302) tmp = Float64(Float64(Float64(a * a) + 1.0) * Float64(Float64(a * a) + -1.0)); else tmp = Float64(4.0 * Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 4.5e+302) tmp = ((a * a) + 1.0) * ((a * a) + -1.0); else tmp = 4.0 * (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 4.5e+302], N[(N[(N[(a * a), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 4.5 \cdot 10^{+302}:\\
\;\;\;\;\left(a \cdot a + 1\right) \cdot \left(a \cdot a + -1\right)\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 4.5000000000000002e302Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.8%
Simplified99.9%
Taylor expanded in b around 0 80.6%
metadata-eval80.6%
pow-sqr80.5%
pow280.5%
pow280.5%
difference-of-sqr-180.5%
Applied egg-rr80.5%
if 4.5000000000000002e302 < (*.f64 b b) Initial program 100.0%
associate--l+100.0%
unpow2100.0%
unpow1100.0%
sqr-pow100.0%
associate-*r*100.0%
Simplified100.0%
Taylor expanded in b around inf 100.0%
*-commutative100.0%
unpow2100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
unpow2100.0%
associate-*r*100.0%
Simplified100.0%
Taylor expanded in b around 0 97.6%
unpow297.6%
Simplified97.6%
Final simplification85.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 7.5e-28) -1.0 (* 4.0 (* b b))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 7.5e-28) {
tmp = -1.0;
} else {
tmp = 4.0 * (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) <= 7.5d-28) then
tmp = -1.0d0
else
tmp = 4.0d0 * (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 7.5e-28) {
tmp = -1.0;
} else {
tmp = 4.0 * (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 7.5e-28: tmp = -1.0 else: tmp = 4.0 * (b * b) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 7.5e-28) tmp = -1.0; else tmp = Float64(4.0 * Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 7.5e-28) tmp = -1.0; else tmp = 4.0 * (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 7.5e-28], -1.0, N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 7.5 \cdot 10^{-28}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 7.5000000000000003e-28Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.9%
Simplified100.0%
Taylor expanded in b around 0 100.0%
Taylor expanded in a around 0 44.0%
if 7.5000000000000003e-28 < (*.f64 b b) Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
Simplified99.9%
Taylor expanded in b around inf 97.4%
*-commutative97.4%
unpow297.4%
unpow297.4%
Simplified97.4%
Taylor expanded in a around 0 90.9%
unpow290.9%
associate-*r*90.9%
Simplified90.9%
Taylor expanded in b around 0 56.0%
unpow256.0%
Simplified56.0%
Final simplification49.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%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.8%
associate-*r*99.9%
Simplified100.0%
Taylor expanded in b around 0 70.7%
Taylor expanded in a around 0 22.9%
Final simplification22.9%
herbie shell --seed 2023256
(FPCore (a b)
:name "Bouland and Aaronson, Equation (26)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))