
(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
(let* ((t_0 (* (* b b) (+ a 3.0))))
(if (<=
(+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) t_0)))
INFINITY)
(fma 4.0 (fma a (- a (* a a)) t_0) (+ (pow (hypot a b) 4.0) -1.0))
(+ -1.0 (pow a 4.0)))))
double code(double a, double b) {
double t_0 = (b * b) * (a + 3.0);
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + t_0))) <= ((double) INFINITY)) {
tmp = fma(4.0, fma(a, (a - (a * a)), t_0), (pow(hypot(a, b), 4.0) + -1.0));
} else {
tmp = -1.0 + pow(a, 4.0);
}
return tmp;
}
function code(a, b) t_0 = Float64(Float64(b * b) * Float64(a + 3.0)) tmp = 0.0 if (Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + t_0))) <= Inf) tmp = fma(4.0, fma(a, Float64(a - Float64(a * a)), t_0), Float64((hypot(a, b) ^ 4.0) + -1.0)); else tmp = Float64(-1.0 + (a ^ 4.0)); end return tmp end
code[a_, b_] := Block[{t$95$0 = N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(4.0 * N[(a * N[(a - N[(a * a), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] + N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(b \cdot b\right) \cdot \left(a + 3\right)\\
\mathbf{if}\;{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + t_0\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(4, \mathsf{fma}\left(a, a - a \cdot a, t_0\right), {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + -1\right)\\
\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%
sub-neg99.9%
+-commutative99.9%
associate-+l+99.9%
fma-def99.9%
associate-*l*99.9%
fma-def99.9%
distribute-lft-out--99.9%
*-rgt-identity99.9%
+-commutative99.9%
Simplified100.0%
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%
sqr-pow0.0%
sqr-pow0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified4.7%
Taylor expanded in a around inf 86.8%
Final simplification96.7%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))))
(if (<= t_0 INFINITY) (+ t_0 -1.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 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.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 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.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 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.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(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.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 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.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[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.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(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;t_0 + -1\\
\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%
sqr-pow0.0%
sqr-pow0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified4.7%
Taylor expanded in a around inf 86.8%
Final simplification96.6%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+293) (+ -1.0 (pow a 4.0)) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+293) {
tmp = -1.0 + pow(a, 4.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) <= 5d+293) then
tmp = (-1.0d0) + (a ** 4.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) <= 5e+293) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+293: tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + ((b * b) * 12.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+293) tmp = Float64(-1.0 + (a ^ 4.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) <= 5e+293) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + ((b * b) * 12.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+293], N[(-1.0 + N[Power[a, 4.0], $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^{+293}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\end{array}
\end{array}
if (*.f64 b b) < 5.00000000000000033e293Initial program 79.7%
sub-neg79.7%
sqr-pow79.7%
sqr-pow79.7%
sqr-neg79.7%
distribute-rgt-in79.7%
sqr-neg79.7%
distribute-rgt-in79.7%
Simplified79.7%
Taylor expanded in a around inf 84.4%
if 5.00000000000000033e293 < (*.f64 b b) Initial program 63.0%
sub-neg63.0%
sqr-pow63.0%
sqr-pow63.0%
sqr-neg63.0%
distribute-rgt-in63.0%
sqr-neg63.0%
distribute-rgt-in63.0%
Simplified67.1%
Taylor expanded in a around 0 49.3%
+-commutative49.3%
+-commutative49.3%
associate-+l+49.3%
unpow249.3%
unpow249.3%
associate-*r*49.3%
distribute-rgt-in78.1%
metadata-eval78.1%
distribute-lft-in78.1%
associate-*l*78.1%
+-commutative78.1%
Simplified78.1%
Taylor expanded in b around 0 76.9%
unpow276.9%
+-commutative76.9%
associate-*l*76.9%
+-commutative76.9%
Simplified76.9%
Taylor expanded in a around 0 97.6%
unpow297.6%
Simplified97.6%
Final simplification88.2%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+78) (+ -1.0 (pow a 4.0)) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+78) {
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 * b) <= 2d+78) 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 * b) <= 2e+78) {
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 * b) <= 2e+78: 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 (Float64(b * b) <= 2e+78) 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 * b) <= 2e+78) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+78], 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 \cdot b \leq 2 \cdot 10^{+78}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 2.00000000000000002e78Initial program 84.3%
sub-neg84.3%
sqr-pow84.3%
sqr-pow84.3%
sqr-neg84.3%
distribute-rgt-in84.3%
sqr-neg84.3%
distribute-rgt-in84.3%
Simplified84.3%
Taylor expanded in a around inf 97.3%
if 2.00000000000000002e78 < (*.f64 b b) Initial program 63.4%
sub-neg63.4%
sqr-pow63.4%
sqr-pow63.4%
sqr-neg63.4%
distribute-rgt-in63.4%
sqr-neg63.4%
distribute-rgt-in63.4%
Simplified66.0%
Taylor expanded in b around inf 95.3%
Final simplification96.4%
(FPCore (a b)
:precision binary64
(let* ((t_0 (- 9.0 (* a a))))
(if (<= (* b b) 5e+293)
(+ -1.0 (* 4.0 (* b (/ b (+ (* (/ a t_0) 0.0) (/ (- 3.0 a) t_0))))))
(+ -1.0 (* (* b b) 12.0)))))
double code(double a, double b) {
double t_0 = 9.0 - (a * a);
double tmp;
if ((b * b) <= 5e+293) {
tmp = -1.0 + (4.0 * (b * (b / (((a / t_0) * 0.0) + ((3.0 - a) / t_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) :: t_0
real(8) :: tmp
t_0 = 9.0d0 - (a * a)
if ((b * b) <= 5d+293) then
tmp = (-1.0d0) + (4.0d0 * (b * (b / (((a / t_0) * 0.0d0) + ((3.0d0 - a) / t_0)))))
else
tmp = (-1.0d0) + ((b * b) * 12.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = 9.0 - (a * a);
double tmp;
if ((b * b) <= 5e+293) {
tmp = -1.0 + (4.0 * (b * (b / (((a / t_0) * 0.0) + ((3.0 - a) / t_0)))));
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
def code(a, b): t_0 = 9.0 - (a * a) tmp = 0 if (b * b) <= 5e+293: tmp = -1.0 + (4.0 * (b * (b / (((a / t_0) * 0.0) + ((3.0 - a) / t_0))))) else: tmp = -1.0 + ((b * b) * 12.0) return tmp
function code(a, b) t_0 = Float64(9.0 - Float64(a * a)) tmp = 0.0 if (Float64(b * b) <= 5e+293) tmp = Float64(-1.0 + Float64(4.0 * Float64(b * Float64(b / Float64(Float64(Float64(a / t_0) * 0.0) + Float64(Float64(3.0 - a) / t_0)))))); else tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); end return tmp end
function tmp_2 = code(a, b) t_0 = 9.0 - (a * a); tmp = 0.0; if ((b * b) <= 5e+293) tmp = -1.0 + (4.0 * (b * (b / (((a / t_0) * 0.0) + ((3.0 - a) / t_0))))); else tmp = -1.0 + ((b * b) * 12.0); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(9.0 - N[(a * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(b * b), $MachinePrecision], 5e+293], N[(-1.0 + N[(4.0 * N[(b * N[(b / N[(N[(N[(a / t$95$0), $MachinePrecision] * 0.0), $MachinePrecision] + N[(N[(3.0 - a), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 9 - a \cdot a\\
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+293}:\\
\;\;\;\;-1 + 4 \cdot \left(b \cdot \frac{b}{\frac{a}{t_0} \cdot 0 + \frac{3 - a}{t_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\end{array}
\end{array}
if (*.f64 b b) < 5.00000000000000033e293Initial program 79.7%
sub-neg79.7%
sqr-pow79.7%
sqr-pow79.7%
sqr-neg79.7%
distribute-rgt-in79.7%
sqr-neg79.7%
distribute-rgt-in79.7%
Simplified79.7%
Taylor expanded in a around 0 57.0%
+-commutative57.0%
+-commutative57.0%
associate-+l+57.0%
unpow257.0%
unpow257.0%
associate-*r*57.5%
distribute-rgt-in57.5%
metadata-eval57.5%
distribute-lft-in57.5%
associate-*l*57.5%
+-commutative57.5%
Simplified57.5%
Taylor expanded in b around 0 43.6%
unpow243.6%
+-commutative43.6%
associate-*l*43.6%
+-commutative43.6%
Simplified43.6%
flip-+51.6%
associate-*r/51.6%
metadata-eval51.6%
Applied egg-rr51.6%
associate-/l*51.6%
Simplified51.6%
div-sub51.6%
div-inv51.6%
div-inv51.6%
prod-diff66.3%
Applied egg-rr66.3%
+-commutative66.3%
fma-udef66.3%
associate-+r+66.3%
associate-*r/66.3%
metadata-eval66.3%
associate-+r+66.3%
Simplified66.3%
if 5.00000000000000033e293 < (*.f64 b b) Initial program 63.0%
sub-neg63.0%
sqr-pow63.0%
sqr-pow63.0%
sqr-neg63.0%
distribute-rgt-in63.0%
sqr-neg63.0%
distribute-rgt-in63.0%
Simplified67.1%
Taylor expanded in a around 0 49.3%
+-commutative49.3%
+-commutative49.3%
associate-+l+49.3%
unpow249.3%
unpow249.3%
associate-*r*49.3%
distribute-rgt-in78.1%
metadata-eval78.1%
distribute-lft-in78.1%
associate-*l*78.1%
+-commutative78.1%
Simplified78.1%
Taylor expanded in b around 0 76.9%
unpow276.9%
+-commutative76.9%
associate-*l*76.9%
+-commutative76.9%
Simplified76.9%
Taylor expanded in a around 0 97.6%
unpow297.6%
Simplified97.6%
Final simplification75.3%
(FPCore (a b) :precision binary64 (if (<= a -0.008) (+ -1.0 (* (* b b) 12.0)) (+ -1.0 (* 4.0 (* b (/ b (/ (- 3.0 a) (- 9.0 (* a a)))))))))
double code(double a, double b) {
double tmp;
if (a <= -0.008) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 + (4.0 * (b * (b / ((3.0 - a) / (9.0 - (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 <= (-0.008d0)) then
tmp = (-1.0d0) + ((b * b) * 12.0d0)
else
tmp = (-1.0d0) + (4.0d0 * (b * (b / ((3.0d0 - a) / (9.0d0 - (a * a))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -0.008) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 + (4.0 * (b * (b / ((3.0 - a) / (9.0 - (a * a))))));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -0.008: tmp = -1.0 + ((b * b) * 12.0) else: tmp = -1.0 + (4.0 * (b * (b / ((3.0 - a) / (9.0 - (a * a)))))) return tmp
function code(a, b) tmp = 0.0 if (a <= -0.008) tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); else tmp = Float64(-1.0 + Float64(4.0 * Float64(b * Float64(b / Float64(Float64(3.0 - a) / Float64(9.0 - Float64(a * a))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -0.008) tmp = -1.0 + ((b * b) * 12.0); else tmp = -1.0 + (4.0 * (b * (b / ((3.0 - a) / (9.0 - (a * a)))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -0.008], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(4.0 * N[(b * N[(b / N[(N[(3.0 - a), $MachinePrecision] / N[(9.0 - N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.008:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\mathbf{else}:\\
\;\;\;\;-1 + 4 \cdot \left(b \cdot \frac{b}{\frac{3 - a}{9 - a \cdot a}}\right)\\
\end{array}
\end{array}
if a < -0.0080000000000000002Initial program 62.4%
sub-neg62.4%
sqr-pow62.4%
sqr-pow62.4%
sqr-neg62.4%
distribute-rgt-in62.4%
sqr-neg62.4%
distribute-rgt-in62.4%
Simplified62.4%
Taylor expanded in a around 0 2.1%
+-commutative2.1%
+-commutative2.1%
associate-+l+2.1%
unpow22.1%
unpow22.1%
associate-*r*2.1%
distribute-rgt-in2.1%
metadata-eval2.1%
distribute-lft-in2.1%
associate-*l*2.1%
+-commutative2.1%
Simplified2.1%
Taylor expanded in b around 0 0.4%
unpow20.4%
+-commutative0.4%
associate-*l*0.4%
+-commutative0.4%
Simplified0.4%
Taylor expanded in a around 0 25.3%
unpow225.3%
Simplified25.3%
if -0.0080000000000000002 < a Initial program 79.1%
sub-neg79.1%
sqr-pow79.1%
sqr-pow79.1%
sqr-neg79.1%
distribute-rgt-in79.1%
sqr-neg79.1%
distribute-rgt-in79.1%
Simplified80.7%
Taylor expanded in a around 0 72.4%
+-commutative72.4%
+-commutative72.4%
associate-+l+72.4%
unpow272.4%
unpow272.4%
associate-*r*72.9%
distribute-rgt-in83.8%
metadata-eval83.8%
distribute-lft-in83.8%
associate-*l*83.8%
+-commutative83.8%
Simplified83.8%
Taylor expanded in b around 0 70.7%
unpow270.7%
+-commutative70.7%
associate-*l*70.7%
+-commutative70.7%
Simplified70.7%
flip-+78.3%
associate-*r/78.3%
metadata-eval78.3%
Applied egg-rr78.3%
associate-/l*78.3%
Simplified78.3%
Final simplification65.1%
(FPCore (a b) :precision binary64 (if (<= a 1.56e+44) (+ -1.0 (* (* b b) 12.0)) (- -1.0 (* 4.0 (* b (/ (* (* a a) b) (- 3.0 a)))))))
double code(double a, double b) {
double tmp;
if (a <= 1.56e+44) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 - (4.0 * (b * (((a * a) * b) / (3.0 - a))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= 1.56d+44) then
tmp = (-1.0d0) + ((b * b) * 12.0d0)
else
tmp = (-1.0d0) - (4.0d0 * (b * (((a * a) * b) / (3.0d0 - a))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 1.56e+44) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 - (4.0 * (b * (((a * a) * b) / (3.0 - a))));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 1.56e+44: tmp = -1.0 + ((b * b) * 12.0) else: tmp = -1.0 - (4.0 * (b * (((a * a) * b) / (3.0 - a)))) return tmp
function code(a, b) tmp = 0.0 if (a <= 1.56e+44) tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); else tmp = Float64(-1.0 - Float64(4.0 * Float64(b * Float64(Float64(Float64(a * a) * b) / Float64(3.0 - a))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 1.56e+44) tmp = -1.0 + ((b * b) * 12.0); else tmp = -1.0 - (4.0 * (b * (((a * a) * b) / (3.0 - a)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 1.56e+44], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 - N[(4.0 * N[(b * N[(N[(N[(a * a), $MachinePrecision] * b), $MachinePrecision] / N[(3.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.56 \cdot 10^{+44}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\mathbf{else}:\\
\;\;\;\;-1 - 4 \cdot \left(b \cdot \frac{\left(a \cdot a\right) \cdot b}{3 - a}\right)\\
\end{array}
\end{array}
if a < 1.56e44Initial program 88.2%
sub-neg88.2%
sqr-pow88.2%
sqr-pow88.2%
sqr-neg88.2%
distribute-rgt-in88.2%
sqr-neg88.2%
distribute-rgt-in88.2%
Simplified88.2%
Taylor expanded in a around 0 56.7%
+-commutative56.7%
+-commutative56.7%
associate-+l+56.7%
unpow256.7%
unpow256.7%
associate-*r*56.7%
distribute-rgt-in67.0%
metadata-eval67.0%
distribute-lft-in67.0%
associate-*l*67.0%
+-commutative67.0%
Simplified67.0%
Taylor expanded in b around 0 54.6%
unpow254.6%
+-commutative54.6%
associate-*l*54.6%
+-commutative54.6%
Simplified54.6%
Taylor expanded in a around 0 62.4%
unpow262.4%
Simplified62.4%
if 1.56e44 < a Initial program 23.0%
sub-neg23.0%
sqr-pow23.0%
sqr-pow23.0%
sqr-neg23.0%
distribute-rgt-in23.0%
sqr-neg23.0%
distribute-rgt-in23.0%
Simplified28.8%
Taylor expanded in a around 0 47.3%
+-commutative47.3%
+-commutative47.3%
associate-+l+47.3%
unpow247.3%
unpow247.3%
associate-*r*49.1%
distribute-rgt-in49.1%
metadata-eval49.1%
distribute-lft-in49.1%
associate-*l*49.1%
+-commutative49.1%
Simplified49.1%
Taylor expanded in b around 0 47.3%
unpow247.3%
+-commutative47.3%
associate-*l*47.3%
+-commutative47.3%
Simplified47.3%
*-commutative47.3%
flip-+75.4%
associate-*l/75.4%
metadata-eval75.4%
Applied egg-rr75.4%
Taylor expanded in a around inf 75.4%
mul-1-neg75.4%
unpow275.4%
Simplified75.4%
Final simplification65.1%
(FPCore (a b) :precision binary64 (if (<= a 1.38e-11) (+ -1.0 (* (* b b) 12.0)) (+ -1.0 (* b (* b (* a 4.0))))))
double code(double a, double b) {
double tmp;
if (a <= 1.38e-11) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 + (b * (b * (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 <= 1.38d-11) then
tmp = (-1.0d0) + ((b * b) * 12.0d0)
else
tmp = (-1.0d0) + (b * (b * (a * 4.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 1.38e-11) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 + (b * (b * (a * 4.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 1.38e-11: tmp = -1.0 + ((b * b) * 12.0) else: tmp = -1.0 + (b * (b * (a * 4.0))) return tmp
function code(a, b) tmp = 0.0 if (a <= 1.38e-11) tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); else tmp = Float64(-1.0 + Float64(b * Float64(b * Float64(a * 4.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 1.38e-11) tmp = -1.0 + ((b * b) * 12.0); else tmp = -1.0 + (b * (b * (a * 4.0))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 1.38e-11], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(b * N[(b * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.38 \cdot 10^{-11}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\mathbf{else}:\\
\;\;\;\;-1 + b \cdot \left(b \cdot \left(a \cdot 4\right)\right)\\
\end{array}
\end{array}
if a < 1.38e-11Initial program 87.8%
sub-neg87.8%
sqr-pow87.8%
sqr-pow87.8%
sqr-neg87.8%
distribute-rgt-in87.8%
sqr-neg87.8%
distribute-rgt-in87.8%
Simplified87.8%
Taylor expanded in a around 0 57.4%
+-commutative57.4%
+-commutative57.4%
associate-+l+57.4%
unpow257.4%
unpow257.4%
associate-*r*57.4%
distribute-rgt-in68.0%
metadata-eval68.0%
distribute-lft-in68.0%
associate-*l*68.0%
+-commutative68.0%
Simplified68.0%
Taylor expanded in b around 0 55.2%
unpow255.2%
+-commutative55.2%
associate-*l*55.2%
+-commutative55.2%
Simplified55.2%
Taylor expanded in a around 0 63.3%
unpow263.3%
Simplified63.3%
if 1.38e-11 < a Initial program 31.0%
sub-neg31.0%
sqr-pow31.0%
sqr-pow31.0%
sqr-neg31.0%
distribute-rgt-in31.0%
sqr-neg31.0%
distribute-rgt-in31.0%
Simplified36.2%
Taylor expanded in a around 0 45.9%
+-commutative45.9%
+-commutative45.9%
associate-+l+45.9%
unpow245.9%
unpow245.9%
associate-*r*47.5%
distribute-rgt-in47.5%
metadata-eval47.5%
distribute-lft-in47.5%
associate-*l*47.5%
+-commutative47.5%
Simplified47.5%
Taylor expanded in a around inf 45.9%
unpow245.9%
associate-*r*47.5%
*-commutative47.5%
associate-*l*47.5%
Simplified47.5%
Final simplification59.7%
(FPCore (a b) :precision binary64 (+ -1.0 (* (* b b) 12.0)))
double code(double a, double b) {
return -1.0 + ((b * b) * 12.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + ((b * b) * 12.0d0)
end function
public static double code(double a, double b) {
return -1.0 + ((b * b) * 12.0);
}
def code(a, b): return -1.0 + ((b * b) * 12.0)
function code(a, b) return Float64(-1.0 + Float64(Float64(b * b) * 12.0)) end
function tmp = code(a, b) tmp = -1.0 + ((b * b) * 12.0); end
code[a_, b_] := N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + \left(b \cdot b\right) \cdot 12
\end{array}
Initial program 74.9%
sub-neg74.9%
sqr-pow74.9%
sqr-pow74.9%
sqr-neg74.9%
distribute-rgt-in74.9%
sqr-neg74.9%
distribute-rgt-in74.9%
Simplified76.1%
Taylor expanded in a around 0 54.8%
+-commutative54.8%
+-commutative54.8%
associate-+l+54.8%
unpow254.8%
unpow254.8%
associate-*r*55.2%
distribute-rgt-in63.4%
metadata-eval63.4%
distribute-lft-in63.4%
associate-*l*63.4%
+-commutative63.4%
Simplified63.4%
Taylor expanded in b around 0 53.1%
unpow253.1%
+-commutative53.1%
associate-*l*53.1%
+-commutative53.1%
Simplified53.1%
Taylor expanded in a around 0 55.9%
unpow255.9%
Simplified55.9%
Final simplification55.9%
herbie shell --seed 2023290
(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))