
(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 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) (+ 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 (<= a 1.9e+72) (+ (pow (hypot b a) 4.0) (- -1.0 (* 4.0 (pow a 3.0)))) (pow a 4.0)))
double code(double a, double b) {
double tmp;
if (a <= 1.9e+72) {
tmp = pow(hypot(b, a), 4.0) + (-1.0 - (4.0 * pow(a, 3.0)));
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
public static double code(double a, double b) {
double tmp;
if (a <= 1.9e+72) {
tmp = Math.pow(Math.hypot(b, a), 4.0) + (-1.0 - (4.0 * Math.pow(a, 3.0)));
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 1.9e+72: tmp = math.pow(math.hypot(b, a), 4.0) + (-1.0 - (4.0 * math.pow(a, 3.0))) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= 1.9e+72) tmp = Float64((hypot(b, a) ^ 4.0) + Float64(-1.0 - Float64(4.0 * (a ^ 3.0)))); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 1.9e+72) tmp = (hypot(b, a) ^ 4.0) + (-1.0 - (4.0 * (a ^ 3.0))); else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 1.9e+72], N[(N[Power[N[Sqrt[b ^ 2 + a ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(-1.0 - N[(4.0 * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.9 \cdot 10^{+72}:\\
\;\;\;\;{\left(\mathsf{hypot}\left(b, a\right)\right)}^{4} + \left(-1 - 4 \cdot {a}^{3}\right)\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 1.90000000000000003e72Initial program 90.1%
associate--l+90.1%
fma-define90.1%
sqr-neg90.1%
fma-define90.1%
distribute-rgt-in90.1%
sqr-neg90.1%
distribute-rgt-in90.1%
fma-define90.1%
sqr-neg90.1%
Simplified90.1%
fma-define90.1%
unpow290.1%
+-commutative90.1%
distribute-lft-in79.0%
fma-define79.0%
add-sqr-sqrt79.0%
pow279.0%
fma-define79.0%
hypot-define79.0%
pow279.0%
fma-define79.0%
add-sqr-sqrt79.0%
pow279.0%
fma-define79.0%
hypot-define79.0%
pow279.0%
Applied egg-rr79.0%
distribute-lft-out90.1%
+-commutative90.1%
rem-square-sqrt90.1%
unpow290.1%
unpow290.1%
hypot-undefine90.1%
unpow290.1%
unpow290.1%
hypot-undefine90.1%
unpow290.1%
pow-sqr90.3%
hypot-undefine90.3%
unpow290.3%
unpow290.3%
+-commutative90.3%
unpow290.3%
unpow290.3%
hypot-define90.3%
metadata-eval90.3%
Simplified90.3%
Taylor expanded in a around inf 98.5%
mul-1-neg98.5%
Simplified98.5%
if 1.90000000000000003e72 < a Initial program 12.0%
associate--l+12.0%
fma-define12.0%
sqr-neg12.0%
fma-define12.0%
distribute-rgt-in12.0%
sqr-neg12.0%
distribute-rgt-in12.0%
fma-define12.0%
sqr-neg12.0%
Simplified16.0%
Taylor expanded in a around inf 100.0%
Final simplification98.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) (* (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) * (1.0 - a)) + ((b * b) * (a + 3.0))));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 + -1.0;
} else {
tmp = 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) * (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, 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) * (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, 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(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((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) * (1.0 - a)) + ((b * b) * (a + 3.0)))); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 + -1.0; else tmp = (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[(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[(N[Power[a, 3.0], $MachinePrecision] * N[(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}:\\
\;\;\;\;{a}^{3} \cdot \left(a - 4\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (-.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (+.f64 #s(literal 3 binary64) a))))) < +inf.0Initial program 99.8%
if +inf.0 < (+.f64 (pow.f64 (+.f64 (*.f64 a a) (*.f64 b b)) #s(literal 2 binary64)) (*.f64 #s(literal 4 binary64) (+.f64 (*.f64 (*.f64 a a) (-.f64 #s(literal 1 binary64) a)) (*.f64 (*.f64 b b) (+.f64 #s(literal 3 binary64) 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%
Simplified3.1%
Taylor expanded in a around inf 89.6%
associate-*r/89.6%
metadata-eval89.6%
Simplified89.6%
Taylor expanded in a around 0 89.6%
Final simplification97.3%
(FPCore (a b) :precision binary64 (if (<= b 22.0) (+ -1.0 (* (pow a 3.0) (+ a -4.0))) (* (pow b 4.0) (+ 1.0 (* 2.0 (/ (/ a b) (/ b a)))))))
double code(double a, double b) {
double tmp;
if (b <= 22.0) {
tmp = -1.0 + (pow(a, 3.0) * (a + -4.0));
} else {
tmp = pow(b, 4.0) * (1.0 + (2.0 * ((a / b) / (b / a))));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 22.0d0) then
tmp = (-1.0d0) + ((a ** 3.0d0) * (a + (-4.0d0)))
else
tmp = (b ** 4.0d0) * (1.0d0 + (2.0d0 * ((a / b) / (b / a))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 22.0) {
tmp = -1.0 + (Math.pow(a, 3.0) * (a + -4.0));
} else {
tmp = Math.pow(b, 4.0) * (1.0 + (2.0 * ((a / b) / (b / a))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 22.0: tmp = -1.0 + (math.pow(a, 3.0) * (a + -4.0)) else: tmp = math.pow(b, 4.0) * (1.0 + (2.0 * ((a / b) / (b / a)))) return tmp
function code(a, b) tmp = 0.0 if (b <= 22.0) tmp = Float64(-1.0 + Float64((a ^ 3.0) * Float64(a + -4.0))); else tmp = Float64((b ^ 4.0) * Float64(1.0 + Float64(2.0 * Float64(Float64(a / b) / Float64(b / a))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 22.0) tmp = -1.0 + ((a ^ 3.0) * (a + -4.0)); else tmp = (b ^ 4.0) * (1.0 + (2.0 * ((a / b) / (b / a)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 22.0], N[(-1.0 + N[(N[Power[a, 3.0], $MachinePrecision] * N[(a + -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] * N[(1.0 + N[(2.0 * N[(N[(a / b), $MachinePrecision] / N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 22:\\
\;\;\;\;-1 + {a}^{3} \cdot \left(a + -4\right)\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} \cdot \left(1 + 2 \cdot \frac{\frac{a}{b}}{\frac{b}{a}}\right)\\
\end{array}
\end{array}
if b < 22Initial program 74.8%
associate--l+74.8%
fma-define74.8%
sqr-neg74.8%
fma-define74.8%
distribute-rgt-in74.8%
sqr-neg74.8%
distribute-rgt-in74.8%
fma-define74.8%
sqr-neg74.8%
Simplified75.8%
fma-define75.8%
unpow275.8%
+-commutative75.8%
distribute-lft-in67.6%
fma-define67.6%
add-sqr-sqrt67.6%
pow267.6%
fma-define67.6%
hypot-define67.6%
pow267.6%
fma-define67.6%
add-sqr-sqrt67.6%
pow267.6%
fma-define67.6%
hypot-define67.6%
pow267.6%
Applied egg-rr67.6%
distribute-lft-out75.8%
+-commutative75.8%
rem-square-sqrt75.8%
unpow275.8%
unpow275.8%
hypot-undefine75.8%
unpow275.8%
unpow275.8%
hypot-undefine75.8%
unpow275.8%
pow-sqr75.9%
hypot-undefine75.9%
unpow275.9%
unpow275.9%
+-commutative75.9%
unpow275.9%
unpow275.9%
hypot-define75.9%
metadata-eval75.9%
Simplified75.9%
Taylor expanded in a around inf 79.2%
mul-1-neg79.2%
Simplified79.2%
Taylor expanded in b around 0 59.5%
sub-neg59.5%
*-commutative59.5%
metadata-eval59.5%
pow-plus59.5%
distribute-lft-in78.9%
+-commutative78.9%
metadata-eval78.9%
+-commutative78.9%
+-commutative78.9%
Simplified78.9%
if 22 < b Initial program 75.2%
associate--l+75.2%
fma-define75.2%
sqr-neg75.2%
fma-define75.2%
distribute-rgt-in75.2%
sqr-neg75.2%
distribute-rgt-in75.2%
fma-define75.2%
sqr-neg75.2%
Simplified75.2%
Taylor expanded in b around inf 94.7%
Taylor expanded in a around inf 94.1%
unpow294.1%
unpow294.1%
times-frac99.1%
unpow299.1%
Simplified99.1%
unpow299.1%
clear-num99.1%
un-div-inv99.1%
Applied egg-rr99.1%
Final simplification83.7%
(FPCore (a b) :precision binary64 (if (or (<= b 1.22e+14) (and (not (<= b 5.8e+43)) (<= b 8.5e+55))) (pow a 4.0) (pow b 4.0)))
double code(double a, double b) {
double tmp;
if ((b <= 1.22e+14) || (!(b <= 5.8e+43) && (b <= 8.5e+55))) {
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 <= 1.22d+14) .or. (.not. (b <= 5.8d+43)) .and. (b <= 8.5d+55)) 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 <= 1.22e+14) || (!(b <= 5.8e+43) && (b <= 8.5e+55))) {
tmp = Math.pow(a, 4.0);
} else {
tmp = Math.pow(b, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if (b <= 1.22e+14) or (not (b <= 5.8e+43) and (b <= 8.5e+55)): tmp = math.pow(a, 4.0) else: tmp = math.pow(b, 4.0) return tmp
function code(a, b) tmp = 0.0 if ((b <= 1.22e+14) || (!(b <= 5.8e+43) && (b <= 8.5e+55))) tmp = a ^ 4.0; else tmp = b ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b <= 1.22e+14) || (~((b <= 5.8e+43)) && (b <= 8.5e+55))) tmp = a ^ 4.0; else tmp = b ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[b, 1.22e+14], And[N[Not[LessEqual[b, 5.8e+43]], $MachinePrecision], LessEqual[b, 8.5e+55]]], N[Power[a, 4.0], $MachinePrecision], N[Power[b, 4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.22 \cdot 10^{+14} \lor \neg \left(b \leq 5.8 \cdot 10^{+43}\right) \land b \leq 8.5 \cdot 10^{+55}:\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;{b}^{4}\\
\end{array}
\end{array}
if b < 1.22e14 or 5.8000000000000004e43 < b < 8.50000000000000002e55Initial program 74.1%
associate--l+74.1%
fma-define74.1%
sqr-neg74.1%
fma-define74.1%
distribute-rgt-in74.1%
sqr-neg74.1%
distribute-rgt-in74.1%
fma-define74.1%
sqr-neg74.1%
Simplified75.1%
Taylor expanded in a around inf 53.4%
if 1.22e14 < b < 5.8000000000000004e43 or 8.50000000000000002e55 < b Initial program 77.6%
associate--l+77.6%
fma-define77.6%
sqr-neg77.6%
fma-define77.6%
distribute-rgt-in77.6%
sqr-neg77.6%
distribute-rgt-in77.6%
fma-define77.6%
sqr-neg77.6%
Simplified77.6%
Taylor expanded in b around inf 99.9%
Final simplification63.2%
(FPCore (a b) :precision binary64 (if (<= b 1.45e+14) (+ (pow a 4.0) -1.0) (if (or (<= b 1.15e+45) (not (<= b 1.6e+56))) (pow b 4.0) (pow a 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 1.45e+14) {
tmp = pow(a, 4.0) + -1.0;
} else if ((b <= 1.15e+45) || !(b <= 1.6e+56)) {
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 (b <= 1.45d+14) then
tmp = (a ** 4.0d0) + (-1.0d0)
else if ((b <= 1.15d+45) .or. (.not. (b <= 1.6d+56))) 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 (b <= 1.45e+14) {
tmp = Math.pow(a, 4.0) + -1.0;
} else if ((b <= 1.15e+45) || !(b <= 1.6e+56)) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 1.45e+14: tmp = math.pow(a, 4.0) + -1.0 elif (b <= 1.15e+45) or not (b <= 1.6e+56): tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 1.45e+14) tmp = Float64((a ^ 4.0) + -1.0); elseif ((b <= 1.15e+45) || !(b <= 1.6e+56)) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 1.45e+14) tmp = (a ^ 4.0) + -1.0; elseif ((b <= 1.15e+45) || ~((b <= 1.6e+56))) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 1.45e+14], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], If[Or[LessEqual[b, 1.15e+45], N[Not[LessEqual[b, 1.6e+56]], $MachinePrecision]], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.45 \cdot 10^{+14}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{+45} \lor \neg \left(b \leq 1.6 \cdot 10^{+56}\right):\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if b < 1.45e14Initial program 74.8%
associate--l+74.8%
fma-define74.8%
sqr-neg74.8%
fma-define74.8%
distribute-rgt-in74.8%
sqr-neg74.8%
distribute-rgt-in74.8%
fma-define74.8%
sqr-neg74.8%
Simplified75.8%
fma-define75.8%
unpow275.8%
+-commutative75.8%
distribute-lft-in67.7%
fma-define67.7%
add-sqr-sqrt67.7%
pow267.7%
fma-define67.7%
hypot-define67.7%
pow267.7%
fma-define67.7%
add-sqr-sqrt67.7%
pow267.7%
fma-define67.7%
hypot-define67.7%
pow267.7%
Applied egg-rr67.7%
distribute-lft-out75.8%
+-commutative75.8%
rem-square-sqrt75.8%
unpow275.8%
unpow275.8%
hypot-undefine75.8%
unpow275.8%
unpow275.8%
hypot-undefine75.8%
unpow275.8%
pow-sqr75.9%
hypot-undefine75.9%
unpow275.9%
unpow275.9%
+-commutative75.9%
unpow275.9%
unpow275.9%
hypot-define75.9%
metadata-eval75.9%
Simplified75.9%
Taylor expanded in a around inf 78.8%
mul-1-neg78.8%
Simplified78.8%
Taylor expanded in b around 0 58.8%
sub-neg58.8%
*-commutative58.8%
metadata-eval58.8%
pow-plus58.8%
distribute-lft-in78.4%
+-commutative78.4%
metadata-eval78.4%
+-commutative78.4%
+-commutative78.4%
Simplified78.4%
Taylor expanded in a around inf 78.0%
if 1.45e14 < b < 1.15000000000000006e45 or 1.60000000000000002e56 < b Initial program 77.6%
associate--l+77.6%
fma-define77.6%
sqr-neg77.6%
fma-define77.6%
distribute-rgt-in77.6%
sqr-neg77.6%
distribute-rgt-in77.6%
fma-define77.6%
sqr-neg77.6%
Simplified77.6%
Taylor expanded in b around inf 99.9%
if 1.15000000000000006e45 < b < 1.60000000000000002e56Initial program 33.3%
associate--l+33.3%
fma-define33.3%
sqr-neg33.3%
fma-define33.3%
distribute-rgt-in33.3%
sqr-neg33.3%
distribute-rgt-in33.3%
fma-define33.3%
sqr-neg33.3%
Simplified33.3%
Taylor expanded in a around inf 68.8%
Final simplification82.5%
(FPCore (a b) :precision binary64 (if (or (<= a -1.45e+44) (not (<= a 5.5e+36))) (pow a 4.0) (+ -1.0 (pow b 4.0))))
double code(double a, double b) {
double tmp;
if ((a <= -1.45e+44) || !(a <= 5.5e+36)) {
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.45d+44)) .or. (.not. (a <= 5.5d+36))) 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.45e+44) || !(a <= 5.5e+36)) {
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.45e+44) or not (a <= 5.5e+36): 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.45e+44) || !(a <= 5.5e+36)) 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.45e+44) || ~((a <= 5.5e+36))) tmp = a ^ 4.0; else tmp = -1.0 + (b ^ 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[Or[LessEqual[a, -1.45e+44], N[Not[LessEqual[a, 5.5e+36]], $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.45 \cdot 10^{+44} \lor \neg \left(a \leq 5.5 \cdot 10^{+36}\right):\\
\;\;\;\;{a}^{4}\\
\mathbf{else}:\\
\;\;\;\;-1 + {b}^{4}\\
\end{array}
\end{array}
if a < -1.4500000000000001e44 or 5.5000000000000002e36 < a Initial program 48.1%
associate--l+48.1%
fma-define48.1%
sqr-neg48.1%
fma-define48.1%
distribute-rgt-in48.1%
sqr-neg48.1%
distribute-rgt-in48.1%
fma-define48.1%
sqr-neg48.1%
Simplified49.9%
Taylor expanded in a around inf 95.1%
if -1.4500000000000001e44 < a < 5.5000000000000002e36Initial program 96.3%
associate--l+96.3%
fma-define96.3%
sqr-neg96.3%
fma-define96.3%
distribute-rgt-in96.3%
sqr-neg96.3%
distribute-rgt-in96.3%
fma-define96.3%
sqr-neg96.3%
Simplified96.3%
fma-define96.3%
unpow296.3%
+-commutative96.3%
distribute-lft-in87.2%
fma-define87.2%
add-sqr-sqrt87.2%
pow287.2%
fma-define87.2%
hypot-define87.2%
pow287.2%
fma-define87.2%
add-sqr-sqrt87.2%
pow287.2%
fma-define87.2%
hypot-define87.2%
pow287.2%
Applied egg-rr87.2%
distribute-lft-out96.3%
+-commutative96.3%
rem-square-sqrt96.3%
unpow296.3%
unpow296.3%
hypot-undefine96.3%
unpow296.3%
unpow296.3%
hypot-undefine96.3%
unpow296.3%
pow-sqr96.5%
hypot-undefine96.5%
unpow296.5%
unpow296.5%
+-commutative96.5%
unpow296.5%
unpow296.5%
hypot-define96.5%
metadata-eval96.5%
Simplified96.5%
Taylor expanded in a around inf 97.8%
mul-1-neg97.8%
Simplified97.8%
Taylor expanded in a around 0 92.9%
Final simplification93.9%
(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 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%
Simplified75.7%
Taylor expanded in a around inf 46.1%
Final simplification46.1%
herbie shell --seed 2024082
(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))