
(FPCore (p r q) :precision binary64 (* (/ 1.0 2.0) (- (+ (fabs p) (fabs r)) (sqrt (+ (pow (- p r) 2.0) (* 4.0 (pow q 2.0)))))))
double code(double p, double r, double q) {
return (1.0 / 2.0) * ((fabs(p) + fabs(r)) - sqrt((pow((p - r), 2.0) + (4.0 * pow(q, 2.0)))));
}
real(8) function code(p, r, q)
real(8), intent (in) :: p
real(8), intent (in) :: r
real(8), intent (in) :: q
code = (1.0d0 / 2.0d0) * ((abs(p) + abs(r)) - sqrt((((p - r) ** 2.0d0) + (4.0d0 * (q ** 2.0d0)))))
end function
public static double code(double p, double r, double q) {
return (1.0 / 2.0) * ((Math.abs(p) + Math.abs(r)) - Math.sqrt((Math.pow((p - r), 2.0) + (4.0 * Math.pow(q, 2.0)))));
}
def code(p, r, q): return (1.0 / 2.0) * ((math.fabs(p) + math.fabs(r)) - math.sqrt((math.pow((p - r), 2.0) + (4.0 * math.pow(q, 2.0)))))
function code(p, r, q) return Float64(Float64(1.0 / 2.0) * Float64(Float64(abs(p) + abs(r)) - sqrt(Float64((Float64(p - r) ^ 2.0) + Float64(4.0 * (q ^ 2.0)))))) end
function tmp = code(p, r, q) tmp = (1.0 / 2.0) * ((abs(p) + abs(r)) - sqrt((((p - r) ^ 2.0) + (4.0 * (q ^ 2.0))))); end
code[p_, r_, q_] := N[(N[(1.0 / 2.0), $MachinePrecision] * N[(N[(N[Abs[p], $MachinePrecision] + N[Abs[r], $MachinePrecision]), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(p - r), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[Power[q, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{2} \cdot \left(\left(\left|p\right| + \left|r\right|\right) - \sqrt{{\left(p - r\right)}^{2} + 4 \cdot {q}^{2}}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (p r q) :precision binary64 (* (/ 1.0 2.0) (- (+ (fabs p) (fabs r)) (sqrt (+ (pow (- p r) 2.0) (* 4.0 (pow q 2.0)))))))
double code(double p, double r, double q) {
return (1.0 / 2.0) * ((fabs(p) + fabs(r)) - sqrt((pow((p - r), 2.0) + (4.0 * pow(q, 2.0)))));
}
real(8) function code(p, r, q)
real(8), intent (in) :: p
real(8), intent (in) :: r
real(8), intent (in) :: q
code = (1.0d0 / 2.0d0) * ((abs(p) + abs(r)) - sqrt((((p - r) ** 2.0d0) + (4.0d0 * (q ** 2.0d0)))))
end function
public static double code(double p, double r, double q) {
return (1.0 / 2.0) * ((Math.abs(p) + Math.abs(r)) - Math.sqrt((Math.pow((p - r), 2.0) + (4.0 * Math.pow(q, 2.0)))));
}
def code(p, r, q): return (1.0 / 2.0) * ((math.fabs(p) + math.fabs(r)) - math.sqrt((math.pow((p - r), 2.0) + (4.0 * math.pow(q, 2.0)))))
function code(p, r, q) return Float64(Float64(1.0 / 2.0) * Float64(Float64(abs(p) + abs(r)) - sqrt(Float64((Float64(p - r) ^ 2.0) + Float64(4.0 * (q ^ 2.0)))))) end
function tmp = code(p, r, q) tmp = (1.0 / 2.0) * ((abs(p) + abs(r)) - sqrt((((p - r) ^ 2.0) + (4.0 * (q ^ 2.0))))); end
code[p_, r_, q_] := N[(N[(1.0 / 2.0), $MachinePrecision] * N[(N[(N[Abs[p], $MachinePrecision] + N[Abs[r], $MachinePrecision]), $MachinePrecision] - N[Sqrt[N[(N[Power[N[(p - r), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[Power[q, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{2} \cdot \left(\left(\left|p\right| + \left|r\right|\right) - \sqrt{{\left(p - r\right)}^{2} + 4 \cdot {q}^{2}}\right)
\end{array}
q_m = (fabs.f64 q)
NOTE: p, r, and q_m should be sorted in increasing order before calling this function.
(FPCore (p r q_m)
:precision binary64
(let* ((t_0 (- (fabs r) r)))
(if (<= q_m 3e-29)
(* 0.5 (+ (+ p (fma (/ (* q_m q_m) r) -2.0 (fabs p))) t_0))
(if (<= q_m 2.2e+34)
(* (pow 2.0 -1.0) (+ (fma (* -2.0 q_m) (/ q_m r) (+ (fabs p) p)) t_0))
(- q_m)))))q_m = fabs(q);
assert(p < r && r < q_m);
double code(double p, double r, double q_m) {
double t_0 = fabs(r) - r;
double tmp;
if (q_m <= 3e-29) {
tmp = 0.5 * ((p + fma(((q_m * q_m) / r), -2.0, fabs(p))) + t_0);
} else if (q_m <= 2.2e+34) {
tmp = pow(2.0, -1.0) * (fma((-2.0 * q_m), (q_m / r), (fabs(p) + p)) + t_0);
} else {
tmp = -q_m;
}
return tmp;
}
q_m = abs(q) p, r, q_m = sort([p, r, q_m]) function code(p, r, q_m) t_0 = Float64(abs(r) - r) tmp = 0.0 if (q_m <= 3e-29) tmp = Float64(0.5 * Float64(Float64(p + fma(Float64(Float64(q_m * q_m) / r), -2.0, abs(p))) + t_0)); elseif (q_m <= 2.2e+34) tmp = Float64((2.0 ^ -1.0) * Float64(fma(Float64(-2.0 * q_m), Float64(q_m / r), Float64(abs(p) + p)) + t_0)); else tmp = Float64(-q_m); end return tmp end
q_m = N[Abs[q], $MachinePrecision]
NOTE: p, r, and q_m should be sorted in increasing order before calling this function.
code[p_, r_, q$95$m_] := Block[{t$95$0 = N[(N[Abs[r], $MachinePrecision] - r), $MachinePrecision]}, If[LessEqual[q$95$m, 3e-29], N[(0.5 * N[(N[(p + N[(N[(N[(q$95$m * q$95$m), $MachinePrecision] / r), $MachinePrecision] * -2.0 + N[Abs[p], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[q$95$m, 2.2e+34], N[(N[Power[2.0, -1.0], $MachinePrecision] * N[(N[(N[(-2.0 * q$95$m), $MachinePrecision] * N[(q$95$m / r), $MachinePrecision] + N[(N[Abs[p], $MachinePrecision] + p), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], (-q$95$m)]]]
\begin{array}{l}
q_m = \left|q\right|
\\
[p, r, q_m] = \mathsf{sort}([p, r, q_m])\\
\\
\begin{array}{l}
t_0 := \left|r\right| - r\\
\mathbf{if}\;q\_m \leq 3 \cdot 10^{-29}:\\
\;\;\;\;0.5 \cdot \left(\left(p + \mathsf{fma}\left(\frac{q\_m \cdot q\_m}{r}, -2, \left|p\right|\right)\right) + t\_0\right)\\
\mathbf{elif}\;q\_m \leq 2.2 \cdot 10^{+34}:\\
\;\;\;\;{2}^{-1} \cdot \left(\mathsf{fma}\left(-2 \cdot q\_m, \frac{q\_m}{r}, \left|p\right| + p\right) + t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;-q\_m\\
\end{array}
\end{array}
if q < 3.0000000000000003e-29Initial program 24.1%
Taylor expanded in r around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites14.1%
Taylor expanded in r around 0
Applied rewrites25.0%
Taylor expanded in p around 0
Applied rewrites28.8%
lift-/.f64N/A
metadata-eval28.8
Applied rewrites28.8%
if 3.0000000000000003e-29 < q < 2.2000000000000002e34Initial program 23.9%
Taylor expanded in r around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites3.9%
Taylor expanded in r around 0
Applied rewrites14.0%
Taylor expanded in p around 0
Applied rewrites14.1%
Applied rewrites14.1%
if 2.2000000000000002e34 < q Initial program 25.3%
Taylor expanded in q around inf
mul-1-negN/A
lower-neg.f6464.5
Applied rewrites64.5%
Final simplification35.1%
q_m = (fabs.f64 q) NOTE: p, r, and q_m should be sorted in increasing order before calling this function. (FPCore (p r q_m) :precision binary64 (if (<= q_m 1.12e+18) (* (pow 2.0 -1.0) (+ (+ (fabs p) p) (- (fabs r) r))) (- q_m)))
q_m = fabs(q);
assert(p < r && r < q_m);
double code(double p, double r, double q_m) {
double tmp;
if (q_m <= 1.12e+18) {
tmp = pow(2.0, -1.0) * ((fabs(p) + p) + (fabs(r) - r));
} else {
tmp = -q_m;
}
return tmp;
}
q_m = abs(q)
NOTE: p, r, and q_m should be sorted in increasing order before calling this function.
real(8) function code(p, r, q_m)
real(8), intent (in) :: p
real(8), intent (in) :: r
real(8), intent (in) :: q_m
real(8) :: tmp
if (q_m <= 1.12d+18) then
tmp = (2.0d0 ** (-1.0d0)) * ((abs(p) + p) + (abs(r) - r))
else
tmp = -q_m
end if
code = tmp
end function
q_m = Math.abs(q);
assert p < r && r < q_m;
public static double code(double p, double r, double q_m) {
double tmp;
if (q_m <= 1.12e+18) {
tmp = Math.pow(2.0, -1.0) * ((Math.abs(p) + p) + (Math.abs(r) - r));
} else {
tmp = -q_m;
}
return tmp;
}
q_m = math.fabs(q) [p, r, q_m] = sort([p, r, q_m]) def code(p, r, q_m): tmp = 0 if q_m <= 1.12e+18: tmp = math.pow(2.0, -1.0) * ((math.fabs(p) + p) + (math.fabs(r) - r)) else: tmp = -q_m return tmp
q_m = abs(q) p, r, q_m = sort([p, r, q_m]) function code(p, r, q_m) tmp = 0.0 if (q_m <= 1.12e+18) tmp = Float64((2.0 ^ -1.0) * Float64(Float64(abs(p) + p) + Float64(abs(r) - r))); else tmp = Float64(-q_m); end return tmp end
q_m = abs(q);
p, r, q_m = num2cell(sort([p, r, q_m])){:}
function tmp_2 = code(p, r, q_m)
tmp = 0.0;
if (q_m <= 1.12e+18)
tmp = (2.0 ^ -1.0) * ((abs(p) + p) + (abs(r) - r));
else
tmp = -q_m;
end
tmp_2 = tmp;
end
q_m = N[Abs[q], $MachinePrecision] NOTE: p, r, and q_m should be sorted in increasing order before calling this function. code[p_, r_, q$95$m_] := If[LessEqual[q$95$m, 1.12e+18], N[(N[Power[2.0, -1.0], $MachinePrecision] * N[(N[(N[Abs[p], $MachinePrecision] + p), $MachinePrecision] + N[(N[Abs[r], $MachinePrecision] - r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-q$95$m)]
\begin{array}{l}
q_m = \left|q\right|
\\
[p, r, q_m] = \mathsf{sort}([p, r, q_m])\\
\\
\begin{array}{l}
\mathbf{if}\;q\_m \leq 1.12 \cdot 10^{+18}:\\
\;\;\;\;{2}^{-1} \cdot \left(\left(\left|p\right| + p\right) + \left(\left|r\right| - r\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-q\_m\\
\end{array}
\end{array}
if q < 1.12e18Initial program 23.6%
Taylor expanded in r around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites13.5%
Taylor expanded in r around 0
Applied rewrites24.6%
Taylor expanded in p around 0
Applied rewrites28.1%
Taylor expanded in r around inf
Applied rewrites25.9%
if 1.12e18 < q Initial program 26.7%
Taylor expanded in q around inf
mul-1-negN/A
lower-neg.f6462.8
Applied rewrites62.8%
Final simplification34.2%
q_m = (fabs.f64 q) NOTE: p, r, and q_m should be sorted in increasing order before calling this function. (FPCore (p r q_m) :precision binary64 (if (<= q_m 1.75e+29) (* 0.5 (+ (+ p (fma (/ (* q_m q_m) r) -2.0 (fabs p))) (- (fabs r) r))) (- q_m)))
q_m = fabs(q);
assert(p < r && r < q_m);
double code(double p, double r, double q_m) {
double tmp;
if (q_m <= 1.75e+29) {
tmp = 0.5 * ((p + fma(((q_m * q_m) / r), -2.0, fabs(p))) + (fabs(r) - r));
} else {
tmp = -q_m;
}
return tmp;
}
q_m = abs(q) p, r, q_m = sort([p, r, q_m]) function code(p, r, q_m) tmp = 0.0 if (q_m <= 1.75e+29) tmp = Float64(0.5 * Float64(Float64(p + fma(Float64(Float64(q_m * q_m) / r), -2.0, abs(p))) + Float64(abs(r) - r))); else tmp = Float64(-q_m); end return tmp end
q_m = N[Abs[q], $MachinePrecision] NOTE: p, r, and q_m should be sorted in increasing order before calling this function. code[p_, r_, q$95$m_] := If[LessEqual[q$95$m, 1.75e+29], N[(0.5 * N[(N[(p + N[(N[(N[(q$95$m * q$95$m), $MachinePrecision] / r), $MachinePrecision] * -2.0 + N[Abs[p], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[r], $MachinePrecision] - r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-q$95$m)]
\begin{array}{l}
q_m = \left|q\right|
\\
[p, r, q_m] = \mathsf{sort}([p, r, q_m])\\
\\
\begin{array}{l}
\mathbf{if}\;q\_m \leq 1.75 \cdot 10^{+29}:\\
\;\;\;\;0.5 \cdot \left(\left(p + \mathsf{fma}\left(\frac{q\_m \cdot q\_m}{r}, -2, \left|p\right|\right)\right) + \left(\left|r\right| - r\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-q\_m\\
\end{array}
\end{array}
if q < 1.74999999999999989e29Initial program 23.8%
Taylor expanded in r around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites13.3%
Taylor expanded in r around 0
Applied rewrites24.3%
Taylor expanded in p around 0
Applied rewrites27.7%
lift-/.f64N/A
metadata-eval27.7
Applied rewrites27.7%
if 1.74999999999999989e29 < q Initial program 26.2%
Taylor expanded in q around inf
mul-1-negN/A
lower-neg.f6464.0
Applied rewrites64.0%
q_m = (fabs.f64 q) NOTE: p, r, and q_m should be sorted in increasing order before calling this function. (FPCore (p r q_m) :precision binary64 (if (<= q_m 1.75e-93) (* -0.5 (- r (+ (+ p (fabs r)) (fabs p)))) (- q_m)))
q_m = fabs(q);
assert(p < r && r < q_m);
double code(double p, double r, double q_m) {
double tmp;
if (q_m <= 1.75e-93) {
tmp = -0.5 * (r - ((p + fabs(r)) + fabs(p)));
} else {
tmp = -q_m;
}
return tmp;
}
q_m = abs(q)
NOTE: p, r, and q_m should be sorted in increasing order before calling this function.
real(8) function code(p, r, q_m)
real(8), intent (in) :: p
real(8), intent (in) :: r
real(8), intent (in) :: q_m
real(8) :: tmp
if (q_m <= 1.75d-93) then
tmp = (-0.5d0) * (r - ((p + abs(r)) + abs(p)))
else
tmp = -q_m
end if
code = tmp
end function
q_m = Math.abs(q);
assert p < r && r < q_m;
public static double code(double p, double r, double q_m) {
double tmp;
if (q_m <= 1.75e-93) {
tmp = -0.5 * (r - ((p + Math.abs(r)) + Math.abs(p)));
} else {
tmp = -q_m;
}
return tmp;
}
q_m = math.fabs(q) [p, r, q_m] = sort([p, r, q_m]) def code(p, r, q_m): tmp = 0 if q_m <= 1.75e-93: tmp = -0.5 * (r - ((p + math.fabs(r)) + math.fabs(p))) else: tmp = -q_m return tmp
q_m = abs(q) p, r, q_m = sort([p, r, q_m]) function code(p, r, q_m) tmp = 0.0 if (q_m <= 1.75e-93) tmp = Float64(-0.5 * Float64(r - Float64(Float64(p + abs(r)) + abs(p)))); else tmp = Float64(-q_m); end return tmp end
q_m = abs(q);
p, r, q_m = num2cell(sort([p, r, q_m])){:}
function tmp_2 = code(p, r, q_m)
tmp = 0.0;
if (q_m <= 1.75e-93)
tmp = -0.5 * (r - ((p + abs(r)) + abs(p)));
else
tmp = -q_m;
end
tmp_2 = tmp;
end
q_m = N[Abs[q], $MachinePrecision] NOTE: p, r, and q_m should be sorted in increasing order before calling this function. code[p_, r_, q$95$m_] := If[LessEqual[q$95$m, 1.75e-93], N[(-0.5 * N[(r - N[(N[(p + N[Abs[r], $MachinePrecision]), $MachinePrecision] + N[Abs[p], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-q$95$m)]
\begin{array}{l}
q_m = \left|q\right|
\\
[p, r, q_m] = \mathsf{sort}([p, r, q_m])\\
\\
\begin{array}{l}
\mathbf{if}\;q\_m \leq 1.75 \cdot 10^{-93}:\\
\;\;\;\;-0.5 \cdot \left(r - \left(\left(p + \left|r\right|\right) + \left|p\right|\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-q\_m\\
\end{array}
\end{array}
if q < 1.75e-93Initial program 23.4%
Taylor expanded in r around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites11.9%
Taylor expanded in r around 0
Applied rewrites11.9%
if 1.75e-93 < q Initial program 26.4%
Taylor expanded in q around inf
mul-1-negN/A
lower-neg.f6452.6
Applied rewrites52.6%
q_m = (fabs.f64 q) NOTE: p, r, and q_m should be sorted in increasing order before calling this function. (FPCore (p r q_m) :precision binary64 (if (<= q_m 3.5e-166) (* (+ (+ p (fabs r)) (fabs p)) 0.5) (- q_m)))
q_m = fabs(q);
assert(p < r && r < q_m);
double code(double p, double r, double q_m) {
double tmp;
if (q_m <= 3.5e-166) {
tmp = ((p + fabs(r)) + fabs(p)) * 0.5;
} else {
tmp = -q_m;
}
return tmp;
}
q_m = abs(q)
NOTE: p, r, and q_m should be sorted in increasing order before calling this function.
real(8) function code(p, r, q_m)
real(8), intent (in) :: p
real(8), intent (in) :: r
real(8), intent (in) :: q_m
real(8) :: tmp
if (q_m <= 3.5d-166) then
tmp = ((p + abs(r)) + abs(p)) * 0.5d0
else
tmp = -q_m
end if
code = tmp
end function
q_m = Math.abs(q);
assert p < r && r < q_m;
public static double code(double p, double r, double q_m) {
double tmp;
if (q_m <= 3.5e-166) {
tmp = ((p + Math.abs(r)) + Math.abs(p)) * 0.5;
} else {
tmp = -q_m;
}
return tmp;
}
q_m = math.fabs(q) [p, r, q_m] = sort([p, r, q_m]) def code(p, r, q_m): tmp = 0 if q_m <= 3.5e-166: tmp = ((p + math.fabs(r)) + math.fabs(p)) * 0.5 else: tmp = -q_m return tmp
q_m = abs(q) p, r, q_m = sort([p, r, q_m]) function code(p, r, q_m) tmp = 0.0 if (q_m <= 3.5e-166) tmp = Float64(Float64(Float64(p + abs(r)) + abs(p)) * 0.5); else tmp = Float64(-q_m); end return tmp end
q_m = abs(q);
p, r, q_m = num2cell(sort([p, r, q_m])){:}
function tmp_2 = code(p, r, q_m)
tmp = 0.0;
if (q_m <= 3.5e-166)
tmp = ((p + abs(r)) + abs(p)) * 0.5;
else
tmp = -q_m;
end
tmp_2 = tmp;
end
q_m = N[Abs[q], $MachinePrecision] NOTE: p, r, and q_m should be sorted in increasing order before calling this function. code[p_, r_, q$95$m_] := If[LessEqual[q$95$m, 3.5e-166], N[(N[(N[(p + N[Abs[r], $MachinePrecision]), $MachinePrecision] + N[Abs[p], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], (-q$95$m)]
\begin{array}{l}
q_m = \left|q\right|
\\
[p, r, q_m] = \mathsf{sort}([p, r, q_m])\\
\\
\begin{array}{l}
\mathbf{if}\;q\_m \leq 3.5 \cdot 10^{-166}:\\
\;\;\;\;\left(\left(p + \left|r\right|\right) + \left|p\right|\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;-q\_m\\
\end{array}
\end{array}
if q < 3.4999999999999999e-166Initial program 23.2%
Taylor expanded in r around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites11.4%
Taylor expanded in r around 0
Applied rewrites8.2%
if 3.4999999999999999e-166 < q Initial program 26.3%
Taylor expanded in q around inf
mul-1-negN/A
lower-neg.f6448.0
Applied rewrites48.0%
q_m = (fabs.f64 q) NOTE: p, r, and q_m should be sorted in increasing order before calling this function. (FPCore (p r q_m) :precision binary64 (- q_m))
q_m = fabs(q);
assert(p < r && r < q_m);
double code(double p, double r, double q_m) {
return -q_m;
}
q_m = abs(q)
NOTE: p, r, and q_m should be sorted in increasing order before calling this function.
real(8) function code(p, r, q_m)
real(8), intent (in) :: p
real(8), intent (in) :: r
real(8), intent (in) :: q_m
code = -q_m
end function
q_m = Math.abs(q);
assert p < r && r < q_m;
public static double code(double p, double r, double q_m) {
return -q_m;
}
q_m = math.fabs(q) [p, r, q_m] = sort([p, r, q_m]) def code(p, r, q_m): return -q_m
q_m = abs(q) p, r, q_m = sort([p, r, q_m]) function code(p, r, q_m) return Float64(-q_m) end
q_m = abs(q);
p, r, q_m = num2cell(sort([p, r, q_m])){:}
function tmp = code(p, r, q_m)
tmp = -q_m;
end
q_m = N[Abs[q], $MachinePrecision] NOTE: p, r, and q_m should be sorted in increasing order before calling this function. code[p_, r_, q$95$m_] := (-q$95$m)
\begin{array}{l}
q_m = \left|q\right|
\\
[p, r, q_m] = \mathsf{sort}([p, r, q_m])\\
\\
-q\_m
\end{array}
Initial program 24.3%
Taylor expanded in q around inf
mul-1-negN/A
lower-neg.f6419.5
Applied rewrites19.5%
herbie shell --seed 2024332
(FPCore (p r q)
:name "1/2(abs(p)+abs(r) - sqrt((p-r)^2 + 4q^2))"
:precision binary64
(* (/ 1.0 2.0) (- (+ (fabs p) (fabs r)) (sqrt (+ (pow (- p r) 2.0) (* 4.0 (pow q 2.0)))))))