
(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(Float64(4.0 * 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[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 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(Float64(4.0 * 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[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -6e+153)
(- (/ c b) (/ b a))
(if (<= b 8.5e-95)
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6e+153) {
tmp = (c / b) - (b / a);
} else if (b <= 8.5e-95) {
tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.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) :: tmp
if (b <= (-6d+153)) then
tmp = (c / b) - (b / a)
else if (b <= 8.5d-95) then
tmp = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6e+153) {
tmp = (c / b) - (b / a);
} else if (b <= 8.5e-95) {
tmp = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6e+153: tmp = (c / b) - (b / a) elif b <= 8.5e-95: tmp = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6e+153) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 8.5e-95) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6e+153) tmp = (c / b) - (b / a); elseif (b <= 8.5e-95) tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6e+153], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.5e-95], 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], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6 \cdot 10^{+153}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-95}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -6.00000000000000037e153Initial program 42.8%
*-commutative42.8%
Simplified42.8%
Taylor expanded in b around -inf 99.5%
mul-1-neg99.5%
distribute-rgt-neg-in99.5%
+-commutative99.5%
mul-1-neg99.5%
unsub-neg99.5%
Simplified99.5%
Taylor expanded in a around inf 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
if -6.00000000000000037e153 < b < 8.4999999999999995e-95Initial program 83.6%
if 8.4999999999999995e-95 < b Initial program 19.1%
*-commutative19.1%
Simplified19.1%
Taylor expanded in b around inf 86.6%
associate-*r/86.6%
mul-1-neg86.6%
Simplified86.6%
Final simplification87.3%
(FPCore (a b c)
:precision binary64
(if (<= b -2.8e-67)
(- (/ c b) (/ b a))
(if (<= b 6.8e-97)
(/ (* 0.5 (- (sqrt (/ (* a 4.0) (/ -1.0 c))) b)) a)
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.8e-67) {
tmp = (c / b) - (b / a);
} else if (b <= 6.8e-97) {
tmp = (0.5 * (sqrt(((a * 4.0) / (-1.0 / c))) - 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 <= (-2.8d-67)) then
tmp = (c / b) - (b / a)
else if (b <= 6.8d-97) then
tmp = (0.5d0 * (sqrt(((a * 4.0d0) / ((-1.0d0) / c))) - 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 <= -2.8e-67) {
tmp = (c / b) - (b / a);
} else if (b <= 6.8e-97) {
tmp = (0.5 * (Math.sqrt(((a * 4.0) / (-1.0 / c))) - b)) / a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.8e-67: tmp = (c / b) - (b / a) elif b <= 6.8e-97: tmp = (0.5 * (math.sqrt(((a * 4.0) / (-1.0 / c))) - b)) / a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.8e-67) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 6.8e-97) tmp = Float64(Float64(0.5 * Float64(sqrt(Float64(Float64(a * 4.0) / Float64(-1.0 / c))) - b)) / a); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.8e-67) tmp = (c / b) - (b / a); elseif (b <= 6.8e-97) tmp = (0.5 * (sqrt(((a * 4.0) / (-1.0 / c))) - b)) / a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.8e-67], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.8e-97], N[(N[(0.5 * N[(N[Sqrt[N[(N[(a * 4.0), $MachinePrecision] / N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.8 \cdot 10^{-67}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 6.8 \cdot 10^{-97}:\\
\;\;\;\;\frac{0.5 \cdot \left(\sqrt{\frac{a \cdot 4}{\frac{-1}{c}}} - b\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -2.8000000000000001e-67Initial program 72.2%
*-commutative72.2%
Simplified72.2%
Taylor expanded in b around -inf 85.6%
mul-1-neg85.6%
distribute-rgt-neg-in85.6%
+-commutative85.6%
mul-1-neg85.6%
unsub-neg85.6%
Simplified85.6%
Taylor expanded in a around inf 86.0%
+-commutative86.0%
mul-1-neg86.0%
unsub-neg86.0%
Simplified86.0%
if -2.8000000000000001e-67 < b < 6.7999999999999998e-97Initial program 74.8%
*-commutative74.8%
Simplified74.8%
Applied egg-rr74.6%
sub-neg74.6%
distribute-rgt-out--74.6%
Simplified74.6%
pow1/274.6%
pow-to-exp69.9%
Applied egg-rr69.9%
Taylor expanded in c around -inf 45.1%
mul-1-neg45.1%
unsub-neg45.1%
*-commutative45.1%
Simplified45.1%
associate-*l/45.1%
exp-prod37.1%
unpow1/237.1%
diff-log65.4%
add-exp-log69.6%
Applied egg-rr69.6%
if 6.7999999999999998e-97 < b Initial program 19.1%
*-commutative19.1%
Simplified19.1%
Taylor expanded in b around inf 86.6%
associate-*r/86.6%
mul-1-neg86.6%
Simplified86.6%
Final simplification82.1%
(FPCore (a b c)
:precision binary64
(if (<= b -3.6e-68)
(- (/ c b) (/ b a))
(if (<= b 1.9e-96)
(/ (- (sqrt (* c (* a -4.0))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e-68) {
tmp = (c / b) - (b / a);
} else if (b <= 1.9e-96) {
tmp = (sqrt((c * (a * -4.0))) - b) / (a * 2.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) :: tmp
if (b <= (-3.6d-68)) then
tmp = (c / b) - (b / a)
else if (b <= 1.9d-96) then
tmp = (sqrt((c * (a * (-4.0d0)))) - b) / (a * 2.0d0)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e-68) {
tmp = (c / b) - (b / a);
} else if (b <= 1.9e-96) {
tmp = (Math.sqrt((c * (a * -4.0))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.6e-68: tmp = (c / b) - (b / a) elif b <= 1.9e-96: tmp = (math.sqrt((c * (a * -4.0))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.6e-68) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.9e-96) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.6e-68) tmp = (c / b) - (b / a); elseif (b <= 1.9e-96) tmp = (sqrt((c * (a * -4.0))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.6e-68], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.9e-96], N[(N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.6 \cdot 10^{-68}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-96}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -3.60000000000000007e-68Initial program 72.2%
*-commutative72.2%
Simplified72.2%
Taylor expanded in b around -inf 85.6%
mul-1-neg85.6%
distribute-rgt-neg-in85.6%
+-commutative85.6%
mul-1-neg85.6%
unsub-neg85.6%
Simplified85.6%
Taylor expanded in a around inf 86.0%
+-commutative86.0%
mul-1-neg86.0%
unsub-neg86.0%
Simplified86.0%
if -3.60000000000000007e-68 < b < 1.9e-96Initial program 74.8%
*-commutative74.8%
Simplified74.8%
Taylor expanded in b around 0 69.5%
*-commutative69.5%
*-commutative69.5%
associate-*r*69.6%
Simplified69.6%
if 1.9e-96 < b Initial program 19.1%
*-commutative19.1%
Simplified19.1%
Taylor expanded in b around inf 86.6%
associate-*r/86.6%
mul-1-neg86.6%
Simplified86.6%
Final simplification82.1%
(FPCore (a b c)
:precision binary64
(if (<= b -7.5e-69)
(- (/ c b) (/ b a))
(if (<= b 4.5e-100)
(* (/ 0.5 a) (- (sqrt (* a (* c -4.0))) b))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.5e-69) {
tmp = (c / b) - (b / a);
} else if (b <= 4.5e-100) {
tmp = (0.5 / a) * (sqrt((a * (c * -4.0))) - b);
} else {
tmp = c / -b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-7.5d-69)) then
tmp = (c / b) - (b / a)
else if (b <= 4.5d-100) then
tmp = (0.5d0 / a) * (sqrt((a * (c * (-4.0d0)))) - b)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -7.5e-69) {
tmp = (c / b) - (b / a);
} else if (b <= 4.5e-100) {
tmp = (0.5 / a) * (Math.sqrt((a * (c * -4.0))) - b);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -7.5e-69: tmp = (c / b) - (b / a) elif b <= 4.5e-100: tmp = (0.5 / a) * (math.sqrt((a * (c * -4.0))) - b) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -7.5e-69) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 4.5e-100) tmp = Float64(Float64(0.5 / a) * Float64(sqrt(Float64(a * Float64(c * -4.0))) - b)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -7.5e-69) tmp = (c / b) - (b / a); elseif (b <= 4.5e-100) tmp = (0.5 / a) * (sqrt((a * (c * -4.0))) - b); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -7.5e-69], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.5e-100], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.5 \cdot 10^{-69}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-100}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{a \cdot \left(c \cdot -4\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -7.5e-69Initial program 72.2%
*-commutative72.2%
Simplified72.2%
Taylor expanded in b around -inf 85.6%
mul-1-neg85.6%
distribute-rgt-neg-in85.6%
+-commutative85.6%
mul-1-neg85.6%
unsub-neg85.6%
Simplified85.6%
Taylor expanded in a around inf 86.0%
+-commutative86.0%
mul-1-neg86.0%
unsub-neg86.0%
Simplified86.0%
if -7.5e-69 < b < 4.5000000000000001e-100Initial program 74.8%
*-commutative74.8%
Simplified74.8%
Applied egg-rr74.6%
sub-neg74.6%
distribute-rgt-out--74.6%
Simplified74.6%
Taylor expanded in a around inf 69.4%
*-commutative69.4%
associate-*r*69.5%
Simplified69.5%
if 4.5000000000000001e-100 < b Initial program 19.1%
*-commutative19.1%
Simplified19.1%
Taylor expanded in b around inf 86.6%
associate-*r/86.6%
mul-1-neg86.6%
Simplified86.6%
Final simplification82.0%
(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(c / Float64(-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 74.9%
*-commutative74.9%
Simplified74.9%
Taylor expanded in b around -inf 63.7%
mul-1-neg63.7%
distribute-rgt-neg-in63.7%
+-commutative63.7%
mul-1-neg63.7%
unsub-neg63.7%
Simplified63.7%
Taylor expanded in a around inf 64.1%
+-commutative64.1%
mul-1-neg64.1%
unsub-neg64.1%
Simplified64.1%
if -1.999999999999994e-310 < b Initial program 28.0%
*-commutative28.0%
Simplified28.0%
Taylor expanded in b around inf 71.9%
associate-*r/71.9%
mul-1-neg71.9%
Simplified71.9%
Final simplification67.8%
(FPCore (a b c) :precision binary64 (if (<= b 2.9e-303) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.9e-303) {
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 <= 2.9d-303) 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 <= 2.9e-303) {
tmp = b / -a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.9e-303: tmp = b / -a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.9e-303) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.9e-303) tmp = b / -a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.9e-303], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.9 \cdot 10^{-303}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < 2.90000000000000014e-303Initial program 75.1%
*-commutative75.1%
Simplified75.1%
Taylor expanded in b around -inf 63.2%
mul-1-neg63.2%
distribute-neg-frac263.2%
Simplified63.2%
if 2.90000000000000014e-303 < b Initial program 27.4%
*-commutative27.4%
Simplified27.4%
Taylor expanded in b around inf 72.5%
associate-*r/72.5%
mul-1-neg72.5%
Simplified72.5%
Final simplification67.6%
(FPCore (a b c) :precision binary64 (if (<= b 1.05e+14) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.05e+14) {
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 <= 1.05d+14) 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 <= 1.05e+14) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.05e+14: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.05e+14) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.05e+14) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.05e+14], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.05 \cdot 10^{+14}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.05e14Initial program 68.7%
*-commutative68.7%
Simplified68.7%
Taylor expanded in b around -inf 47.8%
mul-1-neg47.8%
distribute-neg-frac247.8%
Simplified47.8%
if 1.05e14 < b Initial program 13.5%
*-commutative13.5%
Simplified13.5%
Taylor expanded in b around -inf 2.3%
mul-1-neg2.3%
distribute-rgt-neg-in2.3%
+-commutative2.3%
mul-1-neg2.3%
unsub-neg2.3%
Simplified2.3%
Taylor expanded in b around 0 27.5%
(FPCore (a b c) :precision binary64 (/ c b))
double code(double a, double b, double c) {
return c / b;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = c / b
end function
public static double code(double a, double b, double c) {
return c / b;
}
def code(a, b, c): return c / b
function code(a, b, c) return Float64(c / b) end
function tmp = code(a, b, c) tmp = c / b; end
code[a_, b_, c_] := N[(c / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b}
\end{array}
Initial program 52.5%
*-commutative52.5%
Simplified52.5%
Taylor expanded in b around -inf 34.3%
mul-1-neg34.3%
distribute-rgt-neg-in34.3%
+-commutative34.3%
mul-1-neg34.3%
unsub-neg34.3%
Simplified34.3%
Taylor expanded in b around 0 10.3%
herbie shell --seed 2024108
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))