
(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 -2.75e+82)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 6.4e-66)
(/ (- (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 <= -2.75e+82) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 6.4e-66) {
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 <= (-2.75d+82)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 6.4d-66) 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 <= -2.75e+82) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 6.4e-66) {
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 <= -2.75e+82: tmp = (b * -2.0) / (3.0 * a) elif b <= 6.4e-66: 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 <= -2.75e+82) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 6.4e-66) 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 <= -2.75e+82) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 6.4e-66) 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, -2.75e+82], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.4e-66], 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 -2.75 \cdot 10^{+82}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 6.4 \cdot 10^{-66}:\\
\;\;\;\;\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 < -2.74999999999999998e82Initial program 65.0%
Taylor expanded in b around -inf 96.2%
*-commutative96.2%
Simplified96.2%
if -2.74999999999999998e82 < b < 6.39999999999999963e-66Initial program 82.7%
if 6.39999999999999963e-66 < b Initial program 10.7%
Taylor expanded in b around inf 88.6%
Final simplification87.5%
(FPCore (a b c)
:precision binary64
(if (<= b -2.6e+82)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 4.6e-67)
(* -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 <= -2.6e+82) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 4.6e-67) {
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 <= (-2.6d+82)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 4.6d-67) 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 <= -2.6e+82) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 4.6e-67) {
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 <= -2.6e+82: tmp = (b * -2.0) / (3.0 * a) elif b <= 4.6e-67: 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 <= -2.6e+82) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 4.6e-67) 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 <= -2.6e+82) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 4.6e-67) 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, -2.6e+82], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.6e-67], 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 -2.6 \cdot 10^{+82}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 4.6 \cdot 10^{-67}:\\
\;\;\;\;-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 < -2.5999999999999998e82Initial program 65.0%
Taylor expanded in b around -inf 96.2%
*-commutative96.2%
Simplified96.2%
if -2.5999999999999998e82 < b < 4.6000000000000001e-67Initial program 82.7%
/-rgt-identity82.7%
metadata-eval82.7%
associate-/l*82.7%
associate-*r/82.6%
*-commutative82.6%
associate-*l/82.7%
associate-*r/82.7%
metadata-eval82.7%
metadata-eval82.7%
times-frac82.7%
neg-mul-182.7%
distribute-rgt-neg-in82.7%
times-frac82.4%
metadata-eval82.4%
neg-mul-182.4%
Simplified82.4%
fma-udef82.4%
associate-*r*82.4%
*-commutative82.4%
metadata-eval82.4%
cancel-sign-sub-inv82.4%
Applied egg-rr82.4%
if 4.6000000000000001e-67 < b Initial program 10.7%
Taylor expanded in b around inf 88.6%
Final simplification87.3%
(FPCore (a b c)
:precision binary64
(if (<= b -2.25e+82)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 1.16e-67)
(/ (* (- (sqrt (+ (* b b) (* (* a c) -3.0))) b) 0.3333333333333333) a)
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.25e+82) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.16e-67) {
tmp = ((sqrt(((b * b) + ((a * c) * -3.0))) - b) * 0.3333333333333333) / 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 <= (-2.25d+82)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 1.16d-67) then
tmp = ((sqrt(((b * b) + ((a * c) * (-3.0d0)))) - b) * 0.3333333333333333d0) / 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 <= -2.25e+82) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.16e-67) {
tmp = ((Math.sqrt(((b * b) + ((a * c) * -3.0))) - b) * 0.3333333333333333) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.25e+82: tmp = (b * -2.0) / (3.0 * a) elif b <= 1.16e-67: tmp = ((math.sqrt(((b * b) + ((a * c) * -3.0))) - b) * 0.3333333333333333) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.25e+82) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 1.16e-67) tmp = Float64(Float64(Float64(sqrt(Float64(Float64(b * b) + Float64(Float64(a * c) * -3.0))) - b) * 0.3333333333333333) / 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 <= -2.25e+82) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 1.16e-67) tmp = ((sqrt(((b * b) + ((a * c) * -3.0))) - b) * 0.3333333333333333) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.25e+82], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.16e-67], N[(N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] + N[(N[(a * c), $MachinePrecision] * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.25 \cdot 10^{+82}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.16 \cdot 10^{-67}:\\
\;\;\;\;\frac{\left(\sqrt{b \cdot b + \left(a \cdot c\right) \cdot -3} - b\right) \cdot 0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -2.2499999999999998e82Initial program 65.6%
Taylor expanded in b around -inf 96.3%
*-commutative96.3%
Simplified96.3%
if -2.2499999999999998e82 < b < 1.16e-67Initial program 82.5%
neg-sub082.5%
associate-+l-82.5%
sub0-neg82.5%
neg-mul-182.5%
associate-*r/82.5%
*-commutative82.5%
metadata-eval82.5%
metadata-eval82.5%
times-frac82.5%
*-commutative82.5%
times-frac82.4%
Simplified82.3%
fma-udef82.2%
associate-*r*82.3%
*-commutative82.3%
metadata-eval82.3%
cancel-sign-sub-inv82.3%
Applied egg-rr82.3%
associate-*r/82.3%
cancel-sign-sub-inv82.3%
metadata-eval82.3%
Applied egg-rr82.3%
if 1.16e-67 < b Initial program 10.7%
Taylor expanded in b around inf 88.6%
Final simplification87.4%
(FPCore (a b c)
:precision binary64
(if (<= b -2.75e+82)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 7.5e-67)
(/ (- (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 <= -2.75e+82) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 7.5e-67) {
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 <= (-2.75d+82)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 7.5d-67) 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 <= -2.75e+82) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 7.5e-67) {
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 <= -2.75e+82: tmp = (b * -2.0) / (3.0 * a) elif b <= 7.5e-67: 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 <= -2.75e+82) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 7.5e-67) 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 <= -2.75e+82) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 7.5e-67) 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, -2.75e+82], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 7.5e-67], 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 -2.75 \cdot 10^{+82}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-67}:\\
\;\;\;\;\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 < -2.74999999999999998e82Initial program 65.0%
Taylor expanded in b around -inf 96.2%
*-commutative96.2%
Simplified96.2%
if -2.74999999999999998e82 < b < 7.5000000000000005e-67Initial program 82.7%
neg-sub082.7%
associate-+l-82.7%
sub0-neg82.7%
neg-mul-182.7%
associate-*r/82.7%
metadata-eval82.7%
metadata-eval82.7%
times-frac82.7%
*-commutative82.7%
times-frac82.6%
associate-*l/82.7%
Simplified82.6%
if 7.5000000000000005e-67 < b Initial program 10.7%
Taylor expanded in b around inf 88.6%
Final simplification87.4%
(FPCore (a b c)
:precision binary64
(if (<= b -4.1e-92)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 9e-66)
(* (- (sqrt (* c (* a -3.0))) b) (/ 0.3333333333333333 a))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.1e-92) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 9e-66) {
tmp = (sqrt((c * (a * -3.0))) - b) * (0.3333333333333333 / 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 <= (-4.1d-92)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 9d-66) then
tmp = (sqrt((c * (a * (-3.0d0)))) - b) * (0.3333333333333333d0 / 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 <= -4.1e-92) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 9e-66) {
tmp = (Math.sqrt((c * (a * -3.0))) - b) * (0.3333333333333333 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.1e-92: tmp = (b * -2.0) / (3.0 * a) elif b <= 9e-66: tmp = (math.sqrt((c * (a * -3.0))) - b) * (0.3333333333333333 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.1e-92) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 9e-66) tmp = Float64(Float64(sqrt(Float64(c * Float64(a * -3.0))) - b) * Float64(0.3333333333333333 / 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 <= -4.1e-92) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 9e-66) tmp = (sqrt((c * (a * -3.0))) - b) * (0.3333333333333333 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.1e-92], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9e-66], N[(N[(N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.1 \cdot 10^{-92}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 9 \cdot 10^{-66}:\\
\;\;\;\;\left(\sqrt{c \cdot \left(a \cdot -3\right)} - b\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -4.1000000000000002e-92Initial program 78.0%
Taylor expanded in b around -inf 86.6%
*-commutative86.6%
Simplified86.6%
if -4.1000000000000002e-92 < b < 8.9999999999999995e-66Initial program 76.3%
Taylor expanded in b around 0 74.9%
*-commutative74.9%
*-commutative74.9%
*-commutative74.9%
associate-*l*75.1%
Simplified75.1%
*-un-lft-identity75.1%
Applied egg-rr75.1%
associate-*r/75.1%
associate-*l/75.0%
associate-/r*74.8%
metadata-eval74.8%
+-commutative74.8%
unsub-neg74.8%
Simplified74.8%
if 8.9999999999999995e-66 < b Initial program 10.7%
Taylor expanded in b around inf 88.6%
Final simplification83.8%
(FPCore (a b c)
:precision binary64
(if (<= b -3e-92)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 4.5e-66)
(/ (- (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 <= -3e-92) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 4.5e-66) {
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 <= (-3d-92)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 4.5d-66) 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 <= -3e-92) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 4.5e-66) {
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 <= -3e-92: tmp = (b * -2.0) / (3.0 * a) elif b <= 4.5e-66: 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 <= -3e-92) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 4.5e-66) 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 <= -3e-92) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 4.5e-66) 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, -3e-92], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.5e-66], 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 \cdot 10^{-92}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-66}:\\
\;\;\;\;\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.00000000000000013e-92Initial program 78.0%
Taylor expanded in b around -inf 86.6%
*-commutative86.6%
Simplified86.6%
if -3.00000000000000013e-92 < b < 4.4999999999999998e-66Initial program 76.3%
Taylor expanded in b around 0 74.9%
*-commutative74.9%
*-commutative74.9%
*-commutative74.9%
associate-*l*75.1%
Simplified75.1%
*-un-lft-identity75.1%
Applied egg-rr75.1%
*-lft-identity75.1%
+-commutative75.1%
unsub-neg75.1%
Simplified75.1%
if 4.4999999999999998e-66 < b Initial program 10.7%
Taylor expanded in b around inf 88.6%
Final simplification83.8%
(FPCore (a b c)
:precision binary64
(if (<= b -7e-92)
(/ (fma b -2.0 (* (/ c (/ b a)) 1.5)) (* 3.0 a))
(if (<= b 1.95e-65)
(/ (- (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 <= -7e-92) {
tmp = fma(b, -2.0, ((c / (b / a)) * 1.5)) / (3.0 * a);
} else if (b <= 1.95e-65) {
tmp = (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 <= -7e-92) tmp = Float64(fma(b, -2.0, Float64(Float64(c / Float64(b / a)) * 1.5)) / Float64(3.0 * a)); elseif (b <= 1.95e-65) 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
code[a_, b_, c_] := If[LessEqual[b, -7e-92], N[(N[(b * -2.0 + N[(N[(c / N[(b / a), $MachinePrecision]), $MachinePrecision] * 1.5), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.95e-65], 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 -7 \cdot 10^{-92}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, -2, \frac{c}{\frac{b}{a}} \cdot 1.5\right)}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.95 \cdot 10^{-65}:\\
\;\;\;\;\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 < -7e-92Initial program 78.0%
Taylor expanded in b around -inf 84.5%
+-commutative84.5%
*-commutative84.5%
fma-def84.5%
*-commutative84.5%
associate-/l*86.6%
Simplified86.6%
if -7e-92 < b < 1.9500000000000002e-65Initial program 76.3%
Taylor expanded in b around 0 74.9%
*-commutative74.9%
*-commutative74.9%
*-commutative74.9%
associate-*l*75.1%
Simplified75.1%
*-un-lft-identity75.1%
Applied egg-rr75.1%
*-lft-identity75.1%
+-commutative75.1%
unsub-neg75.1%
Simplified75.1%
if 1.9500000000000002e-65 < b Initial program 10.7%
Taylor expanded in b around inf 88.6%
Final simplification83.9%
(FPCore (a b c) :precision binary64 (if (<= b 7.6e-308) (/ (* b -2.0) (* 3.0 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 7.6e-308) {
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 <= 7.6d-308) 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 <= 7.6e-308) {
tmp = (b * -2.0) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7.6e-308: 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 <= 7.6e-308) 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 <= 7.6e-308) 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, 7.6e-308], 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 7.6 \cdot 10^{-308}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 7.59999999999999951e-308Initial program 79.1%
Taylor expanded in b around -inf 67.0%
*-commutative67.0%
Simplified67.0%
if 7.59999999999999951e-308 < b Initial program 30.0%
Taylor expanded in b around inf 67.2%
Final simplification67.1%
(FPCore (a b c) :precision binary64 (if (<= b 7.8e-308) (* (/ b a) -0.6666666666666666) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 7.8e-308) {
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 <= 7.8d-308) 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 <= 7.8e-308) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7.8e-308: tmp = (b / a) * -0.6666666666666666 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7.8e-308) tmp = Float64(Float64(b / 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 <= 7.8e-308) tmp = (b / a) * -0.6666666666666666; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7.8e-308], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.8 \cdot 10^{-308}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 7.7999999999999999e-308Initial program 79.1%
Taylor expanded in b around -inf 66.8%
*-commutative66.8%
Simplified66.8%
if 7.7999999999999999e-308 < b Initial program 30.0%
Taylor expanded in b around inf 67.2%
Final simplification67.0%
(FPCore (a b c) :precision binary64 (if (<= b 7.5e-308) (/ (* b -0.6666666666666666) a) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 7.5e-308) {
tmp = (b * -0.6666666666666666) / 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 <= 7.5d-308) then
tmp = (b * (-0.6666666666666666d0)) / 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 <= 7.5e-308) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7.5e-308: tmp = (b * -0.6666666666666666) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7.5e-308) tmp = Float64(Float64(b * -0.6666666666666666) / 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 <= 7.5e-308) tmp = (b * -0.6666666666666666) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7.5e-308], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.5 \cdot 10^{-308}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 7.4999999999999998e-308Initial program 79.1%
Taylor expanded in b around -inf 66.8%
*-commutative66.8%
Simplified66.8%
associate-*l/66.9%
Applied egg-rr66.9%
if 7.4999999999999998e-308 < b Initial program 30.0%
Taylor expanded in b around inf 67.2%
Final simplification67.0%
(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 54.3%
Taylor expanded in b around inf 34.9%
Final simplification34.9%
herbie shell --seed 2023175
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))