
(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 (<=
(+
(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 (fma (* a a) (* a a) (* (* a 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 + fma((a * a), (a * a), ((a * 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 + fma(Float64(a * a), Float64(a * a), Float64(Float64(a * 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[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * 4.0), $MachinePrecision]), $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 + \mathsf{fma}\left(a \cdot a, a \cdot a, \left(a \cdot a\right) \cdot 4\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.8%
associate--l+99.8%
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-def5.2%
+-commutative5.2%
metadata-eval5.2%
Simplified5.2%
Taylor expanded in b around 0 24.8%
associate-*r*24.8%
unpow224.8%
Simplified24.8%
sqr-pow24.8%
metadata-eval24.8%
pow224.8%
metadata-eval24.8%
pow224.8%
fma-def24.8%
associate-*l*24.8%
Applied egg-rr24.8%
Taylor expanded in a around 0 90.3%
unpow290.3%
Simplified90.3%
Final simplification97.8%
(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 (fma (* a a) (* a a) (* (* 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 + fma((a * a), (a * a), ((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 + fma(Float64(a * a), Float64(a * a), Float64(Float64(a * a) * 4.0))); end return 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[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * 4.0), $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 + \mathsf{fma}\left(a \cdot a, a \cdot a, \left(a \cdot a\right) \cdot 4\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.8%
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-def5.2%
+-commutative5.2%
metadata-eval5.2%
Simplified5.2%
Taylor expanded in b around 0 24.8%
associate-*r*24.8%
unpow224.8%
Simplified24.8%
sqr-pow24.8%
metadata-eval24.8%
pow224.8%
metadata-eval24.8%
pow224.8%
fma-def24.8%
associate-*l*24.8%
Applied egg-rr24.8%
Taylor expanded in a around 0 90.3%
unpow290.3%
Simplified90.3%
Final simplification97.7%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1000000000000.0) (+ -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) <= 1000000000000.0) {
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) <= 1000000000000.0d0) 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) <= 1000000000000.0) {
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) <= 1000000000000.0: 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) <= 1000000000000.0) 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) <= 1000000000000.0) 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], 1000000000000.0], 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 1000000000000:\\
\;\;\;\;-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) < 1e12Initial program 85.6%
sub-neg85.6%
fma-def85.6%
fma-def85.6%
+-commutative85.6%
metadata-eval85.6%
Simplified85.6%
Taylor expanded in a around inf 97.5%
if 1e12 < (*.f64 b b) Initial program 67.1%
sub-neg67.1%
fma-def67.1%
fma-def69.7%
+-commutative69.7%
metadata-eval69.7%
Simplified69.7%
Taylor expanded in a around 0 64.8%
associate-+r+64.8%
associate-*r*64.8%
distribute-rgt-out77.7%
metadata-eval77.7%
distribute-lft-in77.7%
unpow277.7%
distribute-rgt-in77.7%
metadata-eval77.7%
Simplified77.7%
Taylor expanded in a around 0 93.5%
unpow293.5%
Simplified93.5%
+-commutative93.5%
sqr-pow93.3%
metadata-eval93.3%
pow293.3%
metadata-eval93.3%
pow293.3%
distribute-rgt-out93.3%
Applied egg-rr93.3%
Final simplification95.6%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1000000000000.0) (+ -1.0 (pow a 4.0)) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1000000000000.0) {
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) <= 1000000000000.0d0) 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) <= 1000000000000.0) {
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) <= 1000000000000.0: 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) <= 1000000000000.0) 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) <= 1000000000000.0) 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], 1000000000000.0], 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 1000000000000:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 1e12Initial program 85.6%
sub-neg85.6%
fma-def85.6%
fma-def85.6%
+-commutative85.6%
metadata-eval85.6%
Simplified85.6%
Taylor expanded in a around inf 97.5%
if 1e12 < (*.f64 b b) Initial program 67.1%
sub-neg67.1%
fma-def67.1%
fma-def69.7%
+-commutative69.7%
metadata-eval69.7%
Simplified69.7%
Taylor expanded in b around inf 93.5%
Final simplification95.7%
(FPCore (a b) :precision binary64 (if (or (<= a -4.8e+159) (not (<= a 6.2e+151))) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) (+ (* b b) 12.0)))))
double code(double a, double b) {
double tmp;
if ((a <= -4.8e+159) || !(a <= 6.2e+151)) {
tmp = -1.0 + ((a * 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 ((a <= (-4.8d+159)) .or. (.not. (a <= 6.2d+151))) then
tmp = (-1.0d0) + ((a * 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 ((a <= -4.8e+159) || !(a <= 6.2e+151)) {
tmp = -1.0 + ((a * a) * 4.0);
} else {
tmp = -1.0 + ((b * b) * ((b * b) + 12.0));
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -4.8e+159) or not (a <= 6.2e+151): tmp = -1.0 + ((a * a) * 4.0) else: tmp = -1.0 + ((b * b) * ((b * b) + 12.0)) return tmp
function code(a, b) tmp = 0.0 if ((a <= -4.8e+159) || !(a <= 6.2e+151)) tmp = Float64(-1.0 + Float64(Float64(a * 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 ((a <= -4.8e+159) || ~((a <= 6.2e+151))) tmp = -1.0 + ((a * a) * 4.0); else tmp = -1.0 + ((b * b) * ((b * b) + 12.0)); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -4.8e+159], N[Not[LessEqual[a, 6.2e+151]], $MachinePrecision]], N[(-1.0 + N[(N[(a * a), $MachinePrecision] * 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}\;a \leq -4.8 \cdot 10^{+159} \lor \neg \left(a \leq 6.2 \cdot 10^{+151}\right):\\
\;\;\;\;-1 + \left(a \cdot a\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\
\end{array}
\end{array}
if a < -4.8e159 or 6.2000000000000004e151 < a Initial program 37.7%
sub-neg37.7%
fma-def37.7%
fma-def37.7%
+-commutative37.7%
metadata-eval37.7%
Simplified37.7%
Taylor expanded in b around 0 49.2%
associate-*r*49.2%
unpow249.2%
Simplified49.2%
Taylor expanded in a around 0 98.6%
unpow298.6%
Simplified98.6%
if -4.8e159 < a < 6.2000000000000004e151Initial program 89.6%
sub-neg89.6%
fma-def89.6%
fma-def91.1%
+-commutative91.1%
metadata-eval91.1%
Simplified91.1%
Taylor expanded in a around 0 67.9%
associate-+r+67.9%
associate-*r*67.9%
distribute-rgt-out75.6%
metadata-eval75.6%
distribute-lft-in75.6%
unpow275.6%
distribute-rgt-in75.6%
metadata-eval75.6%
Simplified75.6%
Taylor expanded in a around 0 82.3%
unpow282.3%
Simplified82.3%
+-commutative82.3%
sqr-pow82.2%
metadata-eval82.2%
pow282.2%
metadata-eval82.2%
pow282.2%
distribute-rgt-out82.2%
Applied egg-rr82.2%
Final simplification86.1%
(FPCore (a b)
:precision binary64
(if (<= a -2.1e+87)
(+ -1.0 (* (- 1.0 a) (* a (* a 4.0))))
(if (<= a 6.2e+151)
(+ -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.1e+87) {
tmp = -1.0 + ((1.0 - a) * (a * (a * 4.0)));
} else if (a <= 6.2e+151) {
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.1d+87)) then
tmp = (-1.0d0) + ((1.0d0 - a) * (a * (a * 4.0d0)))
else if (a <= 6.2d+151) 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.1e+87) {
tmp = -1.0 + ((1.0 - a) * (a * (a * 4.0)));
} else if (a <= 6.2e+151) {
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.1e+87: tmp = -1.0 + ((1.0 - a) * (a * (a * 4.0))) elif a <= 6.2e+151: 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.1e+87) tmp = Float64(-1.0 + Float64(Float64(1.0 - a) * Float64(a * Float64(a * 4.0)))); elseif (a <= 6.2e+151) 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.1e+87) tmp = -1.0 + ((1.0 - a) * (a * (a * 4.0))); elseif (a <= 6.2e+151) 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.1e+87], N[(-1.0 + N[(N[(1.0 - a), $MachinePrecision] * N[(a * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 6.2e+151], 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.1 \cdot 10^{+87}:\\
\;\;\;\;-1 + \left(1 - a\right) \cdot \left(a \cdot \left(a \cdot 4\right)\right)\\
\mathbf{elif}\;a \leq 6.2 \cdot 10^{+151}:\\
\;\;\;\;-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.1e87Initial program 71.7%
sub-neg71.7%
fma-def71.7%
fma-def71.7%
+-commutative71.7%
metadata-eval71.7%
Simplified71.7%
Taylor expanded in b around 0 100.0%
associate-*r*100.0%
unpow2100.0%
Simplified100.0%
sqr-pow100.0%
metadata-eval100.0%
pow2100.0%
metadata-eval100.0%
pow2100.0%
fma-def100.0%
associate-*l*100.0%
Applied egg-rr100.0%
Taylor expanded in a around 0 94.0%
unpow294.0%
metadata-eval94.0%
associate-*r*94.0%
mul-1-neg94.0%
unpow394.0%
distribute-rgt-neg-out94.0%
associate-*l*94.0%
*-commutative94.0%
distribute-rgt1-in94.0%
+-commutative94.0%
sub-neg94.0%
associate-*r*94.0%
*-commutative94.0%
Simplified94.0%
if -2.1e87 < a < 6.2000000000000004e151Initial program 92.0%
sub-neg92.0%
fma-def92.0%
fma-def93.7%
+-commutative93.7%
metadata-eval93.7%
Simplified93.7%
Taylor expanded in a around 0 73.9%
associate-+r+73.9%
associate-*r*73.9%
distribute-rgt-out82.3%
metadata-eval82.3%
distribute-lft-in82.3%
unpow282.3%
distribute-rgt-in82.3%
metadata-eval82.3%
Simplified82.3%
Taylor expanded in a around 0 86.2%
unpow286.2%
Simplified86.2%
+-commutative86.2%
sqr-pow86.1%
metadata-eval86.1%
pow286.1%
metadata-eval86.1%
pow286.1%
distribute-rgt-out86.1%
Applied egg-rr86.1%
if 6.2000000000000004e151 < 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 97.2%
unpow297.2%
Simplified97.2%
Final simplification88.9%
(FPCore (a b) :precision binary64 (if (<= (* b b) 1e+255) (+ -1.0 (* (* a a) 4.0)) (+ -1.0 (* (* b b) 12.0))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 1e+255) {
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) <= 1d+255) 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) <= 1e+255) {
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) <= 1e+255: 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) <= 1e+255) 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) <= 1e+255) 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], 1e+255], 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 10^{+255}:\\
\;\;\;\;-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) < 9.99999999999999988e254Initial program 83.0%
sub-neg83.0%
fma-def83.0%
fma-def83.0%
+-commutative83.0%
metadata-eval83.0%
Simplified83.0%
Taylor expanded in b around 0 68.7%
associate-*r*68.7%
unpow268.7%
Simplified68.7%
Taylor expanded in a around 0 64.0%
unpow264.0%
Simplified64.0%
if 9.99999999999999988e254 < (*.f64 b b) Initial program 62.5%
sub-neg62.5%
fma-def62.5%
fma-def66.7%
+-commutative66.7%
metadata-eval66.7%
Simplified66.7%
Taylor expanded in a around 0 56.9%
associate-+r+56.9%
associate-*r*56.9%
distribute-rgt-out77.8%
metadata-eval77.8%
distribute-lft-in77.8%
unpow277.8%
distribute-rgt-in77.8%
metadata-eval77.8%
Simplified77.8%
Taylor expanded in b around 0 72.8%
+-commutative72.8%
*-commutative72.8%
fma-udef72.8%
*-commutative72.8%
unpow272.8%
fma-udef72.8%
*-commutative72.8%
fma-def72.8%
Simplified72.8%
Taylor expanded in a around 0 92.5%
unpow292.5%
*-commutative92.5%
associate-*l*92.5%
Simplified92.5%
Taylor expanded in b around 0 92.5%
unpow292.5%
Simplified92.5%
Final simplification72.0%
(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 77.2%
sub-neg77.2%
fma-def77.2%
fma-def78.4%
+-commutative78.4%
metadata-eval78.4%
Simplified78.4%
Taylor expanded in b around 0 54.0%
associate-*r*54.0%
unpow254.0%
Simplified54.0%
Taylor expanded in a around 0 52.0%
unpow252.0%
Simplified52.0%
Final simplification52.0%
(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 77.2%
sub-neg77.2%
fma-def77.2%
fma-def78.4%
+-commutative78.4%
metadata-eval78.4%
Simplified78.4%
Taylor expanded in b around 0 54.0%
associate-*r*54.0%
unpow254.0%
Simplified54.0%
Taylor expanded in a around 0 27.1%
Final simplification27.1%
herbie shell --seed 2023278
(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))