
(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 (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.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.8%
Simplified100.0%
Final simplification100.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1000000.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) <= 1000000.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) <= 1000000.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) <= 1000000.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) <= 1000000.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) <= 1000000.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) <= 1000000.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], 1000000.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 1000000:\\
\;\;\;\;{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) < 1e6Initial 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 99.8%
if 1e6 < (*.f64 b b) Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.8%
Simplified100.0%
Taylor expanded in b around inf 97.7%
unpow297.7%
unpow297.7%
Simplified97.7%
Final simplification98.8%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1000000.0) (+ (pow a 4.0) -1.0) (* (* b b) (+ (* b b) (fma 2.0 (* a a) 4.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1000000.0) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = (b * b) * ((b * b) + fma(2.0, (a * a), 4.0));
}
return tmp;
}
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 1000000.0) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64(Float64(b * b) * Float64(Float64(b * b) + fma(2.0, Float64(a * a), 4.0))); end return tmp end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 1000000.0], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + N[(2.0 * N[(a * a), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 1000000:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + \mathsf{fma}\left(2, a \cdot a, 4\right)\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1e6Initial 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 99.8%
if 1e6 < (*.f64 b b) Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.8%
Simplified100.0%
Taylor expanded in b around inf 97.7%
unpow297.7%
unpow297.7%
Simplified97.7%
metadata-eval97.7%
pow-sqr97.5%
unpow-prod-down97.5%
+-commutative97.5%
unpow297.5%
distribute-rgt-out97.5%
+-commutative97.5%
fma-def97.5%
Applied egg-rr97.5%
Final simplification98.7%
(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.8%
Final simplification99.8%
(FPCore (a b) :precision binary64 (if (<= (* a a) 1e+82) (+ (* (* b b) (+ 4.0 (* b b))) -1.0) (pow a 4.0)))
double code(double a, double b) {
double tmp;
if ((a * a) <= 1e+82) {
tmp = ((b * b) * (4.0 + (b * b))) + -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 * a) <= 1d+82) then
tmp = ((b * b) * (4.0d0 + (b * b))) + (-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 * a) <= 1e+82) {
tmp = ((b * b) * (4.0 + (b * b))) + -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (a * a) <= 1e+82: tmp = ((b * b) * (4.0 + (b * b))) + -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 1e+82) tmp = Float64(Float64(Float64(b * b) * Float64(4.0 + Float64(b * b))) + -1.0); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a * a) <= 1e+82) tmp = ((b * b) * (4.0 + (b * b))) + -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 1e+82], N[(N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 10^{+82}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if (*.f64 a a) < 9.9999999999999996e81Initial program 99.8%
Taylor expanded in a around 0 94.7%
unpow294.7%
Simplified94.7%
+-commutative94.7%
unpow294.7%
distribute-rgt-out94.7%
Applied egg-rr94.7%
if 9.9999999999999996e81 < (*.f64 a a) Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.9%
Simplified100.0%
Taylor expanded in a around inf 97.7%
Final simplification96.1%
(FPCore (a b) :precision binary64 (if (<= (* a a) 2e+47) (+ (* (* b b) (+ 4.0 (* b b))) -1.0) (* (* b b) (* (* a a) 2.0))))
double code(double a, double b) {
double tmp;
if ((a * a) <= 2e+47) {
tmp = ((b * b) * (4.0 + (b * b))) + -1.0;
} else {
tmp = (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 ((a * a) <= 2d+47) then
tmp = ((b * b) * (4.0d0 + (b * b))) + (-1.0d0)
else
tmp = (b * b) * ((a * a) * 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a * a) <= 2e+47) {
tmp = ((b * b) * (4.0 + (b * b))) + -1.0;
} else {
tmp = (b * b) * ((a * a) * 2.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (a * a) <= 2e+47: tmp = ((b * b) * (4.0 + (b * b))) + -1.0 else: tmp = (b * b) * ((a * a) * 2.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 2e+47) tmp = Float64(Float64(Float64(b * b) * Float64(4.0 + Float64(b * b))) + -1.0); else tmp = Float64(Float64(b * b) * Float64(Float64(a * a) * 2.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a * a) <= 2e+47) tmp = ((b * b) * (4.0 + (b * b))) + -1.0; else tmp = (b * b) * ((a * a) * 2.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 2e+47], N[(N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 2 \cdot 10^{+47}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(\left(a \cdot a\right) \cdot 2\right)\\
\end{array}
\end{array}
if (*.f64 a a) < 2.0000000000000001e47Initial program 99.8%
Taylor expanded in a around 0 96.7%
unpow296.7%
Simplified96.7%
+-commutative96.7%
unpow296.7%
distribute-rgt-out96.7%
Applied egg-rr96.7%
if 2.0000000000000001e47 < (*.f64 a a) Initial 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 inf 57.6%
unpow257.6%
unpow257.6%
Simplified57.6%
metadata-eval57.6%
pow-sqr57.6%
unpow-prod-down57.6%
+-commutative57.6%
unpow257.6%
distribute-rgt-out57.6%
+-commutative57.6%
fma-def57.6%
Applied egg-rr57.6%
Taylor expanded in a around inf 57.6%
unpow257.6%
Simplified57.6%
Final simplification77.0%
(FPCore (a b)
:precision binary64
(let* ((t_0 (+ (* b (* b 4.0)) -1.0)))
(if (<= b 9.5e-45)
t_0
(if (<= b 2e-9)
(* 2.0 (* (* a b) (* a b)))
(if (<= b 1.9) t_0 (* (* b b) (* b b)))))))
double code(double a, double b) {
double t_0 = (b * (b * 4.0)) + -1.0;
double tmp;
if (b <= 9.5e-45) {
tmp = t_0;
} else if (b <= 2e-9) {
tmp = 2.0 * ((a * b) * (a * b));
} else if (b <= 1.9) {
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 = (b * (b * 4.0d0)) + (-1.0d0)
if (b <= 9.5d-45) then
tmp = t_0
else if (b <= 2d-9) then
tmp = 2.0d0 * ((a * b) * (a * b))
else if (b <= 1.9d0) 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 = (b * (b * 4.0)) + -1.0;
double tmp;
if (b <= 9.5e-45) {
tmp = t_0;
} else if (b <= 2e-9) {
tmp = 2.0 * ((a * b) * (a * b));
} else if (b <= 1.9) {
tmp = t_0;
} else {
tmp = (b * b) * (b * b);
}
return tmp;
}
def code(a, b): t_0 = (b * (b * 4.0)) + -1.0 tmp = 0 if b <= 9.5e-45: tmp = t_0 elif b <= 2e-9: tmp = 2.0 * ((a * b) * (a * b)) elif b <= 1.9: tmp = t_0 else: tmp = (b * b) * (b * b) return tmp
function code(a, b) t_0 = Float64(Float64(b * Float64(b * 4.0)) + -1.0) tmp = 0.0 if (b <= 9.5e-45) tmp = t_0; elseif (b <= 2e-9) tmp = Float64(2.0 * Float64(Float64(a * b) * Float64(a * b))); elseif (b <= 1.9) tmp = t_0; else tmp = Float64(Float64(b * b) * Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) t_0 = (b * (b * 4.0)) + -1.0; tmp = 0.0; if (b <= 9.5e-45) tmp = t_0; elseif (b <= 2e-9) tmp = 2.0 * ((a * b) * (a * b)); elseif (b <= 1.9) tmp = t_0; else tmp = (b * b) * (b * b); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[b, 9.5e-45], t$95$0, If[LessEqual[b, 2e-9], N[(2.0 * N[(N[(a * b), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.9], t$95$0, N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot \left(b \cdot 4\right) + -1\\
\mathbf{if}\;b \leq 9.5 \cdot 10^{-45}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-9}:\\
\;\;\;\;2 \cdot \left(\left(a \cdot b\right) \cdot \left(a \cdot b\right)\right)\\
\mathbf{elif}\;b \leq 1.9:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if b < 9.5000000000000002e-45 or 2.00000000000000012e-9 < b < 1.8999999999999999Initial program 99.8%
Taylor expanded in a around 0 57.4%
unpow257.4%
Simplified57.4%
Taylor expanded in b around 0 46.4%
unpow246.4%
*-commutative46.4%
associate-*l*46.4%
Simplified46.4%
if 9.5000000000000002e-45 < b < 2.00000000000000012e-9Initial 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 36.6%
unpow236.6%
unpow236.6%
Simplified36.6%
metadata-eval36.6%
pow-sqr36.6%
unpow-prod-down36.6%
+-commutative36.6%
unpow236.6%
distribute-rgt-out36.6%
+-commutative36.6%
fma-def36.6%
Applied egg-rr36.6%
Taylor expanded in a around inf 36.6%
unpow236.6%
unpow236.6%
*-commutative36.6%
unswap-sqr36.6%
Simplified36.6%
if 1.8999999999999999 < b Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.8%
Simplified100.0%
Taylor expanded in b around inf 98.6%
unpow298.6%
unpow298.6%
Simplified98.6%
metadata-eval98.6%
pow-sqr98.4%
unpow-prod-down98.4%
+-commutative98.4%
unpow298.4%
distribute-rgt-out98.4%
+-commutative98.4%
fma-def98.4%
Applied egg-rr98.4%
Taylor expanded in b around inf 89.9%
unpow289.9%
Simplified89.9%
Final simplification57.7%
(FPCore (a b)
:precision binary64
(let* ((t_0 (+ (* b (* b 4.0)) -1.0)))
(if (<= b 2.1e-68)
t_0
(if (<= b 6.2e-10)
(* (* b b) (* (* a a) 2.0))
(if (<= b 1.9) t_0 (* (* b b) (* b b)))))))
double code(double a, double b) {
double t_0 = (b * (b * 4.0)) + -1.0;
double tmp;
if (b <= 2.1e-68) {
tmp = t_0;
} else if (b <= 6.2e-10) {
tmp = (b * b) * ((a * a) * 2.0);
} else if (b <= 1.9) {
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 = (b * (b * 4.0d0)) + (-1.0d0)
if (b <= 2.1d-68) then
tmp = t_0
else if (b <= 6.2d-10) then
tmp = (b * b) * ((a * a) * 2.0d0)
else if (b <= 1.9d0) 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 = (b * (b * 4.0)) + -1.0;
double tmp;
if (b <= 2.1e-68) {
tmp = t_0;
} else if (b <= 6.2e-10) {
tmp = (b * b) * ((a * a) * 2.0);
} else if (b <= 1.9) {
tmp = t_0;
} else {
tmp = (b * b) * (b * b);
}
return tmp;
}
def code(a, b): t_0 = (b * (b * 4.0)) + -1.0 tmp = 0 if b <= 2.1e-68: tmp = t_0 elif b <= 6.2e-10: tmp = (b * b) * ((a * a) * 2.0) elif b <= 1.9: tmp = t_0 else: tmp = (b * b) * (b * b) return tmp
function code(a, b) t_0 = Float64(Float64(b * Float64(b * 4.0)) + -1.0) tmp = 0.0 if (b <= 2.1e-68) tmp = t_0; elseif (b <= 6.2e-10) tmp = Float64(Float64(b * b) * Float64(Float64(a * a) * 2.0)); elseif (b <= 1.9) tmp = t_0; else tmp = Float64(Float64(b * b) * Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) t_0 = (b * (b * 4.0)) + -1.0; tmp = 0.0; if (b <= 2.1e-68) tmp = t_0; elseif (b <= 6.2e-10) tmp = (b * b) * ((a * a) * 2.0); elseif (b <= 1.9) tmp = t_0; else tmp = (b * b) * (b * b); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[b, 2.1e-68], t$95$0, If[LessEqual[b, 6.2e-10], N[(N[(b * b), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.9], t$95$0, N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot \left(b \cdot 4\right) + -1\\
\mathbf{if}\;b \leq 2.1 \cdot 10^{-68}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-10}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(\left(a \cdot a\right) \cdot 2\right)\\
\mathbf{elif}\;b \leq 1.9:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if b < 2.10000000000000008e-68 or 6.2000000000000003e-10 < b < 1.8999999999999999Initial program 99.8%
Taylor expanded in a around 0 58.3%
unpow258.3%
Simplified58.3%
Taylor expanded in b around 0 46.8%
unpow246.8%
*-commutative46.8%
associate-*l*46.8%
Simplified46.8%
if 2.10000000000000008e-68 < b < 6.2000000000000003e-10Initial 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 inf 47.3%
unpow247.3%
unpow247.3%
Simplified47.3%
metadata-eval47.3%
pow-sqr47.3%
unpow-prod-down47.3%
+-commutative47.3%
unpow247.3%
distribute-rgt-out47.3%
+-commutative47.3%
fma-def47.3%
Applied egg-rr47.3%
Taylor expanded in a around inf 47.5%
unpow247.5%
Simplified47.5%
if 1.8999999999999999 < b Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.8%
Simplified100.0%
Taylor expanded in b around inf 98.6%
unpow298.6%
unpow298.6%
Simplified98.6%
metadata-eval98.6%
pow-sqr98.4%
unpow-prod-down98.4%
+-commutative98.4%
unpow298.4%
distribute-rgt-out98.4%
+-commutative98.4%
fma-def98.4%
Applied egg-rr98.4%
Taylor expanded in b around inf 89.9%
unpow289.9%
Simplified89.9%
Final simplification58.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e-14) (+ (* b (* b 4.0)) -1.0) (* (* b b) (* b b))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e-14) {
tmp = (b * (b * 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) <= 2d-14) then
tmp = (b * (b * 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) <= 2e-14) {
tmp = (b * (b * 4.0)) + -1.0;
} else {
tmp = (b * b) * (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e-14: tmp = (b * (b * 4.0)) + -1.0 else: tmp = (b * b) * (b * b) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e-14) tmp = Float64(Float64(b * Float64(b * 4.0)) + -1.0); else tmp = Float64(Float64(b * b) * Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e-14) tmp = (b * (b * 4.0)) + -1.0; else tmp = (b * b) * (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e-14], N[(N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{-14}:\\
\;\;\;\;b \cdot \left(b \cdot 4\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 2e-14Initial program 99.8%
Taylor expanded in a around 0 43.7%
unpow243.7%
Simplified43.7%
Taylor expanded in b around 0 43.7%
unpow243.7%
*-commutative43.7%
associate-*l*43.7%
Simplified43.7%
if 2e-14 < (*.f64 b b) Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.8%
Simplified100.0%
Taylor expanded in b around inf 96.2%
unpow296.2%
unpow296.2%
Simplified96.2%
metadata-eval96.2%
pow-sqr96.1%
unpow-prod-down96.1%
+-commutative96.1%
unpow296.1%
distribute-rgt-out96.1%
+-commutative96.1%
fma-def96.1%
Applied egg-rr96.1%
Taylor expanded in b around inf 88.6%
unpow288.6%
Simplified88.6%
Final simplification65.1%
(FPCore (a b) :precision binary64 (* (* b b) (* b b)))
double code(double a, double b) {
return (b * b) * (b * b);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (b * b) * (b * b)
end function
public static double code(double a, double b) {
return (b * b) * (b * b);
}
def code(a, b): return (b * b) * (b * b)
function code(a, b) return Float64(Float64(b * b) * Float64(b * b)) end
function tmp = code(a, b) tmp = (b * b) * (b * b); end
code[a_, b_] := N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(b \cdot b\right) \cdot \left(b \cdot b\right)
\end{array}
Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.8%
Simplified100.0%
Taylor expanded in b around inf 55.1%
unpow255.1%
unpow255.1%
Simplified55.1%
metadata-eval55.1%
pow-sqr55.0%
unpow-prod-down55.0%
+-commutative55.0%
unpow255.0%
distribute-rgt-out55.0%
+-commutative55.0%
fma-def55.0%
Applied egg-rr55.0%
Taylor expanded in b around inf 43.5%
unpow243.5%
Simplified43.5%
Final simplification43.5%
(FPCore (a b) :precision binary64 (* 4.0 (* b b)))
double code(double a, double b) {
return 4.0 * (b * b);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 4.0d0 * (b * b)
end function
public static double code(double a, double b) {
return 4.0 * (b * b);
}
def code(a, b): return 4.0 * (b * b)
function code(a, b) return Float64(4.0 * Float64(b * b)) end
function tmp = code(a, b) tmp = 4.0 * (b * b); end
code[a_, b_] := N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot \left(b \cdot b\right)
\end{array}
Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*r*99.8%
Simplified100.0%
Taylor expanded in b around inf 55.1%
unpow255.1%
unpow255.1%
Simplified55.1%
metadata-eval55.1%
pow-sqr55.0%
unpow-prod-down55.0%
+-commutative55.0%
unpow255.0%
distribute-rgt-out55.0%
+-commutative55.0%
fma-def55.0%
Applied egg-rr55.0%
Taylor expanded in a around 0 43.7%
unpow243.7%
+-commutative43.7%
fma-udef43.7%
Simplified43.7%
Taylor expanded in b around 0 24.7%
unpow224.7%
Simplified24.7%
Final simplification24.7%
herbie shell --seed 2023222
(FPCore (a b)
:name "Bouland and Aaronson, Equation (26)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))