
(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 9 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 (if (<= a 1e+77) (+ (+ (pow (sqrt (hypot a b)) 8.0) (* 4.0 (* a (* a (- 1.0 a))))) -1.0) (+ -1.0 (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= 1e+77) {
tmp = (pow(sqrt(hypot(a, b)), 8.0) + (4.0 * (a * (a * (1.0 - a))))) + -1.0;
} else {
tmp = -1.0 + pow(a, 4.0);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= 1e+77) {
tmp = (Math.pow(Math.sqrt(Math.hypot(a, b)), 8.0) + (4.0 * (a * (a * (1.0 - a))))) + -1.0;
} else {
tmp = -1.0 + Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 1e+77: tmp = (math.pow(math.sqrt(math.hypot(a, b)), 8.0) + (4.0 * (a * (a * (1.0 - a))))) + -1.0 else: tmp = -1.0 + math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= 1e+77) tmp = Float64(Float64((sqrt(hypot(a, b)) ^ 8.0) + Float64(4.0 * Float64(a * Float64(a * Float64(1.0 - a))))) + -1.0); else tmp = Float64(-1.0 + (a ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 1e+77) tmp = ((sqrt(hypot(a, b)) ^ 8.0) + (4.0 * (a * (a * (1.0 - a))))) + -1.0; else tmp = -1.0 + (a ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 1e+77], N[(N[(N[Power[N[Sqrt[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision]], $MachinePrecision], 8.0], $MachinePrecision] + N[(4.0 * N[(a * N[(a * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 10^{+77}:\\
\;\;\;\;\left({\left(\sqrt{\mathsf{hypot}\left(a, b\right)}\right)}^{8} + 4 \cdot \left(a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{4}\\
\end{array}
\end{array}
if a < 9.99999999999999983e76Initial program 83.5%
sub-neg83.5%
fma-def83.5%
fma-def83.5%
+-commutative83.5%
metadata-eval83.5%
Simplified83.5%
fma-def83.5%
metadata-eval83.5%
sqrt-pow283.6%
hypot-udef83.6%
add-sqr-sqrt83.4%
unpow-prod-down83.3%
Applied egg-rr83.3%
pow-sqr83.3%
metadata-eval83.3%
Simplified83.3%
Taylor expanded in b around 0 98.7%
unpow298.7%
associate-*r*98.7%
Simplified98.7%
if 9.99999999999999983e76 < a Initial program 11.1%
sub-neg11.1%
fma-def11.1%
fma-def19.4%
+-commutative19.4%
metadata-eval19.4%
Simplified19.4%
Taylor expanded in a around inf 100.0%
Final simplification98.8%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (- 1.0 a) (* a a)) (* (* b b) (+ a 3.0)))))))
(if (<= t_0 INFINITY) (+ -1.0 t_0) (+ -1.0 (pow a 4.0)))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((1.0 - a) * (a * a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = -1.0 + t_0;
} else {
tmp = -1.0 + pow(a, 4.0);
}
return tmp;
}
public static double code(double a, double b) {
double t_0 = Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((1.0 - a) * (a * a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = -1.0 + t_0;
} else {
tmp = -1.0 + Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((1.0 - a) * (a * a)) + ((b * b) * (a + 3.0)))) tmp = 0 if t_0 <= math.inf: tmp = -1.0 + t_0 else: tmp = -1.0 + math.pow(a, 4.0) return tmp
function code(a, b) t_0 = Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(1.0 - a) * Float64(a * a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(-1.0 + t_0); else tmp = Float64(-1.0 + (a ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((1.0 - a) * (a * a)) + ((b * b) * (a + 3.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = -1.0 + t_0; else tmp = -1.0 + (a ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(1.0 - a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(-1.0 + t$95$0), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(1 - a\right) \cdot \left(a \cdot a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;-1 + t_0\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{4}\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) < +inf.0Initial program 99.9%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (-.f64 1 a)) (*.f64 (*.f64 b b) (+.f64 3 a))))) Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def4.4%
+-commutative4.4%
metadata-eval4.4%
Simplified4.4%
Taylor expanded in a around inf 94.5%
Final simplification98.4%
(FPCore (a b) :precision binary64 (if (<= b 0.00135) (+ -1.0 (pow a 4.0)) (+ -1.0 (+ (pow b 4.0) (* (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if (b <= 0.00135) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + (pow(b, 4.0) + ((b * b) * 12.0));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 0.00135d0) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + ((b ** 4.0d0) + ((b * b) * 12.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 0.00135) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + (Math.pow(b, 4.0) + ((b * b) * 12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 0.00135: tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + (math.pow(b, 4.0) + ((b * b) * 12.0)) return tmp
function code(a, b) tmp = 0.0 if (b <= 0.00135) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64((b ^ 4.0) + Float64(Float64(b * b) * 12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 0.00135) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + ((b ^ 4.0) + ((b * b) * 12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 0.00135], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.00135:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot 12\right)\\
\end{array}
\end{array}
if b < 0.0013500000000000001Initial program 78.6%
sub-neg78.6%
fma-def78.6%
fma-def79.1%
+-commutative79.1%
metadata-eval79.1%
Simplified79.1%
Taylor expanded in a around inf 81.9%
if 0.0013500000000000001 < b Initial program 55.9%
sub-neg55.9%
fma-def55.9%
fma-def59.3%
+-commutative59.3%
metadata-eval59.3%
Simplified59.3%
Taylor expanded in a around 0 57.6%
associate-+r+57.6%
associate-*r*57.6%
distribute-rgt-out67.8%
metadata-eval67.8%
distribute-lft-in67.8%
+-commutative67.8%
unpow267.8%
distribute-lft-in67.8%
metadata-eval67.8%
Simplified67.8%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
Final simplification86.1%
(FPCore (a b)
:precision binary64
(if (or (<= a -3.0) (not (<= a 14000.0)))
(+ -1.0 (pow a 4.0))
(+
-1.0
(* 4.0 (/ 1.0 (/ (* b (+ a -3.0)) (* b (* (* b b) (- (* a a) 9.0)))))))))
double code(double a, double b) {
double tmp;
if ((a <= -3.0) || !(a <= 14000.0)) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + (4.0 * (1.0 / ((b * (a + -3.0)) / (b * ((b * b) * ((a * a) - 9.0))))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-3.0d0)) .or. (.not. (a <= 14000.0d0))) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + (4.0d0 * (1.0d0 / ((b * (a + (-3.0d0))) / (b * ((b * b) * ((a * a) - 9.0d0))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -3.0) || !(a <= 14000.0)) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + (4.0 * (1.0 / ((b * (a + -3.0)) / (b * ((b * b) * ((a * a) - 9.0))))));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -3.0) or not (a <= 14000.0): tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + (4.0 * (1.0 / ((b * (a + -3.0)) / (b * ((b * b) * ((a * a) - 9.0)))))) return tmp
function code(a, b) tmp = 0.0 if ((a <= -3.0) || !(a <= 14000.0)) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64(4.0 * Float64(1.0 / Float64(Float64(b * Float64(a + -3.0)) / Float64(b * Float64(Float64(b * b) * Float64(Float64(a * a) - 9.0))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -3.0) || ~((a <= 14000.0))) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + (4.0 * (1.0 / ((b * (a + -3.0)) / (b * ((b * b) * ((a * a) - 9.0)))))); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -3.0], N[Not[LessEqual[a, 14000.0]], $MachinePrecision]], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(4.0 * N[(1.0 / N[(N[(b * N[(a + -3.0), $MachinePrecision]), $MachinePrecision] / N[(b * N[(N[(b * b), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] - 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3 \lor \neg \left(a \leq 14000\right):\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + 4 \cdot \frac{1}{\frac{b \cdot \left(a + -3\right)}{b \cdot \left(\left(b \cdot b\right) \cdot \left(a \cdot a - 9\right)\right)}}\\
\end{array}
\end{array}
if a < -3 or 14000 < a Initial program 49.1%
sub-neg49.1%
fma-def49.1%
fma-def51.3%
+-commutative51.3%
metadata-eval51.3%
Simplified51.3%
Taylor expanded in a around inf 86.8%
if -3 < a < 14000Initial program 99.9%
sub-neg99.9%
fma-def99.9%
fma-def99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
fma-def99.9%
metadata-eval99.9%
sqrt-pow2100.0%
hypot-udef100.0%
add-sqr-sqrt99.8%
unpow-prod-down99.8%
Applied egg-rr99.8%
pow-sqr99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in b around inf 78.2%
+-commutative78.2%
unpow278.2%
associate-*l*78.2%
Simplified78.2%
distribute-lft-in78.2%
flip-+75.0%
*-commutative75.0%
*-commutative75.0%
*-commutative75.0%
Applied egg-rr75.0%
swap-sqr60.2%
associate-*r*60.2%
*-commutative60.2%
associate-*l*68.4%
swap-sqr68.4%
metadata-eval68.4%
*-commutative68.4%
Simplified68.4%
associate-*r*75.0%
*-commutative75.0%
metadata-eval75.0%
swap-sqr75.0%
*-commutative75.0%
associate-*r/84.0%
Applied egg-rr87.2%
Final simplification87.0%
(FPCore (a b) :precision binary64 (if (<= b 0.00135) (+ -1.0 (pow a 4.0)) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 0.00135) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + pow(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 <= 0.00135d0) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + (b ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 0.00135) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 0.00135: tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 0.00135) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + (b ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 0.00135) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 0.00135], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.00135:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if b < 0.0013500000000000001Initial program 78.6%
sub-neg78.6%
fma-def78.6%
fma-def79.1%
+-commutative79.1%
metadata-eval79.1%
Simplified79.1%
Taylor expanded in a around inf 81.9%
if 0.0013500000000000001 < b Initial program 55.9%
sub-neg55.9%
fma-def55.9%
fma-def59.3%
+-commutative59.3%
metadata-eval59.3%
Simplified59.3%
Taylor expanded in b around inf 98.1%
Final simplification85.7%
(FPCore (a b)
:precision binary64
(if (<= (* b b) 2e+87)
(+ -1.0 (* 4.0 (* a a)))
(if (<= (* b b) 5e+301)
(+ -1.0 (* 4.0 (/ (/ (* b (* (* b b) (- (* a a) 9.0))) b) (+ a -3.0))))
(+ -1.0 (* (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+87) {
tmp = -1.0 + (4.0 * (a * a));
} else if ((b * b) <= 5e+301) {
tmp = -1.0 + (4.0 * (((b * ((b * b) * ((a * a) - 9.0))) / b) / (a + -3.0)));
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2d+87) then
tmp = (-1.0d0) + (4.0d0 * (a * a))
else if ((b * b) <= 5d+301) then
tmp = (-1.0d0) + (4.0d0 * (((b * ((b * b) * ((a * a) - 9.0d0))) / b) / (a + (-3.0d0))))
else
tmp = (-1.0d0) + ((b * b) * 12.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+87) {
tmp = -1.0 + (4.0 * (a * a));
} else if ((b * b) <= 5e+301) {
tmp = -1.0 + (4.0 * (((b * ((b * b) * ((a * a) - 9.0))) / b) / (a + -3.0)));
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+87: tmp = -1.0 + (4.0 * (a * a)) elif (b * b) <= 5e+301: tmp = -1.0 + (4.0 * (((b * ((b * b) * ((a * a) - 9.0))) / b) / (a + -3.0))) else: tmp = -1.0 + ((b * b) * 12.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+87) tmp = Float64(-1.0 + Float64(4.0 * Float64(a * a))); elseif (Float64(b * b) <= 5e+301) tmp = Float64(-1.0 + Float64(4.0 * Float64(Float64(Float64(b * Float64(Float64(b * b) * Float64(Float64(a * a) - 9.0))) / b) / Float64(a + -3.0)))); else tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+87) tmp = -1.0 + (4.0 * (a * a)); elseif ((b * b) <= 5e+301) tmp = -1.0 + (4.0 * (((b * ((b * b) * ((a * a) - 9.0))) / b) / (a + -3.0))); else tmp = -1.0 + ((b * b) * 12.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+87], N[(-1.0 + N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(b * b), $MachinePrecision], 5e+301], N[(-1.0 + N[(4.0 * N[(N[(N[(b * N[(N[(b * b), $MachinePrecision] * N[(N[(a * a), $MachinePrecision] - 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision] / N[(a + -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+87}:\\
\;\;\;\;-1 + 4 \cdot \left(a \cdot a\right)\\
\mathbf{elif}\;b \cdot b \leq 5 \cdot 10^{+301}:\\
\;\;\;\;-1 + 4 \cdot \frac{\frac{b \cdot \left(\left(b \cdot b\right) \cdot \left(a \cdot a - 9\right)\right)}{b}}{a + -3}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\end{array}
\end{array}
if (*.f64 b b) < 1.9999999999999999e87Initial program 86.8%
sub-neg86.8%
fma-def86.8%
fma-def86.8%
+-commutative86.8%
metadata-eval86.8%
Simplified86.8%
Taylor expanded in b around 0 80.8%
associate-*r*80.8%
unpow280.8%
Simplified80.8%
Taylor expanded in a around 0 70.9%
unpow270.9%
Simplified70.9%
if 1.9999999999999999e87 < (*.f64 b b) < 5.0000000000000004e301Initial program 78.7%
sub-neg78.7%
fma-def78.7%
fma-def78.7%
+-commutative78.7%
metadata-eval78.7%
Simplified78.7%
fma-def78.7%
metadata-eval78.7%
sqrt-pow278.8%
hypot-udef78.8%
add-sqr-sqrt78.6%
unpow-prod-down78.6%
Applied egg-rr78.6%
pow-sqr78.5%
metadata-eval78.5%
Simplified78.5%
Taylor expanded in b around inf 7.8%
+-commutative7.8%
unpow27.8%
associate-*l*7.8%
Simplified7.8%
distribute-lft-in7.8%
flip-+4.8%
*-commutative4.8%
*-commutative4.8%
*-commutative4.8%
Applied egg-rr4.8%
swap-sqr4.8%
associate-*r*4.8%
*-commutative4.8%
associate-*l*4.8%
swap-sqr4.8%
metadata-eval4.8%
*-commutative4.8%
Simplified4.8%
associate-*r*4.8%
*-commutative4.8%
metadata-eval4.8%
swap-sqr4.8%
*-commutative4.8%
associate-*r/40.8%
Applied egg-rr43.9%
if 5.0000000000000004e301 < (*.f64 b b) Initial program 41.4%
sub-neg41.4%
fma-def41.4%
fma-def45.7%
+-commutative45.7%
metadata-eval45.7%
Simplified45.7%
fma-def45.7%
metadata-eval45.7%
sqrt-pow245.7%
hypot-udef45.7%
add-sqr-sqrt45.7%
unpow-prod-down45.7%
Applied egg-rr45.7%
pow-sqr45.7%
metadata-eval45.7%
Simplified45.7%
Taylor expanded in b around inf 57.1%
+-commutative57.1%
unpow257.1%
associate-*l*57.1%
Simplified57.1%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
Final simplification75.4%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+274) (+ -1.0 (* 4.0 (* a a))) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+274) {
tmp = -1.0 + (4.0 * (a * a));
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 5d+274) then
tmp = (-1.0d0) + (4.0d0 * (a * a))
else
tmp = (-1.0d0) + ((b * b) * 12.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+274) {
tmp = -1.0 + (4.0 * (a * a));
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+274: tmp = -1.0 + (4.0 * (a * a)) else: tmp = -1.0 + ((b * b) * 12.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+274) tmp = Float64(-1.0 + Float64(4.0 * Float64(a * a))); else tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+274) tmp = -1.0 + (4.0 * (a * a)); else tmp = -1.0 + ((b * b) * 12.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+274], N[(-1.0 + N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+274}:\\
\;\;\;\;-1 + 4 \cdot \left(a \cdot a\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\end{array}
\end{array}
if (*.f64 b b) < 4.9999999999999998e274Initial program 84.8%
sub-neg84.8%
fma-def84.8%
fma-def84.8%
+-commutative84.8%
metadata-eval84.8%
Simplified84.8%
Taylor expanded in b around 0 72.8%
associate-*r*72.8%
unpow272.8%
Simplified72.8%
Taylor expanded in a around 0 63.3%
unpow263.3%
Simplified63.3%
if 4.9999999999999998e274 < (*.f64 b b) Initial program 46.1%
sub-neg46.1%
fma-def46.1%
fma-def50.0%
+-commutative50.0%
metadata-eval50.0%
Simplified50.0%
fma-def50.0%
metadata-eval50.0%
sqrt-pow250.0%
hypot-udef50.0%
add-sqr-sqrt50.0%
unpow-prod-down50.0%
Applied egg-rr50.0%
pow-sqr50.0%
metadata-eval50.0%
Simplified50.0%
Taylor expanded in b around inf 53.5%
+-commutative53.5%
unpow253.5%
associate-*l*53.5%
Simplified53.5%
Taylor expanded in a around 0 92.9%
unpow292.9%
Simplified92.9%
Final simplification72.1%
(FPCore (a b) :precision binary64 (+ -1.0 (* 4.0 (* a a))))
double code(double a, double b) {
return -1.0 + (4.0 * (a * a));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + (4.0d0 * (a * a))
end function
public static double code(double a, double b) {
return -1.0 + (4.0 * (a * a));
}
def code(a, b): return -1.0 + (4.0 * (a * a))
function code(a, b) return Float64(-1.0 + Float64(4.0 * Float64(a * a))) end
function tmp = code(a, b) tmp = -1.0 + (4.0 * (a * a)); end
code[a_, b_] := N[(-1.0 + N[(4.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + 4 \cdot \left(a \cdot a\right)
\end{array}
Initial program 73.3%
sub-neg73.3%
fma-def73.3%
fma-def74.5%
+-commutative74.5%
metadata-eval74.5%
Simplified74.5%
Taylor expanded in b around 0 62.0%
associate-*r*62.0%
unpow262.0%
Simplified62.0%
Taylor expanded in a around 0 56.3%
unpow256.3%
Simplified56.3%
Final simplification56.3%
(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 73.3%
sub-neg73.3%
fma-def73.3%
fma-def74.5%
+-commutative74.5%
metadata-eval74.5%
Simplified74.5%
Taylor expanded in b around inf 70.9%
Taylor expanded in b around 0 28.1%
Final simplification28.1%
herbie shell --seed 2023238
(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))