
(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 6 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 (or (<= b -1.35e+154) (not (<= b 7.5e+75)))
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) b)) (/ (* b -2.0) (* 2.0 a)))
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (- t_0 b) (* 2.0 a))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if ((b <= -1.35e+154) || !(b <= 7.5e+75)) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - b);
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - t_0);
} else {
tmp_1 = (t_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) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
if ((b <= (-1.35d+154)) .or. (.not. (b <= 7.5d+75))) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 * c) / (-b - b)
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) / (-b - t_0)
else
tmp_1 = (t_0 - b) / (2.0d0 * a)
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 <= -1.35e+154) || !(b <= 7.5e+75)) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - b);
} else {
tmp_2 = (b * -2.0) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - t_0);
} else {
tmp_1 = (t_0 - b) / (2.0 * a);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp_1 = 0 if (b <= -1.35e+154) or not (b <= 7.5e+75): tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 * c) / (-b - b) else: tmp_2 = (b * -2.0) / (2.0 * a) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (2.0 * c) / (-b - t_0) else: tmp_1 = (t_0 - b) / (2.0 * a) 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 <= -1.35e+154) || !(b <= 7.5e+75)) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - b)); 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(Float64(-b) - t_0)); else tmp_1 = Float64(Float64(t_0 - b) / Float64(2.0 * a)); 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 ((b <= -1.35e+154) || ~((b <= 7.5e+75))) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 * c) / (-b - b); else tmp_3 = (b * -2.0) / (2.0 * a); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (2.0 * c) / (-b - t_0); else tmp_2 = (t_0 - b) / (2.0 * a); 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[Or[LessEqual[b, -1.35e+154], N[Not[LessEqual[b, 7.5e+75]], $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - b), $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[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;b \leq -1.35 \cdot 10^{+154} \lor \neg \left(b \leq 7.5 \cdot 10^{+75}\right):\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\
\end{array}
\end{array}
if b < -1.35000000000000003e154 or 7.4999999999999995e75 < b Initial program 47.8%
Taylor expanded in b around inf 76.1%
Taylor expanded in b around -inf 96.6%
*-commutative96.6%
Simplified96.6%
if -1.35000000000000003e154 < b < 7.4999999999999995e75Initial program 90.9%
Final simplification93.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0)))))
(t_1
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) b)) (/ (* b -2.0) (* 2.0 a)))))
(if (<= b -5e+154)
t_1
(if (<= b -1e-310)
(if (>= b 0.0)
(/ 1.0 (/ (- (- b b) (* b (* -2.0 (* (/ c b) (/ a b))))) (* 2.0 c)))
(/ (- t_0 b) (* 2.0 a)))
(if (<= b 7.5e+75)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) t_0))
(* b (- (/ -1.0 a) (* c (/ (/ -1.0 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 = (2.0 * c) / (-b - b);
} else {
tmp = (b * -2.0) / (2.0 * a);
}
double t_1 = tmp;
double tmp_1;
if (b <= -5e+154) {
tmp_1 = t_1;
} else if (b <= -1e-310) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = 1.0 / (((b - b) - (b * (-2.0 * ((c / b) * (a / b))))) / (2.0 * c));
} else {
tmp_2 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 7.5e+75) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - t_0);
} else {
tmp_3 = b * ((-1.0 / a) - (c * ((-1.0 / b) / b)));
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_1;
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (-b - b)
else
tmp = (b * (-2.0d0)) / (2.0d0 * a)
end if
t_1 = tmp
if (b <= (-5d+154)) then
tmp_1 = t_1
else if (b <= (-1d-310)) then
if (b >= 0.0d0) then
tmp_2 = 1.0d0 / (((b - b) - (b * ((-2.0d0) * ((c / b) * (a / b))))) / (2.0d0 * c))
else
tmp_2 = (t_0 - b) / (2.0d0 * a)
end if
tmp_1 = tmp_2
else if (b <= 7.5d+75) then
if (b >= 0.0d0) then
tmp_3 = (2.0d0 * c) / (-b - t_0)
else
tmp_3 = b * (((-1.0d0) / a) - (c * (((-1.0d0) / b) / b)))
end if
tmp_1 = tmp_3
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 tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - b);
} else {
tmp = (b * -2.0) / (2.0 * a);
}
double t_1 = tmp;
double tmp_1;
if (b <= -5e+154) {
tmp_1 = t_1;
} else if (b <= -1e-310) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = 1.0 / (((b - b) - (b * (-2.0 * ((c / b) * (a / b))))) / (2.0 * c));
} else {
tmp_2 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 7.5e+75) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - t_0);
} else {
tmp_3 = b * ((-1.0 / a) - (c * ((-1.0 / b) / b)));
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_1;
}
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 = (2.0 * c) / (-b - b) else: tmp = (b * -2.0) / (2.0 * a) t_1 = tmp tmp_1 = 0 if b <= -5e+154: tmp_1 = t_1 elif b <= -1e-310: tmp_2 = 0 if b >= 0.0: tmp_2 = 1.0 / (((b - b) - (b * (-2.0 * ((c / b) * (a / b))))) / (2.0 * c)) else: tmp_2 = (t_0 - b) / (2.0 * a) tmp_1 = tmp_2 elif b <= 7.5e+75: tmp_3 = 0 if b >= 0.0: tmp_3 = (2.0 * c) / (-b - t_0) else: tmp_3 = b * ((-1.0 / a) - (c * ((-1.0 / b) / b))) tmp_1 = tmp_3 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)))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - b)); else tmp = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end t_1 = tmp tmp_1 = 0.0 if (b <= -5e+154) tmp_1 = t_1; elseif (b <= -1e-310) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(1.0 / Float64(Float64(Float64(b - b) - Float64(b * Float64(-2.0 * Float64(Float64(c / b) * Float64(a / b))))) / Float64(2.0 * c))); else tmp_2 = Float64(Float64(t_0 - b) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= 7.5e+75) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_3 = Float64(b * Float64(Float64(-1.0 / a) - Float64(c * Float64(Float64(-1.0 / b) / b)))); end tmp_1 = tmp_3; else tmp_1 = t_1; end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-b - b); else tmp = (b * -2.0) / (2.0 * a); end t_1 = tmp; tmp_2 = 0.0; if (b <= -5e+154) tmp_2 = t_1; elseif (b <= -1e-310) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = 1.0 / (((b - b) - (b * (-2.0 * ((c / b) * (a / b))))) / (2.0 * c)); else tmp_3 = (t_0 - b) / (2.0 * a); end tmp_2 = tmp_3; elseif (b <= 7.5e+75) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (2.0 * c) / (-b - t_0); else tmp_4 = b * ((-1.0 / a) - (c * ((-1.0 / b) / b))); end tmp_2 = tmp_4; else tmp_2 = t_1; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - b), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -5e+154], t$95$1, If[LessEqual[b, -1e-310], If[GreaterEqual[b, 0.0], N[(1.0 / N[(N[(N[(b - b), $MachinePrecision] - N[(b * N[(-2.0 * N[(N[(c / b), $MachinePrecision] * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 7.5e+75], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(b * N[(N[(-1.0 / a), $MachinePrecision] - N[(c * N[(N[(-1.0 / b), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $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{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}\\
\mathbf{if}\;b \leq -5 \cdot 10^{+154}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\left(b - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{+75}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(\frac{-1}{a} - c \cdot \frac{\frac{-1}{b}}{b}\right)\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -5.00000000000000004e154 or 7.4999999999999995e75 < b Initial program 47.8%
Taylor expanded in b around inf 76.1%
Taylor expanded in b around -inf 96.6%
*-commutative96.6%
Simplified96.6%
if -5.00000000000000004e154 < b < -9.999999999999969e-311Initial program 88.7%
Taylor expanded in b around inf 88.7%
distribute-lft-in88.7%
*-rgt-identity88.7%
*-commutative88.7%
unpow288.7%
times-frac88.7%
Simplified88.7%
clear-num88.7%
clear-num88.7%
associate--r+88.7%
add-sqr-sqrt88.7%
sqrt-unprod88.7%
sqr-neg88.7%
sqrt-prod88.7%
add-sqr-sqrt88.7%
*-commutative88.7%
Applied egg-rr88.7%
if -9.999999999999969e-311 < b < 7.4999999999999995e75Initial program 93.6%
Taylor expanded in b around -inf 93.6%
mul-1-neg93.6%
*-commutative93.6%
distribute-rgt-neg-in93.6%
+-commutative93.6%
mul-1-neg93.6%
unsub-neg93.6%
unpow293.6%
Simplified93.6%
associate-/r*93.6%
div-inv93.6%
*-un-lft-identity93.6%
times-frac93.6%
Applied egg-rr93.6%
Final simplification93.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (- b) b))
(t_1 (if (>= b 0.0) (/ (* 2.0 c) t_0) (/ (* b -2.0) (* 2.0 a)))))
(if (<= b -1e+154)
t_1
(if (<= b -9.5e-304)
(if (>= b 0.0)
(/ 1.0 (/ (- (- b b) (* b (* -2.0 (* (/ c b) (/ a b))))) (* 2.0 c)))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* 2.0 a)))
(if (<= b 3.4e-38)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (sqrt (* -4.0 (* c a)))))
(/ t_0 (* 2.0 a)))
t_1)))))
double code(double a, double b, double c) {
double t_0 = -b - b;
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / t_0;
} else {
tmp = (b * -2.0) / (2.0 * a);
}
double t_1 = tmp;
double tmp_1;
if (b <= -1e+154) {
tmp_1 = t_1;
} else if (b <= -9.5e-304) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = 1.0 / (((b - b) - (b * (-2.0 * ((c / b) * (a / b))))) / (2.0 * c));
} else {
tmp_2 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 3.4e-38) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - sqrt((-4.0 * (c * a))));
} else {
tmp_3 = t_0 / (2.0 * a);
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_1;
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = -b - b
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / t_0
else
tmp = (b * (-2.0d0)) / (2.0d0 * a)
end if
t_1 = tmp
if (b <= (-1d+154)) then
tmp_1 = t_1
else if (b <= (-9.5d-304)) then
if (b >= 0.0d0) then
tmp_2 = 1.0d0 / (((b - b) - (b * ((-2.0d0) * ((c / b) * (a / b))))) / (2.0d0 * c))
else
tmp_2 = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (2.0d0 * a)
end if
tmp_1 = tmp_2
else if (b <= 3.4d-38) then
if (b >= 0.0d0) then
tmp_3 = (2.0d0 * c) / (-b - sqrt(((-4.0d0) * (c * a))))
else
tmp_3 = t_0 / (2.0d0 * a)
end if
tmp_1 = tmp_3
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 = -b - b;
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / t_0;
} else {
tmp = (b * -2.0) / (2.0 * a);
}
double t_1 = tmp;
double tmp_1;
if (b <= -1e+154) {
tmp_1 = t_1;
} else if (b <= -9.5e-304) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = 1.0 / (((b - b) - (b * (-2.0 * ((c / b) * (a / b))))) / (2.0 * c));
} else {
tmp_2 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 3.4e-38) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - Math.sqrt((-4.0 * (c * a))));
} else {
tmp_3 = t_0 / (2.0 * a);
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_1;
}
return tmp_1;
}
def code(a, b, c): t_0 = -b - b tmp = 0 if b >= 0.0: tmp = (2.0 * c) / t_0 else: tmp = (b * -2.0) / (2.0 * a) t_1 = tmp tmp_1 = 0 if b <= -1e+154: tmp_1 = t_1 elif b <= -9.5e-304: tmp_2 = 0 if b >= 0.0: tmp_2 = 1.0 / (((b - b) - (b * (-2.0 * ((c / b) * (a / b))))) / (2.0 * c)) else: tmp_2 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a) tmp_1 = tmp_2 elif b <= 3.4e-38: tmp_3 = 0 if b >= 0.0: tmp_3 = (2.0 * c) / (-b - math.sqrt((-4.0 * (c * a)))) else: tmp_3 = t_0 / (2.0 * a) tmp_1 = tmp_3 else: tmp_1 = t_1 return tmp_1
function code(a, b, c) t_0 = Float64(Float64(-b) - b) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / t_0); else tmp = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end t_1 = tmp tmp_1 = 0.0 if (b <= -1e+154) tmp_1 = t_1; elseif (b <= -9.5e-304) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(1.0 / Float64(Float64(Float64(b - b) - Float64(b * Float64(-2.0 * Float64(Float64(c / b) * Float64(a / b))))) / Float64(2.0 * c))); else tmp_2 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= 3.4e-38) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(Float64(-4.0 * Float64(c * a))))); else tmp_3 = Float64(t_0 / Float64(2.0 * a)); end tmp_1 = tmp_3; else tmp_1 = t_1; end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = -b - b; tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / t_0; else tmp = (b * -2.0) / (2.0 * a); end t_1 = tmp; tmp_2 = 0.0; if (b <= -1e+154) tmp_2 = t_1; elseif (b <= -9.5e-304) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = 1.0 / (((b - b) - (b * (-2.0 * ((c / b) * (a / b))))) / (2.0 * c)); else tmp_3 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (2.0 * a); end tmp_2 = tmp_3; elseif (b <= 3.4e-38) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (2.0 * c) / (-b - sqrt((-4.0 * (c * a)))); else tmp_4 = t_0 / (2.0 * a); end tmp_2 = tmp_4; else tmp_2 = t_1; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) - b), $MachinePrecision]}, Block[{t$95$1 = If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -1e+154], t$95$1, If[LessEqual[b, -9.5e-304], If[GreaterEqual[b, 0.0], N[(1.0 / N[(N[(N[(b - b), $MachinePrecision] - N[(b * N[(-2.0 * N[(N[(c / b), $MachinePrecision] * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * 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[LessEqual[b, 3.4e-38], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-b\right) - b\\
t_1 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}\\
\mathbf{if}\;b \leq -1 \cdot 10^{+154}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq -9.5 \cdot 10^{-304}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{1}{\frac{\left(b - b\right) - b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)}{2 \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 3.4 \cdot 10^{-38}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{-4 \cdot \left(c \cdot a\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{2 \cdot a}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -1.00000000000000004e154 or 3.4000000000000002e-38 < b Initial program 56.2%
Taylor expanded in b around inf 75.4%
Taylor expanded in b around -inf 92.2%
*-commutative92.2%
Simplified92.2%
if -1.00000000000000004e154 < b < -9.50000000000000023e-304Initial program 89.7%
Taylor expanded in b around inf 89.7%
distribute-lft-in89.7%
*-rgt-identity89.7%
*-commutative89.7%
unpow289.7%
times-frac89.7%
Simplified89.7%
clear-num89.7%
clear-num89.7%
associate--r+89.7%
add-sqr-sqrt89.7%
sqrt-unprod89.7%
sqr-neg89.7%
sqrt-prod89.7%
add-sqr-sqrt89.7%
*-commutative89.7%
Applied egg-rr89.7%
if -9.50000000000000023e-304 < b < 3.4000000000000002e-38Initial program 90.7%
Taylor expanded in b around -inf 90.7%
Taylor expanded in b around 0 80.8%
Final simplification89.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (* -4.0 (* c a))))
(t_1 (- (- b) b))
(t_2 (if (>= b 0.0) (/ (* 2.0 c) t_1) (/ (* b -2.0) (* 2.0 a)))))
(if (<= b -9e-61)
t_2
(if (<= b -9.5e-304)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (+ b (* b (* -2.0 (* (/ c b) (/ a b)))))))
(/ (- t_0 b) (* 2.0 a)))
(if (<= b 1.02e-41)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ t_1 (* 2.0 a)))
t_2)))))
double code(double a, double b, double c) {
double t_0 = sqrt((-4.0 * (c * a)));
double t_1 = -b - b;
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / t_1;
} else {
tmp = (b * -2.0) / (2.0 * a);
}
double t_2 = tmp;
double tmp_1;
if (b <= -9e-61) {
tmp_1 = t_2;
} else if (b <= -9.5e-304) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - (b + (b * (-2.0 * ((c / b) * (a / b))))));
} else {
tmp_2 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 1.02e-41) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - t_0);
} else {
tmp_3 = t_1 / (2.0 * a);
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_2;
}
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
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((-4.0d0) * (c * a)))
t_1 = -b - b
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / t_1
else
tmp = (b * (-2.0d0)) / (2.0d0 * a)
end if
t_2 = tmp
if (b <= (-9d-61)) then
tmp_1 = t_2
else if (b <= (-9.5d-304)) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 * c) / (-b - (b + (b * ((-2.0d0) * ((c / b) * (a / b))))))
else
tmp_2 = (t_0 - b) / (2.0d0 * a)
end if
tmp_1 = tmp_2
else if (b <= 1.02d-41) then
if (b >= 0.0d0) then
tmp_3 = (2.0d0 * c) / (-b - t_0)
else
tmp_3 = t_1 / (2.0d0 * a)
end if
tmp_1 = tmp_3
else
tmp_1 = t_2
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt((-4.0 * (c * a)));
double t_1 = -b - b;
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / t_1;
} else {
tmp = (b * -2.0) / (2.0 * a);
}
double t_2 = tmp;
double tmp_1;
if (b <= -9e-61) {
tmp_1 = t_2;
} else if (b <= -9.5e-304) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - (b + (b * (-2.0 * ((c / b) * (a / b))))));
} else {
tmp_2 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 1.02e-41) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - t_0);
} else {
tmp_3 = t_1 / (2.0 * a);
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_2;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt((-4.0 * (c * a))) t_1 = -b - b tmp = 0 if b >= 0.0: tmp = (2.0 * c) / t_1 else: tmp = (b * -2.0) / (2.0 * a) t_2 = tmp tmp_1 = 0 if b <= -9e-61: tmp_1 = t_2 elif b <= -9.5e-304: tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 * c) / (-b - (b + (b * (-2.0 * ((c / b) * (a / b)))))) else: tmp_2 = (t_0 - b) / (2.0 * a) tmp_1 = tmp_2 elif b <= 1.02e-41: tmp_3 = 0 if b >= 0.0: tmp_3 = (2.0 * c) / (-b - t_0) else: tmp_3 = t_1 / (2.0 * a) tmp_1 = tmp_3 else: tmp_1 = t_2 return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(-4.0 * Float64(c * a))) t_1 = Float64(Float64(-b) - b) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / t_1); else tmp = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end t_2 = tmp tmp_1 = 0.0 if (b <= -9e-61) tmp_1 = t_2; elseif (b <= -9.5e-304) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - Float64(b + Float64(b * Float64(-2.0 * Float64(Float64(c / b) * Float64(a / b))))))); else tmp_2 = Float64(Float64(t_0 - b) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= 1.02e-41) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_3 = Float64(t_1 / Float64(2.0 * a)); end tmp_1 = tmp_3; else tmp_1 = t_2; end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt((-4.0 * (c * a))); t_1 = -b - b; tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / t_1; else tmp = (b * -2.0) / (2.0 * a); end t_2 = tmp; tmp_2 = 0.0; if (b <= -9e-61) tmp_2 = t_2; elseif (b <= -9.5e-304) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 * c) / (-b - (b + (b * (-2.0 * ((c / b) * (a / b)))))); else tmp_3 = (t_0 - b) / (2.0 * a); end tmp_2 = tmp_3; elseif (b <= 1.02e-41) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (2.0 * c) / (-b - t_0); else tmp_4 = t_1 / (2.0 * a); end tmp_2 = tmp_4; else tmp_2 = t_2; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-b) - b), $MachinePrecision]}, Block[{t$95$2 = If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -9e-61], t$95$2, If[LessEqual[b, -9.5e-304], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[(b + N[(b * N[(-2.0 * N[(N[(c / b), $MachinePrecision] * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.02e-41], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{-4 \cdot \left(c \cdot a\right)}\\
t_1 := \left(-b\right) - b\\
t_2 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}\\
\mathbf{if}\;b \leq -9 \cdot 10^{-61}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;b \leq -9.5 \cdot 10^{-304}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left(b + b \cdot \left(-2 \cdot \left(\frac{c}{b} \cdot \frac{a}{b}\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.02 \cdot 10^{-41}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{2 \cdot a}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if b < -9e-61 or 1.02e-41 < b Initial program 66.5%
Taylor expanded in b around inf 80.2%
Taylor expanded in b around -inf 87.3%
*-commutative87.3%
Simplified87.3%
if -9e-61 < b < -9.50000000000000023e-304Initial program 84.9%
Taylor expanded in b around inf 84.9%
distribute-lft-in84.9%
*-rgt-identity84.9%
*-commutative84.9%
unpow284.9%
times-frac84.9%
Simplified84.9%
Taylor expanded in b around 0 82.2%
if -9.50000000000000023e-304 < b < 1.02e-41Initial program 90.7%
Taylor expanded in b around -inf 90.7%
Taylor expanded in b around 0 80.8%
Final simplification85.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (- b) b)))
(if (<= b 5.3e-40)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (sqrt (* -4.0 (* c a)))))
(/ t_0 (* 2.0 a)))
(if (>= b 0.0) (/ (* 2.0 c) t_0) (/ (* b -2.0) (* 2.0 a))))))
double code(double a, double b, double c) {
double t_0 = -b - b;
double tmp_1;
if (b <= 5.3e-40) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - sqrt((-4.0 * (c * a))));
} else {
tmp_2 = t_0 / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / t_0;
} else {
tmp_1 = (b * -2.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 = -b - b
if (b <= 5.3d-40) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 * c) / (-b - sqrt(((-4.0d0) * (c * a))))
else
tmp_2 = t_0 / (2.0d0 * a)
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (2.0d0 * c) / t_0
else
tmp_1 = (b * (-2.0d0)) / (2.0d0 * a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = -b - b;
double tmp_1;
if (b <= 5.3e-40) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - Math.sqrt((-4.0 * (c * a))));
} else {
tmp_2 = t_0 / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / t_0;
} else {
tmp_1 = (b * -2.0) / (2.0 * a);
}
return tmp_1;
}
def code(a, b, c): t_0 = -b - b tmp_1 = 0 if b <= 5.3e-40: tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 * c) / (-b - math.sqrt((-4.0 * (c * a)))) else: tmp_2 = t_0 / (2.0 * a) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (2.0 * c) / t_0 else: tmp_1 = (b * -2.0) / (2.0 * a) return tmp_1
function code(a, b, c) t_0 = Float64(Float64(-b) - b) tmp_1 = 0.0 if (b <= 5.3e-40) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(Float64(-4.0 * Float64(c * a))))); else tmp_2 = Float64(t_0 / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / t_0); else tmp_1 = Float64(Float64(b * -2.0) / Float64(2.0 * a)); end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = -b - b; tmp_2 = 0.0; if (b <= 5.3e-40) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 * c) / (-b - sqrt((-4.0 * (c * a)))); else tmp_3 = t_0 / (2.0 * a); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (2.0 * c) / t_0; else tmp_2 = (b * -2.0) / (2.0 * a); end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) - b), $MachinePrecision]}, If[LessEqual[b, 5.3e-40], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-b\right) - b\\
\mathbf{if}\;b \leq 5.3 \cdot 10^{-40}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{-4 \cdot \left(c \cdot a\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}
\end{array}
if b < 5.3000000000000002e-40Initial program 79.2%
Taylor expanded in b around -inf 74.2%
Taylor expanded in b around 0 71.6%
if 5.3000000000000002e-40 < b Initial program 60.8%
Taylor expanded in b around inf 88.7%
Taylor expanded in b around -inf 88.7%
*-commutative88.7%
Simplified88.7%
Final simplification77.6%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 c) (- (- b) b)) (/ (* 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 - b);
} 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 - b)
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 - b);
} 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 - b) 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(Float64(-b) - b)); 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 - b); 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) - b), $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}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{2 \cdot a}\\
\end{array}
\end{array}
Initial program 72.7%
Taylor expanded in b around inf 69.9%
Taylor expanded in b around -inf 66.7%
*-commutative66.7%
Simplified66.7%
herbie shell --seed 2024097
(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))))