
(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 8 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+115)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ (* b -2.0) (* 2.0 a)))
(if (<= b 1.2e+129)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (- t_0 b) (* 2.0 a)))
(if (>= b 0.0) (/ (- c) b) 0.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+115) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 1.2e+129) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - t_0);
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -c / b;
} else {
tmp_1 = 0.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+115)) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 * c) / (b * (-2.0d0))
else
tmp_2 = (b * (-2.0d0)) / (2.0d0 * a)
end if
tmp_1 = tmp_2
else if (b <= 1.2d+129) then
if (b >= 0.0d0) then
tmp_3 = (2.0d0 * c) / (-b - t_0)
else
tmp_3 = (t_0 - b) / (2.0d0 * a)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = -c / b
else
tmp_1 = 0.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+115) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 1.2e+129) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - t_0);
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -c / b;
} else {
tmp_1 = 0.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+115: tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 * c) / (b * -2.0) else: tmp_2 = (b * -2.0) / (2.0 * a) tmp_1 = tmp_2 elif b <= 1.2e+129: tmp_3 = 0 if b >= 0.0: tmp_3 = (2.0 * c) / (-b - t_0) else: tmp_3 = (t_0 - b) / (2.0 * a) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = -c / b else: tmp_1 = 0.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+115) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_2 = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= 1.2e+129) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_3 = Float64(Float64(t_0 - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(-c) / b); else tmp_1 = 0.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+115) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 * c) / (b * -2.0); else tmp_3 = (b * -2.0) / (2.0 * a); end tmp_2 = tmp_3; elseif (b <= 1.2e+129) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (2.0 * c) / (-b - t_0); else tmp_4 = (t_0 - b) / (2.0 * a); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = -c / b; else tmp_2 = 0.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+115], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.2e+129], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[((-c) / b), $MachinePrecision], 0.0]]]]
\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^{+115}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.2 \cdot 10^{+129}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b < -1e115Initial program 46.6%
Taylor expanded in b around inf 46.6%
*-commutative46.6%
Simplified46.6%
add-cube-cbrt46.6%
pow346.6%
associate-*l*46.6%
Applied egg-rr46.6%
Taylor expanded in b around -inf 92.7%
if -1e115 < b < 1.1999999999999999e129Initial program 91.6%
if 1.1999999999999999e129 < b Initial program 44.5%
Simplified44.6%
Taylor expanded in b around inf 98.1%
Taylor expanded in c around 0 98.1%
Taylor expanded in b around 0 98.3%
associate-*r/98.3%
mul-1-neg98.3%
Simplified98.3%
Final simplification93.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= b -1e+115)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ (* b -2.0) (* 2.0 a)))
(if (<= b -2e-310)
(if (>= b 0.0)
(* (* 2.0 c) (* (/ b a) (/ 0.5 c)))
(/ (- t_0 b) (* 2.0 a)))
(if (<= b 1e+132)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) t_0))
(* c (- (/ 1.0 b) (/ b (* c a)))))
(if (>= b 0.0) (/ (- c) b) 0.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+115) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= -2e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) * ((b / a) * (0.5 / c));
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b <= 1e+132) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (2.0 * c) / (-b - t_0);
} else {
tmp_4 = c * ((1.0 / b) - (b / (c * a)));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = -c / b;
} else {
tmp_1 = 0.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
real(8) :: tmp_4
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
if (b <= (-1d+115)) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 * c) / (b * (-2.0d0))
else
tmp_2 = (b * (-2.0d0)) / (2.0d0 * a)
end if
tmp_1 = tmp_2
else if (b <= (-2d-310)) then
if (b >= 0.0d0) then
tmp_3 = (2.0d0 * c) * ((b / a) * (0.5d0 / c))
else
tmp_3 = (t_0 - b) / (2.0d0 * a)
end if
tmp_1 = tmp_3
else if (b <= 1d+132) then
if (b >= 0.0d0) then
tmp_4 = (2.0d0 * c) / (-b - t_0)
else
tmp_4 = c * ((1.0d0 / b) - (b / (c * a)))
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = -c / b
else
tmp_1 = 0.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+115) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= -2e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) * ((b / a) * (0.5 / c));
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b <= 1e+132) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (2.0 * c) / (-b - t_0);
} else {
tmp_4 = c * ((1.0 / b) - (b / (c * a)));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = -c / b;
} else {
tmp_1 = 0.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+115: tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 * c) / (b * -2.0) else: tmp_2 = (b * -2.0) / (2.0 * a) tmp_1 = tmp_2 elif b <= -2e-310: tmp_3 = 0 if b >= 0.0: tmp_3 = (2.0 * c) * ((b / a) * (0.5 / c)) else: tmp_3 = (t_0 - b) / (2.0 * a) tmp_1 = tmp_3 elif b <= 1e+132: tmp_4 = 0 if b >= 0.0: tmp_4 = (2.0 * c) / (-b - t_0) else: tmp_4 = c * ((1.0 / b) - (b / (c * a))) tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = -c / b else: tmp_1 = 0.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+115) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_2 = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= -2e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) * Float64(Float64(b / a) * Float64(0.5 / c))); else tmp_3 = Float64(Float64(t_0 - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b <= 1e+132) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_4 = Float64(c * Float64(Float64(1.0 / b) - Float64(b / Float64(c * a)))); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(-c) / b); else tmp_1 = 0.0; end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); tmp_2 = 0.0; if (b <= -1e+115) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 * c) / (b * -2.0); else tmp_3 = (b * -2.0) / (2.0 * a); end tmp_2 = tmp_3; elseif (b <= -2e-310) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (2.0 * c) * ((b / a) * (0.5 / c)); else tmp_4 = (t_0 - b) / (2.0 * a); end tmp_2 = tmp_4; elseif (b <= 1e+132) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = (2.0 * c) / (-b - t_0); else tmp_5 = c * ((1.0 / b) - (b / (c * a))); end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = -c / b; else tmp_2 = 0.0; end tmp_6 = 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+115], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -2e-310], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] * N[(N[(b / a), $MachinePrecision] * N[(0.5 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1e+132], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(c * N[(N[(1.0 / b), $MachinePrecision] - N[(b / N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[((-c) / b), $MachinePrecision], 0.0]]]]]
\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^{+115}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\left(2 \cdot c\right) \cdot \left(\frac{b}{a} \cdot \frac{0.5}{c}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 10^{+132}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \left(\frac{1}{b} - \frac{b}{c \cdot a}\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b < -1e115Initial program 46.6%
Taylor expanded in b around inf 46.6%
*-commutative46.6%
Simplified46.6%
add-cube-cbrt46.6%
pow346.6%
associate-*l*46.6%
Applied egg-rr46.6%
Taylor expanded in b around -inf 92.7%
if -1e115 < b < -1.999999999999994e-310Initial program 94.9%
Taylor expanded in a around 0 94.9%
distribute-lft-out--94.9%
associate-/l*94.9%
fmm-def94.9%
Simplified94.9%
div-inv94.9%
fmm-undef94.9%
Applied egg-rr94.9%
Taylor expanded in a around inf 94.9%
associate-*r/94.9%
*-commutative94.9%
times-frac94.9%
Simplified94.9%
if -1.999999999999994e-310 < b < 9.99999999999999991e131Initial program 88.0%
add-cbrt-cube88.0%
pow388.0%
sqrt-pow288.0%
fmm-def88.0%
*-commutative88.0%
distribute-rgt-neg-in88.0%
distribute-lft-neg-in88.0%
metadata-eval88.0%
*-commutative88.0%
metadata-eval88.0%
Applied egg-rr88.0%
Taylor expanded in b around -inf 88.0%
associate-*r*88.0%
neg-mul-188.0%
*-commutative88.0%
associate-/l*88.0%
Simplified88.0%
Taylor expanded in c around -inf 88.0%
associate-*r*88.0%
mul-1-neg88.0%
*-commutative88.0%
Simplified88.0%
if 9.99999999999999991e131 < b Initial program 44.5%
Simplified44.6%
Taylor expanded in b around inf 98.1%
Taylor expanded in c around 0 98.1%
Taylor expanded in b around 0 98.3%
associate-*r/98.3%
mul-1-neg98.3%
Simplified98.3%
Final simplification93.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (* 2.0 c) (* b -2.0))))
(if (<= b -1e+115)
(if (>= b 0.0) t_0 (/ (* b -2.0) (* 2.0 a)))
(if (<= b -1.7e-281)
(if (>= b 0.0)
(* (* 2.0 c) (* (/ b a) (/ 0.5 c)))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* 2.0 a)))
(if (>= b 0.0) t_0 (* -0.5 (- (sqrt (* c (/ -4.0 a))))))))))
double code(double a, double b, double c) {
double t_0 = (2.0 * c) / (b * -2.0);
double tmp_1;
if (b <= -1e+115) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= -1.7e-281) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) * ((b / a) * (0.5 / c));
} else {
tmp_3 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = -0.5 * -sqrt((c * (-4.0 / a)));
}
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 = (2.0d0 * c) / (b * (-2.0d0))
if (b <= (-1d+115)) then
if (b >= 0.0d0) then
tmp_2 = t_0
else
tmp_2 = (b * (-2.0d0)) / (2.0d0 * a)
end if
tmp_1 = tmp_2
else if (b <= (-1.7d-281)) then
if (b >= 0.0d0) then
tmp_3 = (2.0d0 * c) * ((b / a) * (0.5d0 / c))
else
tmp_3 = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (2.0d0 * a)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = t_0
else
tmp_1 = (-0.5d0) * -sqrt((c * ((-4.0d0) / a)))
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = (2.0 * c) / (b * -2.0);
double tmp_1;
if (b <= -1e+115) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= -1.7e-281) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) * ((b / a) * (0.5 / c));
} else {
tmp_3 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = -0.5 * -Math.sqrt((c * (-4.0 / a)));
}
return tmp_1;
}
def code(a, b, c): t_0 = (2.0 * c) / (b * -2.0) tmp_1 = 0 if b <= -1e+115: tmp_2 = 0 if b >= 0.0: tmp_2 = t_0 else: tmp_2 = (b * -2.0) / (2.0 * a) tmp_1 = tmp_2 elif b <= -1.7e-281: tmp_3 = 0 if b >= 0.0: tmp_3 = (2.0 * c) * ((b / a) * (0.5 / c)) else: tmp_3 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = t_0 else: tmp_1 = -0.5 * -math.sqrt((c * (-4.0 / a))) return tmp_1
function code(a, b, c) t_0 = Float64(Float64(2.0 * c) / Float64(b * -2.0)) tmp_1 = 0.0 if (b <= -1e+115) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_0; else tmp_2 = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= -1.7e-281) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) * Float64(Float64(b / a) * Float64(0.5 / c))); else tmp_3 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = t_0; else tmp_1 = Float64(-0.5 * Float64(-sqrt(Float64(c * Float64(-4.0 / a))))); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = (2.0 * c) / (b * -2.0); tmp_2 = 0.0; if (b <= -1e+115) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_0; else tmp_3 = (b * -2.0) / (2.0 * a); end tmp_2 = tmp_3; elseif (b <= -1.7e-281) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (2.0 * c) * ((b / a) * (0.5 / c)); else tmp_4 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = t_0; else tmp_2 = -0.5 * -sqrt((c * (-4.0 / a))); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1e+115], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -1.7e-281], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] * N[(N[(b / a), $MachinePrecision] * N[(0.5 / c), $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[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], t$95$0, N[(-0.5 * (-N[Sqrt[N[(c * N[(-4.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2 \cdot c}{b \cdot -2}\\
\mathbf{if}\;b \leq -1 \cdot 10^{+115}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq -1.7 \cdot 10^{-281}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\left(2 \cdot c\right) \cdot \left(\frac{b}{a} \cdot \frac{0.5}{c}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(-\sqrt{c \cdot \frac{-4}{a}}\right)\\
\end{array}
\end{array}
if b < -1e115Initial program 46.6%
Taylor expanded in b around inf 46.6%
*-commutative46.6%
Simplified46.6%
add-cube-cbrt46.6%
pow346.6%
associate-*l*46.6%
Applied egg-rr46.6%
Taylor expanded in b around -inf 92.7%
if -1e115 < b < -1.7e-281Initial program 94.7%
Taylor expanded in a around 0 94.7%
distribute-lft-out--94.7%
associate-/l*94.7%
fmm-def94.7%
Simplified94.7%
div-inv94.7%
fmm-undef94.7%
Applied egg-rr94.7%
Taylor expanded in a around inf 94.7%
associate-*r/94.7%
*-commutative94.7%
times-frac94.7%
Simplified94.7%
if -1.7e-281 < b Initial program 69.1%
Taylor expanded in b around inf 75.4%
*-commutative75.4%
Simplified75.4%
add-cube-cbrt75.4%
pow375.4%
associate-*l*75.4%
Applied egg-rr75.4%
Taylor expanded in a around -inf 73.9%
rem-cube-cbrt73.9%
associate-/l*73.9%
unpow273.9%
rem-square-sqrt75.4%
Simplified75.4%
Final simplification84.7%
(FPCore (a b c)
:precision binary64
(if (<= b -2e+114)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ (* b -2.0) (* 2.0 a)))
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (fma a (/ c b) (- b))))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* 2.0 a)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -2e+114) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = (b * -2.0) / (2.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(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -2e+114) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_2 = Float64(Float64(b * -2.0) / Float64(2.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(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(2.0 * a)); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -2e+114], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $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[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{+114}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot 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}{2 \cdot a}\\
\end{array}
\end{array}
if b < -2e114Initial program 46.6%
Taylor expanded in b around inf 46.6%
*-commutative46.6%
Simplified46.6%
add-cube-cbrt46.6%
pow346.6%
associate-*l*46.6%
Applied egg-rr46.6%
Taylor expanded in b around -inf 92.7%
if -2e114 < b Initial program 78.8%
Taylor expanded in a around 0 81.4%
distribute-lft-out--81.4%
associate-/l*82.8%
fmm-def82.8%
Simplified82.8%
Final simplification84.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.2e+112)
(if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ (* b -2.0) (* 2.0 a)))
(if (>= b 0.0)
(* (* 2.0 c) (/ -1.0 (* 2.0 (- b (* a (/ c b))))))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* 2.0 a)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -1.2e+112) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) * (-1.0 / (2.0 * (b - (a * (c / b)))));
} else {
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
}
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 <= (-1.2d+112)) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 * c) / (b * (-2.0d0))
else
tmp_2 = (b * (-2.0d0)) / (2.0d0 * a)
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (2.0d0 * c) * ((-1.0d0) / (2.0d0 * (b - (a * (c / b)))))
else
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (2.0d0 * a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= -1.2e+112) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) * (-1.0 / (2.0 * (b - (a * (c / b)))));
} else {
tmp_1 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= -1.2e+112: tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 * c) / (b * -2.0) else: tmp_2 = (b * -2.0) / (2.0 * a) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (2.0 * c) * (-1.0 / (2.0 * (b - (a * (c / b))))) else: tmp_1 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= -1.2e+112) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b * -2.0)); else tmp_2 = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) * Float64(-1.0 / Float64(2.0 * Float64(b - Float64(a * Float64(c / b)))))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(2.0 * a)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= -1.2e+112) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 * c) / (b * -2.0); else tmp_3 = (b * -2.0) / (2.0 * a); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (2.0 * c) * (-1.0 / (2.0 * (b - (a * (c / b))))); else tmp_2 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a); end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, -1.2e+112], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] * N[(-1.0 / N[(2.0 * N[(b - N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.2 \cdot 10^{+112}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\left(2 \cdot c\right) \cdot \frac{-1}{2 \cdot \left(b - a \cdot \frac{c}{b}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a}\\
\end{array}
\end{array}
if b < -1.2e112Initial program 46.6%
Taylor expanded in b around inf 46.6%
*-commutative46.6%
Simplified46.6%
add-cube-cbrt46.6%
pow346.6%
associate-*l*46.6%
Applied egg-rr46.6%
Taylor expanded in b around -inf 92.7%
if -1.2e112 < b Initial program 78.8%
Taylor expanded in a around 0 81.4%
distribute-lft-out--81.4%
associate-/l*82.8%
fmm-def82.8%
Simplified82.8%
div-inv82.7%
fmm-undef82.7%
Applied egg-rr82.7%
Final simplification84.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (* 2.0 c) (* b -2.0))))
(if (<= b -1.4e-82)
(if (>= b 0.0) t_0 (/ (* b -2.0) (* 2.0 a)))
(if (>= b 0.0) t_0 (/ (sqrt (* a (* c -4.0))) (* 2.0 a))))))
double code(double a, double b, double c) {
double t_0 = (2.0 * c) / (b * -2.0);
double tmp_1;
if (b <= -1.4e-82) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = sqrt((a * (c * -4.0))) / (2.0 * a);
}
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
t_0 = (2.0d0 * c) / (b * (-2.0d0))
if (b <= (-1.4d-82)) then
if (b >= 0.0d0) then
tmp_2 = t_0
else
tmp_2 = (b * (-2.0d0)) / (2.0d0 * a)
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = t_0
else
tmp_1 = sqrt((a * (c * (-4.0d0)))) / (2.0d0 * a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = (2.0 * c) / (b * -2.0);
double tmp_1;
if (b <= -1.4e-82) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_0;
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = Math.sqrt((a * (c * -4.0))) / (2.0 * a);
}
return tmp_1;
}
def code(a, b, c): t_0 = (2.0 * c) / (b * -2.0) tmp_1 = 0 if b <= -1.4e-82: tmp_2 = 0 if b >= 0.0: tmp_2 = t_0 else: tmp_2 = (b * -2.0) / (2.0 * a) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = t_0 else: tmp_1 = math.sqrt((a * (c * -4.0))) / (2.0 * a) return tmp_1
function code(a, b, c) t_0 = Float64(Float64(2.0 * c) / Float64(b * -2.0)) tmp_1 = 0.0 if (b <= -1.4e-82) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_0; else tmp_2 = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = t_0; else tmp_1 = Float64(sqrt(Float64(a * Float64(c * -4.0))) / Float64(2.0 * a)); end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = (2.0 * c) / (b * -2.0); tmp_2 = 0.0; if (b <= -1.4e-82) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_0; else tmp_3 = (b * -2.0) / (2.0 * a); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = t_0; else tmp_2 = sqrt((a * (c * -4.0))) / (2.0 * a); end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(2.0 * c), $MachinePrecision] / N[(b * -2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.4e-82], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], t$95$0, N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2 \cdot c}{b \cdot -2}\\
\mathbf{if}\;b \leq -1.4 \cdot 10^{-82}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{2 \cdot a}\\
\end{array}
\end{array}
if b < -1.40000000000000012e-82Initial program 70.5%
Taylor expanded in b around inf 70.5%
*-commutative70.5%
Simplified70.5%
add-cube-cbrt70.5%
pow370.5%
associate-*l*70.5%
Applied egg-rr70.5%
Taylor expanded in b around -inf 88.1%
if -1.40000000000000012e-82 < b Initial program 73.7%
Taylor expanded in b around inf 78.7%
*-commutative78.7%
Simplified78.7%
add-cube-cbrt78.5%
pow378.5%
associate-*l*78.5%
Applied egg-rr78.5%
Taylor expanded in a around -inf 58.4%
associate-*r*58.4%
mul-1-neg58.4%
rem-cube-cbrt58.4%
unpow258.4%
rem-square-sqrt75.1%
Simplified75.1%
Final simplification79.9%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 c) (* b -2.0)) (/ (* b -2.0) (* 2.0 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 * -2.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) :: tmp
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (b * (-2.0d0))
else
tmp = (b * (-2.0d0)) / (2.0d0 * 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 * -2.0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (b * -2.0) else: tmp = (b * -2.0) / (2.0 * 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 * -2.0) / Float64(2.0 * 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 * -2.0) / (2.0 * 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[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}
\end{array}
Initial program 72.6%
Taylor expanded in b around inf 75.7%
*-commutative75.7%
Simplified75.7%
add-cube-cbrt75.6%
pow375.6%
associate-*l*75.6%
Applied egg-rr75.6%
Taylor expanded in b around -inf 73.0%
Final simplification73.0%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (- c) b) 0.0))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -c / b;
} else {
tmp = 0.0;
}
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 = -c / b
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -c / b;
} else {
tmp = 0.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = -c / b else: tmp = 0.0 return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(-c) / b); else tmp = 0.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = -c / b; else tmp = 0.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[((-c) / b), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
Initial program 72.6%
Simplified72.5%
Taylor expanded in b around inf 75.6%
Taylor expanded in c around 0 38.2%
Taylor expanded in b around 0 38.3%
associate-*r/38.3%
mul-1-neg38.3%
Simplified38.3%
herbie shell --seed 2024165
(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))))