
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (+ (- b) t_0) (* 2.0 a)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (-b - t_0)
else
tmp = (-b + t_0) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-b - t_0) else: tmp = (-b + t_0) / (2.0 * a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-b - t_0); else tmp = (-b + t_0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (+ (- b) t_0) (* 2.0 a)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (-b - t_0)
else
tmp = (-b + t_0) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-b - t_0) else: tmp = (-b + t_0) / (2.0 * a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-b - t_0); else tmp = (-b + t_0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\
\end{array}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= b -1e+151)
(if (>= b 0.0) (/ b a) (/ (- b) a))
(if (<= b 7.6e+107)
(if (>= b 0.0) (/ (* c (- 2.0)) (+ b t_0)) (/ (- t_0 b) (* a 2.0)))
(if (>= b 0.0)
(/ (* 2.0 c) (* b -2.0))
(/
(- (pow (exp (* 0.25 (- (log (* c 4.0)) (log (/ -1.0 a))))) 2.0) b)
(* a 2.0)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -1e+151) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = -b / a;
}
tmp_1 = tmp_2;
} else if (b <= 7.6e+107) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * -2.0) / (b + t_0);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (b * -2.0);
} else {
tmp_1 = (pow(exp((0.25 * (log((c * 4.0)) - log((-1.0 / a))))), 2.0) - b) / (a * 2.0);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
if (b <= (-1d+151)) then
if (b >= 0.0d0) then
tmp_2 = b / a
else
tmp_2 = -b / a
end if
tmp_1 = tmp_2
else if (b <= 7.6d+107) then
if (b >= 0.0d0) then
tmp_3 = (c * -2.0d0) / (b + t_0)
else
tmp_3 = (t_0 - b) / (a * 2.0d0)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (2.0d0 * c) / (b * (-2.0d0))
else
tmp_1 = ((exp((0.25d0 * (log((c * 4.0d0)) - log(((-1.0d0) / a))))) ** 2.0d0) - b) / (a * 2.0d0)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -1e+151) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = -b / a;
}
tmp_1 = tmp_2;
} else if (b <= 7.6e+107) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * -2.0) / (b + t_0);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (b * -2.0);
} else {
tmp_1 = (Math.pow(Math.exp((0.25 * (Math.log((c * 4.0)) - Math.log((-1.0 / a))))), 2.0) - b) / (a * 2.0);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp_1 = 0 if b <= -1e+151: tmp_2 = 0 if b >= 0.0: tmp_2 = b / a else: tmp_2 = -b / a tmp_1 = tmp_2 elif b <= 7.6e+107: tmp_3 = 0 if b >= 0.0: tmp_3 = (c * -2.0) / (b + t_0) else: tmp_3 = (t_0 - b) / (a * 2.0) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (2.0 * c) / (b * -2.0) else: tmp_1 = (math.pow(math.exp((0.25 * (math.log((c * 4.0)) - math.log((-1.0 / a))))), 2.0) - b) / (a * 2.0) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) tmp_1 = 0.0 if (b <= -1e+151) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(b / a); else tmp_2 = Float64(Float64(-b) / a); end tmp_1 = tmp_2; elseif (b <= 7.6e+107) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c * Float64(-2.0)) / Float64(b + t_0)); else tmp_3 = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_1 = Float64(Float64((exp(Float64(0.25 * Float64(log(Float64(c * 4.0)) - log(Float64(-1.0 / a))))) ^ 2.0) - b) / Float64(a * 2.0)); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); tmp_2 = 0.0; if (b <= -1e+151) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = b / a; else tmp_3 = -b / a; end tmp_2 = tmp_3; elseif (b <= 7.6e+107) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (c * -2.0) / (b + t_0); else tmp_4 = (t_0 - b) / (a * 2.0); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (2.0 * c) / (b * -2.0); else tmp_2 = ((exp((0.25 * (log((c * 4.0)) - log((-1.0 / a))))) ^ 2.0) - b) / (a * 2.0); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -1e+151], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[((-b) / a), $MachinePrecision]], If[LessEqual[b, 7.6e+107], If[GreaterEqual[b, 0.0], N[(N[(c * (-2.0)), $MachinePrecision] / N[(b + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[N[Exp[N[(0.25 * N[(N[Log[N[(c * 4.0), $MachinePrecision]], $MachinePrecision] - N[Log[N[(-1.0 / a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;b \leq -1 \cdot 10^{+151}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{+107}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot \left(-2\right)}{b + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(e^{0.25 \cdot \left(\log \left(c \cdot 4\right) - \log \left(\frac{-1}{a}\right)\right)}\right)}^{2} - b}{a \cdot 2}\\
\end{array}
\end{array}
if b < -1.00000000000000002e151Initial program 43.6%
Taylor expanded in a around 0 43.6%
distribute-lft-out--43.6%
associate-/l*43.6%
fma-neg43.6%
Simplified43.6%
Taylor expanded in c around inf 43.6%
Taylor expanded in b around -inf 91.3%
mul-1-neg91.3%
distribute-neg-frac291.3%
Simplified91.3%
if -1.00000000000000002e151 < b < 7.5999999999999996e107Initial program 86.0%
if 7.5999999999999996e107 < b Initial program 45.3%
Taylor expanded in b around inf 93.4%
*-commutative93.4%
Simplified93.4%
add-sqr-sqrt93.4%
pow293.4%
pow1/293.4%
metadata-eval93.4%
sqrt-pow193.4%
pow293.4%
associate-*l*93.4%
metadata-eval93.4%
metadata-eval93.4%
Applied egg-rr93.4%
Taylor expanded in a around -inf 93.4%
Final simplification88.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))) (t_1 (/ (- b) a)))
(if (<= b -1.12e+148)
(if (>= b 0.0) (/ b a) t_1)
(if (<= b 6e+107)
(if (>= b 0.0) (/ (* c (- 2.0)) (+ b t_0)) (/ (- t_0 b) (* a 2.0)))
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) t_1)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = -b / a;
double tmp_1;
if (b <= -1.12e+148) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = t_1;
}
tmp_1 = tmp_2;
} else if (b <= 6e+107) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * -2.0) / (b + t_0);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (b * -2.0);
} else {
tmp_1 = t_1;
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
t_1 = -b / a
if (b <= (-1.12d+148)) then
if (b >= 0.0d0) then
tmp_2 = b / a
else
tmp_2 = t_1
end if
tmp_1 = tmp_2
else if (b <= 6d+107) then
if (b >= 0.0d0) then
tmp_3 = (c * -2.0d0) / (b + t_0)
else
tmp_3 = (t_0 - b) / (a * 2.0d0)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (2.0d0 * c) / (b * (-2.0d0))
else
tmp_1 = t_1
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = -b / a;
double tmp_1;
if (b <= -1.12e+148) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = t_1;
}
tmp_1 = tmp_2;
} else if (b <= 6e+107) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * -2.0) / (b + t_0);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (b * -2.0);
} else {
tmp_1 = t_1;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) t_1 = -b / a tmp_1 = 0 if b <= -1.12e+148: tmp_2 = 0 if b >= 0.0: tmp_2 = b / a else: tmp_2 = t_1 tmp_1 = tmp_2 elif b <= 6e+107: tmp_3 = 0 if b >= 0.0: tmp_3 = (c * -2.0) / (b + t_0) else: tmp_3 = (t_0 - b) / (a * 2.0) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (2.0 * c) / (b * -2.0) else: tmp_1 = t_1 return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) t_1 = Float64(Float64(-b) / a) tmp_1 = 0.0 if (b <= -1.12e+148) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(b / a); else tmp_2 = t_1; end tmp_1 = tmp_2; elseif (b <= 6e+107) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c * Float64(-2.0)) / Float64(b + t_0)); else tmp_3 = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_1 = t_1; end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); t_1 = -b / a; tmp_2 = 0.0; if (b <= -1.12e+148) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = b / a; else tmp_3 = t_1; end tmp_2 = tmp_3; elseif (b <= 6e+107) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (c * -2.0) / (b + t_0); else tmp_4 = (t_0 - b) / (a * 2.0); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (2.0 * c) / (b * -2.0); else tmp_2 = t_1; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-b) / a), $MachinePrecision]}, If[LessEqual[b, -1.12e+148], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], t$95$1], If[LessEqual[b, 6e+107], If[GreaterEqual[b, 0.0], N[(N[(c * (-2.0)), $MachinePrecision] / N[(b + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_1 := \frac{-b}{a}\\
\mathbf{if}\;b \leq -1.12 \cdot 10^{+148}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}\\
\mathbf{elif}\;b \leq 6 \cdot 10^{+107}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot \left(-2\right)}{b + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -1.12e148Initial program 43.6%
Taylor expanded in a around 0 43.6%
distribute-lft-out--43.6%
associate-/l*43.6%
fma-neg43.6%
Simplified43.6%
Taylor expanded in c around inf 43.6%
Taylor expanded in b around -inf 91.3%
mul-1-neg91.3%
distribute-neg-frac291.3%
Simplified91.3%
if -1.12e148 < b < 6.00000000000000046e107Initial program 86.0%
if 6.00000000000000046e107 < b Initial program 45.3%
Taylor expanded in b around inf 93.4%
*-commutative93.4%
Simplified93.4%
Taylor expanded in b around -inf 93.4%
mul-1-neg2.7%
distribute-neg-frac22.7%
Simplified93.4%
Final simplification88.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- b) a)))
(if (<= b -1e+151)
(if (>= b 0.0) (/ b a) t_0)
(if (<= b 2.8e-252)
(if (>= b 0.0)
(/ b a)
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) t_0)))))
double code(double a, double b, double c) {
double t_0 = -b / a;
double tmp_1;
if (b <= -1e+151) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b <= 2.8e-252) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = b / a;
} else {
tmp_3 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (b * -2.0);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = -b / a
if (b <= (-1d+151)) then
if (b >= 0.0d0) then
tmp_2 = b / a
else
tmp_2 = t_0
end if
tmp_1 = tmp_2
else if (b <= 2.8d-252) then
if (b >= 0.0d0) then
tmp_3 = b / a
else
tmp_3 = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (2.0d0 * c) / (b * (-2.0d0))
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = -b / a;
double tmp_1;
if (b <= -1e+151) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b <= 2.8e-252) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = b / a;
} else {
tmp_3 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (b * -2.0);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): t_0 = -b / a tmp_1 = 0 if b <= -1e+151: tmp_2 = 0 if b >= 0.0: tmp_2 = b / a else: tmp_2 = t_0 tmp_1 = tmp_2 elif b <= 2.8e-252: tmp_3 = 0 if b >= 0.0: tmp_3 = b / a else: tmp_3 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (2.0 * c) / (b * -2.0) else: tmp_1 = t_0 return tmp_1
function code(a, b, c) t_0 = Float64(Float64(-b) / a) tmp_1 = 0.0 if (b <= -1e+151) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(b / a); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b <= 2.8e-252) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(b / a); else tmp_3 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_1 = t_0; end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = -b / a; tmp_2 = 0.0; if (b <= -1e+151) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = b / a; else tmp_3 = t_0; end tmp_2 = tmp_3; elseif (b <= 2.8e-252) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = b / a; else tmp_4 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (2.0 * c) / (b * -2.0); else tmp_2 = t_0; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) / a), $MachinePrecision]}, If[LessEqual[b, -1e+151], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], t$95$0], If[LessEqual[b, 2.8e-252], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-b}{a}\\
\mathbf{if}\;b \leq -1 \cdot 10^{+151}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}\\
\mathbf{elif}\;b \leq 2.8 \cdot 10^{-252}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -1.00000000000000002e151Initial program 43.6%
Taylor expanded in a around 0 43.6%
distribute-lft-out--43.6%
associate-/l*43.6%
fma-neg43.6%
Simplified43.6%
Taylor expanded in c around inf 43.6%
Taylor expanded in b around -inf 91.3%
mul-1-neg91.3%
distribute-neg-frac291.3%
Simplified91.3%
if -1.00000000000000002e151 < b < 2.80000000000000018e-252Initial program 87.2%
Taylor expanded in a around 0 86.2%
distribute-lft-out--86.2%
associate-/l*86.2%
fma-neg86.2%
Simplified86.2%
Taylor expanded in c around inf 86.2%
if 2.80000000000000018e-252 < b Initial program 66.5%
Taylor expanded in b around inf 70.4%
*-commutative70.4%
Simplified70.4%
Taylor expanded in b around -inf 70.4%
mul-1-neg3.4%
distribute-neg-frac23.4%
Simplified70.4%
Final simplification79.6%
(FPCore (a b c)
:precision binary64
(if (<= b -4e+149)
(if (>= b 0.0) (/ b a) (/ (- b) a))
(if (>= b 0.0)
(/ (* 2.0 c) (* b -2.0))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -4e+149) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = -b / a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (b * -2.0);
} else {
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if (b <= (-4d+149)) then
if (b >= 0.0d0) then
tmp_2 = b / a
else
tmp_2 = -b / a
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (2.0d0 * c) / (b * (-2.0d0))
else
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= -4e+149) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = -b / a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (b * -2.0);
} else {
tmp_1 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= -4e+149: tmp_2 = 0 if b >= 0.0: tmp_2 = b / a else: tmp_2 = -b / a tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (2.0 * c) / (b * -2.0) else: tmp_1 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= -4e+149) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(b / a); else tmp_2 = Float64(Float64(-b) / a); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= -4e+149) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = b / a; else tmp_3 = -b / a; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (2.0 * c) / (b * -2.0); else tmp_2 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, -4e+149], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[((-b) / a), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{+149}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\end{array}
\end{array}
if b < -4.0000000000000002e149Initial program 43.6%
Taylor expanded in a around 0 43.6%
distribute-lft-out--43.6%
associate-/l*43.6%
fma-neg43.6%
Simplified43.6%
Taylor expanded in c around inf 43.6%
Taylor expanded in b around -inf 91.3%
mul-1-neg91.3%
distribute-neg-frac291.3%
Simplified91.3%
if -4.0000000000000002e149 < b Initial program 75.5%
Taylor expanded in b around inf 77.3%
*-commutative77.3%
Simplified77.3%
Final simplification79.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1e+151)
(if (>= b 0.0) (/ b a) (/ (- b) a))
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (fma a (/ c b) (- b))))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -1e+151) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = -b / a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -1e+151) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(b / a); else tmp_2 = Float64(Float64(-b) / a); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -1e+151], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[((-b) / a), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{+151}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\end{array}
\end{array}
if b < -1.00000000000000002e151Initial program 43.6%
Taylor expanded in a around 0 43.6%
distribute-lft-out--43.6%
associate-/l*43.6%
fma-neg43.6%
Simplified43.6%
Taylor expanded in c around inf 43.6%
Taylor expanded in b around -inf 91.3%
mul-1-neg91.3%
distribute-neg-frac291.3%
Simplified91.3%
if -1.00000000000000002e151 < b Initial program 75.5%
Taylor expanded in a around 0 76.2%
distribute-lft-out--76.2%
associate-/l*77.2%
fma-neg77.2%
Simplified77.2%
Final simplification79.5%
(FPCore (a b c)
:precision binary64
(if (<= b -2.95e-71)
(if (>= b 0.0)
(/ (* 2.0 c) (* b -2.0))
(* b (+ (/ c (pow b 2.0)) (/ -1.0 a))))
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (fma a (/ c b) (- b))))
(/ (- (sqrt (* c (* a -4.0))) b) (* a 2.0)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -2.95e-71) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = b * ((c / pow(b, 2.0)) + (-1.0 / a));
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_1 = (sqrt((c * (a * -4.0))) - b) / (a * 2.0);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -2.95e-71) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_2 = Float64(b * Float64(Float64(c / (b ^ 2.0)) + Float64(-1.0 / a))); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_1 = Float64(Float64(sqrt(Float64(c * Float64(a * -4.0))) - b) / Float64(a * 2.0)); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -2.95e-71], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(b * N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.95 \cdot 10^{-71}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\
\end{array}
\end{array}
if b < -2.95000000000000001e-71Initial program 73.7%
Taylor expanded in b around inf 73.7%
*-commutative73.7%
Simplified73.7%
Taylor expanded in b around -inf 88.6%
associate-*r*88.6%
neg-mul-188.6%
+-commutative88.6%
mul-1-neg88.6%
unsub-neg88.6%
Simplified88.6%
if -2.95000000000000001e-71 < b Initial program 68.1%
Taylor expanded in a around 0 69.1%
distribute-lft-out--69.1%
associate-/l*70.4%
fma-neg70.4%
Simplified70.4%
Taylor expanded in b around 0 69.3%
associate-*r*69.3%
*-commutative69.3%
*-commutative69.3%
Simplified69.3%
Final simplification76.9%
(FPCore (a b c) :precision binary64 (if (<= b 2.6e-252) (if (>= b 0.0) (/ b a) (/ (- b) a)) (if (>= b 0.0) (* c (/ -2.0 (+ b b))) (/ (- b b) (* a -2.0)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= 2.6e-252) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = -b / a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = c * (-2.0 / (b + b));
} else {
tmp_1 = (b - b) / (a * -2.0);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if (b <= 2.6d-252) then
if (b >= 0.0d0) then
tmp_2 = b / a
else
tmp_2 = -b / a
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = c * ((-2.0d0) / (b + b))
else
tmp_1 = (b - b) / (a * (-2.0d0))
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= 2.6e-252) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b / a;
} else {
tmp_2 = -b / a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = c * (-2.0 / (b + b));
} else {
tmp_1 = (b - b) / (a * -2.0);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= 2.6e-252: tmp_2 = 0 if b >= 0.0: tmp_2 = b / a else: tmp_2 = -b / a tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = c * (-2.0 / (b + b)) else: tmp_1 = (b - b) / (a * -2.0) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= 2.6e-252) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(b / a); else tmp_2 = Float64(Float64(-b) / a); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(c * Float64(-2.0 / Float64(b + b))); else tmp_1 = Float64(Float64(b - b) / Float64(a * -2.0)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= 2.6e-252) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = b / a; else tmp_3 = -b / a; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = c * (-2.0 / (b + b)); else tmp_2 = (b - b) / (a * -2.0); end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, 2.6e-252], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[((-b) / a), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - b), $MachinePrecision] / N[(a * -2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.6 \cdot 10^{-252}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - b}{a \cdot -2}\\
\end{array}
\end{array}
if b < 2.5999999999999999e-252Initial program 73.7%
Taylor expanded in a around 0 73.0%
distribute-lft-out--73.0%
associate-/l*73.0%
fma-neg73.0%
Simplified73.0%
Taylor expanded in c around inf 73.0%
Taylor expanded in b around -inf 69.4%
mul-1-neg69.4%
distribute-neg-frac269.4%
Simplified69.4%
if 2.5999999999999999e-252 < b Initial program 66.5%
Simplified66.3%
Taylor expanded in c around 0 70.2%
Taylor expanded in c around 0 70.2%
Final simplification69.8%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ (- b) a)))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (b * -2.0);
} else {
tmp = -b / a;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (b * (-2.0d0))
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (b * -2.0);
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (b * -2.0) else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (b * -2.0); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
Initial program 70.3%
Taylor expanded in b around inf 71.8%
*-commutative71.8%
Simplified71.8%
Taylor expanded in b around -inf 69.9%
mul-1-neg38.2%
distribute-neg-frac238.2%
Simplified69.9%
Final simplification69.9%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ b a) (/ (- b) a)))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = b / a;
} else {
tmp = -b / a;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = b / a
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = b / a;
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = b / a else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(b / a); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = b / a; else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[((-b) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
Initial program 70.3%
Taylor expanded in a around 0 70.9%
distribute-lft-out--70.9%
associate-/l*71.7%
fma-neg71.7%
Simplified71.7%
Taylor expanded in c around inf 40.1%
Taylor expanded in b around -inf 38.2%
mul-1-neg38.2%
distribute-neg-frac238.2%
Simplified38.2%
Final simplification38.2%
herbie shell --seed 2024085
(FPCore (a b c)
:name "jeff quadratic root 2"
:precision binary64
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))