
(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 -4e+153)
(- (/ c b) (/ b a))
(if (<= b 2e-25)
(/ (- (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 <= -4e+153) {
tmp = (c / b) - (b / a);
} else if (b <= 2e-25) {
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 <= (-4d+153)) then
tmp = (c / b) - (b / a)
else if (b <= 2d-25) 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 <= -4e+153) {
tmp = (c / b) - (b / a);
} else if (b <= 2e-25) {
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 <= -4e+153: tmp = (c / b) - (b / a) elif b <= 2e-25: 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 <= -4e+153) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 2e-25) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4e+153) tmp = (c / b) - (b / a); elseif (b <= 2e-25) 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, -4e+153], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e-25], 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 -4 \cdot 10^{+153}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-25}:\\
\;\;\;\;\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 < -4e153Initial program 41.1%
*-commutative41.1%
Simplified41.1%
Taylor expanded in b around -inf 92.4%
+-commutative92.4%
mul-1-neg92.4%
unsub-neg92.4%
Simplified92.4%
if -4e153 < b < 2.00000000000000008e-25Initial program 78.5%
if 2.00000000000000008e-25 < b Initial program 19.0%
*-commutative19.0%
Simplified19.0%
Taylor expanded in b around inf 88.9%
mul-1-neg88.9%
distribute-neg-frac88.9%
Simplified88.9%
Final simplification84.4%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (* a (* c -4.0)))))
(if (<= b -1.65e-97)
(- (/ c b) (/ b a))
(if (<= b 5e-110)
(/ (- t_0 b) (* a 2.0))
(if (or (<= b 2.3e-63) (not (<= b 2.2e-25)))
(/ (- c) b)
(* 0.5 (/ t_0 a)))))))
double code(double a, double b, double c) {
double t_0 = sqrt((a * (c * -4.0)));
double tmp;
if (b <= -1.65e-97) {
tmp = (c / b) - (b / a);
} else if (b <= 5e-110) {
tmp = (t_0 - b) / (a * 2.0);
} else if ((b <= 2.3e-63) || !(b <= 2.2e-25)) {
tmp = -c / b;
} else {
tmp = 0.5 * (t_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((a * (c * (-4.0d0))))
if (b <= (-1.65d-97)) then
tmp = (c / b) - (b / a)
else if (b <= 5d-110) then
tmp = (t_0 - b) / (a * 2.0d0)
else if ((b <= 2.3d-63) .or. (.not. (b <= 2.2d-25))) then
tmp = -c / b
else
tmp = 0.5d0 * (t_0 / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt((a * (c * -4.0)));
double tmp;
if (b <= -1.65e-97) {
tmp = (c / b) - (b / a);
} else if (b <= 5e-110) {
tmp = (t_0 - b) / (a * 2.0);
} else if ((b <= 2.3e-63) || !(b <= 2.2e-25)) {
tmp = -c / b;
} else {
tmp = 0.5 * (t_0 / a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt((a * (c * -4.0))) tmp = 0 if b <= -1.65e-97: tmp = (c / b) - (b / a) elif b <= 5e-110: tmp = (t_0 - b) / (a * 2.0) elif (b <= 2.3e-63) or not (b <= 2.2e-25): tmp = -c / b else: tmp = 0.5 * (t_0 / a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(a * Float64(c * -4.0))) tmp = 0.0 if (b <= -1.65e-97) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 5e-110) tmp = Float64(Float64(t_0 - b) / Float64(a * 2.0)); elseif ((b <= 2.3e-63) || !(b <= 2.2e-25)) tmp = Float64(Float64(-c) / b); else tmp = Float64(0.5 * Float64(t_0 / a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt((a * (c * -4.0))); tmp = 0.0; if (b <= -1.65e-97) tmp = (c / b) - (b / a); elseif (b <= 5e-110) tmp = (t_0 - b) / (a * 2.0); elseif ((b <= 2.3e-63) || ~((b <= 2.2e-25))) tmp = -c / b; else tmp = 0.5 * (t_0 / a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -1.65e-97], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5e-110], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[b, 2.3e-63], N[Not[LessEqual[b, 2.2e-25]], $MachinePrecision]], N[((-c) / b), $MachinePrecision], N[(0.5 * N[(t$95$0 / a), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{a \cdot \left(c \cdot -4\right)}\\
\mathbf{if}\;b \leq -1.65 \cdot 10^{-97}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 5 \cdot 10^{-110}:\\
\;\;\;\;\frac{t_0 - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{-63} \lor \neg \left(b \leq 2.2 \cdot 10^{-25}\right):\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{t_0}{a}\\
\end{array}
\end{array}
if b < -1.6500000000000001e-97Initial program 64.5%
*-commutative64.5%
Simplified64.5%
Taylor expanded in b around -inf 86.4%
+-commutative86.4%
mul-1-neg86.4%
unsub-neg86.4%
Simplified86.4%
if -1.6500000000000001e-97 < b < 5e-110Initial program 78.6%
*-commutative78.6%
Simplified78.6%
prod-diff78.3%
*-commutative78.3%
fma-def78.3%
associate-+l+78.3%
pow278.3%
distribute-lft-neg-in78.3%
*-commutative78.3%
distribute-rgt-neg-in78.3%
metadata-eval78.3%
associate-*r*78.3%
*-commutative78.3%
*-commutative78.3%
fma-udef78.3%
Applied egg-rr78.3%
fma-def78.3%
fma-def78.4%
associate-*l*78.4%
Simplified78.4%
Taylor expanded in b around 0 74.4%
mul-1-neg74.4%
unsub-neg74.4%
distribute-rgt-out74.6%
metadata-eval74.6%
associate-*r*74.6%
*-commutative74.6%
Simplified74.6%
if 5e-110 < b < 2.3e-63 or 2.2000000000000002e-25 < b Initial program 20.1%
*-commutative20.1%
Simplified20.1%
Taylor expanded in b around inf 85.3%
mul-1-neg85.3%
distribute-neg-frac85.3%
Simplified85.3%
if 2.3e-63 < b < 2.2000000000000002e-25Initial program 88.5%
*-commutative88.5%
Simplified88.5%
prod-diff88.5%
*-commutative88.5%
fma-def88.5%
associate-+l+88.5%
pow288.5%
distribute-lft-neg-in88.5%
*-commutative88.5%
distribute-rgt-neg-in88.5%
metadata-eval88.5%
associate-*r*88.5%
*-commutative88.5%
*-commutative88.5%
fma-udef88.5%
Applied egg-rr88.5%
fma-def88.5%
fma-def88.3%
associate-*l*88.3%
Simplified88.3%
Taylor expanded in b around 0 88.3%
associate-*l/88.5%
*-lft-identity88.5%
distribute-rgt-out88.5%
metadata-eval88.5%
associate-*r*88.5%
*-commutative88.5%
Simplified88.5%
Final simplification83.2%
(FPCore (a b c) :precision binary64 (if (<= b -8.6e-98) (- (/ c b) (/ b a)) (if (<= b 2.1e-25) (* 0.5 (/ (sqrt (* a (* c -4.0))) a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8.6e-98) {
tmp = (c / b) - (b / a);
} else if (b <= 2.1e-25) {
tmp = 0.5 * (sqrt((a * (c * -4.0))) / 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 <= (-8.6d-98)) then
tmp = (c / b) - (b / a)
else if (b <= 2.1d-25) then
tmp = 0.5d0 * (sqrt((a * (c * (-4.0d0)))) / 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 <= -8.6e-98) {
tmp = (c / b) - (b / a);
} else if (b <= 2.1e-25) {
tmp = 0.5 * (Math.sqrt((a * (c * -4.0))) / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.6e-98: tmp = (c / b) - (b / a) elif b <= 2.1e-25: tmp = 0.5 * (math.sqrt((a * (c * -4.0))) / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8.6e-98) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 2.1e-25) tmp = Float64(0.5 * Float64(sqrt(Float64(a * Float64(c * -4.0))) / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -8.6e-98) tmp = (c / b) - (b / a); elseif (b <= 2.1e-25) tmp = 0.5 * (sqrt((a * (c * -4.0))) / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.6e-98], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.1e-25], N[(0.5 * N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.6 \cdot 10^{-98}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 2.1 \cdot 10^{-25}:\\
\;\;\;\;0.5 \cdot \frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -8.59999999999999977e-98Initial program 64.5%
*-commutative64.5%
Simplified64.5%
Taylor expanded in b around -inf 86.4%
+-commutative86.4%
mul-1-neg86.4%
unsub-neg86.4%
Simplified86.4%
if -8.59999999999999977e-98 < b < 2.10000000000000002e-25Initial program 72.3%
*-commutative72.3%
Simplified72.3%
prod-diff72.0%
*-commutative72.0%
fma-def72.0%
associate-+l+72.0%
pow272.0%
distribute-lft-neg-in72.0%
*-commutative72.0%
distribute-rgt-neg-in72.0%
metadata-eval72.0%
associate-*r*72.0%
*-commutative72.0%
*-commutative72.0%
fma-udef72.0%
Applied egg-rr72.0%
fma-def72.0%
fma-def72.0%
associate-*l*72.0%
Simplified72.0%
Taylor expanded in b around 0 67.7%
associate-*l/67.8%
*-lft-identity67.8%
distribute-rgt-out68.0%
metadata-eval68.0%
associate-*r*68.0%
*-commutative68.0%
Simplified68.0%
if 2.10000000000000002e-25 < b Initial program 19.0%
*-commutative19.0%
Simplified19.0%
Taylor expanded in b around inf 88.9%
mul-1-neg88.9%
distribute-neg-frac88.9%
Simplified88.9%
Final simplification81.3%
(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(Float64(-c) / 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 68.7%
*-commutative68.7%
Simplified68.7%
Taylor expanded in b around -inf 69.6%
+-commutative69.6%
mul-1-neg69.6%
unsub-neg69.6%
Simplified69.6%
if -4.999999999999985e-310 < b Initial program 37.2%
*-commutative37.2%
Simplified37.2%
Taylor expanded in b around inf 64.3%
mul-1-neg64.3%
distribute-neg-frac64.3%
Simplified64.3%
Final simplification66.8%
(FPCore (a b c) :precision binary64 (if (<= b 1.1e+22) (/ (- b) a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.1e+22) {
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.1d+22) 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.1e+22) {
tmp = -b / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.1e+22: tmp = -b / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.1e+22) 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 <= 1.1e+22) tmp = -b / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.1e+22], N[((-b) / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.1 \cdot 10^{+22}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.1e22Initial program 65.3%
*-commutative65.3%
Simplified65.3%
Taylor expanded in b around -inf 46.2%
associate-*r/46.2%
mul-1-neg46.2%
Simplified46.2%
if 1.1e22 < b Initial program 17.7%
*-commutative17.7%
Simplified17.7%
Taylor expanded in b around -inf 2.7%
+-commutative2.7%
mul-1-neg2.7%
unsub-neg2.7%
Simplified2.7%
Taylor expanded in c around inf 30.8%
Final simplification41.9%
(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(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 <= -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 68.7%
*-commutative68.7%
Simplified68.7%
Taylor expanded in b around -inf 69.2%
associate-*r/69.2%
mul-1-neg69.2%
Simplified69.2%
if -4.999999999999985e-310 < b Initial program 37.2%
*-commutative37.2%
Simplified37.2%
Taylor expanded in b around inf 64.3%
mul-1-neg64.3%
distribute-neg-frac64.3%
Simplified64.3%
Final simplification66.6%
(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 52.1%
Simplified52.1%
*-un-lft-identity52.1%
*-un-lft-identity52.1%
prod-diff52.1%
*-commutative52.1%
*-un-lft-identity52.1%
fma-def52.1%
*-un-lft-identity52.1%
+-commutative52.1%
add-sqr-sqrt32.4%
sqrt-unprod49.5%
sqr-neg49.5%
sqrt-prod17.2%
add-sqr-sqrt35.8%
pow235.8%
add-sqr-sqrt18.7%
sqrt-unprod35.8%
sqr-neg35.8%
sqrt-prod17.2%
add-sqr-sqrt35.6%
*-commutative35.6%
*-un-lft-identity35.6%
Applied egg-rr35.6%
associate-+l+35.6%
fma-udef35.6%
*-rgt-identity35.6%
Simplified35.6%
Taylor expanded in b around -inf 2.6%
Final simplification2.6%
(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.1%
*-commutative52.1%
Simplified52.1%
Taylor expanded in b around -inf 34.1%
+-commutative34.1%
mul-1-neg34.1%
unsub-neg34.1%
Simplified34.1%
Taylor expanded in c around inf 10.7%
Final simplification10.7%
herbie shell --seed 2023338
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))