
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) t_0)))))
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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
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 = (-b - t_0) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + t_0)
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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (2.0 * a) else: tmp = (2.0 * c) / (-b + t_0) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + t_0)); 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 = (-b - t_0) / (2.0 * a); else tmp = (2.0 * c) / (-b + t_0); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t\_0}\\
\end{array}
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c))))) (if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) t_0)))))
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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
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 = (-b - t_0) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + t_0)
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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (2.0 * a) else: tmp = (2.0 * c) / (-b + t_0) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + t_0)); 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 = (-b - t_0) / (2.0 * a); else tmp = (2.0 * c) / (-b + t_0); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t\_0}\\
\end{array}
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (fma (* -4.0 a) c (* b b)))))
(if (<= b -4.5e+153)
(if (>= b 0.0) (- (sqrt (- (/ c a)))) (- (/ c b)))
(if (<= b 3.3e+110)
(if (>= b 0.0) (* (/ (+ t_0 b) a) -0.5) (/ (+ c c) (- t_0 b)))
(if (>= b 0.0)
(+ (/ (- b) a) (/ c b))
(/ (* 2.0 c) (+ (- b) (- b))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(fma((-4.0 * a), c, (b * b)));
double tmp_1;
if (b <= -4.5e+153) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -sqrt(-(c / a));
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b <= 3.3e+110) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = ((t_0 + b) / a) * -0.5;
} else {
tmp_3 = (c + c) / (t_0 - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (-b / a) + (c / b);
} else {
tmp_1 = (2.0 * c) / (-b + -b);
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(fma(Float64(-4.0 * a), c, Float64(b * b))) tmp_1 = 0.0 if (b <= -4.5e+153) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-sqrt(Float64(-Float64(c / a)))); else tmp_2 = Float64(-Float64(c / b)); end tmp_1 = tmp_2; elseif (b <= 3.3e+110) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(t_0 + b) / a) * -0.5); else tmp_3 = Float64(Float64(c + c) / Float64(t_0 - b)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) / a) + Float64(c / b)); else tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) + Float64(-b))); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -4.5e+153], If[GreaterEqual[b, 0.0], (-N[Sqrt[(-N[(c / a), $MachinePrecision])], $MachinePrecision]), (-N[(c / b), $MachinePrecision])], If[LessEqual[b, 3.3e+110], If[GreaterEqual[b, 0.0], N[(N[(N[(t$95$0 + b), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(c + c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[((-b) / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + (-b)), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)}\\
\mathbf{if}\;b \leq -4.5 \cdot 10^{+153}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\sqrt{-\frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq 3.3 \cdot 10^{+110}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{t\_0 + b}{a} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{c + c}{t\_0 - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \left(-b\right)}\\
\end{array}
\end{array}
if b < -4.5000000000000001e153Initial program 41.0%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6497.8
Applied rewrites97.8%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6497.8
Applied rewrites97.8%
Taylor expanded in c around -inf
mul-1-negN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6497.8
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6497.8
Applied rewrites97.8%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6498.0
Applied rewrites98.0%
if -4.5000000000000001e153 < b < 3.29999999999999971e110Initial program 87.6%
Taylor expanded in a around 0
Applied rewrites87.6%
if 3.29999999999999971e110 < b Initial program 51.4%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6451.4
Applied rewrites51.4%
Taylor expanded in c around 0
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f64N/A
lift-/.f6496.3
Applied rewrites96.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c)))))
(if (<= b -4.5e+153)
(if (>= b 0.0) (- (sqrt (- (/ c a)))) (- (/ c b)))
(if (<= b 3.3e+110)
(if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) t_0)))
(if (>= b 0.0)
(+ (/ (- b) a) (/ c b))
(/ (* 2.0 c) (+ (- b) (- b))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp_1;
if (b <= -4.5e+153) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -sqrt(-(c / a));
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b <= 3.3e+110) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_0) / (2.0 * a);
} else {
tmp_3 = (2.0 * c) / (-b + t_0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (-b / a) + (c / b);
} else {
tmp_1 = (2.0 * c) / (-b + -b);
}
return tmp_1;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b <= (-4.5d+153)) then
if (b >= 0.0d0) then
tmp_2 = -sqrt(-(c / a))
else
tmp_2 = -(c / b)
end if
tmp_1 = tmp_2
else if (b <= 3.3d+110) then
if (b >= 0.0d0) then
tmp_3 = (-b - t_0) / (2.0d0 * a)
else
tmp_3 = (2.0d0 * c) / (-b + t_0)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (-b / a) + (c / b)
else
tmp_1 = (2.0d0 * c) / (-b + -b)
end if
code = tmp_1
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_1;
if (b <= -4.5e+153) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -Math.sqrt(-(c / a));
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b <= 3.3e+110) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-b - t_0) / (2.0 * a);
} else {
tmp_3 = (2.0 * c) / (-b + t_0);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (-b / a) + (c / b);
} else {
tmp_1 = (2.0 * c) / (-b + -b);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp_1 = 0 if b <= -4.5e+153: tmp_2 = 0 if b >= 0.0: tmp_2 = -math.sqrt(-(c / a)) else: tmp_2 = -(c / b) tmp_1 = tmp_2 elif b <= 3.3e+110: tmp_3 = 0 if b >= 0.0: tmp_3 = (-b - t_0) / (2.0 * a) else: tmp_3 = (2.0 * c) / (-b + t_0) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (-b / a) + (c / b) else: tmp_1 = (2.0 * c) / (-b + -b) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp_1 = 0.0 if (b <= -4.5e+153) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-sqrt(Float64(-Float64(c / a)))); else tmp_2 = Float64(-Float64(c / b)); end tmp_1 = tmp_2; elseif (b <= 3.3e+110) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp_3 = Float64(Float64(2.0 * c) / Float64(Float64(-b) + t_0)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) / a) + Float64(c / b)); else tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) + Float64(-b))); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp_2 = 0.0; if (b <= -4.5e+153) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -sqrt(-(c / a)); else tmp_3 = -(c / b); end tmp_2 = tmp_3; elseif (b <= 3.3e+110) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (-b - t_0) / (2.0 * a); else tmp_4 = (2.0 * c) / (-b + t_0); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (-b / a) + (c / b); else tmp_2 = (2.0 * c) / (-b + -b); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -4.5e+153], If[GreaterEqual[b, 0.0], (-N[Sqrt[(-N[(c / a), $MachinePrecision])], $MachinePrecision]), (-N[(c / b), $MachinePrecision])], If[LessEqual[b, 3.3e+110], If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[((-b) / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + (-b)), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \leq -4.5 \cdot 10^{+153}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\sqrt{-\frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq 3.3 \cdot 10^{+110}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t\_0}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \left(-b\right)}\\
\end{array}
\end{array}
if b < -4.5000000000000001e153Initial program 41.0%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6497.8
Applied rewrites97.8%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6497.8
Applied rewrites97.8%
Taylor expanded in c around -inf
mul-1-negN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6497.8
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6497.8
Applied rewrites97.8%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6498.0
Applied rewrites98.0%
if -4.5000000000000001e153 < b < 3.29999999999999971e110Initial program 87.6%
if 3.29999999999999971e110 < b Initial program 51.4%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6451.4
Applied rewrites51.4%
Taylor expanded in c around 0
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f64N/A
lift-/.f6496.3
Applied rewrites96.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (fma (* -4.0 a) c (* b b)))))
(if (<= b -4.5e+153)
(if (>= b 0.0) (- (sqrt (- (/ c a)))) (- (/ c b)))
(if (<= b 2e-250)
(if (>= b 0.0)
(* (/ (+ (sqrt (* (* -4.0 a) c)) b) a) -0.5)
(/ (+ c c) (- t_0 b)))
(if (<= b 3.3e+110)
(if (>= b 0.0)
(* (/ (+ t_0 b) a) -0.5)
(- (- (sqrt (* (/ c a) -1.0))) (* 0.5 (/ b a))))
(if (>= b 0.0)
(+ (/ (- b) a) (/ c b))
(/ (* 2.0 c) (+ (- b) (- b)))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(fma((-4.0 * a), c, (b * b)));
double tmp_1;
if (b <= -4.5e+153) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -sqrt(-(c / a));
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b <= 2e-250) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = ((sqrt(((-4.0 * a) * c)) + b) / a) * -0.5;
} else {
tmp_3 = (c + c) / (t_0 - b);
}
tmp_1 = tmp_3;
} else if (b <= 3.3e+110) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = ((t_0 + b) / a) * -0.5;
} else {
tmp_4 = -sqrt(((c / a) * -1.0)) - (0.5 * (b / a));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (-b / a) + (c / b);
} else {
tmp_1 = (2.0 * c) / (-b + -b);
}
return tmp_1;
}
function code(a, b, c) t_0 = sqrt(fma(Float64(-4.0 * a), c, Float64(b * b))) tmp_1 = 0.0 if (b <= -4.5e+153) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-sqrt(Float64(-Float64(c / a)))); else tmp_2 = Float64(-Float64(c / b)); end tmp_1 = tmp_2; elseif (b <= 2e-250) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(sqrt(Float64(Float64(-4.0 * a) * c)) + b) / a) * -0.5); else tmp_3 = Float64(Float64(c + c) / Float64(t_0 - b)); end tmp_1 = tmp_3; elseif (b <= 3.3e+110) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(Float64(t_0 + b) / a) * -0.5); else tmp_4 = Float64(Float64(-sqrt(Float64(Float64(c / a) * -1.0))) - Float64(0.5 * Float64(b / a))); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) / a) + Float64(c / b)); else tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) + Float64(-b))); end return tmp_1 end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -4.5e+153], If[GreaterEqual[b, 0.0], (-N[Sqrt[(-N[(c / a), $MachinePrecision])], $MachinePrecision]), (-N[(c / b), $MachinePrecision])], If[LessEqual[b, 2e-250], If[GreaterEqual[b, 0.0], N[(N[(N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] + b), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(c + c), $MachinePrecision] / N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 3.3e+110], If[GreaterEqual[b, 0.0], N[(N[(N[(t$95$0 + b), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision], N[((-N[Sqrt[N[(N[(c / a), $MachinePrecision] * -1.0), $MachinePrecision]], $MachinePrecision]) - N[(0.5 * N[(b / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[((-b) / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + (-b)), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)}\\
\mathbf{if}\;b \leq -4.5 \cdot 10^{+153}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\sqrt{-\frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq 2 \cdot 10^{-250}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c} + b}{a} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{c + c}{t\_0 - b}\\
\end{array}\\
\mathbf{elif}\;b \leq 3.3 \cdot 10^{+110}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{t\_0 + b}{a} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\left(-\sqrt{\frac{c}{a} \cdot -1}\right) - 0.5 \cdot \frac{b}{a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \left(-b\right)}\\
\end{array}
\end{array}
if b < -4.5000000000000001e153Initial program 41.0%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6497.8
Applied rewrites97.8%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6497.8
Applied rewrites97.8%
Taylor expanded in c around -inf
mul-1-negN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6497.8
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6497.8
Applied rewrites97.8%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6498.0
Applied rewrites98.0%
if -4.5000000000000001e153 < b < 2.0000000000000001e-250Initial program 87.6%
Taylor expanded in a around 0
Applied rewrites87.6%
Taylor expanded in a around inf
associate-*r*N/A
lower-*.f64N/A
lift-*.f6487.6
Applied rewrites87.6%
if 2.0000000000000001e-250 < b < 3.29999999999999971e110Initial program 87.6%
Taylor expanded in a around 0
Applied rewrites87.6%
Taylor expanded in c around -inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6487.6
Applied rewrites87.6%
if 3.29999999999999971e110 < b Initial program 51.4%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6451.4
Applied rewrites51.4%
Taylor expanded in c around 0
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f64N/A
lift-/.f6496.3
Applied rewrites96.3%
(FPCore (a b c)
:precision binary64
(if (<= b -4.5e+153)
(if (>= b 0.0) (- (sqrt (- (/ c a)))) (- (/ c b)))
(if (<= b 7.2e-22)
(if (>= b 0.0)
(* (/ (+ (sqrt (* (* -4.0 a) c)) b) a) -0.5)
(/ (+ c c) (- (sqrt (fma (* -4.0 a) c (* b b))) b)))
(if (>= b 0.0) (+ (/ (- b) a) (/ c b)) (/ (* 2.0 c) (+ (- b) (- b)))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -4.5e+153) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -sqrt(-(c / a));
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b <= 7.2e-22) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = ((sqrt(((-4.0 * a) * c)) + b) / a) * -0.5;
} else {
tmp_3 = (c + c) / (sqrt(fma((-4.0 * a), c, (b * b))) - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (-b / a) + (c / b);
} else {
tmp_1 = (2.0 * c) / (-b + -b);
}
return tmp_1;
}
function code(a, b, c) tmp_1 = 0.0 if (b <= -4.5e+153) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-sqrt(Float64(-Float64(c / a)))); else tmp_2 = Float64(-Float64(c / b)); end tmp_1 = tmp_2; elseif (b <= 7.2e-22) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(Float64(sqrt(Float64(Float64(-4.0 * a) * c)) + b) / a) * -0.5); else tmp_3 = Float64(Float64(c + c) / Float64(sqrt(fma(Float64(-4.0 * a), c, Float64(b * b))) - b)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) / a) + Float64(c / b)); else tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) + Float64(-b))); end return tmp_1 end
code[a_, b_, c_] := If[LessEqual[b, -4.5e+153], If[GreaterEqual[b, 0.0], (-N[Sqrt[(-N[(c / a), $MachinePrecision])], $MachinePrecision]), (-N[(c / b), $MachinePrecision])], If[LessEqual[b, 7.2e-22], If[GreaterEqual[b, 0.0], N[(N[(N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] + b), $MachinePrecision] / a), $MachinePrecision] * -0.5), $MachinePrecision], N[(N[(c + c), $MachinePrecision] / N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[((-b) / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + (-b)), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{+153}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\sqrt{-\frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq 7.2 \cdot 10^{-22}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c} + b}{a} \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{c + c}{\sqrt{\mathsf{fma}\left(-4 \cdot a, c, b \cdot b\right)} - b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \left(-b\right)}\\
\end{array}
\end{array}
if b < -4.5000000000000001e153Initial program 41.0%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6497.8
Applied rewrites97.8%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6497.8
Applied rewrites97.8%
Taylor expanded in c around -inf
mul-1-negN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6497.8
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6497.8
Applied rewrites97.8%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6498.0
Applied rewrites98.0%
if -4.5000000000000001e153 < b < 7.1999999999999996e-22Initial program 86.5%
Taylor expanded in a around 0
Applied rewrites86.5%
Taylor expanded in a around inf
associate-*r*N/A
lower-*.f64N/A
lift-*.f6480.1
Applied rewrites80.1%
if 7.1999999999999996e-22 < b Initial program 66.1%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6466.1
Applied rewrites66.1%
Taylor expanded in c around 0
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f64N/A
lift-/.f6489.3
Applied rewrites89.3%
(FPCore (a b c)
:precision binary64
(if (<= b -3.95e-63)
(if (>= b 0.0) (- (sqrt (- (/ c a)))) (- (/ c b)))
(if (<= b 2.3e-22)
(if (>= b 0.0)
(/ (- (sqrt (* (* a c) -4.0))) (* 2.0 a))
(/ (- (* -0.5 b) (sqrt (* (* c a) -1.0))) a))
(if (>= b 0.0) (+ (/ (- b) a) (/ c b)) (/ (* 2.0 c) (+ (- b) (- b)))))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= -3.95e-63) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -sqrt(-(c / a));
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b <= 2.3e-22) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -sqrt(((a * c) * -4.0)) / (2.0 * a);
} else {
tmp_3 = ((-0.5 * b) - sqrt(((c * a) * -1.0))) / a;
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (-b / a) + (c / b);
} else {
tmp_1 = (2.0 * c) / (-b + -b);
}
return tmp_1;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
if (b <= (-3.95d-63)) then
if (b >= 0.0d0) then
tmp_2 = -sqrt(-(c / a))
else
tmp_2 = -(c / b)
end if
tmp_1 = tmp_2
else if (b <= 2.3d-22) then
if (b >= 0.0d0) then
tmp_3 = -sqrt(((a * c) * (-4.0d0))) / (2.0d0 * a)
else
tmp_3 = (((-0.5d0) * b) - sqrt(((c * a) * (-1.0d0)))) / a
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (-b / a) + (c / b)
else
tmp_1 = (2.0d0 * c) / (-b + -b)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= -3.95e-63) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -Math.sqrt(-(c / a));
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b <= 2.3e-22) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -Math.sqrt(((a * c) * -4.0)) / (2.0 * a);
} else {
tmp_3 = ((-0.5 * b) - Math.sqrt(((c * a) * -1.0))) / a;
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (-b / a) + (c / b);
} else {
tmp_1 = (2.0 * c) / (-b + -b);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= -3.95e-63: tmp_2 = 0 if b >= 0.0: tmp_2 = -math.sqrt(-(c / a)) else: tmp_2 = -(c / b) tmp_1 = tmp_2 elif b <= 2.3e-22: tmp_3 = 0 if b >= 0.0: tmp_3 = -math.sqrt(((a * c) * -4.0)) / (2.0 * a) else: tmp_3 = ((-0.5 * b) - math.sqrt(((c * a) * -1.0))) / a tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (-b / a) + (c / b) else: tmp_1 = (2.0 * c) / (-b + -b) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= -3.95e-63) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-sqrt(Float64(-Float64(c / a)))); else tmp_2 = Float64(-Float64(c / b)); end tmp_1 = tmp_2; elseif (b <= 2.3e-22) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(-sqrt(Float64(Float64(a * c) * -4.0))) / Float64(2.0 * a)); else tmp_3 = Float64(Float64(Float64(-0.5 * b) - sqrt(Float64(Float64(c * a) * -1.0))) / a); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) / a) + Float64(c / b)); else tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) + Float64(-b))); end return tmp_1 end
function tmp_5 = code(a, b, c) tmp_2 = 0.0; if (b <= -3.95e-63) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -sqrt(-(c / a)); else tmp_3 = -(c / b); end tmp_2 = tmp_3; elseif (b <= 2.3e-22) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = -sqrt(((a * c) * -4.0)) / (2.0 * a); else tmp_4 = ((-0.5 * b) - sqrt(((c * a) * -1.0))) / a; end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (-b / a) + (c / b); else tmp_2 = (2.0 * c) / (-b + -b); end tmp_5 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, -3.95e-63], If[GreaterEqual[b, 0.0], (-N[Sqrt[(-N[(c / a), $MachinePrecision])], $MachinePrecision]), (-N[(c / b), $MachinePrecision])], If[LessEqual[b, 2.3e-22], If[GreaterEqual[b, 0.0], N[((-N[Sqrt[N[(N[(a * c), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]) / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-0.5 * b), $MachinePrecision] - N[Sqrt[N[(N[(c * a), $MachinePrecision] * -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[((-b) / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + (-b)), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.95 \cdot 10^{-63}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\sqrt{-\frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{-22}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-\sqrt{\left(a \cdot c\right) \cdot -4}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.5 \cdot b - \sqrt{\left(c \cdot a\right) \cdot -1}}{a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \left(-b\right)}\\
\end{array}
\end{array}
if b < -3.9500000000000002e-63Initial program 68.6%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6487.6
Applied rewrites87.6%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6487.6
Applied rewrites87.6%
Taylor expanded in c around -inf
mul-1-negN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6487.6
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6487.6
Applied rewrites87.6%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6487.6
Applied rewrites87.6%
if -3.9500000000000002e-63 < b < 2.2999999999999998e-22Initial program 82.5%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6454.1
Applied rewrites54.1%
Taylor expanded in a around inf
mul-1-negN/A
lower-neg.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6441.9
Applied rewrites41.9%
Taylor expanded in c around -inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
mul-1-negN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6446.1
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6446.1
Applied rewrites46.1%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
*-commutativeN/A
sqrt-prodN/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6463.0
Applied rewrites63.0%
if 2.2999999999999998e-22 < b Initial program 66.2%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6466.2
Applied rewrites66.2%
Taylor expanded in c around 0
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f64N/A
lift-/.f6489.3
Applied rewrites89.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (+ (/ (- b) a) (/ c b)))
(t_1 (+ (- b) (- b)))
(t_2 (sqrt (* (* c a) -4.0))))
(if (<= b -3.95e-63)
(if (>= b 0.0) (- (sqrt (- (/ c a)))) (- (/ c b)))
(if (<= b -1e-310)
(if (>= b 0.0) t_0 (/ (* 2.0 c) t_2))
(if (<= b 2.3e-22)
(if (>= b 0.0) (/ (- t_2) (+ a a)) (/ (+ c c) t_1))
(if (>= b 0.0) t_0 (/ (* 2.0 c) t_1)))))))
double code(double a, double b, double c) {
double t_0 = (-b / a) + (c / b);
double t_1 = -b + -b;
double t_2 = sqrt(((c * a) * -4.0));
double tmp_1;
if (b <= -3.95e-63) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -sqrt(-(c / a));
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b <= -1e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_0;
} else {
tmp_3 = (2.0 * c) / t_2;
}
tmp_1 = tmp_3;
} else if (b <= 2.3e-22) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = -t_2 / (a + a);
} else {
tmp_4 = (c + c) / t_1;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = (2.0 * c) / t_1;
}
return tmp_1;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
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) :: t_2
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
real(8) :: tmp_4
t_0 = (-b / a) + (c / b)
t_1 = -b + -b
t_2 = sqrt(((c * a) * (-4.0d0)))
if (b <= (-3.95d-63)) then
if (b >= 0.0d0) then
tmp_2 = -sqrt(-(c / a))
else
tmp_2 = -(c / b)
end if
tmp_1 = tmp_2
else if (b <= (-1d-310)) then
if (b >= 0.0d0) then
tmp_3 = t_0
else
tmp_3 = (2.0d0 * c) / t_2
end if
tmp_1 = tmp_3
else if (b <= 2.3d-22) then
if (b >= 0.0d0) then
tmp_4 = -t_2 / (a + a)
else
tmp_4 = (c + c) / t_1
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = t_0
else
tmp_1 = (2.0d0 * c) / t_1
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = (-b / a) + (c / b);
double t_1 = -b + -b;
double t_2 = Math.sqrt(((c * a) * -4.0));
double tmp_1;
if (b <= -3.95e-63) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -Math.sqrt(-(c / a));
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b <= -1e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_0;
} else {
tmp_3 = (2.0 * c) / t_2;
}
tmp_1 = tmp_3;
} else if (b <= 2.3e-22) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = -t_2 / (a + a);
} else {
tmp_4 = (c + c) / t_1;
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = (2.0 * c) / t_1;
}
return tmp_1;
}
def code(a, b, c): t_0 = (-b / a) + (c / b) t_1 = -b + -b t_2 = math.sqrt(((c * a) * -4.0)) tmp_1 = 0 if b <= -3.95e-63: tmp_2 = 0 if b >= 0.0: tmp_2 = -math.sqrt(-(c / a)) else: tmp_2 = -(c / b) tmp_1 = tmp_2 elif b <= -1e-310: tmp_3 = 0 if b >= 0.0: tmp_3 = t_0 else: tmp_3 = (2.0 * c) / t_2 tmp_1 = tmp_3 elif b <= 2.3e-22: tmp_4 = 0 if b >= 0.0: tmp_4 = -t_2 / (a + a) else: tmp_4 = (c + c) / t_1 tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = t_0 else: tmp_1 = (2.0 * c) / t_1 return tmp_1
function code(a, b, c) t_0 = Float64(Float64(Float64(-b) / a) + Float64(c / b)) t_1 = Float64(Float64(-b) + Float64(-b)) t_2 = sqrt(Float64(Float64(c * a) * -4.0)) tmp_1 = 0.0 if (b <= -3.95e-63) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-sqrt(Float64(-Float64(c / a)))); else tmp_2 = Float64(-Float64(c / b)); end tmp_1 = tmp_2; elseif (b <= -1e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_0; else tmp_3 = Float64(Float64(2.0 * c) / t_2); end tmp_1 = tmp_3; elseif (b <= 2.3e-22) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(-t_2) / Float64(a + a)); else tmp_4 = Float64(Float64(c + c) / t_1); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = t_0; else tmp_1 = Float64(Float64(2.0 * c) / t_1); end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = (-b / a) + (c / b); t_1 = -b + -b; t_2 = sqrt(((c * a) * -4.0)); tmp_2 = 0.0; if (b <= -3.95e-63) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -sqrt(-(c / a)); else tmp_3 = -(c / b); end tmp_2 = tmp_3; elseif (b <= -1e-310) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = t_0; else tmp_4 = (2.0 * c) / t_2; end tmp_2 = tmp_4; elseif (b <= 2.3e-22) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = -t_2 / (a + a); else tmp_5 = (c + c) / t_1; end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = t_0; else tmp_2 = (2.0 * c) / t_1; end tmp_6 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[((-b) / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-b) + (-b)), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -3.95e-63], If[GreaterEqual[b, 0.0], (-N[Sqrt[(-N[(c / a), $MachinePrecision])], $MachinePrecision]), (-N[(c / b), $MachinePrecision])], If[LessEqual[b, -1e-310], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(2.0 * c), $MachinePrecision] / t$95$2), $MachinePrecision]], If[LessEqual[b, 2.3e-22], If[GreaterEqual[b, 0.0], N[((-t$95$2) / N[(a + a), $MachinePrecision]), $MachinePrecision], N[(N[(c + c), $MachinePrecision] / t$95$1), $MachinePrecision]], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(2.0 * c), $MachinePrecision] / t$95$1), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-b}{a} + \frac{c}{b}\\
t_1 := \left(-b\right) + \left(-b\right)\\
t_2 := \sqrt{\left(c \cdot a\right) \cdot -4}\\
\mathbf{if}\;b \leq -3.95 \cdot 10^{-63}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\sqrt{-\frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t\_2}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{-22}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-t\_2}{a + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c + c}{t\_1}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{t\_1}\\
\end{array}
\end{array}
if b < -3.9500000000000002e-63Initial program 68.6%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6487.6
Applied rewrites87.6%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6487.6
Applied rewrites87.6%
Taylor expanded in c around -inf
mul-1-negN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6487.6
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6487.6
Applied rewrites87.6%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6487.6
Applied rewrites87.6%
if -3.9500000000000002e-63 < b < -9.999999999999969e-311Initial program 83.1%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6421.9
Applied rewrites21.9%
Taylor expanded in c around 0
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f64N/A
lift-/.f6421.9
Applied rewrites21.9%
Taylor expanded in a around inf
sqrt-prodN/A
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f6467.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.2
Applied rewrites67.2%
if -9.999999999999969e-311 < b < 2.2999999999999998e-22Initial program 81.9%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6481.9
Applied rewrites81.9%
Taylor expanded in a around inf
mul-1-negN/A
lower-neg.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6459.1
Applied rewrites59.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6459.1
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites59.1%
if 2.2999999999999998e-22 < b Initial program 66.2%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6466.2
Applied rewrites66.2%
Taylor expanded in c around 0
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f64N/A
lift-/.f6489.3
Applied rewrites89.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (+ (/ (- b) a) (/ c b))))
(if (<= b -3.95e-63)
(if (>= b 0.0) (- (sqrt (- (/ c a)))) (- (/ c b)))
(if (<= b -1e-310)
(if (>= b 0.0) t_0 (/ (* 2.0 c) (sqrt (* (* c a) -4.0))))
(if (<= b 2.3e-22)
(if (>= b 0.0)
(/ (- (sqrt (* (* a c) -4.0))) (* 2.0 a))
(- (* (/ b a) -0.5) (sqrt (/ (- c) a))))
(if (>= b 0.0) t_0 (/ (* 2.0 c) (+ (- b) (- b)))))))))
double code(double a, double b, double c) {
double t_0 = (-b / a) + (c / b);
double tmp_1;
if (b <= -3.95e-63) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -sqrt(-(c / a));
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b <= -1e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_0;
} else {
tmp_3 = (2.0 * c) / sqrt(((c * a) * -4.0));
}
tmp_1 = tmp_3;
} else if (b <= 2.3e-22) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = -sqrt(((a * c) * -4.0)) / (2.0 * a);
} else {
tmp_4 = ((b / a) * -0.5) - sqrt((-c / a));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = (2.0 * c) / (-b + -b);
}
return tmp_1;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
real(8) :: tmp_4
t_0 = (-b / a) + (c / b)
if (b <= (-3.95d-63)) then
if (b >= 0.0d0) then
tmp_2 = -sqrt(-(c / a))
else
tmp_2 = -(c / b)
end if
tmp_1 = tmp_2
else if (b <= (-1d-310)) then
if (b >= 0.0d0) then
tmp_3 = t_0
else
tmp_3 = (2.0d0 * c) / sqrt(((c * a) * (-4.0d0)))
end if
tmp_1 = tmp_3
else if (b <= 2.3d-22) then
if (b >= 0.0d0) then
tmp_4 = -sqrt(((a * c) * (-4.0d0))) / (2.0d0 * a)
else
tmp_4 = ((b / a) * (-0.5d0)) - sqrt((-c / a))
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = t_0
else
tmp_1 = (2.0d0 * c) / (-b + -b)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = (-b / a) + (c / b);
double tmp_1;
if (b <= -3.95e-63) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -Math.sqrt(-(c / a));
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b <= -1e-310) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_0;
} else {
tmp_3 = (2.0 * c) / Math.sqrt(((c * a) * -4.0));
}
tmp_1 = tmp_3;
} else if (b <= 2.3e-22) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = -Math.sqrt(((a * c) * -4.0)) / (2.0 * a);
} else {
tmp_4 = ((b / a) * -0.5) - Math.sqrt((-c / a));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = t_0;
} else {
tmp_1 = (2.0 * c) / (-b + -b);
}
return tmp_1;
}
def code(a, b, c): t_0 = (-b / a) + (c / b) tmp_1 = 0 if b <= -3.95e-63: tmp_2 = 0 if b >= 0.0: tmp_2 = -math.sqrt(-(c / a)) else: tmp_2 = -(c / b) tmp_1 = tmp_2 elif b <= -1e-310: tmp_3 = 0 if b >= 0.0: tmp_3 = t_0 else: tmp_3 = (2.0 * c) / math.sqrt(((c * a) * -4.0)) tmp_1 = tmp_3 elif b <= 2.3e-22: tmp_4 = 0 if b >= 0.0: tmp_4 = -math.sqrt(((a * c) * -4.0)) / (2.0 * a) else: tmp_4 = ((b / a) * -0.5) - math.sqrt((-c / a)) tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = t_0 else: tmp_1 = (2.0 * c) / (-b + -b) return tmp_1
function code(a, b, c) t_0 = Float64(Float64(Float64(-b) / a) + Float64(c / b)) tmp_1 = 0.0 if (b <= -3.95e-63) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-sqrt(Float64(-Float64(c / a)))); else tmp_2 = Float64(-Float64(c / b)); end tmp_1 = tmp_2; elseif (b <= -1e-310) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_0; else tmp_3 = Float64(Float64(2.0 * c) / sqrt(Float64(Float64(c * a) * -4.0))); end tmp_1 = tmp_3; elseif (b <= 2.3e-22) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(-sqrt(Float64(Float64(a * c) * -4.0))) / Float64(2.0 * a)); else tmp_4 = Float64(Float64(Float64(b / a) * -0.5) - sqrt(Float64(Float64(-c) / a))); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = t_0; else tmp_1 = Float64(Float64(2.0 * c) / Float64(Float64(-b) + Float64(-b))); end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = (-b / a) + (c / b); tmp_2 = 0.0; if (b <= -3.95e-63) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -sqrt(-(c / a)); else tmp_3 = -(c / b); end tmp_2 = tmp_3; elseif (b <= -1e-310) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = t_0; else tmp_4 = (2.0 * c) / sqrt(((c * a) * -4.0)); end tmp_2 = tmp_4; elseif (b <= 2.3e-22) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = -sqrt(((a * c) * -4.0)) / (2.0 * a); else tmp_5 = ((b / a) * -0.5) - sqrt((-c / a)); end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = t_0; else tmp_2 = (2.0 * c) / (-b + -b); end tmp_6 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[((-b) / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -3.95e-63], If[GreaterEqual[b, 0.0], (-N[Sqrt[(-N[(c / a), $MachinePrecision])], $MachinePrecision]), (-N[(c / b), $MachinePrecision])], If[LessEqual[b, -1e-310], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(2.0 * c), $MachinePrecision] / N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 2.3e-22], If[GreaterEqual[b, 0.0], N[((-N[Sqrt[N[(N[(a * c), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]) / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b / a), $MachinePrecision] * -0.5), $MachinePrecision] - N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], t$95$0, N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + (-b)), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-b}{a} + \frac{c}{b}\\
\mathbf{if}\;b \leq -3.95 \cdot 10^{-63}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\sqrt{-\frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}\\
\mathbf{elif}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\sqrt{\left(c \cdot a\right) \cdot -4}}\\
\end{array}\\
\mathbf{elif}\;b \leq 2.3 \cdot 10^{-22}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-\sqrt{\left(a \cdot c\right) \cdot -4}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{a} \cdot -0.5 - \sqrt{\frac{-c}{a}}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \left(-b\right)}\\
\end{array}
\end{array}
if b < -3.9500000000000002e-63Initial program 68.6%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6487.6
Applied rewrites87.6%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6487.6
Applied rewrites87.6%
Taylor expanded in c around -inf
mul-1-negN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6487.6
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6487.6
Applied rewrites87.6%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6487.6
Applied rewrites87.6%
if -3.9500000000000002e-63 < b < -9.999999999999969e-311Initial program 83.1%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6421.9
Applied rewrites21.9%
Taylor expanded in c around 0
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f64N/A
lift-/.f6421.9
Applied rewrites21.9%
Taylor expanded in a around inf
sqrt-prodN/A
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f6467.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.2
Applied rewrites67.2%
if -9.999999999999969e-311 < b < 2.2999999999999998e-22Initial program 81.9%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6481.9
Applied rewrites81.9%
Taylor expanded in a around inf
mul-1-negN/A
lower-neg.f64N/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f6459.1
Applied rewrites59.1%
Taylor expanded in c around -inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
mul-1-negN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6459.1
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6459.1
Applied rewrites59.1%
Taylor expanded in a around inf
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f64N/A
sqrt-prodN/A
*-commutativeN/A
mul-1-negN/A
lower-sqrt.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6459.1
Applied rewrites59.1%
if 2.2999999999999998e-22 < b Initial program 66.2%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6466.2
Applied rewrites66.2%
Taylor expanded in c around 0
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f64N/A
lift-/.f6489.3
Applied rewrites89.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (if (>= b 0.0) (- (sqrt (- (/ c a)))) (- (/ c b)))))
(if (<= b -3.95e-63)
t_0
(if (<= b -1e-310)
(if (>= b 0.0)
(+ (/ (- b) a) (/ c b))
(/ (* 2.0 c) (sqrt (* (* c a) -4.0))))
(if (<= b 7e-129)
t_0
(if (>= b 0.0)
(/ (- (- b) b) (* 2.0 a))
(/ (* 2.0 c) (* -2.0 b))))))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -sqrt(-(c / a));
} else {
tmp = -(c / b);
}
double t_0 = tmp;
double tmp_1;
if (b <= -3.95e-63) {
tmp_1 = t_0;
} else if (b <= -1e-310) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-b / a) + (c / b);
} else {
tmp_2 = (2.0 * c) / sqrt(((c * a) * -4.0));
}
tmp_1 = tmp_2;
} else if (b <= 7e-129) {
tmp_1 = t_0;
} else if (b >= 0.0) {
tmp_1 = (-b - b) / (2.0 * a);
} else {
tmp_1 = (2.0 * c) / (-2.0 * b);
}
return tmp_1;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if (b >= 0.0d0) then
tmp = -sqrt(-(c / a))
else
tmp = -(c / b)
end if
t_0 = tmp
if (b <= (-3.95d-63)) then
tmp_1 = t_0
else if (b <= (-1d-310)) then
if (b >= 0.0d0) then
tmp_2 = (-b / a) + (c / b)
else
tmp_2 = (2.0d0 * c) / sqrt(((c * a) * (-4.0d0)))
end if
tmp_1 = tmp_2
else if (b <= 7d-129) then
tmp_1 = t_0
else if (b >= 0.0d0) then
tmp_1 = (-b - b) / (2.0d0 * a)
else
tmp_1 = (2.0d0 * c) / ((-2.0d0) * b)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -Math.sqrt(-(c / a));
} else {
tmp = -(c / b);
}
double t_0 = tmp;
double tmp_1;
if (b <= -3.95e-63) {
tmp_1 = t_0;
} else if (b <= -1e-310) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (-b / a) + (c / b);
} else {
tmp_2 = (2.0 * c) / Math.sqrt(((c * a) * -4.0));
}
tmp_1 = tmp_2;
} else if (b <= 7e-129) {
tmp_1 = t_0;
} else if (b >= 0.0) {
tmp_1 = (-b - b) / (2.0 * a);
} else {
tmp_1 = (2.0 * c) / (-2.0 * b);
}
return tmp_1;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = -math.sqrt(-(c / a)) else: tmp = -(c / b) t_0 = tmp tmp_1 = 0 if b <= -3.95e-63: tmp_1 = t_0 elif b <= -1e-310: tmp_2 = 0 if b >= 0.0: tmp_2 = (-b / a) + (c / b) else: tmp_2 = (2.0 * c) / math.sqrt(((c * a) * -4.0)) tmp_1 = tmp_2 elif b <= 7e-129: tmp_1 = t_0 elif b >= 0.0: tmp_1 = (-b - b) / (2.0 * a) else: tmp_1 = (2.0 * c) / (-2.0 * b) return tmp_1
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(-sqrt(Float64(-Float64(c / a)))); else tmp = Float64(-Float64(c / b)); end t_0 = tmp tmp_1 = 0.0 if (b <= -3.95e-63) tmp_1 = t_0; elseif (b <= -1e-310) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(Float64(-b) / a) + Float64(c / b)); else tmp_2 = Float64(Float64(2.0 * c) / sqrt(Float64(Float64(c * a) * -4.0))); end tmp_1 = tmp_2; elseif (b <= 7e-129) tmp_1 = t_0; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) - b) / Float64(2.0 * a)); else tmp_1 = Float64(Float64(2.0 * c) / Float64(-2.0 * b)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = -sqrt(-(c / a)); else tmp = -(c / b); end t_0 = tmp; tmp_2 = 0.0; if (b <= -3.95e-63) tmp_2 = t_0; elseif (b <= -1e-310) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (-b / a) + (c / b); else tmp_3 = (2.0 * c) / sqrt(((c * a) * -4.0)); end tmp_2 = tmp_3; elseif (b <= 7e-129) tmp_2 = t_0; elseif (b >= 0.0) tmp_2 = (-b - b) / (2.0 * a); else tmp_2 = (2.0 * c) / (-2.0 * b); end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = If[GreaterEqual[b, 0.0], (-N[Sqrt[(-N[(c / a), $MachinePrecision])], $MachinePrecision]), (-N[(c / b), $MachinePrecision])]}, If[LessEqual[b, -3.95e-63], t$95$0, If[LessEqual[b, -1e-310], If[GreaterEqual[b, 0.0], N[(N[((-b) / a), $MachinePrecision] + N[(c / b), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 7e-129], t$95$0, If[GreaterEqual[b, 0.0], N[(N[((-b) - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(-2.0 * b), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\sqrt{-\frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}\\
\mathbf{if}\;b \leq -3.95 \cdot 10^{-63}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-b}{a} + \frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\sqrt{\left(c \cdot a\right) \cdot -4}}\\
\end{array}\\
\mathbf{elif}\;b \leq 7 \cdot 10^{-129}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{-2 \cdot b}\\
\end{array}
\end{array}
if b < -3.9500000000000002e-63 or -9.999999999999969e-311 < b < 6.9999999999999995e-129Initial program 70.3%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6485.3
Applied rewrites85.3%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6475.9
Applied rewrites75.9%
Taylor expanded in c around -inf
mul-1-negN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6476.0
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6476.0
Applied rewrites76.0%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6476.0
Applied rewrites76.0%
if -3.9500000000000002e-63 < b < -9.999999999999969e-311Initial program 83.1%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6421.9
Applied rewrites21.9%
Taylor expanded in c around 0
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lift-neg.f64N/A
lower-/.f64N/A
lift-/.f6421.9
Applied rewrites21.9%
Taylor expanded in a around inf
sqrt-prodN/A
lift-*.f64N/A
lift-*.f64N/A
lift-sqrt.f6467.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.2
Applied rewrites67.2%
if 6.9999999999999995e-129 < b Initial program 70.4%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6470.4
Applied rewrites70.4%
Taylor expanded in a around 0
Applied rewrites81.3%
Taylor expanded in b around -inf
lower-*.f6481.3
Applied rewrites81.3%
(FPCore (a b c) :precision binary64 (if (<= b 7e-129) (if (>= b 0.0) (- (sqrt (- (/ c a)))) (- (/ c b))) (if (>= b 0.0) (/ (- (- b) b) (* 2.0 a)) (/ (* 2.0 c) (* -2.0 b)))))
double code(double a, double b, double c) {
double tmp_1;
if (b <= 7e-129) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -sqrt(-(c / a));
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (-b - b) / (2.0 * a);
} else {
tmp_1 = (2.0 * c) / (-2.0 * b);
}
return tmp_1;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
if (b <= 7d-129) then
if (b >= 0.0d0) then
tmp_2 = -sqrt(-(c / a))
else
tmp_2 = -(c / b)
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (-b - b) / (2.0d0 * a)
else
tmp_1 = (2.0d0 * c) / ((-2.0d0) * b)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= 7e-129) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = -Math.sqrt(-(c / a));
} else {
tmp_2 = -(c / b);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (-b - b) / (2.0 * a);
} else {
tmp_1 = (2.0 * c) / (-2.0 * b);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= 7e-129: tmp_2 = 0 if b >= 0.0: tmp_2 = -math.sqrt(-(c / a)) else: tmp_2 = -(c / b) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (-b - b) / (2.0 * a) else: tmp_1 = (2.0 * c) / (-2.0 * b) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= 7e-129) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(-sqrt(Float64(-Float64(c / a)))); else tmp_2 = Float64(-Float64(c / b)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(Float64(-b) - b) / Float64(2.0 * a)); else tmp_1 = Float64(Float64(2.0 * c) / Float64(-2.0 * b)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= 7e-129) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = -sqrt(-(c / a)); else tmp_3 = -(c / b); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (-b - b) / (2.0 * a); else tmp_2 = (2.0 * c) / (-2.0 * b); end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, 7e-129], If[GreaterEqual[b, 0.0], (-N[Sqrt[(-N[(c / a), $MachinePrecision])], $MachinePrecision]), (-N[(c / b), $MachinePrecision])], If[GreaterEqual[b, 0.0], N[(N[((-b) - b), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[(-2.0 * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 7 \cdot 10^{-129}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\sqrt{-\frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - b}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{-2 \cdot b}\\
\end{array}
\end{array}
if b < 6.9999999999999995e-129Initial program 73.4%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6469.8
Applied rewrites69.8%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6462.7
Applied rewrites62.7%
Taylor expanded in c around -inf
mul-1-negN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6462.8
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6462.8
Applied rewrites62.8%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6462.8
Applied rewrites62.8%
if 6.9999999999999995e-129 < b Initial program 70.4%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6470.4
Applied rewrites70.4%
Taylor expanded in a around 0
Applied rewrites81.3%
Taylor expanded in b around -inf
lower-*.f6481.3
Applied rewrites81.3%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c)))) (t_1 (- (/ c b))))
(if (<=
(if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) t_0)))
-1e-140)
(if (>= b 0.0) (- (sqrt (- (/ c a)))) t_1)
(if (>= b 0.0) (sqrt (* (/ c a) -1.0)) t_1))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
double t_1 = -(c / b);
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
double tmp_2;
if (tmp <= -1e-140) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -sqrt(-(c / a));
} else {
tmp_3 = t_1;
}
tmp_2 = tmp_3;
} else if (b >= 0.0) {
tmp_2 = sqrt(((c / a) * -1.0));
} else {
tmp_2 = t_1;
}
return tmp_2;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
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
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
t_1 = -(c / b)
if (b >= 0.0d0) then
tmp = (-b - t_0) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + t_0)
end if
if (tmp <= (-1d-140)) then
if (b >= 0.0d0) then
tmp_3 = -sqrt(-(c / a))
else
tmp_3 = t_1
end if
tmp_2 = tmp_3
else if (b >= 0.0d0) then
tmp_2 = sqrt(((c / a) * (-1.0d0)))
else
tmp_2 = t_1
end if
code = tmp_2
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double t_1 = -(c / b);
double tmp;
if (b >= 0.0) {
tmp = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
double tmp_2;
if (tmp <= -1e-140) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -Math.sqrt(-(c / a));
} else {
tmp_3 = t_1;
}
tmp_2 = tmp_3;
} else if (b >= 0.0) {
tmp_2 = Math.sqrt(((c / a) * -1.0));
} else {
tmp_2 = t_1;
}
return tmp_2;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) t_1 = -(c / b) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (2.0 * a) else: tmp = (2.0 * c) / (-b + t_0) tmp_2 = 0 if tmp <= -1e-140: tmp_3 = 0 if b >= 0.0: tmp_3 = -math.sqrt(-(c / a)) else: tmp_3 = t_1 tmp_2 = tmp_3 elif b >= 0.0: tmp_2 = math.sqrt(((c / a) * -1.0)) else: tmp_2 = t_1 return tmp_2
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) t_1 = Float64(-Float64(c / b)) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + t_0)); end tmp_2 = 0.0 if (tmp <= -1e-140) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(-sqrt(Float64(-Float64(c / a)))); else tmp_3 = t_1; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = sqrt(Float64(Float64(c / a) * -1.0)); else tmp_2 = t_1; end return tmp_2 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); t_1 = -(c / b); tmp = 0.0; if (b >= 0.0) tmp = (-b - t_0) / (2.0 * a); else tmp = (2.0 * c) / (-b + t_0); end tmp_3 = 0.0; if (tmp <= -1e-140) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = -sqrt(-(c / a)); else tmp_4 = t_1; end tmp_3 = tmp_4; elseif (b >= 0.0) tmp_3 = sqrt(((c / a) * -1.0)); else tmp_3 = t_1; end tmp_5 = tmp_3; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = (-N[(c / b), $MachinePrecision])}, If[LessEqual[If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $MachinePrecision]), $MachinePrecision]], -1e-140], If[GreaterEqual[b, 0.0], (-N[Sqrt[(-N[(c / a), $MachinePrecision])], $MachinePrecision]), t$95$1], If[GreaterEqual[b, 0.0], N[Sqrt[N[(N[(c / a), $MachinePrecision] * -1.0), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
t_1 := -\frac{c}{b}\\
\mathbf{if}\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t\_0}\\
\end{array} \leq -1 \cdot 10^{-140}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\sqrt{-\frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\sqrt{\frac{c}{a} \cdot -1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) < -9.9999999999999998e-141Initial program 78.2%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6463.4
Applied rewrites63.4%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6415.9
Applied rewrites15.9%
Taylor expanded in c around -inf
mul-1-negN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6435.8
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6435.8
Applied rewrites35.8%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6435.8
Applied rewrites35.8%
if -9.9999999999999998e-141 < (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) Initial program 69.3%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6473.3
Applied rewrites73.3%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6454.8
Applied rewrites54.8%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6454.8
Applied rewrites54.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c)))))
(if (<=
(if (>= b 0.0) (/ (- (- b) t_0) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) t_0)))
5e-36)
(if (>= b 0.0) (- (sqrt (- (/ c a)))) (- (/ c b)))
(if (>= b 0.0) (sqrt (* (/ c a) -1.0)) (sqrt (/ (- c) 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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
double tmp_2;
if (tmp <= 5e-36) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -sqrt(-(c / a));
} else {
tmp_3 = -(c / b);
}
tmp_2 = tmp_3;
} else if (b >= 0.0) {
tmp_2 = sqrt(((c / a) * -1.0));
} else {
tmp_2 = sqrt((-c / a));
}
return tmp_2;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: t_0
real(8) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (-b - t_0) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + t_0)
end if
if (tmp <= 5d-36) then
if (b >= 0.0d0) then
tmp_3 = -sqrt(-(c / a))
else
tmp_3 = -(c / b)
end if
tmp_2 = tmp_3
else if (b >= 0.0d0) then
tmp_2 = sqrt(((c / a) * (-1.0d0)))
else
tmp_2 = sqrt((-c / a))
end if
code = tmp_2
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 = (-b - t_0) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_0);
}
double tmp_2;
if (tmp <= 5e-36) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = -Math.sqrt(-(c / a));
} else {
tmp_3 = -(c / b);
}
tmp_2 = tmp_3;
} else if (b >= 0.0) {
tmp_2 = Math.sqrt(((c / a) * -1.0));
} else {
tmp_2 = Math.sqrt((-c / a));
}
return tmp_2;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (-b - t_0) / (2.0 * a) else: tmp = (2.0 * c) / (-b + t_0) tmp_2 = 0 if tmp <= 5e-36: tmp_3 = 0 if b >= 0.0: tmp_3 = -math.sqrt(-(c / a)) else: tmp_3 = -(c / b) tmp_2 = tmp_3 elif b >= 0.0: tmp_2 = math.sqrt(((c / a) * -1.0)) else: tmp_2 = math.sqrt((-c / a)) return tmp_2
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + t_0)); end tmp_2 = 0.0 if (tmp <= 5e-36) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(-sqrt(Float64(-Float64(c / a)))); else tmp_3 = Float64(-Float64(c / b)); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = sqrt(Float64(Float64(c / a) * -1.0)); else tmp_2 = sqrt(Float64(Float64(-c) / a)); end return tmp_2 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b >= 0.0) tmp = (-b - t_0) / (2.0 * a); else tmp = (2.0 * c) / (-b + t_0); end tmp_3 = 0.0; if (tmp <= 5e-36) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = -sqrt(-(c / a)); else tmp_4 = -(c / b); end tmp_3 = tmp_4; elseif (b >= 0.0) tmp_3 = sqrt(((c / a) * -1.0)); else tmp_3 = sqrt((-c / a)); end tmp_5 = tmp_3; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$0), $MachinePrecision]), $MachinePrecision]], 5e-36], If[GreaterEqual[b, 0.0], (-N[Sqrt[(-N[(c / a), $MachinePrecision])], $MachinePrecision]), (-N[(c / b), $MachinePrecision])], If[GreaterEqual[b, 0.0], N[Sqrt[N[(N[(c / a), $MachinePrecision] * -1.0), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t\_0}\\
\end{array} \leq 5 \cdot 10^{-36}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\sqrt{-\frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\sqrt{\frac{c}{a} \cdot -1}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{-c}{a}}\\
\end{array}
\end{array}
if (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) < 5.00000000000000004e-36Initial program 72.8%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6473.4
Applied rewrites73.4%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6446.2
Applied rewrites46.2%
Taylor expanded in c around -inf
mul-1-negN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6453.6
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6453.6
Applied rewrites53.6%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6453.6
Applied rewrites53.6%
if 5.00000000000000004e-36 < (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) Initial program 70.8%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6461.3
Applied rewrites61.3%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6431.2
Applied rewrites31.2%
Taylor expanded in a around -inf
mul-1-negN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6418.8
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6418.8
Applied rewrites18.8%
Taylor expanded in c around -inf
sqrt-prodN/A
*-commutativeN/A
mul-1-negN/A
lower-sqrt.f64N/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6429.2
Applied rewrites29.2%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (- (sqrt (- (/ c a))))) (t_1 (sqrt (- (* b b) (* (* 4.0 a) c)))))
(if (<=
(if (>= b 0.0) (/ (- (- b) t_1) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) t_1)))
5e+18)
(if (>= b 0.0) t_0 (- (/ c b)))
(if (>= b 0.0) (sqrt (/ (- c) a)) t_0))))
double code(double a, double b, double c) {
double t_0 = -sqrt(-(c / a));
double t_1 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_1) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_1);
}
double tmp_2;
if (tmp <= 5e+18) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_0;
} else {
tmp_3 = -(c / b);
}
tmp_2 = tmp_3;
} else if (b >= 0.0) {
tmp_2 = sqrt((-c / a));
} else {
tmp_2 = t_0;
}
return tmp_2;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
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
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = -sqrt(-(c / a))
t_1 = sqrt(((b * b) - ((4.0d0 * a) * c)))
if (b >= 0.0d0) then
tmp = (-b - t_1) / (2.0d0 * a)
else
tmp = (2.0d0 * c) / (-b + t_1)
end if
if (tmp <= 5d+18) then
if (b >= 0.0d0) then
tmp_3 = t_0
else
tmp_3 = -(c / b)
end if
tmp_2 = tmp_3
else if (b >= 0.0d0) then
tmp_2 = sqrt((-c / a))
else
tmp_2 = t_0
end if
code = tmp_2
end function
public static double code(double a, double b, double c) {
double t_0 = -Math.sqrt(-(c / a));
double t_1 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (-b - t_1) / (2.0 * a);
} else {
tmp = (2.0 * c) / (-b + t_1);
}
double tmp_2;
if (tmp <= 5e+18) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = t_0;
} else {
tmp_3 = -(c / b);
}
tmp_2 = tmp_3;
} else if (b >= 0.0) {
tmp_2 = Math.sqrt((-c / a));
} else {
tmp_2 = t_0;
}
return tmp_2;
}
def code(a, b, c): t_0 = -math.sqrt(-(c / a)) t_1 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (-b - t_1) / (2.0 * a) else: tmp = (2.0 * c) / (-b + t_1) tmp_2 = 0 if tmp <= 5e+18: tmp_3 = 0 if b >= 0.0: tmp_3 = t_0 else: tmp_3 = -(c / b) tmp_2 = tmp_3 elif b >= 0.0: tmp_2 = math.sqrt((-c / a)) else: tmp_2 = t_0 return tmp_2
function code(a, b, c) t_0 = Float64(-sqrt(Float64(-Float64(c / a)))) t_1 = sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(Float64(-b) - t_1) / Float64(2.0 * a)); else tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) + t_1)); end tmp_2 = 0.0 if (tmp <= 5e+18) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = t_0; else tmp_3 = Float64(-Float64(c / b)); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = sqrt(Float64(Float64(-c) / a)); else tmp_2 = t_0; end return tmp_2 end
function tmp_5 = code(a, b, c) t_0 = -sqrt(-(c / a)); t_1 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b >= 0.0) tmp = (-b - t_1) / (2.0 * a); else tmp = (2.0 * c) / (-b + t_1); end tmp_3 = 0.0; if (tmp <= 5e+18) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = t_0; else tmp_4 = -(c / b); end tmp_3 = tmp_4; elseif (b >= 0.0) tmp_3 = sqrt((-c / a)); else tmp_3 = t_0; end tmp_5 = tmp_3; end
code[a_, b_, c_] := Block[{t$95$0 = (-N[Sqrt[(-N[(c / a), $MachinePrecision])], $MachinePrecision])}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[If[GreaterEqual[b, 0.0], N[(N[((-b) - t$95$1), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) + t$95$1), $MachinePrecision]), $MachinePrecision]], 5e+18], If[GreaterEqual[b, 0.0], t$95$0, (-N[(c / b), $MachinePrecision])], If[GreaterEqual[b, 0.0], N[Sqrt[N[((-c) / a), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\sqrt{-\frac{c}{a}}\\
t_1 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{\left(-b\right) - t\_1}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) + t\_1}\\
\end{array} \leq 5 \cdot 10^{+18}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\sqrt{\frac{-c}{a}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) < 5e18Initial program 73.6%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6473.5
Applied rewrites73.5%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6446.5
Applied rewrites46.5%
Taylor expanded in c around -inf
mul-1-negN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6452.7
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6452.7
Applied rewrites52.7%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6452.7
Applied rewrites52.7%
if 5e18 < (if (>=.f64 b #s(literal 0 binary64)) (/.f64 (-.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))) (*.f64 #s(literal 2 binary64) a)) (/.f64 (*.f64 #s(literal 2 binary64) c) (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 4 binary64) a) c)))))) Initial program 68.2%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6459.7
Applied rewrites59.7%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6428.4
Applied rewrites28.4%
Taylor expanded in a around -inf
mul-1-negN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6418.1
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6418.1
Applied rewrites18.1%
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
distribute-neg-fracN/A
lower-/.f64N/A
lower-neg.f6418.1
Applied rewrites18.1%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (- (sqrt (- (/ c a)))) (- (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = -sqrt(-(c / a));
} else {
tmp = -(c / b);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b >= 0.0d0) then
tmp = -sqrt(-(c / 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 >= 0.0) {
tmp = -Math.sqrt(-(c / a));
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = -math.sqrt(-(c / a)) else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(-sqrt(Float64(-Float64(c / a)))); else tmp = Float64(-Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = -sqrt(-(c / a)); else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], (-N[Sqrt[(-N[(c / a), $MachinePrecision])], $MachinePrecision]), (-N[(c / b), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;-\sqrt{-\frac{c}{a}}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
Initial program 72.2%
Taylor expanded in b around -inf
mul-1-negN/A
lift-neg.f6470.0
Applied rewrites70.0%
Taylor expanded in a around -inf
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6442.0
Applied rewrites42.0%
Taylor expanded in c around -inf
mul-1-negN/A
sqrt-prodN/A
lift-/.f64N/A
lift-*.f64N/A
lift-sqrt.f64N/A
lift-neg.f6442.2
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
mul-1-negN/A
lower-neg.f64N/A
lift-/.f6442.2
Applied rewrites42.2%
Taylor expanded in b around -inf
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6442.2
Applied rewrites42.2%
herbie shell --seed 2025112
(FPCore (a b c)
:name "jeff quadratic root 1"
:precision binary64
(if (>= b 0.0) (/ (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)) (/ (* 2.0 c) (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))))