
(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.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
Simplified100.0%
Final simplification100.0%
(FPCore (a b) :precision binary64 (+ (pow (fma a a (* b b)) 2.0) (+ (* 4.0 (* b b)) -1.0)))
double code(double a, double b) {
return pow(fma(a, a, (b * b)), 2.0) + ((4.0 * (b * b)) + -1.0);
}
function code(a, b) return Float64((fma(a, a, Float64(b * b)) ^ 2.0) + Float64(Float64(4.0 * Float64(b * b)) + -1.0)) end
code[a_, b_] := N[(N[Power[N[(a * a + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \left(4 \cdot \left(b \cdot b\right) + -1\right)
\end{array}
Initial program 99.9%
associate--l+99.9%
fma-def99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (a b) :precision binary64 (+ (+ (pow (+ (* b b) (* a a)) 2.0) (* 4.0 (* b b))) -1.0))
double code(double a, double b) {
return (pow(((b * b) + (a * a)), 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 = ((((b * b) + (a * a)) ** 2.0d0) + (4.0d0 * (b * b))) + (-1.0d0)
end function
public static double code(double a, double b) {
return (Math.pow(((b * b) + (a * a)), 2.0) + (4.0 * (b * b))) + -1.0;
}
def code(a, b): return (math.pow(((b * b) + (a * a)), 2.0) + (4.0 * (b * b))) + -1.0
function code(a, b) return Float64(Float64((Float64(Float64(b * b) + Float64(a * a)) ^ 2.0) + Float64(4.0 * Float64(b * b))) + -1.0) end
function tmp = code(a, b) tmp = ((((b * b) + (a * a)) ^ 2.0) + (4.0 * (b * b))) + -1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(b * b), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(b \cdot b + a \cdot a\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 (<= (* a a) 5e-18) (+ (+ (* 4.0 (* b b)) (pow b 4.0)) -1.0) (+ (* (* a a) (+ (* a a) (* b (* b 2.0)))) -1.0)))
double code(double a, double b) {
double tmp;
if ((a * a) <= 5e-18) {
tmp = ((4.0 * (b * b)) + pow(b, 4.0)) + -1.0;
} else {
tmp = ((a * a) * ((a * a) + (b * (b * 2.0)))) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a * a) <= 5d-18) then
tmp = ((4.0d0 * (b * b)) + (b ** 4.0d0)) + (-1.0d0)
else
tmp = ((a * a) * ((a * a) + (b * (b * 2.0d0)))) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a * a) <= 5e-18) {
tmp = ((4.0 * (b * b)) + Math.pow(b, 4.0)) + -1.0;
} else {
tmp = ((a * a) * ((a * a) + (b * (b * 2.0)))) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a * a) <= 5e-18: tmp = ((4.0 * (b * b)) + math.pow(b, 4.0)) + -1.0 else: tmp = ((a * a) * ((a * a) + (b * (b * 2.0)))) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 5e-18) tmp = Float64(Float64(Float64(4.0 * Float64(b * b)) + (b ^ 4.0)) + -1.0); else tmp = Float64(Float64(Float64(a * a) * Float64(Float64(a * a) + Float64(b * Float64(b * 2.0)))) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a * a) <= 5e-18) tmp = ((4.0 * (b * b)) + (b ^ 4.0)) + -1.0; else tmp = ((a * a) * ((a * a) + (b * (b * 2.0)))) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 5e-18], N[(N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + N[(b * N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 5 \cdot 10^{-18}:\\
\;\;\;\;\left(4 \cdot \left(b \cdot b\right) + {b}^{4}\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a + b \cdot \left(b \cdot 2\right)\right) + -1\\
\end{array}
\end{array}
if (*.f64 a a) < 5.00000000000000036e-18Initial program 100.0%
associate--l+100.0%
fma-def100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
associate-+r-100.0%
unpow-prod-down100.0%
pow-prod-up100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if 5.00000000000000036e-18 < (*.f64 a a) Initial program 99.8%
Taylor expanded in b around 0 87.6%
unpow287.6%
unpow287.6%
Simplified87.6%
Taylor expanded in a around inf 87.6%
*-commutative87.6%
unpow287.6%
unpow287.6%
*-commutative87.6%
associate-*r*87.6%
*-commutative87.6%
Simplified87.6%
+-commutative87.6%
associate-*r*87.6%
metadata-eval87.6%
pow-sqr87.4%
pow287.4%
pow287.4%
distribute-rgt-out95.7%
associate-*l*95.7%
add-sqr-sqrt46.0%
sqrt-prod83.2%
metadata-eval83.2%
sqrt-prod83.2%
*-commutative83.2%
sqrt-prod83.2%
metadata-eval83.2%
sqrt-prod46.0%
add-sqr-sqrt95.7%
Applied egg-rr95.7%
Final simplification97.7%
(FPCore (a b)
:precision binary64
(if (<= (* a a) 4.7e-123)
-1.0
(if (<= (* a a) 2.1e-55)
(* 4.0 (* b b))
(if (<= (* a a) 1.0) -1.0 (* (* a a) (* a a))))))
double code(double a, double b) {
double tmp;
if ((a * a) <= 4.7e-123) {
tmp = -1.0;
} else if ((a * a) <= 2.1e-55) {
tmp = 4.0 * (b * b);
} else if ((a * a) <= 1.0) {
tmp = -1.0;
} else {
tmp = (a * a) * (a * a);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a * a) <= 4.7d-123) then
tmp = -1.0d0
else if ((a * a) <= 2.1d-55) then
tmp = 4.0d0 * (b * b)
else if ((a * a) <= 1.0d0) then
tmp = -1.0d0
else
tmp = (a * a) * (a * a)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a * a) <= 4.7e-123) {
tmp = -1.0;
} else if ((a * a) <= 2.1e-55) {
tmp = 4.0 * (b * b);
} else if ((a * a) <= 1.0) {
tmp = -1.0;
} else {
tmp = (a * a) * (a * a);
}
return tmp;
}
def code(a, b): tmp = 0 if (a * a) <= 4.7e-123: tmp = -1.0 elif (a * a) <= 2.1e-55: tmp = 4.0 * (b * b) elif (a * a) <= 1.0: tmp = -1.0 else: tmp = (a * a) * (a * a) return tmp
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 4.7e-123) tmp = -1.0; elseif (Float64(a * a) <= 2.1e-55) tmp = Float64(4.0 * Float64(b * b)); elseif (Float64(a * a) <= 1.0) tmp = -1.0; else tmp = Float64(Float64(a * a) * Float64(a * a)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a * a) <= 4.7e-123) tmp = -1.0; elseif ((a * a) <= 2.1e-55) tmp = 4.0 * (b * b); elseif ((a * a) <= 1.0) tmp = -1.0; else tmp = (a * a) * (a * a); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 4.7e-123], -1.0, If[LessEqual[N[(a * a), $MachinePrecision], 2.1e-55], N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * a), $MachinePrecision], 1.0], -1.0, N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 4.7 \cdot 10^{-123}:\\
\;\;\;\;-1\\
\mathbf{elif}\;a \cdot a \leq 2.1 \cdot 10^{-55}:\\
\;\;\;\;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\right)\\
\end{array}
\end{array}
if (*.f64 a a) < 4.7000000000000002e-123 or 2.1000000000000002e-55 < (*.f64 a a) < 1Initial program 100.0%
associate--l+100.0%
fma-def100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around 0 99.6%
unpow299.6%
Simplified99.6%
Taylor expanded in b around 0 57.1%
if 4.7000000000000002e-123 < (*.f64 a a) < 2.1000000000000002e-55Initial program 100.0%
associate--l+100.0%
unpow2100.0%
unpow1100.0%
sqr-pow100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in a around inf 83.8%
Taylor expanded in b around inf 63.5%
unpow263.5%
Simplified63.5%
if 1 < (*.f64 a a) Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*l*99.8%
fma-def99.8%
Simplified99.9%
Taylor expanded in a around inf 52.7%
Taylor expanded in a around inf 86.9%
metadata-eval86.9%
pow-prod-up86.8%
pow286.8%
pow286.8%
Applied egg-rr86.8%
Final simplification72.6%
(FPCore (a b) :precision binary64 (if (<= (* a a) 5e-18) (+ (* (* b b) (+ 4.0 (* b b))) -1.0) (+ (* (* a a) (+ (* a a) (* b (* b 2.0)))) -1.0)))
double code(double a, double b) {
double tmp;
if ((a * a) <= 5e-18) {
tmp = ((b * b) * (4.0 + (b * b))) + -1.0;
} else {
tmp = ((a * a) * ((a * a) + (b * (b * 2.0)))) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a * a) <= 5d-18) then
tmp = ((b * b) * (4.0d0 + (b * b))) + (-1.0d0)
else
tmp = ((a * a) * ((a * a) + (b * (b * 2.0d0)))) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a * a) <= 5e-18) {
tmp = ((b * b) * (4.0 + (b * b))) + -1.0;
} else {
tmp = ((a * a) * ((a * a) + (b * (b * 2.0)))) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a * a) <= 5e-18: tmp = ((b * b) * (4.0 + (b * b))) + -1.0 else: tmp = ((a * a) * ((a * a) + (b * (b * 2.0)))) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 5e-18) tmp = Float64(Float64(Float64(b * b) * Float64(4.0 + Float64(b * b))) + -1.0); else tmp = Float64(Float64(Float64(a * a) * Float64(Float64(a * a) + Float64(b * Float64(b * 2.0)))) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a * a) <= 5e-18) tmp = ((b * b) * (4.0 + (b * b))) + -1.0; else tmp = ((a * a) * ((a * a) + (b * (b * 2.0)))) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 5e-18], N[(N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(a * a), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] + N[(b * N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 5 \cdot 10^{-18}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a + b \cdot \left(b \cdot 2\right)\right) + -1\\
\end{array}
\end{array}
if (*.f64 a a) < 5.00000000000000036e-18Initial program 100.0%
associate--l+100.0%
fma-def100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
associate-+r-100.0%
unpow-prod-down100.0%
pow-prod-up100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-commutative100.0%
metadata-eval100.0%
pow-prod-up100.0%
pow2100.0%
pow2100.0%
distribute-lft-out100.0%
Applied egg-rr100.0%
if 5.00000000000000036e-18 < (*.f64 a a) Initial program 99.8%
Taylor expanded in b around 0 87.6%
unpow287.6%
unpow287.6%
Simplified87.6%
Taylor expanded in a around inf 87.6%
*-commutative87.6%
unpow287.6%
unpow287.6%
*-commutative87.6%
associate-*r*87.6%
*-commutative87.6%
Simplified87.6%
+-commutative87.6%
associate-*r*87.6%
metadata-eval87.6%
pow-sqr87.4%
pow287.4%
pow287.4%
distribute-rgt-out95.7%
associate-*l*95.7%
add-sqr-sqrt46.0%
sqrt-prod83.2%
metadata-eval83.2%
sqrt-prod83.2%
*-commutative83.2%
sqrt-prod83.2%
metadata-eval83.2%
sqrt-prod46.0%
add-sqr-sqrt95.7%
Applied egg-rr95.7%
Final simplification97.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 6.6e+20) (+ (* (* a a) (* a a)) -1.0) (+ (* (* b b) (+ 4.0 (* b b))) -1.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 6.6e+20) {
tmp = ((a * a) * (a * a)) + -1.0;
} else {
tmp = ((b * b) * (4.0 + (b * b))) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 6.6d+20) then
tmp = ((a * a) * (a * a)) + (-1.0d0)
else
tmp = ((b * b) * (4.0d0 + (b * b))) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 6.6e+20) {
tmp = ((a * a) * (a * a)) + -1.0;
} else {
tmp = ((b * b) * (4.0 + (b * b))) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 6.6e+20: tmp = ((a * a) * (a * a)) + -1.0 else: tmp = ((b * b) * (4.0 + (b * b))) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 6.6e+20) tmp = Float64(Float64(Float64(a * a) * Float64(a * a)) + -1.0); else tmp = Float64(Float64(Float64(b * b) * Float64(4.0 + Float64(b * b))) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 6.6e+20) tmp = ((a * a) * (a * a)) + -1.0; else tmp = ((b * b) * (4.0 + (b * b))) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 6.6e+20], N[(N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 6.6 \cdot 10^{+20}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) + -1\\
\end{array}
\end{array}
if (*.f64 b b) < 6.6e20Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*l*99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in b around 0 98.6%
metadata-eval48.7%
pow-prod-up48.6%
pow248.6%
pow248.6%
Applied egg-rr98.4%
if 6.6e20 < (*.f64 b b) Initial program 100.0%
associate--l+100.0%
fma-def100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in a around 0 91.8%
unpow291.8%
Simplified91.8%
associate-+r-91.8%
unpow-prod-down91.8%
pow-prod-up91.8%
metadata-eval91.8%
Applied egg-rr91.8%
+-commutative91.8%
metadata-eval91.8%
pow-prod-up91.8%
pow291.8%
pow291.8%
distribute-lft-out91.8%
Applied egg-rr91.8%
Final simplification95.2%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2.6e+306) (+ (* (* a a) (* a a)) -1.0) (* 4.0 (* b b))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2.6e+306) {
tmp = ((a * a) * (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) <= 2.6d+306) then
tmp = ((a * a) * (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) <= 2.6e+306) {
tmp = ((a * a) * (a * a)) + -1.0;
} else {
tmp = 4.0 * (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2.6e+306: tmp = ((a * a) * (a * a)) + -1.0 else: tmp = 4.0 * (b * b) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2.6e+306) tmp = Float64(Float64(Float64(a * a) * 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) <= 2.6e+306) tmp = ((a * a) * (a * a)) + -1.0; else tmp = 4.0 * (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2.6e+306], N[(N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2.6 \cdot 10^{+306}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right) + -1\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 2.60000000000000008e306Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*l*99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in b around 0 82.1%
metadata-eval47.2%
pow-prod-up47.1%
pow247.1%
pow247.1%
Applied egg-rr82.0%
if 2.60000000000000008e306 < (*.f64 b b) Initial program 100.0%
associate--l+100.0%
unpow2100.0%
unpow1100.0%
sqr-pow100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in a around inf 81.4%
Taylor expanded in b around inf 100.0%
unpow2100.0%
Simplified100.0%
Final simplification86.9%
(FPCore (a b) :precision binary64 (if (<= (* a a) 53.0) (+ (* 4.0 (* b b)) -1.0) (* (* a a) (* a a))))
double code(double a, double b) {
double tmp;
if ((a * a) <= 53.0) {
tmp = (4.0 * (b * b)) + -1.0;
} else {
tmp = (a * a) * (a * a);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a * a) <= 53.0d0) then
tmp = (4.0d0 * (b * b)) + (-1.0d0)
else
tmp = (a * a) * (a * a)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a * a) <= 53.0) {
tmp = (4.0 * (b * b)) + -1.0;
} else {
tmp = (a * a) * (a * a);
}
return tmp;
}
def code(a, b): tmp = 0 if (a * a) <= 53.0: tmp = (4.0 * (b * b)) + -1.0 else: tmp = (a * a) * (a * a) return tmp
function code(a, b) tmp = 0.0 if (Float64(a * a) <= 53.0) tmp = Float64(Float64(4.0 * Float64(b * b)) + -1.0); else tmp = Float64(Float64(a * a) * Float64(a * a)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a * a) <= 53.0) tmp = (4.0 * (b * b)) + -1.0; else tmp = (a * a) * (a * a); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(a * a), $MachinePrecision], 53.0], N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot a \leq 53:\\
\;\;\;\;4 \cdot \left(b \cdot b\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\
\end{array}
\end{array}
if (*.f64 a a) < 53Initial program 100.0%
Taylor expanded in b around 0 80.6%
unpow280.6%
unpow280.6%
Simplified80.6%
metadata-eval2.4%
pow-prod-up2.4%
pow22.4%
pow22.4%
Applied egg-rr80.6%
Taylor expanded in a around 0 80.3%
unpow280.3%
Simplified80.3%
if 53 < (*.f64 a a) Initial program 99.8%
associate--l+99.8%
unpow299.8%
unpow199.8%
sqr-pow99.8%
associate-*l*99.8%
fma-def99.8%
Simplified99.9%
Taylor expanded in a around inf 52.7%
Taylor expanded in a around inf 86.9%
metadata-eval86.9%
pow-prod-up86.8%
pow286.8%
pow286.8%
Applied egg-rr86.8%
Final simplification83.6%
(FPCore (a b) :precision binary64 (if (<= b 0.49) -1.0 (* 4.0 (* b b))))
double code(double a, double b) {
double tmp;
if (b <= 0.49) {
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 <= 0.49d0) 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 <= 0.49) {
tmp = -1.0;
} else {
tmp = 4.0 * (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 0.49: tmp = -1.0 else: tmp = 4.0 * (b * b) return tmp
function code(a, b) tmp = 0.0 if (b <= 0.49) 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 <= 0.49) tmp = -1.0; else tmp = 4.0 * (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 0.49], -1.0, N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.49:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if b < 0.48999999999999999Initial program 99.8%
associate--l+99.8%
fma-def99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in a around 0 66.2%
unpow266.2%
Simplified66.2%
Taylor expanded in b around 0 34.0%
if 0.48999999999999999 < b Initial program 100.0%
associate--l+100.0%
unpow2100.0%
unpow1100.0%
sqr-pow100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in a around inf 55.3%
Taylor expanded in b around inf 65.0%
unpow265.0%
Simplified65.0%
Final simplification41.2%
(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%
fma-def99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in a around 0 71.5%
unpow271.5%
Simplified71.5%
Taylor expanded in b around 0 26.3%
Final simplification26.3%
herbie shell --seed 2023192
(FPCore (a b)
:name "Bouland and Aaronson, Equation (26)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))