
(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 -2e+138)
(/ b (- a))
(if (<= b 1.9e-92)
(/ (- (sqrt (- (* b b) (* (* a 4.0) c))) b) (* a 2.0))
(/ (/ 1.0 (fma a (pow b -2.0) (/ -1.0 c))) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e+138) {
tmp = b / -a;
} else if (b <= 1.9e-92) {
tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} else {
tmp = (1.0 / fma(a, pow(b, -2.0), (-1.0 / c))) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2e+138) tmp = Float64(b / Float64(-a)); elseif (b <= 1.9e-92) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(1.0 / fma(a, (b ^ -2.0), Float64(-1.0 / c))) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2e+138], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.9e-92], 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[(N[(1.0 / N[(a * N[Power[b, -2.0], $MachinePrecision] + N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{+138}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-92}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\mathsf{fma}\left(a, {b}^{-2}, \frac{-1}{c}\right)}}{b}\\
\end{array}
\end{array}
if b < -2.0000000000000001e138Initial program 31.4%
*-commutative31.4%
Simplified31.4%
Taylor expanded in b around -inf 90.8%
associate-*r/90.8%
mul-1-neg90.8%
Simplified90.8%
if -2.0000000000000001e138 < b < 1.9e-92Initial program 88.8%
if 1.9e-92 < b Initial program 18.8%
*-commutative18.8%
Simplified18.8%
Applied egg-rr10.2%
unpow-110.2%
associate-/l*10.2%
Simplified10.2%
Taylor expanded in b around -inf 19.9%
associate-*r*19.9%
neg-mul-119.9%
Simplified19.9%
inv-pow19.9%
unpow-prod-down19.9%
inv-pow19.9%
add-sqr-sqrt0.0%
sqrt-unprod60.7%
sqr-neg60.7%
pow260.7%
sqrt-pow186.4%
metadata-eval86.4%
pow186.4%
div-inv86.4%
pow-flip86.4%
metadata-eval86.4%
Applied egg-rr86.4%
associate-*l/86.6%
*-lft-identity86.6%
unpow-186.6%
fma-neg86.6%
distribute-neg-frac86.6%
metadata-eval86.6%
Simplified86.6%
Final simplification88.2%
(FPCore (a b c)
:precision binary64
(if (<= b -8e+136)
(/ b (- a))
(if (<= b 2.95e-92)
(/ (- (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 <= -8e+136) {
tmp = b / -a;
} else if (b <= 2.95e-92) {
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 <= (-8d+136)) then
tmp = b / -a
else if (b <= 2.95d-92) 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 <= -8e+136) {
tmp = b / -a;
} else if (b <= 2.95e-92) {
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 <= -8e+136: tmp = b / -a elif b <= 2.95e-92: 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 <= -8e+136) tmp = Float64(b / Float64(-a)); elseif (b <= 2.95e-92) 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 <= -8e+136) tmp = b / -a; elseif (b <= 2.95e-92) 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, -8e+136], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 2.95e-92], 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 -8 \cdot 10^{+136}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 2.95 \cdot 10^{-92}:\\
\;\;\;\;\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 < -8.00000000000000047e136Initial program 31.4%
*-commutative31.4%
Simplified31.4%
Taylor expanded in b around -inf 90.8%
associate-*r/90.8%
mul-1-neg90.8%
Simplified90.8%
if -8.00000000000000047e136 < b < 2.95e-92Initial program 88.8%
if 2.95e-92 < b Initial program 18.8%
*-commutative18.8%
Simplified18.8%
Taylor expanded in b around inf 86.0%
associate-*r/86.0%
mul-1-neg86.0%
Simplified86.0%
Final simplification87.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.1e-53)
(- (/ c b) (/ b a))
(if (<= b 2.95e-92)
(/ (- (sqrt (* c (* a -4.0))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.1e-53) {
tmp = (c / b) - (b / a);
} else if (b <= 2.95e-92) {
tmp = (sqrt((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 <= (-1.1d-53)) then
tmp = (c / b) - (b / a)
else if (b <= 2.95d-92) then
tmp = (sqrt((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 <= -1.1e-53) {
tmp = (c / b) - (b / a);
} else if (b <= 2.95e-92) {
tmp = (Math.sqrt((c * (a * -4.0))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.1e-53: tmp = (c / b) - (b / a) elif b <= 2.95e-92: tmp = (math.sqrt((c * (a * -4.0))) - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.1e-53) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 2.95e-92) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.1e-53) tmp = (c / b) - (b / a); elseif (b <= 2.95e-92) tmp = (sqrt((c * (a * -4.0))) - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.1e-53], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.95e-92], N[(N[(N[Sqrt[N[(c * N[(a * -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 -1.1 \cdot 10^{-53}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 2.95 \cdot 10^{-92}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.10000000000000009e-53Initial program 62.3%
*-commutative62.3%
Simplified62.3%
Taylor expanded in b around -inf 85.1%
mul-1-neg85.1%
distribute-rgt-neg-in85.1%
+-commutative85.1%
mul-1-neg85.1%
unsub-neg85.1%
Simplified85.1%
Taylor expanded in a around inf 85.5%
neg-mul-185.5%
distribute-frac-neg85.5%
+-commutative85.5%
distribute-frac-neg85.5%
unsub-neg85.5%
Simplified85.5%
if -1.10000000000000009e-53 < b < 2.95e-92Initial program 85.8%
*-commutative85.8%
Simplified85.8%
Taylor expanded in b around 0 79.1%
associate-*r*79.1%
*-commutative79.1%
Simplified79.1%
if 2.95e-92 < b Initial program 18.8%
*-commutative18.8%
Simplified18.8%
Taylor expanded in b around inf 86.0%
associate-*r/86.0%
mul-1-neg86.0%
Simplified86.0%
Final simplification83.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.5e-57)
(- (/ c b) (/ b a))
(if (<= b 7.9e-94)
(* (/ 0.5 a) (- (sqrt (* a (* c -4.0))) b))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e-57) {
tmp = (c / b) - (b / a);
} else if (b <= 7.9e-94) {
tmp = (0.5 / a) * (sqrt((a * (c * -4.0))) - b);
} 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.5d-57)) then
tmp = (c / b) - (b / a)
else if (b <= 7.9d-94) then
tmp = (0.5d0 / a) * (sqrt((a * (c * (-4.0d0)))) - b)
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.5e-57) {
tmp = (c / b) - (b / a);
} else if (b <= 7.9e-94) {
tmp = (0.5 / a) * (Math.sqrt((a * (c * -4.0))) - b);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.5e-57: tmp = (c / b) - (b / a) elif b <= 7.9e-94: tmp = (0.5 / a) * (math.sqrt((a * (c * -4.0))) - b) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.5e-57) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 7.9e-94) tmp = Float64(Float64(0.5 / a) * Float64(sqrt(Float64(a * Float64(c * -4.0))) - b)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.5e-57) tmp = (c / b) - (b / a); elseif (b <= 7.9e-94) tmp = (0.5 / a) * (sqrt((a * (c * -4.0))) - b); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.5e-57], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.9e-94], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{-57}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 7.9 \cdot 10^{-94}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{a \cdot \left(c \cdot -4\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.5e-57Initial program 62.3%
*-commutative62.3%
Simplified62.3%
Taylor expanded in b around -inf 85.1%
mul-1-neg85.1%
distribute-rgt-neg-in85.1%
+-commutative85.1%
mul-1-neg85.1%
unsub-neg85.1%
Simplified85.1%
Taylor expanded in a around inf 85.5%
neg-mul-185.5%
distribute-frac-neg85.5%
+-commutative85.5%
distribute-frac-neg85.5%
unsub-neg85.5%
Simplified85.5%
if -1.5e-57 < b < 7.9e-94Initial program 85.8%
*-commutative85.8%
Simplified85.8%
Applied egg-rr85.7%
sub-neg85.7%
distribute-rgt-out--85.6%
Simplified85.6%
Taylor expanded in a around inf 78.9%
*-commutative78.9%
associate-*r*79.0%
Simplified79.0%
if 7.9e-94 < b Initial program 18.8%
*-commutative18.8%
Simplified18.8%
Taylor expanded in b around inf 86.0%
associate-*r/86.0%
mul-1-neg86.0%
Simplified86.0%
(FPCore (a b c) :precision binary64 (if (<= b -5.9e-211) (- (/ c b) (/ b a)) (if (<= b 1.75e-125) (* (sqrt (* c (/ -4.0 a))) (- -0.5)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.9e-211) {
tmp = (c / b) - (b / a);
} else if (b <= 1.75e-125) {
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 <= (-5.9d-211)) then
tmp = (c / b) - (b / a)
else if (b <= 1.75d-125) 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 <= -5.9e-211) {
tmp = (c / b) - (b / a);
} else if (b <= 1.75e-125) {
tmp = Math.sqrt((c * (-4.0 / a))) * -(-0.5);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.9e-211: tmp = (c / b) - (b / a) elif b <= 1.75e-125: 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 <= -5.9e-211) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.75e-125) tmp = Float64(sqrt(Float64(c * Float64(-4.0 / a))) * Float64(-(-0.5))); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.9e-211) tmp = (c / b) - (b / a); elseif (b <= 1.75e-125) tmp = sqrt((c * (-4.0 / a))) * -(-0.5); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.9e-211], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.75e-125], 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 -5.9 \cdot 10^{-211}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.75 \cdot 10^{-125}:\\
\;\;\;\;\sqrt{c \cdot \frac{-4}{a}} \cdot \left(--0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.9000000000000002e-211Initial program 68.7%
*-commutative68.7%
Simplified68.7%
Taylor expanded in b around -inf 70.5%
mul-1-neg70.5%
distribute-rgt-neg-in70.5%
+-commutative70.5%
mul-1-neg70.5%
unsub-neg70.5%
Simplified70.5%
Taylor expanded in a around inf 72.9%
neg-mul-172.9%
distribute-frac-neg72.9%
+-commutative72.9%
distribute-frac-neg72.9%
unsub-neg72.9%
Simplified72.9%
if -5.9000000000000002e-211 < b < 1.74999999999999999e-125Initial program 84.3%
*-commutative84.3%
Simplified84.3%
add-cube-cbrt83.4%
pow383.4%
Applied egg-rr83.4%
Taylor expanded in a around -inf 0.0%
associate-*r*0.0%
rem-cube-cbrt0.0%
associate-/l*0.0%
unpow20.0%
rem-square-sqrt42.1%
Simplified42.1%
if 1.74999999999999999e-125 < b Initial program 22.2%
*-commutative22.2%
Simplified22.2%
Taylor expanded in b around inf 82.6%
associate-*r/82.6%
mul-1-neg82.6%
Simplified82.6%
Final simplification72.0%
(FPCore (a b c) :precision binary64 (if (<= b -5e-311) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-311) {
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-311)) 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-311) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-311: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-311) 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-311) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-311], 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^{-311}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.00000000000023e-311Initial program 68.4%
*-commutative68.4%
Simplified68.4%
Taylor expanded in b around -inf 65.6%
mul-1-neg65.6%
distribute-rgt-neg-in65.6%
+-commutative65.6%
mul-1-neg65.6%
unsub-neg65.6%
Simplified65.6%
Taylor expanded in a around inf 67.9%
neg-mul-167.9%
distribute-frac-neg67.9%
+-commutative67.9%
distribute-frac-neg67.9%
unsub-neg67.9%
Simplified67.9%
if -5.00000000000023e-311 < b Initial program 38.0%
*-commutative38.0%
Simplified38.0%
Taylor expanded in b around inf 64.5%
associate-*r/64.5%
mul-1-neg64.5%
Simplified64.5%
(FPCore (a b c) :precision binary64 (if (<= b 3.05e-308) (/ b (- a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 3.05e-308) {
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 <= 3.05d-308) 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 <= 3.05e-308) {
tmp = b / -a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 3.05e-308: tmp = b / -a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 3.05e-308) tmp = Float64(b / Float64(-a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 3.05e-308) tmp = b / -a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 3.05e-308], N[(b / (-a)), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.05 \cdot 10^{-308}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 3.0500000000000001e-308Initial program 68.4%
*-commutative68.4%
Simplified68.4%
Taylor expanded in b around -inf 67.4%
associate-*r/67.4%
mul-1-neg67.4%
Simplified67.4%
if 3.0500000000000001e-308 < b Initial program 38.0%
*-commutative38.0%
Simplified38.0%
Taylor expanded in b around inf 64.5%
associate-*r/64.5%
mul-1-neg64.5%
Simplified64.5%
Final simplification65.7%
(FPCore (a b c) :precision binary64 (if (<= b 1.45e+32) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.45e+32) {
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.45d+32) 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.45e+32) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.45e+32: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.45e+32) 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 <= 1.45e+32) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.45e+32], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.45 \cdot 10^{+32}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.45000000000000001e32Initial program 66.9%
*-commutative66.9%
Simplified66.9%
Taylor expanded in b around -inf 42.9%
associate-*r/42.9%
mul-1-neg42.9%
Simplified42.9%
if 1.45000000000000001e32 < b Initial program 16.1%
*-commutative16.1%
Simplified16.1%
Taylor expanded in b around -inf 2.5%
mul-1-neg2.5%
distribute-rgt-neg-in2.5%
+-commutative2.5%
mul-1-neg2.5%
unsub-neg2.5%
Simplified2.5%
Taylor expanded in b around 0 25.3%
Final simplification37.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 50.8%
*-commutative50.8%
Simplified50.8%
Taylor expanded in b around -inf 29.0%
mul-1-neg29.0%
distribute-rgt-neg-in29.0%
+-commutative29.0%
mul-1-neg29.0%
unsub-neg29.0%
Simplified29.0%
Taylor expanded in b around 0 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 50.8%
*-commutative50.8%
Simplified50.8%
Applied egg-rr33.5%
unpow-133.5%
associate-/l*33.5%
Simplified33.5%
Taylor expanded in a around 0 2.8%
herbie shell --seed 2024137
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))