
(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 10 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 -3.9e+121)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2.5e-10)
(/ (- (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 <= -3.9e+121) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.5e-10) {
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 <= (-3.9d+121)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 2.5d-10) 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 <= -3.9e+121) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.5e-10) {
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 <= -3.9e+121: tmp = (b * -2.0) / (3.0 * a) elif b <= 2.5e-10: 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 <= -3.9e+121) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2.5e-10) 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 <= -3.9e+121) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 2.5e-10) 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, -3.9e+121], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.5e-10], 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 -3.9 \cdot 10^{+121}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.5 \cdot 10^{-10}:\\
\;\;\;\;\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 < -3.89999999999999984e121Initial program 48.9%
Simplified48.9%
Taylor expanded in b around -inf 98.2%
*-commutative98.2%
Simplified98.2%
if -3.89999999999999984e121 < b < 2.50000000000000016e-10Initial program 81.2%
if 2.50000000000000016e-10 < b Initial program 15.6%
Simplified15.6%
Taylor expanded in b around inf 92.9%
Final simplification88.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.45e+118)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2.6e-10)
(/ (- (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 <= -1.45e+118) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.6e-10) {
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 <= (-1.45d+118)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 2.6d-10) 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 <= -1.45e+118) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.6e-10) {
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 <= -1.45e+118: tmp = (b * -2.0) / (3.0 * a) elif b <= 2.6e-10: 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 <= -1.45e+118) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2.6e-10) 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 <= -1.45e+118) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 2.6e-10) 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, -1.45e+118], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.6e-10], 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 -1.45 \cdot 10^{+118}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.6 \cdot 10^{-10}:\\
\;\;\;\;\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 < -1.45000000000000008e118Initial program 48.9%
Simplified48.9%
Taylor expanded in b around -inf 98.2%
*-commutative98.2%
Simplified98.2%
if -1.45000000000000008e118 < b < 2.59999999999999981e-10Initial program 81.2%
sqr-neg81.2%
sqr-neg81.2%
associate-*l*81.0%
Simplified81.0%
if 2.59999999999999981e-10 < b Initial program 15.6%
Simplified15.6%
Taylor expanded in b around inf 92.9%
Final simplification88.5%
(FPCore (a b c)
:precision binary64
(if (<= b -5.8e-116)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2.7e-33)
(/ (- (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 <= -5.8e-116) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.7e-33) {
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 <= (-5.8d-116)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 2.7d-33) 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 <= -5.8e-116) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.7e-33) {
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 <= -5.8e-116: tmp = (b * -2.0) / (3.0 * a) elif b <= 2.7e-33: 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 <= -5.8e-116) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2.7e-33) 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 <= -5.8e-116) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 2.7e-33) 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, -5.8e-116], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.7e-33], 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 -5.8 \cdot 10^{-116}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.7 \cdot 10^{-33}:\\
\;\;\;\;\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 < -5.7999999999999996e-116Initial program 70.7%
Simplified70.6%
Taylor expanded in b around -inf 85.8%
*-commutative85.8%
Simplified85.8%
if -5.7999999999999996e-116 < b < 2.7000000000000001e-33Initial program 70.7%
Simplified70.6%
Taylor expanded in b around 0 68.6%
associate-*r*69.0%
*-commutative69.0%
Simplified69.0%
if 2.7000000000000001e-33 < b Initial program 16.6%
Simplified16.6%
Taylor expanded in b around inf 91.9%
Final simplification83.4%
(FPCore (a b c)
:precision binary64
(if (<= b -1.4e-115)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 3.8e-33)
(/ (- (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 <= -1.4e-115) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 3.8e-33) {
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 <= (-1.4d-115)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 3.8d-33) 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 <= -1.4e-115) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 3.8e-33) {
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 <= -1.4e-115: tmp = (b * -2.0) / (3.0 * a) elif b <= 3.8e-33: 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 <= -1.4e-115) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 3.8e-33) 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 <= -1.4e-115) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 3.8e-33) 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, -1.4e-115], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.8e-33], 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 -1.4 \cdot 10^{-115}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 3.8 \cdot 10^{-33}:\\
\;\;\;\;\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 < -1.39999999999999994e-115Initial program 70.7%
Simplified70.6%
Taylor expanded in b around -inf 85.8%
*-commutative85.8%
Simplified85.8%
if -1.39999999999999994e-115 < b < 3.79999999999999994e-33Initial program 70.7%
Simplified70.6%
Taylor expanded in b around 0 68.6%
if 3.79999999999999994e-33 < b Initial program 16.6%
Simplified16.6%
Taylor expanded in b around inf 91.9%
Final simplification83.3%
(FPCore (a b c)
:precision binary64
(if (<= b -1.02e-121)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2.4e-33)
(* -0.3333333333333333 (- (sqrt (/ (* c -3.0) a))))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.02e-121) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.4e-33) {
tmp = -0.3333333333333333 * -sqrt(((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.02d-121)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 2.4d-33) then
tmp = (-0.3333333333333333d0) * -sqrt(((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.02e-121) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.4e-33) {
tmp = -0.3333333333333333 * -Math.sqrt(((c * -3.0) / a));
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.02e-121: tmp = (b * -2.0) / (3.0 * a) elif b <= 2.4e-33: tmp = -0.3333333333333333 * -math.sqrt(((c * -3.0) / a)) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.02e-121) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2.4e-33) tmp = Float64(-0.3333333333333333 * Float64(-sqrt(Float64(Float64(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.02e-121) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 2.4e-33) tmp = -0.3333333333333333 * -sqrt(((c * -3.0) / a)); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.02e-121], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.4e-33], N[(-0.3333333333333333 * (-N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] / a), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.02 \cdot 10^{-121}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.4 \cdot 10^{-33}:\\
\;\;\;\;-0.3333333333333333 \cdot \left(-\sqrt{\frac{c \cdot -3}{a}}\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.02e-121Initial program 70.7%
Simplified70.6%
Taylor expanded in b around -inf 85.8%
*-commutative85.8%
Simplified85.8%
if -1.02e-121 < b < 2.4e-33Initial program 70.7%
sqr-neg70.7%
sqr-neg70.7%
associate-*l*70.4%
Simplified70.4%
add-cube-cbrt69.9%
pow369.9%
Applied egg-rr69.9%
Taylor expanded in a around -inf 0.0%
rem-cube-cbrt0.0%
unpow20.0%
rem-square-sqrt36.2%
Simplified36.2%
if 2.4e-33 < b Initial program 16.6%
Simplified16.6%
Taylor expanded in b around inf 91.9%
Final simplification75.2%
(FPCore (a b c) :precision binary64 (if (<= b 9.2e-303) (/ (* b -2.0) (* 3.0 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 9.2e-303) {
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 <= 9.2d-303) 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 <= 9.2e-303) {
tmp = (b * -2.0) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 9.2e-303: 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 <= 9.2e-303) 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 <= 9.2e-303) 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, 9.2e-303], 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 9.2 \cdot 10^{-303}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 9.19999999999999981e-303Initial program 70.6%
Simplified70.6%
Taylor expanded in b around -inf 75.3%
*-commutative75.3%
Simplified75.3%
if 9.19999999999999981e-303 < b Initial program 36.0%
Simplified36.0%
Taylor expanded in b around inf 64.7%
(FPCore (a b c) :precision binary64 (if (<= b 1.35e-304) (/ 1.0 (/ (* a -1.5) b)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.35e-304) {
tmp = 1.0 / ((a * -1.5) / b);
} 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.35d-304) then
tmp = 1.0d0 / ((a * (-1.5d0)) / b)
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.35e-304) {
tmp = 1.0 / ((a * -1.5) / b);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.35e-304: tmp = 1.0 / ((a * -1.5) / b) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.35e-304) tmp = Float64(1.0 / Float64(Float64(a * -1.5) / b)); 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.35e-304) tmp = 1.0 / ((a * -1.5) / b); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.35e-304], N[(1.0 / N[(N[(a * -1.5), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.35 \cdot 10^{-304}:\\
\;\;\;\;\frac{1}{\frac{a \cdot -1.5}{b}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 1.35000000000000005e-304Initial program 70.6%
sqr-neg70.6%
sqr-neg70.6%
associate-*l*70.6%
Simplified70.6%
add-cube-cbrt70.5%
pow370.5%
Applied egg-rr70.5%
Applied egg-rr70.5%
clear-num70.4%
frac-times70.5%
metadata-eval70.5%
fma-undefine70.5%
add-sqr-sqrt54.0%
hypot-define65.5%
Applied egg-rr65.5%
Taylor expanded in b around -inf 75.2%
associate-*r/75.3%
*-commutative75.3%
Simplified75.3%
if 1.35000000000000005e-304 < b Initial program 36.0%
Simplified36.0%
Taylor expanded in b around inf 64.7%
(FPCore (a b c) :precision binary64 (if (<= b 1.1e-303) (/ (* b -0.6666666666666666) a) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.1e-303) {
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 <= 1.1d-303) 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 <= 1.1e-303) {
tmp = (b * -0.6666666666666666) / a;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.1e-303: tmp = (b * -0.6666666666666666) / a else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.1e-303) 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 <= 1.1e-303) tmp = (b * -0.6666666666666666) / a; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.1e-303], 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 1.1 \cdot 10^{-303}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 1.10000000000000007e-303Initial program 70.6%
Simplified70.6%
Taylor expanded in b around -inf 75.2%
*-commutative75.2%
Simplified75.2%
associate-*l/75.3%
Applied egg-rr75.3%
if 1.10000000000000007e-303 < b Initial program 36.0%
Simplified36.0%
Taylor expanded in b around inf 64.7%
(FPCore (a b c) :precision binary64 (if (<= b 1.35e-304) (* b (/ -0.6666666666666666 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.35e-304) {
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 <= 1.35d-304) 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 <= 1.35e-304) {
tmp = b * (-0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.35e-304: tmp = b * (-0.6666666666666666 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.35e-304) tmp = Float64(b * Float64(-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 <= 1.35e-304) tmp = b * (-0.6666666666666666 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.35e-304], N[(b * N[(-0.6666666666666666 / a), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.35 \cdot 10^{-304}:\\
\;\;\;\;b \cdot \frac{-0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 1.35000000000000005e-304Initial program 70.6%
Simplified70.6%
Taylor expanded in b around -inf 75.2%
*-commutative75.2%
Simplified75.2%
*-commutative75.2%
clear-num75.1%
un-div-inv75.2%
Applied egg-rr75.2%
associate-/r/75.2%
Simplified75.2%
if 1.35000000000000005e-304 < b Initial program 36.0%
Simplified36.0%
Taylor expanded in b around inf 64.7%
Final simplification70.3%
(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.4%
Simplified54.4%
Taylor expanded in b around inf 31.6%
herbie shell --seed 2024186
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))