
(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+143)
(- (/ b a))
(if (<= b 1.75e-59)
(/ (- (sqrt (- (* b b) (* (* a 4.0) c))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3e+143) {
tmp = -(b / a);
} else if (b <= 1.75e-59) {
tmp = (sqrt(((b * b) - ((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+143)) then
tmp = -(b / a)
else if (b <= 1.75d-59) then
tmp = (sqrt(((b * b) - ((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+143) {
tmp = -(b / a);
} else if (b <= 1.75e-59) {
tmp = (Math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3e+143: tmp = -(b / a) elif b <= 1.75e-59: tmp = (math.sqrt(((b * b) - ((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+143) tmp = Float64(-Float64(b / a)); elseif (b <= 1.75e-59) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - 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 <= -3e+143) tmp = -(b / a); elseif (b <= 1.75e-59) tmp = (sqrt(((b * b) - ((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+143], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 1.75e-59], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * c), $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^{+143}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 1.75 \cdot 10^{-59}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -3.0000000000000001e143Initial program 48.7%
*-commutative48.7%
Simplified48.7%
Taylor expanded in b around -inf 95.0%
associate-*r/95.0%
mul-1-neg95.0%
Simplified95.0%
if -3.0000000000000001e143 < b < 1.75e-59Initial program 85.6%
if 1.75e-59 < b Initial program 20.1%
*-commutative20.1%
Simplified20.1%
Taylor expanded in b around inf 83.0%
mul-1-neg83.0%
distribute-neg-frac83.0%
Simplified83.0%
Final simplification86.0%
(FPCore (a b c)
:precision binary64
(if (<= b -2.2e-58)
(- (/ c b) (/ b a))
(if (<= b 5.6e-62)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.2e-58) {
tmp = (c / b) - (b / a);
} else if (b <= 5.6e-62) {
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 <= (-2.2d-58)) then
tmp = (c / b) - (b / a)
else if (b <= 5.6d-62) 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 <= -2.2e-58) {
tmp = (c / b) - (b / a);
} else if (b <= 5.6e-62) {
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 <= -2.2e-58: tmp = (c / b) - (b / a) elif b <= 5.6e-62: 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 <= -2.2e-58) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 5.6e-62) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -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 <= -2.2e-58) tmp = (c / b) - (b / a); elseif (b <= 5.6e-62) 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, -2.2e-58], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.6e-62], 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 -2.2 \cdot 10^{-58}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 5.6 \cdot 10^{-62}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.20000000000000006e-58Initial program 73.7%
*-commutative73.7%
Simplified73.7%
Taylor expanded in b around -inf 86.1%
+-commutative86.1%
mul-1-neg86.1%
unsub-neg86.1%
Simplified86.1%
if -2.20000000000000006e-58 < b < 5.60000000000000005e-62Initial program 80.9%
*-commutative80.9%
Simplified80.9%
prod-diff80.7%
*-commutative80.7%
fma-def80.7%
associate-+l+80.7%
pow280.7%
distribute-lft-neg-in80.7%
*-commutative80.7%
distribute-rgt-neg-in80.7%
metadata-eval80.7%
associate-*r*80.7%
*-commutative80.7%
*-commutative80.7%
fma-udef80.7%
Applied egg-rr80.7%
fma-def80.7%
fma-def80.6%
associate-*l*80.6%
Simplified80.6%
Taylor expanded in b around 0 72.1%
neg-mul-172.1%
unsub-neg72.1%
distribute-rgt-out72.3%
metadata-eval72.3%
associate-*r*72.3%
*-commutative72.3%
Simplified72.3%
if 5.60000000000000005e-62 < b Initial program 20.1%
*-commutative20.1%
Simplified20.1%
Taylor expanded in b around inf 83.0%
mul-1-neg83.0%
distribute-neg-frac83.0%
Simplified83.0%
Final simplification81.2%
(FPCore (a b c) :precision binary64 (if (<= b -2.6e-141) (- (/ c b) (/ b a)) (if (<= b 1.8e-101) (* 0.5 (/ 1.0 (sqrt (* (/ a c) -0.25)))) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.6e-141) {
tmp = (c / b) - (b / a);
} else if (b <= 1.8e-101) {
tmp = 0.5 * (1.0 / sqrt(((a / c) * -0.25)));
} 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.6d-141)) then
tmp = (c / b) - (b / a)
else if (b <= 1.8d-101) then
tmp = 0.5d0 * (1.0d0 / sqrt(((a / c) * (-0.25d0))))
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.6e-141) {
tmp = (c / b) - (b / a);
} else if (b <= 1.8e-101) {
tmp = 0.5 * (1.0 / Math.sqrt(((a / c) * -0.25)));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.6e-141: tmp = (c / b) - (b / a) elif b <= 1.8e-101: tmp = 0.5 * (1.0 / math.sqrt(((a / c) * -0.25))) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.6e-141) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.8e-101) tmp = Float64(0.5 * Float64(1.0 / sqrt(Float64(Float64(a / c) * -0.25)))); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.6e-141) tmp = (c / b) - (b / a); elseif (b <= 1.8e-101) tmp = 0.5 * (1.0 / sqrt(((a / c) * -0.25))); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.6e-141], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e-101], N[(0.5 * N[(1.0 / N[Sqrt[N[(N[(a / c), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.6 \cdot 10^{-141}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-101}:\\
\;\;\;\;0.5 \cdot \frac{1}{\sqrt{\frac{a}{c} \cdot -0.25}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.60000000000000011e-141Initial program 77.2%
*-commutative77.2%
Simplified77.2%
Taylor expanded in b around -inf 78.5%
+-commutative78.5%
mul-1-neg78.5%
unsub-neg78.5%
Simplified78.5%
if -2.60000000000000011e-141 < b < 1.8e-101Initial program 75.7%
*-commutative75.7%
Simplified75.7%
prod-diff75.4%
*-commutative75.4%
fma-def75.4%
associate-+l+75.4%
pow275.4%
distribute-lft-neg-in75.4%
*-commutative75.4%
distribute-rgt-neg-in75.4%
metadata-eval75.4%
associate-*r*75.4%
*-commutative75.4%
*-commutative75.4%
fma-udef75.4%
Applied egg-rr75.4%
fma-def75.4%
fma-def75.3%
associate-*l*75.3%
Simplified75.3%
Taylor expanded in b around 0 75.1%
associate-*l/75.3%
*-lft-identity75.3%
distribute-rgt-out75.5%
metadata-eval75.5%
associate-*r*75.6%
*-commutative75.6%
Simplified75.6%
add-sqr-sqrt41.6%
sqrt-unprod28.6%
frac-times21.8%
add-sqr-sqrt21.7%
pow221.7%
Applied egg-rr21.7%
unpow221.7%
times-frac33.8%
*-inverses33.8%
*-commutative33.8%
Simplified33.8%
*-un-lft-identity33.8%
clear-num33.8%
sqrt-div33.8%
metadata-eval33.8%
*-un-lft-identity33.8%
*-commutative33.8%
times-frac33.8%
metadata-eval33.8%
Applied egg-rr33.8%
*-commutative33.8%
Simplified33.8%
if 1.8e-101 < b Initial program 23.0%
*-commutative23.0%
Simplified23.0%
Taylor expanded in b around inf 80.2%
mul-1-neg80.2%
distribute-neg-frac80.2%
Simplified80.2%
Final simplification71.2%
(FPCore (a b c) :precision binary64 (if (<= b -2.9e-58) (- (/ c b) (/ b a)) (if (<= b 4.1e-60) (* 0.5 (/ (sqrt (* a (* c -4.0))) a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.9e-58) {
tmp = (c / b) - (b / a);
} else if (b <= 4.1e-60) {
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 <= (-2.9d-58)) then
tmp = (c / b) - (b / a)
else if (b <= 4.1d-60) 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 <= -2.9e-58) {
tmp = (c / b) - (b / a);
} else if (b <= 4.1e-60) {
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 <= -2.9e-58: tmp = (c / b) - (b / a) elif b <= 4.1e-60: 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 <= -2.9e-58) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 4.1e-60) 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 <= -2.9e-58) tmp = (c / b) - (b / a); elseif (b <= 4.1e-60) 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, -2.9e-58], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.1e-60], 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 -2.9 \cdot 10^{-58}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 4.1 \cdot 10^{-60}:\\
\;\;\;\;0.5 \cdot \frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.8999999999999999e-58Initial program 73.7%
*-commutative73.7%
Simplified73.7%
Taylor expanded in b around -inf 86.1%
+-commutative86.1%
mul-1-neg86.1%
unsub-neg86.1%
Simplified86.1%
if -2.8999999999999999e-58 < b < 4.10000000000000013e-60Initial program 80.9%
*-commutative80.9%
Simplified80.9%
prod-diff80.7%
*-commutative80.7%
fma-def80.7%
associate-+l+80.7%
pow280.7%
distribute-lft-neg-in80.7%
*-commutative80.7%
distribute-rgt-neg-in80.7%
metadata-eval80.7%
associate-*r*80.7%
*-commutative80.7%
*-commutative80.7%
fma-udef80.7%
Applied egg-rr80.7%
fma-def80.7%
fma-def80.6%
associate-*l*80.6%
Simplified80.6%
Taylor expanded in b around 0 70.7%
associate-*l/70.9%
*-lft-identity70.9%
distribute-rgt-out71.1%
metadata-eval71.1%
associate-*r*71.1%
*-commutative71.1%
Simplified71.1%
if 4.10000000000000013e-60 < b Initial program 20.1%
*-commutative20.1%
Simplified20.1%
Taylor expanded in b around inf 83.0%
mul-1-neg83.0%
distribute-neg-frac83.0%
Simplified83.0%
Final simplification80.8%
(FPCore (a b c) :precision binary64 (if (<= b -6.8e-143) (- (/ c b) (/ b a)) (if (<= b 5.1e-104) (* 0.5 (sqrt (* c (/ -4.0 a)))) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.8e-143) {
tmp = (c / b) - (b / a);
} else if (b <= 5.1e-104) {
tmp = 0.5 * sqrt((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 <= (-6.8d-143)) then
tmp = (c / b) - (b / a)
else if (b <= 5.1d-104) then
tmp = 0.5d0 * sqrt((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 <= -6.8e-143) {
tmp = (c / b) - (b / a);
} else if (b <= 5.1e-104) {
tmp = 0.5 * Math.sqrt((c * (-4.0 / a)));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.8e-143: tmp = (c / b) - (b / a) elif b <= 5.1e-104: tmp = 0.5 * math.sqrt((c * (-4.0 / a))) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.8e-143) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 5.1e-104) tmp = Float64(0.5 * sqrt(Float64(c * Float64(-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 <= -6.8e-143) tmp = (c / b) - (b / a); elseif (b <= 5.1e-104) tmp = 0.5 * sqrt((c * (-4.0 / a))); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.8e-143], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.1e-104], N[(0.5 * N[Sqrt[N[(c * N[(-4.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.8 \cdot 10^{-143}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 5.1 \cdot 10^{-104}:\\
\;\;\;\;0.5 \cdot \sqrt{c \cdot \frac{-4}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -6.79999999999999966e-143Initial program 77.2%
*-commutative77.2%
Simplified77.2%
Taylor expanded in b around -inf 78.5%
+-commutative78.5%
mul-1-neg78.5%
unsub-neg78.5%
Simplified78.5%
if -6.79999999999999966e-143 < b < 5.09999999999999992e-104Initial program 75.7%
*-commutative75.7%
Simplified75.7%
prod-diff75.4%
*-commutative75.4%
fma-def75.4%
associate-+l+75.4%
pow275.4%
distribute-lft-neg-in75.4%
*-commutative75.4%
distribute-rgt-neg-in75.4%
metadata-eval75.4%
associate-*r*75.4%
*-commutative75.4%
*-commutative75.4%
fma-udef75.4%
Applied egg-rr75.4%
fma-def75.4%
fma-def75.3%
associate-*l*75.3%
Simplified75.3%
Taylor expanded in b around 0 75.1%
associate-*l/75.3%
*-lft-identity75.3%
distribute-rgt-out75.5%
metadata-eval75.5%
associate-*r*75.6%
*-commutative75.6%
Simplified75.6%
add-sqr-sqrt41.6%
sqrt-unprod28.6%
frac-times21.8%
add-sqr-sqrt21.7%
pow221.7%
Applied egg-rr21.7%
unpow221.7%
times-frac33.8%
*-inverses33.8%
*-commutative33.8%
Simplified33.8%
expm1-log1p-u33.2%
expm1-udef17.5%
*-un-lft-identity17.5%
*-un-lft-identity17.5%
times-frac17.5%
/-rgt-identity17.5%
Applied egg-rr17.5%
expm1-def33.1%
expm1-log1p33.7%
Simplified33.7%
if 5.09999999999999992e-104 < b Initial program 23.0%
*-commutative23.0%
Simplified23.0%
Taylor expanded in b around inf 80.2%
mul-1-neg80.2%
distribute-neg-frac80.2%
Simplified80.2%
Final simplification71.1%
(FPCore (a b c) :precision binary64 (if (<= b -3.1e-140) (- (/ c b) (/ b a)) (if (<= b 5e-104) (* 0.5 (sqrt (/ (* c -4.0) a))) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.1e-140) {
tmp = (c / b) - (b / a);
} else if (b <= 5e-104) {
tmp = 0.5 * sqrt(((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 <= (-3.1d-140)) then
tmp = (c / b) - (b / a)
else if (b <= 5d-104) then
tmp = 0.5d0 * sqrt(((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 <= -3.1e-140) {
tmp = (c / b) - (b / a);
} else if (b <= 5e-104) {
tmp = 0.5 * Math.sqrt(((c * -4.0) / a));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.1e-140: tmp = (c / b) - (b / a) elif b <= 5e-104: tmp = 0.5 * math.sqrt(((c * -4.0) / a)) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.1e-140) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 5e-104) tmp = Float64(0.5 * sqrt(Float64(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 <= -3.1e-140) tmp = (c / b) - (b / a); elseif (b <= 5e-104) tmp = 0.5 * sqrt(((c * -4.0) / a)); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.1e-140], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5e-104], N[(0.5 * N[Sqrt[N[(N[(c * -4.0), $MachinePrecision] / a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.1 \cdot 10^{-140}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 5 \cdot 10^{-104}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{c \cdot -4}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -3.0999999999999999e-140Initial program 77.2%
*-commutative77.2%
Simplified77.2%
Taylor expanded in b around -inf 78.5%
+-commutative78.5%
mul-1-neg78.5%
unsub-neg78.5%
Simplified78.5%
if -3.0999999999999999e-140 < b < 4.99999999999999979e-104Initial program 75.7%
*-commutative75.7%
Simplified75.7%
prod-diff75.4%
*-commutative75.4%
fma-def75.4%
associate-+l+75.4%
pow275.4%
distribute-lft-neg-in75.4%
*-commutative75.4%
distribute-rgt-neg-in75.4%
metadata-eval75.4%
associate-*r*75.4%
*-commutative75.4%
*-commutative75.4%
fma-udef75.4%
Applied egg-rr75.4%
fma-def75.4%
fma-def75.3%
associate-*l*75.3%
Simplified75.3%
Taylor expanded in b around 0 75.1%
associate-*l/75.3%
*-lft-identity75.3%
distribute-rgt-out75.5%
metadata-eval75.5%
associate-*r*75.6%
*-commutative75.6%
Simplified75.6%
add-sqr-sqrt41.6%
sqrt-unprod28.6%
frac-times21.8%
add-sqr-sqrt21.7%
pow221.7%
Applied egg-rr21.7%
unpow221.7%
times-frac33.8%
*-inverses33.8%
*-commutative33.8%
Simplified33.8%
if 4.99999999999999979e-104 < b Initial program 23.0%
*-commutative23.0%
Simplified23.0%
Taylor expanded in b around inf 80.2%
mul-1-neg80.2%
distribute-neg-frac80.2%
Simplified80.2%
Final simplification71.2%
(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 78.5%
*-commutative78.5%
Simplified78.5%
Taylor expanded in b around -inf 66.6%
+-commutative66.6%
mul-1-neg66.6%
unsub-neg66.6%
Simplified66.6%
if -4.999999999999985e-310 < b Initial program 32.0%
*-commutative32.0%
Simplified32.0%
Taylor expanded in b around inf 68.0%
mul-1-neg68.0%
distribute-neg-frac68.0%
Simplified68.0%
Final simplification67.3%
(FPCore (a b c) :precision binary64 (if (<= b -6.6e-301) (- (/ b a)) (/ 0.0 a)))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.6e-301) {
tmp = -(b / a);
} else {
tmp = 0.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) :: tmp
if (b <= (-6.6d-301)) then
tmp = -(b / a)
else
tmp = 0.0d0 / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -6.6e-301) {
tmp = -(b / a);
} else {
tmp = 0.0 / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.6e-301: tmp = -(b / a) else: tmp = 0.0 / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.6e-301) tmp = Float64(-Float64(b / a)); else tmp = Float64(0.0 / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -6.6e-301) tmp = -(b / a); else tmp = 0.0 / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.6e-301], (-N[(b / a), $MachinePrecision]), N[(0.0 / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -6.6 \cdot 10^{-301}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{a}\\
\end{array}
\end{array}
if b < -6.6000000000000001e-301Initial program 78.3%
*-commutative78.3%
Simplified78.3%
Taylor expanded in b around -inf 67.0%
associate-*r/67.0%
mul-1-neg67.0%
Simplified67.0%
if -6.6000000000000001e-301 < b Initial program 32.5%
*-commutative32.5%
Simplified32.5%
pow1/232.5%
sub-neg32.5%
+-commutative32.5%
distribute-lft-neg-in32.5%
*-commutative32.5%
distribute-rgt-neg-in32.5%
metadata-eval32.5%
associate-*r*32.5%
*-commutative32.5%
fma-udef32.5%
pow-to-exp25.3%
pow225.3%
Applied egg-rr25.3%
clear-num25.3%
inv-pow25.3%
neg-mul-125.3%
fma-def25.3%
exp-to-pow32.4%
pow1/232.4%
Applied egg-rr32.4%
unpow-132.4%
associate-/l*32.4%
*-commutative32.4%
Simplified32.4%
Taylor expanded in a around 0 23.8%
associate-*r/23.8%
distribute-rgt1-in23.8%
metadata-eval23.8%
mul0-lft23.8%
metadata-eval23.8%
Simplified23.8%
Final simplification44.8%
(FPCore (a b c) :precision binary64 (if (<= b 8e-309) (- (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 8e-309) {
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 <= 8d-309) 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 <= 8e-309) {
tmp = -(b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 8e-309: tmp = -(b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 8e-309) 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 <= 8e-309) tmp = -(b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 8e-309], (-N[(b / a), $MachinePrecision]), N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 8 \cdot 10^{-309}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 8.0000000000000003e-309Initial program 78.5%
*-commutative78.5%
Simplified78.5%
Taylor expanded in b around -inf 66.5%
associate-*r/66.5%
mul-1-neg66.5%
Simplified66.5%
if 8.0000000000000003e-309 < b Initial program 32.0%
*-commutative32.0%
Simplified32.0%
Taylor expanded in b around inf 68.0%
mul-1-neg68.0%
distribute-neg-frac68.0%
Simplified68.0%
Final simplification67.3%
(FPCore (a b c) :precision binary64 (/ 0.0 a))
double code(double a, double b, double c) {
return 0.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 = 0.0d0 / a
end function
public static double code(double a, double b, double c) {
return 0.0 / a;
}
def code(a, b, c): return 0.0 / a
function code(a, b, c) return Float64(0.0 / a) end
function tmp = code(a, b, c) tmp = 0.0 / a; end
code[a_, b_, c_] := N[(0.0 / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{0}{a}
\end{array}
Initial program 54.7%
*-commutative54.7%
Simplified54.7%
pow1/254.7%
sub-neg54.7%
+-commutative54.7%
distribute-lft-neg-in54.7%
*-commutative54.7%
distribute-rgt-neg-in54.7%
metadata-eval54.7%
associate-*r*54.7%
*-commutative54.7%
fma-udef54.7%
pow-to-exp49.1%
pow249.1%
Applied egg-rr49.1%
clear-num49.1%
inv-pow49.1%
neg-mul-149.1%
fma-def49.1%
exp-to-pow54.6%
pow1/254.6%
Applied egg-rr54.6%
unpow-154.6%
associate-/l*54.6%
*-commutative54.6%
Simplified54.6%
Taylor expanded in a around 0 13.6%
associate-*r/13.6%
distribute-rgt1-in13.6%
metadata-eval13.6%
mul0-lft13.6%
metadata-eval13.6%
Simplified13.6%
Final simplification13.6%
herbie shell --seed 2024010
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))