
(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 9 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 -4e+119)
(- (/ c b) (/ b a))
(if (<= b 1.15e-110)
(/ (- (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 <= -4e+119) {
tmp = (c / b) - (b / a);
} else if (b <= 1.15e-110) {
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 <= (-4d+119)) then
tmp = (c / b) - (b / a)
else if (b <= 1.15d-110) 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 <= -4e+119) {
tmp = (c / b) - (b / a);
} else if (b <= 1.15e-110) {
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 <= -4e+119: tmp = (c / b) - (b / a) elif b <= 1.15e-110: 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 <= -4e+119) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 1.15e-110) 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 <= -4e+119) tmp = (c / b) - (b / a); elseif (b <= 1.15e-110) 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, -4e+119], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.15e-110], 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 -4 \cdot 10^{+119}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 1.15 \cdot 10^{-110}:\\
\;\;\;\;\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.99999999999999978e119Initial program 38.0%
*-commutative38.0%
Simplified38.0%
Applied egg-rr38.1%
sub-neg38.1%
distribute-rgt-out--38.1%
Simplified38.1%
Taylor expanded in b around -inf 90.3%
mul-1-neg90.3%
*-commutative90.3%
distribute-rgt-neg-in90.3%
+-commutative90.3%
mul-1-neg90.3%
unsub-neg90.3%
Simplified90.3%
Taylor expanded in a around inf 90.6%
+-commutative90.6%
mul-1-neg90.6%
unsub-neg90.6%
Simplified90.6%
if -3.99999999999999978e119 < b < 1.1500000000000001e-110Initial program 78.9%
if 1.1500000000000001e-110 < b Initial program 16.8%
*-commutative16.8%
Simplified16.8%
Taylor expanded in b around inf 90.0%
associate-*r/90.0%
mul-1-neg90.0%
Simplified90.0%
Final simplification85.3%
(FPCore (a b c)
:precision binary64
(if (<= b -2.6e-99)
(- (/ c b) (/ b a))
(if (<= b 8.5e-110)
(* (/ 1.0 (* a -2.0)) (- b (sqrt (* c (* a -4.0)))))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.6e-99) {
tmp = (c / b) - (b / a);
} else if (b <= 8.5e-110) {
tmp = (1.0 / (a * -2.0)) * (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 <= (-2.6d-99)) then
tmp = (c / b) - (b / a)
else if (b <= 8.5d-110) then
tmp = (1.0d0 / (a * (-2.0d0))) * (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 <= -2.6e-99) {
tmp = (c / b) - (b / a);
} else if (b <= 8.5e-110) {
tmp = (1.0 / (a * -2.0)) * (b - Math.sqrt((c * (a * -4.0))));
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.6e-99: tmp = (c / b) - (b / a) elif b <= 8.5e-110: tmp = (1.0 / (a * -2.0)) * (b - math.sqrt((c * (a * -4.0)))) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.6e-99) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 8.5e-110) tmp = Float64(Float64(1.0 / Float64(a * -2.0)) * 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 <= -2.6e-99) tmp = (c / b) - (b / a); elseif (b <= 8.5e-110) tmp = (1.0 / (a * -2.0)) * (b - sqrt((c * (a * -4.0)))); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.6e-99], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8.5e-110], N[(N[(1.0 / N[(a * -2.0), $MachinePrecision]), $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 -2.6 \cdot 10^{-99}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 8.5 \cdot 10^{-110}:\\
\;\;\;\;\frac{1}{a \cdot -2} \cdot \left(b - \sqrt{c \cdot \left(a \cdot -4\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -2.60000000000000005e-99Initial program 68.8%
*-commutative68.8%
Simplified68.8%
Applied egg-rr68.7%
sub-neg68.7%
distribute-rgt-out--68.7%
Simplified68.7%
Taylor expanded in b around -inf 81.5%
mul-1-neg81.5%
*-commutative81.5%
distribute-rgt-neg-in81.5%
+-commutative81.5%
mul-1-neg81.5%
unsub-neg81.5%
Simplified81.5%
Taylor expanded in a around inf 81.7%
+-commutative81.7%
mul-1-neg81.7%
unsub-neg81.7%
Simplified81.7%
if -2.60000000000000005e-99 < b < 8.50000000000000029e-110Initial program 66.8%
*-commutative66.8%
Simplified66.8%
Taylor expanded in b around 0 62.2%
*-commutative62.2%
*-commutative62.2%
associate-*r*62.2%
Simplified62.2%
frac-2neg62.2%
div-inv62.3%
distribute-neg-in62.3%
add-sqr-sqrt26.1%
sqrt-unprod61.8%
sqr-neg61.8%
sqrt-prod36.5%
add-sqr-sqrt60.8%
sub-neg60.8%
add-sqr-sqrt24.4%
sqrt-unprod60.7%
sqr-neg60.7%
sqrt-prod36.2%
add-sqr-sqrt62.3%
distribute-rgt-neg-in62.3%
metadata-eval62.3%
Applied egg-rr62.3%
*-commutative62.3%
*-commutative62.3%
Simplified62.3%
if 8.50000000000000029e-110 < b Initial program 16.8%
*-commutative16.8%
Simplified16.8%
Taylor expanded in b around inf 90.0%
associate-*r/90.0%
mul-1-neg90.0%
Simplified90.0%
Final simplification80.3%
(FPCore (a b c)
:precision binary64
(if (<= b -6.8e-101)
(- (/ c b) (/ b a))
(if (<= b 6.8e-108)
(* (/ 0.5 a) (+ b (sqrt (* c (* a -4.0)))))
(/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.8e-101) {
tmp = (c / b) - (b / a);
} else if (b <= 6.8e-108) {
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 <= (-6.8d-101)) then
tmp = (c / b) - (b / a)
else if (b <= 6.8d-108) 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 <= -6.8e-101) {
tmp = (c / b) - (b / a);
} else if (b <= 6.8e-108) {
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 <= -6.8e-101: tmp = (c / b) - (b / a) elif b <= 6.8e-108: 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 <= -6.8e-101) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 6.8e-108) 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 <= -6.8e-101) tmp = (c / b) - (b / a); elseif (b <= 6.8e-108) 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, -6.8e-101], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 6.8e-108], 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 -6.8 \cdot 10^{-101}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 6.8 \cdot 10^{-108}:\\
\;\;\;\;\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 < -6.79999999999999978e-101Initial program 68.8%
*-commutative68.8%
Simplified68.8%
Applied egg-rr68.7%
sub-neg68.7%
distribute-rgt-out--68.7%
Simplified68.7%
Taylor expanded in b around -inf 81.5%
mul-1-neg81.5%
*-commutative81.5%
distribute-rgt-neg-in81.5%
+-commutative81.5%
mul-1-neg81.5%
unsub-neg81.5%
Simplified81.5%
Taylor expanded in a around inf 81.7%
+-commutative81.7%
mul-1-neg81.7%
unsub-neg81.7%
Simplified81.7%
if -6.79999999999999978e-101 < b < 6.80000000000000004e-108Initial program 66.8%
*-commutative66.8%
Simplified66.8%
Taylor expanded in b around 0 62.2%
*-commutative62.2%
*-commutative62.2%
associate-*r*62.2%
Simplified62.2%
add-cbrt-cube53.8%
pow1/350.4%
pow350.4%
sqrt-pow250.4%
metadata-eval50.4%
Applied egg-rr50.4%
unpow1/353.9%
Simplified53.9%
*-un-lft-identity53.9%
*-commutative53.9%
times-frac53.9%
metadata-eval53.9%
add-sqr-sqrt22.5%
sqrt-unprod53.5%
sqr-neg53.5%
sqrt-prod31.8%
add-sqr-sqrt52.6%
pow1/349.1%
pow-pow60.8%
metadata-eval60.8%
pow1/260.8%
Applied egg-rr60.8%
*-commutative60.8%
associate-*l/60.8%
associate-*r/60.8%
*-commutative60.8%
Simplified60.8%
if 6.80000000000000004e-108 < b Initial program 16.8%
*-commutative16.8%
Simplified16.8%
Taylor expanded in b around inf 90.0%
associate-*r/90.0%
mul-1-neg90.0%
Simplified90.0%
Final simplification79.9%
(FPCore (a b c) :precision binary64 (if (<= b -6.4e-101) (- (/ c b) (/ b a)) (if (<= b 8e-109) (/ (- (sqrt (* c (* a -4.0))) b) (* a 2.0)) (/ c (- b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -6.4e-101) {
tmp = (c / b) - (b / a);
} else if (b <= 8e-109) {
tmp = (sqrt((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 <= (-6.4d-101)) then
tmp = (c / b) - (b / a)
else if (b <= 8d-109) then
tmp = (sqrt((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 <= -6.4e-101) {
tmp = (c / b) - (b / a);
} else if (b <= 8e-109) {
tmp = (Math.sqrt((c * (a * -4.0))) - b) / (a * 2.0);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -6.4e-101: tmp = (c / b) - (b / a) elif b <= 8e-109: tmp = (math.sqrt((c * (a * -4.0))) - b) / (a * 2.0) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -6.4e-101) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 8e-109) tmp = Float64(Float64(sqrt(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 <= -6.4e-101) tmp = (c / b) - (b / a); elseif (b <= 8e-109) tmp = (sqrt((c * (a * -4.0))) - b) / (a * 2.0); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -6.4e-101], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 8e-109], N[(N[(N[Sqrt[N[(c * N[(a * -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 -6.4 \cdot 10^{-101}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 8 \cdot 10^{-109}:\\
\;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -6.39999999999999957e-101Initial program 68.8%
*-commutative68.8%
Simplified68.8%
Applied egg-rr68.7%
sub-neg68.7%
distribute-rgt-out--68.7%
Simplified68.7%
Taylor expanded in b around -inf 81.5%
mul-1-neg81.5%
*-commutative81.5%
distribute-rgt-neg-in81.5%
+-commutative81.5%
mul-1-neg81.5%
unsub-neg81.5%
Simplified81.5%
Taylor expanded in a around inf 81.7%
+-commutative81.7%
mul-1-neg81.7%
unsub-neg81.7%
Simplified81.7%
if -6.39999999999999957e-101 < b < 7.9999999999999999e-109Initial program 66.8%
*-commutative66.8%
Simplified66.8%
Taylor expanded in b around 0 62.2%
*-commutative62.2%
*-commutative62.2%
associate-*r*62.2%
Simplified62.2%
+-commutative62.2%
unsub-neg62.2%
Applied egg-rr62.2%
if 7.9999999999999999e-109 < b Initial program 16.8%
*-commutative16.8%
Simplified16.8%
Taylor expanded in b around inf 90.0%
associate-*r/90.0%
mul-1-neg90.0%
Simplified90.0%
Final simplification80.3%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (- (/ c b) (/ b a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-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 <= (-5d-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 <= -5e-310) {
tmp = (c / b) - (b / a);
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = (c / b) - (b / a) else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-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 <= -5e-310) tmp = (c / b) - (b / a); else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-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 -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 67.3%
*-commutative67.3%
Simplified67.3%
Applied egg-rr67.3%
sub-neg67.3%
distribute-rgt-out--67.3%
Simplified67.3%
Taylor expanded in b around -inf 63.4%
mul-1-neg63.4%
*-commutative63.4%
distribute-rgt-neg-in63.4%
+-commutative63.4%
mul-1-neg63.4%
unsub-neg63.4%
Simplified63.4%
Taylor expanded in a around inf 64.7%
+-commutative64.7%
mul-1-neg64.7%
unsub-neg64.7%
Simplified64.7%
if -4.999999999999985e-310 < b Initial program 29.5%
*-commutative29.5%
Simplified29.5%
Taylor expanded in b around inf 71.8%
associate-*r/71.8%
mul-1-neg71.8%
Simplified71.8%
Final simplification68.5%
(FPCore (a b c) :precision binary64 (if (<= b 2.5e-28) (/ b (- a)) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.5e-28) {
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.5d-28) 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.5e-28) {
tmp = b / -a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.5e-28: tmp = b / -a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.5e-28) 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.5e-28) tmp = b / -a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.5e-28], N[(b / (-a)), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.5 \cdot 10^{-28}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 2.5000000000000001e-28Initial program 65.8%
*-commutative65.8%
Simplified65.8%
Taylor expanded in b around -inf 47.9%
mul-1-neg47.9%
distribute-neg-frac247.9%
Simplified47.9%
if 2.5000000000000001e-28 < b Initial program 14.6%
*-commutative14.6%
Simplified14.6%
Applied egg-rr7.4%
unpow-17.4%
associate-/l*7.4%
Simplified7.4%
Taylor expanded in b around -inf 34.3%
Final simplification42.8%
(FPCore (a b c) :precision binary64 (if (<= b 2.5e-308) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.5e-308) {
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.5d-308) 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.5e-308) {
tmp = b / -a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.5e-308: tmp = b / -a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.5e-308) 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 <= 2.5e-308) tmp = b / -a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.5e-308], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.5 \cdot 10^{-308}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < 2.49999999999999977e-308Initial program 67.6%
*-commutative67.6%
Simplified67.6%
Taylor expanded in b around -inf 64.1%
mul-1-neg64.1%
distribute-neg-frac264.1%
Simplified64.1%
if 2.49999999999999977e-308 < b Initial program 29.0%
*-commutative29.0%
Simplified29.0%
Taylor expanded in b around inf 72.3%
associate-*r/72.3%
mul-1-neg72.3%
Simplified72.3%
Final simplification68.5%
(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 46.8%
*-commutative46.8%
Simplified46.8%
Applied egg-rr25.5%
unpow-125.5%
associate-/l*25.5%
Simplified25.5%
Taylor expanded in a around 0 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 46.8%
*-commutative46.8%
Simplified46.8%
Applied egg-rr25.5%
unpow-125.5%
associate-/l*25.5%
Simplified25.5%
Taylor expanded in b around -inf 14.8%
Final simplification14.8%
herbie shell --seed 2024076
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))