
(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
(+
(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)
(cbrt (pow (fma (pow a 2.0) (fma a (+ a -4.0) 4.0) -1.0) 3.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 = cbrt(pow(fma(pow(a, 2.0), fma(a, (a + -4.0), 4.0), -1.0), 3.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 = cbrt((fma((a ^ 2.0), fma(a, Float64(a + -4.0), 4.0), -1.0) ^ 3.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[Power[N[Power[N[(N[Power[a, 2.0], $MachinePrecision] * N[(a * N[(a + -4.0), $MachinePrecision] + 4.0), $MachinePrecision] + -1.0), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $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}:\\
\;\;\;\;\sqrt[3]{{\left(\mathsf{fma}\left({a}^{2}, \mathsf{fma}\left(a, a + -4, 4\right), -1\right)\right)}^{3}}\\
\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%
associate--l+0.0%
fma-define0.0%
sqr-neg0.0%
fma-define0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
fma-define0.0%
sqr-neg0.0%
Simplified6.8%
Taylor expanded in b around 0 27.9%
associate--l+27.9%
associate-*r*27.9%
fma-define47.0%
sub-neg47.0%
metadata-eval47.0%
Simplified47.0%
Taylor expanded in a around 0 92.2%
fma-neg92.2%
sub-neg92.2%
metadata-eval92.2%
metadata-eval92.2%
Simplified92.2%
metadata-eval92.2%
sub-neg92.2%
metadata-eval92.2%
fma-neg92.2%
add-cbrt-cube97.4%
pow397.4%
fma-neg97.4%
+-commutative97.4%
fma-define97.4%
sub-neg97.4%
metadata-eval97.4%
metadata-eval97.4%
Applied egg-rr97.4%
Final simplification99.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) (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 = 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 = 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 = 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 = 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 = 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[Power[a, 4.0], $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}:\\
\;\;\;\;{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.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%
associate--l+0.0%
fma-define0.0%
sqr-neg0.0%
fma-define0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
fma-define0.0%
sqr-neg0.0%
Simplified6.8%
Taylor expanded in a around inf 92.2%
Final simplification97.7%
(FPCore (a b)
:precision binary64
(if (<= a -3.2e+15)
(pow a 4.0)
(if (<= a -2.05e-14)
(pow b 4.0)
(if (<= a -1.2e-63)
-1.0
(if (<= a -3.6e-154)
(pow b 4.0)
(if (<= a 3.6e-87)
-1.0
(if (<= a 8000000000000.0) (pow b 4.0) (pow a 4.0))))))))
double code(double a, double b) {
double tmp;
if (a <= -3.2e+15) {
tmp = pow(a, 4.0);
} else if (a <= -2.05e-14) {
tmp = pow(b, 4.0);
} else if (a <= -1.2e-63) {
tmp = -1.0;
} else if (a <= -3.6e-154) {
tmp = pow(b, 4.0);
} else if (a <= 3.6e-87) {
tmp = -1.0;
} else if (a <= 8000000000000.0) {
tmp = pow(b, 4.0);
} else {
tmp = pow(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 <= (-3.2d+15)) then
tmp = a ** 4.0d0
else if (a <= (-2.05d-14)) then
tmp = b ** 4.0d0
else if (a <= (-1.2d-63)) then
tmp = -1.0d0
else if (a <= (-3.6d-154)) then
tmp = b ** 4.0d0
else if (a <= 3.6d-87) then
tmp = -1.0d0
else if (a <= 8000000000000.0d0) then
tmp = b ** 4.0d0
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -3.2e+15) {
tmp = Math.pow(a, 4.0);
} else if (a <= -2.05e-14) {
tmp = Math.pow(b, 4.0);
} else if (a <= -1.2e-63) {
tmp = -1.0;
} else if (a <= -3.6e-154) {
tmp = Math.pow(b, 4.0);
} else if (a <= 3.6e-87) {
tmp = -1.0;
} else if (a <= 8000000000000.0) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -3.2e+15: tmp = math.pow(a, 4.0) elif a <= -2.05e-14: tmp = math.pow(b, 4.0) elif a <= -1.2e-63: tmp = -1.0 elif a <= -3.6e-154: tmp = math.pow(b, 4.0) elif a <= 3.6e-87: tmp = -1.0 elif a <= 8000000000000.0: tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -3.2e+15) tmp = a ^ 4.0; elseif (a <= -2.05e-14) tmp = b ^ 4.0; elseif (a <= -1.2e-63) tmp = -1.0; elseif (a <= -3.6e-154) tmp = b ^ 4.0; elseif (a <= 3.6e-87) tmp = -1.0; elseif (a <= 8000000000000.0) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -3.2e+15) tmp = a ^ 4.0; elseif (a <= -2.05e-14) tmp = b ^ 4.0; elseif (a <= -1.2e-63) tmp = -1.0; elseif (a <= -3.6e-154) tmp = b ^ 4.0; elseif (a <= 3.6e-87) tmp = -1.0; elseif (a <= 8000000000000.0) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -3.2e+15], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, -2.05e-14], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, -1.2e-63], -1.0, If[LessEqual[a, -3.6e-154], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, 3.6e-87], -1.0, If[LessEqual[a, 8000000000000.0], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.2 \cdot 10^{+15}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq -2.05 \cdot 10^{-14}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq -1.2 \cdot 10^{-63}:\\
\;\;\;\;-1\\
\mathbf{elif}\;a \leq -3.6 \cdot 10^{-154}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq 3.6 \cdot 10^{-87}:\\
\;\;\;\;-1\\
\mathbf{elif}\;a \leq 8000000000000:\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -3.2e15 or 8e12 < a Initial program 42.1%
associate--l+42.1%
fma-define42.1%
sqr-neg42.1%
fma-define42.1%
distribute-rgt-in42.1%
sqr-neg42.1%
distribute-rgt-in42.1%
fma-define42.1%
sqr-neg42.1%
Simplified46.2%
Taylor expanded in a around inf 95.4%
if -3.2e15 < a < -2.0500000000000001e-14 or -1.2e-63 < a < -3.6000000000000003e-154 or 3.59999999999999993e-87 < a < 8e12Initial program 95.0%
associate--l+95.0%
fma-define95.0%
sqr-neg95.0%
fma-define95.0%
distribute-rgt-in95.0%
sqr-neg95.0%
distribute-rgt-in95.0%
fma-define95.0%
sqr-neg95.0%
Simplified95.0%
Taylor expanded in b around inf 76.6%
if -2.0500000000000001e-14 < a < -1.2e-63 or -3.6000000000000003e-154 < a < 3.59999999999999993e-87Initial program 99.9%
associate--l+99.9%
fma-define99.9%
sqr-neg99.9%
fma-define99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
fma-define99.9%
sqr-neg99.9%
Simplified99.9%
Taylor expanded in b around 0 65.6%
associate--l+65.6%
associate-*r*65.6%
fma-define65.6%
sub-neg65.6%
metadata-eval65.6%
Simplified65.6%
Taylor expanded in a around 0 65.6%
Final simplification81.7%
(FPCore (a b) :precision binary64 (if (<= b 9.4e+20) (fma (* a (+ 4.0 (* a (- a 4.0)))) a -1.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if (b <= 9.4e+20) {
tmp = fma((a * (4.0 + (a * (a - 4.0)))), a, -1.0);
} else {
tmp = pow(b, 4.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 9.4e+20) tmp = fma(Float64(a * Float64(4.0 + Float64(a * Float64(a - 4.0)))), a, -1.0); else tmp = b ^ 4.0; end return tmp end
code[a_, b_] := If[LessEqual[b, 9.4e+20], N[(N[(a * N[(4.0 + N[(a * N[(a - 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a + -1.0), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9.4 \cdot 10^{+20}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot \left(4 + a \cdot \left(a - 4\right)\right), a, -1\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 9.4e20Initial program 74.6%
associate--l+74.6%
fma-define74.6%
sqr-neg74.6%
fma-define74.6%
distribute-rgt-in74.6%
sqr-neg74.6%
distribute-rgt-in74.6%
fma-define74.6%
sqr-neg74.6%
Simplified76.6%
Taylor expanded in b around 0 61.9%
associate--l+61.9%
associate-*r*61.9%
fma-define67.9%
sub-neg67.9%
metadata-eval67.9%
Simplified67.9%
Taylor expanded in a around 0 79.2%
*-commutative79.2%
unpow279.2%
associate-*r*79.2%
fma-neg79.2%
+-commutative79.2%
fma-define79.2%
sub-neg79.2%
metadata-eval79.2%
metadata-eval79.2%
Applied egg-rr79.2%
Taylor expanded in a around 0 79.2%
if 9.4e20 < b Initial program 59.2%
associate--l+59.2%
fma-define59.2%
sqr-neg59.2%
fma-define59.2%
distribute-rgt-in59.2%
sqr-neg59.2%
distribute-rgt-in59.2%
fma-define59.2%
sqr-neg59.2%
Simplified61.0%
Taylor expanded in b around inf 91.4%
Final simplification81.8%
(FPCore (a b) :precision binary64 (if (<= b 3e-32) (* (+ 1.0 (* a 2.0)) (fma a 2.0 -1.0)) (if (<= b 1.4e+20) (pow a 4.0) (pow b 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 3e-32) {
tmp = (1.0 + (a * 2.0)) * fma(a, 2.0, -1.0);
} else if (b <= 1.4e+20) {
tmp = pow(a, 4.0);
} else {
tmp = pow(b, 4.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 3e-32) tmp = Float64(Float64(1.0 + Float64(a * 2.0)) * fma(a, 2.0, -1.0)); elseif (b <= 1.4e+20) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
code[a_, b_] := If[LessEqual[b, 3e-32], N[(N[(1.0 + N[(a * 2.0), $MachinePrecision]), $MachinePrecision] * N[(a * 2.0 + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.4e+20], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3 \cdot 10^{-32}:\\
\;\;\;\;\left(1 + a \cdot 2\right) \cdot \mathsf{fma}\left(a, 2, -1\right)\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{+20}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 3e-32Initial program 74.9%
associate--l+74.9%
fma-define74.9%
sqr-neg74.9%
fma-define74.9%
distribute-rgt-in74.9%
sqr-neg74.9%
distribute-rgt-in74.9%
fma-define74.9%
sqr-neg74.9%
Simplified76.9%
Taylor expanded in b around 0 61.8%
associate--l+61.8%
associate-*r*61.8%
fma-define66.9%
sub-neg66.9%
metadata-eval66.9%
Simplified66.9%
Taylor expanded in a around 0 59.4%
add-sqr-sqrt59.4%
difference-of-sqr-159.4%
*-commutative59.4%
sqrt-prod59.4%
sqrt-pow146.3%
metadata-eval46.3%
pow146.3%
metadata-eval46.3%
*-commutative46.3%
sqrt-prod46.3%
sqrt-pow159.4%
metadata-eval59.4%
pow159.4%
metadata-eval59.4%
fma-neg59.4%
metadata-eval59.4%
Applied egg-rr59.4%
if 3e-32 < b < 1.4e20Initial program 66.4%
associate--l+66.4%
fma-define66.4%
sqr-neg66.4%
fma-define66.4%
distribute-rgt-in66.4%
sqr-neg66.4%
distribute-rgt-in66.4%
fma-define66.4%
sqr-neg66.4%
Simplified66.4%
Taylor expanded in a around inf 83.8%
if 1.4e20 < b Initial program 59.2%
associate--l+59.2%
fma-define59.2%
sqr-neg59.2%
fma-define59.2%
distribute-rgt-in59.2%
sqr-neg59.2%
distribute-rgt-in59.2%
fma-define59.2%
sqr-neg59.2%
Simplified61.0%
Taylor expanded in b around inf 91.4%
Final simplification66.7%
(FPCore (a b) :precision binary64 (if (or (<= a -0.42) (not (<= a 2.4))) (pow a 4.0) -1.0))
double code(double a, double b) {
double tmp;
if ((a <= -0.42) || !(a <= 2.4)) {
tmp = pow(a, 4.0);
} else {
tmp = -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-0.42d0)) .or. (.not. (a <= 2.4d0))) then
tmp = a ** 4.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -0.42) || !(a <= 2.4)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -0.42) or not (a <= 2.4): tmp = math.pow(a, 4.0) else: tmp = -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -0.42) || !(a <= 2.4)) tmp = a ^ 4.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -0.42) || ~((a <= 2.4))) tmp = a ^ 4.0; else tmp = -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -0.42], N[Not[LessEqual[a, 2.4]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.42 \lor \neg \left(a \leq 2.4\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if a < -0.419999999999999984 or 2.39999999999999991 < a Initial program 42.8%
associate--l+42.8%
fma-define42.8%
sqr-neg42.8%
fma-define42.8%
distribute-rgt-in42.8%
sqr-neg42.8%
distribute-rgt-in42.8%
fma-define42.8%
sqr-neg42.8%
Simplified46.7%
Taylor expanded in a around inf 91.9%
if -0.419999999999999984 < a < 2.39999999999999991Initial program 99.9%
associate--l+99.9%
fma-define99.9%
sqr-neg99.9%
fma-define99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
fma-define99.9%
sqr-neg99.9%
Simplified99.9%
Taylor expanded in b around 0 53.8%
associate--l+53.8%
associate-*r*53.8%
fma-define53.8%
sub-neg53.8%
metadata-eval53.8%
Simplified53.8%
Taylor expanded in a around 0 52.8%
Final simplification72.4%
(FPCore (a b) :precision binary64 (if (<= b 9.5e-33) (fma (* a 4.0) a -1.0) (if (<= b 1.85e+20) (pow a 4.0) (pow b 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 9.5e-33) {
tmp = fma((a * 4.0), a, -1.0);
} else if (b <= 1.85e+20) {
tmp = pow(a, 4.0);
} else {
tmp = pow(b, 4.0);
}
return tmp;
}
function code(a, b) tmp = 0.0 if (b <= 9.5e-33) tmp = fma(Float64(a * 4.0), a, -1.0); elseif (b <= 1.85e+20) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
code[a_, b_] := If[LessEqual[b, 9.5e-33], N[(N[(a * 4.0), $MachinePrecision] * a + -1.0), $MachinePrecision], If[LessEqual[b, 1.85e+20], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 9.5 \cdot 10^{-33}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot 4, a, -1\right)\\
\mathbf{elif}\;b \leq 1.85 \cdot 10^{+20}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 9.50000000000000019e-33Initial program 74.9%
associate--l+74.9%
fma-define74.9%
sqr-neg74.9%
fma-define74.9%
distribute-rgt-in74.9%
sqr-neg74.9%
distribute-rgt-in74.9%
fma-define74.9%
sqr-neg74.9%
Simplified76.9%
Taylor expanded in b around 0 61.8%
associate--l+61.8%
associate-*r*61.8%
fma-define66.9%
sub-neg66.9%
metadata-eval66.9%
Simplified66.9%
Taylor expanded in a around 0 59.4%
unpow259.4%
associate-*r*59.4%
*-commutative59.4%
fma-neg59.4%
metadata-eval59.4%
Applied egg-rr59.4%
if 9.50000000000000019e-33 < b < 1.85e20Initial program 66.4%
associate--l+66.4%
fma-define66.4%
sqr-neg66.4%
fma-define66.4%
distribute-rgt-in66.4%
sqr-neg66.4%
distribute-rgt-in66.4%
fma-define66.4%
sqr-neg66.4%
Simplified66.4%
Taylor expanded in a around inf 83.8%
if 1.85e20 < b Initial program 59.2%
associate--l+59.2%
fma-define59.2%
sqr-neg59.2%
fma-define59.2%
distribute-rgt-in59.2%
sqr-neg59.2%
distribute-rgt-in59.2%
fma-define59.2%
sqr-neg59.2%
Simplified61.0%
Taylor expanded in b around inf 91.4%
Final simplification66.7%
(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 71.4%
associate--l+71.4%
fma-define71.4%
sqr-neg71.4%
fma-define71.4%
distribute-rgt-in71.4%
sqr-neg71.4%
distribute-rgt-in71.4%
fma-define71.4%
sqr-neg71.4%
Simplified73.3%
Taylor expanded in b around 0 54.8%
associate--l+54.8%
associate-*r*54.8%
fma-define60.3%
sub-neg60.3%
metadata-eval60.3%
Simplified60.3%
Taylor expanded in a around 0 26.8%
Final simplification26.8%
herbie shell --seed 2024054
(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))