
(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 -1e+153)
(/ (- b) a)
(if (<= b -3.8e-20)
(/ (- (sqrt (- (* b b) (* 4.0 (* a c)))) b) (* a 2.0))
(if (<= b -2.55e-48)
(* (- b (hypot b (* (sqrt (* c -4.0)) (sqrt a)))) (/ -0.5 a))
(if (<= b 5.2e-70)
(* (/ -0.5 a) (- b (hypot b (sqrt (* c (* a -4.0))))))
(/ (- c) b))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e+153) {
tmp = -b / a;
} else if (b <= -3.8e-20) {
tmp = (sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0);
} else if (b <= -2.55e-48) {
tmp = (b - hypot(b, (sqrt((c * -4.0)) * sqrt(a)))) * (-0.5 / a);
} else if (b <= 5.2e-70) {
tmp = (-0.5 / a) * (b - hypot(b, sqrt((c * (a * -4.0)))));
} else {
tmp = -c / b;
}
return tmp;
}
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1e+153) {
tmp = -b / a;
} else if (b <= -3.8e-20) {
tmp = (Math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0);
} else if (b <= -2.55e-48) {
tmp = (b - Math.hypot(b, (Math.sqrt((c * -4.0)) * Math.sqrt(a)))) * (-0.5 / a);
} else if (b <= 5.2e-70) {
tmp = (-0.5 / a) * (b - Math.hypot(b, Math.sqrt((c * (a * -4.0)))));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e+153: tmp = -b / a elif b <= -3.8e-20: tmp = (math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0) elif b <= -2.55e-48: tmp = (b - math.hypot(b, (math.sqrt((c * -4.0)) * math.sqrt(a)))) * (-0.5 / a) elif b <= 5.2e-70: tmp = (-0.5 / a) * (b - math.hypot(b, math.sqrt((c * (a * -4.0))))) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e+153) tmp = Float64(Float64(-b) / a); elseif (b <= -3.8e-20) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) - b) / Float64(a * 2.0)); elseif (b <= -2.55e-48) tmp = Float64(Float64(b - hypot(b, Float64(sqrt(Float64(c * -4.0)) * sqrt(a)))) * Float64(-0.5 / a)); elseif (b <= 5.2e-70) tmp = Float64(Float64(-0.5 / a) * Float64(b - hypot(b, sqrt(Float64(c * Float64(a * -4.0)))))); else tmp = Float64(Float64(-c) / 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.8e-20) tmp = (sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0); elseif (b <= -2.55e-48) tmp = (b - hypot(b, (sqrt((c * -4.0)) * sqrt(a)))) * (-0.5 / a); elseif (b <= 5.2e-70) tmp = (-0.5 / a) * (b - hypot(b, sqrt((c * (a * -4.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.8e-20], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, -2.55e-48], N[(N[(b - N[Sqrt[b ^ 2 + N[(N[Sqrt[N[(c * -4.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[a], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.2e-70], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[b ^ 2 + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $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.8 \cdot 10^{-20}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq -2.55 \cdot 10^{-48}:\\
\;\;\;\;\left(b - \mathsf{hypot}\left(b, \sqrt{c \cdot -4} \cdot \sqrt{a}\right)\right) \cdot \frac{-0.5}{a}\\
\mathbf{elif}\;b \leq 5.2 \cdot 10^{-70}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1e153Initial program 38.1%
sqr-neg38.1%
sqr-neg38.1%
associate-*l*38.1%
*-commutative38.1%
Simplified38.1%
Taylor expanded in b around -inf 97.7%
associate-*r/97.7%
mul-1-neg97.7%
Simplified97.7%
if -1e153 < b < -3.7999999999999998e-20Initial program 97.1%
sqr-neg97.1%
sqr-neg97.1%
associate-*l*97.1%
*-commutative97.1%
Simplified97.1%
if -3.7999999999999998e-20 < b < -2.55000000000000006e-48Initial program 35.6%
sqr-neg35.6%
sqr-neg35.6%
associate-*l*35.6%
*-commutative35.6%
Simplified35.6%
frac-2neg35.6%
div-inv35.6%
Applied egg-rr35.6%
*-commutative35.6%
associate-*l*35.6%
*-commutative35.6%
*-commutative35.6%
associate-/r*35.6%
metadata-eval35.6%
Simplified35.6%
*-commutative35.6%
associate-*r*35.6%
*-commutative35.6%
sqrt-prod99.5%
*-commutative99.5%
Applied egg-rr99.5%
if -2.55000000000000006e-48 < b < 5.20000000000000004e-70Initial program 77.2%
sqr-neg77.2%
sqr-neg77.2%
associate-*l*77.2%
*-commutative77.2%
Simplified77.2%
frac-2neg77.2%
div-inv77.0%
Applied egg-rr80.9%
*-commutative80.9%
associate-*l*80.9%
*-commutative80.9%
*-commutative80.9%
associate-/r*80.9%
metadata-eval80.9%
Simplified80.9%
if 5.20000000000000004e-70 < b Initial program 13.2%
sqr-neg13.2%
sqr-neg13.2%
associate-*l*14.1%
*-commutative14.1%
Simplified14.1%
Taylor expanded in b around inf 87.4%
associate-*r/87.4%
neg-mul-187.4%
Simplified87.4%
Final simplification88.7%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+154)
(/ (- b) a)
(if (<= b -8.6e-44)
(/ (- (sqrt (- (* b b) (* 4.0 (* a c)))) b) (* a 2.0))
(if (<= b -2.55e-48)
(* (/ -0.5 a) (- b (* (sqrt (* c -4.0)) (sqrt a))))
(if (<= b 3.7e-70)
(* (/ -0.5 a) (- b (hypot b (sqrt (* c (* a -4.0))))))
(/ (- c) b))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+154) {
tmp = -b / a;
} else if (b <= -8.6e-44) {
tmp = (sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0);
} else if (b <= -2.55e-48) {
tmp = (-0.5 / a) * (b - (sqrt((c * -4.0)) * sqrt(a)));
} else if (b <= 3.7e-70) {
tmp = (-0.5 / a) * (b - hypot(b, sqrt((c * (a * -4.0)))));
} else {
tmp = -c / b;
}
return tmp;
}
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e+154) {
tmp = -b / a;
} else if (b <= -8.6e-44) {
tmp = (Math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0);
} else if (b <= -2.55e-48) {
tmp = (-0.5 / a) * (b - (Math.sqrt((c * -4.0)) * Math.sqrt(a)));
} else if (b <= 3.7e-70) {
tmp = (-0.5 / a) * (b - Math.hypot(b, Math.sqrt((c * (a * -4.0)))));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+154: tmp = -b / a elif b <= -8.6e-44: tmp = (math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0) elif b <= -2.55e-48: tmp = (-0.5 / a) * (b - (math.sqrt((c * -4.0)) * math.sqrt(a))) elif b <= 3.7e-70: tmp = (-0.5 / a) * (b - math.hypot(b, math.sqrt((c * (a * -4.0))))) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+154) tmp = Float64(Float64(-b) / a); elseif (b <= -8.6e-44) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) - b) / Float64(a * 2.0)); elseif (b <= -2.55e-48) tmp = Float64(Float64(-0.5 / a) * Float64(b - Float64(sqrt(Float64(c * -4.0)) * sqrt(a)))); elseif (b <= 3.7e-70) tmp = Float64(Float64(-0.5 / a) * Float64(b - hypot(b, sqrt(Float64(c * Float64(a * -4.0)))))); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e+154) tmp = -b / a; elseif (b <= -8.6e-44) tmp = (sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0); elseif (b <= -2.55e-48) tmp = (-0.5 / a) * (b - (sqrt((c * -4.0)) * sqrt(a))); elseif (b <= 3.7e-70) tmp = (-0.5 / a) * (b - hypot(b, sqrt((c * (a * -4.0))))); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+154], N[((-b) / a), $MachinePrecision], If[LessEqual[b, -8.6e-44], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, -2.55e-48], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[(N[Sqrt[N[(c * -4.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[a], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.7e-70], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[b ^ 2 + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $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 -8.6 \cdot 10^{-44}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\
\mathbf{elif}\;b \leq -2.55 \cdot 10^{-48}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{c \cdot -4} \cdot \sqrt{a}\right)\\
\mathbf{elif}\;b \leq 3.7 \cdot 10^{-70}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \mathsf{hypot}\left(b, \sqrt{c \cdot \left(a \cdot -4\right)}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.00000000000000004e154Initial program 38.1%
sqr-neg38.1%
sqr-neg38.1%
associate-*l*38.1%
*-commutative38.1%
Simplified38.1%
Taylor expanded in b around -inf 97.7%
associate-*r/97.7%
mul-1-neg97.7%
Simplified97.7%
if -5.00000000000000004e154 < b < -8.60000000000000027e-44Initial program 97.2%
sqr-neg97.2%
sqr-neg97.2%
associate-*l*97.2%
*-commutative97.2%
Simplified97.2%
if -8.60000000000000027e-44 < b < -2.55000000000000006e-48Initial program 3.3%
sqr-neg3.3%
sqr-neg3.3%
associate-*l*3.3%
*-commutative3.3%
Simplified3.3%
Taylor expanded in b around 0 3.3%
*-commutative3.3%
associate-*l*3.3%
Simplified3.3%
expm1-log1p-u3.3%
expm1-udef3.3%
Applied egg-rr3.3%
expm1-def3.3%
expm1-log1p3.3%
*-commutative3.3%
Simplified3.3%
*-commutative3.3%
associate-*r*3.3%
*-commutative3.3%
sqrt-prod99.2%
*-commutative99.2%
Applied egg-rr99.2%
if -2.55000000000000006e-48 < b < 3.7e-70Initial program 77.2%
sqr-neg77.2%
sqr-neg77.2%
associate-*l*77.2%
*-commutative77.2%
Simplified77.2%
frac-2neg77.2%
div-inv77.0%
Applied egg-rr80.9%
*-commutative80.9%
associate-*l*80.9%
*-commutative80.9%
*-commutative80.9%
associate-/r*80.9%
metadata-eval80.9%
Simplified80.9%
if 3.7e-70 < b Initial program 13.2%
sqr-neg13.2%
sqr-neg13.2%
associate-*l*14.1%
*-commutative14.1%
Simplified14.1%
Taylor expanded in b around inf 87.4%
associate-*r/87.4%
neg-mul-187.4%
Simplified87.4%
Final simplification88.7%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+154)
(/ (- b) a)
(if (<= b 5.3e-70)
(/ (- (sqrt (- (* b b) (* 4.0 (* a c)))) 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 <= 5.3e-70) {
tmp = (sqrt(((b * b) - (4.0 * (a * 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 <= (-5d+154)) then
tmp = -b / a
else if (b <= 5.3d-70) then
tmp = (sqrt(((b * b) - (4.0d0 * (a * 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 <= -5e+154) {
tmp = -b / a;
} else if (b <= 5.3e-70) {
tmp = (Math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+154: tmp = -b / a elif b <= 5.3e-70: tmp = (math.sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+154) tmp = Float64(Float64(-b) / a); elseif (b <= 5.3e-70) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * 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 <= -5e+154) tmp = -b / a; elseif (b <= 5.3e-70) tmp = (sqrt(((b * b) - (4.0 * (a * c)))) - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+154], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 5.3e-70], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * 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 -5 \cdot 10^{+154}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 5.3 \cdot 10^{-70}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.00000000000000004e154Initial program 38.1%
sqr-neg38.1%
sqr-neg38.1%
associate-*l*38.1%
*-commutative38.1%
Simplified38.1%
Taylor expanded in b around -inf 97.7%
associate-*r/97.7%
mul-1-neg97.7%
Simplified97.7%
if -5.00000000000000004e154 < b < 5.29999999999999983e-70Initial program 82.4%
sqr-neg82.4%
sqr-neg82.4%
associate-*l*82.4%
*-commutative82.4%
Simplified82.4%
if 5.29999999999999983e-70 < b Initial program 13.2%
sqr-neg13.2%
sqr-neg13.2%
associate-*l*14.1%
*-commutative14.1%
Simplified14.1%
Taylor expanded in b around inf 87.4%
associate-*r/87.4%
neg-mul-187.4%
Simplified87.4%
Final simplification86.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.35e-68)
(- (/ c b) (/ b a))
(if (<= b 1.2e-69)
(* (/ -0.5 a) (- b (sqrt (* c (* a -4.0)))))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.35e-68) {
tmp = (c / b) - (b / a);
} else if (b <= 1.2e-69) {
tmp = (-0.5 / a) * (b - sqrt((c * (a * -4.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.35d-68)) then
tmp = (c / b) - (b / a)
else if (b <= 1.2d-69) then
tmp = ((-0.5d0) / a) * (b - sqrt((c * (a * (-4.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.35e-68) {
tmp = (c / b) - (b / a);
} else if (b <= 1.2e-69) {
tmp = (-0.5 / a) * (b - Math.sqrt((c * (a * -4.0))));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.35e-68: tmp = (c / b) - (b / a) elif b <= 1.2e-69: tmp = (-0.5 / a) * (b - math.sqrt((c * (a * -4.0)))) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.35e-68) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.2e-69) tmp = Float64(Float64(-0.5 / a) * Float64(b - sqrt(Float64(c * Float64(a * -4.0))))); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.35e-68) tmp = (c / b) - (b / a); elseif (b <= 1.2e-69) tmp = (-0.5 / a) * (b - sqrt((c * (a * -4.0)))); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.35e-68], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.2e-69], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.35 \cdot 10^{-68}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.2 \cdot 10^{-69}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{c \cdot \left(a \cdot -4\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.3500000000000001e-68Initial program 64.6%
sqr-neg64.6%
sqr-neg64.6%
associate-*l*64.6%
*-commutative64.6%
Simplified64.6%
Taylor expanded in b around -inf 90.1%
mul-1-neg90.1%
unsub-neg90.1%
Simplified90.1%
if -1.3500000000000001e-68 < b < 1.2000000000000001e-69Initial program 76.9%
sqr-neg76.9%
sqr-neg76.9%
associate-*l*76.9%
*-commutative76.9%
Simplified76.9%
Taylor expanded in b around 0 70.6%
*-commutative70.6%
associate-*l*70.6%
Simplified70.6%
expm1-log1p-u49.4%
expm1-udef18.4%
Applied egg-rr18.4%
expm1-def49.4%
expm1-log1p70.4%
*-commutative70.4%
Simplified70.4%
if 1.2000000000000001e-69 < b Initial program 13.2%
sqr-neg13.2%
sqr-neg13.2%
associate-*l*14.1%
*-commutative14.1%
Simplified14.1%
Taylor expanded in b around inf 87.4%
associate-*r/87.4%
neg-mul-187.4%
Simplified87.4%
Final simplification83.6%
(FPCore (a b c) :precision binary64 (if (<= b -9e-77) (- (/ c b) (/ b a)) (if (<= b 9e-70) (/ (* -0.5 (- b (sqrt (* c (* a -4.0))))) a) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9e-77) {
tmp = (c / b) - (b / a);
} else if (b <= 9e-70) {
tmp = (-0.5 * (b - sqrt((c * (a * -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 <= (-9d-77)) then
tmp = (c / b) - (b / a)
else if (b <= 9d-70) then
tmp = ((-0.5d0) * (b - sqrt((c * (a * (-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 <= -9e-77) {
tmp = (c / b) - (b / a);
} else if (b <= 9e-70) {
tmp = (-0.5 * (b - Math.sqrt((c * (a * -4.0))))) / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9e-77: tmp = (c / b) - (b / a) elif b <= 9e-70: tmp = (-0.5 * (b - math.sqrt((c * (a * -4.0))))) / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9e-77) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 9e-70) tmp = Float64(Float64(-0.5 * Float64(b - sqrt(Float64(c * Float64(a * -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 <= -9e-77) tmp = (c / b) - (b / a); elseif (b <= 9e-70) tmp = (-0.5 * (b - sqrt((c * (a * -4.0))))) / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9e-77], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9e-70], N[(N[(-0.5 * N[(b - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9 \cdot 10^{-77}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 9 \cdot 10^{-70}:\\
\;\;\;\;\frac{-0.5 \cdot \left(b - \sqrt{c \cdot \left(a \cdot -4\right)}\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -9.0000000000000001e-77Initial program 64.6%
sqr-neg64.6%
sqr-neg64.6%
associate-*l*64.6%
*-commutative64.6%
Simplified64.6%
Taylor expanded in b around -inf 90.1%
mul-1-neg90.1%
unsub-neg90.1%
Simplified90.1%
if -9.0000000000000001e-77 < b < 9.00000000000000044e-70Initial program 76.9%
sqr-neg76.9%
sqr-neg76.9%
associate-*l*76.9%
*-commutative76.9%
Simplified76.9%
Taylor expanded in b around 0 70.6%
*-commutative70.6%
associate-*l*70.6%
Simplified70.6%
expm1-log1p-u49.4%
expm1-udef18.4%
Applied egg-rr18.4%
expm1-def49.4%
expm1-log1p70.4%
*-commutative70.4%
Simplified70.4%
associate-*l/70.6%
Applied egg-rr70.6%
if 9.00000000000000044e-70 < b Initial program 13.2%
sqr-neg13.2%
sqr-neg13.2%
associate-*l*14.1%
*-commutative14.1%
Simplified14.1%
Taylor expanded in b around inf 87.4%
associate-*r/87.4%
neg-mul-187.4%
Simplified87.4%
Final simplification83.6%
(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 69.5%
sqr-neg69.5%
sqr-neg69.5%
associate-*l*69.5%
*-commutative69.5%
Simplified69.5%
Taylor expanded in b around -inf 71.6%
mul-1-neg71.6%
unsub-neg71.6%
Simplified71.6%
if -4.999999999999985e-310 < b Initial program 28.4%
sqr-neg28.4%
sqr-neg28.4%
associate-*l*29.2%
*-commutative29.2%
Simplified29.2%
Taylor expanded in b around inf 69.7%
associate-*r/69.7%
neg-mul-169.7%
Simplified69.7%
Final simplification70.6%
(FPCore (a b c) :precision binary64 (if (<= b 1.35e-12) (/ (- b) a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.35e-12) {
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.35d-12) 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.35e-12) {
tmp = -b / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.35e-12: tmp = -b / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.35e-12) 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.35e-12) tmp = -b / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.35e-12], N[((-b) / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.35 \cdot 10^{-12}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.3499999999999999e-12Initial program 68.6%
sqr-neg68.6%
sqr-neg68.6%
associate-*l*68.6%
*-commutative68.6%
Simplified68.6%
Taylor expanded in b around -inf 51.9%
associate-*r/51.9%
mul-1-neg51.9%
Simplified51.9%
if 1.3499999999999999e-12 < b Initial program 10.2%
sqr-neg10.2%
sqr-neg10.2%
associate-*l*11.2%
*-commutative11.2%
Simplified11.2%
Taylor expanded in b around -inf 2.5%
mul-1-neg2.5%
unsub-neg2.5%
Simplified2.5%
Taylor expanded in c around inf 35.1%
Final simplification45.7%
(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 69.5%
sqr-neg69.5%
sqr-neg69.5%
associate-*l*69.5%
*-commutative69.5%
Simplified69.5%
Taylor expanded in b around -inf 71.5%
associate-*r/71.5%
mul-1-neg71.5%
Simplified71.5%
if -4.999999999999985e-310 < b Initial program 28.4%
sqr-neg28.4%
sqr-neg28.4%
associate-*l*29.2%
*-commutative29.2%
Simplified29.2%
Taylor expanded in b around inf 69.7%
associate-*r/69.7%
neg-mul-169.7%
Simplified69.7%
Final simplification70.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 46.9%
sqr-neg46.9%
sqr-neg46.9%
associate-*l*47.3%
*-commutative47.3%
Simplified47.3%
frac-2neg47.3%
div-inv47.2%
Applied egg-rr50.4%
*-commutative50.4%
associate-*l*50.7%
*-commutative50.7%
*-commutative50.7%
associate-/r*50.7%
metadata-eval50.7%
Simplified50.7%
associate-*r/50.8%
clear-num50.7%
Applied egg-rr50.7%
Taylor expanded in b around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
times-frac0.0%
unpow20.0%
rem-square-sqrt39.3%
metadata-eval39.3%
neg-mul-139.3%
sub-neg39.3%
Simplified39.3%
Taylor expanded in a around inf 2.4%
Final simplification2.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 46.9%
sqr-neg46.9%
sqr-neg46.9%
associate-*l*47.3%
*-commutative47.3%
Simplified47.3%
Taylor expanded in b around -inf 33.4%
mul-1-neg33.4%
unsub-neg33.4%
Simplified33.4%
Taylor expanded in c around inf 14.8%
Final simplification14.8%
herbie shell --seed 2023275
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))