
(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 11 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 -4e+102)
(- (/ c b) (/ b a))
(if (<= b 1.22e-101)
(/ (- (sqrt (fma a (* c -4.0) (* b b))) b) (* a 2.0))
(/ 1.0 (* b (+ (/ a (pow b 2.0)) (/ -1.0 c)))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e+102) {
tmp = (c / b) - (b / a);
} else if (b <= 1.22e-101) {
tmp = (sqrt(fma(a, (c * -4.0), (b * b))) - b) / (a * 2.0);
} else {
tmp = 1.0 / (b * ((a / pow(b, 2.0)) + (-1.0 / c)));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4e+102) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.22e-101) tmp = Float64(Float64(sqrt(fma(a, Float64(c * -4.0), Float64(b * b))) - b) / Float64(a * 2.0)); else tmp = Float64(1.0 / Float64(b * Float64(Float64(a / (b ^ 2.0)) + Float64(-1.0 / c)))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4e+102], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.22e-101], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(N[(a / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{+102}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.22 \cdot 10^{-101}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(\frac{a}{{b}^{2}} + \frac{-1}{c}\right)}\\
\end{array}
\end{array}
if b < -3.99999999999999991e102Initial program 48.3%
*-commutative48.3%
Simplified48.5%
Taylor expanded in b around -inf 91.6%
mul-1-neg91.6%
*-commutative91.6%
distribute-rgt-neg-in91.6%
+-commutative91.6%
mul-1-neg91.6%
unsub-neg91.6%
Simplified91.6%
add-cube-cbrt91.6%
unpow291.6%
times-frac92.1%
pow292.1%
Applied egg-rr92.1%
Taylor expanded in a around inf 92.3%
+-commutative92.3%
mul-1-neg92.3%
unsub-neg92.3%
Simplified92.3%
if -3.99999999999999991e102 < b < 1.2199999999999999e-101Initial program 73.4%
*-commutative73.4%
Simplified73.4%
if 1.2199999999999999e-101 < b Initial program 13.2%
*-commutative13.2%
Simplified13.2%
div-sub12.7%
sub-neg12.7%
div-inv12.5%
pow212.5%
*-commutative12.5%
associate-/r*12.5%
metadata-eval12.5%
div-inv12.7%
*-commutative12.7%
associate-/r*12.7%
metadata-eval12.7%
Applied egg-rr12.7%
sub-neg12.7%
distribute-rgt-out--13.2%
Simplified13.2%
Applied egg-rr13.2%
Taylor expanded in b around inf 90.9%
Final simplification83.8%
(FPCore (a b c)
:precision binary64
(if (<= b -4.6e+102)
(- (/ c b) (/ b a))
(if (<= b 7.5e-101)
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0))
(/ 1.0 (* b (+ (/ a (pow b 2.0)) (/ -1.0 c)))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e+102) {
tmp = (c / b) - (b / a);
} else if (b <= 7.5e-101) {
tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = 1.0 / (b * ((a / pow(b, 2.0)) + (-1.0 / c)));
}
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.6d+102)) then
tmp = (c / b) - (b / a)
else if (b <= 7.5d-101) then
tmp = (sqrt(((b * b) - (c * (a * 4.0d0)))) - b) / (a * 2.0d0)
else
tmp = 1.0d0 / (b * ((a / (b ** 2.0d0)) + ((-1.0d0) / c)))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.6e+102) {
tmp = (c / b) - (b / a);
} else if (b <= 7.5e-101) {
tmp = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = 1.0 / (b * ((a / Math.pow(b, 2.0)) + (-1.0 / c)));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.6e+102: tmp = (c / b) - (b / a) elif b <= 7.5e-101: tmp = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) else: tmp = 1.0 / (b * ((a / math.pow(b, 2.0)) + (-1.0 / c))) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.6e+102) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 7.5e-101) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(1.0 / Float64(b * Float64(Float64(a / (b ^ 2.0)) + Float64(-1.0 / c)))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.6e+102) tmp = (c / b) - (b / a); elseif (b <= 7.5e-101) tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); else tmp = 1.0 / (b * ((a / (b ^ 2.0)) + (-1.0 / c))); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.6e+102], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.5e-101], 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[(1.0 / N[(b * N[(N[(a / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.6 \cdot 10^{+102}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-101}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(\frac{a}{{b}^{2}} + \frac{-1}{c}\right)}\\
\end{array}
\end{array}
if b < -4.5999999999999998e102Initial program 48.3%
*-commutative48.3%
Simplified48.5%
Taylor expanded in b around -inf 91.6%
mul-1-neg91.6%
*-commutative91.6%
distribute-rgt-neg-in91.6%
+-commutative91.6%
mul-1-neg91.6%
unsub-neg91.6%
Simplified91.6%
add-cube-cbrt91.6%
unpow291.6%
times-frac92.1%
pow292.1%
Applied egg-rr92.1%
Taylor expanded in a around inf 92.3%
+-commutative92.3%
mul-1-neg92.3%
unsub-neg92.3%
Simplified92.3%
if -4.5999999999999998e102 < b < 7.5000000000000001e-101Initial program 73.4%
if 7.5000000000000001e-101 < b Initial program 13.2%
*-commutative13.2%
Simplified13.2%
div-sub12.7%
sub-neg12.7%
div-inv12.5%
pow212.5%
*-commutative12.5%
associate-/r*12.5%
metadata-eval12.5%
div-inv12.7%
*-commutative12.7%
associate-/r*12.7%
metadata-eval12.7%
Applied egg-rr12.7%
sub-neg12.7%
distribute-rgt-out--13.2%
Simplified13.2%
Applied egg-rr13.2%
Taylor expanded in b around inf 90.9%
Final simplification83.8%
(FPCore (a b c)
:precision binary64
(if (<= b -1.2e-56)
(- (/ c b) (/ b a))
(if (<= b 6.5e-101)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ 1.0 (* b (+ (/ a (pow b 2.0)) (/ -1.0 c)))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.2e-56) {
tmp = (c / b) - (b / a);
} else if (b <= 6.5e-101) {
tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = 1.0 / (b * ((a / pow(b, 2.0)) + (-1.0 / c)));
}
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-56)) then
tmp = (c / b) - (b / a)
else if (b <= 6.5d-101) then
tmp = (sqrt((a * (c * (-4.0d0)))) - b) / (a * 2.0d0)
else
tmp = 1.0d0 / (b * ((a / (b ** 2.0d0)) + ((-1.0d0) / c)))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.2e-56) {
tmp = (c / b) - (b / a);
} else if (b <= 6.5e-101) {
tmp = (Math.sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = 1.0 / (b * ((a / Math.pow(b, 2.0)) + (-1.0 / c)));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.2e-56: tmp = (c / b) - (b / a) elif b <= 6.5e-101: tmp = (math.sqrt((a * (c * -4.0))) - b) / (a * 2.0) else: tmp = 1.0 / (b * ((a / math.pow(b, 2.0)) + (-1.0 / c))) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.2e-56) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 6.5e-101) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(1.0 / Float64(b * Float64(Float64(a / (b ^ 2.0)) + Float64(-1.0 / c)))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.2e-56) tmp = (c / b) - (b / a); elseif (b <= 6.5e-101) tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0); else tmp = 1.0 / (b * ((a / (b ^ 2.0)) + (-1.0 / c))); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.2e-56], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.5e-101], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(N[(a / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.2 \cdot 10^{-56}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{-101}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(\frac{a}{{b}^{2}} + \frac{-1}{c}\right)}\\
\end{array}
\end{array}
if b < -1.2e-56Initial program 62.4%
*-commutative62.4%
Simplified62.5%
Taylor expanded in b around -inf 81.0%
mul-1-neg81.0%
*-commutative81.0%
distribute-rgt-neg-in81.0%
+-commutative81.0%
mul-1-neg81.0%
unsub-neg81.0%
Simplified81.0%
add-cube-cbrt81.0%
unpow281.0%
times-frac81.4%
pow281.4%
Applied egg-rr81.4%
Taylor expanded in a around inf 81.5%
+-commutative81.5%
mul-1-neg81.5%
unsub-neg81.5%
Simplified81.5%
if -1.2e-56 < b < 6.4999999999999996e-101Initial program 68.9%
*-commutative68.9%
Simplified68.9%
Taylor expanded in a around inf 63.9%
*-commutative63.9%
associate-*r*63.9%
Simplified63.9%
if 6.4999999999999996e-101 < b Initial program 13.2%
*-commutative13.2%
Simplified13.2%
div-sub12.7%
sub-neg12.7%
div-inv12.5%
pow212.5%
*-commutative12.5%
associate-/r*12.5%
metadata-eval12.5%
div-inv12.7%
*-commutative12.7%
associate-/r*12.7%
metadata-eval12.7%
Applied egg-rr12.7%
sub-neg12.7%
distribute-rgt-out--13.2%
Simplified13.2%
Applied egg-rr13.2%
Taylor expanded in b around inf 90.9%
Final simplification80.0%
(FPCore (a b c)
:precision binary64
(if (<= b -1.75e-54)
(- (/ c b) (/ b a))
(if (<= b 3.2e-102)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ 1.0 (- (/ a b) (/ b c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.75e-54) {
tmp = (c / b) - (b / a);
} else if (b <= 3.2e-102) {
tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
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.75d-54)) then
tmp = (c / b) - (b / a)
else if (b <= 3.2d-102) then
tmp = (sqrt((a * (c * (-4.0d0)))) - b) / (a * 2.0d0)
else
tmp = 1.0d0 / ((a / b) - (b / c))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.75e-54) {
tmp = (c / b) - (b / a);
} else if (b <= 3.2e-102) {
tmp = (Math.sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.75e-54: tmp = (c / b) - (b / a) elif b <= 3.2e-102: tmp = (math.sqrt((a * (c * -4.0))) - b) / (a * 2.0) else: tmp = 1.0 / ((a / b) - (b / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.75e-54) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3.2e-102) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.75e-54) tmp = (c / b) - (b / a); elseif (b <= 3.2e-102) tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0); else tmp = 1.0 / ((a / b) - (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.75e-54], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.2e-102], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.75 \cdot 10^{-54}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.2 \cdot 10^{-102}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -1.74999999999999991e-54Initial program 62.4%
*-commutative62.4%
Simplified62.5%
Taylor expanded in b around -inf 81.0%
mul-1-neg81.0%
*-commutative81.0%
distribute-rgt-neg-in81.0%
+-commutative81.0%
mul-1-neg81.0%
unsub-neg81.0%
Simplified81.0%
add-cube-cbrt81.0%
unpow281.0%
times-frac81.4%
pow281.4%
Applied egg-rr81.4%
Taylor expanded in a around inf 81.5%
+-commutative81.5%
mul-1-neg81.5%
unsub-neg81.5%
Simplified81.5%
if -1.74999999999999991e-54 < b < 3.19999999999999986e-102Initial program 68.9%
*-commutative68.9%
Simplified68.9%
Taylor expanded in a around inf 63.9%
*-commutative63.9%
associate-*r*63.9%
Simplified63.9%
if 3.19999999999999986e-102 < b Initial program 13.2%
*-commutative13.2%
Simplified13.2%
div-sub12.7%
sub-neg12.7%
div-inv12.5%
pow212.5%
*-commutative12.5%
associate-/r*12.5%
metadata-eval12.5%
div-inv12.7%
*-commutative12.7%
associate-/r*12.7%
metadata-eval12.7%
Applied egg-rr12.7%
sub-neg12.7%
distribute-rgt-out--13.2%
Simplified13.2%
Applied egg-rr13.2%
Taylor expanded in a around 0 90.9%
neg-mul-190.9%
+-commutative90.9%
sub-neg90.9%
Simplified90.9%
(FPCore (a b c)
:precision binary64
(if (<= b -3.2e-55)
(- (/ c b) (/ b a))
(if (<= b 2.8e-102)
(* (- (sqrt (* a (* c -4.0))) b) (/ 0.5 a))
(/ 1.0 (- (/ a b) (/ b c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.2e-55) {
tmp = (c / b) - (b / a);
} else if (b <= 2.8e-102) {
tmp = (sqrt((a * (c * -4.0))) - b) * (0.5 / a);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
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.2d-55)) then
tmp = (c / b) - (b / a)
else if (b <= 2.8d-102) then
tmp = (sqrt((a * (c * (-4.0d0)))) - b) * (0.5d0 / a)
else
tmp = 1.0d0 / ((a / b) - (b / c))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.2e-55) {
tmp = (c / b) - (b / a);
} else if (b <= 2.8e-102) {
tmp = (Math.sqrt((a * (c * -4.0))) - b) * (0.5 / a);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.2e-55: tmp = (c / b) - (b / a) elif b <= 2.8e-102: tmp = (math.sqrt((a * (c * -4.0))) - b) * (0.5 / a) else: tmp = 1.0 / ((a / b) - (b / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.2e-55) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 2.8e-102) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) * Float64(0.5 / a)); else tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.2e-55) tmp = (c / b) - (b / a); elseif (b <= 2.8e-102) tmp = (sqrt((a * (c * -4.0))) - b) * (0.5 / a); else tmp = 1.0 / ((a / b) - (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.2e-55], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.8e-102], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.2 \cdot 10^{-55}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 2.8 \cdot 10^{-102}:\\
\;\;\;\;\left(\sqrt{a \cdot \left(c \cdot -4\right)} - b\right) \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -3.2000000000000001e-55Initial program 62.4%
*-commutative62.4%
Simplified62.5%
Taylor expanded in b around -inf 81.0%
mul-1-neg81.0%
*-commutative81.0%
distribute-rgt-neg-in81.0%
+-commutative81.0%
mul-1-neg81.0%
unsub-neg81.0%
Simplified81.0%
add-cube-cbrt81.0%
unpow281.0%
times-frac81.4%
pow281.4%
Applied egg-rr81.4%
Taylor expanded in a around inf 81.5%
+-commutative81.5%
mul-1-neg81.5%
unsub-neg81.5%
Simplified81.5%
if -3.2000000000000001e-55 < b < 2.80000000000000013e-102Initial program 68.9%
*-commutative68.9%
Simplified68.9%
div-sub69.0%
sub-neg69.0%
div-inv68.8%
pow268.8%
*-commutative68.8%
associate-/r*68.8%
metadata-eval68.8%
div-inv68.8%
*-commutative68.8%
associate-/r*68.8%
metadata-eval68.8%
Applied egg-rr68.8%
sub-neg68.8%
distribute-rgt-out--68.8%
Simplified68.8%
Taylor expanded in a around inf 63.8%
*-commutative63.8%
associate-*r*63.8%
Simplified63.8%
if 2.80000000000000013e-102 < b Initial program 13.2%
*-commutative13.2%
Simplified13.2%
div-sub12.7%
sub-neg12.7%
div-inv12.5%
pow212.5%
*-commutative12.5%
associate-/r*12.5%
metadata-eval12.5%
div-inv12.7%
*-commutative12.7%
associate-/r*12.7%
metadata-eval12.7%
Applied egg-rr12.7%
sub-neg12.7%
distribute-rgt-out--13.2%
Simplified13.2%
Applied egg-rr13.2%
Taylor expanded in a around 0 90.9%
neg-mul-190.9%
+-commutative90.9%
sub-neg90.9%
Simplified90.9%
Final simplification80.0%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (- (/ c b) (/ b a)) (/ 1.0 (- (/ a b) (/ b c)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
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 = 1.0d0 / ((a / b) - (b / c))
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 = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = (c / b) - (b / a) else: tmp = 1.0 / ((a / b) - (b / c)) 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(1.0 / Float64(Float64(a / b) - Float64(b / c))); 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 = 1.0 / ((a / b) - (b / c)); 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[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 68.6%
*-commutative68.6%
Simplified68.6%
Taylor expanded in b around -inf 59.6%
mul-1-neg59.6%
*-commutative59.6%
distribute-rgt-neg-in59.6%
+-commutative59.6%
mul-1-neg59.6%
unsub-neg59.6%
Simplified59.6%
add-cube-cbrt59.6%
unpow259.6%
times-frac61.7%
pow261.7%
Applied egg-rr61.7%
Taylor expanded in a around inf 61.8%
+-commutative61.8%
mul-1-neg61.8%
unsub-neg61.8%
Simplified61.8%
if -9.999999999999969e-311 < b Initial program 25.0%
*-commutative25.0%
Simplified25.0%
div-sub24.7%
sub-neg24.7%
div-inv24.5%
pow224.5%
*-commutative24.5%
associate-/r*24.5%
metadata-eval24.5%
div-inv24.6%
*-commutative24.6%
associate-/r*24.6%
metadata-eval24.6%
Applied egg-rr24.6%
sub-neg24.6%
distribute-rgt-out--25.0%
Simplified25.0%
Applied egg-rr25.0%
Taylor expanded in a around 0 72.7%
neg-mul-172.7%
+-commutative72.7%
sub-neg72.7%
Simplified72.7%
(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 68.6%
*-commutative68.6%
Simplified68.6%
Taylor expanded in b around -inf 59.6%
mul-1-neg59.6%
*-commutative59.6%
distribute-rgt-neg-in59.6%
+-commutative59.6%
mul-1-neg59.6%
unsub-neg59.6%
Simplified59.6%
add-cube-cbrt59.6%
unpow259.6%
times-frac61.7%
pow261.7%
Applied egg-rr61.7%
Taylor expanded in a around inf 61.8%
+-commutative61.8%
mul-1-neg61.8%
unsub-neg61.8%
Simplified61.8%
if -9.999999999999969e-311 < b Initial program 25.0%
*-commutative25.0%
Simplified25.0%
Taylor expanded in a around 0 72.6%
associate-*r/72.6%
mul-1-neg72.6%
Simplified72.6%
Final simplification67.7%
(FPCore (a b c) :precision binary64 (if (<= b 4.4e-307) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 4.4e-307) {
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.4d-307) 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.4e-307) {
tmp = b / -a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4.4e-307: tmp = b / -a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4.4e-307) 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 <= 4.4e-307) tmp = b / -a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4.4e-307], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.4 \cdot 10^{-307}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < 4.4e-307Initial program 68.8%
*-commutative68.8%
Simplified68.9%
Taylor expanded in b around -inf 60.8%
associate-*r/60.8%
mul-1-neg60.8%
Simplified60.8%
if 4.4e-307 < b Initial program 24.5%
*-commutative24.5%
Simplified24.5%
Taylor expanded in a around 0 73.1%
associate-*r/73.1%
mul-1-neg73.1%
Simplified73.1%
Final simplification67.5%
(FPCore (a b c) :precision binary64 (if (<= b 1.15e+68) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.15e+68) {
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.15d+68) 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.15e+68) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.15e+68: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.15e+68) 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.15e+68) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.15e+68], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.15 \cdot 10^{+68}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.15e68Initial program 56.7%
*-commutative56.7%
Simplified56.8%
Taylor expanded in b around -inf 38.8%
associate-*r/38.8%
mul-1-neg38.8%
Simplified38.8%
if 1.15e68 < b Initial program 10.2%
*-commutative10.2%
Simplified10.2%
Taylor expanded in b around -inf 2.5%
mul-1-neg2.5%
*-commutative2.5%
distribute-rgt-neg-in2.5%
+-commutative2.5%
mul-1-neg2.5%
unsub-neg2.5%
Simplified2.5%
Taylor expanded in a around inf 28.2%
Final simplification36.1%
(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 44.9%
*-commutative44.9%
Simplified45.0%
Taylor expanded in b around -inf 28.5%
mul-1-neg28.5%
*-commutative28.5%
distribute-rgt-neg-in28.5%
+-commutative28.5%
mul-1-neg28.5%
unsub-neg28.5%
Simplified28.5%
Taylor expanded in a around inf 9.7%
(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 44.9%
*-commutative44.9%
Simplified45.0%
Applied egg-rr27.2%
unpow-127.2%
associate-/l*27.2%
Simplified27.2%
Taylor expanded in a around 0 2.5%
herbie shell --seed 2024188
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))