
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.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) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \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) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.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) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -5e+108)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2.55e-48)
(/ (- (sqrt (- (* b b) (* (* 3.0 a) c))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+108) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.55e-48) {
tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d+108)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 2.55d-48) then
tmp = (sqrt(((b * b) - ((3.0d0 * a) * c))) - b) / (3.0d0 * a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e+108) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.55e-48) {
tmp = (Math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+108: tmp = (b * -2.0) / (3.0 * a) elif b <= 2.55e-48: tmp = (math.sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+108) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2.55e-48) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c))) - b) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e+108) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 2.55e-48) tmp = (sqrt(((b * b) - ((3.0 * a) * c))) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+108], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.55e-48], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+108}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.55 \cdot 10^{-48}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.99999999999999991e108Initial program 53.5%
Taylor expanded in b around -inf 96.4%
*-commutative96.4%
Simplified96.4%
if -4.99999999999999991e108 < b < 2.55000000000000006e-48Initial program 78.1%
if 2.55000000000000006e-48 < b Initial program 11.0%
Taylor expanded in b around inf 86.9%
Final simplification85.2%
(FPCore (a b c)
:precision binary64
(if (<= b -5e+108)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 3.1e-50)
(* -0.3333333333333333 (/ (- b (sqrt (- (* b b) (* 3.0 (* a c))))) a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+108) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 3.1e-50) {
tmp = -0.3333333333333333 * ((b - sqrt(((b * b) - (3.0 * (a * c))))) / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d+108)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 3.1d-50) then
tmp = (-0.3333333333333333d0) * ((b - sqrt(((b * b) - (3.0d0 * (a * c))))) / a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e+108) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 3.1e-50) {
tmp = -0.3333333333333333 * ((b - Math.sqrt(((b * b) - (3.0 * (a * c))))) / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e+108: tmp = (b * -2.0) / (3.0 * a) elif b <= 3.1e-50: tmp = -0.3333333333333333 * ((b - math.sqrt(((b * b) - (3.0 * (a * c))))) / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e+108) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 3.1e-50) tmp = Float64(-0.3333333333333333 * Float64(Float64(b - sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c))))) / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e+108) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 3.1e-50) tmp = -0.3333333333333333 * ((b - sqrt(((b * b) - (3.0 * (a * c))))) / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e+108], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.1e-50], N[(-0.3333333333333333 * N[(N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+108}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 3.1 \cdot 10^{-50}:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.99999999999999991e108Initial program 53.5%
Taylor expanded in b around -inf 96.4%
*-commutative96.4%
Simplified96.4%
if -4.99999999999999991e108 < b < 3.1000000000000002e-50Initial program 78.1%
/-rgt-identity78.1%
metadata-eval78.1%
associate-/l*78.1%
associate-*r/78.0%
*-commutative78.0%
associate-*l/78.1%
associate-*r/78.1%
metadata-eval78.1%
metadata-eval78.1%
times-frac78.1%
neg-mul-178.1%
distribute-rgt-neg-in78.1%
times-frac77.9%
metadata-eval77.9%
neg-mul-177.9%
Simplified77.9%
fma-udef77.9%
associate-*r*77.8%
*-commutative77.8%
metadata-eval77.8%
cancel-sign-sub-inv77.8%
Applied egg-rr77.8%
if 3.1000000000000002e-50 < b Initial program 11.0%
Taylor expanded in b around inf 86.9%
Final simplification85.1%
(FPCore (a b c)
:precision binary64
(if (<= b -1.7e+108)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 1.4e-51)
(/ (* -0.3333333333333333 (- b (sqrt (+ (* b b) (* (* a c) -3.0))))) a)
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.7e+108) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.4e-51) {
tmp = (-0.3333333333333333 * (b - sqrt(((b * b) + ((a * c) * -3.0))))) / a;
} else {
tmp = -0.5 * (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.7d+108)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 1.4d-51) then
tmp = ((-0.3333333333333333d0) * (b - sqrt(((b * b) + ((a * c) * (-3.0d0)))))) / a
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.7e+108) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.4e-51) {
tmp = (-0.3333333333333333 * (b - Math.sqrt(((b * b) + ((a * c) * -3.0))))) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.7e+108: tmp = (b * -2.0) / (3.0 * a) elif b <= 1.4e-51: tmp = (-0.3333333333333333 * (b - math.sqrt(((b * b) + ((a * c) * -3.0))))) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.7e+108) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 1.4e-51) tmp = Float64(Float64(-0.3333333333333333 * Float64(b - sqrt(Float64(Float64(b * b) + Float64(Float64(a * c) * -3.0))))) / a); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.7e+108) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 1.4e-51) tmp = (-0.3333333333333333 * (b - sqrt(((b * b) + ((a * c) * -3.0))))) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.7e+108], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.4e-51], N[(N[(-0.3333333333333333 * N[(b - N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.7 \cdot 10^{+108}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.4 \cdot 10^{-51}:\\
\;\;\;\;\frac{-0.3333333333333333 \cdot \left(b - \sqrt{b \cdot b + \left(a \cdot c\right) \cdot -3}\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.69999999999999998e108Initial program 53.5%
Taylor expanded in b around -inf 96.4%
*-commutative96.4%
Simplified96.4%
if -1.69999999999999998e108 < b < 1.4e-51Initial program 78.1%
/-rgt-identity78.1%
metadata-eval78.1%
associate-/l*78.1%
associate-*r/78.0%
*-commutative78.0%
associate-*l/78.1%
associate-*r/78.1%
metadata-eval78.1%
metadata-eval78.1%
times-frac78.1%
neg-mul-178.1%
distribute-rgt-neg-in78.1%
times-frac77.9%
metadata-eval77.9%
neg-mul-177.9%
Simplified77.9%
fma-udef77.9%
associate-*r*77.8%
*-commutative77.8%
metadata-eval77.8%
cancel-sign-sub-inv77.8%
Applied egg-rr77.8%
associate-*r/77.9%
cancel-sign-sub-inv77.9%
metadata-eval77.9%
*-commutative77.9%
Applied egg-rr77.9%
if 1.4e-51 < b Initial program 11.0%
Taylor expanded in b around inf 86.9%
Final simplification85.1%
(FPCore (a b c)
:precision binary64
(if (<= b -5.5e+108)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 1.62e-49)
(/ (- (sqrt (- (* b b) (* 3.0 (* a c)))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e+108) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.62e-49) {
tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (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.5d+108)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 1.62d-49) then
tmp = (sqrt(((b * b) - (3.0d0 * (a * c)))) - b) / (3.0d0 * a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e+108) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.62e-49) {
tmp = (Math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.5e+108: tmp = (b * -2.0) / (3.0 * a) elif b <= 1.62e-49: tmp = (math.sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.5e+108) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 1.62e-49) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(3.0 * Float64(a * c)))) - b) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.5e+108) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 1.62e-49) tmp = (sqrt(((b * b) - (3.0 * (a * c)))) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.5e+108], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.62e-49], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{+108}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.62 \cdot 10^{-49}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -5.4999999999999998e108Initial program 53.5%
Taylor expanded in b around -inf 96.4%
*-commutative96.4%
Simplified96.4%
if -5.4999999999999998e108 < b < 1.62e-49Initial program 78.1%
neg-sub078.1%
associate-+l-78.1%
sub0-neg78.1%
neg-mul-178.1%
associate-*r/78.1%
metadata-eval78.1%
metadata-eval78.1%
times-frac78.1%
*-commutative78.1%
times-frac78.0%
associate-*l/78.1%
Simplified78.0%
if 1.62e-49 < b Initial program 11.0%
Taylor expanded in b around inf 86.9%
Final simplification85.2%
(FPCore (a b c)
:precision binary64
(if (<= b -3.8e-154)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2.4e-49)
(/ (- (sqrt (* (* a c) -3.0)) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.8e-154) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.4e-49) {
tmp = (sqrt(((a * c) * -3.0)) - b) / (3.0 * a);
} else {
tmp = -0.5 * (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.8d-154)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 2.4d-49) then
tmp = (sqrt(((a * c) * (-3.0d0))) - b) / (3.0d0 * a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.8e-154) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.4e-49) {
tmp = (Math.sqrt(((a * c) * -3.0)) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.8e-154: tmp = (b * -2.0) / (3.0 * a) elif b <= 2.4e-49: tmp = (math.sqrt(((a * c) * -3.0)) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.8e-154) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2.4e-49) tmp = Float64(Float64(sqrt(Float64(Float64(a * c) * -3.0)) - b) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.8e-154) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 2.4e-49) tmp = (sqrt(((a * c) * -3.0)) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.8e-154], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.4e-49], N[(N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.8 \cdot 10^{-154}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-49}:\\
\;\;\;\;\frac{\sqrt{\left(a \cdot c\right) \cdot -3} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -3.8000000000000001e-154Initial program 73.5%
Taylor expanded in b around -inf 84.5%
*-commutative84.5%
Simplified84.5%
if -3.8000000000000001e-154 < b < 2.39999999999999992e-49Initial program 62.4%
Taylor expanded in b around 0 62.2%
+-commutative62.2%
*-un-lft-identity62.2%
fma-def62.2%
associate-*r*62.3%
*-commutative62.3%
*-commutative62.3%
Applied egg-rr62.3%
fma-udef62.3%
*-lft-identity62.3%
unsub-neg62.3%
associate-*r*62.2%
*-commutative62.2%
associate-*l*62.4%
Simplified62.4%
Taylor expanded in c around 0 62.2%
if 2.39999999999999992e-49 < b Initial program 11.0%
Taylor expanded in b around inf 86.9%
Final simplification80.6%
(FPCore (a b c)
:precision binary64
(if (<= b -3.8e-154)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 7e-52)
(/ (- (sqrt (* a (* c -3.0))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.8e-154) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 7e-52) {
tmp = (sqrt((a * (c * -3.0))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (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.8d-154)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 7d-52) then
tmp = (sqrt((a * (c * (-3.0d0)))) - b) / (3.0d0 * a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.8e-154) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 7e-52) {
tmp = (Math.sqrt((a * (c * -3.0))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.8e-154: tmp = (b * -2.0) / (3.0 * a) elif b <= 7e-52: tmp = (math.sqrt((a * (c * -3.0))) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.8e-154) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 7e-52) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -3.0))) - b) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.8e-154) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 7e-52) tmp = (sqrt((a * (c * -3.0))) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.8e-154], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7e-52], N[(N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.8 \cdot 10^{-154}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 7 \cdot 10^{-52}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -3.8000000000000001e-154Initial program 73.5%
Taylor expanded in b around -inf 84.5%
*-commutative84.5%
Simplified84.5%
if -3.8000000000000001e-154 < b < 7.0000000000000001e-52Initial program 62.4%
Taylor expanded in b around 0 62.2%
+-commutative62.2%
*-un-lft-identity62.2%
fma-def62.2%
associate-*r*62.3%
*-commutative62.3%
*-commutative62.3%
Applied egg-rr62.3%
fma-udef62.3%
*-lft-identity62.3%
unsub-neg62.3%
associate-*r*62.2%
*-commutative62.2%
associate-*l*62.4%
Simplified62.4%
div-sub62.4%
*-commutative62.4%
*-commutative62.4%
Applied egg-rr62.4%
div-sub62.4%
associate-*r*62.2%
*-commutative62.2%
rem-square-sqrt0.0%
unpow20.0%
associate-*l*0.0%
unpow20.0%
rem-square-sqrt62.3%
Simplified62.3%
if 7.0000000000000001e-52 < b Initial program 11.0%
Taylor expanded in b around inf 86.9%
Final simplification80.6%
(FPCore (a b c)
:precision binary64
(if (<= b -3.8e-154)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2.35e-51)
(/ (- (sqrt (* c (* a -3.0))) b) (* 3.0 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.8e-154) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.35e-51) {
tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (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.8d-154)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 2.35d-51) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) / (3.0d0 * a)
else
tmp = (-0.5d0) * (c / b)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3.8e-154) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.35e-51) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.8e-154: tmp = (b * -2.0) / (3.0 * a) elif b <= 2.35e-51: tmp = (math.sqrt((c * (a * -3.0))) - b) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.8e-154) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2.35e-51) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.8e-154) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 2.35e-51) tmp = (sqrt((c * (a * -3.0))) - b) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.8e-154], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.35e-51], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.8 \cdot 10^{-154}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.35 \cdot 10^{-51}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -3.8000000000000001e-154Initial program 73.5%
Taylor expanded in b around -inf 84.5%
*-commutative84.5%
Simplified84.5%
if -3.8000000000000001e-154 < b < 2.3499999999999999e-51Initial program 62.4%
Taylor expanded in b around 0 62.2%
+-commutative62.2%
*-un-lft-identity62.2%
fma-def62.2%
associate-*r*62.3%
*-commutative62.3%
*-commutative62.3%
Applied egg-rr62.3%
fma-udef62.3%
*-lft-identity62.3%
unsub-neg62.3%
associate-*r*62.2%
*-commutative62.2%
associate-*l*62.4%
Simplified62.4%
if 2.3499999999999999e-51 < b Initial program 11.0%
Taylor expanded in b around inf 86.9%
Final simplification80.6%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (/ (* b -2.0) (* 3.0 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = (b * -2.0) / (3.0 * a);
} else {
tmp = -0.5 * (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 = (b * (-2.0d0)) / (3.0d0 * a)
else
tmp = (-0.5d0) * (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 = (b * -2.0) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = (b * -2.0) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-310) tmp = (b * -2.0) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 73.6%
Taylor expanded in b around -inf 73.0%
*-commutative73.0%
Simplified73.0%
if -9.999999999999969e-311 < b Initial program 22.8%
Taylor expanded in b around inf 70.1%
Final simplification71.6%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (* -0.6666666666666666 (/ b a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (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 = (-0.6666666666666666d0) * (b / a)
else
tmp = (-0.5d0) * (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 = -0.6666666666666666 * (b / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-310) tmp = -0.6666666666666666 * (b / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 73.6%
Taylor expanded in b around -inf 72.9%
*-commutative72.9%
Simplified72.9%
if -9.999999999999969e-311 < b Initial program 22.8%
Taylor expanded in b around inf 70.1%
Final simplification71.5%
(FPCore (a b c) :precision binary64 (if (<= b -1e-310) (/ b (/ a -0.6666666666666666)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-310) {
tmp = b / (a / -0.6666666666666666);
} else {
tmp = -0.5 * (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 = b / (a / (-0.6666666666666666d0))
else
tmp = (-0.5d0) * (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 = b / (a / -0.6666666666666666);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-310: tmp = b / (a / -0.6666666666666666) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-310) tmp = Float64(b / Float64(a / -0.6666666666666666)); else tmp = Float64(-0.5 * Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-310) tmp = b / (a / -0.6666666666666666); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-310], N[(b / N[(a / -0.6666666666666666), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{\frac{a}{-0.6666666666666666}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -9.999999999999969e-311Initial program 73.6%
/-rgt-identity73.6%
metadata-eval73.6%
associate-/l*73.6%
associate-*r/73.5%
*-commutative73.5%
associate-*l/73.6%
associate-*r/73.6%
metadata-eval73.6%
metadata-eval73.6%
times-frac73.6%
neg-mul-173.6%
distribute-rgt-neg-in73.6%
times-frac73.5%
metadata-eval73.5%
neg-mul-173.5%
Simplified73.5%
clear-num73.3%
inv-pow73.3%
fma-udef73.3%
add-sqr-sqrt55.3%
hypot-def67.4%
Applied egg-rr67.4%
unpow-167.4%
associate-*r*67.4%
*-commutative67.4%
associate-*l*67.4%
Simplified67.4%
Taylor expanded in b around -inf 72.9%
associate-*r/72.8%
*-commutative72.8%
associate-/l*72.9%
Simplified72.9%
if -9.999999999999969e-311 < b Initial program 22.8%
Taylor expanded in b around inf 70.1%
Final simplification71.5%
(FPCore (a b c) :precision binary64 (* -0.5 (/ c b)))
double code(double a, double b, double c) {
return -0.5 * (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 = (-0.5d0) * (c / b)
end function
public static double code(double a, double b, double c) {
return -0.5 * (c / b);
}
def code(a, b, c): return -0.5 * (c / b)
function code(a, b, c) return Float64(-0.5 * Float64(c / b)) end
function tmp = code(a, b, c) tmp = -0.5 * (c / b); end
code[a_, b_, c_] := N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \frac{c}{b}
\end{array}
Initial program 48.4%
Taylor expanded in b around inf 35.9%
Final simplification35.9%
herbie shell --seed 2023207
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))