
(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+157)
(- (/ b a))
(if (<= b 1.26e-61)
(/ (- (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 <= -3.5e+157) {
tmp = -(b / a);
} else if (b <= 1.26e-61) {
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 <= (-3.5d+157)) then
tmp = -(b / a)
else if (b <= 1.26d-61) 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 <= -3.5e+157) {
tmp = -(b / a);
} else if (b <= 1.26e-61) {
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 <= -3.5e+157: tmp = -(b / a) elif b <= 1.26e-61: 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 <= -3.5e+157) tmp = Float64(-Float64(b / a)); elseif (b <= 1.26e-61) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - 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 <= -3.5e+157) tmp = -(b / a); elseif (b <= 1.26e-61) 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, -3.5e+157], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 1.26e-61], 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.5 \cdot 10^{+157}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 1.26 \cdot 10^{-61}:\\
\;\;\;\;\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.50000000000000002e157Initial program 23.5%
*-commutative23.5%
Simplified23.7%
Taylor expanded in b around -inf 99.1%
associate-*r/99.1%
mul-1-neg99.1%
Simplified99.1%
if -3.50000000000000002e157 < b < 1.2599999999999999e-61Initial program 79.6%
if 1.2599999999999999e-61 < b Initial program 21.6%
*-commutative21.6%
Simplified21.6%
Taylor expanded in a around 0 83.8%
associate-*r/83.8%
mul-1-neg83.8%
Simplified83.8%
Final simplification84.5%
(FPCore (a b c) :precision binary64 (if (<= b -9.8e-55) (* b (+ (/ c (pow b 2.0)) (/ -1.0 a))) (if (<= b 9e-61) (/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0)) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.8e-55) {
tmp = b * ((c / pow(b, 2.0)) + (-1.0 / a));
} else if (b <= 9e-61) {
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 <= (-9.8d-55)) then
tmp = b * ((c / (b ** 2.0d0)) + ((-1.0d0) / a))
else if (b <= 9d-61) 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 <= -9.8e-55) {
tmp = b * ((c / Math.pow(b, 2.0)) + (-1.0 / a));
} else if (b <= 9e-61) {
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 <= -9.8e-55: tmp = b * ((c / math.pow(b, 2.0)) + (-1.0 / a)) elif b <= 9e-61: 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 <= -9.8e-55) tmp = Float64(b * Float64(Float64(c / (b ^ 2.0)) + Float64(-1.0 / a))); elseif (b <= 9e-61) 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 <= -9.8e-55) tmp = b * ((c / (b ^ 2.0)) + (-1.0 / a)); elseif (b <= 9e-61) 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, -9.8e-55], N[(b * N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9e-61], 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 -9.8 \cdot 10^{-55}:\\
\;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\
\mathbf{elif}\;b \leq 9 \cdot 10^{-61}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -9.80000000000000071e-55Initial program 59.2%
*-commutative59.2%
Simplified59.3%
Taylor expanded in b around -inf 89.0%
mul-1-neg89.0%
*-commutative89.0%
distribute-rgt-neg-in89.0%
+-commutative89.0%
mul-1-neg89.0%
unsub-neg89.0%
Simplified89.0%
if -9.80000000000000071e-55 < b < 9e-61Initial program 70.6%
*-commutative70.6%
Simplified70.6%
Taylor expanded in a around inf 66.0%
*-commutative66.0%
associate-*r*66.0%
Simplified66.0%
if 9e-61 < b Initial program 21.6%
*-commutative21.6%
Simplified21.6%
Taylor expanded in a around 0 83.8%
associate-*r/83.8%
mul-1-neg83.8%
Simplified83.8%
Final simplification81.0%
(FPCore (a b c)
:precision binary64
(if (<= b -1.45e-55)
(* b (+ (/ c (pow b 2.0)) (/ -1.0 a)))
(if (<= b 1.8e-61)
(* (+ b (sqrt (* a (* c -4.0)))) (/ 0.5 a))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.45e-55) {
tmp = b * ((c / pow(b, 2.0)) + (-1.0 / a));
} else if (b <= 1.8e-61) {
tmp = (b + sqrt((a * (c * -4.0)))) * (0.5 / 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.45d-55)) then
tmp = b * ((c / (b ** 2.0d0)) + ((-1.0d0) / a))
else if (b <= 1.8d-61) then
tmp = (b + sqrt((a * (c * (-4.0d0))))) * (0.5d0 / 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.45e-55) {
tmp = b * ((c / Math.pow(b, 2.0)) + (-1.0 / a));
} else if (b <= 1.8e-61) {
tmp = (b + Math.sqrt((a * (c * -4.0)))) * (0.5 / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.45e-55: tmp = b * ((c / math.pow(b, 2.0)) + (-1.0 / a)) elif b <= 1.8e-61: tmp = (b + math.sqrt((a * (c * -4.0)))) * (0.5 / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.45e-55) tmp = Float64(b * Float64(Float64(c / (b ^ 2.0)) + Float64(-1.0 / a))); elseif (b <= 1.8e-61) tmp = Float64(Float64(b + sqrt(Float64(a * Float64(c * -4.0)))) * Float64(0.5 / a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.45e-55) tmp = b * ((c / (b ^ 2.0)) + (-1.0 / a)); elseif (b <= 1.8e-61) tmp = (b + sqrt((a * (c * -4.0)))) * (0.5 / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.45e-55], N[(b * N[(N[(c / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.8e-61], N[(N[(b + N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.45 \cdot 10^{-55}:\\
\;\;\;\;b \cdot \left(\frac{c}{{b}^{2}} + \frac{-1}{a}\right)\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-61}:\\
\;\;\;\;\left(b + \sqrt{a \cdot \left(c \cdot -4\right)}\right) \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.45e-55Initial program 59.2%
*-commutative59.2%
Simplified59.3%
Taylor expanded in b around -inf 89.0%
mul-1-neg89.0%
*-commutative89.0%
distribute-rgt-neg-in89.0%
+-commutative89.0%
mul-1-neg89.0%
unsub-neg89.0%
Simplified89.0%
if -1.45e-55 < b < 1.80000000000000007e-61Initial program 70.6%
*-commutative70.6%
Simplified70.6%
Taylor expanded in a around inf 66.0%
*-commutative66.0%
associate-*r*66.0%
Simplified66.0%
div-inv65.9%
add-log-exp7.9%
add-log-exp65.9%
sub-neg65.9%
add-sqr-sqrt37.7%
sqrt-unprod65.0%
sqr-neg65.0%
sqrt-prod28.4%
add-sqr-sqrt63.9%
Applied egg-rr63.9%
Taylor expanded in a around 0 63.9%
if 1.80000000000000007e-61 < b Initial program 21.6%
*-commutative21.6%
Simplified21.6%
Taylor expanded in a around 0 83.8%
associate-*r/83.8%
mul-1-neg83.8%
Simplified83.8%
Final simplification80.4%
(FPCore (a b c)
:precision binary64
(if (<= b -2.15e-55)
(- (/ b a))
(if (<= b 1.2e-62)
(* (+ b (sqrt (* a (* c -4.0)))) (/ 0.5 a))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.15e-55) {
tmp = -(b / a);
} else if (b <= 1.2e-62) {
tmp = (b + sqrt((a * (c * -4.0)))) * (0.5 / 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.15d-55)) then
tmp = -(b / a)
else if (b <= 1.2d-62) then
tmp = (b + sqrt((a * (c * (-4.0d0))))) * (0.5d0 / 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.15e-55) {
tmp = -(b / a);
} else if (b <= 1.2e-62) {
tmp = (b + Math.sqrt((a * (c * -4.0)))) * (0.5 / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.15e-55: tmp = -(b / a) elif b <= 1.2e-62: tmp = (b + math.sqrt((a * (c * -4.0)))) * (0.5 / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.15e-55) tmp = Float64(-Float64(b / a)); elseif (b <= 1.2e-62) tmp = Float64(Float64(b + sqrt(Float64(a * Float64(c * -4.0)))) * Float64(0.5 / a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.15e-55) tmp = -(b / a); elseif (b <= 1.2e-62) tmp = (b + sqrt((a * (c * -4.0)))) * (0.5 / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.15e-55], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 1.2e-62], N[(N[(b + N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.15 \cdot 10^{-55}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 1.2 \cdot 10^{-62}:\\
\;\;\;\;\left(b + \sqrt{a \cdot \left(c \cdot -4\right)}\right) \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -2.15000000000000005e-55Initial program 59.2%
*-commutative59.2%
Simplified59.3%
Taylor expanded in b around -inf 88.7%
associate-*r/88.7%
mul-1-neg88.7%
Simplified88.7%
if -2.15000000000000005e-55 < b < 1.19999999999999992e-62Initial program 70.6%
*-commutative70.6%
Simplified70.6%
Taylor expanded in a around inf 66.0%
*-commutative66.0%
associate-*r*66.0%
Simplified66.0%
div-inv65.9%
add-log-exp7.9%
add-log-exp65.9%
sub-neg65.9%
add-sqr-sqrt37.7%
sqrt-unprod65.0%
sqr-neg65.0%
sqrt-prod28.4%
add-sqr-sqrt63.9%
Applied egg-rr63.9%
Taylor expanded in a around 0 63.9%
if 1.19999999999999992e-62 < b Initial program 21.6%
*-commutative21.6%
Simplified21.6%
Taylor expanded in a around 0 83.8%
associate-*r/83.8%
mul-1-neg83.8%
Simplified83.8%
Final simplification80.3%
(FPCore (a b c) :precision binary64 (if (<= b -1.15e-110) (- (/ b a)) (if (<= b 1.2e-62) (* (sqrt (* c (/ -4.0 a))) (- -0.5)) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e-110) {
tmp = -(b / a);
} else if (b <= 1.2e-62) {
tmp = sqrt((c * (-4.0 / a))) * -(-0.5);
} else {
tmp = c / -b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-1.15d-110)) then
tmp = -(b / a)
else if (b <= 1.2d-62) then
tmp = sqrt((c * ((-4.0d0) / a))) * -(-0.5d0)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.15e-110) {
tmp = -(b / a);
} else if (b <= 1.2e-62) {
tmp = Math.sqrt((c * (-4.0 / a))) * -(-0.5);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.15e-110: tmp = -(b / a) elif b <= 1.2e-62: tmp = math.sqrt((c * (-4.0 / a))) * -(-0.5) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.15e-110) tmp = Float64(-Float64(b / a)); elseif (b <= 1.2e-62) tmp = Float64(sqrt(Float64(c * Float64(-4.0 / a))) * Float64(-(-0.5))); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.15e-110) tmp = -(b / a); elseif (b <= 1.2e-62) tmp = sqrt((c * (-4.0 / a))) * -(-0.5); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.15e-110], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 1.2e-62], N[(N[Sqrt[N[(c * N[(-4.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (--0.5)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.15 \cdot 10^{-110}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 1.2 \cdot 10^{-62}:\\
\;\;\;\;\sqrt{c \cdot \frac{-4}{a}} \cdot \left(--0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.1500000000000001e-110Initial program 60.9%
*-commutative60.9%
Simplified61.0%
Taylor expanded in b around -inf 86.5%
associate-*r/86.5%
mul-1-neg86.5%
Simplified86.5%
if -1.1500000000000001e-110 < b < 1.19999999999999992e-62Initial program 68.7%
*-commutative68.7%
Simplified68.7%
add-cube-cbrt68.1%
pow368.1%
Applied egg-rr68.1%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt38.5%
associate-/l*38.5%
rem-cube-cbrt38.8%
Simplified38.8%
if 1.19999999999999992e-62 < b Initial program 21.6%
*-commutative21.6%
Simplified21.6%
Taylor expanded in a around 0 83.8%
associate-*r/83.8%
mul-1-neg83.8%
Simplified83.8%
Final simplification73.6%
(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(c / Float64(-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 63.5%
*-commutative63.5%
Simplified63.5%
Taylor expanded in b around -inf 67.6%
associate-*r/67.6%
mul-1-neg67.6%
Simplified67.6%
if -4.999999999999985e-310 < b Initial program 32.2%
*-commutative32.2%
Simplified32.2%
Taylor expanded in a around 0 67.5%
associate-*r/67.5%
mul-1-neg67.5%
Simplified67.5%
Final simplification67.5%
(FPCore (a b c) :precision binary64 (if (<= b 40000.0) (- (/ b a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 40000.0) {
tmp = -(b / a);
} else {
tmp = c / b;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 40000.0d0) then
tmp = -(b / a)
else
tmp = c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 40000.0) {
tmp = -(b / a);
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 40000.0: tmp = -(b / a) else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 40000.0) tmp = Float64(-Float64(b / a)); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 40000.0) tmp = -(b / a); else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 40000.0], (-N[(b / a), $MachinePrecision]), N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 40000:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 4e4Initial program 62.2%
*-commutative62.2%
Simplified62.3%
Taylor expanded in b around -inf 50.4%
associate-*r/50.4%
mul-1-neg50.4%
Simplified50.4%
if 4e4 < b Initial program 15.1%
*-commutative15.1%
Simplified15.1%
Applied egg-rr3.9%
unpow-13.9%
associate-/l*3.9%
Simplified3.9%
Taylor expanded in b around -inf 32.1%
Final simplification45.0%
(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 48.4%
*-commutative48.4%
Simplified48.5%
Applied egg-rr27.8%
unpow-127.8%
associate-/l*27.8%
Simplified27.8%
Taylor expanded in b around -inf 11.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 48.4%
*-commutative48.4%
Simplified48.5%
Applied egg-rr27.8%
unpow-127.8%
associate-/l*27.8%
Simplified27.8%
Taylor expanded in a around 0 2.7%
herbie shell --seed 2024170
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))