
(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
(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) (* a (* 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) + (a * (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 + Float64((a ^ 4.0) + Float64(a * Float64(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[(N[Power[a, 4.0], $MachinePrecision] + N[(a * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $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 + \left({a}^{4} + a \cdot \left(a \cdot 4\right)\right)\\
\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%
+-commutative0.0%
associate-+l+0.0%
fma-def0.0%
associate-*l*0.0%
fma-def1.9%
distribute-lft-out--1.9%
*-rgt-identity1.9%
+-commutative1.9%
Simplified1.9%
Taylor expanded in b around 0 24.5%
sub-neg24.5%
fma-def24.5%
unpow224.5%
metadata-eval24.5%
Simplified24.5%
fma-udef24.5%
+-commutative24.5%
associate-*r*24.5%
*-un-lft-identity24.5%
distribute-rgt-out--24.5%
Applied egg-rr24.5%
Taylor expanded in a around 0 91.2%
Final simplification98.1%
(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) (* a (* 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) + (a * (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) + (a * (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) + (a * (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 + Float64((a ^ 4.0) + Float64(a * Float64(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) + (a * (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[(N[Power[a, 4.0], $MachinePrecision] + N[(a * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $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 + \left({a}^{4} + a \cdot \left(a \cdot 4\right)\right)\\
\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%
+-commutative0.0%
associate-+l+0.0%
fma-def0.0%
associate-*l*0.0%
fma-def1.9%
distribute-lft-out--1.9%
*-rgt-identity1.9%
+-commutative1.9%
Simplified1.9%
Taylor expanded in b around 0 24.5%
sub-neg24.5%
fma-def24.5%
unpow224.5%
metadata-eval24.5%
Simplified24.5%
fma-udef24.5%
+-commutative24.5%
associate-*r*24.5%
*-un-lft-identity24.5%
distribute-rgt-out--24.5%
Applied egg-rr24.5%
Taylor expanded in a around 0 91.2%
Final simplification98.0%
(FPCore (a b) :precision binary64 (if (or (<= a -1.25e+24) (not (<= a 1.35e+15))) (+ -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 ((a <= -1.25e+24) || !(a <= 1.35e+15)) {
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 ((a <= (-1.25d+24)) .or. (.not. (a <= 1.35d+15))) 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 ((a <= -1.25e+24) || !(a <= 1.35e+15)) {
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 (a <= -1.25e+24) or not (a <= 1.35e+15): 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 ((a <= -1.25e+24) || !(a <= 1.35e+15)) 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 ((a <= -1.25e+24) || ~((a <= 1.35e+15))) 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[Or[LessEqual[a, -1.25e+24], N[Not[LessEqual[a, 1.35e+15]], $MachinePrecision]], 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}\;a \leq -1.25 \cdot 10^{+24} \lor \neg \left(a \leq 1.35 \cdot 10^{+15}\right):\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot 12\right)\\
\end{array}
\end{array}
if a < -1.25000000000000011e24 or 1.35e15 < a Initial program 50.8%
sub-neg50.8%
sqr-pow50.8%
sqr-pow50.8%
sqr-neg50.8%
distribute-rgt-in50.8%
sqr-neg50.8%
distribute-rgt-in50.8%
Simplified51.8%
Taylor expanded in a around inf 94.5%
if -1.25000000000000011e24 < a < 1.35e15Initial program 97.9%
sub-neg97.9%
sqr-pow97.9%
sqr-pow97.9%
sqr-neg97.9%
distribute-rgt-in97.9%
sqr-neg97.9%
distribute-rgt-in97.9%
Simplified97.9%
Taylor expanded in a around 0 84.8%
+-commutative84.8%
+-commutative84.8%
associate-+l+84.8%
unpow284.8%
unpow284.8%
associate-*r*84.8%
distribute-rgt-in96.0%
metadata-eval96.0%
distribute-lft-in96.0%
*-commutative96.0%
distribute-lft-in96.0%
metadata-eval96.0%
Simplified96.0%
Taylor expanded in a around 0 98.0%
unpow298.0%
Simplified98.0%
Final simplification96.6%
(FPCore (a b) :precision binary64 (if (or (<= a -4.6e+26) (not (<= a 9.8e+14))) (+ -1.0 (pow a 4.0)) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((a <= -4.6e+26) || !(a <= 9.8e+14)) {
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 ((a <= (-4.6d+26)) .or. (.not. (a <= 9.8d+14))) 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 ((a <= -4.6e+26) || !(a <= 9.8e+14)) {
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 (a <= -4.6e+26) or not (a <= 9.8e+14): 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 ((a <= -4.6e+26) || !(a <= 9.8e+14)) 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 ((a <= -4.6e+26) || ~((a <= 9.8e+14))) tmp = -1.0 + (a ^ 4.0); else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -4.6e+26], N[Not[LessEqual[a, 9.8e+14]], $MachinePrecision]], 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}\;a \leq -4.6 \cdot 10^{+26} \lor \neg \left(a \leq 9.8 \cdot 10^{+14}\right):\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if a < -4.6000000000000001e26 or 9.8e14 < a Initial program 50.8%
sub-neg50.8%
sqr-pow50.8%
sqr-pow50.8%
sqr-neg50.8%
distribute-rgt-in50.8%
sqr-neg50.8%
distribute-rgt-in50.8%
Simplified51.8%
Taylor expanded in a around inf 94.5%
if -4.6000000000000001e26 < a < 9.8e14Initial program 97.9%
sub-neg97.9%
sqr-pow97.9%
sqr-pow97.9%
sqr-neg97.9%
distribute-rgt-in97.9%
sqr-neg97.9%
distribute-rgt-in97.9%
Simplified97.9%
Taylor expanded in b around inf 95.3%
Final simplification95.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+61) (+ -1.0 (pow a 4.0)) (* (* b b) (* b b))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+61) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = (b * b) * (b * b);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2d+61) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = (b * b) * (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+61) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = (b * b) * (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+61: tmp = -1.0 + math.pow(a, 4.0) else: tmp = (b * b) * (b * b) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+61) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = Float64(Float64(b * b) * Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+61) tmp = -1.0 + (a ^ 4.0); else tmp = (b * b) * (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+61], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+61}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1.9999999999999999e61Initial program 87.7%
sub-neg87.7%
sqr-pow87.7%
sqr-pow87.7%
sqr-neg87.7%
distribute-rgt-in87.7%
sqr-neg87.7%
distribute-rgt-in87.7%
Simplified87.7%
Taylor expanded in a around inf 94.7%
if 1.9999999999999999e61 < (*.f64 b b) Initial program 68.1%
sub-neg68.1%
sqr-pow68.1%
sqr-pow68.1%
sqr-neg68.1%
distribute-rgt-in68.1%
sqr-neg68.1%
distribute-rgt-in68.1%
Simplified68.9%
Taylor expanded in a around 0 69.0%
+-commutative69.0%
+-commutative69.0%
associate-+l+69.0%
unpow269.0%
unpow269.0%
associate-*r*69.0%
distribute-rgt-in83.7%
metadata-eval83.7%
distribute-lft-in83.7%
*-commutative83.7%
distribute-lft-in83.7%
metadata-eval83.7%
Simplified83.7%
add-sqr-sqrt83.7%
pow283.7%
+-commutative83.7%
+-commutative83.7%
fma-def85.4%
+-commutative85.4%
fma-def85.4%
Applied egg-rr85.4%
Taylor expanded in b around inf 92.7%
unpow292.7%
Simplified92.7%
unpow292.7%
Applied egg-rr92.7%
Final simplification93.8%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2.45e-6) -1.0 (* (* b b) (* b b))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2.45e-6) {
tmp = -1.0;
} else {
tmp = (b * b) * (b * b);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2.45d-6) then
tmp = -1.0d0
else
tmp = (b * b) * (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2.45e-6) {
tmp = -1.0;
} else {
tmp = (b * b) * (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2.45e-6: tmp = -1.0 else: tmp = (b * b) * (b * b) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2.45e-6) tmp = -1.0; else tmp = Float64(Float64(b * b) * Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2.45e-6) tmp = -1.0; else tmp = (b * b) * (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2.45e-6], -1.0, N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2.45 \cdot 10^{-6}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 2.44999999999999984e-6Initial program 88.3%
sub-neg88.3%
sqr-pow88.3%
sqr-pow88.3%
sqr-neg88.3%
distribute-rgt-in88.3%
sqr-neg88.3%
distribute-rgt-in88.3%
Simplified88.3%
Taylor expanded in a around 0 55.7%
+-commutative55.7%
+-commutative55.7%
associate-+l+55.7%
unpow255.7%
unpow255.7%
associate-*r*55.7%
distribute-rgt-in55.7%
metadata-eval55.7%
distribute-lft-in55.7%
*-commutative55.7%
distribute-lft-in55.7%
metadata-eval55.7%
Simplified55.7%
Taylor expanded in b around 0 55.1%
if 2.44999999999999984e-6 < (*.f64 b b) Initial program 70.3%
sub-neg70.3%
sqr-pow70.3%
sqr-pow70.3%
sqr-neg70.3%
distribute-rgt-in70.3%
sqr-neg70.3%
distribute-rgt-in70.3%
Simplified71.0%
Taylor expanded in a around 0 63.3%
+-commutative63.3%
+-commutative63.3%
associate-+l+63.3%
unpow263.3%
unpow263.3%
associate-*r*63.3%
distribute-rgt-in75.9%
metadata-eval75.9%
distribute-lft-in75.9%
*-commutative75.9%
distribute-lft-in75.9%
metadata-eval75.9%
Simplified75.9%
add-sqr-sqrt75.9%
pow275.9%
+-commutative75.9%
+-commutative75.9%
fma-def77.4%
+-commutative77.4%
fma-def77.4%
Applied egg-rr77.4%
Taylor expanded in b around inf 81.3%
unpow281.3%
Simplified81.3%
unpow281.3%
Applied egg-rr81.3%
Final simplification68.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+61) (+ -1.0 (* a (* a 4.0))) (* (* b b) (* b b))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+61) {
tmp = -1.0 + (a * (a * 4.0));
} else {
tmp = (b * b) * (b * b);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 2d+61) then
tmp = (-1.0d0) + (a * (a * 4.0d0))
else
tmp = (b * b) * (b * b)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+61) {
tmp = -1.0 + (a * (a * 4.0));
} else {
tmp = (b * b) * (b * b);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+61: tmp = -1.0 + (a * (a * 4.0)) else: tmp = (b * b) * (b * b) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+61) tmp = Float64(-1.0 + Float64(a * Float64(a * 4.0))); else tmp = Float64(Float64(b * b) * Float64(b * b)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+61) tmp = -1.0 + (a * (a * 4.0)); else tmp = (b * b) * (b * b); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+61], N[(-1.0 + N[(a * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+61}:\\
\;\;\;\;-1 + a \cdot \left(a \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1.9999999999999999e61Initial program 87.7%
sub-neg87.7%
+-commutative87.7%
associate-+l+87.7%
fma-def87.7%
associate-*l*87.7%
fma-def87.7%
distribute-lft-out--87.7%
*-rgt-identity87.7%
+-commutative87.7%
Simplified87.8%
Taylor expanded in b around 0 83.9%
sub-neg83.9%
fma-def83.9%
unpow283.9%
metadata-eval83.9%
Simplified83.9%
Taylor expanded in a around 0 74.0%
unpow274.0%
associate-*r*74.0%
*-commutative74.0%
Simplified74.0%
if 1.9999999999999999e61 < (*.f64 b b) Initial program 68.1%
sub-neg68.1%
sqr-pow68.1%
sqr-pow68.1%
sqr-neg68.1%
distribute-rgt-in68.1%
sqr-neg68.1%
distribute-rgt-in68.1%
Simplified68.9%
Taylor expanded in a around 0 69.0%
+-commutative69.0%
+-commutative69.0%
associate-+l+69.0%
unpow269.0%
unpow269.0%
associate-*r*69.0%
distribute-rgt-in83.7%
metadata-eval83.7%
distribute-lft-in83.7%
*-commutative83.7%
distribute-lft-in83.7%
metadata-eval83.7%
Simplified83.7%
add-sqr-sqrt83.7%
pow283.7%
+-commutative83.7%
+-commutative83.7%
fma-def85.4%
+-commutative85.4%
fma-def85.4%
Applied egg-rr85.4%
Taylor expanded in b around inf 92.7%
unpow292.7%
Simplified92.7%
unpow292.7%
Applied egg-rr92.7%
Final simplification82.5%
(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 78.8%
sub-neg78.8%
sqr-pow78.8%
sqr-pow78.8%
sqr-neg78.8%
distribute-rgt-in78.8%
sqr-neg78.8%
distribute-rgt-in78.8%
Simplified79.2%
Taylor expanded in a around 0 59.7%
+-commutative59.7%
+-commutative59.7%
associate-+l+59.7%
unpow259.7%
unpow259.7%
associate-*r*59.7%
distribute-rgt-in66.4%
metadata-eval66.4%
distribute-lft-in66.4%
*-commutative66.4%
distribute-lft-in66.4%
metadata-eval66.4%
Simplified66.4%
Taylor expanded in b around 0 26.4%
Final simplification26.4%
herbie shell --seed 2023293
(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))