
(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 8 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 (/ (/ (* c (* 3.0 a)) (- (- b) (sqrt (- (pow b 2.0) (* a (* c 3.0)))))) (* 3.0 a)))
double code(double a, double b, double c) {
return ((c * (3.0 * a)) / (-b - sqrt((pow(b, 2.0) - (a * (c * 3.0)))))) / (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 = ((c * (3.0d0 * a)) / (-b - sqrt(((b ** 2.0d0) - (a * (c * 3.0d0)))))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return ((c * (3.0 * a)) / (-b - Math.sqrt((Math.pow(b, 2.0) - (a * (c * 3.0)))))) / (3.0 * a);
}
def code(a, b, c): return ((c * (3.0 * a)) / (-b - math.sqrt((math.pow(b, 2.0) - (a * (c * 3.0)))))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(c * Float64(3.0 * a)) / Float64(Float64(-b) - sqrt(Float64((b ^ 2.0) - Float64(a * Float64(c * 3.0)))))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = ((c * (3.0 * a)) / (-b - sqrt(((b ^ 2.0) - (a * (c * 3.0)))))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[(N[(c * N[(3.0 * a), $MachinePrecision]), $MachinePrecision] / N[((-b) - N[Sqrt[N[(N[Power[b, 2.0], $MachinePrecision] - N[(a * N[(c * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{c \cdot \left(3 \cdot a\right)}{\left(-b\right) - \sqrt{{b}^{2} - a \cdot \left(c \cdot 3\right)}}}{3 \cdot a}
\end{array}
Initial program 52.3%
neg-sub052.3%
flip--52.2%
metadata-eval52.2%
pow252.2%
add-sqr-sqrt51.6%
sqrt-prod52.2%
sqr-neg52.2%
sqrt-unprod0.0%
add-sqr-sqrt1.6%
sub-neg1.6%
neg-sub01.6%
add-sqr-sqrt0.0%
sqrt-unprod52.2%
sqr-neg52.2%
sqrt-prod51.6%
add-sqr-sqrt52.2%
Applied egg-rr52.2%
neg-sub052.2%
Simplified52.2%
flip-+52.2%
Applied egg-rr53.9%
associate--r-99.3%
associate-*r*99.1%
*-commutative99.1%
associate-*r*99.0%
associate-*r*99.0%
*-commutative99.0%
associate-*r*99.0%
Simplified99.0%
add-exp-log97.3%
Applied egg-rr97.3%
Taylor expanded in b around 0 99.1%
associate-*r*99.3%
*-commutative99.3%
Simplified99.3%
(FPCore (a b c) :precision binary64 (if (<= b 0.496) (/ (- (sqrt (- (* b b) (* c (* 3.0 a)))) (/ (* b b) b)) (* 3.0 a)) (/ 1.0 (* b (- (* 1.5 (/ a (pow b 2.0))) (/ 2.0 c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= 0.496) {
tmp = (sqrt(((b * b) - (c * (3.0 * a)))) - ((b * b) / b)) / (3.0 * a);
} else {
tmp = 1.0 / (b * ((1.5 * (a / pow(b, 2.0))) - (2.0 / c)));
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 0.496d0) then
tmp = (sqrt(((b * b) - (c * (3.0d0 * a)))) - ((b * b) / b)) / (3.0d0 * a)
else
tmp = 1.0d0 / (b * ((1.5d0 * (a / (b ** 2.0d0))) - (2.0d0 / c)))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 0.496) {
tmp = (Math.sqrt(((b * b) - (c * (3.0 * a)))) - ((b * b) / b)) / (3.0 * a);
} else {
tmp = 1.0 / (b * ((1.5 * (a / Math.pow(b, 2.0))) - (2.0 / c)));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 0.496: tmp = (math.sqrt(((b * b) - (c * (3.0 * a)))) - ((b * b) / b)) / (3.0 * a) else: tmp = 1.0 / (b * ((1.5 * (a / math.pow(b, 2.0))) - (2.0 / c))) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 0.496) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(3.0 * a)))) - Float64(Float64(b * b) / b)) / Float64(3.0 * a)); else tmp = Float64(1.0 / Float64(b * Float64(Float64(1.5 * Float64(a / (b ^ 2.0))) - Float64(2.0 / c)))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 0.496) tmp = (sqrt(((b * b) - (c * (3.0 * a)))) - ((b * b) / b)) / (3.0 * a); else tmp = 1.0 / (b * ((1.5 * (a / (b ^ 2.0))) - (2.0 / c))); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 0.496], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(N[(b * b), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(N[(1.5 * N[(a / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(2.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.496:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} - \frac{b \cdot b}{b}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(1.5 \cdot \frac{a}{{b}^{2}} - \frac{2}{c}\right)}\\
\end{array}
\end{array}
if b < 0.496Initial program 84.0%
neg-sub084.0%
flip--84.1%
metadata-eval84.1%
pow284.1%
add-sqr-sqrt82.3%
sqrt-prod84.1%
sqr-neg84.1%
sqrt-unprod0.0%
add-sqr-sqrt1.6%
sub-neg1.6%
neg-sub01.6%
add-sqr-sqrt0.0%
sqrt-unprod84.1%
sqr-neg84.1%
sqrt-prod82.3%
add-sqr-sqrt84.1%
Applied egg-rr84.1%
neg-sub084.1%
Simplified84.1%
pow298.9%
Applied egg-rr84.1%
if 0.496 < b Initial program 46.0%
add-sqr-sqrt46.0%
pow246.0%
Applied egg-rr46.0%
unpow246.0%
add-sqr-sqrt46.0%
pow146.0%
metadata-eval46.0%
pow-div46.0%
pow246.0%
pow146.0%
distribute-frac-neg46.0%
pow246.0%
clear-num46.0%
inv-pow46.0%
Applied egg-rr46.0%
unpow-146.0%
associate-/l*46.0%
associate-*r*46.0%
*-commutative46.0%
associate-*r*46.0%
Simplified46.0%
Taylor expanded in b around inf 88.6%
associate-*r/88.6%
metadata-eval88.6%
Simplified88.6%
Final simplification87.8%
(FPCore (a b c) :precision binary64 (/ (/ (* 3.0 (* c a)) (- (- b) (sqrt (- (* b b) (* a (* c 3.0)))))) (* 3.0 a)))
double code(double a, double b, double c) {
return ((3.0 * (c * a)) / (-b - sqrt(((b * b) - (a * (c * 3.0)))))) / (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 = ((3.0d0 * (c * a)) / (-b - sqrt(((b * b) - (a * (c * 3.0d0)))))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return ((3.0 * (c * a)) / (-b - Math.sqrt(((b * b) - (a * (c * 3.0)))))) / (3.0 * a);
}
def code(a, b, c): return ((3.0 * (c * a)) / (-b - math.sqrt(((b * b) - (a * (c * 3.0)))))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(3.0 * Float64(c * a)) / Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 3.0)))))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = ((3.0 * (c * a)) / (-b - sqrt(((b * b) - (a * (c * 3.0)))))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[(N[(3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision] / N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{3 \cdot \left(c \cdot a\right)}{\left(-b\right) - \sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)}}}{3 \cdot a}
\end{array}
Initial program 52.3%
neg-sub052.3%
flip--52.2%
metadata-eval52.2%
pow252.2%
add-sqr-sqrt51.6%
sqrt-prod52.2%
sqr-neg52.2%
sqrt-unprod0.0%
add-sqr-sqrt1.6%
sub-neg1.6%
neg-sub01.6%
add-sqr-sqrt0.0%
sqrt-unprod52.2%
sqr-neg52.2%
sqrt-prod51.6%
add-sqr-sqrt52.2%
Applied egg-rr52.2%
neg-sub052.2%
Simplified52.2%
flip-+52.2%
Applied egg-rr53.9%
associate--r-99.3%
associate-*r*99.1%
*-commutative99.1%
associate-*r*99.0%
associate-*r*99.0%
*-commutative99.0%
associate-*r*99.0%
Simplified99.0%
Taylor expanded in b around 0 99.1%
pow299.1%
Applied egg-rr99.1%
Final simplification99.1%
(FPCore (a b c) :precision binary64 (if (<= b 0.496) (/ (- (sqrt (- (* b b) (* c (* 3.0 a)))) b) (* 3.0 a)) (/ 1.0 (* b (- (* 1.5 (/ a (pow b 2.0))) (/ 2.0 c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= 0.496) {
tmp = (sqrt(((b * b) - (c * (3.0 * a)))) - b) / (3.0 * a);
} else {
tmp = 1.0 / (b * ((1.5 * (a / pow(b, 2.0))) - (2.0 / c)));
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 0.496d0) then
tmp = (sqrt(((b * b) - (c * (3.0d0 * a)))) - b) / (3.0d0 * a)
else
tmp = 1.0d0 / (b * ((1.5d0 * (a / (b ** 2.0d0))) - (2.0d0 / c)))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 0.496) {
tmp = (Math.sqrt(((b * b) - (c * (3.0 * a)))) - b) / (3.0 * a);
} else {
tmp = 1.0 / (b * ((1.5 * (a / Math.pow(b, 2.0))) - (2.0 / c)));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 0.496: tmp = (math.sqrt(((b * b) - (c * (3.0 * a)))) - b) / (3.0 * a) else: tmp = 1.0 / (b * ((1.5 * (a / math.pow(b, 2.0))) - (2.0 / c))) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 0.496) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(3.0 * a)))) - b) / Float64(3.0 * a)); else tmp = Float64(1.0 / Float64(b * Float64(Float64(1.5 * Float64(a / (b ^ 2.0))) - Float64(2.0 / c)))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 0.496) tmp = (sqrt(((b * b) - (c * (3.0 * a)))) - b) / (3.0 * a); else tmp = 1.0 / (b * ((1.5 * (a / (b ^ 2.0))) - (2.0 / c))); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 0.496], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(b * N[(N[(1.5 * N[(a / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(2.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.496:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{b \cdot \left(1.5 \cdot \frac{a}{{b}^{2}} - \frac{2}{c}\right)}\\
\end{array}
\end{array}
if b < 0.496Initial program 84.0%
if 0.496 < b Initial program 46.0%
add-sqr-sqrt46.0%
pow246.0%
Applied egg-rr46.0%
unpow246.0%
add-sqr-sqrt46.0%
pow146.0%
metadata-eval46.0%
pow-div46.0%
pow246.0%
pow146.0%
distribute-frac-neg46.0%
pow246.0%
clear-num46.0%
inv-pow46.0%
Applied egg-rr46.0%
unpow-146.0%
associate-/l*46.0%
associate-*r*46.0%
*-commutative46.0%
associate-*r*46.0%
Simplified46.0%
Taylor expanded in b around inf 88.6%
associate-*r/88.6%
metadata-eval88.6%
Simplified88.6%
Final simplification87.8%
(FPCore (a b c) :precision binary64 (/ 1.0 (* b (- (* 1.5 (/ a (pow b 2.0))) (/ 2.0 c)))))
double code(double a, double b, double c) {
return 1.0 / (b * ((1.5 * (a / pow(b, 2.0))) - (2.0 / c)));
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = 1.0d0 / (b * ((1.5d0 * (a / (b ** 2.0d0))) - (2.0d0 / c)))
end function
public static double code(double a, double b, double c) {
return 1.0 / (b * ((1.5 * (a / Math.pow(b, 2.0))) - (2.0 / c)));
}
def code(a, b, c): return 1.0 / (b * ((1.5 * (a / math.pow(b, 2.0))) - (2.0 / c)))
function code(a, b, c) return Float64(1.0 / Float64(b * Float64(Float64(1.5 * Float64(a / (b ^ 2.0))) - Float64(2.0 / c)))) end
function tmp = code(a, b, c) tmp = 1.0 / (b * ((1.5 * (a / (b ^ 2.0))) - (2.0 / c))); end
code[a_, b_, c_] := N[(1.0 / N[(b * N[(N[(1.5 * N[(a / N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(2.0 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{b \cdot \left(1.5 \cdot \frac{a}{{b}^{2}} - \frac{2}{c}\right)}
\end{array}
Initial program 52.3%
add-sqr-sqrt52.3%
pow252.3%
Applied egg-rr52.3%
unpow252.3%
add-sqr-sqrt52.3%
pow152.3%
metadata-eval52.3%
pow-div52.2%
pow252.2%
pow152.2%
distribute-frac-neg52.2%
pow252.2%
clear-num52.2%
inv-pow52.2%
Applied egg-rr52.3%
unpow-152.3%
associate-/l*52.3%
associate-*r*52.3%
*-commutative52.3%
associate-*r*52.2%
Simplified52.2%
Taylor expanded in b around inf 83.9%
associate-*r/83.9%
metadata-eval83.9%
Simplified83.9%
(FPCore (a b c) :precision binary64 (/ (/ (* 3.0 (* c a)) (+ (* 1.5 (* a (/ c b))) (* b -2.0))) (* 3.0 a)))
double code(double a, double b, double c) {
return ((3.0 * (c * a)) / ((1.5 * (a * (c / b))) + (b * -2.0))) / (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 = ((3.0d0 * (c * a)) / ((1.5d0 * (a * (c / b))) + (b * (-2.0d0)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return ((3.0 * (c * a)) / ((1.5 * (a * (c / b))) + (b * -2.0))) / (3.0 * a);
}
def code(a, b, c): return ((3.0 * (c * a)) / ((1.5 * (a * (c / b))) + (b * -2.0))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(3.0 * Float64(c * a)) / Float64(Float64(1.5 * Float64(a * Float64(c / b))) + Float64(b * -2.0))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = ((3.0 * (c * a)) / ((1.5 * (a * (c / b))) + (b * -2.0))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[(N[(3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(1.5 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{3 \cdot \left(c \cdot a\right)}{1.5 \cdot \left(a \cdot \frac{c}{b}\right) + b \cdot -2}}{3 \cdot a}
\end{array}
Initial program 52.3%
neg-sub052.3%
flip--52.2%
metadata-eval52.2%
pow252.2%
add-sqr-sqrt51.6%
sqrt-prod52.2%
sqr-neg52.2%
sqrt-unprod0.0%
add-sqr-sqrt1.6%
sub-neg1.6%
neg-sub01.6%
add-sqr-sqrt0.0%
sqrt-unprod52.2%
sqr-neg52.2%
sqrt-prod51.6%
add-sqr-sqrt52.2%
Applied egg-rr52.2%
neg-sub052.2%
Simplified52.2%
flip-+52.2%
Applied egg-rr53.9%
associate--r-99.3%
associate-*r*99.1%
*-commutative99.1%
associate-*r*99.0%
associate-*r*99.0%
*-commutative99.0%
associate-*r*99.0%
Simplified99.0%
Taylor expanded in b around 0 99.1%
Taylor expanded in a around 0 83.7%
cancel-sign-sub-inv83.7%
*-commutative83.7%
associate-/l*83.7%
metadata-eval83.7%
*-commutative83.7%
Simplified83.7%
Final simplification83.7%
(FPCore (a b c) :precision binary64 (* (/ c b) -0.5))
double code(double a, double b, double c) {
return (c / b) * -0.5;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c / b) * (-0.5d0)
end function
public static double code(double a, double b, double c) {
return (c / b) * -0.5;
}
def code(a, b, c): return (c / b) * -0.5
function code(a, b, c) return Float64(Float64(c / b) * -0.5) end
function tmp = code(a, b, c) tmp = (c / b) * -0.5; end
code[a_, b_, c_] := N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b} \cdot -0.5
\end{array}
Initial program 52.3%
/-rgt-identity52.3%
metadata-eval52.3%
Simplified52.4%
Taylor expanded in b around inf 66.9%
Final simplification66.9%
(FPCore (a b c) :precision binary64 (/ 0.0 a))
double code(double a, double b, double c) {
return 0.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 = 0.0d0 / a
end function
public static double code(double a, double b, double c) {
return 0.0 / a;
}
def code(a, b, c): return 0.0 / a
function code(a, b, c) return Float64(0.0 / a) end
function tmp = code(a, b, c) tmp = 0.0 / a; end
code[a_, b_, c_] := N[(0.0 / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{0}{a}
\end{array}
Initial program 52.3%
neg-sub052.3%
flip--52.2%
metadata-eval52.2%
pow252.2%
add-sqr-sqrt51.6%
sqrt-prod52.2%
sqr-neg52.2%
sqrt-unprod0.0%
add-sqr-sqrt1.6%
sub-neg1.6%
neg-sub01.6%
add-sqr-sqrt0.0%
sqrt-unprod52.2%
sqr-neg52.2%
sqrt-prod51.6%
add-sqr-sqrt52.2%
Applied egg-rr52.2%
neg-sub052.2%
Simplified52.2%
Taylor expanded in a around 0 3.2%
associate-*r/3.2%
distribute-rgt1-in3.2%
metadata-eval3.2%
mul0-lft3.2%
metadata-eval3.2%
Simplified3.2%
herbie shell --seed 2024139
(FPCore (a b c)
:name "Cubic critical, narrow range"
:precision binary64
:pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))