
(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 10 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 -1.5e+122)
(- (/ c b) (/ b a))
(if (<= b 1.02e-103)
(/ (- (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 <= -1.5e+122) {
tmp = (c / b) - (b / a);
} else if (b <= 1.02e-103) {
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 <= -1.5e+122) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.02e-103) tmp = Float64(Float64(sqrt(fma(a, Float64(c * -4.0), Float64(b * b))) - b) / Float64(a * 2.0)); else tmp = Float64(c / Float64(-b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.5e+122], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.02e-103], 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 -1.5 \cdot 10^{+122}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.02 \cdot 10^{-103}:\\
\;\;\;\;\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 < -1.49999999999999993e122Initial program 54.3%
*-commutative54.3%
Simplified54.4%
Taylor expanded in b around -inf 96.1%
mul-1-neg96.1%
*-commutative96.1%
distribute-rgt-neg-in96.1%
+-commutative96.1%
mul-1-neg96.1%
unsub-neg96.1%
Simplified96.1%
Taylor expanded in a around inf 96.4%
if -1.49999999999999993e122 < b < 1.01999999999999998e-103Initial program 79.2%
*-commutative79.2%
Simplified79.2%
if 1.01999999999999998e-103 < b Initial program 16.6%
*-commutative16.6%
Simplified16.6%
Taylor expanded in a around 0 91.1%
associate-*r/91.1%
mul-1-neg91.1%
Simplified91.1%
Final simplification87.2%
(FPCore (a b c)
:precision binary64
(if (<= b -2e+125)
(- (/ c b) (/ b a))
(if (<= b 3.5e-105)
(/ (- (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+125) {
tmp = (c / b) - (b / a);
} else if (b <= 3.5e-105) {
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+125)) then
tmp = (c / b) - (b / a)
else if (b <= 3.5d-105) 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+125) {
tmp = (c / b) - (b / a);
} else if (b <= 3.5e-105) {
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+125: tmp = (c / b) - (b / a) elif b <= 3.5e-105: 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+125) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3.5e-105) 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+125) tmp = (c / b) - (b / a); elseif (b <= 3.5e-105) 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+125], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.5e-105], 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^{+125}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.5 \cdot 10^{-105}:\\
\;\;\;\;\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.9999999999999998e125Initial program 54.3%
*-commutative54.3%
Simplified54.4%
Taylor expanded in b around -inf 96.1%
mul-1-neg96.1%
*-commutative96.1%
distribute-rgt-neg-in96.1%
+-commutative96.1%
mul-1-neg96.1%
unsub-neg96.1%
Simplified96.1%
Taylor expanded in a around inf 96.4%
if -1.9999999999999998e125 < b < 3.5e-105Initial program 79.2%
if 3.5e-105 < b Initial program 16.6%
*-commutative16.6%
Simplified16.6%
Taylor expanded in a around 0 91.1%
associate-*r/91.1%
mul-1-neg91.1%
Simplified91.1%
Final simplification87.2%
(FPCore (a b c)
:precision binary64
(if (<= b -8.6e-81)
(- (/ c b) (/ b a))
(if (<= b 3.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 <= -8.6e-81) {
tmp = (c / b) - (b / a);
} else if (b <= 3.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 <= (-8.6d-81)) then
tmp = (c / b) - (b / a)
else if (b <= 3.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 <= -8.6e-81) {
tmp = (c / b) - (b / a);
} else if (b <= 3.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 <= -8.6e-81: tmp = (c / b) - (b / a) elif b <= 3.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 <= -8.6e-81) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 3.2e-104) 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 <= -8.6e-81) tmp = (c / b) - (b / a); elseif (b <= 3.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, -8.6e-81], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3.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 -8.6 \cdot 10^{-81}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 3.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 < -8.6000000000000006e-81Initial program 69.8%
*-commutative69.8%
Simplified69.9%
Taylor expanded in b around -inf 85.0%
mul-1-neg85.0%
*-commutative85.0%
distribute-rgt-neg-in85.0%
+-commutative85.0%
mul-1-neg85.0%
unsub-neg85.0%
Simplified85.0%
Taylor expanded in a around inf 85.3%
if -8.6000000000000006e-81 < b < 3.19999999999999989e-104Initial program 72.9%
*-commutative72.9%
Simplified72.9%
Taylor expanded in a around inf 63.3%
*-commutative63.3%
associate-*r*63.3%
Simplified63.3%
if 3.19999999999999989e-104 < b Initial program 16.6%
*-commutative16.6%
Simplified16.6%
Taylor expanded in a around 0 91.1%
associate-*r/91.1%
mul-1-neg91.1%
Simplified91.1%
Final simplification82.0%
(FPCore (a b c)
:precision binary64
(if (<= b -8.5e-79)
(- (/ c b) (/ b a))
(if (<= b 1.9e-104)
(* (- (sqrt (* a (* c -4.0))) b) (/ 0.5 a))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -8.5e-79) {
tmp = (c / b) - (b / a);
} else if (b <= 1.9e-104) {
tmp = (sqrt((a * (c * -4.0))) - b) * (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 <= (-8.5d-79)) then
tmp = (c / b) - (b / a)
else if (b <= 1.9d-104) then
tmp = (sqrt((a * (c * (-4.0d0)))) - b) * (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 <= -8.5e-79) {
tmp = (c / b) - (b / a);
} else if (b <= 1.9e-104) {
tmp = (Math.sqrt((a * (c * -4.0))) - b) * (0.5 / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -8.5e-79: tmp = (c / b) - (b / a) elif b <= 1.9e-104: tmp = (math.sqrt((a * (c * -4.0))) - b) * (0.5 / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -8.5e-79) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.9e-104) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) * 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 <= -8.5e-79) tmp = (c / b) - (b / a); elseif (b <= 1.9e-104) tmp = (sqrt((a * (c * -4.0))) - b) * (0.5 / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -8.5e-79], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.9e-104], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -8.5 \cdot 10^{-79}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{-104}:\\
\;\;\;\;\left(\sqrt{a \cdot \left(c \cdot -4\right)} - b\right) \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -8.50000000000000029e-79Initial program 69.8%
*-commutative69.8%
Simplified69.9%
Taylor expanded in b around -inf 85.0%
mul-1-neg85.0%
*-commutative85.0%
distribute-rgt-neg-in85.0%
+-commutative85.0%
mul-1-neg85.0%
unsub-neg85.0%
Simplified85.0%
Taylor expanded in a around inf 85.3%
if -8.50000000000000029e-79 < b < 1.9e-104Initial program 72.9%
*-commutative72.9%
Simplified72.9%
Taylor expanded in a around inf 63.3%
*-commutative63.3%
associate-*r*63.3%
Simplified63.3%
div-sub63.3%
sub-neg63.3%
div-inv63.2%
*-commutative63.2%
associate-/r*63.2%
metadata-eval63.2%
div-inv63.2%
*-commutative63.2%
associate-/r*63.2%
metadata-eval63.2%
Applied egg-rr63.2%
sub-neg63.2%
distribute-rgt-out--63.2%
Simplified63.2%
if 1.9e-104 < b Initial program 16.6%
*-commutative16.6%
Simplified16.6%
Taylor expanded in a around 0 91.1%
associate-*r/91.1%
mul-1-neg91.1%
Simplified91.1%
Final simplification82.0%
(FPCore (a b c) :precision binary64 (if (<= b -3e-242) (- (/ c b) (/ b a)) (if (<= b 2.3e-104) (* -0.5 (- (sqrt (* c (/ -4.0 a))))) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3e-242) {
tmp = (c / b) - (b / a);
} else if (b <= 2.3e-104) {
tmp = -0.5 * -sqrt((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 <= (-3d-242)) then
tmp = (c / b) - (b / a)
else if (b <= 2.3d-104) then
tmp = (-0.5d0) * -sqrt((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 <= -3e-242) {
tmp = (c / b) - (b / a);
} else if (b <= 2.3e-104) {
tmp = -0.5 * -Math.sqrt((c * (-4.0 / a)));
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3e-242: tmp = (c / b) - (b / a) elif b <= 2.3e-104: tmp = -0.5 * -math.sqrt((c * (-4.0 / a))) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3e-242) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 2.3e-104) tmp = Float64(-0.5 * Float64(-sqrt(Float64(c * Float64(-4.0 / a))))); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3e-242) tmp = (c / b) - (b / a); elseif (b <= 2.3e-104) tmp = -0.5 * -sqrt((c * (-4.0 / a))); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3e-242], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.3e-104], N[(-0.5 * (-N[Sqrt[N[(c * N[(-4.0 / a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3 \cdot 10^{-242}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{-104}:\\
\;\;\;\;-0.5 \cdot \left(-\sqrt{c \cdot \frac{-4}{a}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -3e-242Initial program 73.3%
*-commutative73.3%
Simplified73.4%
Taylor expanded in b around -inf 72.5%
mul-1-neg72.5%
*-commutative72.5%
distribute-rgt-neg-in72.5%
+-commutative72.5%
mul-1-neg72.5%
unsub-neg72.5%
Simplified72.5%
Taylor expanded in a around inf 74.5%
if -3e-242 < b < 2.2999999999999999e-104Initial program 63.9%
*-commutative63.9%
Simplified63.9%
add-cube-cbrt63.2%
pow363.3%
Applied egg-rr63.3%
Taylor expanded in a around -inf 0.0%
rem-cube-cbrt0.0%
associate-/l*0.0%
unpow20.0%
rem-square-sqrt57.3%
Simplified57.3%
if 2.2999999999999999e-104 < b Initial program 16.6%
*-commutative16.6%
Simplified16.6%
Taylor expanded in a around 0 91.1%
associate-*r/91.1%
mul-1-neg91.1%
Simplified91.1%
Final simplification78.2%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (- (/ c b) (/ b a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-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 <= (-2d-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 <= -2e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = (c / b) - (b / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-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 <= -2e-310) tmp = (c / b) - (b / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-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 -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 71.3%
*-commutative71.3%
Simplified71.3%
Taylor expanded in b around -inf 68.2%
mul-1-neg68.2%
*-commutative68.2%
distribute-rgt-neg-in68.2%
+-commutative68.2%
mul-1-neg68.2%
unsub-neg68.2%
Simplified68.2%
Taylor expanded in a around inf 70.1%
if -1.999999999999994e-310 < b Initial program 29.3%
*-commutative29.3%
Simplified29.3%
Taylor expanded in a around 0 73.3%
associate-*r/73.3%
mul-1-neg73.3%
Simplified73.3%
Final simplification71.7%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-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 <= (-2d-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 <= -2e-310) {
tmp = b / -a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = b / -a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-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 <= -2e-310) tmp = b / -a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 71.3%
*-commutative71.3%
Simplified71.3%
Taylor expanded in b around -inf 69.9%
associate-*r/69.9%
mul-1-neg69.9%
Simplified69.9%
if -1.999999999999994e-310 < b Initial program 29.3%
*-commutative29.3%
Simplified29.3%
Taylor expanded in a around 0 73.3%
associate-*r/73.3%
mul-1-neg73.3%
Simplified73.3%
Final simplification71.6%
(FPCore (a b c) :precision binary64 (if (<= b 1.7e-51) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.7e-51) {
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.7d-51) 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.7e-51) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.7e-51: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.7e-51) 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 <= 1.7e-51) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.7e-51], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.7 \cdot 10^{-51}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.70000000000000001e-51Initial program 66.7%
*-commutative66.7%
Simplified66.8%
Taylor expanded in b around -inf 52.8%
associate-*r/52.8%
mul-1-neg52.8%
Simplified52.8%
if 1.70000000000000001e-51 < b Initial program 16.5%
*-commutative16.5%
Simplified16.5%
Taylor expanded in b around -inf 2.5%
mul-1-neg2.5%
*-commutative2.5%
distribute-rgt-neg-in2.5%
+-commutative2.5%
mul-1-neg2.5%
unsub-neg2.5%
Simplified2.5%
Taylor expanded in a around inf 25.6%
Final simplification44.0%
(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 50.4%
*-commutative50.4%
Simplified50.5%
Taylor expanded in b around -inf 35.4%
mul-1-neg35.4%
*-commutative35.4%
distribute-rgt-neg-in35.4%
+-commutative35.4%
mul-1-neg35.4%
unsub-neg35.4%
Simplified35.4%
Taylor expanded in a around inf 10.4%
(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 50.4%
*-commutative50.4%
Simplified50.5%
clear-num50.3%
inv-pow50.3%
*-commutative50.3%
*-un-lft-identity50.3%
times-frac50.3%
metadata-eval50.3%
sub-neg50.3%
pow250.3%
add-sqr-sqrt35.8%
sqrt-unprod46.1%
sqr-neg46.1%
sqrt-prod10.4%
add-sqr-sqrt28.8%
Applied egg-rr28.8%
unpow-128.8%
associate-*r/28.8%
*-commutative28.8%
fma-define28.8%
+-commutative28.8%
unpow228.8%
rem-square-sqrt25.5%
hypot-undefine20.8%
+-commutative20.8%
associate-/l*20.7%
Simplified20.7%
Taylor expanded in a around 0 2.5%
herbie shell --seed 2024185
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))