
(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 10 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 -3e+108)
(/ b (- a))
(if (<= b 1.16e-92)
(/ (- (sqrt (* a (+ (/ (pow b 2.0) a) (* -4.0 c)))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3e+108) {
tmp = b / -a;
} else if (b <= 1.16e-92) {
tmp = (sqrt((a * ((pow(b, 2.0) / a) + (-4.0 * c)))) - 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 <= (-3d+108)) then
tmp = b / -a
else if (b <= 1.16d-92) then
tmp = (sqrt((a * (((b ** 2.0d0) / a) + ((-4.0d0) * c)))) - 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 <= -3e+108) {
tmp = b / -a;
} else if (b <= 1.16e-92) {
tmp = (Math.sqrt((a * ((Math.pow(b, 2.0) / a) + (-4.0 * c)))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3e+108: tmp = b / -a elif b <= 1.16e-92: tmp = (math.sqrt((a * ((math.pow(b, 2.0) / a) + (-4.0 * c)))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3e+108) tmp = Float64(b / Float64(-a)); elseif (b <= 1.16e-92) tmp = Float64(Float64(sqrt(Float64(a * Float64(Float64((b ^ 2.0) / a) + Float64(-4.0 * c)))) - 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 <= -3e+108) tmp = b / -a; elseif (b <= 1.16e-92) tmp = (sqrt((a * (((b ^ 2.0) / a) + (-4.0 * c)))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3e+108], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.16e-92], N[(N[(N[Sqrt[N[(a * N[(N[(N[Power[b, 2.0], $MachinePrecision] / a), $MachinePrecision] + N[(-4.0 * c), $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 -3 \cdot 10^{+108}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 1.16 \cdot 10^{-92}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(\frac{{b}^{2}}{a} + -4 \cdot c\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -2.99999999999999984e108Initial program 59.7%
*-commutative59.7%
Simplified59.7%
Taylor expanded in b around -inf 95.9%
associate-*r/95.9%
mul-1-neg95.9%
Simplified95.9%
if -2.99999999999999984e108 < b < 1.1599999999999999e-92Initial program 87.1%
*-commutative87.1%
Simplified87.1%
Taylor expanded in a around inf 87.1%
if 1.1599999999999999e-92 < b Initial program 14.6%
*-commutative14.6%
Simplified14.7%
Taylor expanded in a around 0 89.9%
associate-*r/89.9%
mul-1-neg89.9%
Simplified89.9%
Final simplification89.8%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+154)
(/ b (- a))
(if (<= b 2.5e-78)
(/ (- (sqrt (fma a (* -4.0 c) (* b b))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+154) {
tmp = b / -a;
} else if (b <= 2.5e-78) {
tmp = (sqrt(fma(a, (-4.0 * c), (b * b))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e+154) tmp = Float64(b / Float64(-a)); elseif (b <= 2.5e-78) tmp = Float64(Float64(sqrt(fma(a, Float64(-4.0 * c), Float64(b * b))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e+154], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 2.5e-78], N[(N[(N[Sqrt[N[(a * N[(-4.0 * c), $MachinePrecision] + N[(b * b), $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 -5 \cdot 10^{+154}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 2.5 \cdot 10^{-78}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, -4 \cdot c, b \cdot b\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -5.00000000000000004e154Initial program 39.5%
*-commutative39.5%
Simplified39.6%
Taylor expanded in b around -inf 93.8%
associate-*r/93.8%
mul-1-neg93.8%
Simplified93.8%
if -5.00000000000000004e154 < b < 2.4999999999999998e-78Initial program 88.7%
*-commutative88.7%
Simplified88.7%
if 2.4999999999999998e-78 < b Initial program 14.6%
*-commutative14.6%
Simplified14.7%
Taylor expanded in a around 0 89.9%
associate-*r/89.9%
mul-1-neg89.9%
Simplified89.9%
Final simplification89.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1e+153)
(/ b (- a))
(if (<= b 3.1e-90)
(/ (- (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 <= -1e+153) {
tmp = b / -a;
} else if (b <= 3.1e-90) {
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 <= (-1d+153)) then
tmp = b / -a
else if (b <= 3.1d-90) 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 <= -1e+153) {
tmp = b / -a;
} else if (b <= 3.1e-90) {
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 <= -1e+153: tmp = b / -a elif b <= 3.1e-90: 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 <= -1e+153) tmp = Float64(b / Float64(-a)); elseif (b <= 3.1e-90) 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 <= -1e+153) tmp = b / -a; elseif (b <= 3.1e-90) 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, -1e+153], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 3.1e-90], 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 -1 \cdot 10^{+153}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 3.1 \cdot 10^{-90}:\\
\;\;\;\;\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 < -1e153Initial program 39.5%
*-commutative39.5%
Simplified39.6%
Taylor expanded in b around -inf 93.8%
associate-*r/93.8%
mul-1-neg93.8%
Simplified93.8%
if -1e153 < b < 3.1000000000000001e-90Initial program 88.7%
if 3.1000000000000001e-90 < b Initial program 14.6%
*-commutative14.6%
Simplified14.7%
Taylor expanded in a around 0 89.9%
associate-*r/89.9%
mul-1-neg89.9%
Simplified89.9%
Final simplification89.8%
(FPCore (a b c)
:precision binary64
(if (<= b -2.9e-135)
(- (/ c b) (/ b a))
(if (<= b 3.9e-77)
(/ (- (sqrt (* c (* a -4.0))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.9e-135) {
tmp = (c / b) - (b / a);
} else if (b <= 3.9e-77) {
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 <= (-2.9d-135)) then
tmp = (c / b) - (b / a)
else if (b <= 3.9d-77) 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 <= -2.9e-135) {
tmp = (c / b) - (b / a);
} else if (b <= 3.9e-77) {
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 <= -2.9e-135: tmp = (c / b) - (b / a) elif b <= 3.9e-77: 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 <= -2.9e-135) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3.9e-77) 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 <= -2.9e-135) tmp = (c / b) - (b / a); elseif (b <= 3.9e-77) 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, -2.9e-135], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.9e-77], 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 -2.9 \cdot 10^{-135}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.9 \cdot 10^{-77}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -2.9000000000000002e-135Initial program 74.6%
*-commutative74.6%
Simplified74.7%
Taylor expanded in b around -inf 77.6%
mul-1-neg77.6%
distribute-rgt-neg-in77.6%
+-commutative77.6%
mul-1-neg77.6%
unsub-neg77.6%
Simplified77.6%
Taylor expanded in a around inf 77.8%
+-commutative77.8%
mul-1-neg77.8%
unsub-neg77.8%
Simplified77.8%
if -2.9000000000000002e-135 < b < 3.89999999999999979e-77Initial program 85.6%
*-commutative85.6%
Simplified85.6%
Taylor expanded in a around inf 85.5%
associate-*r*85.5%
*-commutative85.5%
Simplified85.5%
if 3.89999999999999979e-77 < b Initial program 14.6%
*-commutative14.6%
Simplified14.7%
Taylor expanded in a around 0 89.9%
associate-*r/89.9%
mul-1-neg89.9%
Simplified89.9%
Final simplification84.5%
(FPCore (a b c)
:precision binary64
(if (<= b -2.9e-135)
(- (/ c b) (/ b a))
(if (<= b 1.7e-87)
(* (/ 0.5 a) (- (sqrt (* a (* -4.0 c))) b))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.9e-135) {
tmp = (c / b) - (b / a);
} else if (b <= 1.7e-87) {
tmp = (0.5 / a) * (sqrt((a * (-4.0 * c))) - b);
} else {
tmp = c / -b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-2.9d-135)) then
tmp = (c / b) - (b / a)
else if (b <= 1.7d-87) then
tmp = (0.5d0 / a) * (sqrt((a * ((-4.0d0) * c))) - b)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.9e-135) {
tmp = (c / b) - (b / a);
} else if (b <= 1.7e-87) {
tmp = (0.5 / a) * (Math.sqrt((a * (-4.0 * c))) - b);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.9e-135: tmp = (c / b) - (b / a) elif b <= 1.7e-87: tmp = (0.5 / a) * (math.sqrt((a * (-4.0 * c))) - b) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.9e-135) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.7e-87) tmp = Float64(Float64(0.5 / a) * Float64(sqrt(Float64(a * Float64(-4.0 * c))) - b)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.9e-135) tmp = (c / b) - (b / a); elseif (b <= 1.7e-87) tmp = (0.5 / a) * (sqrt((a * (-4.0 * c))) - b); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.9e-135], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.7e-87], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(a * N[(-4.0 * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.9 \cdot 10^{-135}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.7 \cdot 10^{-87}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{a \cdot \left(-4 \cdot c\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -2.9000000000000002e-135Initial program 74.6%
*-commutative74.6%
Simplified74.7%
Taylor expanded in b around -inf 77.6%
mul-1-neg77.6%
distribute-rgt-neg-in77.6%
+-commutative77.6%
mul-1-neg77.6%
unsub-neg77.6%
Simplified77.6%
Taylor expanded in a around inf 77.8%
+-commutative77.8%
mul-1-neg77.8%
unsub-neg77.8%
Simplified77.8%
if -2.9000000000000002e-135 < b < 1.6999999999999999e-87Initial program 85.6%
*-commutative85.6%
Simplified85.6%
Taylor expanded in a around inf 85.5%
associate-*r*85.5%
*-commutative85.5%
Simplified85.5%
add-sqr-sqrt85.0%
pow285.0%
pow1/285.0%
sqrt-pow185.1%
associate-*l*85.1%
*-commutative85.1%
metadata-eval85.1%
Applied egg-rr85.1%
pow-pow85.5%
metadata-eval85.5%
pow1/285.5%
div-sub85.5%
sub-neg85.5%
div-inv85.4%
metadata-eval85.4%
div-inv85.4%
clear-num85.4%
div-inv85.4%
metadata-eval85.4%
div-inv85.4%
clear-num85.4%
Applied egg-rr85.4%
sub-neg85.4%
distribute-rgt-out--85.4%
Simplified85.4%
if 1.6999999999999999e-87 < b Initial program 14.6%
*-commutative14.6%
Simplified14.7%
Taylor expanded in a around 0 89.9%
associate-*r/89.9%
mul-1-neg89.9%
Simplified89.9%
Final simplification84.5%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (- (/ c b) (/ b a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-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 <= (-5d-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 <= -5e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (c / b) - (b / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-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 <= -5e-310) tmp = (c / b) - (b / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-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 -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 76.6%
*-commutative76.6%
Simplified76.6%
Taylor expanded in b around -inf 59.2%
mul-1-neg59.2%
distribute-rgt-neg-in59.2%
+-commutative59.2%
mul-1-neg59.2%
unsub-neg59.2%
Simplified59.2%
Taylor expanded in a around inf 59.6%
+-commutative59.6%
mul-1-neg59.6%
unsub-neg59.6%
Simplified59.6%
if -4.999999999999985e-310 < b Initial program 33.2%
*-commutative33.2%
Simplified33.2%
Taylor expanded in a around 0 69.9%
associate-*r/69.9%
mul-1-neg69.9%
Simplified69.9%
Final simplification65.0%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-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 <= (-5d-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 <= -5e-310) {
tmp = b / -a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b / -a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) 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 <= -5e-310) tmp = b / -a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 76.6%
*-commutative76.6%
Simplified76.6%
Taylor expanded in b around -inf 59.4%
associate-*r/59.4%
mul-1-neg59.4%
Simplified59.4%
if -4.999999999999985e-310 < b Initial program 33.2%
*-commutative33.2%
Simplified33.2%
Taylor expanded in a around 0 69.9%
associate-*r/69.9%
mul-1-neg69.9%
Simplified69.9%
Final simplification64.9%
(FPCore (a b c) :precision binary64 (if (<= b 3.4e-11) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.4e-11) {
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 <= 3.4d-11) 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 <= 3.4e-11) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.4e-11: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.4e-11) 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 <= 3.4e-11) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.4e-11], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.4 \cdot 10^{-11}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 3.3999999999999999e-11Initial program 75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in b around -inf 44.3%
associate-*r/44.3%
mul-1-neg44.3%
Simplified44.3%
if 3.3999999999999999e-11 < b Initial program 13.7%
*-commutative13.7%
Simplified13.7%
add-cbrt-cube13.6%
pow313.7%
Applied egg-rr5.5%
Taylor expanded in b around -inf 32.1%
Final simplification40.0%
(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 53.7%
*-commutative53.7%
Simplified53.7%
add-cbrt-cube34.0%
pow334.0%
Applied egg-rr21.7%
Taylor expanded in b around -inf 13.5%
(FPCore (a b c) :precision binary64 (/ b a))
double code(double a, double b, double c) {
return b / a;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = b / a
end function
public static double code(double a, double b, double c) {
return b / a;
}
def code(a, b, c): return b / a
function code(a, b, c) return Float64(b / a) end
function tmp = code(a, b, c) tmp = b / a; end
code[a_, b_, c_] := N[(b / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{a}
\end{array}
Initial program 53.7%
*-commutative53.7%
Simplified53.7%
add-cbrt-cube34.0%
pow334.0%
Applied egg-rr21.7%
Taylor expanded in b around inf 2.6%
herbie shell --seed 2024182
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))