
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) t_0)))))
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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_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) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (-b - t_0) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + t_0)
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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (2.0 * a) else: tmp = (2.0 * c) / (-b + t_0) 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(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + t_0)); 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 = (-b - t_0) / (2.0 * a); else tmp = (2.0 * c) / (-b + t_0); 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[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $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{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t\_0}\\
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) t_0)))))
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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_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) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (-b - t_0) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + t_0)
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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (2.0 * a) else: tmp = (2.0 * c) / (-b + t_0) 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(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + t_0)); 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 = (-b - t_0) / (2.0 * a); else tmp = (2.0 * c) / (-b + t_0); 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[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $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{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t\_0}\\
\end{array}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
(t_1
(if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))))
(if (<= t_1 5e+238)
t_1
(if (>= b 0.0)
(* -0.5 (/ (+ b b) a))
(* c (/ (- 2.0) (* b (+ 2.0 (* -2.0 (* a (/ c (pow b 2.0))))))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (t_0 - b);
}
double t_1 = tmp;
double tmp_1;
if (t_1 <= 5e+238) {
tmp_1 = t_1;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((b + b) / a);
} else {
tmp_1 = c * (-2.0 / (b * (2.0 + (-2.0 * (a * (c / pow(b, 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) :: t_1
real(8) :: tmp
real(8) :: tmp_1
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
if (b >= 0.0d0) then
tmp = (-b - t_0) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (t_0 - b)
end if
t_1 = tmp
if (t_1 <= 5d+238) then
tmp_1 = t_1
else if (b >= 0.0d0) then
tmp_1 = (-0.5d0) * ((b + b) / a)
else
tmp_1 = c * (-2.0d0 / (b * (2.0d0 + ((-2.0d0) * (a * (c / (b ** 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;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (t_0 - b);
}
double t_1 = tmp;
double tmp_1;
if (t_1 <= 5e+238) {
tmp_1 = t_1;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((b + b) / a);
} else {
tmp_1 = c * (-2.0 / (b * (2.0 + (-2.0 * (a * (c / Math.pow(b, 2.0)))))));
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (2.0 * a) else: tmp = (2.0 * c) / (t_0 - b) t_1 = tmp tmp_1 = 0 if t_1 <= 5e+238: tmp_1 = t_1 elif b >= 0.0: tmp_1 = -0.5 * ((b + b) / a) else: tmp_1 = c * (-2.0 / (b * (2.0 + (-2.0 * (a * (c / math.pow(b, 2.0))))))) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(t_0 - b)); end t_1 = tmp tmp_1 = 0.0 if (t_1 <= 5e+238) tmp_1 = t_1; elseif (b >= 0.0) tmp_1 = Float64(-0.5 * Float64(Float64(b + b) / a)); else tmp_1 = Float64(c * Float64(Float64(-2.0) / Float64(b * Float64(2.0 + Float64(-2.0 * Float64(a * Float64(c / (b ^ 2.0)))))))); end return tmp_1 end
function tmp_3 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); tmp = 0.0; if (b >= 0.0) tmp = (-b - t_0) / (2.0 * a); else tmp = (2.0 * c) / (t_0 - b); end t_1 = tmp; tmp_2 = 0.0; if (t_1 <= 5e+238) tmp_2 = t_1; elseif (b >= 0.0) tmp_2 = -0.5 * ((b + b) / a); else tmp_2 = c * (-2.0 / (b * (2.0 + (-2.0 * (a * (c / (b ^ 2.0))))))); end tmp_3 = 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 = If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[t$95$1, 5e+238], t$95$1, If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(c * N[((-2.0) / N[(b * N[(2.0 + N[(-2.0 * N[(a * N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_1 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\
\end{array}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+238}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{-2}{b \cdot \left(2 + -2 \cdot \left(a \cdot \frac{c}{{b}^{2}}\right)\right)}\\
\end{array}
\end{array}
if (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) < 4.99999999999999995e238Initial program 75.7%
if 4.99999999999999995e238 < (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) Initial program 38.7%
Simplified39.6%
Taylor expanded in c around 0 77.7%
Taylor expanded in b around -inf 77.3%
associate-*r*77.3%
mul-1-neg77.3%
associate-/l*88.8%
Simplified88.8%
Final simplification77.9%
(FPCore (a b c)
:precision binary64
(if (<= b -5e-124)
(if (>= b 0.0) (* -0.5 (* b (/ 2.0 a))) (/ c (- b)))
(if (>= b 0.0)
(/ (- (- b) (sqrt (- (* b b) (* c (* a 4.0))))) (* 2.0 a))
(*
(cbrt c)
(*
(/ 2.0 (+ b (sqrt (fma c (* a -4.0) (pow b 2.0)))))
(pow (cbrt c) 2.0))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -5e-124) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -0.5 * (b * (2.0 / a));
} else {
tmp_2 = c / -b;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (-b - sqrt(((b * b) - (c * (a * 4.0))))) / (2.0 * a);
} else {
tmp_1 = cbrt(c) * ((2.0 / (b + sqrt(fma(c, (a * -4.0), pow(b, 2.0))))) * pow(cbrt(c), 2.0));
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -5e-124) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-0.5 * Float64(b * Float64(2.0 / a))); else tmp_2 = Float64(c / Float64(-b)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0))))) / Float64(2.0 * a)); else tmp_1 = Float64(cbrt(c) * Float64(Float64(2.0 / Float64(b + sqrt(fma(c, Float64(a * -4.0), (b ^ 2.0))))) * (cbrt(c) ^ 2.0))); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -5e-124], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(b * N[(2.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[Power[c, 1/3], $MachinePrecision] * N[(N[(2.0 / N[(b + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[N[Power[c, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-124}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \left(b \cdot \frac{2}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{c} \cdot \left(\frac{2}{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, {b}^{2}\right)}} \cdot {\left(\sqrt[3]{c}\right)}^{2}\right)\\
\end{array}
\end{array}
if b < -5.0000000000000003e-124Initial program 67.1%
Simplified67.1%
Taylor expanded in b around -inf 86.1%
mul-1-neg86.1%
distribute-neg-frac286.1%
Simplified86.1%
Taylor expanded in a around 0 86.1%
Taylor expanded in a around 0 86.1%
associate-*r/86.1%
*-commutative86.1%
associate-*r/86.1%
Simplified86.1%
if -5.0000000000000003e-124 < b Initial program 70.8%
Applied egg-rr69.9%
Final simplification75.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
(t_1
(if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))))
(if (<= t_1 5e+238)
t_1
(if (>= b 0.0) (* -0.5 (/ (+ b b) a)) (pow (- (cbrt (/ c b))) 3.0)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (t_0 - b);
}
double t_1 = tmp;
double tmp_1;
if (t_1 <= 5e+238) {
tmp_1 = t_1;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((b + b) / a);
} else {
tmp_1 = pow(-cbrt((c / b)), 3.0);
}
return tmp_1;
}
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (t_0 - b);
}
double t_1 = tmp;
double tmp_1;
if (t_1 <= 5e+238) {
tmp_1 = t_1;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((b + b) / a);
} else {
tmp_1 = Math.pow(-Math.cbrt((c / b)), 3.0);
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(t_0 - b)); end t_1 = tmp tmp_1 = 0.0 if (t_1 <= 5e+238) tmp_1 = t_1; elseif (b >= 0.0) tmp_1 = Float64(-0.5 * Float64(Float64(b + b) / a)); else tmp_1 = Float64(-cbrt(Float64(c / b))) ^ 3.0; end return tmp_1 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 = If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[t$95$1, 5e+238], t$95$1, If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[Power[(-N[Power[N[(c / b), $MachinePrecision], 1/3], $MachinePrecision]), 3.0], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_1 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\
\end{array}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+238}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\
\mathbf{else}:\\
\;\;\;\;{\left(-\sqrt[3]{\frac{c}{b}}\right)}^{3}\\
\end{array}
\end{array}
if (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) < 4.99999999999999995e238Initial program 75.7%
if 4.99999999999999995e238 < (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) Initial program 38.7%
Simplified39.6%
Taylor expanded in c around 0 77.7%
Taylor expanded in b around -inf 88.8%
*-commutative88.8%
Simplified88.8%
add-cube-cbrt88.6%
pow388.6%
associate-*r/88.6%
times-frac88.6%
metadata-eval88.6%
Applied egg-rr88.6%
Taylor expanded in c around -inf 88.6%
mul-1-neg88.6%
Simplified88.6%
Final simplification77.9%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
(t_1
(if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))))
(if (<= t_1 5e+238)
t_1
(if (>= b 0.0) (* -0.5 (/ (+ b b) a)) (cbrt (pow (/ c (- b)) 3.0))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (t_0 - b);
}
double t_1 = tmp;
double tmp_1;
if (t_1 <= 5e+238) {
tmp_1 = t_1;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((b + b) / a);
} else {
tmp_1 = cbrt(pow((c / -b), 3.0));
}
return tmp_1;
}
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (t_0 - b);
}
double t_1 = tmp;
double tmp_1;
if (t_1 <= 5e+238) {
tmp_1 = t_1;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((b + b) / a);
} else {
tmp_1 = Math.cbrt(Math.pow((c / -b), 3.0));
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(t_0 - b)); end t_1 = tmp tmp_1 = 0.0 if (t_1 <= 5e+238) tmp_1 = t_1; elseif (b >= 0.0) tmp_1 = Float64(-0.5 * Float64(Float64(b + b) / a)); else tmp_1 = cbrt((Float64(c / Float64(-b)) ^ 3.0)); end return tmp_1 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 = If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[t$95$1, 5e+238], t$95$1, If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[Power[N[Power[N[(c / (-b)), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_1 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\
\end{array}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+238}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(\frac{c}{-b}\right)}^{3}}\\
\end{array}
\end{array}
if (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) < 4.99999999999999995e238Initial program 75.7%
if 4.99999999999999995e238 < (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) Initial program 38.7%
Simplified39.6%
Taylor expanded in c around 0 77.7%
Taylor expanded in b around -inf 88.8%
*-commutative88.8%
Simplified88.8%
add-cbrt-cube86.5%
pow386.5%
associate-*r/86.6%
times-frac86.6%
metadata-eval86.6%
Applied egg-rr86.6%
Final simplification77.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
(t_1
(if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))))
(if (<= t_1 5e+238)
t_1
(if (>= b 0.0) (* -0.5 (/ (+ b b) a)) (exp (log (/ c (- b))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (t_0 - b);
}
double t_1 = tmp;
double tmp_1;
if (t_1 <= 5e+238) {
tmp_1 = t_1;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((b + b) / a);
} else {
tmp_1 = exp(log((c / -b)));
}
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
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
if (b >= 0.0d0) then
tmp = (-b - t_0) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (t_0 - b)
end if
t_1 = tmp
if (t_1 <= 5d+238) then
tmp_1 = t_1
else if (b >= 0.0d0) then
tmp_1 = (-0.5d0) * ((b + b) / a)
else
tmp_1 = exp(log((c / -b)))
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;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (t_0 - b);
}
double t_1 = tmp;
double tmp_1;
if (t_1 <= 5e+238) {
tmp_1 = t_1;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((b + b) / a);
} else {
tmp_1 = Math.exp(Math.log((c / -b)));
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (2.0 * a) else: tmp = (2.0 * c) / (t_0 - b) t_1 = tmp tmp_1 = 0 if t_1 <= 5e+238: tmp_1 = t_1 elif b >= 0.0: tmp_1 = -0.5 * ((b + b) / a) else: tmp_1 = math.exp(math.log((c / -b))) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(t_0 - b)); end t_1 = tmp tmp_1 = 0.0 if (t_1 <= 5e+238) tmp_1 = t_1; elseif (b >= 0.0) tmp_1 = Float64(-0.5 * Float64(Float64(b + b) / a)); else tmp_1 = exp(log(Float64(c / Float64(-b)))); end return tmp_1 end
function tmp_3 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); tmp = 0.0; if (b >= 0.0) tmp = (-b - t_0) / (2.0 * a); else tmp = (2.0 * c) / (t_0 - b); end t_1 = tmp; tmp_2 = 0.0; if (t_1 <= 5e+238) tmp_2 = t_1; elseif (b >= 0.0) tmp_2 = -0.5 * ((b + b) / a); else tmp_2 = exp(log((c / -b))); end tmp_3 = 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 = If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[t$95$1, 5e+238], t$95$1, If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[Exp[N[Log[N[(c / (-b)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
t_1 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\
\end{array}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{+238}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left(\frac{c}{-b}\right)}\\
\end{array}
\end{array}
if (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) < 4.99999999999999995e238Initial program 75.7%
if 4.99999999999999995e238 < (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) Initial program 38.7%
Simplified39.6%
Taylor expanded in c around 0 77.7%
Taylor expanded in b around -inf 88.8%
*-commutative88.8%
Simplified88.8%
add-exp-log85.8%
associate-*r/85.8%
times-frac85.8%
metadata-eval85.8%
Applied egg-rr85.8%
Final simplification77.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
(t_1
(if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))))
(if (<= t_1 (- INFINITY))
(if (>= b 0.0)
(/ (* 2.0 (- (* a (/ c b)) b)) (* 2.0 a))
(/ (* 2.0 c) (- (- b) b)))
t_1)))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (t_0 - b);
}
double t_1 = tmp;
double tmp_2;
if (t_1 <= -((double) INFINITY)) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * ((a * (c / b)) - b)) / (2.0 * a);
} else {
tmp_3 = (2.0 * c) / (-b - b);
}
tmp_2 = tmp_3;
} else {
tmp_2 = t_1;
}
return tmp_2;
}
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (t_0 - b);
}
double t_1 = tmp;
double tmp_2;
if (t_1 <= -Double.POSITIVE_INFINITY) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * ((a * (c / b)) - b)) / (2.0 * a);
} else {
tmp_3 = (2.0 * c) / (-b - b);
}
tmp_2 = tmp_3;
} else {
tmp_2 = t_1;
}
return tmp_2;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (2.0 * a) else: tmp = (2.0 * c) / (t_0 - b) t_1 = tmp tmp_2 = 0 if t_1 <= -math.inf: tmp_3 = 0 if b >= 0.0: tmp_3 = (2.0 * ((a * (c / b)) - b)) / (2.0 * a) else: tmp_3 = (2.0 * c) / (-b - b) tmp_2 = tmp_3 else: tmp_2 = t_1 return tmp_2
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(t_0 - b)); end t_1 = tmp tmp_2 = 0.0 if (t_1 <= Float64(-Inf)) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b)) / Float64(2.0 * a)); else tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - b)); end tmp_2 = tmp_3; else tmp_2 = t_1; end return tmp_2 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); tmp = 0.0; if (b >= 0.0) tmp = (-b - t_0) / (2.0 * a); else tmp = (2.0 * c) / (t_0 - b); end t_1 = tmp; tmp_3 = 0.0; if (t_1 <= -Inf) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (2.0 * ((a * (c / b)) - b)) / (2.0 * a); else tmp_4 = (2.0 * c) / (-b - b); end tmp_3 = tmp_4; else tmp_3 = t_1; end tmp_5 = tmp_3; 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 = If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[t$95$1, (-Infinity)], If[GreaterEqual[b, 0.0], N[(N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - b), $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 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\
\end{array}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) < -inf.0Initial program 38.9%
Taylor expanded in a around 0 81.3%
distribute-lft-out--81.3%
associate-/l*84.5%
Simplified84.5%
Taylor expanded in b around -inf 84.5%
if -inf.0 < (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) Initial program 73.7%
Final simplification75.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
(t_1 (/ (* 2.0 c) (- t_0 b)))
(t_2 (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) t_1)))
(if (<= t_2 5e+169)
t_2
(if (>= b 0.0) (/ (- (* 2.0 (/ (* a c) b)) (* b 2.0)) (* 2.0 a)) t_1))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double t_1 = (2.0 * c) / (t_0 - b);
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = t_1;
}
double t_2 = tmp;
double tmp_1;
if (t_2 <= 5e+169) {
tmp_1 = t_2;
} else if (b >= 0.0) {
tmp_1 = ((2.0 * ((a * c) / b)) - (b * 2.0)) / (2.0 * a);
} 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) :: t_2
real(8) :: tmp
real(8) :: tmp_1
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
t_1 = (2.0d0 * c) / (t_0 - b)
if (b >= 0.0d0) then
tmp = (-b - t_0) / (2.0d0 * a)
else
tmp = t_1
end if
t_2 = tmp
if (t_2 <= 5d+169) then
tmp_1 = t_2
else if (b >= 0.0d0) then
tmp_1 = ((2.0d0 * ((a * c) / b)) - (b * 2.0d0)) / (2.0d0 * a)
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 = (2.0 * c) / (t_0 - b);
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = t_1;
}
double t_2 = tmp;
double tmp_1;
if (t_2 <= 5e+169) {
tmp_1 = t_2;
} else if (b >= 0.0) {
tmp_1 = ((2.0 * ((a * c) / b)) - (b * 2.0)) / (2.0 * a);
} 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 = (2.0 * c) / (t_0 - b) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (2.0 * a) else: tmp = t_1 t_2 = tmp tmp_1 = 0 if t_2 <= 5e+169: tmp_1 = t_2 elif b >= 0.0: tmp_1 = ((2.0 * ((a * c) / b)) - (b * 2.0)) / (2.0 * a) 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(2.0 * c) / Float64(t_0 - b)) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = t_1; end t_2 = tmp tmp_1 = 0.0 if (t_2 <= 5e+169) tmp_1 = t_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(2.0 * Float64(Float64(a * c) / b)) - Float64(b * 2.0)) / Float64(2.0 * a)); else tmp_1 = t_1; end return tmp_1 end
function tmp_3 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); t_1 = (2.0 * c) / (t_0 - b); tmp = 0.0; if (b >= 0.0) tmp = (-b - t_0) / (2.0 * a); else tmp = t_1; end t_2 = tmp; tmp_2 = 0.0; if (t_2 <= 5e+169) tmp_2 = t_2; elseif (b >= 0.0) tmp_2 = ((2.0 * ((a * c) / b)) - (b * 2.0)) / (2.0 * a); else tmp_2 = t_1; end tmp_3 = 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[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], t$95$1]}, If[LessEqual[t$95$2, 5e+169], t$95$2, If[GreaterEqual[b, 0.0], N[(N[(N[(2.0 * N[(N[(a * c), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(b * 2.0), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $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{2 \cdot c}{t\_0 - b}\\
t_2 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}\\
\mathbf{if}\;t\_2 \leq 5 \cdot 10^{+169}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - b \cdot 2}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) < 5.00000000000000017e169Initial program 74.4%
if 5.00000000000000017e169 < (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) Initial program 51.2%
Taylor expanded in a around 0 68.9%
Final simplification73.2%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= a 4e+210)
(if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))
(if (>= b 0.0)
(* -0.5 (pow (pow (/ b (* a 0.5)) 3.0) 0.3333333333333333))
(/ c (- b))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (a <= 4e+210) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-b - t_0) / (2.0 * a);
} else {
tmp_2 = (2.0 * c) / (t_0 - b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = -0.5 * pow(pow((b / (a * 0.5)), 3.0), 0.3333333333333333);
} else {
tmp_1 = c / -b;
}
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 = sqrt(((b * b) - (c * (a * 4.0d0))))
if (a <= 4d+210) then
if (b >= 0.0d0) then
tmp_2 = (-b - t_0) / (2.0d0 * a)
else
tmp_2 = (2.0d0 * c) / (t_0 - b)
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (-0.5d0) * (((b / (a * 0.5d0)) ** 3.0d0) ** 0.3333333333333333d0)
else
tmp_1 = c / -b
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 (a <= 4e+210) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-b - t_0) / (2.0 * a);
} else {
tmp_2 = (2.0 * c) / (t_0 - b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = -0.5 * Math.pow(Math.pow((b / (a * 0.5)), 3.0), 0.3333333333333333);
} else {
tmp_1 = c / -b;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp_1 = 0 if a <= 4e+210: tmp_2 = 0 if b >= 0.0: tmp_2 = (-b - t_0) / (2.0 * a) else: tmp_2 = (2.0 * c) / (t_0 - b) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = -0.5 * math.pow(math.pow((b / (a * 0.5)), 3.0), 0.3333333333333333) else: tmp_1 = c / -b 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 (a <= 4e+210) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp_2 = Float64(Float64(2.0 * c) / Float64(t_0 - b)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(-0.5 * ((Float64(b / Float64(a * 0.5)) ^ 3.0) ^ 0.3333333333333333)); else tmp_1 = Float64(c / Float64(-b)); end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); tmp_2 = 0.0; if (a <= 4e+210) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (-b - t_0) / (2.0 * a); else tmp_3 = (2.0 * c) / (t_0 - b); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = -0.5 * (((b / (a * 0.5)) ^ 3.0) ^ 0.3333333333333333); else tmp_2 = c / -b; end tmp_4 = 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[a, 4e+210], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-0.5 * N[Power[N[Power[N[(b / N[(a * 0.5), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;a \leq 4 \cdot 10^{+210}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot {\left({\left(\frac{b}{a \cdot 0.5}\right)}^{3}\right)}^{0.3333333333333333}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if a < 3.99999999999999971e210Initial program 73.1%
if 3.99999999999999971e210 < a Initial program 14.9%
Simplified15.8%
Taylor expanded in b around -inf 33.7%
mul-1-neg33.7%
distribute-neg-frac233.7%
Simplified33.7%
Taylor expanded in a around 0 45.6%
Taylor expanded in a around 0 64.2%
associate-*r/64.2%
*-commutative64.2%
associate-*r/64.1%
Simplified64.1%
add-cbrt-cube64.0%
pow1/361.8%
pow361.8%
clear-num61.8%
un-div-inv61.8%
div-inv61.8%
metadata-eval61.8%
Applied egg-rr61.8%
Final simplification72.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= a 1.4e+211)
(if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))
(if (>= b 0.0) (* -0.5 (cbrt (pow (/ b (* a 0.5)) 3.0))) (/ c (- b))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (a <= 1.4e+211) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-b - t_0) / (2.0 * a);
} else {
tmp_2 = (2.0 * c) / (t_0 - b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = -0.5 * cbrt(pow((b / (a * 0.5)), 3.0));
} else {
tmp_1 = c / -b;
}
return tmp_1;
}
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 (a <= 1.4e+211) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-b - t_0) / (2.0 * a);
} else {
tmp_2 = (2.0 * c) / (t_0 - b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = -0.5 * Math.cbrt(Math.pow((b / (a * 0.5)), 3.0));
} else {
tmp_1 = c / -b;
}
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 (a <= 1.4e+211) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp_2 = Float64(Float64(2.0 * c) / Float64(t_0 - b)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(-0.5 * cbrt((Float64(b / Float64(a * 0.5)) ^ 3.0))); else tmp_1 = Float64(c / Float64(-b)); end return tmp_1 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[a, 1.4e+211], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-0.5 * N[Power[N[Power[N[(b / N[(a * 0.5), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;a \leq 1.4 \cdot 10^{+211}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \sqrt[3]{{\left(\frac{b}{a \cdot 0.5}\right)}^{3}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if a < 1.4e211Initial program 73.1%
if 1.4e211 < a Initial program 14.9%
Simplified15.8%
Taylor expanded in b around -inf 33.7%
mul-1-neg33.7%
distribute-neg-frac233.7%
Simplified33.7%
Taylor expanded in a around 0 45.6%
Taylor expanded in a around 0 64.2%
associate-*r/64.2%
*-commutative64.2%
associate-*r/64.1%
Simplified64.1%
add-cbrt-cube64.0%
pow364.0%
clear-num64.0%
un-div-inv64.0%
div-inv64.0%
metadata-eval64.0%
Applied egg-rr64.0%
Final simplification72.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= a 210000000.0)
(if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))
(if (>= b 0.0) (* -0.5 (pow (sqrt (/ b (* a 0.5))) 2.0)) (/ c (- b))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (a <= 210000000.0) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-b - t_0) / (2.0 * a);
} else {
tmp_2 = (2.0 * c) / (t_0 - b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = -0.5 * pow(sqrt((b / (a * 0.5))), 2.0);
} else {
tmp_1 = c / -b;
}
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 = sqrt(((b * b) - (c * (a * 4.0d0))))
if (a <= 210000000.0d0) then
if (b >= 0.0d0) then
tmp_2 = (-b - t_0) / (2.0d0 * a)
else
tmp_2 = (2.0d0 * c) / (t_0 - b)
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (-0.5d0) * (sqrt((b / (a * 0.5d0))) ** 2.0d0)
else
tmp_1 = c / -b
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 (a <= 210000000.0) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-b - t_0) / (2.0 * a);
} else {
tmp_2 = (2.0 * c) / (t_0 - b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = -0.5 * Math.pow(Math.sqrt((b / (a * 0.5))), 2.0);
} else {
tmp_1 = c / -b;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp_1 = 0 if a <= 210000000.0: tmp_2 = 0 if b >= 0.0: tmp_2 = (-b - t_0) / (2.0 * a) else: tmp_2 = (2.0 * c) / (t_0 - b) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = -0.5 * math.pow(math.sqrt((b / (a * 0.5))), 2.0) else: tmp_1 = c / -b 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 (a <= 210000000.0) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp_2 = Float64(Float64(2.0 * c) / Float64(t_0 - b)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(-0.5 * (sqrt(Float64(b / Float64(a * 0.5))) ^ 2.0)); else tmp_1 = Float64(c / Float64(-b)); end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); tmp_2 = 0.0; if (a <= 210000000.0) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (-b - t_0) / (2.0 * a); else tmp_3 = (2.0 * c) / (t_0 - b); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = -0.5 * (sqrt((b / (a * 0.5))) ^ 2.0); else tmp_2 = c / -b; end tmp_4 = 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[a, 210000000.0], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-0.5 * N[Power[N[Sqrt[N[(b / N[(a * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;a \leq 210000000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot {\left(\sqrt{\frac{b}{a \cdot 0.5}}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if a < 2.1e8Initial program 77.3%
if 2.1e8 < a Initial program 45.5%
Simplified45.8%
Taylor expanded in b around -inf 47.0%
mul-1-neg47.0%
distribute-neg-frac247.0%
Simplified47.0%
Taylor expanded in a around 0 55.9%
Taylor expanded in a around 0 62.2%
associate-*r/62.2%
*-commutative62.2%
associate-*r/62.2%
Simplified62.2%
add-sqr-sqrt62.0%
pow262.0%
clear-num62.0%
un-div-inv62.1%
div-inv62.1%
metadata-eval62.1%
Applied egg-rr62.1%
Final simplification73.6%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* -0.5 (/ (+ b b) a)) (* c (/ 2.0 (- (sqrt (fma c (* a -4.0) (* b b))) b)))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -0.5 * ((b + b) / a);
} else {
tmp = c * (2.0 / (sqrt(fma(c, (a * -4.0), (b * b))) - b));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(-0.5 * Float64(Float64(b + b) / a)); else tmp = Float64(c * Float64(2.0 / Float64(sqrt(fma(c, Float64(a * -4.0), Float64(b * b))) - b))); end return tmp end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(2.0 / N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{\sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)} - b}\\
\end{array}
\end{array}
Initial program 69.5%
Simplified69.6%
Taylor expanded in c around 0 70.7%
Final simplification70.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= a 3.4e+16)
(if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))
(if (>= b 0.0) (* -0.5 (expm1 (log1p (/ b (* a 0.5))))) (/ c (- b))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (a <= 3.4e+16) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-b - t_0) / (2.0 * a);
} else {
tmp_2 = (2.0 * c) / (t_0 - b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = -0.5 * expm1(log1p((b / (a * 0.5))));
} else {
tmp_1 = c / -b;
}
return tmp_1;
}
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 (a <= 3.4e+16) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-b - t_0) / (2.0 * a);
} else {
tmp_2 = (2.0 * c) / (t_0 - b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = -0.5 * Math.expm1(Math.log1p((b / (a * 0.5))));
} else {
tmp_1 = c / -b;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp_1 = 0 if a <= 3.4e+16: tmp_2 = 0 if b >= 0.0: tmp_2 = (-b - t_0) / (2.0 * a) else: tmp_2 = (2.0 * c) / (t_0 - b) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = -0.5 * math.expm1(math.log1p((b / (a * 0.5)))) else: tmp_1 = c / -b 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 (a <= 3.4e+16) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp_2 = Float64(Float64(2.0 * c) / Float64(t_0 - b)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(-0.5 * expm1(log1p(Float64(b / Float64(a * 0.5))))); else tmp_1 = Float64(c / Float64(-b)); end return tmp_1 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[a, 3.4e+16], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(Exp[N[Log[1 + N[(b / N[(a * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;a \leq 3.4 \cdot 10^{+16}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{b}{a \cdot 0.5}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if a < 3.4e16Initial program 77.2%
if 3.4e16 < a Initial program 44.4%
Simplified44.7%
Taylor expanded in b around -inf 47.4%
mul-1-neg47.4%
distribute-neg-frac247.4%
Simplified47.4%
Taylor expanded in a around 0 55.3%
Taylor expanded in a around 0 61.9%
associate-*r/61.9%
*-commutative61.9%
associate-*r/61.9%
Simplified61.9%
expm1-log1p-u60.6%
expm1-undefine54.0%
clear-num54.0%
un-div-inv54.0%
div-inv54.0%
metadata-eval54.0%
Applied egg-rr54.0%
expm1-define60.6%
Simplified60.6%
Final simplification73.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= a 2200000000.0)
(if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (- t_0 b)))
(if (>= b 0.0) (* -0.5 (/ (+ b b) a)) (pow (cbrt (/ c (- b))) 3.0)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (a <= 2200000000.0) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-b - t_0) / (2.0 * a);
} else {
tmp_2 = (2.0 * c) / (t_0 - b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((b + b) / a);
} else {
tmp_1 = pow(cbrt((c / -b)), 3.0);
}
return tmp_1;
}
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 (a <= 2200000000.0) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-b - t_0) / (2.0 * a);
} else {
tmp_2 = (2.0 * c) / (t_0 - b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = -0.5 * ((b + b) / a);
} else {
tmp_1 = Math.pow(Math.cbrt((c / -b)), 3.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 (a <= 2200000000.0) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp_2 = Float64(Float64(2.0 * c) / Float64(t_0 - b)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(-0.5 * Float64(Float64(b + b) / a)); else tmp_1 = cbrt(Float64(c / Float64(-b))) ^ 3.0; end return tmp_1 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[a, 2200000000.0], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[Power[N[Power[N[(c / (-b)), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;a \leq 2200000000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t\_0 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\
\mathbf{else}:\\
\;\;\;\;{\left(\sqrt[3]{\frac{c}{-b}}\right)}^{3}\\
\end{array}
\end{array}
if a < 2.2e9Initial program 77.3%
if 2.2e9 < a Initial program 45.5%
Simplified45.8%
Taylor expanded in c around 0 61.1%
Taylor expanded in b around -inf 62.0%
*-commutative62.0%
Simplified62.0%
add-cube-cbrt61.6%
pow361.7%
associate-*r/61.8%
times-frac61.8%
metadata-eval61.8%
Applied egg-rr61.8%
Final simplification73.5%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 (- (* a (/ c b)) b)) (* 2.0 a)) (/ (* 2.0 c) (- (sqrt (- (* b b) (* c (* a 4.0)))) b))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * ((a * (c / b)) - b)) / (2.0 * a);
} else {
tmp = (2.0 * c) / (sqrt(((b * b) - (c * (a * 4.0)))) - b);
}
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 * ((a * (c / b)) - b)) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (sqrt(((b * b) - (c * (a * 4.0d0)))) - b)
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 * ((a * (c / b)) - b)) / (2.0 * a);
} else {
tmp = (2.0 * c) / (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * ((a * (c / b)) - b)) / (2.0 * a) else: tmp = (2.0 * c) / (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b)) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * ((a * (c / b)) - b)) / (2.0 * a); else tmp = (2.0 * c) / (sqrt(((b * b) - (c * (a * 4.0)))) - b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}\\
\end{array}
\end{array}
Initial program 69.5%
Taylor expanded in a around 0 67.8%
distribute-lft-out--67.8%
associate-/l*70.5%
Simplified70.5%
Final simplification70.5%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* -0.5 (* b (/ 2.0 a))) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -0.5 * (b * (2.0 / a));
} else {
tmp = c / -b;
}
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 = (-0.5d0) * (b * (2.0d0 / a))
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -0.5 * (b * (2.0 / a));
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = -0.5 * (b * (2.0 / a)) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(-0.5 * Float64(b * Float64(2.0 / a))); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = -0.5 * (b * (2.0 / a)); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(-0.5 * N[(b * N[(2.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \left(b \cdot \frac{2}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
Initial program 69.5%
Simplified69.6%
Taylor expanded in b around -inf 67.9%
mul-1-neg67.9%
distribute-neg-frac267.9%
Simplified67.9%
Taylor expanded in a around 0 66.0%
Taylor expanded in a around 0 69.0%
associate-*r/69.0%
*-commutative69.0%
associate-*r/68.9%
Simplified68.9%
Final simplification68.9%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* -0.5 (/ (+ b b) a)) (* c (/ 2.0 (* b -2.0)))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -0.5 * ((b + b) / a);
} else {
tmp = c * (2.0 / (b * -2.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 = (-0.5d0) * ((b + b) / a)
else
tmp = c * (2.0d0 / (b * (-2.0d0)))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -0.5 * ((b + b) / a);
} else {
tmp = c * (2.0 / (b * -2.0));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = -0.5 * ((b + b) / a) else: tmp = c * (2.0 / (b * -2.0)) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(-0.5 * Float64(Float64(b + b) / a)); else tmp = Float64(c * Float64(2.0 / Float64(b * -2.0))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = -0.5 * ((b + b) / a); else tmp = c * (2.0 / (b * -2.0)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(c * N[(2.0 / N[(b * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{b \cdot -2}\\
\end{array}
\end{array}
Initial program 69.5%
Simplified69.6%
Taylor expanded in c around 0 70.7%
Taylor expanded in b around -inf 68.9%
*-commutative68.9%
Simplified68.9%
Final simplification68.9%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* -0.5 (/ (+ b b) a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -0.5 * ((b + b) / a);
} else {
tmp = c / -b;
}
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 = (-0.5d0) * ((b + b) / a)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -0.5 * ((b + b) / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = -0.5 * ((b + b) / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(-0.5 * Float64(Float64(b + b) / a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = -0.5 * ((b + b) / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(-0.5 * N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-0.5 \cdot \frac{b + b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
Initial program 69.5%
Simplified69.6%
Taylor expanded in b around -inf 67.9%
mul-1-neg67.9%
distribute-neg-frac267.9%
Simplified67.9%
Taylor expanded in c around 0 69.0%
Final simplification69.0%
herbie shell --seed 2024066
(FPCore (a b c)
:name "jeff quadratic root 1"
:precision binary64
(if (>= b 0.0) (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))))