
(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 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (/ (+ (- b) t_0) (* 2.0 a)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (2.0d0 * c) / (-b - t_0)
else
tmp = (-b + t_0) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-b - t_0) else: tmp = (-b + t_0) / (2.0 * a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-b - t_0); else tmp = (-b + t_0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t_0}{2 \cdot a}\\
\end{array}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a)))))
(t_1 (/ (* 2.0 c) (- (- b) t_0))))
(if (<= b -6.8e+31)
(if (>= b 0.0) t_1 (- (/ c b) (/ b a)))
(if (<= b 2.7e+48)
(if (>= b 0.0) t_1 (* 0.5 (- (/ t_0 a) (/ b a))))
(if (>= b 0.0) (/ (- c) b) (/ (- b) a))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = (2.0 * c) / (-b - t_0);
double tmp_1;
if (b <= -6.8e+31) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 2.7e+48) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = 0.5 * ((t_0 / a) - (b / a));
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -c / b;
} else {
tmp_1 = -b / a;
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (c * (4.0d0 * a))))
t_1 = (2.0d0 * c) / (-b - t_0)
if (b <= (-6.8d+31)) then
if (b >= 0.0d0) then
tmp_2 = t_1
else
tmp_2 = (c / b) - (b / a)
end if
tmp_1 = tmp_2
else if (b <= 2.7d+48) then
if (b >= 0.0d0) then
tmp_3 = t_1
else
tmp_3 = 0.5d0 * ((t_0 / a) - (b / a))
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = -c / b
else
tmp_1 = -b / a
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = (2.0 * c) / (-b - t_0);
double tmp_1;
if (b <= -6.8e+31) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 2.7e+48) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = 0.5 * ((t_0 / a) - (b / a));
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -c / b;
} else {
tmp_1 = -b / a;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (4.0 * a)))) t_1 = (2.0 * c) / (-b - t_0) tmp_1 = 0 if b <= -6.8e+31: tmp_2 = 0 if b >= 0.0: tmp_2 = t_1 else: tmp_2 = (c / b) - (b / a) tmp_1 = tmp_2 elif b <= 2.7e+48: tmp_3 = 0 if b >= 0.0: tmp_3 = t_1 else: tmp_3 = 0.5 * ((t_0 / a) - (b / a)) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = -c / b else: tmp_1 = -b / a return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) t_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)) tmp_1 = 0.0 if (b <= -6.8e+31) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= 2.7e+48) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_1; else tmp_3 = Float64(0.5 * Float64(Float64(t_0 / a) - Float64(b / a))); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(-c) / b); else tmp_1 = Float64(Float64(-b) / a); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (4.0 * a)))); t_1 = (2.0 * c) / (-b - t_0); tmp_2 = 0.0; if (b <= -6.8e+31) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_1; else tmp_3 = (c / b) - (b / a); end tmp_2 = tmp_3; elseif (b <= 2.7e+48) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = t_1; else tmp_4 = 0.5 * ((t_0 / a) - (b / a)); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = -c / b; else tmp_2 = -b / a; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -6.8e+31], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2.7e+48], If[GreaterEqual[b, 0.0], t$95$1, N[(0.5 * N[(N[(t$95$0 / a), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[((-c) / b), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_1 := \frac{2 \cdot c}{\left(-b\right) - t_0}\\
\mathbf{if}\;b \leq -6.8 \cdot 10^{+31}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.7 \cdot 10^{+48}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\frac{t_0}{a} - \frac{b}{a}\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
if b < -6.7999999999999996e31Initial program 63.9%
Taylor expanded in b around -inf 66.2%
+-commutative66.2%
+-commutative66.2%
associate-+l+66.2%
associate-/l*71.9%
unpow271.9%
mul-1-neg71.9%
unsub-neg71.9%
Simplified71.9%
Taylor expanded in a around 0 93.5%
+-commutative93.5%
mul-1-neg93.5%
sub-neg93.5%
Simplified93.5%
if -6.7999999999999996e31 < b < 2.70000000000000004e48Initial program 87.7%
add-cbrt-cube77.2%
pow377.1%
pow1/277.1%
pow-pow77.2%
*-commutative77.2%
*-commutative77.2%
metadata-eval77.2%
Applied egg-rr77.2%
*-un-lft-identity77.2%
+-commutative77.2%
Applied egg-rr77.2%
*-lft-identity77.2%
unsub-neg77.2%
Simplified77.2%
div-sub77.2%
sub-neg77.2%
pow1/374.9%
pow-pow87.7%
metadata-eval87.7%
pow1/287.7%
*-un-lft-identity87.7%
times-frac87.7%
metadata-eval87.7%
add-sqr-sqrt39.6%
sqrt-prod72.4%
*-un-lft-identity72.4%
metadata-eval72.4%
pow272.4%
unpow-prod-down72.4%
neg-mul-172.4%
unpow272.4%
sqrt-prod72.4%
add-sqr-sqrt72.4%
Applied egg-rr87.7%
sub-neg87.7%
distribute-lft-out--87.7%
Simplified87.7%
if 2.70000000000000004e48 < b Initial program 64.3%
Taylor expanded in b around -inf 64.3%
+-commutative64.3%
+-commutative64.3%
associate-+l+64.3%
associate-/l*64.3%
unpow264.3%
mul-1-neg64.3%
unsub-neg64.3%
Simplified64.3%
Taylor expanded in a around 0 64.3%
associate-*r/64.3%
neg-mul-164.3%
Simplified64.3%
Taylor expanded in c around 0 97.1%
associate-*r/97.1%
mul-1-neg97.1%
Simplified97.1%
Final simplification91.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a)))))
(t_1 (/ (- b) a))
(t_2 (if (>= b 0.0) (/ (- c) b) t_1)))
(if (<= b -1e+110)
t_2
(if (<= b -2.25e-306)
(if (>= b 0.0) (/ (* 2.0 c) (* b (- 2.0))) (/ (- t_0 b) (* 2.0 a)))
(if (<= b 3.2e-34) (if (>= b 0.0) (/ (* 2.0 c) (- b t_0)) t_1) t_2)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = -b / a;
double tmp;
if (b >= 0.0) {
tmp = -c / b;
} else {
tmp = t_1;
}
double t_2 = tmp;
double tmp_1;
if (b <= -1e+110) {
tmp_1 = t_2;
} else if (b <= -2.25e-306) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 3.2e-34) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (b - t_0);
} else {
tmp_3 = t_1;
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_2;
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (c * (4.0d0 * a))))
t_1 = -b / a
if (b >= 0.0d0) then
tmp = -c / b
else
tmp = t_1
end if
t_2 = tmp
if (b <= (-1d+110)) then
tmp_1 = t_2
else if (b <= (-2.25d-306)) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 * c) / (b * -2.0d0)
else
tmp_2 = (t_0 - b) / (2.0d0 * a)
end if
tmp_1 = tmp_2
else if (b <= 3.2d-34) then
if (b >= 0.0d0) then
tmp_3 = (2.0d0 * c) / (b - t_0)
else
tmp_3 = t_1
end if
tmp_1 = tmp_3
else
tmp_1 = t_2
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = -b / a;
double tmp;
if (b >= 0.0) {
tmp = -c / b;
} else {
tmp = t_1;
}
double t_2 = tmp;
double tmp_1;
if (b <= -1e+110) {
tmp_1 = t_2;
} else if (b <= -2.25e-306) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b * -2.0);
} else {
tmp_2 = (t_0 - b) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b <= 3.2e-34) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (2.0 * c) / (b - t_0);
} else {
tmp_3 = t_1;
}
tmp_1 = tmp_3;
} else {
tmp_1 = t_2;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (4.0 * a)))) t_1 = -b / a tmp = 0 if b >= 0.0: tmp = -c / b else: tmp = t_1 t_2 = tmp tmp_1 = 0 if b <= -1e+110: tmp_1 = t_2 elif b <= -2.25e-306: tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 * c) / (b * -2.0) else: tmp_2 = (t_0 - b) / (2.0 * a) tmp_1 = tmp_2 elif b <= 3.2e-34: tmp_3 = 0 if b >= 0.0: tmp_3 = (2.0 * c) / (b - t_0) else: tmp_3 = t_1 tmp_1 = tmp_3 else: tmp_1 = t_2 return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) t_1 = Float64(Float64(-b) / a) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(-c) / b); else tmp = t_1; end t_2 = tmp tmp_1 = 0.0 if (b <= -1e+110) tmp_1 = t_2; elseif (b <= -2.25e-306) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b * Float64(-2.0))); else tmp_2 = Float64(Float64(t_0 - b) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b <= 3.2e-34) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(2.0 * c) / Float64(b - t_0)); else tmp_3 = t_1; end tmp_1 = tmp_3; else tmp_1 = t_2; end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (4.0 * a)))); t_1 = -b / a; tmp = 0.0; if (b >= 0.0) tmp = -c / b; else tmp = t_1; end t_2 = tmp; tmp_2 = 0.0; if (b <= -1e+110) tmp_2 = t_2; elseif (b <= -2.25e-306) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 * c) / (b * -2.0); else tmp_3 = (t_0 - b) / (2.0 * a); end tmp_2 = tmp_3; elseif (b <= 3.2e-34) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (2.0 * c) / (b - t_0); else tmp_4 = t_1; end tmp_2 = tmp_4; else tmp_2 = t_2; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-b) / a), $MachinePrecision]}, Block[{t$95$2 = If[GreaterEqual[b, 0.0], N[((-c) / b), $MachinePrecision], t$95$1]}, If[LessEqual[b, -1e+110], t$95$2, If[LessEqual[b, -2.25e-306], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b * (-2.0)), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 3.2e-34], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b - t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1], t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_1 := \frac{-b}{a}\\
t_2 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{if}\;b \leq -1 \cdot 10^{+110}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;b \leq -2.25 \cdot 10^{-306}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b \cdot \left(-2\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_0 - b}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 3.2 \cdot 10^{-34}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b - t_0}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if b < -1e110 or 3.20000000000000003e-34 < b Initial program 64.1%
Taylor expanded in b around -inf 66.1%
+-commutative66.1%
+-commutative66.1%
associate-+l+66.1%
associate-/l*69.1%
unpow269.1%
mul-1-neg69.1%
unsub-neg69.1%
Simplified69.1%
Taylor expanded in a around 0 79.5%
associate-*r/79.5%
neg-mul-179.5%
Simplified79.5%
Taylor expanded in c around 0 93.1%
associate-*r/93.1%
mul-1-neg93.1%
Simplified93.1%
if -1e110 < b < -2.25000000000000002e-306Initial program 91.9%
add-sqr-sqrt91.9%
pow291.9%
*-commutative91.9%
*-commutative91.9%
Applied egg-rr91.9%
Taylor expanded in b around inf 91.9%
if -2.25000000000000002e-306 < b < 3.20000000000000003e-34Initial program 80.2%
Taylor expanded in b around -inf 80.1%
+-commutative80.1%
+-commutative80.1%
associate-+l+80.1%
associate-/l*80.1%
unpow280.1%
mul-1-neg80.1%
unsub-neg80.1%
Simplified80.1%
Taylor expanded in a around 0 80.2%
associate-*r/80.2%
neg-mul-180.2%
Simplified80.2%
expm1-log1p-u64.3%
expm1-udef26.1%
*-commutative26.1%
add-sqr-sqrt0.1%
sqrt-unprod21.1%
sqr-neg21.1%
sqrt-prod21.9%
add-sqr-sqrt21.2%
*-commutative21.2%
*-commutative21.2%
Applied egg-rr21.2%
expm1-def47.6%
expm1-log1p61.0%
Simplified61.0%
Final simplification87.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a))))))
(if (or (<= b -5e+110) (not (<= b 2.7e+48)))
(if (>= b 0.0) (/ (- c) b) (/ (- b) a))
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) t_0)) (* 0.5 (/ (- t_0 b) a))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double tmp_1;
if ((b <= -5e+110) || !(b <= 2.7e+48)) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -c / b;
} else {
tmp_2 = -b / a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - t_0);
} else {
tmp_1 = 0.5 * ((t_0 - b) / a);
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
t_0 = sqrt(((b * b) - (c * (4.0d0 * a))))
if ((b <= (-5d+110)) .or. (.not. (b <= 2.7d+48))) then
if (b >= 0.0d0) then
tmp_2 = -c / b
else
tmp_2 = -b / a
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (2.0d0 * c) / (-b - t_0)
else
tmp_1 = 0.5d0 * ((t_0 - b) / a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (4.0 * a))));
double tmp_1;
if ((b <= -5e+110) || !(b <= 2.7e+48)) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -c / b;
} else {
tmp_2 = -b / a;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (2.0 * c) / (-b - t_0);
} else {
tmp_1 = 0.5 * ((t_0 - b) / a);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (4.0 * a)))) tmp_1 = 0 if (b <= -5e+110) or not (b <= 2.7e+48): tmp_2 = 0 if b >= 0.0: tmp_2 = -c / b else: tmp_2 = -b / a tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (2.0 * c) / (-b - t_0) else: tmp_1 = 0.5 * ((t_0 - b) / a) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) tmp_1 = 0.0 if ((b <= -5e+110) || !(b <= 2.7e+48)) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(-c) / b); else tmp_2 = Float64(Float64(-b) / a); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp_1 = Float64(0.5 * Float64(Float64(t_0 - b) / a)); end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (4.0 * a)))); tmp_2 = 0.0; if ((b <= -5e+110) || ~((b <= 2.7e+48))) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -c / b; else tmp_3 = -b / a; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (2.0 * c) / (-b - t_0); else tmp_2 = 0.5 * ((t_0 - b) / a); end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[b, -5e+110], N[Not[LessEqual[b, 2.7e+48]], $MachinePrecision]], If[GreaterEqual[b, 0.0], N[((-c) / b), $MachinePrecision], N[((-b) / a), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(t$95$0 - b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
\mathbf{if}\;b \leq -5 \cdot 10^{+110} \lor \neg \left(b \leq 2.7 \cdot 10^{+48}\right):\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t_0}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{t_0 - b}{a}\\
\end{array}
\end{array}
if b < -4.99999999999999978e110 or 2.70000000000000004e48 < b Initial program 61.7%
Taylor expanded in b around -inf 64.0%
+-commutative64.0%
+-commutative64.0%
associate-+l+64.0%
associate-/l*67.4%
unpow267.4%
mul-1-neg67.4%
unsub-neg67.4%
Simplified67.4%
Taylor expanded in a around 0 79.2%
associate-*r/79.2%
neg-mul-179.2%
Simplified79.2%
Taylor expanded in c around 0 96.9%
associate-*r/96.9%
mul-1-neg96.9%
Simplified96.9%
if -4.99999999999999978e110 < b < 2.70000000000000004e48Initial program 87.0%
add-cbrt-cube77.0%
pow377.0%
pow1/277.0%
pow-pow77.0%
*-commutative77.0%
*-commutative77.0%
metadata-eval77.0%
Applied egg-rr77.0%
*-un-lft-identity77.0%
+-commutative77.0%
Applied egg-rr77.0%
*-lft-identity77.0%
unsub-neg77.0%
Simplified77.0%
div-sub77.0%
sub-neg77.0%
pow1/374.5%
pow-pow87.0%
metadata-eval87.0%
pow1/287.0%
*-un-lft-identity87.0%
times-frac87.0%
metadata-eval87.0%
add-sqr-sqrt35.0%
sqrt-prod64.1%
*-un-lft-identity64.1%
metadata-eval64.1%
pow264.1%
unpow-prod-down64.1%
neg-mul-164.1%
unpow264.1%
sqrt-prod64.3%
add-sqr-sqrt64.1%
Applied egg-rr87.0%
sub-neg87.0%
distribute-lft-out--87.0%
Simplified87.0%
sub-neg87.0%
Applied egg-rr87.0%
unsub-neg87.0%
div-sub87.0%
Simplified87.0%
Final simplification91.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* c (* 4.0 a)))))
(t_1 (/ (* 2.0 c) (- (- b) t_0))))
(if (<= b -6.8e+31)
(if (>= b 0.0) t_1 (- (/ c b) (/ b a)))
(if (<= b 2.7e+48)
(if (>= b 0.0) t_1 (* 0.5 (/ (- t_0 b) a)))
(if (>= b 0.0) (/ (- c) b) (/ (- b) a))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = (2.0 * c) / (-b - t_0);
double tmp_1;
if (b <= -6.8e+31) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 2.7e+48) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = 0.5 * ((t_0 - b) / a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -c / b;
} else {
tmp_1 = -b / a;
}
return tmp_1;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - (c * (4.0d0 * a))))
t_1 = (2.0d0 * c) / (-b - t_0)
if (b <= (-6.8d+31)) then
if (b >= 0.0d0) then
tmp_2 = t_1
else
tmp_2 = (c / b) - (b / a)
end if
tmp_1 = tmp_2
else if (b <= 2.7d+48) then
if (b >= 0.0d0) then
tmp_3 = t_1
else
tmp_3 = 0.5d0 * ((t_0 - b) / a)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = -c / b
else
tmp_1 = -b / a
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (c * (4.0 * a))));
double t_1 = (2.0 * c) / (-b - t_0);
double tmp_1;
if (b <= -6.8e+31) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = t_1;
} else {
tmp_2 = (c / b) - (b / a);
}
tmp_1 = tmp_2;
} else if (b <= 2.7e+48) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_1;
} else {
tmp_3 = 0.5 * ((t_0 - b) / a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = -c / b;
} else {
tmp_1 = -b / a;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (c * (4.0 * a)))) t_1 = (2.0 * c) / (-b - t_0) tmp_1 = 0 if b <= -6.8e+31: tmp_2 = 0 if b >= 0.0: tmp_2 = t_1 else: tmp_2 = (c / b) - (b / a) tmp_1 = tmp_2 elif b <= 2.7e+48: tmp_3 = 0 if b >= 0.0: tmp_3 = t_1 else: tmp_3 = 0.5 * ((t_0 - b) / a) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = -c / b else: tmp_1 = -b / a return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) t_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)) tmp_1 = 0.0 if (b <= -6.8e+31) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = t_1; else tmp_2 = Float64(Float64(c / b) - Float64(b / a)); end tmp_1 = tmp_2; elseif (b <= 2.7e+48) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_1; else tmp_3 = Float64(0.5 * Float64(Float64(t_0 - b) / a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(-c) / b); else tmp_1 = Float64(Float64(-b) / a); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - (c * (4.0 * a)))); t_1 = (2.0 * c) / (-b - t_0); tmp_2 = 0.0; if (b <= -6.8e+31) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = t_1; else tmp_3 = (c / b) - (b / a); end tmp_2 = tmp_3; elseif (b <= 2.7e+48) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = t_1; else tmp_4 = 0.5 * ((t_0 - b) / a); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = -c / b; else tmp_2 = -b / a; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -6.8e+31], If[GreaterEqual[b, 0.0], t$95$1, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2.7e+48], If[GreaterEqual[b, 0.0], t$95$1, N[(0.5 * N[(N[(t$95$0 - b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[((-c) / b), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}\\
t_1 := \frac{2 \cdot c}{\left(-b\right) - t_0}\\
\mathbf{if}\;b \leq -6.8 \cdot 10^{+31}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.7 \cdot 10^{+48}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{t_0 - b}{a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
if b < -6.7999999999999996e31Initial program 63.9%
Taylor expanded in b around -inf 66.2%
+-commutative66.2%
+-commutative66.2%
associate-+l+66.2%
associate-/l*71.9%
unpow271.9%
mul-1-neg71.9%
unsub-neg71.9%
Simplified71.9%
Taylor expanded in a around 0 93.5%
+-commutative93.5%
mul-1-neg93.5%
sub-neg93.5%
Simplified93.5%
if -6.7999999999999996e31 < b < 2.70000000000000004e48Initial program 87.7%
add-cbrt-cube77.2%
pow377.1%
pow1/277.1%
pow-pow77.2%
*-commutative77.2%
*-commutative77.2%
metadata-eval77.2%
Applied egg-rr77.2%
*-un-lft-identity77.2%
+-commutative77.2%
Applied egg-rr77.2%
*-lft-identity77.2%
unsub-neg77.2%
Simplified77.2%
div-sub77.2%
sub-neg77.2%
pow1/374.9%
pow-pow87.7%
metadata-eval87.7%
pow1/287.7%
*-un-lft-identity87.7%
times-frac87.7%
metadata-eval87.7%
add-sqr-sqrt39.6%
sqrt-prod72.4%
*-un-lft-identity72.4%
metadata-eval72.4%
pow272.4%
unpow-prod-down72.4%
neg-mul-172.4%
unpow272.4%
sqrt-prod72.4%
add-sqr-sqrt72.4%
Applied egg-rr87.7%
sub-neg87.7%
distribute-lft-out--87.7%
Simplified87.7%
sub-neg87.7%
Applied egg-rr87.7%
unsub-neg87.7%
div-sub87.7%
Simplified87.7%
if 2.70000000000000004e48 < b Initial program 64.3%
Taylor expanded in b around -inf 64.3%
+-commutative64.3%
+-commutative64.3%
associate-+l+64.3%
associate-/l*64.3%
unpow264.3%
mul-1-neg64.3%
unsub-neg64.3%
Simplified64.3%
Taylor expanded in a around 0 64.3%
associate-*r/64.3%
neg-mul-164.3%
Simplified64.3%
Taylor expanded in c around 0 97.1%
associate-*r/97.1%
mul-1-neg97.1%
Simplified97.1%
Final simplification91.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- b) a)))
(if (<= b 7.5e-29)
(if (>= b 0.0) (/ (* 2.0 c) (- b (sqrt (- (* b b) (* c (* 4.0 a)))))) t_0)
(if (>= b 0.0) (/ (- c) b) t_0))))
double code(double a, double b, double c) {
double t_0 = -b / a;
double tmp_1;
if (b <= 7.5e-29) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b - sqrt(((b * b) - (c * (4.0 * a)))));
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = -c / 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 / a
if (b <= 7.5d-29) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 * c) / (b - sqrt(((b * b) - (c * (4.0d0 * a)))))
else
tmp_2 = t_0
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = -c / 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 / a;
double tmp_1;
if (b <= 7.5e-29) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (b - Math.sqrt(((b * b) - (c * (4.0 * a)))));
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = -c / b;
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): t_0 = -b / a tmp_1 = 0 if b <= 7.5e-29: tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 * c) / (b - math.sqrt(((b * b) - (c * (4.0 * a))))) else: tmp_2 = t_0 tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = -c / b else: tmp_1 = t_0 return tmp_1
function code(a, b, c) t_0 = Float64(Float64(-b) / a) tmp_1 = 0.0 if (b <= 7.5e-29) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(b - sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))))); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(-c) / b); else tmp_1 = t_0; end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = -b / a; tmp_2 = 0.0; if (b <= 7.5e-29) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 * c) / (b - sqrt(((b * b) - (c * (4.0 * a))))); else tmp_3 = t_0; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = -c / b; else tmp_2 = t_0; end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-b) / a), $MachinePrecision]}, If[LessEqual[b, 7.5e-29], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[((-c) / b), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-b}{a}\\
\mathbf{if}\;b \leq 7.5 \cdot 10^{-29}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{b - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if b < 7.50000000000000006e-29Initial program 78.6%
Taylor expanded in b around -inf 54.8%
+-commutative54.8%
+-commutative54.8%
associate-+l+54.8%
associate-/l*57.1%
unpow257.1%
mul-1-neg57.1%
unsub-neg57.1%
Simplified57.1%
Taylor expanded in a around 0 68.7%
associate-*r/68.7%
neg-mul-168.7%
Simplified68.7%
expm1-log1p-u64.8%
expm1-udef55.4%
*-commutative55.4%
add-sqr-sqrt49.0%
sqrt-unprod54.2%
sqr-neg54.2%
sqrt-prod54.4%
add-sqr-sqrt54.2%
*-commutative54.2%
*-commutative54.2%
Applied egg-rr54.2%
expm1-def60.7%
expm1-log1p64.0%
Simplified64.0%
if 7.50000000000000006e-29 < b Initial program 67.8%
Taylor expanded in b around -inf 67.8%
+-commutative67.8%
+-commutative67.8%
associate-+l+67.8%
associate-/l*67.8%
unpow267.8%
mul-1-neg67.8%
unsub-neg67.8%
Simplified67.8%
Taylor expanded in a around 0 67.8%
associate-*r/67.8%
neg-mul-167.8%
Simplified67.8%
Taylor expanded in c around 0 90.7%
associate-*r/90.7%
mul-1-neg90.7%
Simplified90.7%
Final simplification72.4%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ b a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = 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 = 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 = b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = 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 = b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(b / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
Initial program 75.2%
Simplified75.0%
Taylor expanded in b around inf 72.5%
+-commutative72.5%
fma-def72.5%
associate-*r/72.5%
*-commutative72.5%
Simplified72.5%
Taylor expanded in b around inf 33.4%
mul-1-neg33.4%
distribute-neg-frac33.4%
Simplified33.4%
Taylor expanded in a around inf 2.8%
Final simplification2.8%
(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(Float64(-c) / b); else tmp = Float64(Float64(-b) / 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 75.2%
Taylor expanded in b around -inf 58.9%
+-commutative58.9%
+-commutative58.9%
associate-+l+58.9%
associate-/l*60.5%
unpow260.5%
mul-1-neg60.5%
unsub-neg60.5%
Simplified60.5%
Taylor expanded in a around 0 68.4%
associate-*r/68.4%
neg-mul-168.4%
Simplified68.4%
Taylor expanded in c around 0 66.7%
associate-*r/66.7%
mul-1-neg66.7%
Simplified66.7%
Final simplification66.7%
herbie shell --seed 2023283
(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))))