
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 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) * (1.0 - (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) * (1.0d0 - (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) * (1.0 - (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) * (1.0 - (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(1.0 - 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) * (1.0 - (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[(1.0 - N[(3.0 * a), $MachinePrecision]), $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(1 - 3 \cdot a\right)\right)\right) - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 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) (- 1.0 (* 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) * (1.0 - (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) * (1.0d0 - (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) * (1.0 - (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) * (1.0 - (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(1.0 - 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) * (1.0 - (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[(1.0 - N[(3.0 * a), $MachinePrecision]), $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(1 - 3 \cdot a\right)\right)\right) - 1
\end{array}
(FPCore (a b)
:precision binary64
(if (<=
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))
INFINITY)
(+
(pow (hypot a b) 4.0)
(fma 4.0 (fma b (* b (fma a -3.0 1.0)) (fma a a (pow a 3.0))) -1.0))
(+ -1.0 (* (pow a 3.0) (+ a 4.0)))))
double code(double a, double b) {
double tmp;
if ((pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))))) <= ((double) INFINITY)) {
tmp = pow(hypot(a, b), 4.0) + fma(4.0, fma(b, (b * fma(a, -3.0, 1.0)), fma(a, a, pow(a, 3.0))), -1.0);
} else {
tmp = -1.0 + (pow(a, 3.0) * (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(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0)))))) <= Inf) tmp = Float64((hypot(a, b) ^ 4.0) + fma(4.0, fma(b, Float64(b * fma(a, -3.0, 1.0)), fma(a, a, (a ^ 3.0))), -1.0)); else tmp = Float64(-1.0 + Float64((a ^ 3.0) * Float64(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[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(4.0 * N[(b * N[(b * N[(a * -3.0 + 1.0), $MachinePrecision]), $MachinePrecision] + N[(a * a + N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[(N[Power[a, 3.0], $MachinePrecision] * N[(a + 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(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right) \leq \infty:\\
\;\;\;\;{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(b, b \cdot \mathsf{fma}\left(a, -3, 1\right), \mathsf{fma}\left(a, a, {a}^{3}\right)\right), -1\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{3} \cdot \left(a + 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 1 (*.f64 3 a)))))) < +inf.0Initial program 99.9%
Simplified100.0%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) 2) (*.f64 4 (+.f64 (*.f64 (*.f64 a a) (+.f64 1 a)) (*.f64 (*.f64 b b) (-.f64 1 (*.f64 3 a)))))) Initial program 0.0%
associate--l+0.0%
fma-def0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified8.3%
fma-def8.3%
add-cbrt-cube8.3%
pow38.3%
fma-def8.3%
fma-def8.3%
metadata-eval8.3%
sqrt-pow28.3%
hypot-udef8.3%
pow-pow8.3%
metadata-eval8.3%
Applied egg-rr8.3%
Taylor expanded in b around 0 45.8%
Taylor expanded in a around inf 45.8%
Taylor expanded in b around 0 39.3%
sub-neg39.3%
metadata-eval39.3%
pow-plus39.3%
*-commutative39.3%
distribute-rgt-out93.5%
metadata-eval93.5%
Simplified93.5%
Final simplification98.1%
(FPCore (a b)
:precision binary64
(let* ((t_0
(+
(pow (+ (* a a) (* b b)) 2.0)
(* 4.0 (+ (* (* a a) (+ a 1.0)) (* (* b b) (- 1.0 (* a 3.0))))))))
(if (<= t_0 INFINITY) (+ t_0 -1.0) (+ -1.0 (* (pow a 3.0) (+ a 4.0))))))
double code(double a, double b) {
double t_0 = pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = -1.0 + (pow(a, 3.0) * (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) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0)))));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 + -1.0;
} else {
tmp = -1.0 + (Math.pow(a, 3.0) * (a + 4.0));
}
return tmp;
}
def code(a, b): t_0 = math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))) tmp = 0 if t_0 <= math.inf: tmp = t_0 + -1.0 else: tmp = -1.0 + (math.pow(a, 3.0) * (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(a + 1.0)) + Float64(Float64(b * b) * Float64(1.0 - Float64(a * 3.0)))))) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 + -1.0); else tmp = Float64(-1.0 + Float64((a ^ 3.0) * Float64(a + 4.0))); end return tmp end
function tmp_2 = code(a, b) t_0 = (((a * a) + (b * b)) ^ 2.0) + (4.0 * (((a * a) * (a + 1.0)) + ((b * b) * (1.0 - (a * 3.0))))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = -1.0 + ((a ^ 3.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[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(1.0 - N[(a * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 + -1.0), $MachinePrecision], N[(-1.0 + N[(N[Power[a, 3.0], $MachinePrecision] * N[(a + 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(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 - a \cdot 3\right)\right)\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;t_0 + -1\\
\mathbf{else}:\\
\;\;\;\;-1 + {a}^{3} \cdot \left(a + 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 1 (*.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 1 (*.f64 3 a)))))) Initial program 0.0%
associate--l+0.0%
fma-def0.0%
distribute-rgt-in0.0%
sqr-neg0.0%
distribute-rgt-in0.0%
Simplified8.3%
fma-def8.3%
add-cbrt-cube8.3%
pow38.3%
fma-def8.3%
fma-def8.3%
metadata-eval8.3%
sqrt-pow28.3%
hypot-udef8.3%
pow-pow8.3%
metadata-eval8.3%
Applied egg-rr8.3%
Taylor expanded in b around 0 45.8%
Taylor expanded in a around inf 45.8%
Taylor expanded in b around 0 39.3%
sub-neg39.3%
metadata-eval39.3%
pow-plus39.3%
*-commutative39.3%
distribute-rgt-out93.5%
metadata-eval93.5%
Simplified93.5%
Final simplification98.1%
(FPCore (a b) :precision binary64 (if (<= b 3.2e+36) (+ -1.0 (* (pow a 3.0) (+ a 4.0))) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 3.2e+36) {
tmp = -1.0 + (pow(a, 3.0) * (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 <= 3.2d+36) then
tmp = (-1.0d0) + ((a ** 3.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 <= 3.2e+36) {
tmp = -1.0 + (Math.pow(a, 3.0) * (a + 4.0));
} else {
tmp = -1.0 + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 3.2e+36: tmp = -1.0 + (math.pow(a, 3.0) * (a + 4.0)) else: tmp = -1.0 + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 3.2e+36) tmp = Float64(-1.0 + Float64((a ^ 3.0) * Float64(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 <= 3.2e+36) tmp = -1.0 + ((a ^ 3.0) * (a + 4.0)); else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 3.2e+36], N[(-1.0 + N[(N[Power[a, 3.0], $MachinePrecision] * N[(a + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.2 \cdot 10^{+36}:\\
\;\;\;\;-1 + {a}^{3} \cdot \left(a + 4\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if b < 3.1999999999999999e36Initial program 74.3%
associate--l+74.3%
fma-def74.3%
distribute-rgt-in74.3%
sqr-neg74.3%
distribute-rgt-in74.3%
Simplified76.3%
fma-def76.3%
add-cbrt-cube70.1%
pow370.1%
fma-def70.1%
fma-def70.1%
metadata-eval70.1%
sqrt-pow270.1%
hypot-udef70.1%
pow-pow70.1%
metadata-eval70.1%
Applied egg-rr70.1%
Taylor expanded in b around 0 75.5%
Taylor expanded in a around inf 73.9%
Taylor expanded in b around 0 62.4%
sub-neg62.4%
metadata-eval62.4%
pow-plus62.4%
*-commutative62.4%
distribute-rgt-out79.8%
metadata-eval79.8%
Simplified79.8%
if 3.1999999999999999e36 < b Initial program 63.8%
associate--l+63.8%
fma-def63.8%
distribute-rgt-in63.8%
sqr-neg63.8%
distribute-rgt-in63.8%
Simplified67.1%
fma-def67.1%
add-cbrt-cube59.5%
pow359.5%
fma-def59.5%
fma-def59.5%
metadata-eval59.5%
sqrt-pow259.5%
hypot-udef59.5%
pow-pow59.5%
metadata-eval59.5%
Applied egg-rr59.5%
Taylor expanded in b around 0 84.1%
Taylor expanded in a around 0 98.5%
Final simplification84.3%
(FPCore (a b) :precision binary64 (if (or (<= a -1.5e+38) (not (<= a 1.4e+25))) (pow a 4.0) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((a <= -1.5e+38) || !(a <= 1.4e+25)) {
tmp = pow(a, 4.0);
} else {
tmp = -1.0 + pow(b, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a <= (-1.5d+38)) .or. (.not. (a <= 1.4d+25))) then
tmp = a ** 4.0d0
else
tmp = (-1.0d0) + (b ** 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((a <= -1.5e+38) || !(a <= 1.4e+25)) {
tmp = Math.pow(a, 4.0);
} else {
tmp = -1.0 + Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (a <= -1.5e+38) or not (a <= 1.4e+25): tmp = math.pow(a, 4.0) else: tmp = -1.0 + math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if ((a <= -1.5e+38) || !(a <= 1.4e+25)) tmp = a ^ 4.0; else tmp = Float64(-1.0 + (b ^ 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((a <= -1.5e+38) || ~((a <= 1.4e+25))) tmp = a ^ 4.0; else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -1.5e+38], N[Not[LessEqual[a, 1.4e+25]], $MachinePrecision]], N[Power[a, 4.0], $MachinePrecision], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.5 \cdot 10^{+38} \lor \neg \left(a \leq 1.4 \cdot 10^{+25}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if a < -1.5000000000000001e38 or 1.4000000000000001e25 < a Initial program 38.3%
Simplified42.0%
Taylor expanded in a around inf 96.7%
if -1.5000000000000001e38 < a < 1.4000000000000001e25Initial program 97.8%
associate--l+97.8%
fma-def97.8%
distribute-rgt-in97.8%
sqr-neg97.8%
distribute-rgt-in97.8%
Simplified97.8%
fma-def97.8%
add-cbrt-cube90.7%
pow390.7%
fma-def90.7%
fma-def90.7%
metadata-eval90.7%
sqrt-pow290.7%
hypot-udef90.7%
pow-pow90.7%
metadata-eval90.7%
Applied egg-rr90.7%
Taylor expanded in b around 0 91.8%
Taylor expanded in a around 0 94.4%
Final simplification95.4%
(FPCore (a b) :precision binary64 (if (<= a -32500000000.0) (* (pow a 3.0) (+ a 4.0)) (if (<= a 5.2e+28) (+ -1.0 (pow b 4.0)) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (a <= -32500000000.0) {
tmp = pow(a, 3.0) * (a + 4.0);
} else if (a <= 5.2e+28) {
tmp = -1.0 + 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 <= (-32500000000.0d0)) then
tmp = (a ** 3.0d0) * (a + 4.0d0)
else if (a <= 5.2d+28) then
tmp = (-1.0d0) + (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 <= -32500000000.0) {
tmp = Math.pow(a, 3.0) * (a + 4.0);
} else if (a <= 5.2e+28) {
tmp = -1.0 + Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -32500000000.0: tmp = math.pow(a, 3.0) * (a + 4.0) elif a <= 5.2e+28: tmp = -1.0 + math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= -32500000000.0) tmp = Float64((a ^ 3.0) * Float64(a + 4.0)); elseif (a <= 5.2e+28) tmp = Float64(-1.0 + (b ^ 4.0)); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -32500000000.0) tmp = (a ^ 3.0) * (a + 4.0); elseif (a <= 5.2e+28) tmp = -1.0 + (b ^ 4.0); else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -32500000000.0], N[(N[Power[a, 3.0], $MachinePrecision] * N[(a + 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[a, 5.2e+28], N[(-1.0 + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -32500000000:\\
\;\;\;\;{a}^{3} \cdot \left(a + 4\right)\\
\mathbf{elif}\;a \leq 5.2 \cdot 10^{+28}:\\
\;\;\;\;-1 + {b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < -3.25e10Initial program 26.3%
associate--l+26.3%
fma-def26.3%
distribute-rgt-in26.3%
sqr-neg26.3%
distribute-rgt-in26.3%
Simplified37.6%
fma-def37.6%
add-cbrt-cube34.1%
pow334.1%
fma-def34.1%
fma-def34.1%
metadata-eval34.1%
sqrt-pow234.1%
hypot-udef34.1%
pow-pow34.2%
metadata-eval34.2%
Applied egg-rr34.2%
Taylor expanded in b around 0 22.8%
Taylor expanded in a around inf 22.8%
Taylor expanded in a around inf 19.2%
metadata-eval19.2%
pow-plus19.2%
*-commutative19.2%
distribute-rgt-out92.8%
Simplified92.8%
if -3.25e10 < a < 5.2000000000000004e28Initial program 97.8%
associate--l+97.8%
fma-def97.8%
distribute-rgt-in97.8%
sqr-neg97.8%
distribute-rgt-in97.8%
Simplified97.8%
fma-def97.8%
add-cbrt-cube90.5%
pow390.4%
fma-def90.4%
fma-def90.4%
metadata-eval90.4%
sqrt-pow290.4%
hypot-udef90.4%
pow-pow90.4%
metadata-eval90.4%
Applied egg-rr90.4%
Taylor expanded in b around 0 91.6%
Taylor expanded in a around 0 95.7%
if 5.2000000000000004e28 < a Initial program 52.3%
Simplified58.7%
Taylor expanded in a around inf 97.2%
Final simplification95.5%
(FPCore (a b) :precision binary64 (if (<= b 7.2e+35) (pow a 4.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if (b <= 7.2e+35) {
tmp = 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 <= 7.2d+35) then
tmp = 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 <= 7.2e+35) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 7.2e+35: tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 7.2e+35) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 7.2e+35) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 7.2e+35], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.2 \cdot 10^{+35}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 7.2000000000000001e35Initial program 74.3%
Simplified75.9%
Taylor expanded in a around inf 47.2%
if 7.2000000000000001e35 < b Initial program 63.8%
Simplified65.6%
Taylor expanded in b around inf 98.5%
Final simplification59.4%
(FPCore (a b) :precision binary64 (pow a 4.0))
double code(double a, double b) {
return pow(a, 4.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = a ** 4.0d0
end function
public static double code(double a, double b) {
return Math.pow(a, 4.0);
}
def code(a, b): return math.pow(a, 4.0)
function code(a, b) return a ^ 4.0 end
function tmp = code(a, b) tmp = a ^ 4.0; end
code[a_, b_] := N[Power[a, 4.0], $MachinePrecision]
\begin{array}{l}
\\
{a}^{4}
\end{array}
Initial program 71.8%
Simplified73.4%
Taylor expanded in a around inf 44.9%
Final simplification44.9%
herbie shell --seed 2023311
(FPCore (a b)
:name "Bouland and Aaronson, Equation (25)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))) 1.0))