| Alternative 1 | |
|---|---|
| Accuracy | 84.7% |
| Cost | 7368 |
(FPCore (a b_2 c) :precision binary64 (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
(FPCore (a b_2 c)
:precision binary64
(let* ((t_0 (sqrt (- (* b_2 b_2) (* a c)))))
(if (<= b_2 -4e+152)
(/ (* b_2 -2.0) a)
(if (<= b_2 -8.5e-292)
(/ (- t_0 b_2) a)
(if (<= b_2 1e+117) (/ (- c) (+ b_2 t_0)) (/ (* c -0.5) b_2))))))double code(double a, double b_2, double c) {
return (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a;
}
double code(double a, double b_2, double c) {
double t_0 = sqrt(((b_2 * b_2) - (a * c)));
double tmp;
if (b_2 <= -4e+152) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= -8.5e-292) {
tmp = (t_0 - b_2) / a;
} else if (b_2 <= 1e+117) {
tmp = -c / (b_2 + t_0);
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a
end function
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((b_2 * b_2) - (a * c)))
if (b_2 <= (-4d+152)) then
tmp = (b_2 * (-2.0d0)) / a
else if (b_2 <= (-8.5d-292)) then
tmp = (t_0 - b_2) / a
else if (b_2 <= 1d+117) then
tmp = -c / (b_2 + t_0)
else
tmp = (c * (-0.5d0)) / b_2
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
return (-b_2 + Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
public static double code(double a, double b_2, double c) {
double t_0 = Math.sqrt(((b_2 * b_2) - (a * c)));
double tmp;
if (b_2 <= -4e+152) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= -8.5e-292) {
tmp = (t_0 - b_2) / a;
} else if (b_2 <= 1e+117) {
tmp = -c / (b_2 + t_0);
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): return (-b_2 + math.sqrt(((b_2 * b_2) - (a * c)))) / a
def code(a, b_2, c): t_0 = math.sqrt(((b_2 * b_2) - (a * c))) tmp = 0 if b_2 <= -4e+152: tmp = (b_2 * -2.0) / a elif b_2 <= -8.5e-292: tmp = (t_0 - b_2) / a elif b_2 <= 1e+117: tmp = -c / (b_2 + t_0) else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) + sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function code(a, b_2, c) t_0 = sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c))) tmp = 0.0 if (b_2 <= -4e+152) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= -8.5e-292) tmp = Float64(Float64(t_0 - b_2) / a); elseif (b_2 <= 1e+117) tmp = Float64(Float64(-c) / Float64(b_2 + t_0)); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp = code(a, b_2, c) tmp = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a; end
function tmp_2 = code(a, b_2, c) t_0 = sqrt(((b_2 * b_2) - (a * c))); tmp = 0.0; if (b_2 <= -4e+152) tmp = (b_2 * -2.0) / a; elseif (b_2 <= -8.5e-292) tmp = (t_0 - b_2) / a; elseif (b_2 <= 1e+117) tmp = -c / (b_2 + t_0); else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) + N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
code[a_, b$95$2_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b$95$2, -4e+152], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, -8.5e-292], N[(N[(t$95$0 - b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 1e+117], N[((-c) / N[(b$95$2 + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]]]
\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
t_0 := \sqrt{b_2 \cdot b_2 - a \cdot c}\\
\mathbf{if}\;b_2 \leq -4 \cdot 10^{+152}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{elif}\;b_2 \leq -8.5 \cdot 10^{-292}:\\
\;\;\;\;\frac{t_0 - b_2}{a}\\
\mathbf{elif}\;b_2 \leq 10^{+117}:\\
\;\;\;\;\frac{-c}{b_2 + t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
Results
if b_2 < -4.0000000000000002e152Initial program 0.8%
Simplified0.8%
[Start]0.8 | \[ \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\] |
|---|---|
+-commutative [=>]0.8 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a}
\] |
unsub-neg [=>]0.8 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}
\] |
Taylor expanded in b_2 around -inf 97.4%
Simplified97.4%
[Start]97.4 | \[ \frac{-2 \cdot b_2}{a}
\] |
|---|---|
*-commutative [=>]97.4 | \[ \frac{\color{blue}{b_2 \cdot -2}}{a}
\] |
if -4.0000000000000002e152 < b_2 < -8.50000000000000066e-292Initial program 87.4%
Simplified87.4%
[Start]87.4 | \[ \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\] |
|---|---|
+-commutative [=>]87.4 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a}
\] |
unsub-neg [=>]87.4 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}
\] |
if -8.50000000000000066e-292 < b_2 < 1.00000000000000005e117Initial program 49.7%
Simplified49.7%
[Start]49.7 | \[ \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\] |
|---|---|
+-commutative [=>]49.7 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a}
\] |
unsub-neg [=>]49.7 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}
\] |
Applied egg-rr49.6%
[Start]49.7 | \[ \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}
\] |
|---|---|
clear-num [=>]49.6 | \[ \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}
\] |
inv-pow [=>]49.6 | \[ \color{blue}{{\left(\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\right)}^{-1}}
\] |
Applied egg-rr49.6%
[Start]49.6 | \[ {\left(\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\right)}^{-1}
\] |
|---|---|
unpow-1 [=>]49.6 | \[ \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}
\] |
associate-/r/ [=>]49.6 | \[ \color{blue}{\frac{1}{a} \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}
\] |
sub-neg [=>]49.6 | \[ \frac{1}{a} \cdot \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)\right)}
\] |
flip-+ [=>]49.6 | \[ \frac{1}{a} \cdot \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - \left(-b_2\right) \cdot \left(-b_2\right)}{\sqrt{b_2 \cdot b_2 - a \cdot c} - \left(-b_2\right)}}
\] |
associate-*r/ [=>]49.5 | \[ \color{blue}{\frac{\frac{1}{a} \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - \left(-b_2\right) \cdot \left(-b_2\right)\right)}{\sqrt{b_2 \cdot b_2 - a \cdot c} - \left(-b_2\right)}}
\] |
add-sqr-sqrt [<=]49.6 | \[ \frac{\frac{1}{a} \cdot \left(\color{blue}{\left(b_2 \cdot b_2 - a \cdot c\right)} - \left(-b_2\right) \cdot \left(-b_2\right)\right)}{\sqrt{b_2 \cdot b_2 - a \cdot c} - \left(-b_2\right)}
\] |
Taylor expanded in a around 0 86.9%
Simplified86.9%
[Start]86.9 | \[ \frac{-1 \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - \left(-b_2\right)}
\] |
|---|---|
mul-1-neg [=>]86.9 | \[ \frac{\color{blue}{-c}}{\sqrt{b_2 \cdot b_2 - a \cdot c} - \left(-b_2\right)}
\] |
if 1.00000000000000005e117 < b_2 Initial program 4.7%
Simplified4.7%
[Start]4.7 | \[ \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\] |
|---|---|
+-commutative [=>]4.7 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a}
\] |
unsub-neg [=>]4.7 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}
\] |
Taylor expanded in b_2 around inf 96.8%
Simplified96.8%
[Start]96.8 | \[ -0.5 \cdot \frac{c}{b_2}
\] |
|---|---|
associate-*r/ [=>]96.8 | \[ \color{blue}{\frac{-0.5 \cdot c}{b_2}}
\] |
*-commutative [=>]96.8 | \[ \frac{\color{blue}{c \cdot -0.5}}{b_2}
\] |
Final simplification90.4%
| Alternative 1 | |
|---|---|
| Accuracy | 84.7% |
| Cost | 7368 |
| Alternative 2 | |
|---|---|
| Accuracy | 77.8% |
| Cost | 7176 |
| Alternative 3 | |
|---|---|
| Accuracy | 65.4% |
| Cost | 452 |
| Alternative 4 | |
|---|---|
| Accuracy | 65.1% |
| Cost | 452 |
| Alternative 5 | |
|---|---|
| Accuracy | 65.2% |
| Cost | 452 |
| Alternative 6 | |
|---|---|
| Accuracy | 65.6% |
| Cost | 452 |
| Alternative 7 | |
|---|---|
| Accuracy | 29.4% |
| Cost | 320 |
| Alternative 8 | |
|---|---|
| Accuracy | 7.5% |
| Cost | 256 |
herbie shell --seed 2023126
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
:precision binary64
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))