
(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 10 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%
Simplified99.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-def1.7%
+-commutative1.7%
metadata-eval1.7%
Simplified1.7%
Taylor expanded in a around inf 98.4%
Final simplification99.6%
(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)
(+ (pow (fma a a (* b b)) 2.0) (fma 4.0 (fma a (* a (- 1.0 a)) t_0) -1.0))
(+ -1.0 (pow 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 = pow(fma(a, a, (b * b)), 2.0) + fma(4.0, fma(a, (a * (1.0 - a)), t_0), -1.0);
} else {
tmp = -1.0 + pow(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 = Float64((fma(a, a, Float64(b * b)) ^ 2.0) + fma(4.0, fma(a, Float64(a * Float64(1.0 - a)), t_0), -1.0)); else tmp = Float64(-1.0 + (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[(N[Power[N[(a * a + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(a * N[(a * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[a, 4.0], $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:\\
\;\;\;\;{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \mathsf{fma}\left(4, \mathsf{fma}\left(a, a \cdot \left(1 - a\right), t_0\right), -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%
fma-def99.9%
fma-neg99.9%
associate-*l*99.9%
fma-def99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.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-def1.7%
+-commutative1.7%
metadata-eval1.7%
Simplified1.7%
Taylor expanded in a around inf 98.4%
Final simplification99.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) (+ -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-def1.7%
+-commutative1.7%
metadata-eval1.7%
Simplified1.7%
Taylor expanded in a around inf 98.4%
Final simplification99.5%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+50) (+ (pow a 4.0) (+ -1.0 (* a (* a 4.0)))) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+50) {
tmp = pow(a, 4.0) + (-1.0 + (a * (a * 4.0)));
} else {
tmp = 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) <= 2d+50) then
tmp = (a ** 4.0d0) + ((-1.0d0) + (a * (a * 4.0d0)))
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+50) {
tmp = Math.pow(a, 4.0) + (-1.0 + (a * (a * 4.0)));
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+50: tmp = math.pow(a, 4.0) + (-1.0 + (a * (a * 4.0))) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+50) tmp = Float64((a ^ 4.0) + Float64(-1.0 + Float64(a * Float64(a * 4.0)))); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+50) tmp = (a ^ 4.0) + (-1.0 + (a * (a * 4.0))); else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+50], N[(N[Power[a, 4.0], $MachinePrecision] + N[(-1.0 + N[(a * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+50}:\\
\;\;\;\;{a}^{4} + \left(-1 + a \cdot \left(a \cdot 4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 2.0000000000000002e50Initial program 85.4%
associate--l+85.4%
fma-def85.4%
fma-neg85.4%
associate-*l*85.4%
fma-def85.4%
+-commutative85.4%
metadata-eval85.4%
Simplified85.4%
Taylor expanded in b around 0 84.1%
associate--l+84.2%
unpow284.2%
Simplified84.2%
Taylor expanded in a around 0 97.0%
*-commutative97.0%
unpow297.0%
associate-*l*97.0%
Simplified97.0%
if 2.0000000000000002e50 < (*.f64 b b) Initial program 66.0%
sub-neg66.0%
fma-def66.0%
fma-def66.9%
+-commutative66.9%
metadata-eval66.9%
Simplified66.9%
Taylor expanded in a around 0 60.3%
associate-+r+60.3%
associate-*r*60.3%
distribute-rgt-out79.8%
metadata-eval79.8%
distribute-lft-in79.8%
+-commutative79.8%
unpow279.8%
distribute-lft-in79.8%
metadata-eval79.8%
Simplified79.8%
Taylor expanded in a around 0 95.2%
unpow295.2%
Simplified95.2%
Taylor expanded in b around inf 95.2%
Final simplification96.2%
(FPCore (a b) :precision binary64 (if (<= (* b b) 2e+50) (+ -1.0 (pow a 4.0)) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+50) {
tmp = -1.0 + pow(a, 4.0);
} else {
tmp = 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) <= 2d+50) then
tmp = (-1.0d0) + (a ** 4.0d0)
else
tmp = b ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 2e+50) {
tmp = -1.0 + Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 2e+50: tmp = -1.0 + math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 2e+50) tmp = Float64(-1.0 + (a ^ 4.0)); else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 2e+50) tmp = -1.0 + (a ^ 4.0); else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 2e+50], N[(-1.0 + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 2 \cdot 10^{+50}:\\
\;\;\;\;-1 + {a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if (*.f64 b b) < 2.0000000000000002e50Initial program 85.4%
sub-neg85.4%
fma-def85.4%
fma-def85.4%
+-commutative85.4%
metadata-eval85.4%
Simplified85.4%
Taylor expanded in a around inf 96.8%
if 2.0000000000000002e50 < (*.f64 b b) Initial program 66.0%
sub-neg66.0%
fma-def66.0%
fma-def66.9%
+-commutative66.9%
metadata-eval66.9%
Simplified66.9%
Taylor expanded in a around 0 60.3%
associate-+r+60.3%
associate-*r*60.3%
distribute-rgt-out79.8%
metadata-eval79.8%
distribute-lft-in79.8%
+-commutative79.8%
unpow279.8%
distribute-lft-in79.8%
metadata-eval79.8%
Simplified79.8%
Taylor expanded in a around 0 95.2%
unpow295.2%
Simplified95.2%
Taylor expanded in b around inf 95.2%
Final simplification96.1%
(FPCore (a b) :precision binary64 (if (<= a -1.3) (pow a 4.0) (if (<= a 1550000000.0) (+ -1.0 (* b (* b 12.0))) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -1.3) {
tmp = pow(a, 4.0);
} else if (a <= 1550000000.0) {
tmp = -1.0 + (b * (b * 12.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.3d0)) then
tmp = a ** 4.0d0
else if (a <= 1550000000.0d0) then
tmp = (-1.0d0) + (b * (b * 12.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.3) {
tmp = Math.pow(a, 4.0);
} else if (a <= 1550000000.0) {
tmp = -1.0 + (b * (b * 12.0));
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1.3: tmp = math.pow(a, 4.0) elif a <= 1550000000.0: tmp = -1.0 + (b * (b * 12.0)) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -1.3) tmp = a ^ 4.0; elseif (a <= 1550000000.0) tmp = Float64(-1.0 + Float64(b * Float64(b * 12.0))); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1.3) tmp = a ^ 4.0; elseif (a <= 1550000000.0) tmp = -1.0 + (b * (b * 12.0)); else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1.3], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 1550000000.0], N[(-1.0 + N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.3:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 1550000000:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 12\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -1.30000000000000004 or 1.55e9 < a Initial program 47.7%
sub-neg47.7%
fma-def47.7%
fma-def48.6%
+-commutative48.6%
metadata-eval48.6%
Simplified48.6%
Taylor expanded in a around inf 91.1%
Taylor expanded in a around inf 91.1%
if -1.30000000000000004 < a < 1.55e9Initial program 99.9%
sub-neg99.9%
fma-def99.9%
fma-def99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in a around 0 82.2%
associate-+r+82.2%
associate-*r*82.2%
distribute-rgt-out98.5%
metadata-eval98.5%
distribute-lft-in98.5%
+-commutative98.5%
unpow298.5%
distribute-lft-in98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in a around 0 98.4%
unpow298.4%
Simplified98.4%
Taylor expanded in b around 0 78.9%
unpow278.9%
associate-*r*78.9%
fma-neg78.9%
metadata-eval78.9%
Simplified78.9%
fma-udef78.9%
*-commutative78.9%
*-commutative78.9%
Applied egg-rr78.9%
Final simplification84.4%
(FPCore (a b) :precision binary64 (if (<= a 0.72) (+ -1.0 (* b (* b 12.0))) (+ -1.0 (* a (* (* b b) 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= 0.72) {
tmp = -1.0 + (b * (b * 12.0));
} else {
tmp = -1.0 + (a * ((b * 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 <= 0.72d0) then
tmp = (-1.0d0) + (b * (b * 12.0d0))
else
tmp = (-1.0d0) + (a * ((b * b) * 4.0d0))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 0.72) {
tmp = -1.0 + (b * (b * 12.0));
} else {
tmp = -1.0 + (a * ((b * b) * 4.0));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 0.72: tmp = -1.0 + (b * (b * 12.0)) else: tmp = -1.0 + (a * ((b * b) * 4.0)) return tmp
function code(a, b) tmp = 0.0 if (a <= 0.72) tmp = Float64(-1.0 + Float64(b * Float64(b * 12.0))); else tmp = Float64(-1.0 + Float64(a * Float64(Float64(b * b) * 4.0))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 0.72) tmp = -1.0 + (b * (b * 12.0)); else tmp = -1.0 + (a * ((b * b) * 4.0)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 0.72], N[(-1.0 + N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(a * N[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 0.72:\\
\;\;\;\;-1 + b \cdot \left(b \cdot 12\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + a \cdot \left(\left(b \cdot b\right) \cdot 4\right)\\
\end{array}
\end{array}
if a < 0.71999999999999997Initial program 88.9%
sub-neg88.9%
fma-def88.9%
fma-def88.9%
+-commutative88.9%
metadata-eval88.9%
Simplified88.9%
Taylor expanded in a around 0 59.1%
associate-+r+59.1%
associate-*r*59.1%
distribute-rgt-out70.6%
metadata-eval70.6%
distribute-lft-in70.6%
+-commutative70.6%
unpow270.6%
distribute-lft-in70.6%
metadata-eval70.6%
Simplified70.6%
Taylor expanded in a around 0 81.6%
unpow281.6%
Simplified81.6%
Taylor expanded in b around 0 64.0%
unpow264.0%
associate-*r*64.0%
fma-neg64.0%
metadata-eval64.0%
Simplified64.0%
fma-udef64.0%
*-commutative64.0%
*-commutative64.0%
Applied egg-rr64.0%
if 0.71999999999999997 < a Initial program 32.0%
sub-neg32.0%
fma-def32.0%
fma-def33.8%
+-commutative33.8%
metadata-eval33.8%
Simplified33.8%
Taylor expanded in a around 0 46.1%
associate-+r+46.1%
associate-*r*46.1%
distribute-rgt-out46.1%
metadata-eval46.1%
distribute-lft-in46.1%
+-commutative46.1%
unpow246.1%
distribute-lft-in46.1%
metadata-eval46.1%
Simplified46.1%
Taylor expanded in a around inf 44.4%
*-commutative44.4%
associate-*l*44.4%
*-commutative44.4%
unpow244.4%
Simplified44.4%
Final simplification59.7%
(FPCore (a b) :precision binary64 (if (or (<= b -9.5e-9) (not (<= b 0.29))) (* b (* b 12.0)) -1.0))
double code(double a, double b) {
double tmp;
if ((b <= -9.5e-9) || !(b <= 0.29)) {
tmp = b * (b * 12.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 ((b <= (-9.5d-9)) .or. (.not. (b <= 0.29d0))) then
tmp = b * (b * 12.0d0)
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b <= -9.5e-9) || !(b <= 0.29)) {
tmp = b * (b * 12.0);
} else {
tmp = -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if (b <= -9.5e-9) or not (b <= 0.29): tmp = b * (b * 12.0) else: tmp = -1.0 return tmp
function code(a, b) tmp = 0.0 if ((b <= -9.5e-9) || !(b <= 0.29)) tmp = Float64(b * Float64(b * 12.0)); else tmp = -1.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b <= -9.5e-9) || ~((b <= 0.29))) tmp = b * (b * 12.0); else tmp = -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[b, -9.5e-9], N[Not[LessEqual[b, 0.29]], $MachinePrecision]], N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision], -1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.5 \cdot 10^{-9} \lor \neg \left(b \leq 0.29\right):\\
\;\;\;\;b \cdot \left(b \cdot 12\right)\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\end{array}
if b < -9.5000000000000007e-9 or 0.28999999999999998 < b Initial program 67.3%
sub-neg67.3%
fma-def67.3%
fma-def68.1%
+-commutative68.1%
metadata-eval68.1%
Simplified68.1%
Taylor expanded in a around 0 57.2%
associate-+r+57.2%
associate-*r*57.2%
distribute-rgt-out75.4%
metadata-eval75.4%
distribute-lft-in75.4%
+-commutative75.4%
unpow275.4%
distribute-lft-in75.4%
metadata-eval75.4%
Simplified75.4%
Taylor expanded in a around 0 89.8%
unpow289.8%
Simplified89.8%
Taylor expanded in b around 0 59.0%
unpow259.0%
associate-*r*59.0%
fma-neg59.0%
metadata-eval59.0%
Simplified59.0%
Taylor expanded in b around inf 59.0%
unpow259.0%
*-commutative59.0%
associate-*r*59.0%
Simplified59.0%
if -9.5000000000000007e-9 < b < 0.28999999999999998Initial program 85.3%
sub-neg85.3%
fma-def85.3%
fma-def85.3%
+-commutative85.3%
metadata-eval85.3%
Simplified85.3%
Taylor expanded in a around inf 97.9%
Taylor expanded in a around 0 55.1%
Final simplification57.1%
(FPCore (a b) :precision binary64 (+ -1.0 (* b (* b 12.0))))
double code(double a, double b) {
return -1.0 + (b * (b * 12.0));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + (b * (b * 12.0d0))
end function
public static double code(double a, double b) {
return -1.0 + (b * (b * 12.0));
}
def code(a, b): return -1.0 + (b * (b * 12.0))
function code(a, b) return Float64(-1.0 + Float64(b * Float64(b * 12.0))) end
function tmp = code(a, b) tmp = -1.0 + (b * (b * 12.0)); end
code[a_, b_] := N[(-1.0 + N[(b * N[(b * 12.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + b \cdot \left(b \cdot 12\right)
\end{array}
Initial program 76.4%
sub-neg76.4%
fma-def76.4%
fma-def76.8%
+-commutative76.8%
metadata-eval76.8%
Simplified76.8%
Taylor expanded in a around 0 56.2%
associate-+r+56.2%
associate-*r*56.2%
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 72.2%
unpow272.2%
Simplified72.2%
Taylor expanded in b around 0 57.1%
unpow257.1%
associate-*r*57.1%
fma-neg57.1%
metadata-eval57.1%
Simplified57.1%
fma-udef57.1%
*-commutative57.1%
*-commutative57.1%
Applied egg-rr57.1%
Final simplification57.1%
(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 76.4%
sub-neg76.4%
fma-def76.4%
fma-def76.8%
+-commutative76.8%
metadata-eval76.8%
Simplified76.8%
Taylor expanded in a around inf 68.9%
Taylor expanded in a around 0 28.3%
Final simplification28.3%
herbie shell --seed 2023207
(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))