
(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 9 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 -2e+141)
(- (/ b a))
(if (<= b 5.6e-105)
(/ (- (sqrt (fma a (* c -4.0) (* b b))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e+141) {
tmp = -(b / a);
} else if (b <= 5.6e-105) {
tmp = (sqrt(fma(a, (c * -4.0), (b * b))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2e+141) tmp = Float64(-Float64(b / a)); elseif (b <= 5.6e-105) tmp = Float64(Float64(sqrt(fma(a, Float64(c * -4.0), 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, -2e+141], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 5.6e-105], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $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 -2 \cdot 10^{+141}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-105}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -2.00000000000000003e141Initial program 42.0%
*-commutative42.0%
Simplified42.0%
Taylor expanded in b around -inf 92.4%
associate-*r/92.4%
mul-1-neg92.4%
Simplified92.4%
if -2.00000000000000003e141 < b < 5.6e-105Initial program 84.8%
*-commutative84.8%
Simplified84.8%
if 5.6e-105 < b Initial program 17.3%
*-commutative17.3%
Simplified17.4%
Taylor expanded in a around 0 90.2%
associate-*r/90.2%
mul-1-neg90.2%
Simplified90.2%
Final simplification88.2%
(FPCore (a b c)
:precision binary64
(if (<= b -2.8e+139)
(- (/ b a))
(if (<= b 4.4e-108)
(/ (- (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 <= -2.8e+139) {
tmp = -(b / a);
} else if (b <= 4.4e-108) {
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 <= (-2.8d+139)) then
tmp = -(b / a)
else if (b <= 4.4d-108) 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 <= -2.8e+139) {
tmp = -(b / a);
} else if (b <= 4.4e-108) {
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 <= -2.8e+139: tmp = -(b / a) elif b <= 4.4e-108: 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 <= -2.8e+139) tmp = Float64(-Float64(b / a)); elseif (b <= 4.4e-108) 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 <= -2.8e+139) tmp = -(b / a); elseif (b <= 4.4e-108) 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, -2.8e+139], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 4.4e-108], 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 -2.8 \cdot 10^{+139}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{-108}:\\
\;\;\;\;\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 < -2.7999999999999998e139Initial program 42.0%
*-commutative42.0%
Simplified42.0%
Taylor expanded in b around -inf 92.4%
associate-*r/92.4%
mul-1-neg92.4%
Simplified92.4%
if -2.7999999999999998e139 < b < 4.4000000000000002e-108Initial program 84.8%
if 4.4000000000000002e-108 < b Initial program 17.3%
*-commutative17.3%
Simplified17.4%
Taylor expanded in a around 0 90.2%
associate-*r/90.2%
mul-1-neg90.2%
Simplified90.2%
Final simplification88.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.15e-57)
(- (/ c b) (/ b a))
(if (<= b 1.85e-110)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e-57) {
tmp = (c / b) - (b / a);
} else if (b <= 1.85e-110) {
tmp = (sqrt((a * (c * -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 <= (-1.15d-57)) then
tmp = (c / b) - (b / a)
else if (b <= 1.85d-110) then
tmp = (sqrt((a * (c * (-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 <= -1.15e-57) {
tmp = (c / b) - (b / a);
} else if (b <= 1.85e-110) {
tmp = (Math.sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.15e-57: tmp = (c / b) - (b / a) elif b <= 1.85e-110: tmp = (math.sqrt((a * (c * -4.0))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.15e-57) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.85e-110) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -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 <= -1.15e-57) tmp = (c / b) - (b / a); elseif (b <= 1.85e-110) tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.15e-57], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.85e-110], N[(N[(N[Sqrt[N[(a * N[(c * -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 -1.15 \cdot 10^{-57}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.85 \cdot 10^{-110}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.15e-57Initial program 71.8%
*-commutative71.8%
Simplified71.8%
Taylor expanded in b around -inf 90.7%
mul-1-neg90.7%
*-commutative90.7%
distribute-rgt-neg-in90.7%
+-commutative90.7%
mul-1-neg90.7%
unsub-neg90.7%
Simplified90.7%
Taylor expanded in a around inf 90.9%
neg-mul-190.9%
+-commutative90.9%
unsub-neg90.9%
Simplified90.9%
if -1.15e-57 < b < 1.85000000000000008e-110Initial program 77.0%
*-commutative77.0%
Simplified77.0%
Taylor expanded in a around inf 73.1%
*-commutative73.1%
associate-*r*73.1%
Simplified73.1%
if 1.85000000000000008e-110 < b Initial program 17.3%
*-commutative17.3%
Simplified17.4%
Taylor expanded in a around 0 90.2%
associate-*r/90.2%
mul-1-neg90.2%
Simplified90.2%
Final simplification86.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.06e-57)
(- (/ c b) (/ b a))
(if (<= b 2.65e-111)
(* (/ 0.5 a) (- (sqrt (* -4.0 (* a c))) b))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.06e-57) {
tmp = (c / b) - (b / a);
} else if (b <= 2.65e-111) {
tmp = (0.5 / a) * (sqrt((-4.0 * (a * 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 <= (-1.06d-57)) then
tmp = (c / b) - (b / a)
else if (b <= 2.65d-111) then
tmp = (0.5d0 / a) * (sqrt(((-4.0d0) * (a * 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 <= -1.06e-57) {
tmp = (c / b) - (b / a);
} else if (b <= 2.65e-111) {
tmp = (0.5 / a) * (Math.sqrt((-4.0 * (a * c))) - b);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.06e-57: tmp = (c / b) - (b / a) elif b <= 2.65e-111: tmp = (0.5 / a) * (math.sqrt((-4.0 * (a * c))) - b) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.06e-57) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 2.65e-111) tmp = Float64(Float64(0.5 / a) * Float64(sqrt(Float64(-4.0 * Float64(a * c))) - b)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.06e-57) tmp = (c / b) - (b / a); elseif (b <= 2.65e-111) tmp = (0.5 / a) * (sqrt((-4.0 * (a * c))) - b); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.06e-57], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.65e-111], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(-4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.06 \cdot 10^{-57}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 2.65 \cdot 10^{-111}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{-4 \cdot \left(a \cdot c\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.0600000000000001e-57Initial program 71.8%
*-commutative71.8%
Simplified71.8%
Taylor expanded in b around -inf 90.7%
mul-1-neg90.7%
*-commutative90.7%
distribute-rgt-neg-in90.7%
+-commutative90.7%
mul-1-neg90.7%
unsub-neg90.7%
Simplified90.7%
Taylor expanded in a around inf 90.9%
neg-mul-190.9%
+-commutative90.9%
unsub-neg90.9%
Simplified90.9%
if -1.0600000000000001e-57 < b < 2.6499999999999999e-111Initial program 77.0%
*-commutative77.0%
Simplified77.0%
div-sub77.0%
sub-neg77.0%
div-inv76.8%
pow276.8%
*-commutative76.8%
associate-/r*76.8%
metadata-eval76.8%
div-inv76.8%
*-commutative76.8%
associate-/r*76.8%
metadata-eval76.8%
Applied egg-rr76.8%
sub-neg76.8%
distribute-rgt-out--76.8%
Simplified76.8%
Taylor expanded in a around inf 72.9%
*-commutative72.9%
Simplified72.9%
if 2.6499999999999999e-111 < b Initial program 17.3%
*-commutative17.3%
Simplified17.4%
Taylor expanded in a around 0 90.2%
associate-*r/90.2%
mul-1-neg90.2%
Simplified90.2%
Final simplification86.2%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (- (/ c b) (/ b a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-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 <= (-4d-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 <= -4e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = (c / b) - (b / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-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 <= -4e-310) tmp = (c / b) - (b / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-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 -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 74.6%
*-commutative74.6%
Simplified74.6%
Taylor expanded in b around -inf 64.9%
mul-1-neg64.9%
*-commutative64.9%
distribute-rgt-neg-in64.9%
+-commutative64.9%
mul-1-neg64.9%
unsub-neg64.9%
Simplified64.9%
Taylor expanded in a around inf 66.0%
neg-mul-166.0%
+-commutative66.0%
unsub-neg66.0%
Simplified66.0%
if -3.999999999999988e-310 < b Initial program 26.9%
*-commutative26.9%
Simplified26.9%
Taylor expanded in a around 0 75.0%
associate-*r/75.0%
mul-1-neg75.0%
Simplified75.0%
Final simplification70.8%
(FPCore (a b c) :precision binary64 (if (<= b 7.9e-249) (- (/ b a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 7.9e-249) {
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 <= 7.9d-249) 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 <= 7.9e-249) {
tmp = -(b / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7.9e-249: tmp = -(b / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7.9e-249) tmp = Float64(-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 <= 7.9e-249) tmp = -(b / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7.9e-249], (-N[(b / a), $MachinePrecision]), N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.9 \cdot 10^{-249}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < 7.89999999999999962e-249Initial program 74.8%
*-commutative74.8%
Simplified74.8%
Taylor expanded in b around -inf 62.9%
associate-*r/62.9%
mul-1-neg62.9%
Simplified62.9%
if 7.89999999999999962e-249 < b Initial program 24.8%
*-commutative24.8%
Simplified24.9%
Taylor expanded in a around 0 77.7%
associate-*r/77.7%
mul-1-neg77.7%
Simplified77.7%
Final simplification70.5%
(FPCore (a b c) :precision binary64 (if (<= b 2000000.0) (- (/ b a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2000000.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 <= 2000000.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 <= 2000000.0) {
tmp = -(b / a);
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2000000.0: tmp = -(b / a) else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2000000.0) tmp = Float64(-Float64(b / a)); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2000000.0) tmp = -(b / a); else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2000000.0], (-N[(b / a), $MachinePrecision]), N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2000000:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 2e6Initial program 67.1%
*-commutative67.1%
Simplified67.1%
Taylor expanded in b around -inf 47.5%
associate-*r/47.5%
mul-1-neg47.5%
Simplified47.5%
if 2e6 < b Initial program 14.6%
*-commutative14.6%
Simplified14.6%
Applied egg-rr5.4%
unpow-15.4%
associate-/l*5.3%
Simplified5.3%
Taylor expanded in b around -inf 32.6%
Final simplification42.4%
(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 49.2%
*-commutative49.2%
Simplified49.3%
Applied egg-rr28.2%
unpow-128.2%
associate-/l*28.2%
Simplified28.2%
Taylor expanded in b around -inf 13.2%
(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 49.2%
*-commutative49.2%
Simplified49.3%
Applied egg-rr28.2%
unpow-128.2%
associate-/l*28.2%
Simplified28.2%
Taylor expanded in a around 0 2.3%
herbie shell --seed 2024145
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))