
(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+138)
(- (/ c b) (/ b a))
(if (<= b 9.5e-15)
(- (/ b (* a -2.0)) (/ (sqrt (fma a (* c -4.0) (pow b 2.0))) (* a -2.0)))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e+138) {
tmp = (c / b) - (b / a);
} else if (b <= 9.5e-15) {
tmp = (b / (a * -2.0)) - (sqrt(fma(a, (c * -4.0), pow(b, 2.0))) / (a * -2.0));
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4e+138) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 9.5e-15) tmp = Float64(Float64(b / Float64(a * -2.0)) - Float64(sqrt(fma(a, Float64(c * -4.0), (b ^ 2.0))) / Float64(a * -2.0))); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4e+138], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9.5e-15], N[(N[(b / N[(a * -2.0), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(a * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{+138}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 9.5 \cdot 10^{-15}:\\
\;\;\;\;\frac{b}{a \cdot -2} - \frac{\sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)}}{a \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.0000000000000001e138Initial program 46.6%
*-commutative46.6%
Simplified46.6%
Taylor expanded in b around -inf 94.1%
mul-1-neg94.1%
*-commutative94.1%
distribute-rgt-neg-in94.1%
+-commutative94.1%
mul-1-neg94.1%
unsub-neg94.1%
Simplified94.1%
Taylor expanded in a around inf 95.0%
neg-mul-195.0%
+-commutative95.0%
unsub-neg95.0%
Simplified95.0%
if -4.0000000000000001e138 < b < 9.5000000000000005e-15Initial program 80.6%
*-commutative80.6%
Simplified80.6%
Applied egg-rr48.9%
unpow-148.9%
*-commutative48.9%
*-lft-identity48.9%
times-frac48.9%
metadata-eval48.9%
Simplified48.9%
associate-*r/48.9%
*-commutative48.9%
frac-2neg48.9%
distribute-rgt-neg-in48.9%
metadata-eval48.9%
distribute-neg-in48.9%
add-sqr-sqrt25.7%
sqrt-unprod50.6%
sqr-neg50.6%
sqrt-prod25.3%
add-sqr-sqrt80.4%
sub-neg80.4%
Applied egg-rr80.4%
clear-num80.6%
div-sub80.6%
Applied egg-rr80.6%
if 9.5000000000000005e-15 < b Initial program 10.3%
*-commutative10.3%
Simplified10.3%
Taylor expanded in a around 0 87.7%
associate-*r/87.7%
mul-1-neg87.7%
Simplified87.7%
(FPCore (a b c)
:precision binary64
(if (<= b -4.8e+139)
(- (/ c b) (/ b a))
(if (<= b 8.5e-15)
(/ (- (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 <= -4.8e+139) {
tmp = (c / b) - (b / a);
} else if (b <= 8.5e-15) {
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 <= (-4.8d+139)) then
tmp = (c / b) - (b / a)
else if (b <= 8.5d-15) 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 <= -4.8e+139) {
tmp = (c / b) - (b / a);
} else if (b <= 8.5e-15) {
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 <= -4.8e+139: tmp = (c / b) - (b / a) elif b <= 8.5e-15: 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 <= -4.8e+139) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 8.5e-15) 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 <= -4.8e+139) tmp = (c / b) - (b / a); elseif (b <= 8.5e-15) 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, -4.8e+139], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.5e-15], 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 -4.8 \cdot 10^{+139}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-15}:\\
\;\;\;\;\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 < -4.80000000000000016e139Initial program 46.6%
*-commutative46.6%
Simplified46.6%
Taylor expanded in b around -inf 94.1%
mul-1-neg94.1%
*-commutative94.1%
distribute-rgt-neg-in94.1%
+-commutative94.1%
mul-1-neg94.1%
unsub-neg94.1%
Simplified94.1%
Taylor expanded in a around inf 95.0%
neg-mul-195.0%
+-commutative95.0%
unsub-neg95.0%
Simplified95.0%
if -4.80000000000000016e139 < b < 8.50000000000000007e-15Initial program 80.6%
if 8.50000000000000007e-15 < b Initial program 10.3%
*-commutative10.3%
Simplified10.3%
Taylor expanded in a around 0 87.7%
associate-*r/87.7%
mul-1-neg87.7%
Simplified87.7%
Final simplification85.3%
(FPCore (a b c) :precision binary64 (if (<= b -3.5e-92) (- (/ c b) (/ b a)) (if (<= b 2e-14) (/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.5e-92) {
tmp = (c / b) - (b / a);
} else if (b <= 2e-14) {
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 <= (-3.5d-92)) then
tmp = (c / b) - (b / a)
else if (b <= 2d-14) 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 <= -3.5e-92) {
tmp = (c / b) - (b / a);
} else if (b <= 2e-14) {
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 <= -3.5e-92: tmp = (c / b) - (b / a) elif b <= 2e-14: 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 <= -3.5e-92) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 2e-14) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -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 <= -3.5e-92) tmp = (c / b) - (b / a); elseif (b <= 2e-14) 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, -3.5e-92], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e-14], 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 -3.5 \cdot 10^{-92}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -3.5e-92Initial program 69.7%
*-commutative69.7%
Simplified69.7%
Taylor expanded in b around -inf 83.7%
mul-1-neg83.7%
*-commutative83.7%
distribute-rgt-neg-in83.7%
+-commutative83.7%
mul-1-neg83.7%
unsub-neg83.7%
Simplified83.7%
Taylor expanded in a around inf 84.3%
neg-mul-184.3%
+-commutative84.3%
unsub-neg84.3%
Simplified84.3%
if -3.5e-92 < b < 2e-14Initial program 74.8%
*-commutative74.8%
Simplified74.8%
Taylor expanded in a around inf 69.8%
*-commutative69.8%
associate-*r*69.8%
Simplified69.8%
if 2e-14 < b Initial program 10.3%
*-commutative10.3%
Simplified10.3%
Taylor expanded in a around 0 87.7%
associate-*r/87.7%
mul-1-neg87.7%
Simplified87.7%
(FPCore (a b c)
:precision binary64
(if (<= b -5.4e-92)
(- (/ c b) (/ b a))
(if (<= b 1.4e-14)
(* (- (sqrt (* a (* c -4.0))) b) (/ 0.5 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.4e-92) {
tmp = (c / b) - (b / a);
} else if (b <= 1.4e-14) {
tmp = (sqrt((a * (c * -4.0))) - b) * (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 <= (-5.4d-92)) then
tmp = (c / b) - (b / a)
else if (b <= 1.4d-14) then
tmp = (sqrt((a * (c * (-4.0d0)))) - b) * (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 <= -5.4e-92) {
tmp = (c / b) - (b / a);
} else if (b <= 1.4e-14) {
tmp = (Math.sqrt((a * (c * -4.0))) - b) * (0.5 / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.4e-92: tmp = (c / b) - (b / a) elif b <= 1.4e-14: tmp = (math.sqrt((a * (c * -4.0))) - b) * (0.5 / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.4e-92) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.4e-14) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) * Float64(0.5 / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.4e-92) tmp = (c / b) - (b / a); elseif (b <= 1.4e-14) tmp = (sqrt((a * (c * -4.0))) - b) * (0.5 / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.4e-92], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.4e-14], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.4 \cdot 10^{-92}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{-14}:\\
\;\;\;\;\left(\sqrt{a \cdot \left(c \cdot -4\right)} - b\right) \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.3999999999999999e-92Initial program 69.7%
*-commutative69.7%
Simplified69.7%
Taylor expanded in b around -inf 83.7%
mul-1-neg83.7%
*-commutative83.7%
distribute-rgt-neg-in83.7%
+-commutative83.7%
mul-1-neg83.7%
unsub-neg83.7%
Simplified83.7%
Taylor expanded in a around inf 84.3%
neg-mul-184.3%
+-commutative84.3%
unsub-neg84.3%
Simplified84.3%
if -5.3999999999999999e-92 < b < 1.4e-14Initial program 74.8%
*-commutative74.8%
Simplified74.8%
div-sub74.7%
sub-neg74.7%
div-inv74.6%
pow274.6%
*-commutative74.6%
associate-/r*74.6%
metadata-eval74.6%
div-inv74.6%
*-commutative74.6%
associate-/r*74.6%
metadata-eval74.6%
Applied egg-rr74.6%
sub-neg74.6%
distribute-rgt-out--74.6%
Simplified74.6%
Taylor expanded in a around inf 69.7%
*-commutative69.7%
associate-*r*69.7%
Simplified69.7%
if 1.4e-14 < b Initial program 10.3%
*-commutative10.3%
Simplified10.3%
Taylor expanded in a around 0 87.7%
associate-*r/87.7%
mul-1-neg87.7%
Simplified87.7%
Final simplification80.9%
(FPCore (a b c)
:precision binary64
(if (<= b -3.1e-97)
(- (/ c b) (/ b a))
(if (<= b 1.3e-157)
(* (sqrt (* c (/ -4.0 a))) (- -0.5))
(/ 1.0 (- (/ a b) (/ b c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.1e-97) {
tmp = (c / b) - (b / a);
} else if (b <= 1.3e-157) {
tmp = sqrt((c * (-4.0 / a))) * -(-0.5);
} 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.1d-97)) then
tmp = (c / b) - (b / a)
else if (b <= 1.3d-157) then
tmp = sqrt((c * ((-4.0d0) / a))) * -(-0.5d0)
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.1e-97) {
tmp = (c / b) - (b / a);
} else if (b <= 1.3e-157) {
tmp = Math.sqrt((c * (-4.0 / a))) * -(-0.5);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.1e-97: tmp = (c / b) - (b / a) elif b <= 1.3e-157: tmp = math.sqrt((c * (-4.0 / a))) * -(-0.5) else: tmp = 1.0 / ((a / b) - (b / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.1e-97) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.3e-157) tmp = Float64(sqrt(Float64(c * Float64(-4.0 / a))) * Float64(-(-0.5))); 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.1e-97) tmp = (c / b) - (b / a); elseif (b <= 1.3e-157) tmp = sqrt((c * (-4.0 / a))) * -(-0.5); else tmp = 1.0 / ((a / b) - (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.1e-97], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.3e-157], N[(N[Sqrt[N[(c * N[(-4.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (--0.5)), $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.1 \cdot 10^{-97}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.3 \cdot 10^{-157}:\\
\;\;\;\;\sqrt{c \cdot \frac{-4}{a}} \cdot \left(--0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -3.10000000000000002e-97Initial program 70.0%
*-commutative70.0%
Simplified70.0%
Taylor expanded in b around -inf 82.9%
mul-1-neg82.9%
*-commutative82.9%
distribute-rgt-neg-in82.9%
+-commutative82.9%
mul-1-neg82.9%
unsub-neg82.9%
Simplified82.9%
Taylor expanded in a around inf 83.5%
neg-mul-183.5%
+-commutative83.5%
unsub-neg83.5%
Simplified83.5%
if -3.10000000000000002e-97 < b < 1.29999999999999994e-157Initial program 85.1%
*-commutative85.1%
Simplified85.1%
add-cube-cbrt84.6%
pow384.5%
associate-*l*84.5%
Applied egg-rr84.5%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt38.9%
associate-/l*39.0%
rem-cube-cbrt39.1%
Simplified39.1%
if 1.29999999999999994e-157 < b Initial program 20.9%
*-commutative20.9%
Simplified21.0%
Applied egg-rr15.6%
unpow-115.6%
*-commutative15.6%
*-lft-identity15.6%
times-frac15.6%
metadata-eval15.6%
Simplified15.6%
associate-*r/15.6%
*-commutative15.6%
frac-2neg15.6%
distribute-rgt-neg-in15.6%
metadata-eval15.6%
distribute-neg-in15.6%
add-sqr-sqrt0.0%
sqrt-unprod20.1%
sqr-neg20.1%
sqrt-prod18.6%
add-sqr-sqrt20.9%
sub-neg20.9%
Applied egg-rr20.9%
Taylor expanded in a around 0 76.9%
+-commutative76.9%
mul-1-neg76.9%
unsub-neg76.9%
Simplified76.9%
Final simplification71.6%
(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 74.8%
*-commutative74.8%
Simplified74.8%
Taylor expanded in b around -inf 65.6%
mul-1-neg65.6%
*-commutative65.6%
distribute-rgt-neg-in65.6%
+-commutative65.6%
mul-1-neg65.6%
unsub-neg65.6%
Simplified65.6%
Taylor expanded in a around inf 66.3%
neg-mul-166.3%
+-commutative66.3%
unsub-neg66.3%
Simplified66.3%
if -9.999999999999969e-311 < b Initial program 30.9%
*-commutative30.9%
Simplified30.9%
Applied egg-rr26.4%
unpow-126.4%
*-commutative26.4%
*-lft-identity26.4%
times-frac26.4%
metadata-eval26.4%
Simplified26.4%
associate-*r/26.4%
*-commutative26.4%
frac-2neg26.4%
distribute-rgt-neg-in26.4%
metadata-eval26.4%
distribute-neg-in26.4%
add-sqr-sqrt0.0%
sqrt-unprod30.1%
sqr-neg30.1%
sqrt-prod29.0%
add-sqr-sqrt30.9%
sub-neg30.9%
Applied egg-rr30.9%
Taylor expanded in a around 0 65.4%
+-commutative65.4%
mul-1-neg65.4%
unsub-neg65.4%
Simplified65.4%
(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(Float64(-c) / 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 74.8%
*-commutative74.8%
Simplified74.8%
Taylor expanded in b around -inf 65.6%
mul-1-neg65.6%
*-commutative65.6%
distribute-rgt-neg-in65.6%
+-commutative65.6%
mul-1-neg65.6%
unsub-neg65.6%
Simplified65.6%
Taylor expanded in a around inf 66.3%
neg-mul-166.3%
+-commutative66.3%
unsub-neg66.3%
Simplified66.3%
if -9.999999999999969e-311 < b Initial program 30.9%
*-commutative30.9%
Simplified30.9%
Taylor expanded in a around 0 65.2%
associate-*r/65.2%
mul-1-neg65.2%
Simplified65.2%
(FPCore (a b c) :precision binary64 (if (<= b 2.7e-272) (/ b (- a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.7e-272) {
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.7d-272) 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.7e-272) {
tmp = b / -a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.7e-272: tmp = b / -a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.7e-272) tmp = Float64(b / Float64(-a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.7e-272) tmp = b / -a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.7e-272], N[(b / (-a)), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.7 \cdot 10^{-272}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 2.69999999999999993e-272Initial program 75.7%
*-commutative75.7%
Simplified75.7%
Taylor expanded in b around -inf 63.4%
associate-*r/63.4%
mul-1-neg63.4%
Simplified63.4%
if 2.69999999999999993e-272 < b Initial program 28.3%
*-commutative28.3%
Simplified28.3%
Taylor expanded in a around 0 67.6%
associate-*r/67.6%
mul-1-neg67.6%
Simplified67.6%
Final simplification65.5%
(FPCore (a b c) :precision binary64 (if (<= b 4.4e-7) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 4.4e-7) {
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-7) 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-7) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 4.4e-7: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 4.4e-7) 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.4e-7) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 4.4e-7], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4.4 \cdot 10^{-7}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 4.4000000000000002e-7Initial program 72.1%
*-commutative72.1%
Simplified72.1%
Taylor expanded in b around -inf 47.8%
associate-*r/47.8%
mul-1-neg47.8%
Simplified47.8%
if 4.4000000000000002e-7 < b Initial program 10.3%
*-commutative10.3%
Simplified10.3%
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 23.4%
Final simplification39.8%
(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 51.8%
*-commutative51.8%
Simplified51.8%
Taylor expanded in b around -inf 32.4%
mul-1-neg32.4%
*-commutative32.4%
distribute-rgt-neg-in32.4%
+-commutative32.4%
mul-1-neg32.4%
unsub-neg32.4%
Simplified32.4%
Taylor expanded in a around inf 9.8%
(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 51.8%
*-commutative51.8%
Simplified51.8%
Applied egg-rr34.4%
unpow-134.4%
*-commutative34.4%
*-lft-identity34.4%
times-frac34.4%
metadata-eval34.4%
Simplified34.4%
Taylor expanded in a around 0 2.7%
herbie shell --seed 2024133
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))