
(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 -3.5e+125)
(/ b (- a))
(if (<= b 1.15e-60)
(/ (- (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 <= -3.5e+125) {
tmp = b / -a;
} else if (b <= 1.15e-60) {
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 <= -3.5e+125) tmp = Float64(b / Float64(-a)); elseif (b <= 1.15e-60) 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, -3.5e+125], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.15e-60], 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 -3.5 \cdot 10^{+125}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{-60}:\\
\;\;\;\;\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 < -3.50000000000000011e125Initial program 48.2%
*-commutative48.2%
Simplified48.2%
Taylor expanded in b around -inf 97.3%
associate-*r/97.3%
mul-1-neg97.3%
Simplified97.3%
if -3.50000000000000011e125 < b < 1.1500000000000001e-60Initial program 76.0%
*-commutative76.0%
Simplified76.0%
if 1.1500000000000001e-60 < b Initial program 15.5%
*-commutative15.5%
Simplified15.5%
Taylor expanded in b around inf 88.8%
associate-*r/88.8%
mul-1-neg88.8%
Simplified88.8%
Final simplification84.3%
(FPCore (a b c)
:precision binary64
(if (<= b -4.4e+125)
(/ b (- a))
(if (<= b 1.18e-60)
(/ (- (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 <= -4.4e+125) {
tmp = b / -a;
} else if (b <= 1.18e-60) {
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 <= (-4.4d+125)) then
tmp = b / -a
else if (b <= 1.18d-60) 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 <= -4.4e+125) {
tmp = b / -a;
} else if (b <= 1.18e-60) {
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 <= -4.4e+125: tmp = b / -a elif b <= 1.18e-60: 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 <= -4.4e+125) tmp = Float64(b / Float64(-a)); elseif (b <= 1.18e-60) 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 <= -4.4e+125) tmp = b / -a; elseif (b <= 1.18e-60) 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, -4.4e+125], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.18e-60], 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.4 \cdot 10^{+125}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 1.18 \cdot 10^{-60}:\\
\;\;\;\;\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 < -4.39999999999999982e125Initial program 48.2%
*-commutative48.2%
Simplified48.2%
Taylor expanded in b around -inf 97.3%
associate-*r/97.3%
mul-1-neg97.3%
Simplified97.3%
if -4.39999999999999982e125 < b < 1.17999999999999994e-60Initial program 76.0%
if 1.17999999999999994e-60 < b Initial program 15.5%
*-commutative15.5%
Simplified15.5%
Taylor expanded in b around inf 88.8%
associate-*r/88.8%
mul-1-neg88.8%
Simplified88.8%
Final simplification84.3%
(FPCore (a b c)
:precision binary64
(if (<= b -6.5e-11)
(* b (- (/ c (pow b 2.0)) (/ 1.0 a)))
(if (<= b 5.2e-60)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.5e-11) {
tmp = b * ((c / pow(b, 2.0)) - (1.0 / a));
} else if (b <= 5.2e-60) {
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 <= (-6.5d-11)) then
tmp = b * ((c / (b ** 2.0d0)) - (1.0d0 / a))
else if (b <= 5.2d-60) 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 <= -6.5e-11) {
tmp = b * ((c / Math.pow(b, 2.0)) - (1.0 / a));
} else if (b <= 5.2e-60) {
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 <= -6.5e-11: tmp = b * ((c / math.pow(b, 2.0)) - (1.0 / a)) elif b <= 5.2e-60: 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 <= -6.5e-11) tmp = Float64(b * Float64(Float64(c / (b ^ 2.0)) - Float64(1.0 / a))); elseif (b <= 5.2e-60) 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 <= -6.5e-11) tmp = b * ((c / (b ^ 2.0)) - (1.0 / a)); elseif (b <= 5.2e-60) 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, -6.5e-11], N[(b * N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] - N[(1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.2e-60], 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 -6.5 \cdot 10^{-11}:\\
\;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} - \frac{1}{a}\right)\\
\mathbf{elif}\;b \leq 5.2 \cdot 10^{-60}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -6.49999999999999953e-11Initial program 65.5%
*-commutative65.5%
Simplified65.5%
Taylor expanded in b around -inf 90.2%
mul-1-neg90.2%
distribute-rgt-neg-in90.2%
+-commutative90.2%
mul-1-neg90.2%
unsub-neg90.2%
Simplified90.2%
if -6.49999999999999953e-11 < b < 5.1999999999999995e-60Initial program 70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in b around 0 61.0%
*-commutative61.0%
associate-*r*61.0%
Simplified61.0%
if 5.1999999999999995e-60 < b Initial program 15.5%
*-commutative15.5%
Simplified15.5%
Taylor expanded in b around inf 88.8%
associate-*r/88.8%
mul-1-neg88.8%
Simplified88.8%
Final simplification79.6%
(FPCore (a b c) :precision binary64 (if (<= b -1.1e-157) (* b (- (/ c (pow b 2.0)) (/ 1.0 a))) (if (<= b 4e-182) (* -0.5 (- (sqrt (* c (/ -4.0 a))))) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.1e-157) {
tmp = b * ((c / pow(b, 2.0)) - (1.0 / a));
} else if (b <= 4e-182) {
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 <= (-1.1d-157)) then
tmp = b * ((c / (b ** 2.0d0)) - (1.0d0 / a))
else if (b <= 4d-182) 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 <= -1.1e-157) {
tmp = b * ((c / Math.pow(b, 2.0)) - (1.0 / a));
} else if (b <= 4e-182) {
tmp = -0.5 * -Math.sqrt((c * (-4.0 / a)));
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.1e-157: tmp = b * ((c / math.pow(b, 2.0)) - (1.0 / a)) elif b <= 4e-182: 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 <= -1.1e-157) tmp = Float64(b * Float64(Float64(c / (b ^ 2.0)) - Float64(1.0 / a))); elseif (b <= 4e-182) tmp = Float64(-0.5 * Float64(-sqrt(Float64(c * Float64(-4.0 / a))))); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.1e-157) tmp = b * ((c / (b ^ 2.0)) - (1.0 / a)); elseif (b <= 4e-182) tmp = -0.5 * -sqrt((c * (-4.0 / a))); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.1e-157], N[(b * N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] - N[(1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4e-182], 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 -1.1 \cdot 10^{-157}:\\
\;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} - \frac{1}{a}\right)\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-182}:\\
\;\;\;\;-0.5 \cdot \left(-\sqrt{c \cdot \frac{-4}{a}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.10000000000000005e-157Initial program 70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in b around -inf 78.6%
mul-1-neg78.6%
distribute-rgt-neg-in78.6%
+-commutative78.6%
mul-1-neg78.6%
unsub-neg78.6%
Simplified78.6%
if -1.10000000000000005e-157 < b < 4.0000000000000002e-182Initial program 70.5%
*-commutative70.5%
Simplified70.5%
add-cube-cbrt69.8%
pow369.8%
*-commutative69.8%
associate-*l*69.8%
Applied egg-rr69.8%
Taylor expanded in a around -inf 0.0%
associate-*r*0.0%
associate-/l*0.0%
rem-cube-cbrt0.0%
unpow20.0%
rem-square-sqrt40.1%
Simplified40.1%
if 4.0000000000000002e-182 < b Initial program 24.8%
*-commutative24.8%
Simplified24.8%
Taylor expanded in b around inf 74.5%
associate-*r/74.5%
mul-1-neg74.5%
Simplified74.5%
Final simplification71.0%
(FPCore (a b c) :precision binary64 (if (<= b -1.05e-156) (/ b (- a)) (if (<= b 2.4e-183) (* -0.5 (- (sqrt (* c (/ -4.0 a))))) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.05e-156) {
tmp = b / -a;
} else if (b <= 2.4e-183) {
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 <= (-1.05d-156)) then
tmp = b / -a
else if (b <= 2.4d-183) 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 <= -1.05e-156) {
tmp = b / -a;
} else if (b <= 2.4e-183) {
tmp = -0.5 * -Math.sqrt((c * (-4.0 / a)));
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.05e-156: tmp = b / -a elif b <= 2.4e-183: 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 <= -1.05e-156) tmp = Float64(b / Float64(-a)); elseif (b <= 2.4e-183) tmp = Float64(-0.5 * Float64(-sqrt(Float64(c * Float64(-4.0 / a))))); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.05e-156) tmp = b / -a; elseif (b <= 2.4e-183) tmp = -0.5 * -sqrt((c * (-4.0 / a))); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.05e-156], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 2.4e-183], 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 -1.05 \cdot 10^{-156}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-183}:\\
\;\;\;\;-0.5 \cdot \left(-\sqrt{c \cdot \frac{-4}{a}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.05000000000000006e-156Initial program 70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in b around -inf 78.1%
associate-*r/78.1%
mul-1-neg78.1%
Simplified78.1%
if -1.05000000000000006e-156 < b < 2.39999999999999993e-183Initial program 70.5%
*-commutative70.5%
Simplified70.5%
add-cube-cbrt69.8%
pow369.8%
*-commutative69.8%
associate-*l*69.8%
Applied egg-rr69.8%
Taylor expanded in a around -inf 0.0%
associate-*r*0.0%
associate-/l*0.0%
rem-cube-cbrt0.0%
unpow20.0%
rem-square-sqrt40.1%
Simplified40.1%
if 2.39999999999999993e-183 < b Initial program 24.8%
*-commutative24.8%
Simplified24.8%
Taylor expanded in b around inf 74.5%
associate-*r/74.5%
mul-1-neg74.5%
Simplified74.5%
Final simplification70.8%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-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 <= (-2d-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 <= -2e-310) {
tmp = b / -a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = b / -a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = b / -a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 69.1%
*-commutative69.1%
Simplified69.1%
Taylor expanded in b around -inf 66.3%
associate-*r/66.3%
mul-1-neg66.3%
Simplified66.3%
if -1.999999999999994e-310 < b Initial program 32.5%
*-commutative32.5%
Simplified32.5%
Taylor expanded in b around inf 65.1%
associate-*r/65.1%
mul-1-neg65.1%
Simplified65.1%
Final simplification65.7%
(FPCore (a b c) :precision binary64 (if (<= b 6.1e+54) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.1e+54) {
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 <= 6.1d+54) 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 <= 6.1e+54) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.1e+54: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.1e+54) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 6.1e+54) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.1e+54], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.1 \cdot 10^{+54}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 6.0999999999999998e54Initial program 63.3%
*-commutative63.3%
Simplified63.3%
Taylor expanded in b around -inf 45.4%
associate-*r/45.4%
mul-1-neg45.4%
Simplified45.4%
if 6.0999999999999998e54 < b Initial program 12.9%
*-commutative12.9%
Simplified12.9%
Applied egg-rr2.3%
unpow-12.3%
associate-/l*2.3%
Simplified2.3%
Taylor expanded in b around -inf 32.7%
Final simplification42.3%
(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 51.1%
*-commutative51.1%
Simplified51.1%
Applied egg-rr31.2%
unpow-131.2%
associate-/l*31.2%
Simplified31.2%
Taylor expanded in b around -inf 10.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 51.1%
*-commutative51.1%
Simplified51.1%
Applied egg-rr31.2%
unpow-131.2%
associate-/l*31.2%
Simplified31.2%
Taylor expanded in a around 0 2.5%
herbie shell --seed 2024118
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))