
(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 8 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 (<=
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0)))))
INFINITY)
(+
(pow (hypot a b) 4.0)
(fma 4.0 (- (fma (* b b) (+ a 3.0) (* a a)) (pow a 3.0)) -1.0))
(+ -1.0 (pow a 4.0))))
double code(double a, double b) {
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) <= ((double) INFINITY)) {
tmp = pow(hypot(a, b), 4.0) + fma(4.0, (fma((b * b), (a + 3.0), (a * a)) - pow(a, 3.0)), -1.0);
} else {
tmp = -1.0 + pow(a, 4.0);
}
return tmp;
}
function code(a, b) 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)) + Float64(Float64(b * b) * Float64(a + 3.0))))) <= Inf) tmp = Float64((hypot(a, b) ^ 4.0) + fma(4.0, Float64(fma(Float64(b * b), Float64(a + 3.0), Float64(a * a)) - (a ^ 3.0)), -1.0)); else tmp = Float64(-1.0 + (a ^ 4.0)); end return tmp end
code[a_, b_] := 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] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision] - N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\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) \leq \infty:\\
\;\;\;\;{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - {a}^{3}, -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%
associate--l+99.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%
fma-def0.0%
fma-def8.0%
+-commutative8.0%
metadata-eval8.0%
Simplified8.0%
Taylor expanded in a around inf 91.1%
Final simplification97.4%
(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%
fma-def0.0%
fma-def8.0%
+-commutative8.0%
metadata-eval8.0%
Simplified8.0%
Taylor expanded in a around inf 91.1%
Final simplification97.3%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+24) (+ -1.0 (pow a 4.0)) (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+24) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = -1.0 + ((b * b) * ((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+24) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (-1.0d0) + ((b * b) * ((b * b) + 12.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+24) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+24: tmp = -1.0 + math.pow(a, 4.0) else: tmp = -1.0 + ((b * b) * ((b * b) + 12.0)) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 5e+24) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 12.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 5e+24) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + ((b * b) * ((b * b) + 12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 5e+24], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 5 \cdot 10^{+24}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 5.00000000000000045e24Initial program 78.8%
sub-neg78.8%
fma-def78.8%
fma-def78.8%
+-commutative78.8%
metadata-eval78.8%
Simplified78.8%
Taylor expanded in a around inf 97.7%
if 5.00000000000000045e24 < (*.f64 b b) Initial program 61.3%
sub-neg61.3%
fma-def61.3%
fma-def66.3%
+-commutative66.3%
metadata-eval66.3%
Simplified66.3%
Taylor expanded in a around 0 51.7%
associate-+r+51.7%
associate-*r*51.7%
distribute-rgt-out69.4%
metadata-eval69.4%
distribute-lft-in69.4%
+-commutative69.4%
unpow269.4%
distribute-lft-in69.4%
metadata-eval69.4%
Simplified69.4%
Taylor expanded in a around 0 92.2%
unpow292.2%
Simplified92.2%
+-commutative92.2%
sqr-pow92.1%
metadata-eval92.1%
pow292.1%
metadata-eval92.1%
pow292.1%
distribute-rgt-out92.1%
Applied egg-rr92.1%
Final simplification95.1%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+24) (+ -1.0 (pow a 4.0)) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+24) {
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) <= 5d+24) 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) <= 5e+24) {
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) <= 5e+24: 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) <= 5e+24) 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) <= 5e+24) 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], 5e+24], 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 5 \cdot 10^{+24}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 5.00000000000000045e24Initial program 78.8%
sub-neg78.8%
fma-def78.8%
fma-def78.8%
+-commutative78.8%
metadata-eval78.8%
Simplified78.8%
Taylor expanded in a around inf 97.7%
if 5.00000000000000045e24 < (*.f64 b b) Initial program 61.3%
sub-neg61.3%
fma-def61.3%
fma-def66.3%
+-commutative66.3%
metadata-eval66.3%
Simplified66.3%
Taylor expanded in b around inf 92.2%
Final simplification95.2%
(FPCore (a b)
:precision binary64
(if (<= a -2.2e+111)
(+ -1.0 (* 4.0 (* a (* a (- 1.0 a)))))
(if (<= a 6.6e+153)
(+ -1.0 (* (* b b) (+ (* b b) 12.0)))
(+ -1.0 (* (* a a) 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -2.2e+111) {
tmp = -1.0 + (4.0 * (a * (a * (1.0 - a))));
} else if (a <= 6.6e+153) {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
} else {
tmp = -1.0 + ((a * 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 <= (-2.2d+111)) then
tmp = (-1.0d0) + (4.0d0 * (a * (a * (1.0d0 - a))))
else if (a <= 6.6d+153) then
tmp = (-1.0d0) + ((b * b) * ((b * b) + 12.0d0))
else
tmp = (-1.0d0) + ((a * a) * 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -2.2e+111) {
tmp = -1.0 + (4.0 * (a * (a * (1.0 - a))));
} else if (a <= 6.6e+153) {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
} else {
tmp = -1.0 + ((a * a) * 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -2.2e+111: tmp = -1.0 + (4.0 * (a * (a * (1.0 - a)))) elif a <= 6.6e+153: tmp = -1.0 + ((b * b) * ((b * b) + 12.0)) else: tmp = -1.0 + ((a * a) * 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -2.2e+111) tmp = Float64(-1.0 + Float64(4.0 * Float64(a * Float64(a * Float64(1.0 - a))))); elseif (a <= 6.6e+153) tmp = Float64(-1.0 + Float64(Float64(b * b) * Float64(Float64(b * b) + 12.0))); else tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -2.2e+111) tmp = -1.0 + (4.0 * (a * (a * (1.0 - a)))); elseif (a <= 6.6e+153) tmp = -1.0 + ((b * b) * ((b * b) + 12.0)); else tmp = -1.0 + ((a * a) * 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -2.2e+111], N[(-1.0 + N[(4.0 * N[(a * N[(a * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 6.6e+153], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] + 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.2 \cdot 10^{+111}:\\
\;\;\;\;-1 + 4 \cdot \left(a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\\
\mathbf{elif}\;a \leq 6.6 \cdot 10^{+153}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\end{array}
\end{array}
if a < -2.19999999999999999e111Initial program 59.1%
sub-neg59.1%
fma-def59.1%
fma-def59.1%
+-commutative59.1%
metadata-eval59.1%
Simplified59.1%
Taylor expanded in b around 0 100.0%
associate-*r*100.0%
unpow2100.0%
Simplified100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
*-commutative100.0%
*-commutative100.0%
swap-sqr100.0%
pow2100.0%
metadata-eval100.0%
pow2100.0%
metadata-eval100.0%
sqr-pow100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 100.0%
unpow2100.0%
metadata-eval100.0%
cancel-sign-sub-inv100.0%
unpow3100.0%
associate-*l*100.0%
unsub-neg100.0%
distribute-rgt-neg-out100.0%
*-rgt-identity100.0%
distribute-lft-in100.0%
sub-neg100.0%
associate-*l*100.0%
associate-*l*100.0%
Simplified100.0%
if -2.19999999999999999e111 < a < 6.59999999999999989e153Initial program 85.0%
sub-neg85.0%
fma-def85.0%
fma-def88.3%
+-commutative88.3%
metadata-eval88.3%
Simplified88.3%
Taylor expanded in a around 0 62.6%
associate-+r+62.6%
associate-*r*62.6%
distribute-rgt-out74.1%
metadata-eval74.1%
distribute-lft-in74.1%
+-commutative74.1%
unpow274.1%
distribute-lft-in74.1%
metadata-eval74.1%
Simplified74.1%
Taylor expanded in a around 0 80.1%
unpow280.1%
Simplified80.1%
+-commutative80.1%
sqr-pow80.1%
metadata-eval80.1%
pow280.1%
metadata-eval80.1%
pow280.1%
distribute-rgt-out80.1%
Applied egg-rr80.1%
if 6.59999999999999989e153 < a Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def0.0%
+-commutative0.0%
metadata-eval0.0%
Simplified0.0%
Taylor expanded in b around 0 0.0%
associate-*r*0.0%
unpow20.0%
Simplified0.0%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
Final simplification85.8%
(FPCore (a b) :precision binary64 (if (<= a -4.3e+99) (+ -1.0 (* 4.0 (* a (* a (- 1.0 a))))) (if (<= a 6.2e+153) (+ -1.0 (* (* b b) 12.0)) (+ -1.0 (* (* a a) 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= -4.3e+99) {
tmp = -1.0 + (4.0 * (a * (a * (1.0 - a))));
} else if (a <= 6.2e+153) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 + ((a * 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 <= (-4.3d+99)) then
tmp = (-1.0d0) + (4.0d0 * (a * (a * (1.0d0 - a))))
else if (a <= 6.2d+153) then
tmp = (-1.0d0) + ((b * b) * 12.0d0)
else
tmp = (-1.0d0) + ((a * a) * 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -4.3e+99) {
tmp = -1.0 + (4.0 * (a * (a * (1.0 - a))));
} else if (a <= 6.2e+153) {
tmp = -1.0 + ((b * b) * 12.0);
} else {
tmp = -1.0 + ((a * a) * 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -4.3e+99: tmp = -1.0 + (4.0 * (a * (a * (1.0 - a)))) elif a <= 6.2e+153: tmp = -1.0 + ((b * b) * 12.0) else: tmp = -1.0 + ((a * a) * 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -4.3e+99) tmp = Float64(-1.0 + Float64(4.0 * Float64(a * Float64(a * Float64(1.0 - a))))); elseif (a <= 6.2e+153) tmp = Float64(-1.0 + Float64(Float64(b * b) * 12.0)); else tmp = Float64(-1.0 + Float64(Float64(a * a) * 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -4.3e+99) tmp = -1.0 + (4.0 * (a * (a * (1.0 - a)))); elseif (a <= 6.2e+153) tmp = -1.0 + ((b * b) * 12.0); else tmp = -1.0 + ((a * a) * 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -4.3e+99], N[(-1.0 + N[(4.0 * N[(a * N[(a * N[(1.0 - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 6.2e+153], N[(-1.0 + N[(N[(b * b), $MachinePrecision] * 12.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -4.3 \cdot 10^{+99}:\\
\;\;\;\;-1 + 4 \cdot \left(a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\\
\mathbf{elif}\;a \leq 6.2 \cdot 10^{+153}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\end{array}
\end{array}
if a < -4.3000000000000001e99Initial program 57.4%
sub-neg57.4%
fma-def57.4%
fma-def57.4%
+-commutative57.4%
metadata-eval57.4%
Simplified57.4%
Taylor expanded in b around 0 100.0%
associate-*r*100.0%
unpow2100.0%
Simplified100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
*-commutative100.0%
*-commutative100.0%
swap-sqr100.0%
pow2100.0%
metadata-eval100.0%
pow2100.0%
metadata-eval100.0%
sqr-pow100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 98.1%
unpow298.1%
metadata-eval98.1%
cancel-sign-sub-inv98.1%
unpow398.1%
associate-*l*98.1%
unsub-neg98.1%
distribute-rgt-neg-out98.1%
*-rgt-identity98.1%
distribute-lft-in98.1%
sub-neg98.1%
associate-*l*98.1%
associate-*l*98.1%
Simplified98.1%
if -4.3000000000000001e99 < a < 6.2e153Initial program 85.9%
sub-neg85.9%
fma-def85.9%
fma-def89.3%
+-commutative89.3%
metadata-eval89.3%
Simplified89.3%
Taylor expanded in a around 0 63.5%
associate-+r+63.5%
associate-*r*63.5%
distribute-rgt-out75.2%
metadata-eval75.2%
distribute-lft-in75.2%
+-commutative75.2%
unpow275.2%
distribute-lft-in75.2%
metadata-eval75.2%
Simplified75.2%
Taylor expanded in a around 0 80.3%
unpow280.3%
Simplified80.3%
+-commutative80.3%
sqr-pow80.2%
metadata-eval80.2%
pow280.2%
metadata-eval80.2%
pow280.2%
distribute-rgt-out80.2%
Applied egg-rr80.2%
Taylor expanded in b around 0 59.3%
unpow259.3%
Simplified59.3%
if 6.2e153 < a Initial program 0.0%
sub-neg0.0%
fma-def0.0%
fma-def0.0%
+-commutative0.0%
metadata-eval0.0%
Simplified0.0%
Taylor expanded in b around 0 0.0%
associate-*r*0.0%
unpow20.0%
Simplified0.0%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
Final simplification71.2%
(FPCore (a b) :precision binary64 (if (<= (* b b) 5e+290) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 5e+290) {
tmp = -1.0 + ((a * 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+290) then
tmp = (-1.0d0) + ((a * 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+290) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * 12.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 5e+290: tmp = -1.0 + ((a * 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+290) tmp = Float64(-1.0 + Float64(Float64(a * 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+290) tmp = -1.0 + ((a * 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+290], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 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^{+290}:\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot 12\\
\end{array}
\end{array}
if (*.f64 b b) < 4.9999999999999998e290Initial program 77.4%
sub-neg77.4%
fma-def77.4%
fma-def79.0%
+-commutative79.0%
metadata-eval79.0%
Simplified79.0%
Taylor expanded in b around 0 63.4%
associate-*r*63.4%
unpow263.4%
Simplified63.4%
Taylor expanded in a around 0 58.3%
unpow258.3%
Simplified58.3%
if 4.9999999999999998e290 < (*.f64 b b) Initial program 52.2%
sub-neg52.2%
fma-def52.2%
fma-def56.5%
+-commutative56.5%
metadata-eval56.5%
Simplified56.5%
Taylor expanded in a around 0 34.8%
associate-+r+34.8%
associate-*r*34.8%
distribute-rgt-out65.2%
metadata-eval65.2%
distribute-lft-in65.2%
+-commutative65.2%
unpow265.2%
distribute-lft-in65.2%
metadata-eval65.2%
Simplified65.2%
Taylor expanded in a around 0 100.0%
unpow2100.0%
Simplified100.0%
+-commutative100.0%
sqr-pow100.0%
metadata-eval100.0%
pow2100.0%
metadata-eval100.0%
pow2100.0%
distribute-rgt-out100.0%
Applied egg-rr100.0%
Taylor expanded in b around 0 94.8%
unpow294.8%
Simplified94.8%
Final simplification68.1%
(FPCore (a b) :precision binary64 (+ -1.0 (* (* a a) 4.0)))
double code(double a, double b) {
return -1.0 + ((a * a) * 4.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + ((a * a) * 4.0d0)
end function
public static double code(double a, double b) {
return -1.0 + ((a * a) * 4.0);
}
def code(a, b): return -1.0 + ((a * a) * 4.0)
function code(a, b) return Float64(-1.0 + Float64(Float64(a * a) * 4.0)) end
function tmp = code(a, b) tmp = -1.0 + ((a * a) * 4.0); end
code[a_, b_] := N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + \left(a \cdot a\right) \cdot 4
\end{array}
Initial program 70.6%
sub-neg70.6%
fma-def70.6%
fma-def73.0%
+-commutative73.0%
metadata-eval73.0%
Simplified73.0%
Taylor expanded in b around 0 53.6%
associate-*r*53.6%
unpow253.6%
Simplified53.6%
Taylor expanded in a around 0 50.8%
unpow250.8%
Simplified50.8%
Final simplification50.8%
herbie shell --seed 2023187
(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))