
(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 (sqrt (- (* b b) (* c (* a 4.0))))))
(if (<= b -1.05e+151)
(- (/ b a))
(if (<= b 1.6e+81)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (- t_0 b) (* a 2.0)))
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (- (* a (/ c b)) b)))
(/ (- (sqrt (* (* a c) -4.0)) b) (* a 2.0)))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (a * 4.0))));
double tmp;
if (b <= -1.05e+151) {
tmp = -(b / a);
} else if (b <= 1.6e+81) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - t_0);
} else {
tmp_1 = (t_0 - b) / (a * 2.0);
}
tmp = tmp_1;
} else if (b >= 0.0) {
tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp = (sqrt(((a * c) * -4.0)) - b) / (a * 2.0);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
real(8) :: tmp_1
t_0 = sqrt(((b * b) - (c * (a * 4.0d0))))
if (b <= (-1.05d+151)) then
tmp = -(b / a)
else if (b <= 1.6d+81) then
if (b >= 0.0d0) then
tmp_1 = (2.0d0 * c) / (-b - t_0)
else
tmp_1 = (t_0 - b) / (a * 2.0d0)
end if
tmp = tmp_1
else if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (2.0d0 * ((a * (c / b)) - b))
else
tmp = (sqrt(((a * c) * (-4.0d0))) - b) / (a * 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (a * 4.0))));
double tmp;
if (b <= -1.05e+151) {
tmp = -(b / a);
} else if (b <= 1.6e+81) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - t_0);
} else {
tmp_1 = (t_0 - b) / (a * 2.0);
}
tmp = tmp_1;
} else if (b >= 0.0) {
tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp = (Math.sqrt(((a * c) * -4.0)) - b) / (a * 2.0);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (a * 4.0)))) tmp = 0 if b <= -1.05e+151: tmp = -(b / a) elif b <= 1.6e+81: tmp_1 = 0 if b >= 0.0: tmp_1 = (2.0 * c) / (-b - t_0) else: tmp_1 = (t_0 - b) / (a * 2.0) tmp = tmp_1 elif b >= 0.0: tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b)) else: tmp = (math.sqrt(((a * c) * -4.0)) - b) / (a * 2.0) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) tmp = 0.0 if (b <= -1.05e+151) tmp = Float64(-Float64(b / a)); elseif (b <= 1.6e+81) tmp_1 = 0.0 if (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_1 = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end tmp = tmp_1; elseif (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b))); else tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -4.0)) - b) / Float64(a * 2.0)); end return tmp end
function tmp_3 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (a * 4.0)))); tmp = 0.0; if (b <= -1.05e+151) tmp = -(b / a); elseif (b <= 1.6e+81) tmp_2 = 0.0; if (b >= 0.0) tmp_2 = (2.0 * c) / (-b - t_0); else tmp_2 = (t_0 - b) / (a * 2.0); end tmp = tmp_2; elseif (b >= 0.0) tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b)); else tmp = (sqrt(((a * c) * -4.0)) - b) / (a * 2.0); end tmp_3 = tmp; 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, -1.05e+151], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 1.6e+81], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] - b), $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 -1.05 \cdot 10^{+151}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{+81}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -4} - b}{a \cdot 2}\\
\end{array}
\end{array}
if b < -1.05e151Initial program 33.7%
Taylor expanded in b around -inf
mul-1-negN/A
neg-lowering-neg.f64100.0
Simplified100.0%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-lowering-neg.f64100.0
Simplified100.0%
Taylor expanded in b around 0
if-sameN/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-lowering-neg.f64100.0
Simplified100.0%
if -1.05e151 < b < 1.6e81Initial program 87.5%
if 1.6e81 < b Initial program 44.8%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6498.4
Simplified98.4%
Taylor expanded in b around 0
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6498.4
Simplified98.4%
Taylor expanded in c around 0
distribute-lft-out--N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6498.4
Simplified98.4%
Final simplification92.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (* (* a c) -4.0)))
(t_1
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (- (* a (/ c b)) b)))
(/ (- t_0 b) (* a 2.0)))))
(if (<= b -5e-76)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (fma (/ c b) (* a -2.0) b)))
(- (fma b (- (/ c (* b b))) (/ b a))))
(if (<= b -5e-310)
t_1
(if (<= b 9.5e-92)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (+ b b) (* a (- 2.0))))
t_1)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((a * c) * -4.0));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp = (t_0 - b) / (a * 2.0);
}
double t_1 = tmp;
double tmp_2;
if (b <= -5e-76) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (-b - fma((c / b), (a * -2.0), b));
} else {
tmp_3 = -fma(b, -(c / (b * b)), (b / a));
}
tmp_2 = tmp_3;
} else if (b <= -5e-310) {
tmp_2 = t_1;
} else if (b <= 9.5e-92) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (2.0 * c) / (-b - t_0);
} else {
tmp_4 = (b + b) / (a * -2.0);
}
tmp_2 = tmp_4;
} else {
tmp_2 = t_1;
}
return tmp_2;
}
function code(a, b, c) t_0 = sqrt(Float64(Float64(a * c) * -4.0)) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b))); else tmp = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end t_1 = tmp tmp_2 = 0.0 if (b <= -5e-76) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - fma(Float64(c / b), Float64(a * -2.0), b))); else tmp_3 = Float64(-fma(b, Float64(-Float64(c / Float64(b * b))), Float64(b / a))); end tmp_2 = tmp_3; elseif (b <= -5e-310) tmp_2 = t_1; elseif (b <= 9.5e-92) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_4 = Float64(Float64(b + b) / Float64(a * Float64(-2.0))); end tmp_2 = tmp_4; else tmp_2 = t_1; end return tmp_2 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(a * c), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -5e-76], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[(N[(c / b), $MachinePrecision] * N[(a * -2.0), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(b * (-N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision]) + N[(b / a), $MachinePrecision]), $MachinePrecision])], If[LessEqual[b, -5e-310], t$95$1, If[LessEqual[b, 9.5e-92], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(b + b), $MachinePrecision] / N[(a * (-2.0)), $MachinePrecision]), $MachinePrecision]], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\left(a \cdot c\right) \cdot -4}\\
t_1 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{if}\;b \leq -5 \cdot 10^{-76}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \mathsf{fma}\left(\frac{c}{b}, a \cdot -2, b\right)}\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(b, -\frac{c}{b \cdot b}, \frac{b}{a}\right)\\
\end{array}\\
\mathbf{elif}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 9.5 \cdot 10^{-92}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + b}{a \cdot \left(-2\right)}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -4.9999999999999998e-76Initial program 62.3%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6462.3
Simplified62.3%
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
unsub-negN/A
Applied egg-rr62.3%
Taylor expanded in b around -inf
mul-1-negN/A
neg-lowering-neg.f64N/A
distribute-lft-inN/A
associate-*r/N/A
*-rgt-identityN/A
accelerator-lowering-fma.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
/-lowering-/.f6490.6
Simplified90.6%
if -4.9999999999999998e-76 < b < -4.999999999999985e-310 or 9.49999999999999946e-92 < b Initial program 64.9%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6481.5
Simplified81.5%
Taylor expanded in b around 0
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6478.3
Simplified78.3%
Taylor expanded in c around 0
distribute-lft-out--N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6478.3
Simplified78.3%
if -4.999999999999985e-310 < b < 9.49999999999999946e-92Initial program 90.2%
Taylor expanded in b around -inf
mul-1-negN/A
neg-lowering-neg.f6490.2
Simplified90.2%
Taylor expanded in b around 0
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6485.5
Simplified85.5%
Final simplification83.9%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (* (* a c) -4.0)))
(t_1
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (- (* a (/ c b)) b)))
(/ (- t_0 b) (* a 2.0)))))
(if (<= b -4.8e-76)
(- (/ b a))
(if (<= b -5e-310)
t_1
(if (<= b 3.5e-79)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (+ b b) (* a (- 2.0))))
t_1)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((a * c) * -4.0));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp = (t_0 - b) / (a * 2.0);
}
double t_1 = tmp;
double tmp_1;
if (b <= -4.8e-76) {
tmp_1 = -(b / a);
} else if (b <= -5e-310) {
tmp_1 = t_1;
} else if (b <= 3.5e-79) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - t_0);
} else {
tmp_2 = (b + b) / (a * -2.0);
}
tmp_1 = tmp_2;
} 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
t_0 = sqrt(((a * c) * (-4.0d0)))
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (2.0d0 * ((a * (c / b)) - b))
else
tmp = (t_0 - b) / (a * 2.0d0)
end if
t_1 = tmp
if (b <= (-4.8d-76)) then
tmp_1 = -(b / a)
else if (b <= (-5d-310)) then
tmp_1 = t_1
else if (b <= 3.5d-79) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 * c) / (-b - t_0)
else
tmp_2 = (b + b) / (a * -2.0d0)
end if
tmp_1 = tmp_2
else
tmp_1 = t_1
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((a * c) * -4.0));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp = (t_0 - b) / (a * 2.0);
}
double t_1 = tmp;
double tmp_1;
if (b <= -4.8e-76) {
tmp_1 = -(b / a);
} else if (b <= -5e-310) {
tmp_1 = t_1;
} else if (b <= 3.5e-79) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - t_0);
} else {
tmp_2 = (b + b) / (a * -2.0);
}
tmp_1 = tmp_2;
} else {
tmp_1 = t_1;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((a * c) * -4.0)) tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b)) else: tmp = (t_0 - b) / (a * 2.0) t_1 = tmp tmp_1 = 0 if b <= -4.8e-76: tmp_1 = -(b / a) elif b <= -5e-310: tmp_1 = t_1 elif b <= 3.5e-79: tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 * c) / (-b - t_0) else: tmp_2 = (b + b) / (a * -2.0) tmp_1 = tmp_2 else: tmp_1 = t_1 return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(a * c) * -4.0)) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b))); else tmp = Float64(Float64(t_0 - b) / Float64(a * 2.0)); end t_1 = tmp tmp_1 = 0.0 if (b <= -4.8e-76) tmp_1 = Float64(-Float64(b / a)); elseif (b <= -5e-310) tmp_1 = t_1; elseif (b <= 3.5e-79) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_2 = Float64(Float64(b + b) / Float64(a * Float64(-2.0))); end tmp_1 = tmp_2; else tmp_1 = t_1; end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = sqrt(((a * c) * -4.0)); tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b)); else tmp = (t_0 - b) / (a * 2.0); end t_1 = tmp; tmp_2 = 0.0; if (b <= -4.8e-76) tmp_2 = -(b / a); elseif (b <= -5e-310) tmp_2 = t_1; elseif (b <= 3.5e-79) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 * c) / (-b - t_0); else tmp_3 = (b + b) / (a * -2.0); end tmp_2 = tmp_3; else tmp_2 = t_1; end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(a * c), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -4.8e-76], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, -5e-310], t$95$1, If[LessEqual[b, 3.5e-79], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(b + b), $MachinePrecision] / N[(a * (-2.0)), $MachinePrecision]), $MachinePrecision]], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\left(a \cdot c\right) \cdot -4}\\
t_1 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a \cdot 2}\\
\end{array}\\
\mathbf{if}\;b \leq -4.8 \cdot 10^{-76}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-79}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + b}{a \cdot \left(-2\right)}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -4.80000000000000026e-76Initial program 62.3%
Taylor expanded in b around -inf
mul-1-negN/A
neg-lowering-neg.f6490.3
Simplified90.3%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-lowering-neg.f6490.3
Simplified90.3%
Taylor expanded in b around 0
if-sameN/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-lowering-neg.f6490.3
Simplified90.3%
if -4.80000000000000026e-76 < b < -4.999999999999985e-310 or 3.5000000000000003e-79 < b Initial program 64.9%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6481.5
Simplified81.5%
Taylor expanded in b around 0
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6478.3
Simplified78.3%
Taylor expanded in c around 0
distribute-lft-out--N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6478.3
Simplified78.3%
if -4.999999999999985e-310 < b < 3.5000000000000003e-79Initial program 90.2%
Taylor expanded in b around -inf
mul-1-negN/A
neg-lowering-neg.f6490.2
Simplified90.2%
Taylor expanded in b around 0
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6485.5
Simplified85.5%
Final simplification83.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (- (* a (/ c b)) b)))
(/ (- (sqrt (* (* a c) -4.0)) b) (* a 2.0)))))
(if (<= b -5e-76)
(- (/ b a))
(if (<= b -5e-310)
t_0
(if (<= b 6e-77)
(if (>= b 0.0)
(* c (/ 2.0 (- (- b) (sqrt (* c (* a -4.0))))))
(/ (+ b b) (* a (- 2.0))))
t_0)))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp = (sqrt(((a * c) * -4.0)) - b) / (a * 2.0);
}
double t_0 = tmp;
double tmp_1;
if (b <= -5e-76) {
tmp_1 = -(b / a);
} else if (b <= -5e-310) {
tmp_1 = t_0;
} else if (b <= 6e-77) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (2.0 / (-b - sqrt((c * (a * -4.0)))));
} else {
tmp_2 = (b + b) / (a * -2.0);
}
tmp_1 = tmp_2;
} 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
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (2.0d0 * ((a * (c / b)) - b))
else
tmp = (sqrt(((a * c) * (-4.0d0))) - b) / (a * 2.0d0)
end if
t_0 = tmp
if (b <= (-5d-76)) then
tmp_1 = -(b / a)
else if (b <= (-5d-310)) then
tmp_1 = t_0
else if (b <= 6d-77) then
if (b >= 0.0d0) then
tmp_2 = c * (2.0d0 / (-b - sqrt((c * (a * (-4.0d0))))))
else
tmp_2 = (b + b) / (a * -2.0d0)
end if
tmp_1 = tmp_2
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 = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp = (Math.sqrt(((a * c) * -4.0)) - b) / (a * 2.0);
}
double t_0 = tmp;
double tmp_1;
if (b <= -5e-76) {
tmp_1 = -(b / a);
} else if (b <= -5e-310) {
tmp_1 = t_0;
} else if (b <= 6e-77) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (2.0 / (-b - Math.sqrt((c * (a * -4.0)))));
} else {
tmp_2 = (b + b) / (a * -2.0);
}
tmp_1 = tmp_2;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b)) else: tmp = (math.sqrt(((a * c) * -4.0)) - b) / (a * 2.0) t_0 = tmp tmp_1 = 0 if b <= -5e-76: tmp_1 = -(b / a) elif b <= -5e-310: tmp_1 = t_0 elif b <= 6e-77: tmp_2 = 0 if b >= 0.0: tmp_2 = c * (2.0 / (-b - math.sqrt((c * (a * -4.0))))) else: tmp_2 = (b + b) / (a * -2.0) tmp_1 = tmp_2 else: tmp_1 = t_0 return tmp_1
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b))); else tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -4.0)) - b) / Float64(a * 2.0)); end t_0 = tmp tmp_1 = 0.0 if (b <= -5e-76) tmp_1 = Float64(-Float64(b / a)); elseif (b <= -5e-310) tmp_1 = t_0; elseif (b <= 6e-77) 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 + b) / Float64(a * Float64(-2.0))); end tmp_1 = tmp_2; else tmp_1 = t_0; end return tmp_1 end
function tmp_4 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b)); else tmp = (sqrt(((a * c) * -4.0)) - b) / (a * 2.0); end t_0 = tmp; tmp_2 = 0.0; if (b <= -5e-76) tmp_2 = -(b / a); elseif (b <= -5e-310) tmp_2 = t_0; elseif (b <= 6e-77) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c * (2.0 / (-b - sqrt((c * (a * -4.0))))); else tmp_3 = (b + b) / (a * -2.0); end tmp_2 = tmp_3; else tmp_2 = t_0; end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -5e-76], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, -5e-310], t$95$0, If[LessEqual[b, 6e-77], 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 + b), $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{2 \cdot c}{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -4} - b}{a \cdot 2}\\
\end{array}\\
\mathbf{if}\;b \leq -5 \cdot 10^{-76}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 6 \cdot 10^{-77}:\\
\;\;\;\;\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 + b}{a \cdot \left(-2\right)}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < -4.9999999999999998e-76Initial program 62.3%
Taylor expanded in b around -inf
mul-1-negN/A
neg-lowering-neg.f6490.3
Simplified90.3%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-lowering-neg.f6490.3
Simplified90.3%
Taylor expanded in b around 0
if-sameN/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-lowering-neg.f6490.3
Simplified90.3%
if -4.9999999999999998e-76 < b < -4.999999999999985e-310 or 6.00000000000000033e-77 < b Initial program 64.9%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6481.5
Simplified81.5%
Taylor expanded in b around 0
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6478.3
Simplified78.3%
Taylor expanded in c around 0
distribute-lft-out--N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6478.3
Simplified78.3%
if -4.999999999999985e-310 < b < 6.00000000000000033e-77Initial program 90.2%
Taylor expanded in b around -inf
mul-1-negN/A
neg-lowering-neg.f6490.2
Simplified90.2%
Taylor expanded in b around 0
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6485.5
Simplified85.5%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
neg-lowering-neg.f64N/A
associate-*l*N/A
*-commutativeN/A
sqrt-lowering-sqrt.f64N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6485.4
Applied egg-rr85.4%
Final simplification83.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1e+154)
(- (/ b a))
(if (<= b 1.05e+80)
(if (>= b 0.0)
(* c (/ -2.0 (+ b (sqrt (fma c (* a -4.0) (* b b))))))
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0)))
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (- (* a (/ c b)) b)))
(/ (- (sqrt (* (* a c) -4.0)) b) (* a 2.0))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e+154) {
tmp = -(b / a);
} else if (b <= 1.05e+80) {
double tmp_1;
if (b >= 0.0) {
tmp_1 = c * (-2.0 / (b + sqrt(fma(c, (a * -4.0), (b * b)))));
} else {
tmp_1 = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
}
tmp = tmp_1;
} else if (b >= 0.0) {
tmp = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp = (sqrt(((a * c) * -4.0)) - b) / (a * 2.0);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1e+154) tmp = Float64(-Float64(b / a)); elseif (b <= 1.05e+80) tmp_1 = 0.0 if (b >= 0.0) tmp_1 = Float64(c * Float64(-2.0 / Float64(b + sqrt(fma(c, Float64(a * -4.0), Float64(b * b)))))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); end tmp = tmp_1; elseif (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b))); else tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -4.0)) - b) / Float64(a * 2.0)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1e+154], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 1.05e+80], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision] + N[(b * b), $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]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{+154}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{+80}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot 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 \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -4} - b}{a \cdot 2}\\
\end{array}
\end{array}
if b < -1.00000000000000004e154Initial program 33.7%
Taylor expanded in b around -inf
mul-1-negN/A
neg-lowering-neg.f64100.0
Simplified100.0%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-lowering-neg.f64100.0
Simplified100.0%
Taylor expanded in b around 0
if-sameN/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-lowering-neg.f64100.0
Simplified100.0%
if -1.00000000000000004e154 < b < 1.05000000000000001e80Initial program 87.5%
Applied egg-rr87.5%
if 1.05000000000000001e80 < b Initial program 44.8%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6498.4
Simplified98.4%
Taylor expanded in b around 0
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6498.4
Simplified98.4%
Taylor expanded in c around 0
distribute-lft-out--N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6498.4
Simplified98.4%
Final simplification92.3%
(FPCore (a b c)
:precision binary64
(if (<= b -4.5e+65)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (fma (/ c b) (* a -2.0) b)))
(- (fma b (- (/ c (* b b))) (/ b a))))
(if (<= b 1.55e+81)
(if (>= b 0.0)
(* c (/ -2.0 (+ b (sqrt (fma c (* a -4.0) (* b b))))))
(* (/ 0.5 a) (- (sqrt (fma a (* c -4.0) (* b b))) b)))
(if (>= b 0.0)
(/ (* 2.0 c) (* 2.0 (- (* a (/ c b)) b)))
(/ (- (sqrt (* (* a c) -4.0)) b) (* a 2.0))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -4.5e+65) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - fma((c / b), (a * -2.0), b));
} else {
tmp_2 = -fma(b, -(c / (b * b)), (b / a));
}
tmp_1 = tmp_2;
} else if (b <= 1.55e+81) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (-2.0 / (b + sqrt(fma(c, (a * -4.0), (b * b)))));
} else {
tmp_3 = (0.5 / a) * (sqrt(fma(a, (c * -4.0), (b * b))) - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (2.0 * ((a * (c / b)) - b));
} else {
tmp_1 = (sqrt(((a * c) * -4.0)) - b) / (a * 2.0);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -4.5e+65) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - fma(Float64(c / b), Float64(a * -2.0), b))); else tmp_2 = Float64(-fma(b, Float64(-Float64(c / Float64(b * b))), Float64(b / a))); end tmp_1 = tmp_2; elseif (b <= 1.55e+81) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(c * Float64(-2.0 / Float64(b + sqrt(fma(c, Float64(a * -4.0), Float64(b * b)))))); else tmp_3 = Float64(Float64(0.5 / a) * Float64(sqrt(fma(a, Float64(c * -4.0), Float64(b * b))) - b)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(2.0 * Float64(Float64(a * Float64(c / b)) - b))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(a * c) * -4.0)) - b) / Float64(a * 2.0)); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -4.5e+65], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[(N[(c / b), $MachinePrecision] * N[(a * -2.0), $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-N[(b * (-N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision]) + N[(b / a), $MachinePrecision]), $MachinePrecision])], If[LessEqual[b, 1.55e+81], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(b + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(2.0 * N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{+65}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \mathsf{fma}\left(\frac{c}{b}, a \cdot -2, b\right)}\\
\mathbf{else}:\\
\;\;\;\;-\mathsf{fma}\left(b, -\frac{c}{b \cdot b}, \frac{b}{a}\right)\\
\end{array}\\
\mathbf{elif}\;b \leq 1.55 \cdot 10^{+81}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{b + \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(a \cdot \frac{c}{b} - b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -4} - b}{a \cdot 2}\\
\end{array}
\end{array}
if b < -4.5e65Initial program 52.2%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6452.2
Simplified52.2%
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
unsub-negN/A
Applied egg-rr52.2%
Taylor expanded in b around -inf
mul-1-negN/A
neg-lowering-neg.f64N/A
distribute-lft-inN/A
associate-*r/N/A
*-rgt-identityN/A
accelerator-lowering-fma.f64N/A
mul-1-negN/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
/-lowering-/.f64100.0
Simplified100.0%
if -4.5e65 < b < 1.55e81Initial program 85.7%
Applied egg-rr85.6%
clear-numN/A
associate-/r/N/A
*-lowering-*.f64N/A
associate-/r*N/A
metadata-evalN/A
/-lowering-/.f64N/A
+-commutativeN/A
unsub-negN/A
Applied egg-rr85.5%
if 1.55e81 < b Initial program 44.8%
Taylor expanded in a around 0
+-commutativeN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*r/N/A
*-commutativeN/A
associate-*l*N/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6498.4
Simplified98.4%
Taylor expanded in b around 0
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6498.4
Simplified98.4%
Taylor expanded in c around 0
distribute-lft-out--N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f6498.4
Simplified98.4%
Final simplification92.2%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (+ b b) (* a (- 2.0)))))
(if (<= b 4.4e-78)
(if (>= b 0.0) (* c (/ 2.0 (- (- b) (sqrt (* c (* a -4.0)))))) t_0)
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) b)) t_0))))
double code(double a, double b, double c) {
double t_0 = (b + b) / (a * -2.0);
double tmp_1;
if (b <= 4.4e-78) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (2.0 / (-b - sqrt((c * (a * -4.0)))));
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - b);
} 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
t_0 = (b + b) / (a * -2.0d0)
if (b <= 4.4d-78) then
if (b >= 0.0d0) then
tmp_2 = c * (2.0d0 / (-b - sqrt((c * (a * (-4.0d0))))))
else
tmp_2 = t_0
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (2.0d0 * c) / (-b - b)
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = (b + b) / (a * -2.0);
double tmp_1;
if (b <= 4.4e-78) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (2.0 / (-b - Math.sqrt((c * (a * -4.0)))));
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - b);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): t_0 = (b + b) / (a * -2.0) tmp_1 = 0 if b <= 4.4e-78: tmp_2 = 0 if b >= 0.0: tmp_2 = c * (2.0 / (-b - math.sqrt((c * (a * -4.0))))) else: tmp_2 = t_0 tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (2.0 * c) / (-b - b) else: tmp_1 = t_0 return tmp_1
function code(a, b, c) t_0 = Float64(Float64(b + b) / Float64(a * Float64(-2.0))) tmp_1 = 0.0 if (b <= 4.4e-78) 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 = t_0; end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - b)); else tmp_1 = t_0; end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = (b + b) / (a * -2.0); tmp_2 = 0.0; if (b <= 4.4e-78) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c * (2.0 / (-b - sqrt((c * (a * -4.0))))); else tmp_3 = t_0; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (2.0 * c) / (-b - b); else tmp_2 = t_0; end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(b + b), $MachinePrecision] / N[(a * (-2.0)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 4.4e-78], 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], t$95$0], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - b), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b + b}{a \cdot \left(-2\right)}\\
\mathbf{if}\;b \leq 4.4 \cdot 10^{-78}:\\
\;\;\;\;\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}:\\
\;\;\;\;t\_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if b < 4.3999999999999998e-78Initial program 70.9%
Taylor expanded in b around -inf
mul-1-negN/A
neg-lowering-neg.f6476.9
Simplified76.9%
Taylor expanded in b around 0
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6475.8
Simplified75.8%
*-commutativeN/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
neg-lowering-neg.f64N/A
associate-*l*N/A
*-commutativeN/A
sqrt-lowering-sqrt.f64N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6475.8
Applied egg-rr75.8%
if 4.3999999999999998e-78 < b Initial program 61.8%
Taylor expanded in b around -inf
mul-1-negN/A
neg-lowering-neg.f6461.8
Simplified61.8%
Taylor expanded in b around inf
Simplified84.1%
sub-negN/A
--lowering--.f64N/A
neg-lowering-neg.f6484.1
Applied egg-rr84.1%
Final simplification78.7%
(FPCore (a b c) :precision binary64 (if (<= b 1.15e-262) (if (>= b 0.0) (* (* c -2.0) (+ b b)) (/ (+ b b) (* a (- 2.0)))) (if (>= b 0.0) (/ (- c) (+ b b)) (- (/ (+ b b) a)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= 1.15e-262) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (c * -2.0) * (b + b);
} else {
tmp_2 = (b + b) / (a * -2.0);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = -c / (b + b);
} else {
tmp_1 = -((b + 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 <= 1.15d-262) then
if (b >= 0.0d0) then
tmp_2 = (c * (-2.0d0)) * (b + b)
else
tmp_2 = (b + b) / (a * -2.0d0)
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = -c / (b + b)
else
tmp_1 = -((b + b) / a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= 1.15e-262) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (c * -2.0) * (b + b);
} else {
tmp_2 = (b + b) / (a * -2.0);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = -c / (b + b);
} else {
tmp_1 = -((b + b) / a);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= 1.15e-262: tmp_2 = 0 if b >= 0.0: tmp_2 = (c * -2.0) * (b + b) else: tmp_2 = (b + b) / (a * -2.0) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = -c / (b + b) else: tmp_1 = -((b + b) / a) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= 1.15e-262) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(c * -2.0) * Float64(b + b)); else tmp_2 = Float64(Float64(b + b) / Float64(a * Float64(-2.0))); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(-c) / Float64(b + b)); else tmp_1 = Float64(-Float64(Float64(b + b) / a)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= 1.15e-262) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (c * -2.0) * (b + b); else tmp_3 = (b + b) / (a * -2.0); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = -c / (b + b); else tmp_2 = -((b + b) / a); end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, 1.15e-262], If[GreaterEqual[b, 0.0], N[(N[(c * -2.0), $MachinePrecision] * N[(b + b), $MachinePrecision]), $MachinePrecision], N[(N[(b + b), $MachinePrecision] / N[(a * (-2.0)), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[((-c) / N[(b + b), $MachinePrecision]), $MachinePrecision], (-N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.15 \cdot 10^{-262}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\left(c \cdot -2\right) \cdot \left(b + b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b + b}{a \cdot \left(-2\right)}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-c}{b + b}\\
\mathbf{else}:\\
\;\;\;\;-\frac{b + b}{a}\\
\end{array}
\end{array}
if b < 1.15000000000000005e-262Initial program 66.5%
Taylor expanded in b around -inf
mul-1-negN/A
neg-lowering-neg.f6473.8
Simplified73.8%
Taylor expanded in b around inf
Simplified68.9%
sub-negN/A
--lowering--.f64N/A
neg-lowering-neg.f6468.9
Applied egg-rr68.9%
frac-2negN/A
div-invN/A
sub-negN/A
distribute-neg-outN/A
remove-double-negN/A
flip-+N/A
+-inversesN/A
+-inversesN/A
+-inversesN/A
+-inversesN/A
clear-numN/A
flip-+N/A
*-lowering-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-lowering-*.f64N/A
+-lowering-+.f6469.0
Applied egg-rr69.0%
if 1.15000000000000005e-262 < b Initial program 69.1%
Taylor expanded in b around -inf
mul-1-negN/A
neg-lowering-neg.f6469.1
Simplified69.1%
Taylor expanded in b around inf
Simplified67.0%
clear-numN/A
associate-/r*N/A
sub-negN/A
flip-+N/A
+-inversesN/A
associate-/l/N/A
metadata-evalN/A
+-inversesN/A
flip-+N/A
sub-negN/A
clear-numN/A
frac-2negN/A
sub-negN/A
flip-+N/A
+-inversesN/A
distribute-neg-frac2N/A
Applied egg-rr23.3%
sub-negN/A
associate-/r*N/A
frac-2negN/A
sub-negN/A
flip-+N/A
+-inversesN/A
associate-/l/N/A
metadata-evalN/A
+-inversesN/A
flip-+N/A
distribute-neg-outN/A
remove-double-negN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
neg-lowering-neg.f6423.3
Applied egg-rr23.3%
Final simplification47.5%
(FPCore (a b c) :precision binary64 (if (<= b -2.05e-229) (- (/ b a)) (if (>= b 0.0) (/ (- c) (+ b b)) (- (/ (+ b b) a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.05e-229) {
tmp = -(b / a);
} else if (b >= 0.0) {
tmp = -c / (b + b);
} else {
tmp = -((b + 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 <= (-2.05d-229)) then
tmp = -(b / a)
else if (b >= 0.0d0) then
tmp = -c / (b + b)
else
tmp = -((b + b) / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.05e-229) {
tmp = -(b / a);
} else if (b >= 0.0) {
tmp = -c / (b + b);
} else {
tmp = -((b + b) / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.05e-229: tmp = -(b / a) elif b >= 0.0: tmp = -c / (b + b) else: tmp = -((b + b) / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.05e-229) tmp = Float64(-Float64(b / a)); elseif (b >= 0.0) tmp = Float64(Float64(-c) / Float64(b + b)); else tmp = Float64(-Float64(Float64(b + b) / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.05e-229) tmp = -(b / a); elseif (b >= 0.0) tmp = -c / (b + b); else tmp = -((b + b) / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.05e-229], (-N[(b / a), $MachinePrecision]), If[GreaterEqual[b, 0.0], N[((-c) / N[(b + b), $MachinePrecision]), $MachinePrecision], (-N[(N[(b + b), $MachinePrecision] / a), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.05 \cdot 10^{-229}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-c}{b + b}\\
\mathbf{else}:\\
\;\;\;\;-\frac{b + b}{a}\\
\end{array}
\end{array}
if b < -2.05e-229Initial program 64.9%
Taylor expanded in b around -inf
mul-1-negN/A
neg-lowering-neg.f6478.2
Simplified78.2%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-lowering-neg.f6478.2
Simplified78.2%
Taylor expanded in b around 0
if-sameN/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-lowering-neg.f6478.2
Simplified78.2%
if -2.05e-229 < b Initial program 70.1%
Taylor expanded in b around -inf
mul-1-negN/A
neg-lowering-neg.f6465.9
Simplified65.9%
Taylor expanded in b around inf
Simplified59.2%
clear-numN/A
associate-/r*N/A
sub-negN/A
flip-+N/A
+-inversesN/A
associate-/l/N/A
metadata-evalN/A
+-inversesN/A
flip-+N/A
sub-negN/A
clear-numN/A
frac-2negN/A
sub-negN/A
flip-+N/A
+-inversesN/A
distribute-neg-frac2N/A
Applied egg-rr20.9%
sub-negN/A
associate-/r*N/A
frac-2negN/A
sub-negN/A
flip-+N/A
+-inversesN/A
associate-/l/N/A
metadata-evalN/A
+-inversesN/A
flip-+N/A
distribute-neg-outN/A
remove-double-negN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
neg-lowering-neg.f6420.9
Applied egg-rr20.9%
Final simplification47.5%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (* 2.0 c) (- (- b) b)) (/ (+ b b) (* a (- 2.0)))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - b);
} else {
tmp = (b + b) / (a * -2.0);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (-b - b)
else
tmp = (b + b) / (a * -2.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - b);
} else {
tmp = (b + b) / (a * -2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-b - b) else: tmp = (b + b) / (a * -2.0) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - b)); else tmp = Float64(Float64(b + b) / Float64(a * Float64(-2.0))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-b - b); else tmp = (b + b) / (a * -2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - b), $MachinePrecision]), $MachinePrecision], N[(N[(b + b), $MachinePrecision] / N[(a * (-2.0)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + b}{a \cdot \left(-2\right)}\\
\end{array}
\end{array}
Initial program 67.7%
Taylor expanded in b around -inf
mul-1-negN/A
neg-lowering-neg.f6471.6
Simplified71.6%
Taylor expanded in b around inf
Simplified68.0%
sub-negN/A
--lowering--.f64N/A
neg-lowering-neg.f6468.0
Applied egg-rr68.0%
Final simplification68.0%
(FPCore (a b c) :precision binary64 (- (/ b a)))
double code(double a, double b, double c) {
return -(b / a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = -(b / a)
end function
public static double code(double a, double b, double c) {
return -(b / a);
}
def code(a, b, c): return -(b / a)
function code(a, b, c) return Float64(-Float64(b / a)) end
function tmp = code(a, b, c) tmp = -(b / a); end
code[a_, b_, c_] := (-N[(b / a), $MachinePrecision])
\begin{array}{l}
\\
-\frac{b}{a}
\end{array}
Initial program 67.7%
Taylor expanded in b around -inf
mul-1-negN/A
neg-lowering-neg.f6471.6
Simplified71.6%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-lowering-neg.f6438.0
Simplified38.0%
Taylor expanded in b around 0
if-sameN/A
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
/-lowering-/.f64N/A
mul-1-negN/A
neg-lowering-neg.f6438.0
Simplified38.0%
Final simplification38.0%
herbie shell --seed 2024199
(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))))