
(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 -4.6e+59)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 2.2e-34)
(/ (- (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 <= -4.6e+59) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.2e-34) {
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 <= (-4.6d+59)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 2.2d-34) 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 <= -4.6e+59) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2.2e-34) {
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 <= -4.6e+59: tmp = (b * -2.0) / (3.0 * a) elif b <= 2.2e-34: 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 <= -4.6e+59) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2.2e-34) 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 <= -4.6e+59) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 2.2e-34) 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, -4.6e+59], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.2e-34], 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 -4.6 \cdot 10^{+59}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2.2 \cdot 10^{-34}:\\
\;\;\;\;\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.60000000000000016e59Initial program 67.5%
Simplified67.5%
Taylor expanded in b around -inf 93.4%
*-commutative93.4%
Simplified93.4%
if -4.60000000000000016e59 < b < 2.1999999999999999e-34Initial program 82.7%
if 2.1999999999999999e-34 < b Initial program 17.3%
Simplified17.3%
Taylor expanded in b around inf 87.2%
Final simplification86.8%
(FPCore (a b c)
:precision binary64
(if (<= b -4.6e+59)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 8.5e-35)
(/ (- (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 <= -4.6e+59) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 8.5e-35) {
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 <= (-4.6d+59)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 8.5d-35) 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 <= -4.6e+59) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 8.5e-35) {
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 <= -4.6e+59: tmp = (b * -2.0) / (3.0 * a) elif b <= 8.5e-35: 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 <= -4.6e+59) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 8.5e-35) 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 <= -4.6e+59) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 8.5e-35) 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, -4.6e+59], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.5e-35], 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 -4.6 \cdot 10^{+59}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-35}:\\
\;\;\;\;\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 < -4.60000000000000016e59Initial program 67.5%
Simplified67.5%
Taylor expanded in b around -inf 93.4%
*-commutative93.4%
Simplified93.4%
if -4.60000000000000016e59 < b < 8.5000000000000001e-35Initial program 82.7%
sqr-neg82.7%
sqr-neg82.7%
associate-*l*82.6%
Simplified82.6%
if 8.5000000000000001e-35 < b Initial program 17.3%
Simplified17.3%
Taylor expanded in b around inf 87.2%
Final simplification86.8%
(FPCore (a b c)
:precision binary64
(if (<= b -4.8e-78)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 1.32e-39)
(/ (- (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 <= -4.8e-78) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.32e-39) {
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 <= (-4.8d-78)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 1.32d-39) 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 <= -4.8e-78) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.32e-39) {
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 <= -4.8e-78: tmp = (b * -2.0) / (3.0 * a) elif b <= 1.32e-39: 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 <= -4.8e-78) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 1.32e-39) 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 <= -4.8e-78) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 1.32e-39) 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, -4.8e-78], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.32e-39], 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 -4.8 \cdot 10^{-78}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.32 \cdot 10^{-39}:\\
\;\;\;\;\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 < -4.79999999999999999e-78Initial program 75.3%
Simplified75.3%
Taylor expanded in b around -inf 86.6%
*-commutative86.6%
Simplified86.6%
if -4.79999999999999999e-78 < b < 1.31999999999999997e-39Initial program 79.6%
Simplified79.4%
Taylor expanded in b around 0 78.3%
associate-*r*78.5%
*-commutative78.5%
Simplified78.5%
if 1.31999999999999997e-39 < b Initial program 17.3%
Simplified17.3%
Taylor expanded in b around inf 87.2%
Final simplification84.8%
(FPCore (a b c)
:precision binary64
(if (<= b -2.95e-78)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 1.18e-37)
(/ (- (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 <= -2.95e-78) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.18e-37) {
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 <= (-2.95d-78)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 1.18d-37) 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 <= -2.95e-78) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 1.18e-37) {
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 <= -2.95e-78: tmp = (b * -2.0) / (3.0 * a) elif b <= 1.18e-37: 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 <= -2.95e-78) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 1.18e-37) 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 <= -2.95e-78) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 1.18e-37) 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, -2.95e-78], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.18e-37], 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 -2.95 \cdot 10^{-78}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 1.18 \cdot 10^{-37}:\\
\;\;\;\;\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 < -2.9500000000000002e-78Initial program 75.3%
Simplified75.3%
Taylor expanded in b around -inf 86.6%
*-commutative86.6%
Simplified86.6%
if -2.9500000000000002e-78 < b < 1.17999999999999997e-37Initial program 79.6%
Simplified79.4%
Taylor expanded in b around 0 78.3%
if 1.17999999999999997e-37 < b Initial program 17.3%
Simplified17.3%
Taylor expanded in b around inf 87.2%
Final simplification84.7%
(FPCore (a b c) :precision binary64 (if (<= b -5.2e-78) (/ (* b -2.0) (* 3.0 a)) (if (<= b 2e-36) (/ (sqrt (* a (* c -3.0))) (* 3.0 a)) (* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.2e-78) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2e-36) {
tmp = sqrt((a * (c * -3.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 <= (-5.2d-78)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 2d-36) then
tmp = sqrt((a * (c * (-3.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 <= -5.2e-78) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 2e-36) {
tmp = Math.sqrt((a * (c * -3.0))) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.2e-78: tmp = (b * -2.0) / (3.0 * a) elif b <= 2e-36: tmp = math.sqrt((a * (c * -3.0))) / (3.0 * a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.2e-78) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 2e-36) tmp = Float64(sqrt(Float64(a * Float64(c * -3.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 <= -5.2e-78) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 2e-36) tmp = sqrt((a * (c * -3.0))) / (3.0 * a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.2e-78], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2e-36], N[(N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision]), $MachinePrecision]], $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.2 \cdot 10^{-78}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-36}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -3\right)}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -5.2000000000000002e-78Initial program 75.3%
Simplified75.3%
Taylor expanded in b around -inf 86.6%
*-commutative86.6%
Simplified86.6%
if -5.2000000000000002e-78 < b < 1.9999999999999999e-36Initial program 79.6%
add-cube-cbrt78.8%
pow378.9%
Applied egg-rr78.9%
Taylor expanded in a around -inf 0.0%
mul-1-neg0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt77.2%
distribute-lft-neg-in77.2%
metadata-eval77.2%
rem-cube-cbrt77.3%
Simplified77.3%
if 1.9999999999999999e-36 < b Initial program 17.3%
Simplified17.3%
Taylor expanded in b around inf 87.2%
Final simplification84.4%
(FPCore (a b c)
:precision binary64
(if (<= b -1.52e-117)
(/ (* b -2.0) (* 3.0 a))
(if (<= b 6.2e-40)
(* (sqrt (* c (/ -3.0 a))) (- -0.3333333333333333))
(* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.52e-117) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 6.2e-40) {
tmp = sqrt((c * (-3.0 / a))) * -(-0.3333333333333333);
} 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.52d-117)) then
tmp = (b * (-2.0d0)) / (3.0d0 * a)
else if (b <= 6.2d-40) then
tmp = sqrt((c * ((-3.0d0) / a))) * -(-0.3333333333333333d0)
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.52e-117) {
tmp = (b * -2.0) / (3.0 * a);
} else if (b <= 6.2e-40) {
tmp = Math.sqrt((c * (-3.0 / a))) * -(-0.3333333333333333);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.52e-117: tmp = (b * -2.0) / (3.0 * a) elif b <= 6.2e-40: tmp = math.sqrt((c * (-3.0 / a))) * -(-0.3333333333333333) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.52e-117) tmp = Float64(Float64(b * -2.0) / Float64(3.0 * a)); elseif (b <= 6.2e-40) tmp = Float64(sqrt(Float64(c * Float64(-3.0 / a))) * Float64(-(-0.3333333333333333))); 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.52e-117) tmp = (b * -2.0) / (3.0 * a); elseif (b <= 6.2e-40) tmp = sqrt((c * (-3.0 / a))) * -(-0.3333333333333333); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.52e-117], N[(N[(b * -2.0), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.2e-40], N[(N[Sqrt[N[(c * N[(-3.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (--0.3333333333333333)), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.52 \cdot 10^{-117}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{elif}\;b \leq 6.2 \cdot 10^{-40}:\\
\;\;\;\;\sqrt{c \cdot \frac{-3}{a}} \cdot \left(--0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < -1.52e-117Initial program 75.3%
Simplified75.3%
Taylor expanded in b around -inf 83.3%
*-commutative83.3%
Simplified83.3%
if -1.52e-117 < b < 6.20000000000000021e-40Initial program 79.8%
add-cube-cbrt79.0%
pow379.2%
Applied egg-rr79.2%
Taylor expanded in a around -inf 0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt32.3%
associate-/l*32.3%
rem-cube-cbrt32.5%
Simplified32.5%
if 6.20000000000000021e-40 < b Initial program 17.3%
Simplified17.3%
Taylor expanded in b around inf 87.2%
Final simplification72.5%
(FPCore (a b c) :precision binary64 (if (<= b 6.5e-301) (/ (* b -2.0) (* 3.0 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.5e-301) {
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 <= 6.5d-301) 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 <= 6.5e-301) {
tmp = (b * -2.0) / (3.0 * a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.5e-301: 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 <= 6.5e-301) 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 <= 6.5e-301) 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, 6.5e-301], 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 6.5 \cdot 10^{-301}:\\
\;\;\;\;\frac{b \cdot -2}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 6.49999999999999991e-301Initial program 77.8%
Simplified77.7%
Taylor expanded in b around -inf 67.8%
*-commutative67.8%
Simplified67.8%
if 6.49999999999999991e-301 < b Initial program 32.6%
Simplified32.6%
Taylor expanded in b around inf 67.4%
(FPCore (a b c) :precision binary64 (if (<= b 6.5e-301) (/ -2.0 (/ (* 3.0 a) b)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.5e-301) {
tmp = -2.0 / ((3.0 * a) / 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 <= 6.5d-301) then
tmp = (-2.0d0) / ((3.0d0 * a) / 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 <= 6.5e-301) {
tmp = -2.0 / ((3.0 * a) / b);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.5e-301: tmp = -2.0 / ((3.0 * a) / b) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.5e-301) tmp = Float64(-2.0 / Float64(Float64(3.0 * a) / 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 <= 6.5e-301) tmp = -2.0 / ((3.0 * a) / b); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.5e-301], N[(-2.0 / N[(N[(3.0 * a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 6.5 \cdot 10^{-301}:\\
\;\;\;\;\frac{-2}{\frac{3 \cdot a}{b}}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 6.49999999999999991e-301Initial program 77.8%
sqr-neg77.8%
sqr-neg77.8%
associate-*l*77.7%
Simplified77.7%
add-cube-cbrt77.6%
pow377.6%
Applied egg-rr76.6%
Taylor expanded in b around -inf 67.2%
Applied egg-rr67.7%
if 6.49999999999999991e-301 < b Initial program 32.6%
Simplified32.6%
Taylor expanded in b around inf 67.4%
Final simplification67.5%
(FPCore (a b c) :precision binary64 (if (<= b 6.5e-301) (* (- b) (/ 0.6666666666666666 a)) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.5e-301) {
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 <= 6.5d-301) 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 <= 6.5e-301) {
tmp = -b * (0.6666666666666666 / a);
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.5e-301: tmp = -b * (0.6666666666666666 / a) else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.5e-301) tmp = Float64(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 <= 6.5e-301) tmp = -b * (0.6666666666666666 / a); else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.5e-301], 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 6.5 \cdot 10^{-301}:\\
\;\;\;\;\left(-b\right) \cdot \frac{0.6666666666666666}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 6.49999999999999991e-301Initial program 77.8%
Simplified77.7%
Taylor expanded in b around -inf 66.8%
Taylor expanded in b around inf 67.6%
associate-*r/67.6%
associate-*l/67.6%
*-commutative67.6%
Simplified67.6%
if 6.49999999999999991e-301 < b Initial program 32.6%
Simplified32.6%
Taylor expanded in b around inf 67.4%
Final simplification67.5%
(FPCore (a b c) :precision binary64 (if (<= b 6.5e-301) (* (/ b a) -0.6666666666666666) (* -0.5 (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 6.5e-301) {
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 <= 6.5d-301) 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 <= 6.5e-301) {
tmp = (b / a) * -0.6666666666666666;
} else {
tmp = -0.5 * (c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 6.5e-301: tmp = (b / a) * -0.6666666666666666 else: tmp = -0.5 * (c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 6.5e-301) 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 <= 6.5e-301) tmp = (b / a) * -0.6666666666666666; else tmp = -0.5 * (c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 6.5e-301], 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 6.5 \cdot 10^{-301}:\\
\;\;\;\;\frac{b}{a} \cdot -0.6666666666666666\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\
\end{array}
\end{array}
if b < 6.49999999999999991e-301Initial program 77.8%
Simplified77.7%
Taylor expanded in b around -inf 67.6%
*-commutative67.6%
Simplified67.6%
if 6.49999999999999991e-301 < b Initial program 32.6%
Simplified32.6%
Taylor expanded in b around inf 67.4%
(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.7%
Simplified54.6%
Taylor expanded in b around inf 35.5%
herbie shell --seed 2024136
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))