
(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 8 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
(if (<= b -3e+151)
(- (/ b a))
(if (<= b 7.6e-34)
(/ (- (sqrt (- (* b b) (* (* a 4.0) c))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3e+151) {
tmp = -(b / a);
} else if (b <= 7.6e-34) {
tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} else {
tmp = 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+151)) then
tmp = -(b / a)
else if (b <= 7.6d-34) then
tmp = (sqrt(((b * b) - ((a * 4.0d0) * c))) - b) / (a * 2.0d0)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3e+151) {
tmp = -(b / a);
} else if (b <= 7.6e-34) {
tmp = (Math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3e+151: tmp = -(b / a) elif b <= 7.6e-34: tmp = (math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3e+151) tmp = Float64(-Float64(b / a)); elseif (b <= 7.6e-34) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3e+151) tmp = -(b / a); elseif (b <= 7.6e-34) tmp = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3e+151], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 7.6e-34], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3 \cdot 10^{+151}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 7.6 \cdot 10^{-34}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -2.9999999999999999e151Initial program 52.3%
*-commutative52.3%
Simplified52.3%
Taylor expanded in b around -inf 96.3%
associate-*r/96.3%
mul-1-neg96.3%
Simplified96.3%
if -2.9999999999999999e151 < b < 7.6000000000000002e-34Initial program 83.1%
if 7.6000000000000002e-34 < b Initial program 15.2%
*-commutative15.2%
Simplified15.2%
Taylor expanded in b around inf 89.5%
associate-*r/89.5%
mul-1-neg89.5%
Simplified89.5%
Final simplification87.7%
(FPCore (a b c)
:precision binary64
(if (<= b -5.5e-70)
(- (/ b a))
(if (<= b 1.3e-38)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-70) {
tmp = -(b / a);
} else if (b <= 1.3e-38) {
tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = 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.5d-70)) then
tmp = -(b / a)
else if (b <= 1.3d-38) then
tmp = (sqrt((a * (c * (-4.0d0)))) - b) / (a * 2.0d0)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-70) {
tmp = -(b / a);
} else if (b <= 1.3e-38) {
tmp = (Math.sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.5e-70: tmp = -(b / a) elif b <= 1.3e-38: tmp = (math.sqrt((a * (c * -4.0))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.5e-70) tmp = Float64(-Float64(b / a)); elseif (b <= 1.3e-38) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.5e-70) tmp = -(b / a); elseif (b <= 1.3e-38) tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.5e-70], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 1.3e-38], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{-70}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 1.3 \cdot 10^{-38}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -5.5000000000000001e-70Initial program 75.0%
*-commutative75.0%
Simplified75.0%
Taylor expanded in b around -inf 88.1%
associate-*r/88.1%
mul-1-neg88.1%
Simplified88.1%
if -5.5000000000000001e-70 < b < 1.30000000000000005e-38Initial program 72.6%
*-commutative72.6%
Simplified72.6%
Taylor expanded in b around 0 72.6%
*-commutative72.6%
associate-*r*72.6%
Simplified72.6%
add-sqr-sqrt72.2%
pow272.2%
pow1/272.2%
sqrt-pow172.2%
metadata-eval72.2%
Applied egg-rr72.2%
pow-pow72.6%
metadata-eval72.6%
pow1/272.6%
+-commutative72.6%
unsub-neg72.6%
Applied egg-rr72.6%
if 1.30000000000000005e-38 < b Initial program 15.2%
*-commutative15.2%
Simplified15.2%
Taylor expanded in b around inf 89.5%
associate-*r/89.5%
mul-1-neg89.5%
Simplified89.5%
Final simplification84.3%
(FPCore (a b c)
:precision binary64
(if (<= b -2.4e-68)
(- (/ b a))
(if (<= b 1.95e-42)
(/ (+ b (sqrt (* a (* c -4.0)))) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.4e-68) {
tmp = -(b / a);
} else if (b <= 1.95e-42) {
tmp = (b + sqrt((a * (c * -4.0)))) / (a * 2.0);
} else {
tmp = 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.4d-68)) then
tmp = -(b / a)
else if (b <= 1.95d-42) then
tmp = (b + sqrt((a * (c * (-4.0d0))))) / (a * 2.0d0)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -2.4e-68) {
tmp = -(b / a);
} else if (b <= 1.95e-42) {
tmp = (b + Math.sqrt((a * (c * -4.0)))) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.4e-68: tmp = -(b / a) elif b <= 1.95e-42: tmp = (b + math.sqrt((a * (c * -4.0)))) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.4e-68) tmp = Float64(-Float64(b / a)); elseif (b <= 1.95e-42) tmp = Float64(Float64(b + sqrt(Float64(a * Float64(c * -4.0)))) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.4e-68) tmp = -(b / a); elseif (b <= 1.95e-42) tmp = (b + sqrt((a * (c * -4.0)))) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.4e-68], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 1.95e-42], N[(N[(b + N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.4 \cdot 10^{-68}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 1.95 \cdot 10^{-42}:\\
\;\;\;\;\frac{b + \sqrt{a \cdot \left(c \cdot -4\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -2.39999999999999991e-68Initial program 75.0%
*-commutative75.0%
Simplified75.0%
Taylor expanded in b around -inf 88.1%
associate-*r/88.1%
mul-1-neg88.1%
Simplified88.1%
if -2.39999999999999991e-68 < b < 1.9500000000000001e-42Initial program 72.6%
*-commutative72.6%
Simplified72.6%
Taylor expanded in b around 0 72.6%
*-commutative72.6%
associate-*r*72.6%
Simplified72.6%
*-un-lft-identity72.6%
*-commutative72.6%
times-frac72.6%
metadata-eval72.6%
add-sqr-sqrt32.3%
sqrt-unprod72.1%
sqr-neg72.1%
sqrt-prod40.6%
add-sqr-sqrt72.2%
Applied egg-rr72.2%
metadata-eval72.2%
times-frac72.2%
*-lft-identity72.2%
*-commutative72.2%
Simplified72.2%
if 1.9500000000000001e-42 < b Initial program 15.2%
*-commutative15.2%
Simplified15.2%
Taylor expanded in b around inf 89.5%
associate-*r/89.5%
mul-1-neg89.5%
Simplified89.5%
Final simplification84.2%
(FPCore (a b c)
:precision binary64
(if (<= b -4.5e-70)
(- (/ b a))
(if (<= b 1.1e-41)
(* (/ 0.5 a) (+ b (sqrt (* c (* a -4.0)))))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e-70) {
tmp = -(b / a);
} else if (b <= 1.1e-41) {
tmp = (0.5 / a) * (b + sqrt((c * (a * -4.0))));
} else {
tmp = 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.5d-70)) then
tmp = -(b / a)
else if (b <= 1.1d-41) then
tmp = (0.5d0 / a) * (b + sqrt((c * (a * (-4.0d0)))))
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e-70) {
tmp = -(b / a);
} else if (b <= 1.1e-41) {
tmp = (0.5 / a) * (b + Math.sqrt((c * (a * -4.0))));
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.5e-70: tmp = -(b / a) elif b <= 1.1e-41: tmp = (0.5 / a) * (b + math.sqrt((c * (a * -4.0)))) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.5e-70) tmp = Float64(-Float64(b / a)); elseif (b <= 1.1e-41) tmp = Float64(Float64(0.5 / a) * Float64(b + sqrt(Float64(c * Float64(a * -4.0))))); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.5e-70) tmp = -(b / a); elseif (b <= 1.1e-41) tmp = (0.5 / a) * (b + sqrt((c * (a * -4.0)))); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.5e-70], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 1.1e-41], N[(N[(0.5 / a), $MachinePrecision] * N[(b + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{-70}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{-41}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(b + \sqrt{c \cdot \left(a \cdot -4\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -4.50000000000000022e-70Initial program 75.0%
*-commutative75.0%
Simplified75.0%
Taylor expanded in b around -inf 88.1%
associate-*r/88.1%
mul-1-neg88.1%
Simplified88.1%
if -4.50000000000000022e-70 < b < 1.1e-41Initial program 72.6%
*-commutative72.6%
Simplified72.6%
Taylor expanded in b around 0 72.6%
*-commutative72.6%
associate-*r*72.6%
Simplified72.6%
clear-num72.5%
inv-pow72.5%
*-commutative72.5%
*-un-lft-identity72.5%
times-frac72.5%
metadata-eval72.5%
add-sqr-sqrt32.3%
sqrt-unprod72.0%
sqr-neg72.0%
sqrt-prod40.5%
add-sqr-sqrt72.1%
Applied egg-rr72.1%
unpow-172.1%
associate-*r/72.1%
*-commutative72.1%
Simplified72.1%
associate-/r/72.0%
*-commutative72.0%
associate-/r*72.0%
metadata-eval72.0%
*-commutative72.0%
associate-*l*72.0%
Applied egg-rr72.0%
if 1.1e-41 < b Initial program 15.2%
*-commutative15.2%
Simplified15.2%
Taylor expanded in b around inf 89.5%
associate-*r/89.5%
mul-1-neg89.5%
Simplified89.5%
Final simplification84.1%
(FPCore (a b c) :precision binary64 (if (<= b 2.15e-297) (- (/ b a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.15e-297) {
tmp = -(b / a);
} else {
tmp = 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.15d-297) then
tmp = -(b / a)
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 2.15e-297) {
tmp = -(b / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.15e-297: tmp = -(b / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.15e-297) tmp = Float64(-Float64(b / a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.15e-297) tmp = -(b / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.15e-297], (-N[(b / a), $MachinePrecision]), N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.15 \cdot 10^{-297}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < 2.1500000000000002e-297Initial program 74.9%
*-commutative74.9%
Simplified74.9%
Taylor expanded in b around -inf 69.5%
associate-*r/69.5%
mul-1-neg69.5%
Simplified69.5%
if 2.1500000000000002e-297 < b Initial program 33.0%
*-commutative33.0%
Simplified33.0%
Taylor expanded in b around inf 64.1%
associate-*r/64.1%
mul-1-neg64.1%
Simplified64.1%
Final simplification67.0%
(FPCore (a b c) :precision binary64 (if (<= b 5.8e+27) (- (/ b a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 5.8e+27) {
tmp = -(b / a);
} else {
tmp = 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+27) then
tmp = -(b / a)
else
tmp = c / b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 5.8e+27) {
tmp = -(b / a);
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 5.8e+27: tmp = -(b / a) else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 5.8e+27) tmp = Float64(-Float64(b / a)); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 5.8e+27) tmp = -(b / a); else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 5.8e+27], (-N[(b / a), $MachinePrecision]), N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 5.8 \cdot 10^{+27}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 5.8000000000000002e27Initial program 70.4%
*-commutative70.4%
Simplified70.4%
Taylor expanded in b around -inf 51.6%
associate-*r/51.6%
mul-1-neg51.6%
Simplified51.6%
if 5.8000000000000002e27 < b Initial program 13.1%
*-commutative13.1%
Simplified13.1%
Taylor expanded in b around inf 82.3%
associate-*r/82.3%
frac-2neg82.3%
add-sqr-sqrt0.0%
sqrt-unprod41.0%
sqr-neg41.0%
sqrt-prod40.7%
add-sqr-sqrt40.7%
Applied egg-rr40.7%
distribute-frac-neg40.7%
associate-*r/40.7%
associate-*r/40.8%
distribute-lft-neg-in40.8%
metadata-eval40.8%
Simplified40.8%
Taylor expanded in a around 0 40.7%
Final simplification48.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 / 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 55.9%
*-commutative55.9%
Simplified55.9%
Taylor expanded in b around inf 26.0%
associate-*r/26.0%
frac-2neg26.0%
add-sqr-sqrt1.2%
sqrt-unprod11.8%
sqr-neg11.8%
sqrt-prod10.7%
add-sqr-sqrt12.5%
Applied egg-rr12.5%
distribute-frac-neg12.5%
associate-*r/12.5%
associate-*r/12.6%
distribute-lft-neg-in12.6%
metadata-eval12.6%
Simplified12.6%
Taylor expanded in a around 0 12.6%
(FPCore (a b c) :precision binary64 (/ b a))
double code(double a, double b, double c) {
return b / 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 / a
end function
public static double code(double a, double b, double c) {
return b / a;
}
def code(a, b, c): return b / a
function code(a, b, c) return Float64(b / a) end
function tmp = code(a, b, c) tmp = b / a; end
code[a_, b_, c_] := N[(b / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{a}
\end{array}
Initial program 55.9%
*-commutative55.9%
Simplified55.9%
Taylor expanded in b around -inf 39.1%
associate-*r/39.1%
mul-1-neg39.1%
Simplified39.1%
div-inv39.0%
add-sqr-sqrt37.7%
sqrt-unprod29.9%
sqr-neg29.9%
sqrt-prod1.8%
add-sqr-sqrt2.5%
Applied egg-rr2.5%
associate-*r/2.5%
*-rgt-identity2.5%
Simplified2.5%
herbie shell --seed 2024116
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))