
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.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) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.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) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
(FPCore (a b c) :precision binary64 (let* ((t_0 (* c (* 4.0 a)))) (/ t_0 (* (* a 2.0) (- (- b) (sqrt (- (pow b 2.0) t_0)))))))
double code(double a, double b, double c) {
double t_0 = c * (4.0 * a);
return t_0 / ((a * 2.0) * (-b - sqrt((pow(b, 2.0) - t_0))));
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
t_0 = c * (4.0d0 * a)
code = t_0 / ((a * 2.0d0) * (-b - sqrt(((b ** 2.0d0) - t_0))))
end function
public static double code(double a, double b, double c) {
double t_0 = c * (4.0 * a);
return t_0 / ((a * 2.0) * (-b - Math.sqrt((Math.pow(b, 2.0) - t_0))));
}
def code(a, b, c): t_0 = c * (4.0 * a) return t_0 / ((a * 2.0) * (-b - math.sqrt((math.pow(b, 2.0) - t_0))))
function code(a, b, c) t_0 = Float64(c * Float64(4.0 * a)) return Float64(t_0 / Float64(Float64(a * 2.0) * Float64(Float64(-b) - sqrt(Float64((b ^ 2.0) - t_0))))) end
function tmp = code(a, b, c) t_0 = c * (4.0 * a); tmp = t_0 / ((a * 2.0) * (-b - sqrt(((b ^ 2.0) - t_0)))); end
code[a_, b_, c_] := Block[{t$95$0 = N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 / N[(N[(a * 2.0), $MachinePrecision] * N[((-b) - N[Sqrt[N[(N[Power[b, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \left(4 \cdot a\right)\\
\frac{t\_0}{\left(a \cdot 2\right) \cdot \left(\left(-b\right) - \sqrt{{b}^{2} - t\_0}\right)}
\end{array}
\end{array}
Initial program 57.4%
*-commutative57.4%
Simplified57.4%
add-cbrt-cube57.4%
pow357.4%
Applied egg-rr57.4%
flip-+57.4%
pow257.4%
add-sqr-sqrt59.1%
pow259.1%
*-commutative59.1%
unpow359.1%
add-cbrt-cube59.1%
*-commutative59.1%
Applied egg-rr59.1%
*-un-lft-identity59.1%
associate-/l/59.1%
associate--r-99.4%
neg-mul-199.4%
unpow-prod-down99.4%
metadata-eval99.4%
*-un-lft-identity99.4%
*-commutative99.4%
Applied egg-rr99.4%
*-un-lft-identity99.4%
+-commutative99.4%
fma-define99.4%
+-inverses99.4%
*-commutative99.4%
Applied egg-rr99.4%
fma-undefine99.4%
+-rgt-identity99.4%
*-commutative99.4%
*-commutative99.4%
*-commutative99.4%
*-commutative99.4%
Simplified99.4%
(FPCore (a b c)
:precision binary64
(/
(/
1.0
(/
(+
(* -0.5 (/ b c))
(* a (+ (* 0.5 (/ (* c a) (pow b 3.0))) (* 0.5 (/ 1.0 b)))))
a))
(* a 2.0)))
double code(double a, double b, double c) {
return (1.0 / (((-0.5 * (b / c)) + (a * ((0.5 * ((c * a) / pow(b, 3.0))) + (0.5 * (1.0 / b))))) / a)) / (a * 2.0);
}
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 / ((((-0.5d0) * (b / c)) + (a * ((0.5d0 * ((c * a) / (b ** 3.0d0))) + (0.5d0 * (1.0d0 / b))))) / a)) / (a * 2.0d0)
end function
public static double code(double a, double b, double c) {
return (1.0 / (((-0.5 * (b / c)) + (a * ((0.5 * ((c * a) / Math.pow(b, 3.0))) + (0.5 * (1.0 / b))))) / a)) / (a * 2.0);
}
def code(a, b, c): return (1.0 / (((-0.5 * (b / c)) + (a * ((0.5 * ((c * a) / math.pow(b, 3.0))) + (0.5 * (1.0 / b))))) / a)) / (a * 2.0)
function code(a, b, c) return Float64(Float64(1.0 / Float64(Float64(Float64(-0.5 * Float64(b / c)) + Float64(a * Float64(Float64(0.5 * Float64(Float64(c * a) / (b ^ 3.0))) + Float64(0.5 * Float64(1.0 / b))))) / a)) / Float64(a * 2.0)) end
function tmp = code(a, b, c) tmp = (1.0 / (((-0.5 * (b / c)) + (a * ((0.5 * ((c * a) / (b ^ 3.0))) + (0.5 * (1.0 / b))))) / a)) / (a * 2.0); end
code[a_, b_, c_] := N[(N[(1.0 / N[(N[(N[(-0.5 * N[(b / c), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[(0.5 * N[(N[(c * a), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{\frac{-0.5 \cdot \frac{b}{c} + a \cdot \left(0.5 \cdot \frac{c \cdot a}{{b}^{3}} + 0.5 \cdot \frac{1}{b}\right)}{a}}}{a \cdot 2}
\end{array}
Initial program 57.4%
*-commutative57.4%
Simplified57.4%
add-cbrt-cube57.4%
pow357.4%
Applied egg-rr57.4%
flip-+57.4%
pow257.4%
add-sqr-sqrt59.1%
pow259.1%
*-commutative59.1%
unpow359.1%
add-cbrt-cube59.1%
*-commutative59.1%
Applied egg-rr59.1%
clear-num59.1%
inv-pow59.1%
associate--r-99.4%
neg-mul-199.4%
unpow-prod-down99.4%
metadata-eval99.4%
*-un-lft-identity99.4%
Applied egg-rr99.4%
unpow-199.4%
associate-*r*99.4%
*-commutative99.4%
*-commutative99.4%
cancel-sign-sub-inv99.4%
metadata-eval99.4%
+-commutative99.4%
fma-define99.4%
*-commutative99.4%
+-inverses99.4%
+-lft-identity99.4%
associate-*r*99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
Simplified99.4%
Taylor expanded in a around 0 88.4%
Final simplification88.4%
(FPCore (a b c)
:precision binary64
(/
(/
1.0
(/
(+
(* -0.5 (/ b a))
(* c (+ (* 0.5 (/ (* c a) (pow b 3.0))) (* 0.5 (/ 1.0 b)))))
c))
(* a 2.0)))
double code(double a, double b, double c) {
return (1.0 / (((-0.5 * (b / a)) + (c * ((0.5 * ((c * a) / pow(b, 3.0))) + (0.5 * (1.0 / b))))) / c)) / (a * 2.0);
}
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 / ((((-0.5d0) * (b / a)) + (c * ((0.5d0 * ((c * a) / (b ** 3.0d0))) + (0.5d0 * (1.0d0 / b))))) / c)) / (a * 2.0d0)
end function
public static double code(double a, double b, double c) {
return (1.0 / (((-0.5 * (b / a)) + (c * ((0.5 * ((c * a) / Math.pow(b, 3.0))) + (0.5 * (1.0 / b))))) / c)) / (a * 2.0);
}
def code(a, b, c): return (1.0 / (((-0.5 * (b / a)) + (c * ((0.5 * ((c * a) / math.pow(b, 3.0))) + (0.5 * (1.0 / b))))) / c)) / (a * 2.0)
function code(a, b, c) return Float64(Float64(1.0 / Float64(Float64(Float64(-0.5 * Float64(b / a)) + Float64(c * Float64(Float64(0.5 * Float64(Float64(c * a) / (b ^ 3.0))) + Float64(0.5 * Float64(1.0 / b))))) / c)) / Float64(a * 2.0)) end
function tmp = code(a, b, c) tmp = (1.0 / (((-0.5 * (b / a)) + (c * ((0.5 * ((c * a) / (b ^ 3.0))) + (0.5 * (1.0 / b))))) / c)) / (a * 2.0); end
code[a_, b_, c_] := N[(N[(1.0 / N[(N[(N[(-0.5 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(c * N[(N[(0.5 * N[(N[(c * a), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{\frac{-0.5 \cdot \frac{b}{a} + c \cdot \left(0.5 \cdot \frac{c \cdot a}{{b}^{3}} + 0.5 \cdot \frac{1}{b}\right)}{c}}}{a \cdot 2}
\end{array}
Initial program 57.4%
*-commutative57.4%
Simplified57.4%
add-cbrt-cube57.4%
pow357.4%
Applied egg-rr57.4%
flip-+57.4%
pow257.4%
add-sqr-sqrt59.1%
pow259.1%
*-commutative59.1%
unpow359.1%
add-cbrt-cube59.1%
*-commutative59.1%
Applied egg-rr59.1%
clear-num59.1%
inv-pow59.1%
associate--r-99.4%
neg-mul-199.4%
unpow-prod-down99.4%
metadata-eval99.4%
*-un-lft-identity99.4%
Applied egg-rr99.4%
unpow-199.4%
associate-*r*99.4%
*-commutative99.4%
*-commutative99.4%
cancel-sign-sub-inv99.4%
metadata-eval99.4%
+-commutative99.4%
fma-define99.4%
*-commutative99.4%
+-inverses99.4%
+-lft-identity99.4%
associate-*r*99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
Simplified99.4%
Taylor expanded in c around 0 88.4%
Final simplification88.4%
(FPCore (a b c) :precision binary64 (if (<= b 17.0) (/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* a 2.0)) (/ (/ 1.0 (/ (+ (* -0.5 (/ b a)) (* 0.5 (/ c b))) c)) (* a 2.0))))
double code(double a, double b, double c) {
double tmp;
if (b <= 17.0) {
tmp = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (a * 2.0);
} else {
tmp = (1.0 / (((-0.5 * (b / a)) + (0.5 * (c / b))) / c)) / (a * 2.0);
}
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 <= 17.0d0) then
tmp = (sqrt(((b * b) - (c * (4.0d0 * a)))) - b) / (a * 2.0d0)
else
tmp = (1.0d0 / ((((-0.5d0) * (b / a)) + (0.5d0 * (c / b))) / c)) / (a * 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 17.0) {
tmp = (Math.sqrt(((b * b) - (c * (4.0 * a)))) - b) / (a * 2.0);
} else {
tmp = (1.0 / (((-0.5 * (b / a)) + (0.5 * (c / b))) / c)) / (a * 2.0);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 17.0: tmp = (math.sqrt(((b * b) - (c * (4.0 * a)))) - b) / (a * 2.0) else: tmp = (1.0 / (((-0.5 * (b / a)) + (0.5 * (c / b))) / c)) / (a * 2.0) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 17.0) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(1.0 / Float64(Float64(Float64(-0.5 * Float64(b / a)) + Float64(0.5 * Float64(c / b))) / c)) / Float64(a * 2.0)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 17.0) tmp = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (a * 2.0); else tmp = (1.0 / (((-0.5 * (b / a)) + (0.5 * (c / b))) / c)) / (a * 2.0); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 17.0], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[(N[(-0.5 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 17:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\frac{-0.5 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}}{c}}}{a \cdot 2}\\
\end{array}
\end{array}
if b < 17Initial program 78.0%
if 17 < b Initial program 50.0%
*-commutative50.0%
Simplified50.0%
add-cbrt-cube50.0%
pow350.0%
Applied egg-rr50.0%
flip-+49.9%
pow249.9%
add-sqr-sqrt51.6%
pow251.6%
*-commutative51.6%
unpow351.6%
add-cbrt-cube51.6%
*-commutative51.6%
Applied egg-rr51.6%
clear-num51.6%
inv-pow51.6%
associate--r-99.4%
neg-mul-199.4%
unpow-prod-down99.4%
metadata-eval99.4%
*-un-lft-identity99.4%
Applied egg-rr99.4%
unpow-199.4%
associate-*r*99.4%
*-commutative99.4%
*-commutative99.4%
cancel-sign-sub-inv99.4%
metadata-eval99.4%
+-commutative99.4%
fma-define99.4%
*-commutative99.4%
+-inverses99.4%
+-lft-identity99.4%
associate-*r*99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
Simplified99.4%
Taylor expanded in c around 0 87.4%
Final simplification84.9%
(FPCore (a b c) :precision binary64 (/ (/ 1.0 (/ (+ (* -0.5 (/ b c)) (* 0.5 (/ a b))) a)) (* a 2.0)))
double code(double a, double b, double c) {
return (1.0 / (((-0.5 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 2.0);
}
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 / ((((-0.5d0) * (b / c)) + (0.5d0 * (a / b))) / a)) / (a * 2.0d0)
end function
public static double code(double a, double b, double c) {
return (1.0 / (((-0.5 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 2.0);
}
def code(a, b, c): return (1.0 / (((-0.5 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 2.0)
function code(a, b, c) return Float64(Float64(1.0 / Float64(Float64(Float64(-0.5 * Float64(b / c)) + Float64(0.5 * Float64(a / b))) / a)) / Float64(a * 2.0)) end
function tmp = code(a, b, c) tmp = (1.0 / (((-0.5 * (b / c)) + (0.5 * (a / b))) / a)) / (a * 2.0); end
code[a_, b_, c_] := N[(N[(1.0 / N[(N[(N[(-0.5 * N[(b / c), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{\frac{-0.5 \cdot \frac{b}{c} + 0.5 \cdot \frac{a}{b}}{a}}}{a \cdot 2}
\end{array}
Initial program 57.4%
*-commutative57.4%
Simplified57.4%
add-cbrt-cube57.4%
pow357.4%
Applied egg-rr57.4%
flip-+57.4%
pow257.4%
add-sqr-sqrt59.1%
pow259.1%
*-commutative59.1%
unpow359.1%
add-cbrt-cube59.1%
*-commutative59.1%
Applied egg-rr59.1%
clear-num59.1%
inv-pow59.1%
associate--r-99.4%
neg-mul-199.4%
unpow-prod-down99.4%
metadata-eval99.4%
*-un-lft-identity99.4%
Applied egg-rr99.4%
unpow-199.4%
associate-*r*99.4%
*-commutative99.4%
*-commutative99.4%
cancel-sign-sub-inv99.4%
metadata-eval99.4%
+-commutative99.4%
fma-define99.4%
*-commutative99.4%
+-inverses99.4%
+-lft-identity99.4%
associate-*r*99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
Simplified99.4%
Taylor expanded in a around 0 81.9%
(FPCore (a b c) :precision binary64 (/ (/ 1.0 (/ (+ (* -0.5 (/ b a)) (* 0.5 (/ c b))) c)) (* a 2.0)))
double code(double a, double b, double c) {
return (1.0 / (((-0.5 * (b / a)) + (0.5 * (c / b))) / c)) / (a * 2.0);
}
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 / ((((-0.5d0) * (b / a)) + (0.5d0 * (c / b))) / c)) / (a * 2.0d0)
end function
public static double code(double a, double b, double c) {
return (1.0 / (((-0.5 * (b / a)) + (0.5 * (c / b))) / c)) / (a * 2.0);
}
def code(a, b, c): return (1.0 / (((-0.5 * (b / a)) + (0.5 * (c / b))) / c)) / (a * 2.0)
function code(a, b, c) return Float64(Float64(1.0 / Float64(Float64(Float64(-0.5 * Float64(b / a)) + Float64(0.5 * Float64(c / b))) / c)) / Float64(a * 2.0)) end
function tmp = code(a, b, c) tmp = (1.0 / (((-0.5 * (b / a)) + (0.5 * (c / b))) / c)) / (a * 2.0); end
code[a_, b_, c_] := N[(N[(1.0 / N[(N[(N[(-0.5 * N[(b / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{\frac{-0.5 \cdot \frac{b}{a} + 0.5 \cdot \frac{c}{b}}{c}}}{a \cdot 2}
\end{array}
Initial program 57.4%
*-commutative57.4%
Simplified57.4%
add-cbrt-cube57.4%
pow357.4%
Applied egg-rr57.4%
flip-+57.4%
pow257.4%
add-sqr-sqrt59.1%
pow259.1%
*-commutative59.1%
unpow359.1%
add-cbrt-cube59.1%
*-commutative59.1%
Applied egg-rr59.1%
clear-num59.1%
inv-pow59.1%
associate--r-99.4%
neg-mul-199.4%
unpow-prod-down99.4%
metadata-eval99.4%
*-un-lft-identity99.4%
Applied egg-rr99.4%
unpow-199.4%
associate-*r*99.4%
*-commutative99.4%
*-commutative99.4%
cancel-sign-sub-inv99.4%
metadata-eval99.4%
+-commutative99.4%
fma-define99.4%
*-commutative99.4%
+-inverses99.4%
+-lft-identity99.4%
associate-*r*99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
Simplified99.4%
Taylor expanded in c around 0 81.9%
(FPCore (a b c) :precision binary64 (/ c (- b)))
double code(double a, double b, double c) {
return 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 = c / -b
end function
public static double code(double a, double b, double c) {
return c / -b;
}
def code(a, b, c): return c / -b
function code(a, b, c) return Float64(c / Float64(-b)) end
function tmp = code(a, b, c) tmp = c / -b; end
code[a_, b_, c_] := N[(c / (-b)), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{-b}
\end{array}
Initial program 57.4%
*-commutative57.4%
Simplified57.5%
Taylor expanded in b around inf 63.1%
associate-*r/63.1%
mul-1-neg63.1%
Simplified63.1%
Final simplification63.1%
herbie shell --seed 2024179
(FPCore (a b c)
:name "Quadratic roots, 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) (* (* 4.0 a) c)))) (* 2.0 a)))