
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) t_0)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (-b - t_0) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + t_0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (2.0 * a) else: tmp = (2.0 * c) / (-b + t_0) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + t_0)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b >= 0.0) tmp = (-b - t_0) / (2.0 * a); else tmp = (2.0 * c) / (-b + t_0); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t_0}\\
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) t_0)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (-b - t_0) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + t_0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (2.0 * a) else: tmp = (2.0 * c) / (-b + t_0) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + t_0)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b >= 0.0) tmp = (-b - t_0) / (2.0 * a); else tmp = (2.0 * c) / (-b + t_0); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t_0}\\
\end{array}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a))))))
(if (<= b -2e+122)
(if (>= b 0.0) (/ c b) (/ (- c) b))
(if (<= b 2e+153)
(if (>= b 0.0) (/ (- (- b) t_0) (* a 2.0)) (/ (* c 2.0) (- t_0 b)))
(if (>= b 0.0) (- (/ c b) (/ b a)) (* (/ 2.0 b) (* c -0.5)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double tmp_1;
if (b <= -2e+122) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / b;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 2e+153) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_0) / (a * 2.0);
} else {
tmp_3 = (c * 2.0) / (t_0 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = (2.0 / b) * (c * -0.5);
}
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 * (4.0d0 * a))))
if (b <= (-2d+122)) then
if (b >= 0.0d0) then
tmp_2 = c / b
else
tmp_2 = -c / b
end if
tmp_1 = tmp_2
else if (b <= 2d+153) then
if (b >= 0.0d0) then
tmp_3 = (-b - t_0) / (a * 2.0d0)
else
tmp_3 = (c * 2.0d0) / (t_0 - b)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (c / b) - (b / a)
else
tmp_1 = (2.0d0 / b) * (c * (-0.5d0))
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 <= -2e+122) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / b;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 2e+153) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_0) / (a * 2.0);
} else {
tmp_3 = (c * 2.0) / (t_0 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = (2.0 / b) * (c * -0.5);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (4.0 * a)))) tmp_1 = 0 if b <= -2e+122: tmp_2 = 0 if b >= 0.0: tmp_2 = c / b else: tmp_2 = -c / b tmp_1 = tmp_2 elif b <= 2e+153: tmp_3 = 0 if b >= 0.0: tmp_3 = (-b - t_0) / (a * 2.0) else: tmp_3 = (c * 2.0) / (t_0 - b) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (c / b) - (b / a) else: tmp_1 = (2.0 / b) * (c * -0.5) 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 <= -2e+122) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / b); else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b <= 2e+153) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(-b) - t_0) / Float64(a * 2.0)); else tmp_3 = Float64(Float64(c * 2.0) / Float64(t_0 - b)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = Float64(Float64(2.0 / b) * Float64(c * -0.5)); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (4.0 * a)))); tmp_2 = 0.0; if (b <= -2e+122) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c / b; else tmp_3 = -c / b; end tmp_2 = tmp_3; elseif (b <= 2e+153) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (-b - t_0) / (a * 2.0); else tmp_4 = (c * 2.0) / (t_0 - b); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (c / b) - (b / a); else tmp_2 = (2.0 / b) * (c * -0.5); 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]}, If[LessEqual[b, -2e+122], If[GreaterEqual[b, 0.0], N[(c / b), $MachinePrecision], N[((-c) / b), $MachinePrecision]], If[LessEqual[b, 2e+153], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * 2.0), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / b), $MachinePrecision] * N[(c * -0.5), $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 \cdot 10^{+122}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{+153}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot 2}{t_0 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b} \cdot \left(c \cdot -0.5\right)\\
\end{array}
\end{array}
if b < -2.00000000000000003e122Initial program 42.7%
Simplified42.7%
Taylor expanded in b around -inf 93.8%
Taylor expanded in b around inf 93.8%
+-commutative93.8%
mul-1-neg93.8%
unsub-neg93.8%
Simplified93.8%
Taylor expanded in b around 0 96.2%
associate-*r/96.2%
neg-mul-196.2%
Simplified96.2%
Taylor expanded in c around inf 96.2%
if -2.00000000000000003e122 < b < 2e153Initial program 88.3%
if 2e153 < b Initial program 39.8%
Simplified39.8%
Taylor expanded in b around -inf 39.8%
Taylor expanded in b around inf 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in c around 0 100.0%
associate-*r/100.0%
associate-/l*100.0%
*-commutative100.0%
*-rgt-identity100.0%
distribute-lft-out--100.0%
metadata-eval100.0%
Simplified100.0%
associate-/l*100.0%
associate-/r/100.0%
div-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification91.9%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* 4.0 (* c a))))))
(if (<= b -1.18e+72)
(if (>= b 0.0) (/ c b) (/ (- c) b))
(if (<= b 2e+151)
(if (>= b 0.0) (/ (- (- b) t_0) (* a 2.0)) (/ 2.0 (/ (- t_0 b) c)))
(if (>= b 0.0) (- (/ c b) (/ b a)) (* (/ 2.0 b) (* c -0.5)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (4.0 * (c * a))));
double tmp_1;
if (b <= -1.18e+72) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / b;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 2e+151) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_0) / (a * 2.0);
} else {
tmp_3 = 2.0 / ((t_0 - b) / c);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = (2.0 / b) * (c * -0.5);
}
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) - (4.0d0 * (c * a))))
if (b <= (-1.18d+72)) then
if (b >= 0.0d0) then
tmp_2 = c / b
else
tmp_2 = -c / b
end if
tmp_1 = tmp_2
else if (b <= 2d+151) then
if (b >= 0.0d0) then
tmp_3 = (-b - t_0) / (a * 2.0d0)
else
tmp_3 = 2.0d0 / ((t_0 - b) / c)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (c / b) - (b / a)
else
tmp_1 = (2.0d0 / b) * (c * (-0.5d0))
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (4.0 * (c * a))));
double tmp_1;
if (b <= -1.18e+72) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / b;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= 2e+151) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_0) / (a * 2.0);
} else {
tmp_3 = 2.0 / ((t_0 - b) / c);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c / b) - (b / a);
} else {
tmp_1 = (2.0 / b) * (c * -0.5);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (4.0 * (c * a)))) tmp_1 = 0 if b <= -1.18e+72: tmp_2 = 0 if b >= 0.0: tmp_2 = c / b else: tmp_2 = -c / b tmp_1 = tmp_2 elif b <= 2e+151: tmp_3 = 0 if b >= 0.0: tmp_3 = (-b - t_0) / (a * 2.0) else: tmp_3 = 2.0 / ((t_0 - b) / c) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (c / b) - (b / a) else: tmp_1 = (2.0 / b) * (c * -0.5) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(c * a)))) tmp_1 = 0.0 if (b <= -1.18e+72) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / b); else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b <= 2e+151) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(-b) - t_0) / Float64(a * 2.0)); else tmp_3 = Float64(2.0 / Float64(Float64(t_0 - b) / c)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(c / b) - Float64(b / a)); else tmp_1 = Float64(Float64(2.0 / b) * Float64(c * -0.5)); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (4.0 * (c * a)))); tmp_2 = 0.0; if (b <= -1.18e+72) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c / b; else tmp_3 = -c / b; end tmp_2 = tmp_3; elseif (b <= 2e+151) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (-b - t_0) / (a * 2.0); else tmp_4 = 2.0 / ((t_0 - b) / c); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (c / b) - (b / a); else tmp_2 = (2.0 / b) * (c * -0.5); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -1.18e+72], If[GreaterEqual[b, 0.0], N[(c / b), $MachinePrecision], N[((-c) / b), $MachinePrecision]], If[LessEqual[b, 2e+151], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(t$95$0 - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / b), $MachinePrecision] * N[(c * -0.5), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\\
\mathbf{if}\;b \leq -1.18 \cdot 10^{+72}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{+151}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{t_0 - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b} \cdot \left(c \cdot -0.5\right)\\
\end{array}
\end{array}
if b < -1.18e72Initial program 54.2%
Simplified54.1%
Taylor expanded in b around -inf 94.9%
Taylor expanded in b around inf 94.9%
+-commutative94.9%
mul-1-neg94.9%
unsub-neg94.9%
Simplified94.9%
Taylor expanded in b around 0 96.9%
associate-*r/96.9%
neg-mul-196.9%
Simplified96.9%
Taylor expanded in c around inf 96.9%
if -1.18e72 < b < 2.00000000000000003e151Initial program 87.3%
Simplified87.2%
if 2.00000000000000003e151 < b Initial program 39.8%
Simplified39.8%
Taylor expanded in b around -inf 39.8%
Taylor expanded in b around inf 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in c around 0 100.0%
associate-*r/100.0%
associate-/l*100.0%
*-commutative100.0%
*-rgt-identity100.0%
distribute-lft-out--100.0%
metadata-eval100.0%
Simplified100.0%
associate-/l*100.0%
associate-/r/100.0%
div-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification91.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (- b) b)) (t_1 (sqrt (* c (* a -4.0)))))
(if (<= b -1.35e+72)
(if (>= b 0.0) (/ c b) (/ (- c) b))
(if (<= b -1e-310)
(if (>= b 0.0)
(/ t_0 (* a 2.0))
(/ 2.0 (/ (- (sqrt (- (* b b) (* 4.0 (* c a)))) b) c)))
(if (<= b 38000.0)
(if (>= b 0.0) (/ (- (- b) t_1) (* a 2.0)) (/ 2.0 (/ t_0 c)))
(if (>= b 0.0)
(fma -1.0 (/ b a) (/ c b))
(* c (/ 2.0 (+ b t_1)))))))))
double code(double a, double b, double c) {
double t_0 = -b - b;
double t_1 = sqrt((c * (a * -4.0)));
double tmp_1;
if (b <= -1.35e+72) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / b;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= -1e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_0 / (a * 2.0);
} else {
tmp_3 = 2.0 / ((sqrt(((b * b) - (4.0 * (c * a)))) - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 38000.0) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - t_1) / (a * 2.0);
} else {
tmp_4 = 2.0 / (t_0 / c);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = fma(-1.0, (b / a), (c / b));
} else {
tmp_1 = c * (2.0 / (b + t_1));
}
return tmp_1;
}
function code(a, b, c) t_0 = Float64(Float64(-b) - b) t_1 = sqrt(Float64(c * Float64(a * -4.0))) tmp_1 = 0.0 if (b <= -1.35e+72) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / b); else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b <= -1e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(t_0 / Float64(a * 2.0)); else tmp_3 = Float64(2.0 / Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(c * a)))) - b) / c)); end tmp_1 = tmp_3; elseif (b <= 38000.0) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(-b) - t_1) / Float64(a * 2.0)); else tmp_4 = Float64(2.0 / Float64(t_0 / c)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = fma(-1.0, Float64(b / a), Float64(c / b)); else tmp_1 = Float64(c * Float64(2.0 / Float64(b + t_1))); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) - b), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -1.35e+72], If[GreaterEqual[b, 0.0], N[(c / b), $MachinePrecision], N[((-c) / b), $MachinePrecision]], If[LessEqual[b, -1e-310], If[GreaterEqual[b, 0.0], N[(t$95$0 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 38000.0], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$1), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(t$95$0 / c), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision], N[(c * N[(2.0 / N[(b + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-b\right) - b\\
t_1 := \sqrt{c \cdot \left(a \cdot -4\right)}\\
\mathbf{if}\;b \leq -1.35 \cdot 10^{+72}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \leq 38000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_1}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{t_0}{c}}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{b + t_1}\\
\end{array}
\end{array}
if b < -1.35e72Initial program 54.2%
Simplified54.1%
Taylor expanded in b around -inf 94.9%
Taylor expanded in b around inf 94.9%
+-commutative94.9%
mul-1-neg94.9%
unsub-neg94.9%
Simplified94.9%
Taylor expanded in b around 0 96.9%
associate-*r/96.9%
neg-mul-196.9%
Simplified96.9%
Taylor expanded in c around inf 96.9%
if -1.35e72 < b < -9.999999999999969e-311Initial program 88.9%
Simplified88.6%
Taylor expanded in b around inf 88.6%
if -9.999999999999969e-311 < b < 38000Initial program 77.3%
Simplified77.3%
Taylor expanded in b around -inf 77.3%
Taylor expanded in b around 0 61.3%
associate-*r*24.6%
Simplified61.3%
if 38000 < b Initial program 67.4%
Simplified67.4%
Taylor expanded in b around inf 91.9%
fma-def91.9%
Simplified91.9%
Taylor expanded in b around 0 91.9%
associate-*r*91.9%
Simplified91.9%
associate-/r/91.9%
add-sqr-sqrt91.9%
sqrt-unprod91.9%
sqr-neg91.9%
sqrt-unprod91.9%
add-sqr-sqrt91.9%
*-commutative91.9%
*-commutative91.9%
Applied egg-rr91.9%
Final simplification86.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (* c (* a -4.0)))))
(if (<= b -5.6e-149)
(if (>= b 0.0) (/ c b) (/ (- c) b))
(if (or (<= b -1e-310) (not (<= b 38000.0)))
(if (>= b 0.0) (fma -1.0 (/ b a) (/ c b)) (* c (/ 2.0 (+ b t_0))))
(if (>= b 0.0)
(/ (- (- b) t_0) (* a 2.0))
(/ 2.0 (/ (- (- b) b) c)))))))
double code(double a, double b, double c) {
double t_0 = sqrt((c * (a * -4.0)));
double tmp_1;
if (b <= -5.6e-149) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / b;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if ((b <= -1e-310) || !(b <= 38000.0)) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = fma(-1.0, (b / a), (c / b));
} else {
tmp_3 = c * (2.0 / (b + t_0));
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (-b - t_0) / (a * 2.0);
} else {
tmp_1 = 2.0 / ((-b - b) / c);
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(Float64(c * Float64(a * -4.0))) tmp_1 = 0.0 if (b <= -5.6e-149) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / b); else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif ((b <= -1e-310) || !(b <= 38000.0)) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = fma(-1.0, Float64(b / a), Float64(c / b)); else tmp_3 = Float64(c * Float64(2.0 / Float64(b + t_0))); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) - t_0) / Float64(a * 2.0)); else tmp_1 = Float64(2.0 / Float64(Float64(Float64(-b) - b) / c)); 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, -5.6e-149], If[GreaterEqual[b, 0.0], N[(c / b), $MachinePrecision], N[((-c) / b), $MachinePrecision]], If[Or[LessEqual[b, -1e-310], N[Not[LessEqual[b, 38000.0]], $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision], N[(c * N[(2.0 / N[(b + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[((-b) - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{c \cdot \left(a \cdot -4\right)}\\
\mathbf{if}\;b \leq -5.6 \cdot 10^{-149}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq -1 \cdot 10^{-310} \lor \neg \left(b \leq 38000\right):\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{b + t_0}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{\left(-b\right) - b}{c}}\\
\end{array}
\end{array}
if b < -5.5999999999999997e-149Initial program 70.8%
Simplified70.6%
Taylor expanded in b around -inf 87.6%
Taylor expanded in b around inf 87.6%
+-commutative87.6%
mul-1-neg87.6%
unsub-neg87.6%
Simplified87.6%
Taylor expanded in b around 0 88.9%
associate-*r/88.9%
neg-mul-188.9%
Simplified88.9%
Taylor expanded in c around inf 88.9%
if -5.5999999999999997e-149 < b < -9.999999999999969e-311 or 38000 < b Initial program 68.6%
Simplified68.6%
Taylor expanded in b around inf 89.0%
fma-def89.0%
Simplified89.0%
Taylor expanded in b around 0 89.0%
associate-*r*89.0%
Simplified89.0%
associate-/r/89.0%
add-sqr-sqrt89.0%
sqrt-unprod88.8%
sqr-neg88.8%
sqrt-unprod76.7%
add-sqr-sqrt88.7%
*-commutative88.7%
*-commutative88.7%
Applied egg-rr88.7%
if -9.999999999999969e-311 < b < 38000Initial program 77.3%
Simplified77.3%
Taylor expanded in b around -inf 77.3%
Taylor expanded in b around 0 61.3%
associate-*r*24.6%
Simplified61.3%
Final simplification83.9%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma -1.0 (/ b a) (/ c b))) (t_1 (sqrt (* c (* a -4.0)))))
(if (<= b -4.1e-134)
(if (>= b 0.0) (/ c b) (/ (- c) b))
(if (<= b -1e-310)
(if (>= b 0.0) t_0 (/ 2.0 (/ (- t_1 b) c)))
(if (<= b 104.0)
(if (>= b 0.0) (/ (- (- b) t_1) (* a 2.0)) (/ 2.0 (/ (- (- b) b) c)))
(if (>= b 0.0) t_0 (* c (/ 2.0 (+ b t_1)))))))))
double code(double a, double b, double c) {
double t_0 = fma(-1.0, (b / a), (c / b));
double t_1 = sqrt((c * (a * -4.0)));
double tmp_1;
if (b <= -4.1e-134) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / b;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b <= -1e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_0;
} else {
tmp_3 = 2.0 / ((t_1 - b) / c);
}
tmp_1 = tmp_3;
} else if (b <= 104.0) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-b - t_1) / (a * 2.0);
} else {
tmp_4 = 2.0 / ((-b - b) / c);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = c * (2.0 / (b + t_1));
}
return tmp_1;
}
function code(a, b, c) t_0 = fma(-1.0, Float64(b / a), Float64(c / b)) t_1 = sqrt(Float64(c * Float64(a * -4.0))) tmp_1 = 0.0 if (b <= -4.1e-134) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / b); else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b <= -1e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_0; else tmp_3 = Float64(2.0 / Float64(Float64(t_1 - b) / c)); end tmp_1 = tmp_3; elseif (b <= 104.0) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(-b) - t_1) / Float64(a * 2.0)); else tmp_4 = Float64(2.0 / Float64(Float64(Float64(-b) - b) / c)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = t_0; else tmp_1 = Float64(c * Float64(2.0 / Float64(b + t_1))); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -4.1e-134], If[GreaterEqual[b, 0.0], N[(c / b), $MachinePrecision], N[((-c) / b), $MachinePrecision]], If[LessEqual[b, -1e-310], If[GreaterEqual[b, 0.0], t$95$0, N[(2.0 / N[(N[(t$95$1 - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 104.0], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$1), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(N[((-b) - b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], t$95$0, N[(c * N[(2.0 / N[(b + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
t_1 := \sqrt{c \cdot \left(a \cdot -4\right)}\\
\mathbf{if}\;b \leq -4.1 \cdot 10^{-134}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{t_1 - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \leq 104:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t_1}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{\left(-b\right) - b}{c}}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{b + t_1}\\
\end{array}
\end{array}
if b < -4.1000000000000002e-134Initial program 70.2%
Simplified70.0%
Taylor expanded in b around -inf 88.3%
Taylor expanded in b around inf 88.3%
+-commutative88.3%
mul-1-neg88.3%
unsub-neg88.3%
Simplified88.3%
Taylor expanded in b around 0 89.7%
associate-*r/89.7%
neg-mul-189.7%
Simplified89.7%
Taylor expanded in c around inf 89.7%
if -4.1000000000000002e-134 < b < -9.999999999999969e-311Initial program 77.0%
Simplified77.0%
Taylor expanded in b around inf 77.0%
fma-def77.0%
Simplified77.0%
Taylor expanded in b around 0 72.9%
associate-*r*72.9%
Simplified72.9%
if -9.999999999999969e-311 < b < 104Initial program 77.3%
Simplified77.3%
Taylor expanded in b around -inf 77.3%
Taylor expanded in b around 0 61.3%
associate-*r*24.6%
Simplified61.3%
if 104 < b Initial program 67.4%
Simplified67.4%
Taylor expanded in b around inf 91.9%
fma-def91.9%
Simplified91.9%
Taylor expanded in b around 0 91.9%
associate-*r*91.9%
Simplified91.9%
associate-/r/91.9%
add-sqr-sqrt91.9%
sqrt-unprod91.9%
sqr-neg91.9%
sqrt-unprod91.9%
add-sqr-sqrt91.9%
*-commutative91.9%
*-commutative91.9%
Applied egg-rr91.9%
Final simplification84.1%
(FPCore (a b c)
:precision binary64
(if (<= b -2.9e-149)
(if (>= b 0.0) (/ c b) (/ (- c) b))
(if (>= b 0.0)
(fma -1.0 (/ b a) (/ c b))
(* c (/ 2.0 (+ b (sqrt (* c (* a -4.0)))))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -2.9e-149) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c / b;
} else {
tmp_2 = -c / b;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = fma(-1.0, (b / a), (c / b));
} else {
tmp_1 = c * (2.0 / (b + sqrt((c * (a * -4.0)))));
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -2.9e-149) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c / b); else tmp_2 = Float64(Float64(-c) / b); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = fma(-1.0, Float64(b / a), Float64(c / b)); else tmp_1 = Float64(c * Float64(2.0 / Float64(b + sqrt(Float64(c * Float64(a * -4.0)))))); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -2.9e-149], If[GreaterEqual[b, 0.0], N[(c / b), $MachinePrecision], N[((-c) / b), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(-1.0 * N[(b / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision], N[(c * N[(2.0 / N[(b + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.9 \cdot 10^{-149}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{b}{a}, \frac{c}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot \frac{2}{b + \sqrt{c \cdot \left(a \cdot -4\right)}}\\
\end{array}
\end{array}
if b < -2.9e-149Initial program 70.8%
Simplified70.6%
Taylor expanded in b around -inf 87.6%
Taylor expanded in b around inf 87.6%
+-commutative87.6%
mul-1-neg87.6%
unsub-neg87.6%
Simplified87.6%
Taylor expanded in b around 0 88.9%
associate-*r/88.9%
neg-mul-188.9%
Simplified88.9%
Taylor expanded in c around inf 88.9%
if -2.9e-149 < b Initial program 71.2%
Simplified71.2%
Taylor expanded in b around inf 69.9%
fma-def69.9%
Simplified69.9%
Taylor expanded in b around 0 69.9%
associate-*r*69.9%
Simplified69.9%
associate-/r/69.9%
add-sqr-sqrt69.9%
sqrt-unprod69.7%
sqr-neg69.7%
sqrt-unprod61.2%
add-sqr-sqrt69.7%
*-commutative69.7%
*-commutative69.7%
Applied egg-rr69.7%
Final simplification77.3%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (- (/ c b) (/ b a)) (* (/ 2.0 b) (* c -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (c / b) - (b / a);
} else {
tmp = (2.0 / b) * (c * -0.5);
}
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) - (b / a)
else
tmp = (2.0d0 / b) * (c * (-0.5d0))
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) - (b / a);
} else {
tmp = (2.0 / b) * (c * -0.5);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (c / b) - (b / a) else: tmp = (2.0 / b) * (c * -0.5) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(c / b) - Float64(b / a)); else tmp = Float64(Float64(2.0 / b) * Float64(c * -0.5)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (c / b) - (b / a); else tmp = (2.0 / b) * (c * -0.5); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / b), $MachinePrecision] * N[(c * -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{b} \cdot \left(c \cdot -0.5\right)\\
\end{array}
\end{array}
Initial program 71.0%
Simplified71.0%
Taylor expanded in b around -inf 72.9%
Taylor expanded in b around inf 72.1%
+-commutative72.1%
mul-1-neg72.1%
unsub-neg72.1%
Simplified72.1%
Taylor expanded in c around 0 72.6%
associate-*r/72.6%
associate-/l*72.1%
*-commutative72.1%
*-rgt-identity72.1%
distribute-lft-out--72.1%
metadata-eval72.1%
Simplified72.1%
associate-/l*72.1%
associate-/r/72.5%
div-inv72.5%
metadata-eval72.5%
Applied egg-rr72.5%
Final simplification72.5%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = (c / b) - (b / a)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(c / b) - Float64(b / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
Initial program 71.0%
Simplified71.0%
Taylor expanded in b around -inf 72.9%
Taylor expanded in b around inf 72.1%
+-commutative72.1%
mul-1-neg72.1%
unsub-neg72.1%
Simplified72.1%
Taylor expanded in b around 0 72.6%
associate-*r/72.6%
neg-mul-172.6%
Simplified72.6%
Final simplification72.6%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ c b) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c / b;
} else {
tmp = -c / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = c / b
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c / b;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c / b else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c / b); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = c / b; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c / b), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
Initial program 71.0%
Simplified71.0%
Taylor expanded in b around -inf 72.9%
Taylor expanded in b around inf 72.1%
+-commutative72.1%
mul-1-neg72.1%
unsub-neg72.1%
Simplified72.1%
Taylor expanded in b around 0 72.6%
associate-*r/72.6%
neg-mul-172.6%
Simplified72.6%
Taylor expanded in c around inf 37.6%
Final simplification37.6%
herbie shell --seed 2023332
(FPCore (a b c)
:name "jeff quadratic root 1"
:precision binary64
(if (>= b 0.0) (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))))