
(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 12 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%
*-commutative93.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%
*-commutative93.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)
(/ (- (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.8e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 1.05e-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.8d-103)) then
tmp = (c / b) - (b / a)
else if (b <= 1.05d-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.8e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 1.05e-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.8e-103: tmp = (c / b) - (b / a) elif b <= 1.05e-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.8e-103) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.05e-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.8e-103) tmp = (c / b) - (b / a); elseif (b <= 1.05e-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.8e-103], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.05e-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.8 \cdot 10^{-103}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.05 \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.7999999999999999e-103Initial program 70.1%
*-commutative70.1%
Simplified70.1%
Taylor expanded in b around -inf 86.6%
mul-1-neg86.6%
*-commutative86.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%
Taylor expanded in b around 0 70.0%
*-commutative70.0%
associate-*r*70.4%
Simplified70.4%
pow1/270.4%
Applied egg-rr70.4%
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.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1.65e-103)
(- (/ c b) (/ b a))
(if (<= b 1.65e-78)
(/ (- (sqrt (* a (* c -4.0))) 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 = (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 <= (-1.65d-103)) then
tmp = (c / b) - (b / a)
else if (b <= 1.65d-78) 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 <= -1.65e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 1.65e-78) {
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 <= -1.65e-103: tmp = (c / b) - (b / a) elif b <= 1.65e-78: 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 <= -1.65e-103) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.65e-78) 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 <= -1.65e-103) tmp = (c / b) - (b / a); elseif (b <= 1.65e-78) 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, -1.65e-103], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.65e-78], 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 -1.65 \cdot 10^{-103}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.65 \cdot 10^{-78}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - 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%
*-commutative86.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%
Taylor expanded in b around 0 70.0%
*-commutative70.0%
associate-*r*70.4%
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 -1.2e-103) (- (/ c b) (/ b a)) (if (<= b 3.1e-83) (/ (* 0.5 (sqrt (* a (* c -4.0)))) a) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.2e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 3.1e-83) {
tmp = (0.5 * sqrt((a * (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.2d-103)) then
tmp = (c / b) - (b / a)
else if (b <= 3.1d-83) then
tmp = (0.5d0 * sqrt((a * (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.2e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 3.1e-83) {
tmp = (0.5 * Math.sqrt((a * (c * -4.0)))) / a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.2e-103: tmp = (c / b) - (b / a) elif b <= 3.1e-83: tmp = (0.5 * math.sqrt((a * (c * -4.0)))) / a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.2e-103) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3.1e-83) tmp = Float64(Float64(0.5 * sqrt(Float64(a * Float64(c * -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.2e-103) tmp = (c / b) - (b / a); elseif (b <= 3.1e-83) tmp = (0.5 * sqrt((a * (c * -4.0)))) / a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.2e-103], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.1e-83], N[(N[(0.5 * N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.2 \cdot 10^{-103}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.1 \cdot 10^{-83}:\\
\;\;\;\;\frac{0.5 \cdot \sqrt{a \cdot \left(c \cdot -4\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.2000000000000001e-103Initial program 70.1%
*-commutative70.1%
Simplified70.1%
Taylor expanded in b around -inf 86.6%
mul-1-neg86.6%
*-commutative86.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.2000000000000001e-103 < b < 3.09999999999999992e-83Initial 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%
Applied egg-rr69.4%
pow169.4%
pow1/269.4%
pow-div70.4%
metadata-eval70.4%
pow1/270.3%
*-un-lft-identity70.3%
*-un-lft-identity70.3%
times-frac70.3%
metadata-eval70.3%
*-un-lft-identity70.3%
*-commutative70.3%
times-frac70.3%
metadata-eval70.3%
+-rgt-identity70.3%
associate-*r*69.9%
Applied egg-rr69.9%
*-lft-identity69.9%
associate-*r/69.9%
associate-*l*70.3%
Simplified70.3%
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 -1.2e-104) (- (/ c b) (/ b a)) (if (<= b 1.6e-76) (* (sqrt (* a (* c -4.0))) (/ 0.5 a)) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.2e-104) {
tmp = (c / b) - (b / a);
} else if (b <= 1.6e-76) {
tmp = 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.2d-104)) then
tmp = (c / b) - (b / a)
else if (b <= 1.6d-76) then
tmp = 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.2e-104) {
tmp = (c / b) - (b / a);
} else if (b <= 1.6e-76) {
tmp = 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.2e-104: tmp = (c / b) - (b / a) elif b <= 1.6e-76: tmp = 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.2e-104) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.6e-76) tmp = Float64(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.2e-104) tmp = (c / b) - (b / a); elseif (b <= 1.6e-76) tmp = 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.2e-104], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.6e-76], N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.2 \cdot 10^{-104}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.6 \cdot 10^{-76}:\\
\;\;\;\;\sqrt{a \cdot \left(c \cdot -4\right)} \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.2e-104Initial program 70.1%
*-commutative70.1%
Simplified70.1%
Taylor expanded in b around -inf 86.6%
mul-1-neg86.6%
*-commutative86.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.2e-104 < b < 1.5999999999999999e-76Initial 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%
Applied egg-rr69.4%
pow169.4%
pow1/269.4%
pow-div70.4%
metadata-eval70.4%
pow1/270.3%
*-un-lft-identity70.3%
*-un-lft-identity70.3%
times-frac70.3%
metadata-eval70.3%
*-un-lft-identity70.3%
*-commutative70.3%
times-frac70.3%
metadata-eval70.3%
+-rgt-identity70.3%
associate-*r*69.9%
Applied egg-rr69.9%
*-lft-identity69.9%
metadata-eval69.9%
times-frac69.9%
associate-*l/69.9%
*-commutative69.9%
associate-*l*70.3%
associate-/r*70.3%
metadata-eval70.3%
Simplified70.3%
if 1.5999999999999999e-76 < 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.4e-105) (- (/ c b) (/ b a)) (if (<= b 3e-185) (sqrt (* c (/ -1.0 a))) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.4e-105) {
tmp = (c / b) - (b / a);
} else if (b <= 3e-185) {
tmp = sqrt((c * (-1.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 <= (-2.4d-105)) then
tmp = (c / b) - (b / a)
else if (b <= 3d-185) then
tmp = sqrt((c * ((-1.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 <= -2.4e-105) {
tmp = (c / b) - (b / a);
} else if (b <= 3e-185) {
tmp = Math.sqrt((c * (-1.0 / a)));
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.4e-105: tmp = (c / b) - (b / a) elif b <= 3e-185: tmp = math.sqrt((c * (-1.0 / a))) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.4e-105) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3e-185) tmp = sqrt(Float64(c * Float64(-1.0 / a))); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.4e-105) tmp = (c / b) - (b / a); elseif (b <= 3e-185) tmp = sqrt((c * (-1.0 / a))); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.4e-105], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3e-185], N[Sqrt[N[(c * N[(-1.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.4 \cdot 10^{-105}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3 \cdot 10^{-185}:\\
\;\;\;\;\sqrt{c \cdot \frac{-1}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -2.40000000000000015e-105Initial program 70.1%
*-commutative70.1%
Simplified70.1%
Taylor expanded in b around -inf 86.6%
mul-1-neg86.6%
*-commutative86.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.40000000000000015e-105 < b < 3.0000000000000003e-185Initial program 73.5%
*-commutative73.5%
Simplified73.5%
sub-neg73.5%
+-commutative73.5%
distribute-lft-neg-in73.5%
*-commutative73.5%
distribute-rgt-neg-in73.5%
metadata-eval73.5%
associate-*r*73.5%
*-commutative73.5%
fma-undefine73.5%
pow1/273.5%
pow273.5%
Applied egg-rr73.5%
Applied egg-rr72.0%
pow172.0%
pow1/271.9%
pow-div73.0%
metadata-eval73.0%
+-rgt-identity73.0%
associate-*r*72.4%
Applied egg-rr72.4%
add-sqr-sqrt40.5%
sqrt-unprod27.5%
frac-times22.2%
unpow1/222.2%
unpow1/222.2%
add-sqr-sqrt22.2%
associate-*l*22.4%
swap-sqr22.4%
pow222.4%
metadata-eval22.4%
Applied egg-rr22.4%
times-frac26.3%
unpow226.3%
associate-/r*40.4%
*-inverses40.4%
associate-/l*40.4%
metadata-eval40.4%
*-commutative40.4%
neg-mul-140.4%
Simplified40.4%
if 3.0000000000000003e-185 < b Initial program 22.7%
*-commutative22.7%
Simplified22.7%
Taylor expanded in b around inf 78.5%
associate-*r/78.5%
mul-1-neg78.5%
Simplified78.5%
Final simplification75.5%
(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%
*-commutative73.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%
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 4.5e-46) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 4.5e-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 <= 4.5d-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 <= 4.5e-46) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4.5e-46: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4.5e-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 <= 4.5e-46) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4.5e-46], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.5 \cdot 10^{-46}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 4.50000000000000001e-46Initial program 69.0%
*-commutative69.0%
Simplified69.0%
Taylor expanded in b around -inf 53.5%
mul-1-neg53.5%
Simplified53.5%
if 4.50000000000000001e-46 < b Initial program 14.1%
*-commutative14.1%
Simplified14.1%
Taylor expanded in b around -inf 2.4%
mul-1-neg2.4%
*-commutative2.4%
distribute-rgt-neg-in2.4%
+-commutative2.4%
mul-1-neg2.4%
unsub-neg2.4%
Simplified2.4%
Taylor expanded in a around inf 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%
*-commutative33.9%
distribute-rgt-neg-in33.9%
+-commutative33.9%
mul-1-neg33.9%
unsub-neg33.9%
Simplified33.9%
Taylor expanded in a around inf 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%
+-commutative27.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)))