
(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 11 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 (* 2.0 (- (* a (/ c b)) b)))
(t_1 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= b -7.3e+22)
(if (>= b 0.0) (/ c (- b)) (/ b (- a)))
(if (<= b 6.2e-298)
(if (>= b 0.0) (* (* c 2.0) (/ 1.0 t_0)) (/ (- t_1 b) (* a 2.0)))
(if (<= b 1e+117)
(if (>= b 0.0)
(/ (* c 2.0) (- (- b) t_1))
(* b (+ (/ c (pow b 2.0)) (/ -1.0 a))))
(if (>= b 0.0) (/ (* c 2.0) t_0) (/ (* b -2.0) (* a 2.0))))))))
double code(double a, double b, double c) {
double t_0 = 2.0 * ((a * (c / b)) - b);
double t_1 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -7.3e+22) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 6.2e-298) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) * (1.0 / t_0);
} else {
tmp_3 = (t_1 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b <= 1e+117) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * 2.0) / (-b - t_1);
} else {
tmp_4 = b * ((c / pow(b, 2.0)) + (-1.0 / a));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c * 2.0) / t_0;
} else {
tmp_1 = (b * -2.0) / (a * 2.0);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
real(8) :: tmp_4
t_0 = 2.0d0 * ((a * (c / b)) - b)
t_1 = sqrt(((b * b) - (c * (a * 4.0d0))))
if (b <= (-7.3d+22)) then
if (b >= 0.0d0) then
tmp_2 = c / -b
else
tmp_2 = b / -a
end if
tmp_1 = tmp_2
else if (b <= 6.2d-298) then
if (b >= 0.0d0) then
tmp_3 = (c * 2.0d0) * (1.0d0 / t_0)
else
tmp_3 = (t_1 - b) / (a * 2.0d0)
end if
tmp_1 = tmp_3
else if (b <= 1d+117) then
if (b >= 0.0d0) then
tmp_4 = (c * 2.0d0) / (-b - t_1)
else
tmp_4 = b * ((c / (b ** 2.0d0)) + ((-1.0d0) / a))
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = (c * 2.0d0) / t_0
else
tmp_1 = (b * (-2.0d0)) / (a * 2.0d0)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = 2.0 * ((a * (c / b)) - b);
double t_1 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -7.3e+22) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 6.2e-298) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) * (1.0 / t_0);
} else {
tmp_3 = (t_1 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b <= 1e+117) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * 2.0) / (-b - t_1);
} else {
tmp_4 = b * ((c / Math.pow(b, 2.0)) + (-1.0 / a));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c * 2.0) / t_0;
} else {
tmp_1 = (b * -2.0) / (a * 2.0);
}
return tmp_1;
}
def code(a, b, c): t_0 = 2.0 * ((a * (c / b)) - b) t_1 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp_1 = 0 if b <= -7.3e+22: tmp_2 = 0 if b >= 0.0: tmp_2 = c / -b else: tmp_2 = b / -a tmp_1 = tmp_2 elif b <= 6.2e-298: tmp_3 = 0 if b >= 0.0: tmp_3 = (c * 2.0) * (1.0 / t_0) else: tmp_3 = (t_1 - b) / (a * 2.0) tmp_1 = tmp_3 elif b <= 1e+117: tmp_4 = 0 if b >= 0.0: tmp_4 = (c * 2.0) / (-b - t_1) else: tmp_4 = b * ((c / math.pow(b, 2.0)) + (-1.0 / a)) tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = (c * 2.0) / t_0 else: tmp_1 = (b * -2.0) / (a * 2.0) return tmp_1
function code(a, b, c) t_0 = Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b)) t_1 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) tmp_1 = 0.0 if (b <= -7.3e+22) 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 <= 6.2e-298) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c * 2.0) * Float64(1.0 / t_0)); else tmp_3 = Float64(Float64(t_1 - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b <= 1e+117) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - t_1)); else tmp_4 = Float64(b * Float64(Float64(c / (b ^ 2.0)) + Float64(-1.0 / a))); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c * 2.0) / t_0); else tmp_1 = Float64(Float64(b * -2.0) / Float64(a * 2.0)); end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = 2.0 * ((a * (c / b)) - b); t_1 = sqrt(((b * b) - (c * (a * 4.0)))); tmp_2 = 0.0; if (b <= -7.3e+22) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c / -b; else tmp_3 = b / -a; end tmp_2 = tmp_3; elseif (b <= 6.2e-298) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (c * 2.0) * (1.0 / t_0); else tmp_4 = (t_1 - b) / (a * 2.0); end tmp_2 = tmp_4; elseif (b <= 1e+117) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = (c * 2.0) / (-b - t_1); else tmp_5 = b * ((c / (b ^ 2.0)) + (-1.0 / a)); end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = (c * 2.0) / t_0; else tmp_2 = (b * -2.0) / (a * 2.0); end tmp_6 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -7.3e+22], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[LessEqual[b, 6.2e-298], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1e+117], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - t$95$1), $MachinePrecision]), $MachinePrecision], N[(b * N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 \cdot \left(a \cdot \frac{c}{b} - b\right)\\
t_1 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;b \leq -7.3 \cdot 10^{+22}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-298}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\left(c \cdot 2\right) \cdot \frac{1}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \leq 10^{+117}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - t\_1}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\end{array}
\end{array}
if b < -7.29999999999999979e22Initial program 52.7%
Simplified53.0%
Taylor expanded in c around 0 53.0%
associate-*r/53.0%
mul-1-neg53.0%
Simplified53.0%
Taylor expanded in b around -inf 89.9%
*-commutative89.9%
Simplified89.9%
Taylor expanded in b around 0 89.9%
associate-*r/89.9%
mul-1-neg89.9%
associate-*r/89.9%
neg-mul-189.9%
Simplified89.9%
if -7.29999999999999979e22 < b < 6.2000000000000003e-298Initial program 79.0%
Taylor expanded in a around 0 79.3%
distribute-lft-out--79.3%
associate-/l*79.7%
fmm-def79.7%
Simplified79.7%
div-inv79.7%
fmm-undef79.7%
Applied egg-rr79.7%
if 6.2000000000000003e-298 < b < 1.00000000000000005e117Initial program 84.6%
clear-num84.6%
inv-pow84.6%
Applied egg-rr84.6%
Taylor expanded in b around -inf 84.6%
associate-*r*84.6%
neg-mul-184.6%
+-commutative84.6%
mul-1-neg84.6%
unsub-neg84.6%
Simplified84.6%
if 1.00000000000000005e117 < b Initial program 45.2%
Taylor expanded in b around -inf 45.2%
*-commutative45.2%
Simplified45.2%
Taylor expanded in a around 0 86.2%
distribute-lft-out--86.2%
associate-/l*96.2%
Simplified96.2%
Final simplification87.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (if (>= b 0.0) (/ c (- b)) (/ b (- a)))))
(if (<= b -7.6e+22)
t_0
(if (<= b 6.2e-298)
(if (>= b 0.0)
(* (* c 2.0) (/ 1.0 (* 2.0 (- (* a (/ c b)) b))))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))
(if (<= b 3.8e-85)
(if (>= b 0.0)
(/ (* c 2.0) (- (- b) (sqrt (* c (* a -4.0)))))
(/ (* b -2.0) (* a 2.0)))
t_0)))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c / -b;
} else {
tmp = b / -a;
}
double t_0 = tmp;
double tmp_1;
if (b <= -7.6e+22) {
tmp_1 = t_0;
} else if (b <= 6.2e-298) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (c * 2.0) * (1.0 / (2.0 * ((a * (c / b)) - b)));
} else {
tmp_2 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
tmp_1 = tmp_2;
} else if (b <= 3.8e-85) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (-b - sqrt((c * (a * -4.0))));
} else {
tmp_3 = (b * -2.0) / (a * 2.0);
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
if (b >= 0.0d0) then
tmp = c / -b
else
tmp = b / -a
end if
t_0 = tmp
if (b <= (-7.6d+22)) then
tmp_1 = t_0
else if (b <= 6.2d-298) then
if (b >= 0.0d0) then
tmp_2 = (c * 2.0d0) * (1.0d0 / (2.0d0 * ((a * (c / b)) - b)))
else
tmp_2 = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
end if
tmp_1 = tmp_2
else if (b <= 3.8d-85) then
if (b >= 0.0d0) then
tmp_3 = (c * 2.0d0) / (-b - sqrt((c * (a * (-4.0d0)))))
else
tmp_3 = (b * (-2.0d0)) / (a * 2.0d0)
end if
tmp_1 = tmp_3
else
tmp_1 = t_0
end if
code = tmp_1
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;
}
double t_0 = tmp;
double tmp_1;
if (b <= -7.6e+22) {
tmp_1 = t_0;
} else if (b <= 6.2e-298) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (c * 2.0) * (1.0 / (2.0 * ((a * (c / b)) - b)));
} else {
tmp_2 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
tmp_1 = tmp_2;
} else if (b <= 3.8e-85) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (-b - Math.sqrt((c * (a * -4.0))));
} else {
tmp_3 = (b * -2.0) / (a * 2.0);
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c / -b else: tmp = b / -a t_0 = tmp tmp_1 = 0 if b <= -7.6e+22: tmp_1 = t_0 elif b <= 6.2e-298: tmp_2 = 0 if b >= 0.0: tmp_2 = (c * 2.0) * (1.0 / (2.0 * ((a * (c / b)) - b))) else: tmp_2 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) tmp_1 = tmp_2 elif b <= 3.8e-85: tmp_3 = 0 if b >= 0.0: tmp_3 = (c * 2.0) / (-b - math.sqrt((c * (a * -4.0)))) else: tmp_3 = (b * -2.0) / (a * 2.0) tmp_1 = tmp_3 else: tmp_1 = t_0 return tmp_1
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c / Float64(-b)); else tmp = Float64(b / Float64(-a)); end t_0 = tmp tmp_1 = 0.0 if (b <= -7.6e+22) tmp_1 = t_0; elseif (b <= 6.2e-298) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(c * 2.0) * Float64(1.0 / Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b)))); else tmp_2 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); end tmp_1 = tmp_2; elseif (b <= 3.8e-85) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - sqrt(Float64(c * Float64(a * -4.0))))); else tmp_3 = Float64(Float64(b * -2.0) / Float64(a * 2.0)); end tmp_1 = tmp_3; else tmp_1 = t_0; end return tmp_1 end
function tmp_5 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = c / -b; else tmp = b / -a; end t_0 = tmp; tmp_2 = 0.0; if (b <= -7.6e+22) tmp_2 = t_0; elseif (b <= 6.2e-298) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (c * 2.0) * (1.0 / (2.0 * ((a * (c / b)) - b))); else tmp_3 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); end tmp_2 = tmp_3; elseif (b <= 3.8e-85) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (c * 2.0) / (-b - sqrt((c * (a * -4.0)))); else tmp_4 = (b * -2.0) / (a * 2.0); end tmp_2 = tmp_4; else tmp_2 = t_0; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]]}, If[LessEqual[b, -7.6e+22], t$95$0, If[LessEqual[b, 6.2e-298], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] * N[(1.0 / N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 3.8e-85], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{if}\;b \leq -7.6 \cdot 10^{+22}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-298}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\left(c \cdot 2\right) \cdot \frac{1}{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \leq 3.8 \cdot 10^{-85}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \sqrt{c \cdot \left(a \cdot -4\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -7.6000000000000008e22 or 3.7999999999999999e-85 < b Initial program 60.5%
Simplified60.5%
Taylor expanded in c around 0 71.5%
associate-*r/71.5%
mul-1-neg71.5%
Simplified71.5%
Taylor expanded in b around -inf 87.8%
*-commutative87.8%
Simplified87.8%
Taylor expanded in b around 0 87.8%
associate-*r/87.8%
mul-1-neg87.8%
associate-*r/87.8%
neg-mul-187.8%
Simplified87.8%
if -7.6000000000000008e22 < b < 6.2000000000000003e-298Initial program 79.0%
Taylor expanded in a around 0 79.3%
distribute-lft-out--79.3%
associate-/l*79.7%
fmm-def79.7%
Simplified79.7%
div-inv79.7%
fmm-undef79.7%
Applied egg-rr79.7%
if 6.2000000000000003e-298 < b < 3.7999999999999999e-85Initial program 77.7%
Taylor expanded in b around -inf 77.7%
*-commutative77.7%
Simplified77.7%
Taylor expanded in b around 0 67.4%
associate-*r*22.1%
*-commutative22.1%
*-commutative22.1%
Simplified67.4%
Final simplification83.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ b (- a))) (t_1 (if (>= b 0.0) (/ c (- b)) t_0)))
(if (<= b -7.6e+22)
t_1
(if (<= b 8.5e-303)
(if (>= b 0.0)
(* b (/ (+ (/ c a) (pow t_0 2.0)) c))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))
(if (<= b 2.15e-94)
(if (>= b 0.0)
(/ (* c 2.0) (- (- b) (sqrt (* c (* a -4.0)))))
(/ (* b -2.0) (* a 2.0)))
t_1)))))
double code(double a, double b, double c) {
double t_0 = b / -a;
double tmp;
if (b >= 0.0) {
tmp = c / -b;
} else {
tmp = t_0;
}
double t_1 = tmp;
double tmp_1;
if (b <= -7.6e+22) {
tmp_1 = t_1;
} else if (b <= 8.5e-303) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b * (((c / a) + pow(t_0, 2.0)) / c);
} else {
tmp_2 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
tmp_1 = tmp_2;
} else if (b <= 2.15e-94) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (-b - sqrt((c * (a * -4.0))));
} else {
tmp_3 = (b * -2.0) / (a * 2.0);
}
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 / -a
if (b >= 0.0d0) then
tmp = c / -b
else
tmp = t_0
end if
t_1 = tmp
if (b <= (-7.6d+22)) then
tmp_1 = t_1
else if (b <= 8.5d-303) then
if (b >= 0.0d0) then
tmp_2 = b * (((c / a) + (t_0 ** 2.0d0)) / c)
else
tmp_2 = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
end if
tmp_1 = tmp_2
else if (b <= 2.15d-94) then
if (b >= 0.0d0) then
tmp_3 = (c * 2.0d0) / (-b - sqrt((c * (a * (-4.0d0)))))
else
tmp_3 = (b * (-2.0d0)) / (a * 2.0d0)
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 / -a;
double tmp;
if (b >= 0.0) {
tmp = c / -b;
} else {
tmp = t_0;
}
double t_1 = tmp;
double tmp_1;
if (b <= -7.6e+22) {
tmp_1 = t_1;
} else if (b <= 8.5e-303) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = b * (((c / a) + Math.pow(t_0, 2.0)) / c);
} else {
tmp_2 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
tmp_1 = tmp_2;
} else if (b <= 2.15e-94) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (-b - Math.sqrt((c * (a * -4.0))));
} else {
tmp_3 = (b * -2.0) / (a * 2.0);
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_1;
}
return tmp_1;
}
def code(a, b, c): t_0 = b / -a tmp = 0 if b >= 0.0: tmp = c / -b else: tmp = t_0 t_1 = tmp tmp_1 = 0 if b <= -7.6e+22: tmp_1 = t_1 elif b <= 8.5e-303: tmp_2 = 0 if b >= 0.0: tmp_2 = b * (((c / a) + math.pow(t_0, 2.0)) / c) else: tmp_2 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) tmp_1 = tmp_2 elif b <= 2.15e-94: tmp_3 = 0 if b >= 0.0: tmp_3 = (c * 2.0) / (-b - math.sqrt((c * (a * -4.0)))) else: tmp_3 = (b * -2.0) / (a * 2.0) tmp_1 = tmp_3 else: tmp_1 = t_1 return tmp_1
function code(a, b, c) t_0 = Float64(b / Float64(-a)) tmp = 0.0 if (b >= 0.0) tmp = Float64(c / Float64(-b)); else tmp = t_0; end t_1 = tmp tmp_1 = 0.0 if (b <= -7.6e+22) tmp_1 = t_1; elseif (b <= 8.5e-303) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(b * Float64(Float64(Float64(c / a) + (t_0 ^ 2.0)) / c)); else tmp_2 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); end tmp_1 = tmp_2; elseif (b <= 2.15e-94) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - sqrt(Float64(c * Float64(a * -4.0))))); else tmp_3 = Float64(Float64(b * -2.0) / Float64(a * 2.0)); 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 / -a; tmp = 0.0; if (b >= 0.0) tmp = c / -b; else tmp = t_0; end t_1 = tmp; tmp_2 = 0.0; if (b <= -7.6e+22) tmp_2 = t_1; elseif (b <= 8.5e-303) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = b * (((c / a) + (t_0 ^ 2.0)) / c); else tmp_3 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); end tmp_2 = tmp_3; elseif (b <= 2.15e-94) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (c * 2.0) / (-b - sqrt((c * (a * -4.0)))); else tmp_4 = (b * -2.0) / (a * 2.0); 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 / (-a)), $MachinePrecision]}, Block[{t$95$1 = If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], t$95$0]}, If[LessEqual[b, -7.6e+22], t$95$1, If[LessEqual[b, 8.5e-303], If[GreaterEqual[b, 0.0], N[(b * N[(N[(N[(c / a), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2.15e-94], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{-a}\\
t_1 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}\\
\mathbf{if}\;b \leq -7.6 \cdot 10^{+22}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-303}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;b \cdot \frac{\frac{c}{a} + {t\_0}^{2}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.15 \cdot 10^{-94}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - \sqrt{c \cdot \left(a \cdot -4\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -7.6000000000000008e22 or 2.1499999999999999e-94 < b Initial program 60.5%
Simplified60.5%
Taylor expanded in c around 0 71.5%
associate-*r/71.5%
mul-1-neg71.5%
Simplified71.5%
Taylor expanded in b around -inf 87.8%
*-commutative87.8%
Simplified87.8%
Taylor expanded in b around 0 87.8%
associate-*r/87.8%
mul-1-neg87.8%
associate-*r/87.8%
neg-mul-187.8%
Simplified87.8%
if -7.6000000000000008e22 < b < 8.5e-303Initial program 81.6%
Taylor expanded in a around 0 81.6%
distribute-lft-out--81.6%
associate-/l*81.6%
fmm-def81.6%
Simplified81.6%
Taylor expanded in b around 0 81.6%
Taylor expanded in c around 0 81.6%
unpow281.6%
unpow281.6%
times-frac81.6%
sqr-neg81.6%
mul-1-neg81.6%
*-commutative81.6%
mul-1-neg81.6%
*-commutative81.6%
unpow281.6%
*-commutative81.6%
mul-1-neg81.6%
distribute-neg-frac281.6%
Simplified81.6%
if 8.5e-303 < b < 2.1499999999999999e-94Initial program 73.8%
Taylor expanded in b around -inf 73.8%
*-commutative73.8%
Simplified73.8%
Taylor expanded in b around 0 64.1%
associate-*r*20.9%
*-commutative20.9%
*-commutative20.9%
Simplified64.1%
Final simplification83.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (* c (* a -4.0)))))
(if (<= b -6.2e-18)
(if (>= b 0.0)
(/ (* c 2.0) (- (* 2.0 (/ (* c a) b)) (* b 2.0)))
(fma -1.0 (/ b a) (/ c b)))
(if (<= b 6.2e-298)
(if (>= b 0.0)
(/ (* c 2.0) (* 2.0 (fma a (/ c b) (- b))))
(/ (- t_0 b) (* a 2.0)))
(if (<= b 1.25e-87)
(if (>= b 0.0) (/ (* c 2.0) (- (- b) t_0)) (/ (* b -2.0) (* a 2.0)))
(if (>= b 0.0) (/ c (- b)) (/ b (- a))))))))
double code(double a, double b, double c) {
double t_0 = sqrt((c * (a * -4.0)));
double tmp_1;
if (b <= -6.2e-18) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (c * 2.0) / ((2.0 * ((c * a) / b)) - (b * 2.0));
} else {
tmp_2 = fma(-1.0, (b / a), (c / b));
}
tmp_1 = tmp_2;
} else if (b <= 6.2e-298) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b <= 1.25e-87) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (c * 2.0) / (-b - t_0);
} else {
tmp_4 = (b * -2.0) / (a * 2.0);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = b / -a;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(c * Float64(a * -4.0))) tmp_1 = 0.0 if (b <= -6.2e-18) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(c * 2.0) / Float64(Float64(2.0 * Float64(Float64(c * a) / b)) - Float64(b * 2.0))); else tmp_2 = fma(-1.0, Float64(b / a), Float64(c / b)); end tmp_1 = tmp_2; elseif (b <= 6.2e-298) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c * 2.0) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_3 = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b <= 1.25e-87) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - t_0)); else tmp_4 = Float64(Float64(b * -2.0) / Float64(a * 2.0)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(c / Float64(-b)); else tmp_1 = Float64(b / Float64(-a)); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -6.2e-18], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(N[(2.0 * N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 6.2e-298], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.25e-87], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{c \cdot \left(a \cdot -4\right)}\\
\mathbf{if}\;b \leq -6.2 \cdot 10^{-18}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \frac{c \cdot a}{b} - b \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\end{array}\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-298}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.25 \cdot 10^{-87}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}
\end{array}
if b < -6.20000000000000014e-18Initial program 57.2%
Taylor expanded in b around -inf 82.7%
associate-*r*82.7%
mul-1-neg82.7%
associate-/l*88.8%
Simplified88.8%
Taylor expanded in a around inf 88.8%
fma-define88.8%
Simplified88.8%
Taylor expanded in a around 0 88.8%
if -6.20000000000000014e-18 < b < 6.2000000000000003e-298Initial program 76.4%
Taylor expanded in a around 0 76.8%
distribute-lft-out--76.8%
associate-/l*77.3%
fmm-def77.3%
Simplified77.3%
Taylor expanded in b around 0 62.7%
associate-*r*75.9%
*-commutative75.9%
*-commutative75.9%
Simplified62.7%
if 6.2000000000000003e-298 < b < 1.25000000000000011e-87Initial program 77.7%
Taylor expanded in b around -inf 77.7%
*-commutative77.7%
Simplified77.7%
Taylor expanded in b around 0 67.4%
associate-*r*22.1%
*-commutative22.1%
*-commutative22.1%
Simplified67.4%
if 1.25000000000000011e-87 < b Initial program 66.6%
Simplified66.4%
Taylor expanded in c around 0 86.2%
associate-*r/86.2%
mul-1-neg86.2%
Simplified86.2%
Taylor expanded in b around -inf 86.2%
*-commutative86.2%
Simplified86.2%
Taylor expanded in b around 0 86.2%
associate-*r/86.2%
mul-1-neg86.2%
associate-*r/86.2%
neg-mul-186.2%
Simplified86.2%
Final simplification80.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (* c (* a -4.0)))))
(if (<= b -6.8e-18)
(if (>= b 0.0)
(/ (* c 2.0) (- (* 2.0 (/ (* c a) b)) (* b 2.0)))
(fma -1.0 (/ b a) (/ c b)))
(if (<= b 6.2e-298)
(if (>= b 0.0)
(/ (* c 2.0) (* 2.0 (fma a (/ c b) (- b))))
(/ (- t_0 b) (* a 2.0)))
(if (<= b 1.8e-84)
(if (>= b 0.0) (* c (/ 2.0 (- (- b) t_0))) (/ (* b -2.0) (* a 2.0)))
(if (>= b 0.0) (/ c (- b)) (/ b (- a))))))))
double code(double a, double b, double c) {
double t_0 = sqrt((c * (a * -4.0)));
double tmp_1;
if (b <= -6.8e-18) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (c * 2.0) / ((2.0 * ((c * a) / b)) - (b * 2.0));
} else {
tmp_2 = fma(-1.0, (b / a), (c / b));
}
tmp_1 = tmp_2;
} else if (b <= 6.2e-298) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (2.0 * fma(a, (c / b), -b));
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b <= 1.8e-84) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = c * (2.0 / (-b - t_0));
} else {
tmp_4 = (b * -2.0) / (a * 2.0);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = b / -a;
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(c * Float64(a * -4.0))) tmp_1 = 0.0 if (b <= -6.8e-18) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(c * 2.0) / Float64(Float64(2.0 * Float64(Float64(c * a) / b)) - Float64(b * 2.0))); else tmp_2 = fma(-1.0, Float64(b / a), Float64(c / b)); end tmp_1 = tmp_2; elseif (b <= 6.2e-298) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c * 2.0) / Float64(2.0 * fma(a, Float64(c / b), Float64(-b)))); else tmp_3 = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b <= 1.8e-84) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(c * Float64(2.0 / Float64(Float64(-b) - t_0))); else tmp_4 = Float64(Float64(b * -2.0) / Float64(a * 2.0)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(c / Float64(-b)); else tmp_1 = Float64(b / Float64(-a)); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -6.8e-18], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(N[(2.0 * N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] - N[(b * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 6.2e-298], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(2.0 * N[(a * N[(c / b), $MachinePrecision] + (-b)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.8e-84], If[GreaterEqual[b, 0.0], N[(c * N[(2.0 / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{c \cdot \left(a \cdot -4\right)}\\
\mathbf{if}\;b \leq -6.8 \cdot 10^{-18}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \frac{c \cdot a}{b} - b \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\end{array}\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-298}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \mathsf{fma}\left(a, \frac{c}{b}, -b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-84}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}
\end{array}
if b < -6.80000000000000002e-18Initial program 57.2%
Taylor expanded in b around -inf 82.7%
associate-*r*82.7%
mul-1-neg82.7%
associate-/l*88.8%
Simplified88.8%
Taylor expanded in a around inf 88.8%
fma-define88.8%
Simplified88.8%
Taylor expanded in a around 0 88.8%
if -6.80000000000000002e-18 < b < 6.2000000000000003e-298Initial program 76.4%
Taylor expanded in a around 0 76.8%
distribute-lft-out--76.8%
associate-/l*77.3%
fmm-def77.3%
Simplified77.3%
Taylor expanded in b around 0 62.7%
associate-*r*75.9%
*-commutative75.9%
*-commutative75.9%
Simplified62.7%
if 6.2000000000000003e-298 < b < 1.80000000000000002e-84Initial program 77.7%
Taylor expanded in b around -inf 77.7%
*-commutative77.7%
Simplified77.7%
Taylor expanded in b around 0 67.4%
associate-*r*22.1%
*-commutative22.1%
*-commutative22.1%
Simplified67.4%
associate-/l*67.4%
Applied egg-rr67.4%
associate-*r/67.4%
*-commutative67.4%
associate-/l*67.3%
Simplified67.3%
if 1.80000000000000002e-84 < b Initial program 66.6%
Simplified66.4%
Taylor expanded in c around 0 86.2%
associate-*r/86.2%
mul-1-neg86.2%
Simplified86.2%
Taylor expanded in b around -inf 86.2%
*-commutative86.2%
Simplified86.2%
Taylor expanded in b around 0 86.2%
associate-*r/86.2%
mul-1-neg86.2%
associate-*r/86.2%
neg-mul-186.2%
Simplified86.2%
Final simplification80.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= b -5.2e+22)
(if (>= b 0.0) (/ c (- b)) (/ b (- a)))
(if (<= b 1.6e+116)
(if (>= b 0.0) (/ (* c 2.0) (- (- b) t_0)) (/ (- t_0 b) (* a 2.0)))
(if (>= b 0.0)
(/ (* c 2.0) (* 2.0 (- (* a (/ c b)) b)))
(/ (* b -2.0) (* a 2.0)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -5.2e+22) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 1.6e+116) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (-b - t_0);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c * 2.0) / (2.0 * ((a * (c / b)) - b));
} else {
tmp_1 = (b * -2.0) / (a * 2.0);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
if (b <= (-5.2d+22)) then
if (b >= 0.0d0) then
tmp_2 = c / -b
else
tmp_2 = b / -a
end if
tmp_1 = tmp_2
else if (b <= 1.6d+116) then
if (b >= 0.0d0) then
tmp_3 = (c * 2.0d0) / (-b - t_0)
else
tmp_3 = (t_0 - b) / (a * 2.0d0)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (c * 2.0d0) / (2.0d0 * ((a * (c / b)) - b))
else
tmp_1 = (b * (-2.0d0)) / (a * 2.0d0)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double tmp_1;
if (b <= -5.2e+22) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / -b;
} else {
tmp_2 = b / -a;
}
tmp_1 = tmp_2;
} else if (b <= 1.6e+116) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (c * 2.0) / (-b - t_0);
} else {
tmp_3 = (t_0 - b) / (a * 2.0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c * 2.0) / (2.0 * ((a * (c / b)) - b));
} else {
tmp_1 = (b * -2.0) / (a * 2.0);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp_1 = 0 if b <= -5.2e+22: tmp_2 = 0 if b >= 0.0: tmp_2 = c / -b else: tmp_2 = b / -a tmp_1 = tmp_2 elif b <= 1.6e+116: tmp_3 = 0 if b >= 0.0: tmp_3 = (c * 2.0) / (-b - t_0) else: tmp_3 = (t_0 - b) / (a * 2.0) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (c * 2.0) / (2.0 * ((a * (c / b)) - b)) else: tmp_1 = (b * -2.0) / (a * 2.0) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) tmp_1 = 0.0 if (b <= -5.2e+22) 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 <= 1.6e+116) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(c * 2.0) / Float64(Float64(-b) - t_0)); else tmp_3 = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(c * 2.0) / Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b))); else tmp_1 = Float64(Float64(b * -2.0) / Float64(a * 2.0)); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); tmp_2 = 0.0; if (b <= -5.2e+22) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c / -b; else tmp_3 = b / -a; end tmp_2 = tmp_3; elseif (b <= 1.6e+116) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (c * 2.0) / (-b - t_0); else tmp_4 = (t_0 - b) / (a * 2.0); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (c * 2.0) / (2.0 * ((a * (c / b)) - b)); else tmp_2 = (b * -2.0) / (a * 2.0); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -5.2e+22], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[LessEqual[b, 1.6e+116], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)}\\
\mathbf{if}\;b \leq -5.2 \cdot 10^{+22}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{+116}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\end{array}
\end{array}
if b < -5.2e22Initial program 52.7%
Simplified53.0%
Taylor expanded in c around 0 53.0%
associate-*r/53.0%
mul-1-neg53.0%
Simplified53.0%
Taylor expanded in b around -inf 89.9%
*-commutative89.9%
Simplified89.9%
Taylor expanded in b around 0 89.9%
associate-*r/89.9%
mul-1-neg89.9%
associate-*r/89.9%
neg-mul-189.9%
Simplified89.9%
if -5.2e22 < b < 1.6e116Initial program 82.3%
if 1.6e116 < b Initial program 45.2%
Taylor expanded in b around -inf 45.2%
*-commutative45.2%
Simplified45.2%
Taylor expanded in a around 0 86.2%
distribute-lft-out--86.2%
associate-/l*96.2%
Simplified96.2%
Final simplification87.2%
(FPCore (a b c)
:precision binary64
(if (or (<= b -7.6e+22) (not (<= b 4.7e-85)))
(if (>= b 0.0) (/ c (- b)) (/ b (- a)))
(if (>= b 0.0)
(/ -1.0 (/ (+ b (sqrt (* c (* a -4.0)))) (* c 2.0)))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))))
double code(double a, double b, double c) {
double tmp_1;
if ((b <= -7.6e+22) || !(b <= 4.7e-85)) {
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 = -1.0 / ((b + sqrt((c * (a * -4.0)))) / (c * 2.0));
} else {
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if ((b <= (-7.6d+22)) .or. (.not. (b <= 4.7d-85))) 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 = (-1.0d0) / ((b + sqrt((c * (a * (-4.0d0))))) / (c * 2.0d0))
else
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if ((b <= -7.6e+22) || !(b <= 4.7e-85)) {
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 = -1.0 / ((b + Math.sqrt((c * (a * -4.0)))) / (c * 2.0));
} else {
tmp_1 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if (b <= -7.6e+22) or not (b <= 4.7e-85): 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 = -1.0 / ((b + math.sqrt((c * (a * -4.0)))) / (c * 2.0)) else: tmp_1 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if ((b <= -7.6e+22) || !(b <= 4.7e-85)) 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(-1.0 / Float64(Float64(b + sqrt(Float64(c * Float64(a * -4.0)))) / Float64(c * 2.0))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if ((b <= -7.6e+22) || ~((b <= 4.7e-85))) 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 = -1.0 / ((b + sqrt((c * (a * -4.0)))) / (c * 2.0)); else tmp_2 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[Or[LessEqual[b, -7.6e+22], N[Not[LessEqual[b, 4.7e-85]], $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-1.0 / N[(N[(b + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(c * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.6 \cdot 10^{+22} \lor \neg \left(b \leq 4.7 \cdot 10^{-85}\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{-1}{\frac{b + \sqrt{c \cdot \left(a \cdot -4\right)}}{c \cdot 2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\end{array}
\end{array}
if b < -7.6000000000000008e22 or 4.70000000000000009e-85 < b Initial program 60.5%
Simplified60.5%
Taylor expanded in c around 0 71.5%
associate-*r/71.5%
mul-1-neg71.5%
Simplified71.5%
Taylor expanded in b around -inf 87.8%
*-commutative87.8%
Simplified87.8%
Taylor expanded in b around 0 87.8%
associate-*r/87.8%
mul-1-neg87.8%
associate-*r/87.8%
neg-mul-187.8%
Simplified87.8%
if -7.6000000000000008e22 < b < 4.70000000000000009e-85Initial program 78.5%
add-sqr-sqrt58.8%
pow258.8%
*-commutative58.8%
Applied egg-rr58.8%
Taylor expanded in b around 0 57.6%
associate-*r*57.6%
*-commutative57.6%
*-commutative57.6%
Simplified57.6%
clear-num57.6%
inv-pow57.6%
unpow257.6%
add-sqr-sqrt74.6%
*-commutative74.6%
Applied egg-rr74.6%
unpow-174.6%
*-commutative74.6%
Simplified74.6%
Final simplification83.4%
(FPCore (a b c)
:precision binary64
(if (or (<= b -7.6e+22) (not (<= b 2.95e-87)))
(if (>= b 0.0) (/ c (- b)) (/ b (- a)))
(if (>= b 0.0)
(* (* c 2.0) (/ -1.0 (+ b (sqrt (* c (* a -4.0))))))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))))
double code(double a, double b, double c) {
double tmp_1;
if ((b <= -7.6e+22) || !(b <= 2.95e-87)) {
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 = (c * 2.0) * (-1.0 / (b + sqrt((c * (a * -4.0)))));
} else {
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if ((b <= (-7.6d+22)) .or. (.not. (b <= 2.95d-87))) 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 = (c * 2.0d0) * ((-1.0d0) / (b + sqrt((c * (a * (-4.0d0))))))
else
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if ((b <= -7.6e+22) || !(b <= 2.95e-87)) {
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 = (c * 2.0) * (-1.0 / (b + Math.sqrt((c * (a * -4.0)))));
} else {
tmp_1 = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if (b <= -7.6e+22) or not (b <= 2.95e-87): 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 = (c * 2.0) * (-1.0 / (b + math.sqrt((c * (a * -4.0))))) else: tmp_1 = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if ((b <= -7.6e+22) || !(b <= 2.95e-87)) 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(c * 2.0) * Float64(-1.0 / Float64(b + sqrt(Float64(c * Float64(a * -4.0)))))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if ((b <= -7.6e+22) || ~((b <= 2.95e-87))) 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 = (c * 2.0) * (-1.0 / (b + sqrt((c * (a * -4.0))))); else tmp_2 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[Or[LessEqual[b, -7.6e+22], N[Not[LessEqual[b, 2.95e-87]], $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] * N[(-1.0 / N[(b + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.6 \cdot 10^{+22} \lor \neg \left(b \leq 2.95 \cdot 10^{-87}\right):\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\left(c \cdot 2\right) \cdot \frac{-1}{b + \sqrt{c \cdot \left(a \cdot -4\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\end{array}
\end{array}
if b < -7.6000000000000008e22 or 2.9499999999999998e-87 < b Initial program 60.5%
Simplified60.5%
Taylor expanded in c around 0 71.5%
associate-*r/71.5%
mul-1-neg71.5%
Simplified71.5%
Taylor expanded in b around -inf 87.8%
*-commutative87.8%
Simplified87.8%
Taylor expanded in b around 0 87.8%
associate-*r/87.8%
mul-1-neg87.8%
associate-*r/87.8%
neg-mul-187.8%
Simplified87.8%
if -7.6000000000000008e22 < b < 2.9499999999999998e-87Initial program 78.5%
add-sqr-sqrt58.8%
pow258.8%
*-commutative58.8%
Applied egg-rr58.8%
Taylor expanded in b around 0 57.6%
associate-*r*57.6%
*-commutative57.6%
*-commutative57.6%
Simplified57.6%
div-inv57.6%
unpow257.6%
add-sqr-sqrt74.6%
*-commutative74.6%
Applied egg-rr74.6%
Final simplification83.4%
(FPCore (a b c)
:precision binary64
(if (<= b 3e-91)
(if (>= b 0.0)
(* c (/ 2.0 (- (- b) (sqrt (* c (* a -4.0))))))
(/ (* b -2.0) (* a 2.0)))
(if (>= b 0.0) (/ c (- b)) (/ b (- a)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= 3e-91) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (2.0 / (-b - sqrt((c * (a * -4.0)))));
} else {
tmp_2 = (b * -2.0) / (a * 2.0);
}
tmp_1 = tmp_2;
} 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) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if (b <= 3d-91) then
if (b >= 0.0d0) then
tmp_2 = c * (2.0d0 / (-b - sqrt((c * (a * (-4.0d0))))))
else
tmp_2 = (b * (-2.0d0)) / (a * 2.0d0)
end if
tmp_1 = tmp_2
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 tmp_1;
if (b <= 3e-91) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (2.0 / (-b - Math.sqrt((c * (a * -4.0)))));
} else {
tmp_2 = (b * -2.0) / (a * 2.0);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = c / -b;
} else {
tmp_1 = b / -a;
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= 3e-91: tmp_2 = 0 if b >= 0.0: tmp_2 = c * (2.0 / (-b - math.sqrt((c * (a * -4.0))))) else: tmp_2 = (b * -2.0) / (a * 2.0) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = c / -b else: tmp_1 = b / -a return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= 3e-91) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c * Float64(2.0 / Float64(Float64(-b) - sqrt(Float64(c * Float64(a * -4.0)))))); else tmp_2 = Float64(Float64(b * -2.0) / Float64(a * 2.0)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(c / Float64(-b)); else tmp_1 = Float64(b / Float64(-a)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= 3e-91) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c * (2.0 / (-b - sqrt((c * (a * -4.0))))); else tmp_3 = (b * -2.0) / (a * 2.0); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = c / -b; else tmp_2 = b / -a; end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, 3e-91], If[GreaterEqual[b, 0.0], N[(c * N[(2.0 / N[((-b) - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(c / (-b)), $MachinePrecision], N[(b / (-a)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3 \cdot 10^{-91}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{2}{\left(-b\right) - \sqrt{c \cdot \left(a \cdot -4\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}
\end{array}
if b < 3.0000000000000002e-91Initial program 66.5%
Taylor expanded in b around -inf 68.0%
*-commutative68.0%
Simplified68.0%
Taylor expanded in b around 0 66.0%
associate-*r*55.3%
*-commutative55.3%
*-commutative55.3%
Simplified66.0%
associate-/l*66.0%
Applied egg-rr66.0%
associate-*r/66.0%
*-commutative66.0%
associate-/l*65.9%
Simplified65.9%
if 3.0000000000000002e-91 < b Initial program 66.6%
Simplified66.4%
Taylor expanded in c around 0 86.2%
associate-*r/86.2%
mul-1-neg86.2%
Simplified86.2%
Taylor expanded in b around -inf 86.2%
*-commutative86.2%
Simplified86.2%
Taylor expanded in b around 0 86.2%
associate-*r/86.2%
mul-1-neg86.2%
associate-*r/86.2%
neg-mul-186.2%
Simplified86.2%
Final simplification73.4%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* c 2.0) (* 2.0 (- (* a (/ c b)) b))) (/ (* b -2.0) (* a 2.0))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (c * 2.0) / (2.0 * ((a * (c / b)) - b));
} else {
tmp = (b * -2.0) / (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) / (2.0d0 * ((a * (c / b)) - b))
else
tmp = (b * (-2.0d0)) / (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) / (2.0 * ((a * (c / b)) - b));
} else {
tmp = (b * -2.0) / (a * 2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (c * 2.0) / (2.0 * ((a * (c / b)) - b)) else: tmp = (b * -2.0) / (a * 2.0) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(c * 2.0) / Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b))); else tmp = Float64(Float64(b * -2.0) / 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) / (2.0 * ((a * (c / b)) - b)); else tmp = (b * -2.0) / (a * 2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(c * 2.0), $MachinePrecision] / N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b * -2.0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c \cdot 2}{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot -2}{a \cdot 2}\\
\end{array}
\end{array}
Initial program 66.5%
Taylor expanded in b around -inf 67.5%
*-commutative67.5%
Simplified67.5%
Taylor expanded in a around 0 65.2%
distribute-lft-out--65.2%
associate-/l*67.2%
Simplified67.2%
Final simplification67.2%
(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 66.5%
Simplified66.5%
Taylor expanded in c around 0 66.1%
associate-*r/66.1%
mul-1-neg66.1%
Simplified66.1%
Taylor expanded in b around -inf 67.0%
*-commutative67.0%
Simplified67.0%
Taylor expanded in b around 0 67.0%
associate-*r/67.0%
mul-1-neg67.0%
associate-*r/67.0%
neg-mul-167.0%
Simplified67.0%
Final simplification67.0%
herbie shell --seed 2024154
(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))))