
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * 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 + sqrt(((b * b) - (4.0d0 * (a * c))))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * 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 + sqrt(((b * b) - (4.0d0 * (a * c))))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - (4.0 * (a * c))))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -5e+117)
(- (/ c b) (/ b a))
(if (<= b 5.8e-154)
(/ (* (- b (sqrt (- (* b b) (* a (* c 4.0))))) -0.5) a)
(if (<= b 1.4e+78)
(/
(* -0.5 (/ (* c (* a 4.0)) a))
(+ b (sqrt (fma b b (* c (* a -4.0))))))
(/ (- c) b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+117) {
tmp = (c / b) - (b / a);
} else if (b <= 5.8e-154) {
tmp = ((b - sqrt(((b * b) - (a * (c * 4.0))))) * -0.5) / a;
} else if (b <= 1.4e+78) {
tmp = (-0.5 * ((c * (a * 4.0)) / a)) / (b + sqrt(fma(b, b, (c * (a * -4.0)))));
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e+117) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 5.8e-154) tmp = Float64(Float64(Float64(b - sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 4.0))))) * -0.5) / a); elseif (b <= 1.4e+78) tmp = Float64(Float64(-0.5 * Float64(Float64(c * Float64(a * 4.0)) / a)) / Float64(b + sqrt(fma(b, b, Float64(c * Float64(a * -4.0)))))); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e+117], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.8e-154], N[(N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.4e+78], N[(N[(-0.5 * N[(N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[(b + N[Sqrt[N[(b * b + N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+117}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 5.8 \cdot 10^{-154}:\\
\;\;\;\;\frac{\left(b - \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right) \cdot -0.5}{a}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{+78}:\\
\;\;\;\;\frac{-0.5 \cdot \frac{c \cdot \left(a \cdot 4\right)}{a}}{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -4\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.99999999999999983e117Initial program 71.1%
neg-sub071.1%
associate-+l-71.1%
sub0-neg71.1%
neg-mul-171.1%
*-commutative71.1%
associate-*r/71.1%
Simplified71.1%
Taylor expanded in b around -inf 92.6%
mul-1-neg92.6%
unsub-neg92.6%
Simplified92.6%
if -4.99999999999999983e117 < b < 5.8e-154Initial program 86.1%
neg-sub086.1%
associate-+l-86.1%
sub0-neg86.1%
neg-mul-186.1%
*-commutative86.1%
associate-*r/85.9%
Simplified85.9%
fma-udef85.9%
associate-*r*85.9%
metadata-eval85.9%
distribute-rgt-neg-in85.9%
*-commutative85.9%
+-commutative85.9%
sub-neg85.9%
*-commutative85.9%
associate-*l*85.9%
Applied egg-rr85.9%
associate-*r/86.1%
Applied egg-rr86.1%
if 5.8e-154 < b < 1.4000000000000001e78Initial program 50.4%
neg-sub050.4%
associate-+l-50.4%
sub0-neg50.4%
neg-mul-150.4%
*-commutative50.4%
associate-*r/50.2%
Simplified50.2%
fma-udef50.2%
associate-*r*50.2%
metadata-eval50.2%
distribute-rgt-neg-in50.2%
*-commutative50.2%
+-commutative50.2%
sub-neg50.2%
*-commutative50.2%
associate-*l*50.2%
Applied egg-rr50.2%
flip--50.1%
frac-2neg50.1%
metadata-eval50.1%
frac-times41.6%
add-sqr-sqrt41.7%
Applied egg-rr41.7%
*-commutative41.7%
*-commutative41.7%
associate-/r*50.3%
neg-mul-150.3%
times-frac50.3%
metadata-eval50.3%
associate--r-86.1%
+-inverses86.1%
+-lft-identity86.1%
associate-*r*85.7%
*-commutative85.7%
associate-*l*86.1%
fma-neg86.1%
Simplified86.1%
if 1.4000000000000001e78 < b Initial program 14.8%
neg-sub014.8%
associate-+l-14.8%
sub0-neg14.8%
neg-mul-114.8%
*-commutative14.8%
associate-*r/14.8%
Simplified14.9%
Taylor expanded in b around inf 95.8%
associate-*r/95.8%
neg-mul-195.8%
Simplified95.8%
Final simplification89.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* a (* c 4.0))))
(if (<= b -1.85e+79)
(- (/ c b) (/ b a))
(if (<= b 2.5e-98)
(/ 0.5 (/ (- a) (- b (sqrt (fma b b (* a (* c -4.0)))))))
(if (<= b 2.4e+36)
(/ (* -0.5 (/ t_0 (+ b (sqrt (- (* b b) t_0))))) a)
(/ (- c) b))))))
double code(double a, double b, double c) {
double t_0 = a * (c * 4.0);
double tmp;
if (b <= -1.85e+79) {
tmp = (c / b) - (b / a);
} else if (b <= 2.5e-98) {
tmp = 0.5 / (-a / (b - sqrt(fma(b, b, (a * (c * -4.0))))));
} else if (b <= 2.4e+36) {
tmp = (-0.5 * (t_0 / (b + sqrt(((b * b) - t_0))))) / a;
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) t_0 = Float64(a * Float64(c * 4.0)) tmp = 0.0 if (b <= -1.85e+79) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 2.5e-98) tmp = Float64(0.5 / Float64(Float64(-a) / Float64(b - sqrt(fma(b, b, Float64(a * Float64(c * -4.0))))))); elseif (b <= 2.4e+36) tmp = Float64(Float64(-0.5 * Float64(t_0 / Float64(b + sqrt(Float64(Float64(b * b) - t_0))))) / a); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -1.85e+79], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.5e-98], N[(0.5 / N[((-a) / N[(b - N[Sqrt[N[(b * b + N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.4e+36], N[(N[(-0.5 * N[(t$95$0 / N[(b + N[Sqrt[N[(N[(b * b), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(c \cdot 4\right)\\
\mathbf{if}\;b \leq -1.85 \cdot 10^{+79}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 2.5 \cdot 10^{-98}:\\
\;\;\;\;\frac{0.5}{\frac{-a}{b - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)}}}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{+36}:\\
\;\;\;\;\frac{-0.5 \cdot \frac{t_0}{b + \sqrt{b \cdot b - t_0}}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.85000000000000005e79Initial program 76.7%
neg-sub076.7%
associate-+l-76.7%
sub0-neg76.7%
neg-mul-176.7%
*-commutative76.7%
associate-*r/76.6%
Simplified76.6%
Taylor expanded in b around -inf 94.0%
mul-1-neg94.0%
unsub-neg94.0%
Simplified94.0%
if -1.85000000000000005e79 < b < 2.50000000000000009e-98Initial program 83.4%
neg-sub083.4%
associate-+l-83.4%
sub0-neg83.4%
neg-mul-183.4%
*-commutative83.4%
associate-*r/83.2%
Simplified83.2%
associate-*r/83.4%
frac-2neg83.4%
Applied egg-rr83.4%
distribute-rgt-neg-in83.4%
metadata-eval83.4%
*-commutative83.4%
associate-/l*83.4%
fma-def83.4%
+-commutative83.4%
fma-def83.4%
Simplified83.4%
if 2.50000000000000009e-98 < b < 2.39999999999999992e36Initial program 55.1%
neg-sub055.1%
associate-+l-55.1%
sub0-neg55.1%
neg-mul-155.1%
*-commutative55.1%
associate-*r/55.0%
Simplified55.0%
fma-udef55.0%
associate-*r*55.0%
metadata-eval55.0%
distribute-rgt-neg-in55.0%
*-commutative55.0%
+-commutative55.0%
sub-neg55.0%
*-commutative55.0%
associate-*l*55.0%
Applied egg-rr55.0%
associate-*r/55.1%
Applied egg-rr55.1%
flip--54.7%
add-sqr-sqrt54.6%
Applied egg-rr54.8%
associate--r-88.9%
+-inverses88.9%
Simplified89.1%
if 2.39999999999999992e36 < b Initial program 16.8%
neg-sub016.8%
associate-+l-16.8%
sub0-neg16.8%
neg-mul-116.8%
*-commutative16.8%
associate-*r/16.7%
Simplified16.8%
Taylor expanded in b around inf 94.1%
associate-*r/94.1%
neg-mul-194.1%
Simplified94.1%
Final simplification89.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* a (* c 4.0))) (t_1 (sqrt (- (* b b) t_0))))
(if (<= b -4e+114)
(- (/ c b) (/ b a))
(if (<= b 1.35e-157)
(/ (* (- b t_1) -0.5) a)
(if (<= b 1.4e+37) (* (/ t_0 (+ b t_1)) (/ -0.5 a)) (/ (- c) b))))))
double code(double a, double b, double c) {
double t_0 = a * (c * 4.0);
double t_1 = sqrt(((b * b) - t_0));
double tmp;
if (b <= -4e+114) {
tmp = (c / b) - (b / a);
} else if (b <= 1.35e-157) {
tmp = ((b - t_1) * -0.5) / a;
} else if (b <= 1.4e+37) {
tmp = (t_0 / (b + t_1)) * (-0.5 / 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = a * (c * 4.0d0)
t_1 = sqrt(((b * b) - t_0))
if (b <= (-4d+114)) then
tmp = (c / b) - (b / a)
else if (b <= 1.35d-157) then
tmp = ((b - t_1) * (-0.5d0)) / a
else if (b <= 1.4d+37) then
tmp = (t_0 / (b + t_1)) * ((-0.5d0) / a)
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = a * (c * 4.0);
double t_1 = Math.sqrt(((b * b) - t_0));
double tmp;
if (b <= -4e+114) {
tmp = (c / b) - (b / a);
} else if (b <= 1.35e-157) {
tmp = ((b - t_1) * -0.5) / a;
} else if (b <= 1.4e+37) {
tmp = (t_0 / (b + t_1)) * (-0.5 / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): t_0 = a * (c * 4.0) t_1 = math.sqrt(((b * b) - t_0)) tmp = 0 if b <= -4e+114: tmp = (c / b) - (b / a) elif b <= 1.35e-157: tmp = ((b - t_1) * -0.5) / a elif b <= 1.4e+37: tmp = (t_0 / (b + t_1)) * (-0.5 / a) else: tmp = -c / b return tmp
function code(a, b, c) t_0 = Float64(a * Float64(c * 4.0)) t_1 = sqrt(Float64(Float64(b * b) - t_0)) tmp = 0.0 if (b <= -4e+114) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.35e-157) tmp = Float64(Float64(Float64(b - t_1) * -0.5) / a); elseif (b <= 1.4e+37) tmp = Float64(Float64(t_0 / Float64(b + t_1)) * Float64(-0.5 / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) t_0 = a * (c * 4.0); t_1 = sqrt(((b * b) - t_0)); tmp = 0.0; if (b <= -4e+114) tmp = (c / b) - (b / a); elseif (b <= 1.35e-157) tmp = ((b - t_1) * -0.5) / a; elseif (b <= 1.4e+37) tmp = (t_0 / (b + t_1)) * (-0.5 / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -4e+114], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.35e-157], N[(N[(N[(b - t$95$1), $MachinePrecision] * -0.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.4e+37], N[(N[(t$95$0 / N[(b + t$95$1), $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(c \cdot 4\right)\\
t_1 := \sqrt{b \cdot b - t_0}\\
\mathbf{if}\;b \leq -4 \cdot 10^{+114}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.35 \cdot 10^{-157}:\\
\;\;\;\;\frac{\left(b - t_1\right) \cdot -0.5}{a}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{+37}:\\
\;\;\;\;\frac{t_0}{b + t_1} \cdot \frac{-0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4e114Initial program 71.1%
neg-sub071.1%
associate-+l-71.1%
sub0-neg71.1%
neg-mul-171.1%
*-commutative71.1%
associate-*r/71.1%
Simplified71.1%
Taylor expanded in b around -inf 92.6%
mul-1-neg92.6%
unsub-neg92.6%
Simplified92.6%
if -4e114 < b < 1.35e-157Initial program 86.1%
neg-sub086.1%
associate-+l-86.1%
sub0-neg86.1%
neg-mul-186.1%
*-commutative86.1%
associate-*r/85.9%
Simplified85.9%
fma-udef85.9%
associate-*r*85.9%
metadata-eval85.9%
distribute-rgt-neg-in85.9%
*-commutative85.9%
+-commutative85.9%
sub-neg85.9%
*-commutative85.9%
associate-*l*85.9%
Applied egg-rr85.9%
associate-*r/86.1%
Applied egg-rr86.1%
if 1.35e-157 < b < 1.3999999999999999e37Initial program 60.2%
neg-sub060.2%
associate-+l-60.2%
sub0-neg60.2%
neg-mul-160.2%
*-commutative60.2%
associate-*r/60.0%
Simplified60.0%
fma-udef60.0%
associate-*r*60.0%
metadata-eval60.0%
distribute-rgt-neg-in60.0%
*-commutative60.0%
+-commutative60.0%
sub-neg60.0%
*-commutative60.0%
associate-*l*60.0%
Applied egg-rr60.0%
flip--59.9%
add-sqr-sqrt59.9%
Applied egg-rr59.9%
associate--r-85.6%
+-inverses85.6%
Simplified85.6%
if 1.3999999999999999e37 < b Initial program 16.8%
neg-sub016.8%
associate-+l-16.8%
sub0-neg16.8%
neg-mul-116.8%
*-commutative16.8%
associate-*r/16.7%
Simplified16.8%
Taylor expanded in b around inf 94.1%
associate-*r/94.1%
neg-mul-194.1%
Simplified94.1%
Final simplification89.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* a (* c 4.0))) (t_1 (sqrt (- (* b b) t_0))))
(if (<= b -4e+114)
(- (/ c b) (/ b a))
(if (<= b 2.5e-98)
(/ (* (- b t_1) -0.5) a)
(if (<= b 1.6e+36) (/ (* -0.5 (/ t_0 (+ b t_1))) a) (/ (- c) b))))))
double code(double a, double b, double c) {
double t_0 = a * (c * 4.0);
double t_1 = sqrt(((b * b) - t_0));
double tmp;
if (b <= -4e+114) {
tmp = (c / b) - (b / a);
} else if (b <= 2.5e-98) {
tmp = ((b - t_1) * -0.5) / a;
} else if (b <= 1.6e+36) {
tmp = (-0.5 * (t_0 / (b + t_1))) / 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = a * (c * 4.0d0)
t_1 = sqrt(((b * b) - t_0))
if (b <= (-4d+114)) then
tmp = (c / b) - (b / a)
else if (b <= 2.5d-98) then
tmp = ((b - t_1) * (-0.5d0)) / a
else if (b <= 1.6d+36) then
tmp = ((-0.5d0) * (t_0 / (b + t_1))) / a
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = a * (c * 4.0);
double t_1 = Math.sqrt(((b * b) - t_0));
double tmp;
if (b <= -4e+114) {
tmp = (c / b) - (b / a);
} else if (b <= 2.5e-98) {
tmp = ((b - t_1) * -0.5) / a;
} else if (b <= 1.6e+36) {
tmp = (-0.5 * (t_0 / (b + t_1))) / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): t_0 = a * (c * 4.0) t_1 = math.sqrt(((b * b) - t_0)) tmp = 0 if b <= -4e+114: tmp = (c / b) - (b / a) elif b <= 2.5e-98: tmp = ((b - t_1) * -0.5) / a elif b <= 1.6e+36: tmp = (-0.5 * (t_0 / (b + t_1))) / a else: tmp = -c / b return tmp
function code(a, b, c) t_0 = Float64(a * Float64(c * 4.0)) t_1 = sqrt(Float64(Float64(b * b) - t_0)) tmp = 0.0 if (b <= -4e+114) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 2.5e-98) tmp = Float64(Float64(Float64(b - t_1) * -0.5) / a); elseif (b <= 1.6e+36) tmp = Float64(Float64(-0.5 * Float64(t_0 / Float64(b + t_1))) / a); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) t_0 = a * (c * 4.0); t_1 = sqrt(((b * b) - t_0)); tmp = 0.0; if (b <= -4e+114) tmp = (c / b) - (b / a); elseif (b <= 2.5e-98) tmp = ((b - t_1) * -0.5) / a; elseif (b <= 1.6e+36) tmp = (-0.5 * (t_0 / (b + t_1))) / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -4e+114], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.5e-98], N[(N[(N[(b - t$95$1), $MachinePrecision] * -0.5), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 1.6e+36], N[(N[(-0.5 * N[(t$95$0 / N[(b + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot \left(c \cdot 4\right)\\
t_1 := \sqrt{b \cdot b - t_0}\\
\mathbf{if}\;b \leq -4 \cdot 10^{+114}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 2.5 \cdot 10^{-98}:\\
\;\;\;\;\frac{\left(b - t_1\right) \cdot -0.5}{a}\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{+36}:\\
\;\;\;\;\frac{-0.5 \cdot \frac{t_0}{b + t_1}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4e114Initial program 71.1%
neg-sub071.1%
associate-+l-71.1%
sub0-neg71.1%
neg-mul-171.1%
*-commutative71.1%
associate-*r/71.1%
Simplified71.1%
Taylor expanded in b around -inf 92.6%
mul-1-neg92.6%
unsub-neg92.6%
Simplified92.6%
if -4e114 < b < 2.50000000000000009e-98Initial program 85.3%
neg-sub085.3%
associate-+l-85.3%
sub0-neg85.3%
neg-mul-185.3%
*-commutative85.3%
associate-*r/85.0%
Simplified85.0%
fma-udef85.0%
associate-*r*85.0%
metadata-eval85.0%
distribute-rgt-neg-in85.0%
*-commutative85.0%
+-commutative85.0%
sub-neg85.0%
*-commutative85.0%
associate-*l*85.0%
Applied egg-rr85.0%
associate-*r/85.3%
Applied egg-rr85.3%
if 2.50000000000000009e-98 < b < 1.5999999999999999e36Initial program 55.1%
neg-sub055.1%
associate-+l-55.1%
sub0-neg55.1%
neg-mul-155.1%
*-commutative55.1%
associate-*r/55.0%
Simplified55.0%
fma-udef55.0%
associate-*r*55.0%
metadata-eval55.0%
distribute-rgt-neg-in55.0%
*-commutative55.0%
+-commutative55.0%
sub-neg55.0%
*-commutative55.0%
associate-*l*55.0%
Applied egg-rr55.0%
associate-*r/55.1%
Applied egg-rr55.1%
flip--54.7%
add-sqr-sqrt54.6%
Applied egg-rr54.8%
associate--r-88.9%
+-inverses88.9%
Simplified89.1%
if 1.5999999999999999e36 < b Initial program 16.8%
neg-sub016.8%
associate-+l-16.8%
sub0-neg16.8%
neg-mul-116.8%
*-commutative16.8%
associate-*r/16.7%
Simplified16.8%
Taylor expanded in b around inf 94.1%
associate-*r/94.1%
neg-mul-194.1%
Simplified94.1%
Final simplification89.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* (/ -0.5 a) (- b (sqrt (* a (* c -4.0)))))))
(if (<= b -7e-103)
(- (/ c b) (/ b a))
(if (<= b 8.2e-111)
t_0
(if (<= b 3.1e-33)
(/ 0.5 (+ (* 0.5 (/ a b)) (* -0.5 (/ b c))))
(if (<= b 1.8e+33) t_0 (/ (- c) b)))))))
double code(double a, double b, double c) {
double t_0 = (-0.5 / a) * (b - sqrt((a * (c * -4.0))));
double tmp;
if (b <= -7e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 8.2e-111) {
tmp = t_0;
} else if (b <= 3.1e-33) {
tmp = 0.5 / ((0.5 * (a / b)) + (-0.5 * (b / c)));
} else if (b <= 1.8e+33) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = ((-0.5d0) / a) * (b - sqrt((a * (c * (-4.0d0)))))
if (b <= (-7d-103)) then
tmp = (c / b) - (b / a)
else if (b <= 8.2d-111) then
tmp = t_0
else if (b <= 3.1d-33) then
tmp = 0.5d0 / ((0.5d0 * (a / b)) + ((-0.5d0) * (b / c)))
else if (b <= 1.8d+33) then
tmp = t_0
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = (-0.5 / a) * (b - Math.sqrt((a * (c * -4.0))));
double tmp;
if (b <= -7e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 8.2e-111) {
tmp = t_0;
} else if (b <= 3.1e-33) {
tmp = 0.5 / ((0.5 * (a / b)) + (-0.5 * (b / c)));
} else if (b <= 1.8e+33) {
tmp = t_0;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): t_0 = (-0.5 / a) * (b - math.sqrt((a * (c * -4.0)))) tmp = 0 if b <= -7e-103: tmp = (c / b) - (b / a) elif b <= 8.2e-111: tmp = t_0 elif b <= 3.1e-33: tmp = 0.5 / ((0.5 * (a / b)) + (-0.5 * (b / c))) elif b <= 1.8e+33: tmp = t_0 else: tmp = -c / b return tmp
function code(a, b, c) t_0 = Float64(Float64(-0.5 / a) * Float64(b - sqrt(Float64(a * Float64(c * -4.0))))) tmp = 0.0 if (b <= -7e-103) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 8.2e-111) tmp = t_0; elseif (b <= 3.1e-33) tmp = Float64(0.5 / Float64(Float64(0.5 * Float64(a / b)) + Float64(-0.5 * Float64(b / c)))); elseif (b <= 1.8e+33) tmp = t_0; else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) t_0 = (-0.5 / a) * (b - sqrt((a * (c * -4.0)))); tmp = 0.0; if (b <= -7e-103) tmp = (c / b) - (b / a); elseif (b <= 8.2e-111) tmp = t_0; elseif (b <= 3.1e-33) tmp = 0.5 / ((0.5 * (a / b)) + (-0.5 * (b / c))); elseif (b <= 1.8e+33) tmp = t_0; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -7e-103], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.2e-111], t$95$0, If[LessEqual[b, 3.1e-33], N[(0.5 / N[(N[(0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e+33], t$95$0, N[((-c) / b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-0.5}{a} \cdot \left(b - \sqrt{a \cdot \left(c \cdot -4\right)}\right)\\
\mathbf{if}\;b \leq -7 \cdot 10^{-103}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 8.2 \cdot 10^{-111}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 3.1 \cdot 10^{-33}:\\
\;\;\;\;\frac{0.5}{0.5 \cdot \frac{a}{b} + -0.5 \cdot \frac{b}{c}}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{+33}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -7.00000000000000032e-103Initial program 83.7%
neg-sub083.7%
associate-+l-83.7%
sub0-neg83.7%
neg-mul-183.7%
*-commutative83.7%
associate-*r/83.5%
Simplified83.5%
Taylor expanded in b around -inf 86.5%
mul-1-neg86.5%
unsub-neg86.5%
Simplified86.5%
if -7.00000000000000032e-103 < b < 8.19999999999999936e-111 or 3.09999999999999997e-33 < b < 1.8000000000000001e33Initial program 75.6%
neg-sub075.6%
associate-+l-75.6%
sub0-neg75.6%
neg-mul-175.6%
*-commutative75.6%
associate-*r/75.5%
Simplified75.5%
Taylor expanded in a around inf 74.3%
*-commutative74.3%
*-commutative74.3%
associate-*r*74.3%
Simplified74.3%
if 8.19999999999999936e-111 < b < 3.09999999999999997e-33Initial program 37.5%
neg-sub037.5%
associate-+l-37.5%
sub0-neg37.5%
neg-mul-137.5%
*-commutative37.5%
associate-*r/37.3%
Simplified37.3%
associate-*r/37.5%
frac-2neg37.5%
Applied egg-rr37.5%
distribute-rgt-neg-in37.5%
metadata-eval37.5%
*-commutative37.5%
associate-/l*37.3%
fma-def37.3%
+-commutative37.3%
fma-def37.3%
Simplified37.3%
Taylor expanded in a around 0 71.2%
if 1.8000000000000001e33 < b Initial program 16.8%
neg-sub016.8%
associate-+l-16.8%
sub0-neg16.8%
neg-mul-116.8%
*-commutative16.8%
associate-*r/16.7%
Simplified16.8%
Taylor expanded in b around inf 94.1%
associate-*r/94.1%
neg-mul-194.1%
Simplified94.1%
Final simplification84.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (* -0.5 (- b (sqrt (* a (* c -4.0))))) a)))
(if (<= b -7.8e-103)
(- (/ c b) (/ b a))
(if (<= b 1.6e-99)
t_0
(if (<= b 1.8e-34)
(/ 0.5 (+ (* 0.5 (/ a b)) (* -0.5 (/ b c))))
(if (<= b 1.8e+33) t_0 (/ (- c) b)))))))
double code(double a, double b, double c) {
double t_0 = (-0.5 * (b - sqrt((a * (c * -4.0))))) / a;
double tmp;
if (b <= -7.8e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 1.6e-99) {
tmp = t_0;
} else if (b <= 1.8e-34) {
tmp = 0.5 / ((0.5 * (a / b)) + (-0.5 * (b / c)));
} else if (b <= 1.8e+33) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = ((-0.5d0) * (b - sqrt((a * (c * (-4.0d0)))))) / a
if (b <= (-7.8d-103)) then
tmp = (c / b) - (b / a)
else if (b <= 1.6d-99) then
tmp = t_0
else if (b <= 1.8d-34) then
tmp = 0.5d0 / ((0.5d0 * (a / b)) + ((-0.5d0) * (b / c)))
else if (b <= 1.8d+33) then
tmp = t_0
else
tmp = -c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = (-0.5 * (b - Math.sqrt((a * (c * -4.0))))) / a;
double tmp;
if (b <= -7.8e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 1.6e-99) {
tmp = t_0;
} else if (b <= 1.8e-34) {
tmp = 0.5 / ((0.5 * (a / b)) + (-0.5 * (b / c)));
} else if (b <= 1.8e+33) {
tmp = t_0;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): t_0 = (-0.5 * (b - math.sqrt((a * (c * -4.0))))) / a tmp = 0 if b <= -7.8e-103: tmp = (c / b) - (b / a) elif b <= 1.6e-99: tmp = t_0 elif b <= 1.8e-34: tmp = 0.5 / ((0.5 * (a / b)) + (-0.5 * (b / c))) elif b <= 1.8e+33: tmp = t_0 else: tmp = -c / b return tmp
function code(a, b, c) t_0 = Float64(Float64(-0.5 * Float64(b - sqrt(Float64(a * Float64(c * -4.0))))) / a) tmp = 0.0 if (b <= -7.8e-103) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.6e-99) tmp = t_0; elseif (b <= 1.8e-34) tmp = Float64(0.5 / Float64(Float64(0.5 * Float64(a / b)) + Float64(-0.5 * Float64(b / c)))); elseif (b <= 1.8e+33) tmp = t_0; else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) t_0 = (-0.5 * (b - sqrt((a * (c * -4.0))))) / a; tmp = 0.0; if (b <= -7.8e-103) tmp = (c / b) - (b / a); elseif (b <= 1.6e-99) tmp = t_0; elseif (b <= 1.8e-34) tmp = 0.5 / ((0.5 * (a / b)) + (-0.5 * (b / c))); elseif (b <= 1.8e+33) tmp = t_0; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(-0.5 * N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[b, -7.8e-103], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.6e-99], t$95$0, If[LessEqual[b, 1.8e-34], N[(0.5 / N[(N[(0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e+33], t$95$0, N[((-c) / b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-0.5 \cdot \left(b - \sqrt{a \cdot \left(c \cdot -4\right)}\right)}{a}\\
\mathbf{if}\;b \leq -7.8 \cdot 10^{-103}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{-99}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-34}:\\
\;\;\;\;\frac{0.5}{0.5 \cdot \frac{a}{b} + -0.5 \cdot \frac{b}{c}}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{+33}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -7.8000000000000004e-103Initial program 83.7%
neg-sub083.7%
associate-+l-83.7%
sub0-neg83.7%
neg-mul-183.7%
*-commutative83.7%
associate-*r/83.5%
Simplified83.5%
Taylor expanded in b around -inf 86.5%
mul-1-neg86.5%
unsub-neg86.5%
Simplified86.5%
if -7.8000000000000004e-103 < b < 1.6e-99 or 1.80000000000000004e-34 < b < 1.8000000000000001e33Initial program 75.6%
neg-sub075.6%
associate-+l-75.6%
sub0-neg75.6%
neg-mul-175.6%
*-commutative75.6%
associate-*r/75.5%
Simplified75.5%
Taylor expanded in a around inf 74.3%
*-commutative74.3%
*-commutative74.3%
associate-*r*74.3%
Simplified74.3%
associate-*r/74.4%
Applied egg-rr74.4%
if 1.6e-99 < b < 1.80000000000000004e-34Initial program 37.5%
neg-sub037.5%
associate-+l-37.5%
sub0-neg37.5%
neg-mul-137.5%
*-commutative37.5%
associate-*r/37.3%
Simplified37.3%
associate-*r/37.5%
frac-2neg37.5%
Applied egg-rr37.5%
distribute-rgt-neg-in37.5%
metadata-eval37.5%
*-commutative37.5%
associate-/l*37.3%
fma-def37.3%
+-commutative37.3%
fma-def37.3%
Simplified37.3%
Taylor expanded in a around 0 71.2%
if 1.8000000000000001e33 < b Initial program 16.8%
neg-sub016.8%
associate-+l-16.8%
sub0-neg16.8%
neg-mul-116.8%
*-commutative16.8%
associate-*r/16.7%
Simplified16.8%
Taylor expanded in b around inf 94.1%
associate-*r/94.1%
neg-mul-194.1%
Simplified94.1%
Final simplification84.4%
(FPCore (a b c)
:precision binary64
(if (<= b -7.2e+83)
(- (/ c b) (/ b a))
(if (<= b 1.8e+33)
(* (- b (sqrt (- (* b b) (* a (* c 4.0))))) (/ -0.5 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.2e+83) {
tmp = (c / b) - (b / a);
} else if (b <= 1.8e+33) {
tmp = (b - sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / 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 <= (-7.2d+83)) then
tmp = (c / b) - (b / a)
else if (b <= 1.8d+33) then
tmp = (b - sqrt(((b * b) - (a * (c * 4.0d0))))) * ((-0.5d0) / 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 <= -7.2e+83) {
tmp = (c / b) - (b / a);
} else if (b <= 1.8e+33) {
tmp = (b - Math.sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.2e+83: tmp = (c / b) - (b / a) elif b <= 1.8e+33: tmp = (b - math.sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.2e+83) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.8e+33) tmp = Float64(Float64(b - sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 4.0))))) * Float64(-0.5 / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -7.2e+83) tmp = (c / b) - (b / a); elseif (b <= 1.8e+33) tmp = (b - sqrt(((b * b) - (a * (c * 4.0))))) * (-0.5 / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.2e+83], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e+33], N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.2 \cdot 10^{+83}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{+33}:\\
\;\;\;\;\left(b - \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right) \cdot \frac{-0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -7.1999999999999995e83Initial program 75.9%
neg-sub075.9%
associate-+l-75.9%
sub0-neg75.9%
neg-mul-175.9%
*-commutative75.9%
associate-*r/75.8%
Simplified75.8%
Taylor expanded in b around -inf 93.8%
mul-1-neg93.8%
unsub-neg93.8%
Simplified93.8%
if -7.1999999999999995e83 < b < 1.8000000000000001e33Initial program 78.0%
neg-sub078.0%
associate-+l-78.0%
sub0-neg78.0%
neg-mul-178.0%
*-commutative78.0%
associate-*r/77.8%
Simplified77.8%
fma-udef77.8%
associate-*r*77.8%
metadata-eval77.8%
distribute-rgt-neg-in77.8%
*-commutative77.8%
+-commutative77.8%
sub-neg77.8%
*-commutative77.8%
associate-*l*77.8%
Applied egg-rr77.8%
if 1.8000000000000001e33 < b Initial program 16.8%
neg-sub016.8%
associate-+l-16.8%
sub0-neg16.8%
neg-mul-116.8%
*-commutative16.8%
associate-*r/16.7%
Simplified16.8%
Taylor expanded in b around inf 94.1%
associate-*r/94.1%
neg-mul-194.1%
Simplified94.1%
Final simplification86.5%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+115)
(- (/ c b) (/ b a))
(if (<= b 1.75e+34)
(/ (* (- b (sqrt (- (* b b) (* a (* c 4.0))))) -0.5) a)
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+115) {
tmp = (c / b) - (b / a);
} else if (b <= 1.75e+34) {
tmp = ((b - sqrt(((b * b) - (a * (c * 4.0))))) * -0.5) / 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 <= (-5d+115)) then
tmp = (c / b) - (b / a)
else if (b <= 1.75d+34) then
tmp = ((b - sqrt(((b * b) - (a * (c * 4.0d0))))) * (-0.5d0)) / 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 <= -5e+115) {
tmp = (c / b) - (b / a);
} else if (b <= 1.75e+34) {
tmp = ((b - Math.sqrt(((b * b) - (a * (c * 4.0))))) * -0.5) / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+115: tmp = (c / b) - (b / a) elif b <= 1.75e+34: tmp = ((b - math.sqrt(((b * b) - (a * (c * 4.0))))) * -0.5) / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+115) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.75e+34) tmp = Float64(Float64(Float64(b - sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 4.0))))) * -0.5) / a); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e+115) tmp = (c / b) - (b / a); elseif (b <= 1.75e+34) tmp = ((b - sqrt(((b * b) - (a * (c * 4.0))))) * -0.5) / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+115], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.75e+34], N[(N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision] / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+115}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.75 \cdot 10^{+34}:\\
\;\;\;\;\frac{\left(b - \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\right) \cdot -0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.00000000000000008e115Initial program 71.1%
neg-sub071.1%
associate-+l-71.1%
sub0-neg71.1%
neg-mul-171.1%
*-commutative71.1%
associate-*r/71.1%
Simplified71.1%
Taylor expanded in b around -inf 92.6%
mul-1-neg92.6%
unsub-neg92.6%
Simplified92.6%
if -5.00000000000000008e115 < b < 1.74999999999999999e34Initial program 79.7%
neg-sub079.7%
associate-+l-79.7%
sub0-neg79.7%
neg-mul-179.7%
*-commutative79.7%
associate-*r/79.4%
Simplified79.4%
fma-udef79.4%
associate-*r*79.4%
metadata-eval79.4%
distribute-rgt-neg-in79.4%
*-commutative79.4%
+-commutative79.4%
sub-neg79.4%
*-commutative79.4%
associate-*l*79.4%
Applied egg-rr79.4%
associate-*r/79.7%
Applied egg-rr79.7%
if 1.74999999999999999e34 < b Initial program 16.8%
neg-sub016.8%
associate-+l-16.8%
sub0-neg16.8%
neg-mul-116.8%
*-commutative16.8%
associate-*r/16.7%
Simplified16.8%
Taylor expanded in b around inf 94.1%
associate-*r/94.1%
neg-mul-194.1%
Simplified94.1%
Final simplification86.6%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
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 <= (-2d-310)) 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 <= -2e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) 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 <= -2e-310) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 82.4%
neg-sub082.4%
associate-+l-82.4%
sub0-neg82.4%
neg-mul-182.4%
*-commutative82.4%
associate-*r/82.2%
Simplified82.2%
Taylor expanded in b around -inf 67.0%
mul-1-neg67.0%
unsub-neg67.0%
Simplified67.0%
if -1.999999999999994e-310 < b Initial program 38.5%
neg-sub038.5%
associate-+l-38.5%
sub0-neg38.5%
neg-mul-138.5%
*-commutative38.5%
associate-*r/38.4%
Simplified38.5%
Taylor expanded in b around inf 66.2%
associate-*r/66.2%
neg-mul-166.2%
Simplified66.2%
Final simplification66.6%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ (- b) a) 0.0))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = -b / a;
} else {
tmp = 0.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 <= (-2d-310)) then
tmp = -b / a
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = -b / a;
} else {
tmp = 0.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = -b / a else: tmp = 0.0 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(-b) / a); else tmp = 0.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = -b / a; else tmp = 0.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[((-b) / a), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 82.4%
neg-sub082.4%
associate-+l-82.4%
sub0-neg82.4%
neg-mul-182.4%
*-commutative82.4%
associate-*r/82.2%
Simplified82.2%
Taylor expanded in b around -inf 66.7%
associate-*r/66.7%
mul-1-neg66.7%
Simplified66.7%
if -1.999999999999994e-310 < b Initial program 38.5%
neg-sub038.5%
associate-+l-38.5%
sub0-neg38.5%
neg-mul-138.5%
*-commutative38.5%
associate-*r/38.4%
Simplified38.5%
Taylor expanded in a around 0 9.6%
unpow29.6%
Simplified9.6%
Taylor expanded in b around 0 22.5%
Final simplification43.2%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
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 <= (-2d-310)) 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 <= -2e-310) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(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 <= -2e-310) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 82.4%
neg-sub082.4%
associate-+l-82.4%
sub0-neg82.4%
neg-mul-182.4%
*-commutative82.4%
associate-*r/82.2%
Simplified82.2%
Taylor expanded in b around -inf 66.7%
associate-*r/66.7%
mul-1-neg66.7%
Simplified66.7%
if -1.999999999999994e-310 < b Initial program 38.5%
neg-sub038.5%
associate-+l-38.5%
sub0-neg38.5%
neg-mul-138.5%
*-commutative38.5%
associate-*r/38.4%
Simplified38.5%
Taylor expanded in b around inf 66.2%
associate-*r/66.2%
neg-mul-166.2%
Simplified66.2%
Final simplification66.4%
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
return 0.0;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 0.0d0
end function
public static double code(double a, double b, double c) {
return 0.0;
}
def code(a, b, c): return 0.0
function code(a, b, c) return 0.0 end
function tmp = code(a, b, c) tmp = 0.0; end
code[a_, b_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 59.1%
neg-sub059.1%
associate-+l-59.1%
sub0-neg59.1%
neg-mul-159.1%
*-commutative59.1%
associate-*r/58.9%
Simplified59.0%
Taylor expanded in a around 0 31.8%
unpow231.8%
Simplified31.8%
Taylor expanded in b around 0 13.2%
Final simplification13.2%
(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))
(/ c (* a (/ (- (- 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 = (-b + t_0) / (2.0 * a);
} else {
tmp = c / (a * ((-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 = (-b + t_0) / (2.0d0 * a)
else
tmp = c / (a * ((-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 = (-b + t_0) / (2.0 * a);
} else {
tmp = c / (a * ((-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 = (-b + t_0) / (2.0 * a) else: tmp = c / (a * ((-b - t_0) / (2.0 * a))) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) tmp = 0.0 if (b < 0.0) tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)); else tmp = Float64(c / Float64(a * 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 = (-b + t_0) / (2.0 * a); else tmp = c / (a * ((-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[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Less[b, 0.0], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(c / N[(a * N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\
\mathbf{if}\;b < 0:\\
\;\;\;\;\frac{\left(-b\right) + t_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) - t_0}{2 \cdot a}}\\
\end{array}
\end{array}
herbie shell --seed 2023258
(FPCore (a b c)
:name "quadp (p42, positive)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)) (/ c (* a (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))))
(/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))