
(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 -1e+154)
(- (/ c b) (/ b a))
(if (<= b 1.42e-98)
(/ (- (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 <= -1e+154) {
tmp = (c / b) - (b / a);
} else if (b <= 1.42e-98) {
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 <= (-1d+154)) then
tmp = (c / b) - (b / a)
else if (b <= 1.42d-98) 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 <= -1e+154) {
tmp = (c / b) - (b / a);
} else if (b <= 1.42e-98) {
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 <= -1e+154: tmp = (c / b) - (b / a) elif b <= 1.42e-98: 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 <= -1e+154) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.42e-98) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - 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 <= -1e+154) tmp = (c / b) - (b / a); elseif (b <= 1.42e-98) 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, -1e+154], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.42e-98], 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 -1 \cdot 10^{+154}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.42 \cdot 10^{-98}:\\
\;\;\;\;\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 < -1.00000000000000004e154Initial program 43.1%
*-commutative43.1%
Simplified43.1%
Taylor expanded in b around -inf 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
if -1.00000000000000004e154 < b < 1.41999999999999999e-98Initial program 87.2%
if 1.41999999999999999e-98 < b Initial program 19.2%
*-commutative19.2%
Simplified19.2%
Taylor expanded in b around inf 93.5%
mul-1-neg93.5%
distribute-neg-frac93.5%
Simplified93.5%
Final simplification91.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.55e-90)
(- (/ c b) (/ b a))
(if (<= b 3.5e-99)
(* (/ 0.5 a) (+ b (sqrt (* c (* a -4.0)))))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.55e-90) {
tmp = (c / b) - (b / a);
} else if (b <= 3.5e-99) {
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.55d-90)) then
tmp = (c / b) - (b / a)
else if (b <= 3.5d-99) 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.55e-90) {
tmp = (c / b) - (b / a);
} else if (b <= 3.5e-99) {
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.55e-90: tmp = (c / b) - (b / a) elif b <= 3.5e-99: 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.55e-90) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3.5e-99) 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.55e-90) tmp = (c / b) - (b / a); elseif (b <= 3.5e-99) 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.55e-90], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.5e-99], 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.55 \cdot 10^{-90}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-99}:\\
\;\;\;\;\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.5500000000000001e-90Initial program 74.9%
*-commutative74.9%
Simplified74.9%
Taylor expanded in b around -inf 91.1%
+-commutative91.1%
mul-1-neg91.1%
unsub-neg91.1%
Simplified91.1%
if -1.5500000000000001e-90 < b < 3.4999999999999999e-99Initial program 74.9%
*-commutative74.9%
Simplified74.9%
clear-num75.0%
associate-/r/74.9%
*-commutative74.9%
associate-/r*74.9%
metadata-eval74.9%
add-sqr-sqrt47.3%
sqrt-unprod74.6%
sqr-neg74.6%
sqrt-prod27.4%
add-sqr-sqrt71.0%
fma-neg71.0%
*-commutative71.0%
distribute-rgt-neg-in71.0%
*-commutative71.0%
distribute-rgt-neg-in71.0%
metadata-eval71.0%
Applied egg-rr71.0%
Taylor expanded in b around 0 70.9%
associate-*r*70.9%
*-commutative70.9%
*-commutative70.9%
Simplified70.9%
if 3.4999999999999999e-99 < b Initial program 19.2%
*-commutative19.2%
Simplified19.2%
Taylor expanded in b around inf 93.5%
mul-1-neg93.5%
distribute-neg-frac93.5%
Simplified93.5%
Final simplification87.7%
(FPCore (a b c) :precision binary64 (if (<= b -1.5e-90) (- (/ c b) (/ b a)) (if (<= b 8e-99) (/ 0.5 (/ a (+ b (sqrt (* a (* c -4.0)))))) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e-90) {
tmp = (c / b) - (b / a);
} else if (b <= 8e-99) {
tmp = 0.5 / (a / (b + sqrt((a * (c * -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.5d-90)) then
tmp = (c / b) - (b / a)
else if (b <= 8d-99) then
tmp = 0.5d0 / (a / (b + sqrt((a * (c * (-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.5e-90) {
tmp = (c / b) - (b / a);
} else if (b <= 8e-99) {
tmp = 0.5 / (a / (b + Math.sqrt((a * (c * -4.0)))));
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.5e-90: tmp = (c / b) - (b / a) elif b <= 8e-99: tmp = 0.5 / (a / (b + math.sqrt((a * (c * -4.0))))) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.5e-90) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 8e-99) tmp = Float64(0.5 / Float64(a / Float64(b + sqrt(Float64(a * Float64(c * -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.5e-90) tmp = (c / b) - (b / a); elseif (b <= 8e-99) tmp = 0.5 / (a / (b + sqrt((a * (c * -4.0))))); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.5e-90], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e-99], N[(0.5 / N[(a / N[(b + N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{-90}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 8 \cdot 10^{-99}:\\
\;\;\;\;\frac{0.5}{\frac{a}{b + \sqrt{a \cdot \left(c \cdot -4\right)}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.5000000000000001e-90Initial program 74.9%
*-commutative74.9%
Simplified74.9%
Taylor expanded in b around -inf 91.1%
+-commutative91.1%
mul-1-neg91.1%
unsub-neg91.1%
Simplified91.1%
if -1.5000000000000001e-90 < b < 8.0000000000000002e-99Initial program 74.9%
*-commutative74.9%
Simplified74.9%
clear-num75.0%
associate-/r/74.9%
*-commutative74.9%
associate-/r*74.9%
metadata-eval74.9%
add-sqr-sqrt47.3%
sqrt-unprod74.6%
sqr-neg74.6%
sqrt-prod27.4%
add-sqr-sqrt71.0%
fma-neg71.0%
*-commutative71.0%
distribute-rgt-neg-in71.0%
*-commutative71.0%
distribute-rgt-neg-in71.0%
metadata-eval71.0%
Applied egg-rr71.0%
Taylor expanded in b around 0 70.9%
associate-*r*70.9%
*-commutative70.9%
*-commutative70.9%
Simplified70.9%
associate-*l/70.9%
associate-/l*71.0%
*-commutative71.0%
associate-*l*71.0%
Applied egg-rr71.0%
if 8.0000000000000002e-99 < b Initial program 19.2%
*-commutative19.2%
Simplified19.2%
Taylor expanded in b around inf 93.5%
mul-1-neg93.5%
distribute-neg-frac93.5%
Simplified93.5%
Final simplification87.7%
(FPCore (a b c)
:precision binary64
(if (<= b -3e-69)
(- (/ c b) (/ b a))
(if (<= b 1.05e-98)
(/ (- (sqrt (* c (* a -4.0))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3e-69) {
tmp = (c / b) - (b / a);
} else if (b <= 1.05e-98) {
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 <= (-3d-69)) then
tmp = (c / b) - (b / a)
else if (b <= 1.05d-98) 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 <= -3e-69) {
tmp = (c / b) - (b / a);
} else if (b <= 1.05e-98) {
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 <= -3e-69: tmp = (c / b) - (b / a) elif b <= 1.05e-98: 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 <= -3e-69) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.05e-98) 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 <= -3e-69) tmp = (c / b) - (b / a); elseif (b <= 1.05e-98) 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, -3e-69], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.05e-98], 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 -3 \cdot 10^{-69}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{-98}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -2.99999999999999989e-69Initial program 73.9%
*-commutative73.9%
Simplified73.9%
Taylor expanded in b around -inf 92.6%
+-commutative92.6%
mul-1-neg92.6%
unsub-neg92.6%
Simplified92.6%
if -2.99999999999999989e-69 < b < 1.04999999999999996e-98Initial program 76.6%
*-commutative76.6%
Simplified76.6%
Taylor expanded in b around 0 70.7%
*-commutative70.7%
*-commutative70.7%
associate-*r*70.8%
Simplified70.8%
+-commutative70.8%
unsub-neg70.8%
Applied egg-rr70.8%
if 1.04999999999999996e-98 < b Initial program 19.2%
*-commutative19.2%
Simplified19.2%
Taylor expanded in b around inf 93.5%
mul-1-neg93.5%
distribute-neg-frac93.5%
Simplified93.5%
Final simplification87.9%
(FPCore (a b c) :precision binary64 (if (<= b -5e-312) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-312) {
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-312)) 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-312) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-312: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-312) 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-312) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-312], 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^{-312}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.0000000000022e-312Initial program 75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in b around -inf 72.1%
+-commutative72.1%
mul-1-neg72.1%
unsub-neg72.1%
Simplified72.1%
if -5.0000000000022e-312 < b Initial program 28.5%
*-commutative28.5%
Simplified28.5%
Taylor expanded in b around inf 77.3%
mul-1-neg77.3%
distribute-neg-frac77.3%
Simplified77.3%
Final simplification74.5%
(FPCore (a b c) :precision binary64 (if (<= b 2.5e+75) (/ (- b) a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.5e+75) {
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 <= 2.5d+75) 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 <= 2.5e+75) {
tmp = -b / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.5e+75: tmp = -b / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.5e+75) 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 <= 2.5e+75) tmp = -b / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.5e+75], N[((-b) / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.5 \cdot 10^{+75}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 2.5000000000000001e75Initial program 65.2%
*-commutative65.2%
Simplified65.2%
Taylor expanded in b around -inf 52.1%
associate-*r/52.1%
mul-1-neg52.1%
Simplified52.1%
if 2.5000000000000001e75 < b Initial program 19.7%
*-commutative19.7%
Simplified19.7%
clear-num19.7%
associate-/r/19.7%
*-commutative19.7%
associate-/r*19.7%
metadata-eval19.7%
add-sqr-sqrt0.0%
sqrt-unprod3.8%
sqr-neg3.8%
sqrt-prod3.8%
add-sqr-sqrt3.8%
fma-neg3.8%
*-commutative3.8%
distribute-rgt-neg-in3.8%
*-commutative3.8%
distribute-rgt-neg-in3.8%
metadata-eval3.8%
Applied egg-rr3.8%
Taylor expanded in b around -inf 42.6%
Final simplification49.8%
(FPCore (a b c) :precision binary64 (if (<= b -5e-312) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-312) {
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-312)) 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-312) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-312: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-312) 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-312) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-312], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-312}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.0000000000022e-312Initial program 75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in b around -inf 71.5%
associate-*r/71.5%
mul-1-neg71.5%
Simplified71.5%
if -5.0000000000022e-312 < b Initial program 28.5%
*-commutative28.5%
Simplified28.5%
Taylor expanded in b around inf 77.3%
mul-1-neg77.3%
distribute-neg-frac77.3%
Simplified77.3%
Final simplification74.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 54.2%
*-commutative54.2%
Simplified54.2%
clear-num54.2%
associate-/r/54.1%
*-commutative54.1%
associate-/r*54.1%
metadata-eval54.1%
add-sqr-sqrt41.0%
sqrt-unprod49.8%
sqr-neg49.8%
sqrt-prod8.8%
add-sqr-sqrt29.3%
fma-neg29.3%
*-commutative29.3%
distribute-rgt-neg-in29.3%
*-commutative29.3%
distribute-rgt-neg-in29.3%
metadata-eval29.3%
Applied egg-rr29.3%
Taylor expanded in a around 0 2.3%
Final simplification2.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 54.2%
*-commutative54.2%
Simplified54.2%
clear-num54.2%
associate-/r/54.1%
*-commutative54.1%
associate-/r*54.1%
metadata-eval54.1%
add-sqr-sqrt41.0%
sqrt-unprod49.8%
sqr-neg49.8%
sqrt-prod8.8%
add-sqr-sqrt29.3%
fma-neg29.3%
*-commutative29.3%
distribute-rgt-neg-in29.3%
*-commutative29.3%
distribute-rgt-neg-in29.3%
metadata-eval29.3%
Applied egg-rr29.3%
Taylor expanded in b around -inf 12.8%
Final simplification12.8%
herbie shell --seed 2023306
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))