
(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 6 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)
(+ (* 4.0 (fma (* a a) (- 1.0 a) (* b (* b (+ a 3.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) + ((4.0 * fma((a * a), (1.0 - a), (b * (b * (a + 3.0))))) + -1.0);
} else {
tmp = 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) + Float64(Float64(4.0 * fma(Float64(a * a), Float64(1.0 - a), Float64(b * Float64(b * Float64(a + 3.0))))) + -1.0)); else tmp = 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[(N[(4.0 * N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision] + N[(b * N[(b * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $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} + \left(4 \cdot \mathsf{fma}\left(a \cdot a, 1 - a, b \cdot \left(b \cdot \left(a + 3\right)\right)\right) + -1\right)\\
\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%
associate--l+99.8%
fma-def99.8%
sqr-neg99.8%
fma-def99.8%
distribute-rgt-in99.8%
sqr-neg99.8%
distribute-rgt-in99.8%
fma-def99.8%
sqr-neg99.8%
Simplified99.8%
fma-def99.8%
expm1-log1p-u98.0%
expm1-udef98.0%
add-sqr-sqrt98.0%
pow298.0%
hypot-def98.0%
Applied egg-rr98.0%
expm1-def98.0%
expm1-log1p99.8%
unpow299.8%
pow-sqr100.0%
metadata-eval100.0%
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%
associate--l+0.0%
fma-def0.0%
sqr-neg0.0%
fma-def0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
fma-def0.0%
sqr-neg0.0%
Simplified9.0%
Taylor expanded in a around inf 94.4%
Final simplification98.5%
(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-def0.0%
sqr-neg0.0%
fma-def0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
fma-def0.0%
sqr-neg0.0%
Simplified9.0%
Taylor expanded in a around inf 94.4%
Final simplification98.4%
(FPCore (a b)
:precision binary64
(if (<= a -1.15e+49)
(pow a 4.0)
(if (<= a -1.1e-64)
(pow b 4.0)
(if (<= a -1.7e-202)
-1.0
(if (<= a -1.26e-281)
(pow b 4.0)
(if (<= a 3.7e-246)
-1.0
(if (<= a 1.65e-200)
(pow b 4.0)
(if (<= a 6e-119)
-1.0
(if (<= a 3e+30) (pow b 4.0) (pow a 4.0))))))))))
double code(double a, double b) {
double tmp;
if (a <= -1.15e+49) {
tmp = pow(a, 4.0);
} else if (a <= -1.1e-64) {
tmp = pow(b, 4.0);
} else if (a <= -1.7e-202) {
tmp = -1.0;
} else if (a <= -1.26e-281) {
tmp = pow(b, 4.0);
} else if (a <= 3.7e-246) {
tmp = -1.0;
} else if (a <= 1.65e-200) {
tmp = pow(b, 4.0);
} else if (a <= 6e-119) {
tmp = -1.0;
} else if (a <= 3e+30) {
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 <= (-1.15d+49)) then
tmp = a ** 4.0d0
else if (a <= (-1.1d-64)) then
tmp = b ** 4.0d0
else if (a <= (-1.7d-202)) then
tmp = -1.0d0
else if (a <= (-1.26d-281)) then
tmp = b ** 4.0d0
else if (a <= 3.7d-246) then
tmp = -1.0d0
else if (a <= 1.65d-200) then
tmp = b ** 4.0d0
else if (a <= 6d-119) then
tmp = -1.0d0
else if (a <= 3d+30) 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 <= -1.15e+49) {
tmp = Math.pow(a, 4.0);
} else if (a <= -1.1e-64) {
tmp = Math.pow(b, 4.0);
} else if (a <= -1.7e-202) {
tmp = -1.0;
} else if (a <= -1.26e-281) {
tmp = Math.pow(b, 4.0);
} else if (a <= 3.7e-246) {
tmp = -1.0;
} else if (a <= 1.65e-200) {
tmp = Math.pow(b, 4.0);
} else if (a <= 6e-119) {
tmp = -1.0;
} else if (a <= 3e+30) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.15e+49: tmp = math.pow(a, 4.0) elif a <= -1.1e-64: tmp = math.pow(b, 4.0) elif a <= -1.7e-202: tmp = -1.0 elif a <= -1.26e-281: tmp = math.pow(b, 4.0) elif a <= 3.7e-246: tmp = -1.0 elif a <= 1.65e-200: tmp = math.pow(b, 4.0) elif a <= 6e-119: tmp = -1.0 elif a <= 3e+30: tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.15e+49) tmp = a ^ 4.0; elseif (a <= -1.1e-64) tmp = b ^ 4.0; elseif (a <= -1.7e-202) tmp = -1.0; elseif (a <= -1.26e-281) tmp = b ^ 4.0; elseif (a <= 3.7e-246) tmp = -1.0; elseif (a <= 1.65e-200) tmp = b ^ 4.0; elseif (a <= 6e-119) tmp = -1.0; elseif (a <= 3e+30) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.15e+49) tmp = a ^ 4.0; elseif (a <= -1.1e-64) tmp = b ^ 4.0; elseif (a <= -1.7e-202) tmp = -1.0; elseif (a <= -1.26e-281) tmp = b ^ 4.0; elseif (a <= 3.7e-246) tmp = -1.0; elseif (a <= 1.65e-200) tmp = b ^ 4.0; elseif (a <= 6e-119) tmp = -1.0; elseif (a <= 3e+30) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.15e+49], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, -1.1e-64], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, -1.7e-202], -1.0, If[LessEqual[a, -1.26e-281], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, 3.7e-246], -1.0, If[LessEqual[a, 1.65e-200], N[Power[b, 4.0], $MachinePrecision], If[LessEqual[a, 6e-119], -1.0, If[LessEqual[a, 3e+30], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.15 \cdot 10^{+49}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq -1.1 \cdot 10^{-64}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq -1.7 \cdot 10^{-202}:\\
\;\;\;\;-1\\
\mathbf{elif}\;a \leq -1.26 \cdot 10^{-281}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq 3.7 \cdot 10^{-246}:\\
\;\;\;\;-1\\
\mathbf{elif}\;a \leq 1.65 \cdot 10^{-200}:\\
\;\;\;\;{b}^{4}\\
\mathbf{elif}\;a \leq 6 \cdot 10^{-119}:\\
\;\;\;\;-1\\
\mathbf{elif}\;a \leq 3 \cdot 10^{+30}:\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -1.15000000000000001e49 or 2.99999999999999978e30 < a Initial program 44.4%
associate--l+44.4%
fma-def44.4%
sqr-neg44.4%
fma-def44.4%
distribute-rgt-in44.4%
sqr-neg44.4%
distribute-rgt-in44.4%
fma-def44.4%
sqr-neg44.4%
Simplified49.5%
Taylor expanded in a around inf 96.8%
if -1.15000000000000001e49 < a < -1.1e-64 or -1.70000000000000006e-202 < a < -1.26e-281 or 3.7e-246 < a < 1.6499999999999999e-200 or 6.0000000000000004e-119 < a < 2.99999999999999978e30Initial program 97.2%
associate--l+97.2%
fma-def97.2%
sqr-neg97.2%
fma-def97.2%
distribute-rgt-in97.2%
sqr-neg97.2%
distribute-rgt-in97.2%
fma-def97.2%
sqr-neg97.2%
Simplified97.2%
Taylor expanded in b around inf 69.0%
if -1.1e-64 < a < -1.70000000000000006e-202 or -1.26e-281 < a < 3.7e-246 or 1.6499999999999999e-200 < a < 6.0000000000000004e-119Initial program 99.9%
associate--l+99.9%
fma-def99.9%
sqr-neg99.9%
fma-def99.9%
distribute-rgt-in99.9%
sqr-neg99.9%
distribute-rgt-in99.9%
fma-def99.9%
sqr-neg99.9%
Simplified99.9%
Taylor expanded in a around inf 96.1%
mul-1-neg96.1%
Simplified96.1%
Taylor expanded in a around 0 96.2%
Taylor expanded in b around 0 73.9%
Final simplification82.8%
(FPCore (a b) :precision binary64 (if (or (<= a -9.2e+48) (not (<= a 1.18e+27))) (pow a 4.0) (+ (pow b 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if ((a <= -9.2e+48) || !(a <= 1.18e+27)) {
tmp = pow(a, 4.0);
} else {
tmp = pow(b, 4.0) + -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 <= (-9.2d+48)) .or. (.not. (a <= 1.18d+27))) then
tmp = a ** 4.0d0
else
tmp = (b ** 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -9.2e+48) || !(a <= 1.18e+27)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -9.2e+48) or not (a <= 1.18e+27): tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -9.2e+48) || !(a <= 1.18e+27)) tmp = a ^ 4.0; else tmp = Float64((b ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -9.2e+48) || ~((a <= 1.18e+27))) tmp = a ^ 4.0; else tmp = (b ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -9.2e+48], N[Not[LessEqual[a, 1.18e+27]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -9.2 \cdot 10^{+48} \lor \neg \left(a \leq 1.18 \cdot 10^{+27}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + -1\\
\end{array}
\end{array}
if a < -9.2000000000000001e48 or 1.18000000000000006e27 < a Initial program 44.4%
associate--l+44.4%
fma-def44.4%
sqr-neg44.4%
fma-def44.4%
distribute-rgt-in44.4%
sqr-neg44.4%
distribute-rgt-in44.4%
fma-def44.4%
sqr-neg44.4%
Simplified49.5%
Taylor expanded in a around inf 96.8%
if -9.2000000000000001e48 < a < 1.18000000000000006e27Initial program 98.4%
associate--l+98.4%
fma-def98.4%
sqr-neg98.4%
fma-def98.4%
distribute-rgt-in98.4%
sqr-neg98.4%
distribute-rgt-in98.4%
fma-def98.4%
sqr-neg98.4%
Simplified98.4%
Taylor expanded in a around inf 96.2%
mul-1-neg96.2%
Simplified96.2%
Taylor expanded in a around 0 93.5%
Final simplification95.0%
(FPCore (a b) :precision binary64 (if (or (<= a -0.42) (not (<= a 1.9e-32))) (pow a 4.0) -1.0))
double code(double a, double b) {
double tmp;
if ((a <= -0.42) || !(a <= 1.9e-32)) {
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 <= 1.9d-32))) 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 <= 1.9e-32)) {
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 <= 1.9e-32): tmp = math.pow(a, 4.0) else: tmp = -1.0 return tmp
function code(a, b) tmp = 0.0 if ((a <= -0.42) || !(a <= 1.9e-32)) 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 <= 1.9e-32))) 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, 1.9e-32]], $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 1.9 \cdot 10^{-32}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if a < -0.419999999999999984 or 1.90000000000000004e-32 < a Initial program 49.9%
associate--l+49.9%
fma-def49.9%
sqr-neg49.9%
fma-def49.9%
distribute-rgt-in49.9%
sqr-neg49.9%
distribute-rgt-in49.9%
fma-def49.9%
sqr-neg49.9%
Simplified54.4%
Taylor expanded in a around inf 87.2%
if -0.419999999999999984 < a < 1.90000000000000004e-32Initial program 99.8%
associate--l+99.8%
fma-def99.8%
sqr-neg99.8%
fma-def99.8%
distribute-rgt-in99.8%
sqr-neg99.8%
distribute-rgt-in99.8%
fma-def99.8%
sqr-neg99.8%
Simplified99.9%
Taylor expanded in a around inf 96.0%
mul-1-neg96.0%
Simplified96.0%
Taylor expanded in a around 0 96.2%
Taylor expanded in b around 0 51.6%
Final simplification70.2%
(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 73.7%
associate--l+73.7%
fma-def73.7%
sqr-neg73.7%
fma-def73.7%
distribute-rgt-in73.7%
sqr-neg73.7%
distribute-rgt-in73.7%
fma-def73.7%
sqr-neg73.7%
Simplified76.1%
Taylor expanded in a around inf 80.7%
mul-1-neg80.7%
Simplified80.7%
Taylor expanded in a around 0 68.8%
Taylor expanded in b around 0 24.9%
Final simplification24.9%
herbie shell --seed 2023322
(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))