
(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(4.0 * Float64(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[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 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(4.0 * Float64(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[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* a (* c 4.0))))))
(if (<= b -4.2e+104)
(/ (- c) b)
(if (<= b -3.9e-147)
(* -0.5 (/ (/ (* c (* a 4.0)) (- b t_0)) a))
(if (<= b 2.1e+25) (* -0.5 (/ (+ b t_0) a)) (/ (- b) a))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (a * (c * 4.0))));
double tmp;
if (b <= -4.2e+104) {
tmp = -c / b;
} else if (b <= -3.9e-147) {
tmp = -0.5 * (((c * (a * 4.0)) / (b - t_0)) / a);
} else if (b <= 2.1e+25) {
tmp = -0.5 * ((b + t_0) / a);
} else {
tmp = -b / a;
}
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) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - (a * (c * 4.0d0))))
if (b <= (-4.2d+104)) then
tmp = -c / b
else if (b <= (-3.9d-147)) then
tmp = (-0.5d0) * (((c * (a * 4.0d0)) / (b - t_0)) / a)
else if (b <= 2.1d+25) then
tmp = (-0.5d0) * ((b + t_0) / a)
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (a * (c * 4.0))));
double tmp;
if (b <= -4.2e+104) {
tmp = -c / b;
} else if (b <= -3.9e-147) {
tmp = -0.5 * (((c * (a * 4.0)) / (b - t_0)) / a);
} else if (b <= 2.1e+25) {
tmp = -0.5 * ((b + t_0) / a);
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (a * (c * 4.0)))) tmp = 0 if b <= -4.2e+104: tmp = -c / b elif b <= -3.9e-147: tmp = -0.5 * (((c * (a * 4.0)) / (b - t_0)) / a) elif b <= 2.1e+25: tmp = -0.5 * ((b + t_0) / a) else: tmp = -b / a return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 4.0)))) tmp = 0.0 if (b <= -4.2e+104) tmp = Float64(Float64(-c) / b); elseif (b <= -3.9e-147) tmp = Float64(-0.5 * Float64(Float64(Float64(c * Float64(a * 4.0)) / Float64(b - t_0)) / a)); elseif (b <= 2.1e+25) tmp = Float64(-0.5 * Float64(Float64(b + t_0) / a)); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - (a * (c * 4.0)))); tmp = 0.0; if (b <= -4.2e+104) tmp = -c / b; elseif (b <= -3.9e-147) tmp = -0.5 * (((c * (a * 4.0)) / (b - t_0)) / a); elseif (b <= 2.1e+25) tmp = -0.5 * ((b + t_0) / a); else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -4.2e+104], N[((-c) / b), $MachinePrecision], If[LessEqual[b, -3.9e-147], N[(-0.5 * N[(N[(N[(c * N[(a * 4.0), $MachinePrecision]), $MachinePrecision] / N[(b - t$95$0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2.1e+25], N[(-0.5 * N[(N[(b + t$95$0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[((-b) / a), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}\\
\mathbf{if}\;b \leq -4.2 \cdot 10^{+104}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{elif}\;b \leq -3.9 \cdot 10^{-147}:\\
\;\;\;\;-0.5 \cdot \frac{\frac{c \cdot \left(a \cdot 4\right)}{b - t_0}}{a}\\
\mathbf{elif}\;b \leq 2.1 \cdot 10^{+25}:\\
\;\;\;\;-0.5 \cdot \frac{b + t_0}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
if b < -4.1999999999999997e104Initial program 3.8%
Taylor expanded in b around -inf 100.0%
associate-*r/100.0%
neg-mul-1100.0%
Simplified100.0%
if -4.1999999999999997e104 < b < -3.8999999999999998e-147Initial program 42.6%
Simplified42.6%
fma-udef42.6%
associate-*r*42.6%
metadata-eval42.6%
distribute-rgt-neg-in42.6%
*-commutative42.6%
+-commutative42.6%
sub-neg42.6%
*-commutative42.6%
associate-*l*42.6%
Applied egg-rr42.6%
flip-+42.2%
add-sqr-sqrt42.1%
Applied egg-rr42.1%
Taylor expanded in b around 0 72.6%
*-commutative72.6%
associate-*l*72.7%
Simplified72.7%
if -3.8999999999999998e-147 < b < 2.0999999999999999e25Initial program 87.8%
Simplified87.8%
fma-udef87.8%
associate-*r*87.8%
metadata-eval87.8%
distribute-rgt-neg-in87.8%
*-commutative87.8%
+-commutative87.8%
sub-neg87.8%
*-commutative87.8%
associate-*l*87.8%
Applied egg-rr87.8%
if 2.0999999999999999e25 < b Initial program 58.2%
Taylor expanded in b around inf 97.1%
associate-*r/97.1%
mul-1-neg97.1%
Simplified97.1%
Final simplification89.6%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- c) b))
(t_1 (* -0.5 (/ (+ b (sqrt (- (* b b) (* a (* c 4.0))))) a))))
(if (<= b -3e-45)
t_0
(if (<= b -6.2e-106)
t_1
(if (<= b -1.32e-129) t_0 (if (<= b 2.1e+25) t_1 (/ (- b) a)))))))
double code(double a, double b, double c) {
double t_0 = -c / b;
double t_1 = -0.5 * ((b + sqrt(((b * b) - (a * (c * 4.0))))) / a);
double tmp;
if (b <= -3e-45) {
tmp = t_0;
} else if (b <= -6.2e-106) {
tmp = t_1;
} else if (b <= -1.32e-129) {
tmp = t_0;
} else if (b <= 2.1e+25) {
tmp = t_1;
} else {
tmp = -b / a;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = -c / b
t_1 = (-0.5d0) * ((b + sqrt(((b * b) - (a * (c * 4.0d0))))) / a)
if (b <= (-3d-45)) then
tmp = t_0
else if (b <= (-6.2d-106)) then
tmp = t_1
else if (b <= (-1.32d-129)) then
tmp = t_0
else if (b <= 2.1d+25) then
tmp = t_1
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = -c / b;
double t_1 = -0.5 * ((b + Math.sqrt(((b * b) - (a * (c * 4.0))))) / a);
double tmp;
if (b <= -3e-45) {
tmp = t_0;
} else if (b <= -6.2e-106) {
tmp = t_1;
} else if (b <= -1.32e-129) {
tmp = t_0;
} else if (b <= 2.1e+25) {
tmp = t_1;
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): t_0 = -c / b t_1 = -0.5 * ((b + math.sqrt(((b * b) - (a * (c * 4.0))))) / a) tmp = 0 if b <= -3e-45: tmp = t_0 elif b <= -6.2e-106: tmp = t_1 elif b <= -1.32e-129: tmp = t_0 elif b <= 2.1e+25: tmp = t_1 else: tmp = -b / a return tmp
function code(a, b, c) t_0 = Float64(Float64(-c) / b) t_1 = Float64(-0.5 * Float64(Float64(b + sqrt(Float64(Float64(b * b) - Float64(a * Float64(c * 4.0))))) / a)) tmp = 0.0 if (b <= -3e-45) tmp = t_0; elseif (b <= -6.2e-106) tmp = t_1; elseif (b <= -1.32e-129) tmp = t_0; elseif (b <= 2.1e+25) tmp = t_1; else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) t_0 = -c / b; t_1 = -0.5 * ((b + sqrt(((b * b) - (a * (c * 4.0))))) / a); tmp = 0.0; if (b <= -3e-45) tmp = t_0; elseif (b <= -6.2e-106) tmp = t_1; elseif (b <= -1.32e-129) tmp = t_0; elseif (b <= 2.1e+25) tmp = t_1; else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-c) / b), $MachinePrecision]}, Block[{t$95$1 = N[(-0.5 * N[(N[(b + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -3e-45], t$95$0, If[LessEqual[b, -6.2e-106], t$95$1, If[LessEqual[b, -1.32e-129], t$95$0, If[LessEqual[b, 2.1e+25], t$95$1, N[((-b) / a), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-c}{b}\\
t_1 := -0.5 \cdot \frac{b + \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}}{a}\\
\mathbf{if}\;b \leq -3 \cdot 10^{-45}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq -6.2 \cdot 10^{-106}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;b \leq -1.32 \cdot 10^{-129}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 2.1 \cdot 10^{+25}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
if b < -3.00000000000000011e-45 or -6.19999999999999971e-106 < b < -1.31999999999999992e-129Initial program 17.2%
Taylor expanded in b around -inf 86.3%
associate-*r/86.3%
neg-mul-186.3%
Simplified86.3%
if -3.00000000000000011e-45 < b < -6.19999999999999971e-106 or -1.31999999999999992e-129 < b < 2.0999999999999999e25Initial program 84.4%
Simplified84.4%
fma-udef84.4%
associate-*r*84.4%
metadata-eval84.4%
distribute-rgt-neg-in84.4%
*-commutative84.4%
+-commutative84.4%
sub-neg84.4%
*-commutative84.4%
associate-*l*84.4%
Applied egg-rr84.4%
if 2.0999999999999999e25 < b Initial program 58.2%
Taylor expanded in b around inf 97.1%
associate-*r/97.1%
mul-1-neg97.1%
Simplified97.1%
Final simplification88.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- c) b))
(t_1 (* -0.5 (+ (/ b a) (/ (sqrt (* c (* a -4.0))) a)))))
(if (<= b -2.6e-45)
t_0
(if (<= b -6.2e-106)
t_1
(if (<= b -1.32e-129)
t_0
(if (<= b 9.5e-53) t_1 (- (/ c b) (/ b a))))))))
double code(double a, double b, double c) {
double t_0 = -c / b;
double t_1 = -0.5 * ((b / a) + (sqrt((c * (a * -4.0))) / a));
double tmp;
if (b <= -2.6e-45) {
tmp = t_0;
} else if (b <= -6.2e-106) {
tmp = t_1;
} else if (b <= -1.32e-129) {
tmp = t_0;
} else if (b <= 9.5e-53) {
tmp = t_1;
} else {
tmp = (c / b) - (b / a);
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = -c / b
t_1 = (-0.5d0) * ((b / a) + (sqrt((c * (a * (-4.0d0)))) / a))
if (b <= (-2.6d-45)) then
tmp = t_0
else if (b <= (-6.2d-106)) then
tmp = t_1
else if (b <= (-1.32d-129)) then
tmp = t_0
else if (b <= 9.5d-53) then
tmp = t_1
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = -c / b;
double t_1 = -0.5 * ((b / a) + (Math.sqrt((c * (a * -4.0))) / a));
double tmp;
if (b <= -2.6e-45) {
tmp = t_0;
} else if (b <= -6.2e-106) {
tmp = t_1;
} else if (b <= -1.32e-129) {
tmp = t_0;
} else if (b <= 9.5e-53) {
tmp = t_1;
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): t_0 = -c / b t_1 = -0.5 * ((b / a) + (math.sqrt((c * (a * -4.0))) / a)) tmp = 0 if b <= -2.6e-45: tmp = t_0 elif b <= -6.2e-106: tmp = t_1 elif b <= -1.32e-129: tmp = t_0 elif b <= 9.5e-53: tmp = t_1 else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) t_0 = Float64(Float64(-c) / b) t_1 = Float64(-0.5 * Float64(Float64(b / a) + Float64(sqrt(Float64(c * Float64(a * -4.0))) / a))) tmp = 0.0 if (b <= -2.6e-45) tmp = t_0; elseif (b <= -6.2e-106) tmp = t_1; elseif (b <= -1.32e-129) tmp = t_0; elseif (b <= 9.5e-53) tmp = t_1; else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = -c / b; t_1 = -0.5 * ((b / a) + (sqrt((c * (a * -4.0))) / a)); tmp = 0.0; if (b <= -2.6e-45) tmp = t_0; elseif (b <= -6.2e-106) tmp = t_1; elseif (b <= -1.32e-129) tmp = t_0; elseif (b <= 9.5e-53) tmp = t_1; else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-c) / b), $MachinePrecision]}, Block[{t$95$1 = N[(-0.5 * N[(N[(b / a), $MachinePrecision] + N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -2.6e-45], t$95$0, If[LessEqual[b, -6.2e-106], t$95$1, If[LessEqual[b, -1.32e-129], t$95$0, If[LessEqual[b, 9.5e-53], t$95$1, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-c}{b}\\
t_1 := -0.5 \cdot \left(\frac{b}{a} + \frac{\sqrt{c \cdot \left(a \cdot -4\right)}}{a}\right)\\
\mathbf{if}\;b \leq -2.6 \cdot 10^{-45}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq -6.2 \cdot 10^{-106}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;b \leq -1.32 \cdot 10^{-129}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 9.5 \cdot 10^{-53}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -2.59999999999999987e-45 or -6.19999999999999971e-106 < b < -1.31999999999999992e-129Initial program 17.2%
Taylor expanded in b around -inf 86.3%
associate-*r/86.3%
neg-mul-186.3%
Simplified86.3%
if -2.59999999999999987e-45 < b < -6.19999999999999971e-106 or -1.31999999999999992e-129 < b < 9.5000000000000008e-53Initial program 81.5%
Simplified81.5%
fma-udef81.5%
associate-*r*81.5%
metadata-eval81.5%
distribute-rgt-neg-in81.5%
*-commutative81.5%
+-commutative81.5%
sub-neg81.5%
prod-diff81.3%
*-commutative81.3%
fma-neg81.3%
prod-diff81.3%
*-commutative81.3%
fma-neg81.3%
associate-+l+81.3%
Applied egg-rr81.3%
fma-udef81.3%
*-commutative81.3%
associate-*l*81.3%
+-commutative81.3%
fma-def81.3%
*-commutative81.3%
count-281.3%
fma-def81.3%
associate-*r*81.3%
*-commutative81.3%
Simplified81.3%
Taylor expanded in b around 0 77.2%
*-un-lft-identity77.2%
+-commutative77.2%
un-div-inv77.2%
fma-def77.2%
distribute-rgt-out77.2%
*-commutative77.2%
metadata-eval77.2%
*-commutative77.2%
Applied egg-rr77.2%
*-lft-identity77.2%
+-commutative77.2%
fma-udef77.2%
mul0-rgt77.4%
metadata-eval77.4%
+-lft-identity77.4%
associate-*r*77.4%
*-commutative77.4%
*-commutative77.4%
Simplified77.4%
if 9.5000000000000008e-53 < b Initial program 66.1%
Taylor expanded in b around inf 93.4%
mul-1-neg93.4%
unsub-neg93.4%
Simplified93.4%
Final simplification85.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (* c (* a -4.0)))) (t_1 (/ (- c) b)))
(if (<= b -2.3e-43)
t_1
(if (<= b -6.5e-106)
(* -0.5 (+ (/ b a) (* t_0 (/ 1.0 a))))
(if (<= b -1.16e-129)
t_1
(if (<= b 4.4e-51)
(* -0.5 (+ (/ b a) (/ t_0 a)))
(- (/ c b) (/ b a))))))))
double code(double a, double b, double c) {
double t_0 = sqrt((c * (a * -4.0)));
double t_1 = -c / b;
double tmp;
if (b <= -2.3e-43) {
tmp = t_1;
} else if (b <= -6.5e-106) {
tmp = -0.5 * ((b / a) + (t_0 * (1.0 / a)));
} else if (b <= -1.16e-129) {
tmp = t_1;
} else if (b <= 4.4e-51) {
tmp = -0.5 * ((b / a) + (t_0 / a));
} else {
tmp = (c / b) - (b / a);
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt((c * (a * (-4.0d0))))
t_1 = -c / b
if (b <= (-2.3d-43)) then
tmp = t_1
else if (b <= (-6.5d-106)) then
tmp = (-0.5d0) * ((b / a) + (t_0 * (1.0d0 / a)))
else if (b <= (-1.16d-129)) then
tmp = t_1
else if (b <= 4.4d-51) then
tmp = (-0.5d0) * ((b / a) + (t_0 / a))
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt((c * (a * -4.0)));
double t_1 = -c / b;
double tmp;
if (b <= -2.3e-43) {
tmp = t_1;
} else if (b <= -6.5e-106) {
tmp = -0.5 * ((b / a) + (t_0 * (1.0 / a)));
} else if (b <= -1.16e-129) {
tmp = t_1;
} else if (b <= 4.4e-51) {
tmp = -0.5 * ((b / a) + (t_0 / a));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt((c * (a * -4.0))) t_1 = -c / b tmp = 0 if b <= -2.3e-43: tmp = t_1 elif b <= -6.5e-106: tmp = -0.5 * ((b / a) + (t_0 * (1.0 / a))) elif b <= -1.16e-129: tmp = t_1 elif b <= 4.4e-51: tmp = -0.5 * ((b / a) + (t_0 / a)) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(c * Float64(a * -4.0))) t_1 = Float64(Float64(-c) / b) tmp = 0.0 if (b <= -2.3e-43) tmp = t_1; elseif (b <= -6.5e-106) tmp = Float64(-0.5 * Float64(Float64(b / a) + Float64(t_0 * Float64(1.0 / a)))); elseif (b <= -1.16e-129) tmp = t_1; elseif (b <= 4.4e-51) tmp = Float64(-0.5 * Float64(Float64(b / a) + Float64(t_0 / a))); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt((c * (a * -4.0))); t_1 = -c / b; tmp = 0.0; if (b <= -2.3e-43) tmp = t_1; elseif (b <= -6.5e-106) tmp = -0.5 * ((b / a) + (t_0 * (1.0 / a))); elseif (b <= -1.16e-129) tmp = t_1; elseif (b <= 4.4e-51) tmp = -0.5 * ((b / a) + (t_0 / a)); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[((-c) / b), $MachinePrecision]}, If[LessEqual[b, -2.3e-43], t$95$1, If[LessEqual[b, -6.5e-106], N[(-0.5 * N[(N[(b / a), $MachinePrecision] + N[(t$95$0 * N[(1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, -1.16e-129], t$95$1, If[LessEqual[b, 4.4e-51], N[(-0.5 * N[(N[(b / a), $MachinePrecision] + N[(t$95$0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{c \cdot \left(a \cdot -4\right)}\\
t_1 := \frac{-c}{b}\\
\mathbf{if}\;b \leq -2.3 \cdot 10^{-43}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;b \leq -6.5 \cdot 10^{-106}:\\
\;\;\;\;-0.5 \cdot \left(\frac{b}{a} + t_0 \cdot \frac{1}{a}\right)\\
\mathbf{elif}\;b \leq -1.16 \cdot 10^{-129}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{-51}:\\
\;\;\;\;-0.5 \cdot \left(\frac{b}{a} + \frac{t_0}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -2.2999999999999999e-43 or -6.4999999999999997e-106 < b < -1.16e-129Initial program 17.2%
Taylor expanded in b around -inf 86.3%
associate-*r/86.3%
neg-mul-186.3%
Simplified86.3%
if -2.2999999999999999e-43 < b < -6.4999999999999997e-106Initial program 62.7%
Simplified62.7%
fma-udef62.7%
associate-*r*62.7%
metadata-eval62.7%
distribute-rgt-neg-in62.7%
*-commutative62.7%
+-commutative62.7%
sub-neg62.7%
prod-diff62.3%
*-commutative62.3%
fma-neg62.3%
prod-diff62.3%
*-commutative62.3%
fma-neg62.3%
associate-+l+62.3%
Applied egg-rr62.3%
fma-udef62.3%
*-commutative62.3%
associate-*l*62.3%
+-commutative62.3%
fma-def62.3%
*-commutative62.3%
count-262.3%
fma-def62.5%
associate-*r*62.5%
*-commutative62.5%
Simplified62.5%
Taylor expanded in b around 0 60.5%
*-un-lft-identity60.5%
fma-def60.5%
distribute-rgt-out60.5%
*-commutative60.5%
metadata-eval60.5%
*-commutative60.5%
Applied egg-rr60.5%
*-lft-identity60.5%
fma-udef60.5%
mul0-rgt60.9%
metadata-eval60.9%
+-lft-identity60.9%
associate-*r*60.9%
*-commutative60.9%
*-commutative60.9%
Simplified60.9%
if -1.16e-129 < b < 4.4e-51Initial program 85.1%
Simplified85.1%
fma-udef85.1%
associate-*r*85.1%
metadata-eval85.1%
distribute-rgt-neg-in85.1%
*-commutative85.1%
+-commutative85.1%
sub-neg85.1%
prod-diff84.9%
*-commutative84.9%
fma-neg84.9%
prod-diff84.9%
*-commutative84.9%
fma-neg84.9%
associate-+l+84.9%
Applied egg-rr84.9%
fma-udef84.9%
*-commutative84.9%
associate-*l*84.9%
+-commutative84.9%
fma-def84.9%
*-commutative84.9%
count-284.9%
fma-def84.9%
associate-*r*84.9%
*-commutative84.9%
Simplified84.9%
Taylor expanded in b around 0 80.4%
*-un-lft-identity80.4%
+-commutative80.4%
un-div-inv80.4%
fma-def80.4%
distribute-rgt-out80.4%
*-commutative80.4%
metadata-eval80.4%
*-commutative80.4%
Applied egg-rr80.4%
*-lft-identity80.4%
+-commutative80.4%
fma-udef80.4%
mul0-rgt80.5%
metadata-eval80.5%
+-lft-identity80.5%
associate-*r*80.5%
*-commutative80.5%
*-commutative80.5%
Simplified80.5%
if 4.4e-51 < b Initial program 66.1%
Taylor expanded in b around inf 93.4%
mul-1-neg93.4%
unsub-neg93.4%
Simplified93.4%
Final simplification85.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- c) b)) (t_1 (* -0.5 (/ (+ b (sqrt (* -4.0 (* c a)))) a))))
(if (<= b -3.5e-45)
t_0
(if (<= b -6.2e-106)
t_1
(if (<= b -1.08e-131)
t_0
(if (<= b 2.1e-53) t_1 (- (/ c b) (/ b a))))))))
double code(double a, double b, double c) {
double t_0 = -c / b;
double t_1 = -0.5 * ((b + sqrt((-4.0 * (c * a)))) / a);
double tmp;
if (b <= -3.5e-45) {
tmp = t_0;
} else if (b <= -6.2e-106) {
tmp = t_1;
} else if (b <= -1.08e-131) {
tmp = t_0;
} else if (b <= 2.1e-53) {
tmp = t_1;
} else {
tmp = (c / b) - (b / a);
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = -c / b
t_1 = (-0.5d0) * ((b + sqrt(((-4.0d0) * (c * a)))) / a)
if (b <= (-3.5d-45)) then
tmp = t_0
else if (b <= (-6.2d-106)) then
tmp = t_1
else if (b <= (-1.08d-131)) then
tmp = t_0
else if (b <= 2.1d-53) then
tmp = t_1
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = -c / b;
double t_1 = -0.5 * ((b + Math.sqrt((-4.0 * (c * a)))) / a);
double tmp;
if (b <= -3.5e-45) {
tmp = t_0;
} else if (b <= -6.2e-106) {
tmp = t_1;
} else if (b <= -1.08e-131) {
tmp = t_0;
} else if (b <= 2.1e-53) {
tmp = t_1;
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): t_0 = -c / b t_1 = -0.5 * ((b + math.sqrt((-4.0 * (c * a)))) / a) tmp = 0 if b <= -3.5e-45: tmp = t_0 elif b <= -6.2e-106: tmp = t_1 elif b <= -1.08e-131: tmp = t_0 elif b <= 2.1e-53: tmp = t_1 else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) t_0 = Float64(Float64(-c) / b) t_1 = Float64(-0.5 * Float64(Float64(b + sqrt(Float64(-4.0 * Float64(c * a)))) / a)) tmp = 0.0 if (b <= -3.5e-45) tmp = t_0; elseif (b <= -6.2e-106) tmp = t_1; elseif (b <= -1.08e-131) tmp = t_0; elseif (b <= 2.1e-53) tmp = t_1; else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = -c / b; t_1 = -0.5 * ((b + sqrt((-4.0 * (c * a)))) / a); tmp = 0.0; if (b <= -3.5e-45) tmp = t_0; elseif (b <= -6.2e-106) tmp = t_1; elseif (b <= -1.08e-131) tmp = t_0; elseif (b <= 2.1e-53) tmp = t_1; else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[((-c) / b), $MachinePrecision]}, Block[{t$95$1 = N[(-0.5 * N[(N[(b + N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -3.5e-45], t$95$0, If[LessEqual[b, -6.2e-106], t$95$1, If[LessEqual[b, -1.08e-131], t$95$0, If[LessEqual[b, 2.1e-53], t$95$1, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-c}{b}\\
t_1 := -0.5 \cdot \frac{b + \sqrt{-4 \cdot \left(c \cdot a\right)}}{a}\\
\mathbf{if}\;b \leq -3.5 \cdot 10^{-45}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq -6.2 \cdot 10^{-106}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;b \leq -1.08 \cdot 10^{-131}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b \leq 2.1 \cdot 10^{-53}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -3.5e-45 or -6.19999999999999971e-106 < b < -1.07999999999999996e-131Initial program 17.2%
Taylor expanded in b around -inf 86.3%
associate-*r/86.3%
neg-mul-186.3%
Simplified86.3%
if -3.5e-45 < b < -6.19999999999999971e-106 or -1.07999999999999996e-131 < b < 2.09999999999999977e-53Initial program 81.5%
Simplified81.5%
Taylor expanded in a around inf 77.4%
*-commutative77.4%
Simplified77.4%
if 2.09999999999999977e-53 < b Initial program 66.1%
Taylor expanded in b around inf 93.4%
mul-1-neg93.4%
unsub-neg93.4%
Simplified93.4%
Final simplification85.6%
(FPCore (a b c)
:precision binary64
(if (<= b -1.32e-129)
(/ (- c) b)
(if (<= b 1.65e-54)
(* -0.5 (/ (sqrt (* c (* a -4.0))) a))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.32e-129) {
tmp = -c / b;
} else if (b <= 1.65e-54) {
tmp = -0.5 * (sqrt((c * (a * -4.0))) / a);
} else {
tmp = (c / b) - (b / a);
}
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.32d-129)) then
tmp = -c / b
else if (b <= 1.65d-54) then
tmp = (-0.5d0) * (sqrt((c * (a * (-4.0d0)))) / a)
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1.32e-129) {
tmp = -c / b;
} else if (b <= 1.65e-54) {
tmp = -0.5 * (Math.sqrt((c * (a * -4.0))) / a);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.32e-129: tmp = -c / b elif b <= 1.65e-54: tmp = -0.5 * (math.sqrt((c * (a * -4.0))) / a) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.32e-129) tmp = Float64(Float64(-c) / b); elseif (b <= 1.65e-54) tmp = Float64(-0.5 * Float64(sqrt(Float64(c * Float64(a * -4.0))) / a)); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.32e-129) tmp = -c / b; elseif (b <= 1.65e-54) tmp = -0.5 * (sqrt((c * (a * -4.0))) / a); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.32e-129], N[((-c) / b), $MachinePrecision], If[LessEqual[b, 1.65e-54], N[(-0.5 * N[(N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.32 \cdot 10^{-129}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{elif}\;b \leq 1.65 \cdot 10^{-54}:\\
\;\;\;\;-0.5 \cdot \frac{\sqrt{c \cdot \left(a \cdot -4\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -1.31999999999999992e-129Initial program 22.7%
Taylor expanded in b around -inf 79.3%
associate-*r/79.3%
neg-mul-179.3%
Simplified79.3%
if -1.31999999999999992e-129 < b < 1.64999999999999996e-54Initial program 85.1%
Simplified85.1%
fma-udef85.1%
associate-*r*85.1%
metadata-eval85.1%
distribute-rgt-neg-in85.1%
*-commutative85.1%
+-commutative85.1%
sub-neg85.1%
prod-diff84.9%
*-commutative84.9%
fma-neg84.9%
prod-diff84.9%
*-commutative84.9%
fma-neg84.9%
associate-+l+84.9%
Applied egg-rr84.9%
fma-udef84.9%
*-commutative84.9%
associate-*l*84.9%
+-commutative84.9%
fma-def84.9%
*-commutative84.9%
count-284.9%
fma-def84.9%
associate-*r*84.9%
*-commutative84.9%
Simplified84.9%
Taylor expanded in b around 0 80.4%
Taylor expanded in b around 0 78.6%
associate-*r/78.6%
fma-def78.6%
distribute-rgt-out78.6%
*-commutative78.6%
metadata-eval78.6%
*-commutative78.6%
*-rgt-identity78.6%
fma-udef78.6%
mul0-rgt78.8%
metadata-eval78.8%
+-lft-identity78.8%
associate-*r*78.8%
*-commutative78.8%
*-commutative78.8%
Simplified78.8%
if 1.64999999999999996e-54 < b Initial program 66.1%
Taylor expanded in b around inf 93.4%
mul-1-neg93.4%
unsub-neg93.4%
Simplified93.4%
Final simplification83.5%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ (- c) b) (- (/ c b) (/ b a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-310) {
tmp = -c / b;
} else {
tmp = (c / b) - (b / a);
}
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
else
tmp = (c / b) - (b / a)
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;
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = -c / b else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(-c) / b); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2e-310) tmp = -c / b; else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-310], N[((-c) / b), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 34.4%
Taylor expanded in b around -inf 65.9%
associate-*r/65.9%
neg-mul-165.9%
Simplified65.9%
if -1.999999999999994e-310 < b Initial program 72.4%
Taylor expanded in b around inf 67.2%
mul-1-neg67.2%
unsub-neg67.2%
Simplified67.2%
Final simplification66.5%
(FPCore (a b c) :precision binary64 (if (<= b -9.8e+51) (/ c b) (/ (- b) a)))
double code(double a, double b, double c) {
double tmp;
if (b <= -9.8e+51) {
tmp = c / b;
} else {
tmp = -b / a;
}
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 <= (-9.8d+51)) then
tmp = c / b
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -9.8e+51) {
tmp = c / b;
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9.8e+51: tmp = c / b else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9.8e+51) tmp = Float64(c / b); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -9.8e+51) tmp = c / b; else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9.8e+51], N[(c / b), $MachinePrecision], N[((-b) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.8 \cdot 10^{+51}:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
if b < -9.79999999999999967e51Initial program 14.0%
Taylor expanded in b around inf 2.3%
+-commutative2.3%
*-commutative2.3%
fma-def2.3%
*-commutative2.3%
associate-/l*2.3%
Simplified2.3%
Taylor expanded in b around 0 34.3%
if -9.79999999999999967e51 < b Initial program 66.9%
Taylor expanded in b around inf 45.1%
associate-*r/45.1%
mul-1-neg45.1%
Simplified45.1%
Final simplification42.2%
(FPCore (a b c) :precision binary64 (if (<= b -5.5e-261) (/ (- c) b) (/ (- b) a)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-261) {
tmp = -c / b;
} else {
tmp = -b / a;
}
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-261)) then
tmp = -c / b
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5.5e-261) {
tmp = -c / b;
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.5e-261: tmp = -c / b else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.5e-261) tmp = Float64(Float64(-c) / b); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.5e-261) tmp = -c / b; else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.5e-261], N[((-c) / b), $MachinePrecision], N[((-b) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.5 \cdot 10^{-261}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
if b < -5.50000000000000042e-261Initial program 30.7%
Taylor expanded in b around -inf 69.3%
associate-*r/69.3%
neg-mul-169.3%
Simplified69.3%
if -5.50000000000000042e-261 < b Initial program 73.9%
Taylor expanded in b around inf 63.6%
associate-*r/63.6%
mul-1-neg63.6%
Simplified63.6%
Final simplification66.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 52.7%
clear-num52.5%
inv-pow52.5%
Applied egg-rr34.1%
unpow-134.1%
fma-udef34.0%
*-commutative34.0%
associate-*l*34.4%
*-commutative34.4%
fma-def34.4%
Simplified34.4%
Taylor expanded in b around -inf 2.6%
Final simplification2.6%
(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.7%
Taylor expanded in b around inf 31.4%
+-commutative31.4%
*-commutative31.4%
fma-def31.4%
*-commutative31.4%
associate-/l*33.3%
Simplified33.3%
Taylor expanded in b around 0 11.5%
Final simplification11.5%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* 4.0 (* a c))))))
(if (< b 0.0)
(/ c (* a (/ (+ (- b) t_0) (* 2.0 a))))
(/ (- (- b) t_0) (* 2.0 a)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (4.0 * (a * c))));
double tmp;
if (b < 0.0) {
tmp = c / (a * ((-b + t_0) / (2.0 * a)));
} else {
tmp = (-b - t_0) / (2.0 * a);
}
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) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - (4.0d0 * (a * c))))
if (b < 0.0d0) then
tmp = c / (a * ((-b + t_0) / (2.0d0 * a)))
else
tmp = (-b - t_0) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (4.0 * (a * c))));
double tmp;
if (b < 0.0) {
tmp = c / (a * ((-b + t_0) / (2.0 * a)));
} else {
tmp = (-b - t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (4.0 * (a * c)))) tmp = 0 if b < 0.0: tmp = c / (a * ((-b + t_0) / (2.0 * a))) else: tmp = (-b - t_0) / (2.0 * a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) tmp = 0.0 if (b < 0.0) tmp = Float64(c / Float64(a * Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)))); else tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - (4.0 * (a * c)))); tmp = 0.0; if (b < 0.0) tmp = c / (a * ((-b + t_0) / (2.0 * a))); else tmp = (-b - t_0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Less[b, 0.0], N[(c / N[(a * N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\
\mathbf{if}\;b < 0:\\
\;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + t_0}{2 \cdot a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - t_0}{2 \cdot a}\\
\end{array}
\end{array}
herbie shell --seed 2023230
(FPCore (a b c)
:name "quadm (p42, negative)"
:precision binary64
:herbie-target
(if (< b 0.0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))