
(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 -4.5e+105)
(- (/ b a))
(if (<= b 7.5e-97)
(/ (- (sqrt (fma a (* c -4.0) (* b b))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e+105) {
tmp = -(b / a);
} else if (b <= 7.5e-97) {
tmp = (sqrt(fma(a, (c * -4.0), (b * b))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.5e+105) tmp = Float64(-Float64(b / a)); elseif (b <= 7.5e-97) tmp = Float64(Float64(sqrt(fma(a, Float64(c * -4.0), Float64(b * b))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.5e+105], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 7.5e-97], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[(b * b), $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 -4.5 \cdot 10^{+105}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 7.5 \cdot 10^{-97}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(a, c \cdot -4, b \cdot b\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -4.5000000000000001e105Initial program 52.3%
*-commutative52.3%
Simplified52.3%
Taylor expanded in b around -inf 95.0%
associate-*r/95.0%
mul-1-neg95.0%
Simplified95.0%
if -4.5000000000000001e105 < b < 7.5e-97Initial program 79.9%
Simplified79.9%
if 7.5e-97 < b Initial program 18.7%
*-commutative18.7%
Simplified18.7%
Taylor expanded in b around inf 85.5%
mul-1-neg85.5%
distribute-neg-frac85.5%
Simplified85.5%
Final simplification85.5%
(FPCore (a b c)
:precision binary64
(if (<= b -3.8e+105)
(- (/ b a))
(if (<= b 9.5e-104)
(/ (- (sqrt (- (* b b) (* c (* a 4.0)))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.8e+105) {
tmp = -(b / a);
} else if (b <= 9.5e-104) {
tmp = (sqrt(((b * b) - (c * (a * 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 <= (-3.8d+105)) then
tmp = -(b / a)
else if (b <= 9.5d-104) then
tmp = (sqrt(((b * b) - (c * (a * 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 <= -3.8e+105) {
tmp = -(b / a);
} else if (b <= 9.5e-104) {
tmp = (Math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3.8e+105: tmp = -(b / a) elif b <= 9.5e-104: tmp = (math.sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3.8e+105) tmp = Float64(-Float64(b / a)); elseif (b <= 9.5e-104) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3.8e+105) tmp = -(b / a); elseif (b <= 9.5e-104) tmp = (sqrt(((b * b) - (c * (a * 4.0)))) - b) / (a * 2.0); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3.8e+105], (-N[(b / a), $MachinePrecision]), If[LessEqual[b, 9.5e-104], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(a * 4.0), $MachinePrecision]), $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.8 \cdot 10^{+105}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{elif}\;b \leq 9.5 \cdot 10^{-104}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(a \cdot 4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -3.8e105Initial program 52.3%
*-commutative52.3%
Simplified52.3%
Taylor expanded in b around -inf 95.0%
associate-*r/95.0%
mul-1-neg95.0%
Simplified95.0%
if -3.8e105 < b < 9.5000000000000002e-104Initial program 80.7%
if 9.5000000000000002e-104 < b Initial program 18.6%
*-commutative18.6%
Simplified18.6%
Taylor expanded in b around inf 84.7%
mul-1-neg84.7%
distribute-neg-frac84.7%
Simplified84.7%
Final simplification85.5%
(FPCore (a b c)
:precision binary64
(if (<= b -1.4e-103)
(- (/ c b) (/ b a))
(if (<= b 9.2e-104)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.4e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 9.2e-104) {
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 <= (-1.4d-103)) then
tmp = (c / b) - (b / a)
else if (b <= 9.2d-104) 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 <= -1.4e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 9.2e-104) {
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 <= -1.4e-103: tmp = (c / b) - (b / a) elif b <= 9.2e-104: 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 <= -1.4e-103) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 9.2e-104) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.4e-103) tmp = (c / b) - (b / a); elseif (b <= 9.2e-104) 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, -1.4e-103], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9.2e-104], 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 -1.4 \cdot 10^{-103}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 9.2 \cdot 10^{-104}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.40000000000000011e-103Initial program 72.3%
*-commutative72.3%
Simplified72.3%
Taylor expanded in b around -inf 88.9%
+-commutative88.9%
mul-1-neg88.9%
unsub-neg88.9%
Simplified88.9%
if -1.40000000000000011e-103 < b < 9.1999999999999998e-104Initial program 66.2%
*-commutative66.2%
Simplified66.2%
prod-diff65.6%
*-commutative65.6%
fma-def65.6%
associate-+l+65.6%
pow265.6%
distribute-lft-neg-in65.6%
*-commutative65.6%
distribute-rgt-neg-in65.6%
metadata-eval65.6%
associate-*r*65.6%
*-commutative65.6%
*-commutative65.6%
fma-udef65.6%
Applied egg-rr65.6%
fma-def65.6%
fma-def65.6%
associate-*l*65.6%
Simplified65.6%
Taylor expanded in b around 0 65.6%
distribute-rgt-out66.2%
metadata-eval66.2%
associate-*r*66.2%
mul-1-neg66.2%
unsub-neg66.2%
*-commutative66.2%
Simplified66.2%
if 9.1999999999999998e-104 < b Initial program 18.6%
*-commutative18.6%
Simplified18.6%
Taylor expanded in b around inf 84.7%
mul-1-neg84.7%
distribute-neg-frac84.7%
Simplified84.7%
Final simplification82.6%
(FPCore (a b c) :precision binary64 (if (<= b -1.5e-103) (- (/ c b) (/ b a)) (if (<= b 4.4e-104) (* 0.5 (/ (sqrt (* a (* c -4.0))) a)) (/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 4.4e-104) {
tmp = 0.5 * (sqrt((a * (c * -4.0))) / 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 <= (-1.5d-103)) then
tmp = (c / b) - (b / a)
else if (b <= 4.4d-104) then
tmp = 0.5d0 * (sqrt((a * (c * (-4.0d0)))) / 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 <= -1.5e-103) {
tmp = (c / b) - (b / a);
} else if (b <= 4.4e-104) {
tmp = 0.5 * (Math.sqrt((a * (c * -4.0))) / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.5e-103: tmp = (c / b) - (b / a) elif b <= 4.4e-104: tmp = 0.5 * (math.sqrt((a * (c * -4.0))) / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.5e-103) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 4.4e-104) tmp = Float64(0.5 * Float64(sqrt(Float64(a * Float64(c * -4.0))) / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.5e-103) tmp = (c / b) - (b / a); elseif (b <= 4.4e-104) tmp = 0.5 * (sqrt((a * (c * -4.0))) / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.5e-103], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4.4e-104], N[(0.5 * N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{-103}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{-104}:\\
\;\;\;\;0.5 \cdot \frac{\sqrt{a \cdot \left(c \cdot -4\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.5e-103Initial program 72.3%
*-commutative72.3%
Simplified72.3%
Taylor expanded in b around -inf 88.9%
+-commutative88.9%
mul-1-neg88.9%
unsub-neg88.9%
Simplified88.9%
if -1.5e-103 < b < 4.40000000000000023e-104Initial program 66.2%
*-commutative66.2%
Simplified66.2%
prod-diff65.6%
*-commutative65.6%
fma-def65.6%
associate-+l+65.6%
pow265.6%
distribute-lft-neg-in65.6%
*-commutative65.6%
distribute-rgt-neg-in65.6%
metadata-eval65.6%
associate-*r*65.6%
*-commutative65.6%
*-commutative65.6%
fma-udef65.6%
Applied egg-rr65.6%
fma-def65.6%
fma-def65.6%
associate-*l*65.6%
Simplified65.6%
Taylor expanded in b around 0 64.9%
associate-*l/64.9%
distribute-rgt-out65.4%
metadata-eval65.4%
associate-*r*65.5%
*-lft-identity65.5%
*-commutative65.5%
Simplified65.5%
if 4.40000000000000023e-104 < b Initial program 18.6%
*-commutative18.6%
Simplified18.6%
Taylor expanded in b around inf 84.7%
mul-1-neg84.7%
distribute-neg-frac84.7%
Simplified84.7%
Final simplification82.4%
(FPCore (a b c) :precision binary64 (if (<= b 1.45e+44) (- (/ b a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.45e+44) {
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 <= 1.45d+44) 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 <= 1.45e+44) {
tmp = -(b / a);
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.45e+44: tmp = -(b / a) else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.45e+44) 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 <= 1.45e+44) tmp = -(b / a); else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.45e+44], (-N[(b / a), $MachinePrecision]), N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.45 \cdot 10^{+44}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.4500000000000001e44Initial program 63.4%
*-commutative63.4%
Simplified63.4%
Taylor expanded in b around -inf 50.9%
associate-*r/50.9%
mul-1-neg50.9%
Simplified50.9%
if 1.4500000000000001e44 < b Initial program 13.0%
*-commutative13.0%
Simplified13.0%
Taylor expanded in b around inf 73.6%
associate-/l*81.6%
associate-/r/70.1%
Simplified70.1%
associate-*l/73.6%
frac-2neg73.6%
add-sqr-sqrt0.0%
sqrt-unprod29.4%
sqr-neg29.4%
sqrt-prod29.1%
add-sqr-sqrt29.1%
Applied egg-rr29.1%
distribute-frac-neg29.1%
*-commutative29.1%
associate-*r/29.4%
distribute-rgt-neg-in29.4%
Simplified29.4%
Taylor expanded in c around 0 29.0%
Final simplification44.8%
(FPCore (a b c) :precision binary64 (if (<= b 7.5e-298) (- (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 7.5e-298) {
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 <= 7.5d-298) 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 <= 7.5e-298) {
tmp = -(b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 7.5e-298: tmp = -(b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 7.5e-298) tmp = Float64(-Float64(b / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 7.5e-298) tmp = -(b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 7.5e-298], (-N[(b / a), $MachinePrecision]), N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7.5 \cdot 10^{-298}:\\
\;\;\;\;-\frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 7.49999999999999987e-298Initial program 70.6%
*-commutative70.6%
Simplified70.6%
Taylor expanded in b around -inf 73.0%
associate-*r/73.0%
mul-1-neg73.0%
Simplified73.0%
if 7.49999999999999987e-298 < b Initial program 28.5%
*-commutative28.5%
Simplified28.5%
Taylor expanded in b around inf 71.6%
mul-1-neg71.6%
distribute-neg-frac71.6%
Simplified71.6%
Final simplification72.3%
(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 49.2%
Simplified49.2%
*-un-lft-identity49.2%
*-un-lft-identity49.2%
prod-diff49.2%
*-commutative49.2%
*-un-lft-identity49.2%
fma-def49.2%
*-un-lft-identity49.2%
+-commutative49.2%
add-sqr-sqrt34.3%
sqrt-unprod45.9%
sqr-neg45.9%
sqrt-prod11.7%
add-sqr-sqrt27.8%
pow227.8%
add-sqr-sqrt16.8%
sqrt-unprod27.8%
sqr-neg27.8%
sqrt-prod11.7%
add-sqr-sqrt27.5%
*-commutative27.5%
*-un-lft-identity27.5%
Applied egg-rr27.5%
associate-+l+27.5%
fma-udef27.5%
*-rgt-identity27.5%
Simplified27.5%
Taylor expanded in b around -inf 2.4%
Final simplification2.4%
(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 49.2%
*-commutative49.2%
Simplified49.2%
Taylor expanded in b around inf 27.9%
associate-/l*31.5%
associate-/r/28.2%
Simplified28.2%
associate-*l/27.9%
frac-2neg27.9%
add-sqr-sqrt1.0%
sqrt-unprod9.6%
sqr-neg9.6%
sqrt-prod8.6%
add-sqr-sqrt10.3%
Applied egg-rr10.3%
distribute-frac-neg10.3%
*-commutative10.3%
associate-*r/10.4%
distribute-rgt-neg-in10.4%
Simplified10.4%
Taylor expanded in c around 0 10.3%
Final simplification10.3%
herbie shell --seed 2023335
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))