
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (+ (- b) t_0) (* 2.0 a)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (-b - t_0)
else
tmp = (-b + t_0) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-b - t_0) else: tmp = (-b + t_0) / (2.0 * a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-b - t_0); else tmp = (-b + t_0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (+ (- b) t_0) (* 2.0 a)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (-b - t_0)
else
tmp = (-b + t_0) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-b - t_0) else: tmp = (-b + t_0) / (2.0 * a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-b - t_0); else tmp = (-b + t_0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\
\end{array}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a)))))
(t_1 (/ (* 2.0 c) (- (- b) t_0))))
(if (<= b -7e+85)
(if (>= b 0.0)
t_1
(/ (* b (- (- 2.0) (* -2.0 (* a (/ c (pow b 2.0)))))) (* 2.0 a)))
(if (<= b 1.9e+23)
(if (>= b 0.0) t_1 (/ (- t_0 b) (* 2.0 a)))
(if (>= b 0.0) (/ c (- b)) (- (exp (log (/ b a)))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = (2.0 * c) / (-b - t_0);
double tmp_1;
if (b <= -7e+85) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (b * (-2.0 - (-2.0 * (a * (c / pow(b, 2.0)))))) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 1.9e+23) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = -exp(log((b / 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) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (c * (4.0d0 * a))))
t_1 = (2.0d0 * c) / (-b - t_0)
if (b <= (-7d+85)) then
if (b >= 0.0d0) then
tmp_2 = t_1
else
tmp_2 = (b * (-2.0d0 - ((-2.0d0) * (a * (c / (b ** 2.0d0)))))) / (2.0d0 * a)
end if
tmp_1 = tmp_2
else if (b <= 1.9d+23) then
if (b >= 0.0d0) then
tmp_3 = t_1
else
tmp_3 = (t_0 - b) / (2.0d0 * a)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = c / -b
else
tmp_1 = -exp(log((b / 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 * (4.0 * a))));
double t_1 = (2.0 * c) / (-b - t_0);
double tmp_1;
if (b <= -7e+85) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (b * (-2.0 - (-2.0 * (a * (c / Math.pow(b, 2.0)))))) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 1.9e+23) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = -Math.exp(Math.log((b / a)));
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (4.0 * a)))) t_1 = (2.0 * c) / (-b - t_0) tmp_1 = 0 if b <= -7e+85: tmp_2 = 0 if b >= 0.0: tmp_2 = t_1 else: tmp_2 = (b * (-2.0 - (-2.0 * (a * (c / math.pow(b, 2.0)))))) / (2.0 * a) tmp_1 = tmp_2 elif b <= 1.9e+23: tmp_3 = 0 if b >= 0.0: tmp_3 = t_1 else: tmp_3 = (t_0 - b) / (2.0 * a) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = c / -b else: tmp_1 = -math.exp(math.log((b / a))) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) t_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)) tmp_1 = 0.0 if (b <= -7e+85) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(Float64(b * Float64(Float64(-2.0) - Float64(-2.0 * Float64(a * Float64(c / (b ^ 2.0)))))) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= 1.9e+23) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_1; else tmp_3 = Float64(Float64(t_0 - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(c / Float64(-b)); else tmp_1 = Float64(-exp(log(Float64(b / a)))); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (4.0 * a)))); t_1 = (2.0 * c) / (-b - t_0); tmp_2 = 0.0; if (b <= -7e+85) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_1; else tmp_3 = (b * (-2.0 - (-2.0 * (a * (c / (b ^ 2.0)))))) / (2.0 * a); end tmp_2 = tmp_3; elseif (b <= 1.9e+23) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = t_1; else tmp_4 = (t_0 - b) / (2.0 * a); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = c / -b; else tmp_2 = -exp(log((b / a))); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -7e+85], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(b * N[((-2.0) - N[(-2.0 * N[(a * N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.9e+23], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], (-N[Exp[N[Log[N[(b / a), $MachinePrecision]], $MachinePrecision]], $MachinePrecision])]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_1 := \frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{if}\;b \leq -7 \cdot 10^{+85}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \left(\left(-2\right) - -2 \cdot \left(a \cdot \frac{c}{{b}^{2}}\right)\right)}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{+23}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;-e^{\log \left(\frac{b}{a}\right)}\\
\end{array}
\end{array}
if b < -7.0000000000000001e85Initial program 59.2%
Taylor expanded in b around -inf 91.6%
associate-*r*91.6%
mul-1-neg91.6%
associate-/l*93.6%
Simplified93.6%
if -7.0000000000000001e85 < b < 1.89999999999999987e23Initial program 84.3%
if 1.89999999999999987e23 < b Initial program 56.0%
Simplified56.1%
Taylor expanded in b around -inf 56.1%
Taylor expanded in c around 0 92.5%
Taylor expanded in b around inf 92.7%
add-exp-log92.7%
Applied egg-rr92.7%
Final simplification88.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a))))))
(if (or (<= b -2.6e+102) (not (<= b 1.9e+23)))
(if (>= b 0.0) (/ c (- b)) (/ b (- 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 * (4.0 * a))));
double tmp_1;
if ((b <= -2.6e+102) || !(b <= 1.9e+23)) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -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 * (4.0d0 * a))))
if ((b <= (-2.6d+102)) .or. (.not. (b <= 1.9d+23))) then
if (b >= 0.0d0) then
tmp_2 = c / -b
else
tmp_2 = b / -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 * (4.0 * a))));
double tmp_1;
if ((b <= -2.6e+102) || !(b <= 1.9e+23)) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -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 * (4.0 * a)))) tmp_1 = 0 if (b <= -2.6e+102) or not (b <= 1.9e+23): tmp_2 = 0 if b >= 0.0: tmp_2 = c / -b else: tmp_2 = b / -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(4.0 * a)))) tmp_1 = 0.0 if ((b <= -2.6e+102) || !(b <= 1.9e+23)) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / Float64(-b)); else tmp_2 = Float64(b / Float64(-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 * (4.0 * a)))); tmp_2 = 0.0; if ((b <= -2.6e+102) || ~((b <= 1.9e+23))) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c / -b; else tmp_3 = b / -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[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[b, -2.6e+102], N[Not[LessEqual[b, 1.9e+23]], $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $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(4 \cdot a\right)}\\
\mathbf{if}\;b \leq -2.6 \cdot 10^{+102} \lor \neg \left(b \leq 1.9 \cdot 10^{+23}\right):\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-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 < -2.60000000000000006e102 or 1.89999999999999987e23 < b Initial program 55.8%
Simplified55.8%
Taylor expanded in b around -inf 73.0%
Taylor expanded in c around 0 93.4%
neg-mul-193.4%
add-cube-cbrt93.1%
pow393.1%
Applied egg-rr93.1%
Taylor expanded in b around -inf 93.5%
neg-mul-193.5%
distribute-neg-frac93.5%
neg-mul-193.5%
distribute-neg-frac293.5%
Simplified93.5%
if -2.60000000000000006e102 < b < 1.89999999999999987e23Initial program 84.3%
Final simplification88.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a)))))
(t_1 (/ (* 2.0 c) (- (- b) t_0))))
(if (<= b -7e+85)
(if (>= b 0.0)
t_1
(/ (* b (- (- 2.0) (* -2.0 (* a (/ c (pow b 2.0)))))) (* 2.0 a)))
(if (<= b 1.9e+23)
(if (>= b 0.0) t_1 (/ (- t_0 b) (* 2.0 a)))
(if (>= b 0.0) (/ c (- b)) (/ b (- a)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = (2.0 * c) / (-b - t_0);
double tmp_1;
if (b <= -7e+85) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (b * (-2.0 - (-2.0 * (a * (c / pow(b, 2.0)))))) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 1.9e+23) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = b / -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) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (c * (4.0d0 * a))))
t_1 = (2.0d0 * c) / (-b - t_0)
if (b <= (-7d+85)) then
if (b >= 0.0d0) then
tmp_2 = t_1
else
tmp_2 = (b * (-2.0d0 - ((-2.0d0) * (a * (c / (b ** 2.0d0)))))) / (2.0d0 * a)
end if
tmp_1 = tmp_2
else if (b <= 1.9d+23) then
if (b >= 0.0d0) then
tmp_3 = t_1
else
tmp_3 = (t_0 - b) / (2.0d0 * a)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = c / -b
else
tmp_1 = b / -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 * (4.0 * a))));
double t_1 = (2.0 * c) / (-b - t_0);
double tmp_1;
if (b <= -7e+85) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (b * (-2.0 - (-2.0 * (a * (c / Math.pow(b, 2.0)))))) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 1.9e+23) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = b / -a;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (4.0 * a)))) t_1 = (2.0 * c) / (-b - t_0) tmp_1 = 0 if b <= -7e+85: tmp_2 = 0 if b >= 0.0: tmp_2 = t_1 else: tmp_2 = (b * (-2.0 - (-2.0 * (a * (c / math.pow(b, 2.0)))))) / (2.0 * a) tmp_1 = tmp_2 elif b <= 1.9e+23: tmp_3 = 0 if b >= 0.0: tmp_3 = t_1 else: tmp_3 = (t_0 - b) / (2.0 * a) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = c / -b else: tmp_1 = b / -a return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) t_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)) tmp_1 = 0.0 if (b <= -7e+85) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(Float64(b * Float64(Float64(-2.0) - Float64(-2.0 * Float64(a * Float64(c / (b ^ 2.0)))))) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= 1.9e+23) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_1; else tmp_3 = Float64(Float64(t_0 - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(c / Float64(-b)); else tmp_1 = Float64(b / Float64(-a)); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (4.0 * a)))); t_1 = (2.0 * c) / (-b - t_0); tmp_2 = 0.0; if (b <= -7e+85) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_1; else tmp_3 = (b * (-2.0 - (-2.0 * (a * (c / (b ^ 2.0)))))) / (2.0 * a); end tmp_2 = tmp_3; elseif (b <= 1.9e+23) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = t_1; else tmp_4 = (t_0 - b) / (2.0 * a); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = c / -b; else tmp_2 = b / -a; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -7e+85], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(b * N[((-2.0) - N[(-2.0 * N[(a * N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.9e+23], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_1 := \frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{if}\;b \leq -7 \cdot 10^{+85}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \left(\left(-2\right) - -2 \cdot \left(a \cdot \frac{c}{{b}^{2}}\right)\right)}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{+23}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}
\end{array}
if b < -7.0000000000000001e85Initial program 59.2%
Taylor expanded in b around -inf 91.6%
associate-*r*91.6%
mul-1-neg91.6%
associate-/l*93.6%
Simplified93.6%
if -7.0000000000000001e85 < b < 1.89999999999999987e23Initial program 84.3%
if 1.89999999999999987e23 < b Initial program 56.0%
Simplified56.1%
Taylor expanded in b around -inf 56.1%
Taylor expanded in c around 0 92.5%
neg-mul-192.5%
add-cube-cbrt92.5%
pow392.5%
Applied egg-rr92.5%
Taylor expanded in b around -inf 92.7%
neg-mul-192.7%
distribute-neg-frac92.7%
neg-mul-192.7%
distribute-neg-frac292.7%
Simplified92.7%
Final simplification88.5%
(FPCore (a b c)
:precision binary64
(if (<= b -3e+100)
(if (>= b 0.0) (/ c (- b)) (/ b (- a)))
(if (<= b 4.5e-245)
(if (>= b 0.0)
(/ b a)
(/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* 2.0 a)))
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (fma a (/ c b) (- b))))
(/ (- (+ b (/ (* c (* a -2.0)) b)) b) (* 2.0 a))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -3e+100) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 4.5e-245) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = b / a;
} else {
tmp_3 = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_1 = ((b + ((c * (a * -2.0)) / b)) - b) / (2.0 * a);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -3e+100) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / Float64(-b)); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b <= 4.5e-245) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(b / a); else tmp_3 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) - b) / Float64(2.0 * a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_1 = Float64(Float64(Float64(b + Float64(Float64(c * Float64(a * -2.0)) / b)) - b) / Float64(2.0 * a)); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -3e+100], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[LessEqual[b, 4.5e-245], If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b + N[(N[(c * N[(a * -2.0), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3 \cdot 10^{+100}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-245}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(b + \frac{c \cdot \left(a \cdot -2\right)}{b}\right) - b}{2 \cdot a}\\
\end{array}
\end{array}
if b < -2.99999999999999985e100Initial program 55.5%
Simplified55.6%
Taylor expanded in b around -inf 94.5%
Taylor expanded in c around 0 94.5%
neg-mul-194.5%
add-cube-cbrt93.8%
pow393.8%
Applied egg-rr93.8%
Taylor expanded in b around -inf 94.5%
neg-mul-194.5%
distribute-neg-frac94.5%
neg-mul-194.5%
distribute-neg-frac294.5%
Simplified94.5%
if -2.99999999999999985e100 < b < 4.49999999999999969e-245Initial program 81.9%
Taylor expanded in a around 0 73.4%
distribute-lft-out--73.4%
associate-/l*73.3%
fma-neg73.3%
Simplified73.3%
Taylor expanded in c around inf 73.4%
if 4.49999999999999969e-245 < b Initial program 70.3%
Taylor expanded in a around 0 62.3%
distribute-lft-out--62.3%
associate-/l*67.6%
fma-neg67.6%
Simplified67.6%
Taylor expanded in a around 0 67.6%
associate-*r/67.6%
associate-*r*67.6%
Simplified67.6%
Final simplification75.0%
(FPCore (a b c)
:precision binary64
(if (<= b -2e+100)
(if (>= b 0.0) (/ c (- b)) (/ b (- a)))
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (* b (+ (* a (/ c (pow b 2.0))) -1.0))))
(/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* 2.0 a)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -2e+100) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * (b * ((a * (c / pow(b, 2.0))) + -1.0)));
} else {
tmp_1 = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if (b <= (-2d+100)) then
if (b >= 0.0d0) then
tmp_2 = c / -b
else
tmp_2 = b / -a
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (2.0d0 * c) / (2.0d0 * (b * ((a * (c / (b ** 2.0d0))) + (-1.0d0))))
else
tmp_1 = (sqrt(((b * b) - (c * (4.0d0 * a)))) - b) / (2.0d0 * a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= -2e+100) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * (b * ((a * (c / Math.pow(b, 2.0))) + -1.0)));
} else {
tmp_1 = (Math.sqrt(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= -2e+100: tmp_2 = 0 if b >= 0.0: tmp_2 = c / -b else: tmp_2 = b / -a tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (2.0 * c) / (2.0 * (b * ((a * (c / math.pow(b, 2.0))) + -1.0))) else: tmp_1 = (math.sqrt(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= -2e+100) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / Float64(-b)); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * Float64(b * Float64(Float64(a * Float64(c / (b ^ 2.0))) + -1.0)))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) - b) / Float64(2.0 * a)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= -2e+100) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c / -b; else tmp_3 = b / -a; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (2.0 * c) / (2.0 * (b * ((a * (c / (b ^ 2.0))) + -1.0))); else tmp_2 = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a); end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, -2e+100], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(b * N[(N[(a * N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{+100}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(b \cdot \left(a \cdot \frac{c}{{b}^{2}} + -1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\
\end{array}
\end{array}
if b < -2.00000000000000003e100Initial program 55.5%
Simplified55.6%
Taylor expanded in b around -inf 94.5%
Taylor expanded in c around 0 94.5%
neg-mul-194.5%
add-cube-cbrt93.8%
pow393.8%
Applied egg-rr93.8%
Taylor expanded in b around -inf 94.5%
neg-mul-194.5%
distribute-neg-frac94.5%
neg-mul-194.5%
distribute-neg-frac294.5%
Simplified94.5%
if -2.00000000000000003e100 < b Initial program 75.3%
Taylor expanded in a around 0 67.1%
distribute-lft-out--67.1%
associate-/l*70.1%
fma-neg70.1%
Simplified70.1%
Taylor expanded in b around inf 66.6%
sub-neg66.6%
associate-/l*69.5%
metadata-eval69.5%
Simplified69.5%
Final simplification74.5%
(FPCore (a b c)
:precision binary64
(if (<= b -1.6e+102)
(if (>= b 0.0) (/ c (- b)) (/ b (- a)))
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (fma a (/ c b) (- b))))
(/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* 2.0 a)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -1.6e+102) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_1 = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (2.0 * a);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -1.6e+102) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / Float64(-b)); else tmp_2 = Float64(b / Float64(-a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) - b) / Float64(2.0 * a)); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -1.6e+102], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+102}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{2 \cdot a}\\
\end{array}
\end{array}
if b < -1.6e102Initial program 55.5%
Simplified55.6%
Taylor expanded in b around -inf 94.5%
Taylor expanded in c around 0 94.5%
neg-mul-194.5%
add-cube-cbrt93.8%
pow393.8%
Applied egg-rr93.8%
Taylor expanded in b around -inf 94.5%
neg-mul-194.5%
distribute-neg-frac94.5%
neg-mul-194.5%
distribute-neg-frac294.5%
Simplified94.5%
if -1.6e102 < b Initial program 75.3%
Taylor expanded in a around 0 67.1%
distribute-lft-out--67.1%
associate-/l*70.1%
fma-neg70.1%
Simplified70.1%
Final simplification75.0%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* c (/ -2.0 (+ b (+ b (* -2.0 (* a (/ c b))))))) (/ (+ b b) (* a -2.0))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c * (-2.0 / (b + (b + (-2.0 * (a * (c / b))))));
} else {
tmp = (b + b) / (a * -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 = c * ((-2.0d0) / (b + (b + ((-2.0d0) * (a * (c / b))))))
else
tmp = (b + b) / (a * (-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 = c * (-2.0 / (b + (b + (-2.0 * (a * (c / b))))));
} else {
tmp = (b + b) / (a * -2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c * (-2.0 / (b + (b + (-2.0 * (a * (c / b)))))) else: tmp = (b + b) / (a * -2.0) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c * Float64(-2.0 / Float64(b + Float64(b + Float64(-2.0 * Float64(a * Float64(c / b))))))); else tmp = Float64(Float64(b + b) / Float64(a * -2.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = c * (-2.0 / (b + (b + (-2.0 * (a * (c / b)))))); else tmp = (b + b) / (a * -2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + N[(b + N[(-2.0 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + b), $MachinePrecision] / N[(a * -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + \left(b + -2 \cdot \left(a \cdot \frac{c}{b}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + b}{a \cdot -2}\\
\end{array}
\end{array}
Initial program 71.4%
Simplified71.4%
Taylor expanded in b around -inf 68.6%
Taylor expanded in c around 0 61.9%
associate-/l*64.3%
Simplified64.3%
Final simplification64.3%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ c (- b)) (/ b (- a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c / -b;
} else {
tmp = b / -a;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = c / -b
else
tmp = b / -a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c / -b;
} else {
tmp = b / -a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c / -b else: tmp = b / -a return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c / Float64(-b)); else tmp = Float64(b / Float64(-a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = c / -b; else tmp = b / -a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}
\end{array}
Initial program 71.4%
Simplified71.4%
Taylor expanded in b around -inf 68.6%
Taylor expanded in c around 0 64.1%
neg-mul-164.1%
add-cube-cbrt63.8%
pow363.9%
Applied egg-rr63.9%
Taylor expanded in b around -inf 64.2%
neg-mul-164.2%
distribute-neg-frac64.2%
neg-mul-164.2%
distribute-neg-frac264.2%
Simplified64.2%
Final simplification64.2%
herbie shell --seed 2024120
(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))))