
(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 -2e+135)
(- (/ c b) (/ b a))
(if (<= b 1.05e-72)
(/ (- (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 <= -2e+135) {
tmp = (c / b) - (b / a);
} else if (b <= 1.05e-72) {
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 <= (-2d+135)) then
tmp = (c / b) - (b / a)
else if (b <= 1.05d-72) 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 <= -2e+135) {
tmp = (c / b) - (b / a);
} else if (b <= 1.05e-72) {
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 <= -2e+135: tmp = (c / b) - (b / a) elif b <= 1.05e-72: 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 <= -2e+135) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.05e-72) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(a * 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 <= -2e+135) tmp = (c / b) - (b / a); elseif (b <= 1.05e-72) 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, -2e+135], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.05e-72], 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 -2 \cdot 10^{+135}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.05 \cdot 10^{-72}:\\
\;\;\;\;\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 < -1.99999999999999992e135Initial program 47.4%
*-commutative47.4%
Simplified47.4%
Taylor expanded in b around -inf 89.6%
mul-1-neg89.6%
*-commutative89.6%
distribute-rgt-neg-in89.6%
+-commutative89.6%
mul-1-neg89.6%
unsub-neg89.6%
Simplified89.6%
Taylor expanded in a around inf 90.7%
+-commutative90.7%
neg-mul-190.7%
unsub-neg90.7%
Simplified90.7%
if -1.99999999999999992e135 < b < 1.05e-72Initial program 82.1%
if 1.05e-72 < b Initial program 17.9%
*-commutative17.9%
Simplified17.9%
Taylor expanded in a around 0 85.2%
associate-*r/85.2%
mul-1-neg85.2%
Simplified85.2%
Final simplification84.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.25e-67)
(- (/ c b) (/ b a))
(if (<= b 6.5e-73)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.25e-67) {
tmp = (c / b) - (b / a);
} else if (b <= 6.5e-73) {
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.25d-67)) then
tmp = (c / b) - (b / a)
else if (b <= 6.5d-73) 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.25e-67) {
tmp = (c / b) - (b / a);
} else if (b <= 6.5e-73) {
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.25e-67: tmp = (c / b) - (b / a) elif b <= 6.5e-73: 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.25e-67) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 6.5e-73) 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 <= -1.25e-67) tmp = (c / b) - (b / a); elseif (b <= 6.5e-73) 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.25e-67], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.5e-73], 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.25 \cdot 10^{-67}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{-73}:\\
\;\;\;\;\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.25e-67Initial program 63.5%
*-commutative63.5%
Simplified63.5%
Taylor expanded in b around -inf 80.8%
mul-1-neg80.8%
*-commutative80.8%
distribute-rgt-neg-in80.8%
+-commutative80.8%
mul-1-neg80.8%
unsub-neg80.8%
Simplified80.8%
Taylor expanded in a around inf 81.6%
+-commutative81.6%
neg-mul-181.6%
unsub-neg81.6%
Simplified81.6%
if -1.25e-67 < b < 6.4999999999999999e-73Initial program 81.0%
*-commutative81.0%
Simplified81.0%
Taylor expanded in a around inf 74.9%
*-commutative74.9%
associate-*r*75.0%
Simplified75.0%
if 6.4999999999999999e-73 < b Initial program 17.9%
*-commutative17.9%
Simplified17.9%
Taylor expanded in a around 0 85.2%
associate-*r/85.2%
mul-1-neg85.2%
Simplified85.2%
Final simplification81.0%
(FPCore (a b c)
:precision binary64
(if (<= b -5.6e-68)
(- (/ c b) (/ b a))
(if (<= b 1.9e-70)
(* (- b (sqrt (* a (* c -4.0)))) (/ -0.5 a))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.6e-68) {
tmp = (c / b) - (b / a);
} else if (b <= 1.9e-70) {
tmp = (b - sqrt((a * (c * -4.0)))) * (-0.5 / 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.6d-68)) then
tmp = (c / b) - (b / a)
else if (b <= 1.9d-70) then
tmp = (b - sqrt((a * (c * (-4.0d0))))) * ((-0.5d0) / 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.6e-68) {
tmp = (c / b) - (b / a);
} else if (b <= 1.9e-70) {
tmp = (b - Math.sqrt((a * (c * -4.0)))) * (-0.5 / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.6e-68: tmp = (c / b) - (b / a) elif b <= 1.9e-70: tmp = (b - math.sqrt((a * (c * -4.0)))) * (-0.5 / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.6e-68) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.9e-70) tmp = Float64(Float64(b - sqrt(Float64(a * Float64(c * -4.0)))) * Float64(-0.5 / a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.6e-68) tmp = (c / b) - (b / a); elseif (b <= 1.9e-70) tmp = (b - sqrt((a * (c * -4.0)))) * (-0.5 / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.6e-68], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.9e-70], N[(N[(b - N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.6 \cdot 10^{-68}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-70}:\\
\;\;\;\;\left(b - \sqrt{a \cdot \left(c \cdot -4\right)}\right) \cdot \frac{-0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -5.6000000000000002e-68Initial program 63.5%
*-commutative63.5%
Simplified63.5%
Taylor expanded in b around -inf 80.8%
mul-1-neg80.8%
*-commutative80.8%
distribute-rgt-neg-in80.8%
+-commutative80.8%
mul-1-neg80.8%
unsub-neg80.8%
Simplified80.8%
Taylor expanded in a around inf 81.6%
+-commutative81.6%
neg-mul-181.6%
unsub-neg81.6%
Simplified81.6%
if -5.6000000000000002e-68 < b < 1.8999999999999999e-70Initial program 81.0%
*-commutative81.0%
Simplified81.0%
Taylor expanded in a around inf 74.9%
*-commutative74.9%
associate-*r*75.0%
Simplified75.0%
add-cbrt-cube50.3%
pow1/347.5%
pow347.5%
sqrt-pow247.5%
metadata-eval47.5%
Applied egg-rr47.5%
unpow1/350.3%
Simplified50.3%
frac-2neg50.3%
div-inv50.3%
Applied egg-rr74.8%
+-commutative74.8%
unsub-neg74.8%
associate-*r*74.8%
*-commutative74.8%
*-commutative74.8%
associate-/r*74.8%
metadata-eval74.8%
Simplified74.8%
if 1.8999999999999999e-70 < b Initial program 17.9%
*-commutative17.9%
Simplified17.9%
Taylor expanded in a around 0 85.2%
associate-*r/85.2%
mul-1-neg85.2%
Simplified85.2%
Final simplification81.0%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (- (/ c b) (/ b a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
tmp = (c / b) - (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 <= (-4d-310)) then
tmp = (c / b) - (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 <= -4e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = (c / b) - (b / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(Float64(c / b) - 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 <= -4e-310) tmp = (c / b) - (b / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 69.9%
*-commutative69.9%
Simplified70.0%
Taylor expanded in b around -inf 62.6%
mul-1-neg62.6%
*-commutative62.6%
distribute-rgt-neg-in62.6%
+-commutative62.6%
mul-1-neg62.6%
unsub-neg62.6%
Simplified62.6%
Taylor expanded in a around inf 65.6%
+-commutative65.6%
neg-mul-165.6%
unsub-neg65.6%
Simplified65.6%
if -3.999999999999988e-310 < b Initial program 33.9%
*-commutative33.9%
Simplified33.9%
Taylor expanded in a around 0 66.2%
associate-*r/66.2%
mul-1-neg66.2%
Simplified66.2%
Final simplification65.9%
(FPCore (a b c) :precision binary64 (if (<= b -4e-310) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4e-310) {
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 <= (-4d-310)) 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 <= -4e-310) {
tmp = b / -a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4e-310: tmp = b / -a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4e-310) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4e-310) tmp = b / -a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4e-310], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -3.999999999999988e-310Initial program 69.9%
*-commutative69.9%
Simplified70.0%
Taylor expanded in b around -inf 65.1%
associate-*r/65.1%
mul-1-neg65.1%
Simplified65.1%
if -3.999999999999988e-310 < b Initial program 33.9%
*-commutative33.9%
Simplified33.9%
Taylor expanded in a around 0 66.2%
associate-*r/66.2%
mul-1-neg66.2%
Simplified66.2%
Final simplification65.6%
(FPCore (a b c) :precision binary64 (if (<= b 2.85e-24) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.85e-24) {
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.85d-24) 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.85e-24) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.85e-24: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.85e-24) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.85e-24) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.85e-24], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.85 \cdot 10^{-24}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 2.85000000000000001e-24Initial program 69.6%
*-commutative69.6%
Simplified69.6%
Taylor expanded in b around -inf 50.6%
associate-*r/50.6%
mul-1-neg50.6%
Simplified50.6%
if 2.85000000000000001e-24 < b Initial program 17.6%
*-commutative17.6%
Simplified17.6%
Taylor expanded in b around -inf 2.4%
mul-1-neg2.4%
*-commutative2.4%
distribute-rgt-neg-in2.4%
+-commutative2.4%
mul-1-neg2.4%
unsub-neg2.4%
Simplified2.4%
Taylor expanded in a around inf 24.3%
Final simplification41.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 52.3%
*-commutative52.3%
Simplified52.3%
Taylor expanded in b around -inf 33.0%
mul-1-neg33.0%
*-commutative33.0%
distribute-rgt-neg-in33.0%
+-commutative33.0%
mul-1-neg33.0%
unsub-neg33.0%
Simplified33.0%
Taylor expanded in a around inf 10.2%
(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 52.3%
*-commutative52.3%
Simplified52.3%
Taylor expanded in b around -inf 34.6%
associate-*r/34.6%
mul-1-neg34.6%
Simplified34.6%
div-inv34.5%
add-sqr-sqrt33.2%
sqrt-unprod24.7%
sqr-neg24.7%
sqrt-prod1.7%
add-sqr-sqrt2.6%
Applied egg-rr2.6%
associate-*r/2.6%
*-rgt-identity2.6%
Simplified2.6%
herbie shell --seed 2024135
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))