
(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 -7.6e+82)
(- (/ c b) (/ b a))
(if (<= b 4.5e-79)
(/ (- (pow (fma a (* c -4.0) (pow b 2.0)) 0.5) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7.6e+82) {
tmp = (c / b) - (b / a);
} else if (b <= 4.5e-79) {
tmp = (pow(fma(a, (c * -4.0), pow(b, 2.0)), 0.5) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -7.6e+82) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 4.5e-79) tmp = Float64(Float64((fma(a, Float64(c * -4.0), (b ^ 2.0)) ^ 0.5) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -7.6e+82], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.5e-79], N[(N[(N[Power[N[(a * N[(c * -4.0), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7.6 \cdot 10^{+82}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-79}:\\
\;\;\;\;\frac{{\left(\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)\right)}^{0.5} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -7.60000000000000067e82Initial program 56.8%
*-commutative56.8%
Simplified56.8%
Taylor expanded in b around -inf 93.7%
mul-1-neg93.7%
distribute-rgt-neg-in93.7%
+-commutative93.7%
mul-1-neg93.7%
unsub-neg93.7%
Simplified93.7%
Taylor expanded in a around inf 94.0%
+-commutative94.0%
mul-1-neg94.0%
unsub-neg94.0%
Simplified94.0%
if -7.60000000000000067e82 < b < 4.5000000000000003e-79Initial program 79.4%
*-commutative79.4%
Simplified79.4%
sub-neg79.4%
+-commutative79.4%
distribute-lft-neg-in79.4%
*-commutative79.4%
distribute-rgt-neg-in79.4%
metadata-eval79.4%
associate-*r*79.4%
*-commutative79.4%
fma-undefine79.4%
pow1/279.4%
pow279.4%
Applied egg-rr79.4%
if 4.5000000000000003e-79 < b Initial program 14.5%
*-commutative14.5%
Simplified14.5%
Taylor expanded in b around inf 87.7%
associate-*r/87.7%
mul-1-neg87.7%
Simplified87.7%
Final simplification86.2%
(FPCore (a b c)
:precision binary64
(if (<= b -7.5e+81)
(- (/ c b) (/ b a))
(if (<= b 1.4e-78)
(/ (- (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 <= -7.5e+81) {
tmp = (c / b) - (b / a);
} else if (b <= 1.4e-78) {
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 <= (-7.5d+81)) then
tmp = (c / b) - (b / a)
else if (b <= 1.4d-78) 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 <= -7.5e+81) {
tmp = (c / b) - (b / a);
} else if (b <= 1.4e-78) {
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 <= -7.5e+81: tmp = (c / b) - (b / a) elif b <= 1.4e-78: 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 <= -7.5e+81) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.4e-78) 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 <= -7.5e+81) tmp = (c / b) - (b / a); elseif (b <= 1.4e-78) 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, -7.5e+81], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.4e-78], 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 -7.5 \cdot 10^{+81}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{-78}:\\
\;\;\;\;\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 < -7.49999999999999973e81Initial program 56.8%
*-commutative56.8%
Simplified56.8%
Taylor expanded in b around -inf 93.7%
mul-1-neg93.7%
distribute-rgt-neg-in93.7%
+-commutative93.7%
mul-1-neg93.7%
unsub-neg93.7%
Simplified93.7%
Taylor expanded in a around inf 94.0%
+-commutative94.0%
mul-1-neg94.0%
unsub-neg94.0%
Simplified94.0%
if -7.49999999999999973e81 < b < 1.40000000000000012e-78Initial program 79.4%
if 1.40000000000000012e-78 < b Initial program 14.5%
*-commutative14.5%
Simplified14.5%
Taylor expanded in b around inf 87.7%
associate-*r/87.7%
mul-1-neg87.7%
Simplified87.7%
Final simplification86.2%
(FPCore (a b c)
:precision binary64
(if (<= b -1.8e-103)
(- (/ c b) (/ b a))
(if (<= b 1.05e-78)
(/ (+ b (+ (sqrt (* a (* c -4.0))) (+ b b))) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.8e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 1.05e-78) {
tmp = (b + (sqrt((a * (c * -4.0))) + (b + 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.8d-103)) then
tmp = (c / b) - (b / a)
else if (b <= 1.05d-78) then
tmp = (b + (sqrt((a * (c * (-4.0d0)))) + (b + 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.8e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 1.05e-78) {
tmp = (b + (Math.sqrt((a * (c * -4.0))) + (b + b))) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.8e-103: tmp = (c / b) - (b / a) elif b <= 1.05e-78: tmp = (b + (math.sqrt((a * (c * -4.0))) + (b + b))) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.8e-103) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.05e-78) tmp = Float64(Float64(b + Float64(sqrt(Float64(a * Float64(c * -4.0))) + Float64(b + 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 <= -1.8e-103) tmp = (c / b) - (b / a); elseif (b <= 1.05e-78) tmp = (b + (sqrt((a * (c * -4.0))) + (b + b))) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.8e-103], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.05e-78], N[(N[(b + N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + N[(b + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.8 \cdot 10^{-103}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{-78}:\\
\;\;\;\;\frac{b + \left(\sqrt{a \cdot \left(c \cdot -4\right)} + \left(b + b\right)\right)}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.7999999999999999e-103Initial program 70.1%
*-commutative70.1%
Simplified70.1%
Taylor expanded in b around -inf 86.6%
mul-1-neg86.6%
distribute-rgt-neg-in86.6%
+-commutative86.6%
mul-1-neg86.6%
unsub-neg86.6%
Simplified86.6%
Taylor expanded in a around inf 86.8%
+-commutative86.8%
mul-1-neg86.8%
unsub-neg86.8%
Simplified86.8%
if -1.7999999999999999e-103 < b < 1.05e-78Initial program 71.1%
*-commutative71.1%
Simplified71.1%
*-un-lft-identity71.1%
*-un-lft-identity71.1%
prod-diff71.1%
*-commutative71.1%
*-un-lft-identity71.1%
fma-define71.1%
*-un-lft-identity71.1%
+-commutative71.1%
add-sqr-sqrt22.2%
sqrt-unprod70.2%
sqr-neg70.2%
sqrt-prod48.7%
add-sqr-sqrt70.4%
pow270.4%
add-sqr-sqrt21.7%
sqrt-unprod70.5%
sqr-neg70.5%
sqrt-prod48.8%
add-sqr-sqrt70.6%
*-commutative70.6%
*-un-lft-identity70.6%
Applied egg-rr70.6%
associate-+l+70.6%
fma-undefine70.6%
*-rgt-identity70.6%
Simplified70.6%
Taylor expanded in a around inf 70.2%
*-commutative70.2%
associate-*r*70.5%
Simplified70.5%
if 1.05e-78 < b Initial program 14.5%
*-commutative14.5%
Simplified14.5%
Taylor expanded in b around inf 87.7%
associate-*r/87.7%
mul-1-neg87.7%
Simplified87.7%
Final simplification83.4%
(FPCore (a b c)
:precision binary64
(if (<= b -1.65e-103)
(- (/ c b) (/ b a))
(if (<= b 1.65e-78)
(/ (- (pow (* a (* c -4.0)) 0.5) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.65e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 1.65e-78) {
tmp = (pow((a * (c * -4.0)), 0.5) - 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.65d-103)) then
tmp = (c / b) - (b / a)
else if (b <= 1.65d-78) then
tmp = (((a * (c * (-4.0d0))) ** 0.5d0) - 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.65e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 1.65e-78) {
tmp = (Math.pow((a * (c * -4.0)), 0.5) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.65e-103: tmp = (c / b) - (b / a) elif b <= 1.65e-78: tmp = (math.pow((a * (c * -4.0)), 0.5) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.65e-103) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.65e-78) tmp = Float64(Float64((Float64(a * Float64(c * -4.0)) ^ 0.5) - 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 <= -1.65e-103) tmp = (c / b) - (b / a); elseif (b <= 1.65e-78) tmp = (((a * (c * -4.0)) ^ 0.5) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.65e-103], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.65e-78], N[(N[(N[Power[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.65 \cdot 10^{-103}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.65 \cdot 10^{-78}:\\
\;\;\;\;\frac{{\left(a \cdot \left(c \cdot -4\right)\right)}^{0.5} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.64999999999999995e-103Initial program 70.1%
*-commutative70.1%
Simplified70.1%
Taylor expanded in b around -inf 86.6%
mul-1-neg86.6%
distribute-rgt-neg-in86.6%
+-commutative86.6%
mul-1-neg86.6%
unsub-neg86.6%
Simplified86.6%
Taylor expanded in a around inf 86.8%
+-commutative86.8%
mul-1-neg86.8%
unsub-neg86.8%
Simplified86.8%
if -1.64999999999999995e-103 < b < 1.64999999999999991e-78Initial program 71.1%
*-commutative71.1%
Simplified71.1%
sub-neg71.1%
+-commutative71.1%
distribute-lft-neg-in71.1%
*-commutative71.1%
distribute-rgt-neg-in71.1%
metadata-eval71.1%
associate-*r*71.1%
*-commutative71.1%
fma-undefine71.1%
pow1/271.1%
pow271.1%
Applied egg-rr71.1%
Taylor expanded in a around inf 70.0%
*-commutative70.2%
associate-*r*70.5%
Simplified70.4%
if 1.64999999999999991e-78 < b Initial program 14.5%
*-commutative14.5%
Simplified14.5%
Taylor expanded in b around inf 87.7%
associate-*r/87.7%
mul-1-neg87.7%
Simplified87.7%
Final simplification83.3%
(FPCore (a b c)
:precision binary64
(if (<= b -2.2e-103)
(- (/ c b) (/ b a))
(if (<= b 3.1e-83)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.2e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 3.1e-83) {
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 <= (-2.2d-103)) then
tmp = (c / b) - (b / a)
else if (b <= 3.1d-83) 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 <= -2.2e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 3.1e-83) {
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 <= -2.2e-103: tmp = (c / b) - (b / a) elif b <= 3.1e-83: 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 <= -2.2e-103) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3.1e-83) 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 <= -2.2e-103) tmp = (c / b) - (b / a); elseif (b <= 3.1e-83) 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, -2.2e-103], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.1e-83], 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 -2.2 \cdot 10^{-103}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.1 \cdot 10^{-83}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -2.1999999999999999e-103Initial program 70.1%
*-commutative70.1%
Simplified70.1%
Taylor expanded in b around -inf 86.6%
mul-1-neg86.6%
distribute-rgt-neg-in86.6%
+-commutative86.6%
mul-1-neg86.6%
unsub-neg86.6%
Simplified86.6%
Taylor expanded in a around inf 86.8%
+-commutative86.8%
mul-1-neg86.8%
unsub-neg86.8%
Simplified86.8%
if -2.1999999999999999e-103 < b < 3.09999999999999992e-83Initial program 71.1%
*-commutative71.1%
Simplified71.1%
Taylor expanded in b around 0 70.0%
*-commutative70.0%
associate-*r*70.4%
Simplified70.4%
+-commutative70.4%
unsub-neg70.4%
Applied egg-rr70.4%
if 3.09999999999999992e-83 < b Initial program 14.5%
*-commutative14.5%
Simplified14.5%
Taylor expanded in b around inf 87.7%
associate-*r/87.7%
mul-1-neg87.7%
Simplified87.7%
Final simplification83.3%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (- (/ c b) (/ b a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-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 <= (-1d-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 <= -1e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = (c / b) - (b / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = Float64(Float64(c / b) - 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 <= -1e-310) tmp = (c / b) - (b / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-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 -1 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 70.7%
*-commutative70.7%
Simplified70.7%
Taylor expanded in b around -inf 73.6%
mul-1-neg73.6%
distribute-rgt-neg-in73.6%
+-commutative73.6%
mul-1-neg73.6%
unsub-neg73.6%
Simplified73.6%
Taylor expanded in a around inf 74.8%
+-commutative74.8%
mul-1-neg74.8%
unsub-neg74.8%
Simplified74.8%
if -9.999999999999969e-311 < b Initial program 30.9%
*-commutative30.9%
Simplified30.9%
Taylor expanded in b around inf 66.7%
associate-*r/66.7%
mul-1-neg66.7%
Simplified66.7%
Final simplification70.3%
(FPCore (a b c) :precision binary64 (if (<= b 1.8e-306) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.8e-306) {
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.8d-306) 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.8e-306) {
tmp = b / -a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.8e-306: tmp = b / -a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.8e-306) 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 <= 1.8e-306) tmp = b / -a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.8e-306], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.8 \cdot 10^{-306}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < 1.79999999999999996e-306Initial program 70.9%
*-commutative70.9%
Simplified70.9%
Taylor expanded in b around -inf 73.8%
associate-*r/73.8%
mul-1-neg73.8%
Simplified73.8%
if 1.79999999999999996e-306 < b Initial program 30.4%
*-commutative30.4%
Simplified30.4%
Taylor expanded in b around inf 67.1%
associate-*r/67.1%
mul-1-neg67.1%
Simplified67.1%
Final simplification70.1%
(FPCore (a b c) :precision binary64 (if (<= b 1.4e-46) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.4e-46) {
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.4d-46) 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.4e-46) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.4e-46: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.4e-46) 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.4e-46) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.4e-46], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.4 \cdot 10^{-46}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.3999999999999999e-46Initial program 69.0%
*-commutative69.0%
Simplified69.0%
Taylor expanded in b around -inf 53.5%
associate-*r/53.5%
mul-1-neg53.5%
Simplified53.5%
if 1.3999999999999999e-46 < b Initial program 14.1%
*-commutative14.1%
Simplified14.1%
Taylor expanded in b around -inf 2.4%
mul-1-neg2.4%
distribute-rgt-neg-in2.4%
+-commutative2.4%
mul-1-neg2.4%
unsub-neg2.4%
Simplified2.4%
Taylor expanded in b around 0 17.8%
Final simplification40.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 48.6%
*-commutative48.6%
Simplified48.6%
Taylor expanded in b around -inf 33.9%
mul-1-neg33.9%
distribute-rgt-neg-in33.9%
+-commutative33.9%
mul-1-neg33.9%
unsub-neg33.9%
Simplified33.9%
Taylor expanded in b around 0 8.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 48.6%
*-commutative48.6%
Simplified48.6%
*-un-lft-identity48.6%
*-un-lft-identity48.6%
prod-diff48.6%
*-commutative48.6%
*-un-lft-identity48.6%
fma-define48.6%
*-un-lft-identity48.6%
+-commutative48.6%
add-sqr-sqrt31.4%
sqrt-unprod46.0%
sqr-neg46.0%
sqrt-prod14.6%
add-sqr-sqrt28.3%
pow228.3%
add-sqr-sqrt14.6%
sqrt-unprod28.3%
sqr-neg28.3%
sqrt-prod14.6%
add-sqr-sqrt27.9%
*-commutative27.9%
*-un-lft-identity27.9%
Applied egg-rr27.9%
associate-+l+27.9%
fma-undefine27.9%
*-rgt-identity27.9%
Simplified27.9%
Taylor expanded in b around -inf 2.6%
herbie shell --seed 2024110
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))