
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* (* 4.0 a) c)))))
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) t_0))
(/ (+ (- b) t_0) (* 2.0 a)))))double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
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 = (2.0d0 * c) / (-b - t_0)
else
tmp = (-b + t_0) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-b - t_0) else: tmp = (-b + t_0) / (2.0 * a) 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(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-b - t_0); else tmp = (-b + t_0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\
\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)
(/ (* 2.0 c) (- (- b) t_0))
(/ (+ (- b) t_0) (* 2.0 a)))))double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
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 = (2.0d0 * c) / (-b - t_0)
else
tmp = (-b + t_0) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((4.0 * a) * c)));
double tmp;
if (b >= 0.0) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = (-b + t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((4.0 * a) * c))) tmp = 0 if b >= 0.0: tmp = (2.0 * c) / (-b - t_0) else: tmp = (-b + t_0) / (2.0 * a) 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(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp = Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - ((4.0 * a) * c))); tmp = 0.0; if (b >= 0.0) tmp = (2.0 * c) / (-b - t_0); else tmp = (-b + t_0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\\
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t\_0}{2 \cdot a}\\
\end{array}
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* (* a 4.0) c)))))
(if (<= b -1e+110)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))))
(/ (* -4.0 b) (* 2.0 (+ a a))))
(if (<= b 1.1e+105)
(if (>= b 0.0) (/ (* -2.0 c) (+ b t_0)) (/ (- t_0 b) (+ a a)))
(if (>= b 0.0)
(/ (+ c c) (- (+ b b)))
(/ (- (sqrt (* (* -4.0 a) c)) b) (+ a a)))))))double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((a * 4.0) * c)));
double tmp_1;
if (b <= -1e+110) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - sqrt(((b * b) - ((4.0 * a) * c))));
} else {
tmp_2 = (-4.0 * b) / (2.0 * (a + a));
}
tmp_1 = tmp_2;
} else if (b <= 1.1e+105) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-2.0 * c) / (b + t_0);
} else {
tmp_3 = (t_0 - b) / (a + a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
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) - ((a * 4.0d0) * c)))
if (b <= (-1d+110)) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 * c) / (-b - sqrt(((b * b) - ((4.0d0 * a) * c))))
else
tmp_2 = ((-4.0d0) * b) / (2.0d0 * (a + a))
end if
tmp_1 = tmp_2
else if (b <= 1.1d+105) then
if (b >= 0.0d0) then
tmp_3 = ((-2.0d0) * c) / (b + t_0)
else
tmp_3 = (t_0 - b) / (a + a)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (c + c) / -(b + b)
else
tmp_1 = (sqrt((((-4.0d0) * a) * c)) - b) / (a + a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((a * 4.0) * c)));
double tmp_1;
if (b <= -1e+110) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - Math.sqrt(((b * b) - ((4.0 * a) * c))));
} else {
tmp_2 = (-4.0 * b) / (2.0 * (a + a));
}
tmp_1 = tmp_2;
} else if (b <= 1.1e+105) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-2.0 * c) / (b + t_0);
} else {
tmp_3 = (t_0 - b) / (a + a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (Math.sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((a * 4.0) * c))) tmp_1 = 0 if b <= -1e+110: tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 * c) / (-b - math.sqrt(((b * b) - ((4.0 * a) * c)))) else: tmp_2 = (-4.0 * b) / (2.0 * (a + a)) tmp_1 = tmp_2 elif b <= 1.1e+105: tmp_3 = 0 if b >= 0.0: tmp_3 = (-2.0 * c) / (b + t_0) else: tmp_3 = (t_0 - b) / (a + a) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (c + c) / -(b + b) else: tmp_1 = (math.sqrt(((-4.0 * a) * c)) - b) / (a + a) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) tmp_1 = 0.0 if (b <= -1e+110) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c))))); else tmp_2 = Float64(Float64(-4.0 * b) / Float64(2.0 * Float64(a + a))); end tmp_1 = tmp_2; elseif (b <= 1.1e+105) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(-2.0 * c) / Float64(b + t_0)); else tmp_3 = Float64(Float64(t_0 - b) / Float64(a + a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(c + c) / Float64(-Float64(b + b))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(-4.0 * a) * c)) - b) / Float64(a + a)); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - ((a * 4.0) * c))); tmp_2 = 0.0; if (b <= -1e+110) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 * c) / (-b - sqrt(((b * b) - ((4.0 * a) * c)))); else tmp_3 = (-4.0 * b) / (2.0 * (a + a)); end tmp_2 = tmp_3; elseif (b <= 1.1e+105) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (-2.0 * c) / (b + t_0); else tmp_4 = (t_0 - b) / (a + a); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (c + c) / -(b + b); else tmp_2 = (sqrt(((-4.0 * a) * c)) - b) / (a + a); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -1e+110], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * b), $MachinePrecision] / N[(2.0 * N[(a + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.1e+105], If[GreaterEqual[b, 0.0], N[(N[(-2.0 * c), $MachinePrecision] / N[(b + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c + c), $MachinePrecision] / (-N[(b + b), $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}\\
\mathbf{if}\;b \leq -1 \cdot 10^{+110}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-4 \cdot b}{2 \cdot \left(a + a\right)}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{+105}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-2 \cdot c}{b + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a + a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{-\left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c} - b}{a + a}\\
\end{array}
if b < -1e110Initial program 72.0%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
common-denominatorN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites68.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-*.f6461.7%
Applied rewrites61.7%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lift-+.f64N/A
count-2-revN/A
*-commutativeN/A
associate-/r*N/A
lift-/.f64N/A
frac-2negN/A
frac-2negN/A
lift-+.f64N/A
add-flipN/A
sub-negateN/A
sub-negate-revN/A
add-flipN/A
lift-+.f64N/A
Applied rewrites61.7%
Taylor expanded in b around -inf
lower-*.f6469.5%
Applied rewrites69.5%
if -1e110 < b < 1.1e105Initial program 72.0%
Applied rewrites72.0%
if 1.1e105 < b Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
Taylor expanded in b around inf
lower-*.f6454.6%
Applied rewrites54.6%
lift-*.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
count-2-revN/A
lift-+.f64N/A
lower-neg.f6454.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6454.7%
Applied rewrites54.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (/ -4.0 (* a c))))
(t_1 (sqrt (- (* b b) (* (* a 4.0) c)))))
(if (<= b -8.5e+154)
(if (>= b 0.0)
(* (/ c (+ (sqrt (- (* b b) (* (* c 4.0) a))) b)) -2.0)
(/ (* (* a b) -4.0) (* (* 4.0 a) a)))
(if (<= b -9.8e-234)
(if (>= b 0.0) (/ 2.0 (* a t_0)) (/ (- t_1 b) (+ a a)))
(if (<= b 1.1e+105)
(if (>= b 0.0)
(/ (* -2.0 c) (+ b t_1))
(* 0.5 (* -1.0 (* c t_0))))
(if (>= b 0.0)
(/ (+ c c) (- (+ b b)))
(/ (- (sqrt (* (* -4.0 a) c)) b) (+ a a))))))))double code(double a, double b, double c) {
double t_0 = sqrt((-4.0 / (a * c)));
double t_1 = sqrt(((b * b) - ((a * 4.0) * c)));
double tmp_1;
if (b <= -8.5e+154) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (c / (sqrt(((b * b) - ((c * 4.0) * a))) + b)) * -2.0;
} else {
tmp_2 = ((a * b) * -4.0) / ((4.0 * a) * a);
}
tmp_1 = tmp_2;
} else if (b <= -9.8e-234) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = 2.0 / (a * t_0);
} else {
tmp_3 = (t_1 - b) / (a + a);
}
tmp_1 = tmp_3;
} else if (b <= 1.1e+105) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-2.0 * c) / (b + t_1);
} else {
tmp_4 = 0.5 * (-1.0 * (c * t_0));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
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) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
real(8) :: tmp_4
t_0 = sqrt(((-4.0d0) / (a * c)))
t_1 = sqrt(((b * b) - ((a * 4.0d0) * c)))
if (b <= (-8.5d+154)) then
if (b >= 0.0d0) then
tmp_2 = (c / (sqrt(((b * b) - ((c * 4.0d0) * a))) + b)) * (-2.0d0)
else
tmp_2 = ((a * b) * (-4.0d0)) / ((4.0d0 * a) * a)
end if
tmp_1 = tmp_2
else if (b <= (-9.8d-234)) then
if (b >= 0.0d0) then
tmp_3 = 2.0d0 / (a * t_0)
else
tmp_3 = (t_1 - b) / (a + a)
end if
tmp_1 = tmp_3
else if (b <= 1.1d+105) then
if (b >= 0.0d0) then
tmp_4 = ((-2.0d0) * c) / (b + t_1)
else
tmp_4 = 0.5d0 * ((-1.0d0) * (c * t_0))
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = (c + c) / -(b + b)
else
tmp_1 = (sqrt((((-4.0d0) * a) * c)) - b) / (a + a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt((-4.0 / (a * c)));
double t_1 = Math.sqrt(((b * b) - ((a * 4.0) * c)));
double tmp_1;
if (b <= -8.5e+154) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (c / (Math.sqrt(((b * b) - ((c * 4.0) * a))) + b)) * -2.0;
} else {
tmp_2 = ((a * b) * -4.0) / ((4.0 * a) * a);
}
tmp_1 = tmp_2;
} else if (b <= -9.8e-234) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = 2.0 / (a * t_0);
} else {
tmp_3 = (t_1 - b) / (a + a);
}
tmp_1 = tmp_3;
} else if (b <= 1.1e+105) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-2.0 * c) / (b + t_1);
} else {
tmp_4 = 0.5 * (-1.0 * (c * t_0));
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (Math.sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt((-4.0 / (a * c))) t_1 = math.sqrt(((b * b) - ((a * 4.0) * c))) tmp_1 = 0 if b <= -8.5e+154: tmp_2 = 0 if b >= 0.0: tmp_2 = (c / (math.sqrt(((b * b) - ((c * 4.0) * a))) + b)) * -2.0 else: tmp_2 = ((a * b) * -4.0) / ((4.0 * a) * a) tmp_1 = tmp_2 elif b <= -9.8e-234: tmp_3 = 0 if b >= 0.0: tmp_3 = 2.0 / (a * t_0) else: tmp_3 = (t_1 - b) / (a + a) tmp_1 = tmp_3 elif b <= 1.1e+105: tmp_4 = 0 if b >= 0.0: tmp_4 = (-2.0 * c) / (b + t_1) else: tmp_4 = 0.5 * (-1.0 * (c * t_0)) tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = (c + c) / -(b + b) else: tmp_1 = (math.sqrt(((-4.0 * a) * c)) - b) / (a + a) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(-4.0 / Float64(a * c))) t_1 = sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) tmp_1 = 0.0 if (b <= -8.5e+154) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(c / Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(c * 4.0) * a))) + b)) * -2.0); else tmp_2 = Float64(Float64(Float64(a * b) * -4.0) / Float64(Float64(4.0 * a) * a)); end tmp_1 = tmp_2; elseif (b <= -9.8e-234) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(2.0 / Float64(a * t_0)); else tmp_3 = Float64(Float64(t_1 - b) / Float64(a + a)); end tmp_1 = tmp_3; elseif (b <= 1.1e+105) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(-2.0 * c) / Float64(b + t_1)); else tmp_4 = Float64(0.5 * Float64(-1.0 * Float64(c * t_0))); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c + c) / Float64(-Float64(b + b))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(-4.0 * a) * c)) - b) / Float64(a + a)); end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = sqrt((-4.0 / (a * c))); t_1 = sqrt(((b * b) - ((a * 4.0) * c))); tmp_2 = 0.0; if (b <= -8.5e+154) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (c / (sqrt(((b * b) - ((c * 4.0) * a))) + b)) * -2.0; else tmp_3 = ((a * b) * -4.0) / ((4.0 * a) * a); end tmp_2 = tmp_3; elseif (b <= -9.8e-234) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = 2.0 / (a * t_0); else tmp_4 = (t_1 - b) / (a + a); end tmp_2 = tmp_4; elseif (b <= 1.1e+105) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = (-2.0 * c) / (b + t_1); else tmp_5 = 0.5 * (-1.0 * (c * t_0)); end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = (c + c) / -(b + b); else tmp_2 = (sqrt(((-4.0 * a) * c)) - b) / (a + a); end tmp_6 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(-4.0 / N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -8.5e+154], If[GreaterEqual[b, 0.0], N[(N[(c / N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(c * 4.0), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision], N[(N[(N[(a * b), $MachinePrecision] * -4.0), $MachinePrecision] / N[(N[(4.0 * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -9.8e-234], If[GreaterEqual[b, 0.0], N[(2.0 / N[(a * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.1e+105], If[GreaterEqual[b, 0.0], N[(N[(-2.0 * c), $MachinePrecision] / N[(b + t$95$1), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(-1.0 * N[(c * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c + c), $MachinePrecision] / (-N[(b + b), $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \sqrt{\frac{-4}{a \cdot c}}\\
t_1 := \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}\\
\mathbf{if}\;b \leq -8.5 \cdot 10^{+154}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a} + b} \cdot -2\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(a \cdot b\right) \cdot -4}{\left(4 \cdot a\right) \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq -9.8 \cdot 10^{-234}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{a \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1 - b}{a + a}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{+105}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-2 \cdot c}{b + t\_1}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(-1 \cdot \left(c \cdot t\_0\right)\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{-\left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c} - b}{a + a}\\
\end{array}
if b < -8.5000000000000002e154Initial program 72.0%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
common-denominatorN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites68.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-*.f6461.7%
Applied rewrites61.7%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lift-+.f64N/A
count-2-revN/A
*-commutativeN/A
associate-/r*N/A
lift-/.f64N/A
frac-2negN/A
frac-2negN/A
lift-+.f64N/A
add-flipN/A
sub-negateN/A
sub-negate-revN/A
add-flipN/A
lift-+.f64N/A
Applied rewrites61.7%
Applied rewrites57.8%
if -8.5000000000000002e154 < b < -9.8000000000000001e-234Initial program 72.0%
Applied rewrites72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6443.2%
Applied rewrites43.2%
Taylor expanded in c around -inf
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6450.6%
Applied rewrites50.6%
if -9.8000000000000001e-234 < b < 1.1e105Initial program 72.0%
Applied rewrites72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6443.6%
Applied rewrites43.6%
Taylor expanded in c around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6450.7%
Applied rewrites50.7%
if 1.1e105 < b Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
Taylor expanded in b around inf
lower-*.f6454.6%
Applied rewrites54.6%
lift-*.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
count-2-revN/A
lift-+.f64N/A
lower-neg.f6454.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6454.7%
Applied rewrites54.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* (* a 4.0) c)))))
(if (<= b -8.5e+154)
(if (>= b 0.0)
(* (/ c (+ (sqrt (- (* b b) (* (* c 4.0) a))) b)) -2.0)
(/ (* (* a b) -4.0) (* (* 4.0 a) a)))
(if (<= b -2.8e-270)
(if (>= b 0.0)
(/ 2.0 (* a (sqrt (/ -4.0 (* a c)))))
(/ (- t_0 b) (+ a a)))
(if (<= b 1.1e+105)
(if (>= b 0.0)
(/ (* -2.0 c) (+ b t_0))
(* -0.5 (/ (* c (sqrt (* -4.0 (/ a c)))) a)))
(if (>= b 0.0)
(/ (+ c c) (- (+ b b)))
(/ (- (sqrt (* (* -4.0 a) c)) b) (+ a a))))))))double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((a * 4.0) * c)));
double tmp_1;
if (b <= -8.5e+154) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (c / (sqrt(((b * b) - ((c * 4.0) * a))) + b)) * -2.0;
} else {
tmp_2 = ((a * b) * -4.0) / ((4.0 * a) * a);
}
tmp_1 = tmp_2;
} else if (b <= -2.8e-270) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = 2.0 / (a * sqrt((-4.0 / (a * c))));
} else {
tmp_3 = (t_0 - b) / (a + a);
}
tmp_1 = tmp_3;
} else if (b <= 1.1e+105) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-2.0 * c) / (b + t_0);
} else {
tmp_4 = -0.5 * ((c * sqrt((-4.0 * (a / c)))) / a);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
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 = sqrt(((b * b) - ((a * 4.0d0) * c)))
if (b <= (-8.5d+154)) then
if (b >= 0.0d0) then
tmp_2 = (c / (sqrt(((b * b) - ((c * 4.0d0) * a))) + b)) * (-2.0d0)
else
tmp_2 = ((a * b) * (-4.0d0)) / ((4.0d0 * a) * a)
end if
tmp_1 = tmp_2
else if (b <= (-2.8d-270)) then
if (b >= 0.0d0) then
tmp_3 = 2.0d0 / (a * sqrt(((-4.0d0) / (a * c))))
else
tmp_3 = (t_0 - b) / (a + a)
end if
tmp_1 = tmp_3
else if (b <= 1.1d+105) then
if (b >= 0.0d0) then
tmp_4 = ((-2.0d0) * c) / (b + t_0)
else
tmp_4 = (-0.5d0) * ((c * sqrt(((-4.0d0) * (a / c)))) / a)
end if
tmp_1 = tmp_4
else if (b >= 0.0d0) then
tmp_1 = (c + c) / -(b + b)
else
tmp_1 = (sqrt((((-4.0d0) * a) * c)) - b) / (a + a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((a * 4.0) * c)));
double tmp_1;
if (b <= -8.5e+154) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (c / (Math.sqrt(((b * b) - ((c * 4.0) * a))) + b)) * -2.0;
} else {
tmp_2 = ((a * b) * -4.0) / ((4.0 * a) * a);
}
tmp_1 = tmp_2;
} else if (b <= -2.8e-270) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = 2.0 / (a * Math.sqrt((-4.0 / (a * c))));
} else {
tmp_3 = (t_0 - b) / (a + a);
}
tmp_1 = tmp_3;
} else if (b <= 1.1e+105) {
double tmp_4;
if (b >= 0.0) {
tmp_4 = (-2.0 * c) / (b + t_0);
} else {
tmp_4 = -0.5 * ((c * Math.sqrt((-4.0 * (a / c)))) / a);
}
tmp_1 = tmp_4;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (Math.sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((a * 4.0) * c))) tmp_1 = 0 if b <= -8.5e+154: tmp_2 = 0 if b >= 0.0: tmp_2 = (c / (math.sqrt(((b * b) - ((c * 4.0) * a))) + b)) * -2.0 else: tmp_2 = ((a * b) * -4.0) / ((4.0 * a) * a) tmp_1 = tmp_2 elif b <= -2.8e-270: tmp_3 = 0 if b >= 0.0: tmp_3 = 2.0 / (a * math.sqrt((-4.0 / (a * c)))) else: tmp_3 = (t_0 - b) / (a + a) tmp_1 = tmp_3 elif b <= 1.1e+105: tmp_4 = 0 if b >= 0.0: tmp_4 = (-2.0 * c) / (b + t_0) else: tmp_4 = -0.5 * ((c * math.sqrt((-4.0 * (a / c)))) / a) tmp_1 = tmp_4 elif b >= 0.0: tmp_1 = (c + c) / -(b + b) else: tmp_1 = (math.sqrt(((-4.0 * a) * c)) - b) / (a + a) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) tmp_1 = 0.0 if (b <= -8.5e+154) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(c / Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(c * 4.0) * a))) + b)) * -2.0); else tmp_2 = Float64(Float64(Float64(a * b) * -4.0) / Float64(Float64(4.0 * a) * a)); end tmp_1 = tmp_2; elseif (b <= -2.8e-270) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(2.0 / Float64(a * sqrt(Float64(-4.0 / Float64(a * c))))); else tmp_3 = Float64(Float64(t_0 - b) / Float64(a + a)); end tmp_1 = tmp_3; elseif (b <= 1.1e+105) tmp_4 = 0.0 if (b >= 0.0) tmp_4 = Float64(Float64(-2.0 * c) / Float64(b + t_0)); else tmp_4 = Float64(-0.5 * Float64(Float64(c * sqrt(Float64(-4.0 * Float64(a / c)))) / a)); end tmp_1 = tmp_4; elseif (b >= 0.0) tmp_1 = Float64(Float64(c + c) / Float64(-Float64(b + b))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(-4.0 * a) * c)) - b) / Float64(a + a)); end return tmp_1 end
function tmp_6 = code(a, b, c) t_0 = sqrt(((b * b) - ((a * 4.0) * c))); tmp_2 = 0.0; if (b <= -8.5e+154) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (c / (sqrt(((b * b) - ((c * 4.0) * a))) + b)) * -2.0; else tmp_3 = ((a * b) * -4.0) / ((4.0 * a) * a); end tmp_2 = tmp_3; elseif (b <= -2.8e-270) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = 2.0 / (a * sqrt((-4.0 / (a * c)))); else tmp_4 = (t_0 - b) / (a + a); end tmp_2 = tmp_4; elseif (b <= 1.1e+105) tmp_5 = 0.0; if (b >= 0.0) tmp_5 = (-2.0 * c) / (b + t_0); else tmp_5 = -0.5 * ((c * sqrt((-4.0 * (a / c)))) / a); end tmp_2 = tmp_5; elseif (b >= 0.0) tmp_2 = (c + c) / -(b + b); else tmp_2 = (sqrt(((-4.0 * a) * c)) - b) / (a + a); end tmp_6 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -8.5e+154], If[GreaterEqual[b, 0.0], N[(N[(c / N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(c * 4.0), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision], N[(N[(N[(a * b), $MachinePrecision] * -4.0), $MachinePrecision] / N[(N[(4.0 * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, -2.8e-270], If[GreaterEqual[b, 0.0], N[(2.0 / N[(a * N[Sqrt[N[(-4.0 / N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.1e+105], If[GreaterEqual[b, 0.0], N[(N[(-2.0 * c), $MachinePrecision] / N[(b + t$95$0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(c * N[Sqrt[N[(-4.0 * N[(a / c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c + c), $MachinePrecision] / (-N[(b + b), $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}\\
\mathbf{if}\;b \leq -8.5 \cdot 10^{+154}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a} + b} \cdot -2\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(a \cdot b\right) \cdot -4}{\left(4 \cdot a\right) \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq -2.8 \cdot 10^{-270}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{a \cdot \sqrt{\frac{-4}{a \cdot c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a + a}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{+105}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-2 \cdot c}{b + t\_0}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c \cdot \sqrt{-4 \cdot \frac{a}{c}}}{a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{-\left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c} - b}{a + a}\\
\end{array}
if b < -8.5000000000000002e154Initial program 72.0%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
common-denominatorN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites68.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-*.f6461.7%
Applied rewrites61.7%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lift-+.f64N/A
count-2-revN/A
*-commutativeN/A
associate-/r*N/A
lift-/.f64N/A
frac-2negN/A
frac-2negN/A
lift-+.f64N/A
add-flipN/A
sub-negateN/A
sub-negate-revN/A
add-flipN/A
lift-+.f64N/A
Applied rewrites61.7%
Applied rewrites57.8%
if -8.5000000000000002e154 < b < -2.7999999999999999e-270Initial program 72.0%
Applied rewrites72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6443.2%
Applied rewrites43.2%
Taylor expanded in c around -inf
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6450.6%
Applied rewrites50.6%
if -2.7999999999999999e-270 < b < 1.1e105Initial program 72.0%
Applied rewrites72.0%
Taylor expanded in c around -inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6442.8%
Applied rewrites42.8%
if 1.1e105 < b Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
Taylor expanded in b around inf
lower-*.f6454.6%
Applied rewrites54.6%
lift-*.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
count-2-revN/A
lift-+.f64N/A
lower-neg.f6454.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6454.7%
Applied rewrites54.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* (* a 4.0) c)))))
(if (<= b -8.5e+154)
(if (>= b 0.0)
(* (/ c (+ (sqrt (- (* b b) (* (* c 4.0) a))) b)) -2.0)
(/ (* (* a b) -4.0) (* (* 4.0 a) a)))
(if (<= b 1.1e+105)
(if (>= b 0.0) (/ (* -2.0 c) (+ b t_0)) (/ (- t_0 b) (+ a a)))
(if (>= b 0.0)
(/ (+ c c) (- (+ b b)))
(/ (- (sqrt (* (* -4.0 a) c)) b) (+ a a)))))))double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - ((a * 4.0) * c)));
double tmp_1;
if (b <= -8.5e+154) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (c / (sqrt(((b * b) - ((c * 4.0) * a))) + b)) * -2.0;
} else {
tmp_2 = ((a * b) * -4.0) / ((4.0 * a) * a);
}
tmp_1 = tmp_2;
} else if (b <= 1.1e+105) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-2.0 * c) / (b + t_0);
} else {
tmp_3 = (t_0 - b) / (a + a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
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) - ((a * 4.0d0) * c)))
if (b <= (-8.5d+154)) then
if (b >= 0.0d0) then
tmp_2 = (c / (sqrt(((b * b) - ((c * 4.0d0) * a))) + b)) * (-2.0d0)
else
tmp_2 = ((a * b) * (-4.0d0)) / ((4.0d0 * a) * a)
end if
tmp_1 = tmp_2
else if (b <= 1.1d+105) then
if (b >= 0.0d0) then
tmp_3 = ((-2.0d0) * c) / (b + t_0)
else
tmp_3 = (t_0 - b) / (a + a)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (c + c) / -(b + b)
else
tmp_1 = (sqrt((((-4.0d0) * a) * c)) - b) / (a + a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - ((a * 4.0) * c)));
double tmp_1;
if (b <= -8.5e+154) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (c / (Math.sqrt(((b * b) - ((c * 4.0) * a))) + b)) * -2.0;
} else {
tmp_2 = ((a * b) * -4.0) / ((4.0 * a) * a);
}
tmp_1 = tmp_2;
} else if (b <= 1.1e+105) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = (-2.0 * c) / (b + t_0);
} else {
tmp_3 = (t_0 - b) / (a + a);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (Math.sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - ((a * 4.0) * c))) tmp_1 = 0 if b <= -8.5e+154: tmp_2 = 0 if b >= 0.0: tmp_2 = (c / (math.sqrt(((b * b) - ((c * 4.0) * a))) + b)) * -2.0 else: tmp_2 = ((a * b) * -4.0) / ((4.0 * a) * a) tmp_1 = tmp_2 elif b <= 1.1e+105: tmp_3 = 0 if b >= 0.0: tmp_3 = (-2.0 * c) / (b + t_0) else: tmp_3 = (t_0 - b) / (a + a) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (c + c) / -(b + b) else: tmp_1 = (math.sqrt(((-4.0 * a) * c)) - b) / (a + a) return tmp_1
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) tmp_1 = 0.0 if (b <= -8.5e+154) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(c / Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(c * 4.0) * a))) + b)) * -2.0); else tmp_2 = Float64(Float64(Float64(a * b) * -4.0) / Float64(Float64(4.0 * a) * a)); end tmp_1 = tmp_2; elseif (b <= 1.1e+105) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(Float64(-2.0 * c) / Float64(b + t_0)); else tmp_3 = Float64(Float64(t_0 - b) / Float64(a + a)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(c + c) / Float64(-Float64(b + b))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(-4.0 * a) * c)) - b) / Float64(a + a)); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = sqrt(((b * b) - ((a * 4.0) * c))); tmp_2 = 0.0; if (b <= -8.5e+154) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (c / (sqrt(((b * b) - ((c * 4.0) * a))) + b)) * -2.0; else tmp_3 = ((a * b) * -4.0) / ((4.0 * a) * a); end tmp_2 = tmp_3; elseif (b <= 1.1e+105) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = (-2.0 * c) / (b + t_0); else tmp_4 = (t_0 - b) / (a + a); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (c + c) / -(b + b); else tmp_2 = (sqrt(((-4.0 * a) * c)) - b) / (a + a); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -8.5e+154], If[GreaterEqual[b, 0.0], N[(N[(c / N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(c * 4.0), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision], N[(N[(N[(a * b), $MachinePrecision] * -4.0), $MachinePrecision] / N[(N[(4.0 * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.1e+105], If[GreaterEqual[b, 0.0], N[(N[(-2.0 * c), $MachinePrecision] / N[(b + t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c + c), $MachinePrecision] / (-N[(b + b), $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c}\\
\mathbf{if}\;b \leq -8.5 \cdot 10^{+154}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a} + b} \cdot -2\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(a \cdot b\right) \cdot -4}{\left(4 \cdot a\right) \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{+105}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{-2 \cdot c}{b + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a + a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{-\left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c} - b}{a + a}\\
\end{array}
if b < -8.5000000000000002e154Initial program 72.0%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
common-denominatorN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites68.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-*.f6461.7%
Applied rewrites61.7%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lift-+.f64N/A
count-2-revN/A
*-commutativeN/A
associate-/r*N/A
lift-/.f64N/A
frac-2negN/A
frac-2negN/A
lift-+.f64N/A
add-flipN/A
sub-negateN/A
sub-negate-revN/A
add-flipN/A
lift-+.f64N/A
Applied rewrites61.7%
Applied rewrites57.8%
if -8.5000000000000002e154 < b < 1.1e105Initial program 72.0%
Applied rewrites72.0%
if 1.1e105 < b Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
Taylor expanded in b around inf
lower-*.f6454.6%
Applied rewrites54.6%
lift-*.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
count-2-revN/A
lift-+.f64N/A
lower-neg.f6454.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6454.7%
Applied rewrites54.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0
(if (>= b 0.0)
(* (/ c (+ (sqrt (- (* b b) (* (* c 4.0) a))) b)) -2.0)
(/ (* (* a b) -4.0) (* (* 4.0 a) a)))))
(if (<= b -8.5e+154)
t_0
(if (<= b -6e-309)
(if (>= b 0.0)
(/ 2.0 (* a (sqrt (/ -4.0 (* a c)))))
(/ (- (sqrt (- (* b b) (* (* a 4.0) c))) b) (+ a a)))
(if (<= b 1.1e+105)
t_0
(if (>= b 0.0)
(/ (+ c c) (- (+ b b)))
(/ (- (sqrt (* (* -4.0 a) c)) b) (+ a a))))))))double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (c / (sqrt(((b * b) - ((c * 4.0) * a))) + b)) * -2.0;
} else {
tmp = ((a * b) * -4.0) / ((4.0 * a) * a);
}
double t_0 = tmp;
double tmp_1;
if (b <= -8.5e+154) {
tmp_1 = t_0;
} else if (b <= -6e-309) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = 2.0 / (a * sqrt((-4.0 / (a * c))));
} else {
tmp_2 = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a + a);
}
tmp_1 = tmp_2;
} else if (b <= 1.1e+105) {
tmp_1 = t_0;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
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 = (c / (sqrt(((b * b) - ((c * 4.0d0) * a))) + b)) * (-2.0d0)
else
tmp = ((a * b) * (-4.0d0)) / ((4.0d0 * a) * a)
end if
t_0 = tmp
if (b <= (-8.5d+154)) then
tmp_1 = t_0
else if (b <= (-6d-309)) then
if (b >= 0.0d0) then
tmp_2 = 2.0d0 / (a * sqrt(((-4.0d0) / (a * c))))
else
tmp_2 = (sqrt(((b * b) - ((a * 4.0d0) * c))) - b) / (a + a)
end if
tmp_1 = tmp_2
else if (b <= 1.1d+105) then
tmp_1 = t_0
else if (b >= 0.0d0) then
tmp_1 = (c + c) / -(b + b)
else
tmp_1 = (sqrt((((-4.0d0) * a) * c)) - b) / (a + a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (c / (Math.sqrt(((b * b) - ((c * 4.0) * a))) + b)) * -2.0;
} else {
tmp = ((a * b) * -4.0) / ((4.0 * a) * a);
}
double t_0 = tmp;
double tmp_1;
if (b <= -8.5e+154) {
tmp_1 = t_0;
} else if (b <= -6e-309) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = 2.0 / (a * Math.sqrt((-4.0 / (a * c))));
} else {
tmp_2 = (Math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a + a);
}
tmp_1 = tmp_2;
} else if (b <= 1.1e+105) {
tmp_1 = t_0;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (Math.sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
return tmp_1;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (c / (math.sqrt(((b * b) - ((c * 4.0) * a))) + b)) * -2.0 else: tmp = ((a * b) * -4.0) / ((4.0 * a) * a) t_0 = tmp tmp_1 = 0 if b <= -8.5e+154: tmp_1 = t_0 elif b <= -6e-309: tmp_2 = 0 if b >= 0.0: tmp_2 = 2.0 / (a * math.sqrt((-4.0 / (a * c)))) else: tmp_2 = (math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a + a) tmp_1 = tmp_2 elif b <= 1.1e+105: tmp_1 = t_0 elif b >= 0.0: tmp_1 = (c + c) / -(b + b) else: tmp_1 = (math.sqrt(((-4.0 * a) * c)) - b) / (a + a) return tmp_1
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(c / Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(c * 4.0) * a))) + b)) * -2.0); else tmp = Float64(Float64(Float64(a * b) * -4.0) / Float64(Float64(4.0 * a) * a)); end t_0 = tmp tmp_1 = 0.0 if (b <= -8.5e+154) tmp_1 = t_0; elseif (b <= -6e-309) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(2.0 / Float64(a * sqrt(Float64(-4.0 / Float64(a * c))))); else tmp_2 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - b) / Float64(a + a)); end tmp_1 = tmp_2; elseif (b <= 1.1e+105) tmp_1 = t_0; elseif (b >= 0.0) tmp_1 = Float64(Float64(c + c) / Float64(-Float64(b + b))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(-4.0 * a) * c)) - b) / Float64(a + a)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (c / (sqrt(((b * b) - ((c * 4.0) * a))) + b)) * -2.0; else tmp = ((a * b) * -4.0) / ((4.0 * a) * a); end t_0 = tmp; tmp_2 = 0.0; if (b <= -8.5e+154) tmp_2 = t_0; elseif (b <= -6e-309) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = 2.0 / (a * sqrt((-4.0 / (a * c)))); else tmp_3 = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a + a); end tmp_2 = tmp_3; elseif (b <= 1.1e+105) tmp_2 = t_0; elseif (b >= 0.0) tmp_2 = (c + c) / -(b + b); else tmp_2 = (sqrt(((-4.0 * a) * c)) - b) / (a + a); end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = If[GreaterEqual[b, 0.0], N[(N[(c / N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(c * 4.0), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision], N[(N[(N[(a * b), $MachinePrecision] * -4.0), $MachinePrecision] / N[(N[(4.0 * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]]}, If[LessEqual[b, -8.5e+154], t$95$0, If[LessEqual[b, -6e-309], If[GreaterEqual[b, 0.0], N[(2.0 / N[(a * N[Sqrt[N[(-4.0 / N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 1.1e+105], t$95$0, If[GreaterEqual[b, 0.0], N[(N[(c + c), $MachinePrecision] / (-N[(b + b), $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c}{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a} + b} \cdot -2\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(a \cdot b\right) \cdot -4}{\left(4 \cdot a\right) \cdot a}\\
\end{array}\\
\mathbf{if}\;b \leq -8.5 \cdot 10^{+154}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq -6 \cdot 10^{-309}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{a \cdot \sqrt{\frac{-4}{a \cdot c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a + a}\\
\end{array}\\
\mathbf{elif}\;b \leq 1.1 \cdot 10^{+105}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{-\left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c} - b}{a + a}\\
\end{array}
if b < -8.5000000000000002e154 or -6.0000000000000014e-309 < b < 1.1e105Initial program 72.0%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
common-denominatorN/A
associate-/r*N/A
lower-/.f64N/A
Applied rewrites68.0%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-*.f6461.7%
Applied rewrites61.7%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lift-+.f64N/A
count-2-revN/A
*-commutativeN/A
associate-/r*N/A
lift-/.f64N/A
frac-2negN/A
frac-2negN/A
lift-+.f64N/A
add-flipN/A
sub-negateN/A
sub-negate-revN/A
add-flipN/A
lift-+.f64N/A
Applied rewrites61.7%
Applied rewrites57.8%
if -8.5000000000000002e154 < b < -6.0000000000000014e-309Initial program 72.0%
Applied rewrites72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6443.2%
Applied rewrites43.2%
Taylor expanded in c around -inf
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6450.6%
Applied rewrites50.6%
if 1.1e105 < b Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
Taylor expanded in b around inf
lower-*.f6454.6%
Applied rewrites54.6%
lift-*.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
count-2-revN/A
lift-+.f64N/A
lower-neg.f6454.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6454.7%
Applied rewrites54.7%
(FPCore (a b c)
:precision binary64
(if (<= b 390000000000.0)
(if (>= b 0.0)
(/ 2.0 (* a (sqrt (/ -4.0 (* a c)))))
(/ (- (sqrt (- (* b b) (* (* a 4.0) c))) b) (+ a a)))
(if (>= b 0.0)
(/ (+ c c) (- (+ b b)))
(/ (- (sqrt (* (* -4.0 a) c)) b) (+ a a)))))double code(double a, double b, double c) {
double tmp_1;
if (b <= 390000000000.0) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = 2.0 / (a * sqrt((-4.0 / (a * c))));
} else {
tmp_2 = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a + a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
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 <= 390000000000.0d0) then
if (b >= 0.0d0) then
tmp_2 = 2.0d0 / (a * sqrt(((-4.0d0) / (a * c))))
else
tmp_2 = (sqrt(((b * b) - ((a * 4.0d0) * c))) - b) / (a + a)
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (c + c) / -(b + b)
else
tmp_1 = (sqrt((((-4.0d0) * a) * c)) - b) / (a + a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double tmp_1;
if (b <= 390000000000.0) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = 2.0 / (a * Math.sqrt((-4.0 / (a * c))));
} else {
tmp_2 = (Math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a + a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (Math.sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
return tmp_1;
}
def code(a, b, c): tmp_1 = 0 if b <= 390000000000.0: tmp_2 = 0 if b >= 0.0: tmp_2 = 2.0 / (a * math.sqrt((-4.0 / (a * c)))) else: tmp_2 = (math.sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a + a) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (c + c) / -(b + b) else: tmp_1 = (math.sqrt(((-4.0 * a) * c)) - b) / (a + a) return tmp_1
function code(a, b, c) tmp_1 = 0.0 if (b <= 390000000000.0) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(2.0 / Float64(a * sqrt(Float64(-4.0 / Float64(a * c))))); else tmp_2 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 4.0) * c))) - b) / Float64(a + a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(c + c) / Float64(-Float64(b + b))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(-4.0 * a) * c)) - b) / Float64(a + a)); end return tmp_1 end
function tmp_4 = code(a, b, c) tmp_2 = 0.0; if (b <= 390000000000.0) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = 2.0 / (a * sqrt((-4.0 / (a * c)))); else tmp_3 = (sqrt(((b * b) - ((a * 4.0) * c))) - b) / (a + a); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (c + c) / -(b + b); else tmp_2 = (sqrt(((-4.0 * a) * c)) - b) / (a + a); end tmp_4 = tmp_2; end
code[a_, b_, c_] := If[LessEqual[b, 390000000000.0], If[GreaterEqual[b, 0.0], N[(2.0 / N[(a * N[Sqrt[N[(-4.0 / N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c + c), $MachinePrecision] / (-N[(b + b), $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq 390000000000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2}{a \cdot \sqrt{\frac{-4}{a \cdot c}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b}{a + a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{-\left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c} - b}{a + a}\\
\end{array}
if b < 3.9e11Initial program 72.0%
Applied rewrites72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f6443.2%
Applied rewrites43.2%
Taylor expanded in c around -inf
lower-/.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6450.6%
Applied rewrites50.6%
if 3.9e11 < b Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
Taylor expanded in b around inf
lower-*.f6454.6%
Applied rewrites54.6%
lift-*.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
count-2-revN/A
lift-+.f64N/A
lower-neg.f6454.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6454.7%
Applied rewrites54.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* (* -4.0 a) c)) (t_1 (sqrt (fabs t_0))))
(if (<= b 390000000000.0)
(if (>= b 0.0)
(/ (* 2.0 c) (- (- b) t_1))
(/ (+ (- b) t_1) (* 2.0 a)))
(if (>= b 0.0)
(/ (+ c c) (- (+ b b)))
(/ (- (sqrt t_0) b) (+ a a))))))double code(double a, double b, double c) {
double t_0 = (-4.0 * a) * c;
double t_1 = sqrt(fabs(t_0));
double tmp_1;
if (b <= 390000000000.0) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - t_1);
} else {
tmp_2 = (-b + t_1) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (sqrt(t_0) - b) / (a + a);
}
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) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
t_0 = ((-4.0d0) * a) * c
t_1 = sqrt(abs(t_0))
if (b <= 390000000000.0d0) then
if (b >= 0.0d0) then
tmp_2 = (2.0d0 * c) / (-b - t_1)
else
tmp_2 = (-b + t_1) / (2.0d0 * a)
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (c + c) / -(b + b)
else
tmp_1 = (sqrt(t_0) - b) / (a + a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = (-4.0 * a) * c;
double t_1 = Math.sqrt(Math.abs(t_0));
double tmp_1;
if (b <= 390000000000.0) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = (2.0 * c) / (-b - t_1);
} else {
tmp_2 = (-b + t_1) / (2.0 * a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (Math.sqrt(t_0) - b) / (a + a);
}
return tmp_1;
}
def code(a, b, c): t_0 = (-4.0 * a) * c t_1 = math.sqrt(math.fabs(t_0)) tmp_1 = 0 if b <= 390000000000.0: tmp_2 = 0 if b >= 0.0: tmp_2 = (2.0 * c) / (-b - t_1) else: tmp_2 = (-b + t_1) / (2.0 * a) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (c + c) / -(b + b) else: tmp_1 = (math.sqrt(t_0) - b) / (a + a) return tmp_1
function code(a, b, c) t_0 = Float64(Float64(-4.0 * a) * c) t_1 = sqrt(abs(t_0)) tmp_1 = 0.0 if (b <= 390000000000.0) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_1)); else tmp_2 = Float64(Float64(Float64(-b) + t_1) / Float64(2.0 * a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(c + c) / Float64(-Float64(b + b))); else tmp_1 = Float64(Float64(sqrt(t_0) - b) / Float64(a + a)); end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = (-4.0 * a) * c; t_1 = sqrt(abs(t_0)); tmp_2 = 0.0; if (b <= 390000000000.0) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = (2.0 * c) / (-b - t_1); else tmp_3 = (-b + t_1) / (2.0 * a); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (c + c) / -(b + b); else tmp_2 = (sqrt(t_0) - b) / (a + a); end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(-4.0 * a), $MachinePrecision] * c), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[Abs[t$95$0], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, 390000000000.0], If[GreaterEqual[b, 0.0], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[((-b) + t$95$1), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c + c), $MachinePrecision] / (-N[(b + b), $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[t$95$0], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \left(-4 \cdot a\right) \cdot c\\
t_1 := \sqrt{\left|t\_0\right|}\\
\mathbf{if}\;b \leq 390000000000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) + t\_1}{2 \cdot a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{-\left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{t\_0} - b}{a + a}\\
\end{array}
if b < 3.9e11Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
mul-fabsN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fabs.f6445.4%
Applied rewrites45.4%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
mul-fabsN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fabs.f6450.1%
Applied rewrites50.1%
if 3.9e11 < b Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
Taylor expanded in b around inf
lower-*.f6454.6%
Applied rewrites54.6%
lift-*.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
count-2-revN/A
lift-+.f64N/A
lower-neg.f6454.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6454.7%
Applied rewrites54.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (fabs (* (* a c) -4.0)))))
(if (<= b 390000000000.0)
(if (>= b 0.0) (* c (/ -2.0 (+ t_0 b))) (/ (- t_0 b) (+ a a)))
(if (>= b 0.0)
(/ (+ c c) (- (+ b b)))
(/ (- (sqrt (* (* -4.0 a) c)) b) (+ a a))))))double code(double a, double b, double c) {
double t_0 = sqrt(fabs(((a * c) * -4.0)));
double tmp_1;
if (b <= 390000000000.0) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (t_0 + b));
} else {
tmp_2 = (t_0 - b) / (a + a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
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
t_0 = sqrt(abs(((a * c) * (-4.0d0))))
if (b <= 390000000000.0d0) then
if (b >= 0.0d0) then
tmp_2 = c * ((-2.0d0) / (t_0 + b))
else
tmp_2 = (t_0 - b) / (a + a)
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (c + c) / -(b + b)
else
tmp_1 = (sqrt((((-4.0d0) * a) * c)) - b) / (a + a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(Math.abs(((a * c) * -4.0)));
double tmp_1;
if (b <= 390000000000.0) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (t_0 + b));
} else {
tmp_2 = (t_0 - b) / (a + a);
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (Math.sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
return tmp_1;
}
def code(a, b, c): t_0 = math.sqrt(math.fabs(((a * c) * -4.0))) tmp_1 = 0 if b <= 390000000000.0: tmp_2 = 0 if b >= 0.0: tmp_2 = c * (-2.0 / (t_0 + b)) else: tmp_2 = (t_0 - b) / (a + a) tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (c + c) / -(b + b) else: tmp_1 = (math.sqrt(((-4.0 * a) * c)) - b) / (a + a) return tmp_1
function code(a, b, c) t_0 = sqrt(abs(Float64(Float64(a * c) * -4.0))) tmp_1 = 0.0 if (b <= 390000000000.0) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c * Float64(-2.0 / Float64(t_0 + b))); else tmp_2 = Float64(Float64(t_0 - b) / Float64(a + a)); end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(c + c) / Float64(-Float64(b + b))); else tmp_1 = Float64(Float64(sqrt(Float64(Float64(-4.0 * a) * c)) - b) / Float64(a + a)); end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = sqrt(abs(((a * c) * -4.0))); tmp_2 = 0.0; if (b <= 390000000000.0) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c * (-2.0 / (t_0 + b)); else tmp_3 = (t_0 - b) / (a + a); end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (c + c) / -(b + b); else tmp_2 = (sqrt(((-4.0 * a) * c)) - b) / (a + a); end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[Abs[N[(N[(a * c), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, 390000000000.0], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(t$95$0 + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c + c), $MachinePrecision] / (-N[(b + b), $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \sqrt{\left|\left(a \cdot c\right) \cdot -4\right|}\\
\mathbf{if}\;b \leq 390000000000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{t\_0 + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0 - b}{a + a}\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{-\left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c} - b}{a + a}\\
\end{array}
if b < 3.9e11Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
mul-fabsN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fabs.f6445.3%
Applied rewrites45.3%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
mul-fabsN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fabs.f6450.1%
Applied rewrites50.1%
if 3.9e11 < b Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
Taylor expanded in b around inf
lower-*.f6454.6%
Applied rewrites54.6%
lift-*.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
count-2-revN/A
lift-+.f64N/A
lower-neg.f6454.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6454.7%
Applied rewrites54.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* (* -4.0 a) c)) (t_1 (sqrt t_0)))
(if (<= b -6e-224)
(if (>= b 0.0)
(* c (/ -2.0 (* 2.0 b)))
(/ (- (sqrt (fabs t_0)) b) (+ a a)))
(if (<= b 390000000000.0)
(if (>= b 0.0)
(* c (/ -2.0 (+ t_1 b)))
(* (/ 0.5 a) (- (sqrt (* (* a c) -4.0)) b)))
(if (>= b 0.0) (/ (+ c c) (- (+ b b))) (/ (- t_1 b) (+ a a)))))))double code(double a, double b, double c) {
double t_0 = (-4.0 * a) * c;
double t_1 = sqrt(t_0);
double tmp_1;
if (b <= -6e-224) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (2.0 * b));
} else {
tmp_2 = (sqrt(fabs(t_0)) - b) / (a + a);
}
tmp_1 = tmp_2;
} else if (b <= 390000000000.0) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (-2.0 / (t_1 + b));
} else {
tmp_3 = (0.5 / a) * (sqrt(((a * c) * -4.0)) - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (t_1 - b) / (a + a);
}
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) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = ((-4.0d0) * a) * c
t_1 = sqrt(t_0)
if (b <= (-6d-224)) then
if (b >= 0.0d0) then
tmp_2 = c * ((-2.0d0) / (2.0d0 * b))
else
tmp_2 = (sqrt(abs(t_0)) - b) / (a + a)
end if
tmp_1 = tmp_2
else if (b <= 390000000000.0d0) then
if (b >= 0.0d0) then
tmp_3 = c * ((-2.0d0) / (t_1 + b))
else
tmp_3 = (0.5d0 / a) * (sqrt(((a * c) * (-4.0d0))) - b)
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (c + c) / -(b + b)
else
tmp_1 = (t_1 - b) / (a + a)
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = (-4.0 * a) * c;
double t_1 = Math.sqrt(t_0);
double tmp_1;
if (b <= -6e-224) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (2.0 * b));
} else {
tmp_2 = (Math.sqrt(Math.abs(t_0)) - b) / (a + a);
}
tmp_1 = tmp_2;
} else if (b <= 390000000000.0) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (-2.0 / (t_1 + b));
} else {
tmp_3 = (0.5 / a) * (Math.sqrt(((a * c) * -4.0)) - b);
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = (t_1 - b) / (a + a);
}
return tmp_1;
}
def code(a, b, c): t_0 = (-4.0 * a) * c t_1 = math.sqrt(t_0) tmp_1 = 0 if b <= -6e-224: tmp_2 = 0 if b >= 0.0: tmp_2 = c * (-2.0 / (2.0 * b)) else: tmp_2 = (math.sqrt(math.fabs(t_0)) - b) / (a + a) tmp_1 = tmp_2 elif b <= 390000000000.0: tmp_3 = 0 if b >= 0.0: tmp_3 = c * (-2.0 / (t_1 + b)) else: tmp_3 = (0.5 / a) * (math.sqrt(((a * c) * -4.0)) - b) tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (c + c) / -(b + b) else: tmp_1 = (t_1 - b) / (a + a) return tmp_1
function code(a, b, c) t_0 = Float64(Float64(-4.0 * a) * c) t_1 = sqrt(t_0) tmp_1 = 0.0 if (b <= -6e-224) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c * Float64(-2.0 / Float64(2.0 * b))); else tmp_2 = Float64(Float64(sqrt(abs(t_0)) - b) / Float64(a + a)); end tmp_1 = tmp_2; elseif (b <= 390000000000.0) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(c * Float64(-2.0 / Float64(t_1 + b))); else tmp_3 = Float64(Float64(0.5 / a) * Float64(sqrt(Float64(Float64(a * c) * -4.0)) - b)); end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(c + c) / Float64(-Float64(b + b))); else tmp_1 = Float64(Float64(t_1 - b) / Float64(a + a)); end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = (-4.0 * a) * c; t_1 = sqrt(t_0); tmp_2 = 0.0; if (b <= -6e-224) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c * (-2.0 / (2.0 * b)); else tmp_3 = (sqrt(abs(t_0)) - b) / (a + a); end tmp_2 = tmp_3; elseif (b <= 390000000000.0) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = c * (-2.0 / (t_1 + b)); else tmp_4 = (0.5 / a) * (sqrt(((a * c) * -4.0)) - b); end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (c + c) / -(b + b); else tmp_2 = (t_1 - b) / (a + a); end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(-4.0 * a), $MachinePrecision] * c), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, If[LessEqual[b, -6e-224], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(2.0 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[Abs[t$95$0], $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 390000000000.0], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(t$95$1 + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(N[(a * c), $MachinePrecision] * -4.0), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]], If[GreaterEqual[b, 0.0], N[(N[(c + c), $MachinePrecision] / (-N[(b + b), $MachinePrecision])), $MachinePrecision], N[(N[(t$95$1 - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \left(-4 \cdot a\right) \cdot c\\
t_1 := \sqrt{t\_0}\\
\mathbf{if}\;b \leq -6 \cdot 10^{-224}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left|t\_0\right|} - b}{a + a}\\
\end{array}\\
\mathbf{elif}\;b \leq 390000000000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{t\_1 + b}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{\left(a \cdot c\right) \cdot -4} - b\right)\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{-\left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1 - b}{a + a}\\
\end{array}
if b < -5.9999999999999996e-224Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
Taylor expanded in b around inf
lower-*.f6454.6%
Applied rewrites54.6%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
mul-fabsN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fabs.f6459.3%
Applied rewrites59.3%
if -5.9999999999999996e-224 < b < 3.9e11Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lift-+.f64N/A
count-2-revN/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6440.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f6440.8%
Applied rewrites40.8%
if 3.9e11 < b Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
Taylor expanded in b around inf
lower-*.f6454.6%
Applied rewrites54.6%
lift-*.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
count-2-revN/A
lift-+.f64N/A
lower-neg.f6454.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6454.7%
Applied rewrites54.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (* (* -4.0 a) c)) (t_1 (/ (- (sqrt t_0) b) (+ a a))))
(if (<= b -8.4e-137)
(if (>= b 0.0)
(* c (/ -2.0 (* 2.0 b)))
(/ (- (sqrt (fabs t_0)) b) (+ a a)))
(if (<= b 390000000000.0)
(if (>= b 0.0) (* c (/ -2.0 (sqrt (- (* 4.0 (* a c)))))) t_1)
(if (>= b 0.0) (/ (+ c c) (- (+ b b))) t_1)))))double code(double a, double b, double c) {
double t_0 = (-4.0 * a) * c;
double t_1 = (sqrt(t_0) - b) / (a + a);
double tmp_1;
if (b <= -8.4e-137) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (2.0 * b));
} else {
tmp_2 = (sqrt(fabs(t_0)) - b) / (a + a);
}
tmp_1 = tmp_2;
} else if (b <= 390000000000.0) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (-2.0 / sqrt(-(4.0 * (a * c))));
} else {
tmp_3 = t_1;
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = 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) :: tmp
real(8) :: tmp_1
real(8) :: tmp_2
real(8) :: tmp_3
t_0 = ((-4.0d0) * a) * c
t_1 = (sqrt(t_0) - b) / (a + a)
if (b <= (-8.4d-137)) then
if (b >= 0.0d0) then
tmp_2 = c * ((-2.0d0) / (2.0d0 * b))
else
tmp_2 = (sqrt(abs(t_0)) - b) / (a + a)
end if
tmp_1 = tmp_2
else if (b <= 390000000000.0d0) then
if (b >= 0.0d0) then
tmp_3 = c * ((-2.0d0) / sqrt(-(4.0d0 * (a * c))))
else
tmp_3 = t_1
end if
tmp_1 = tmp_3
else if (b >= 0.0d0) then
tmp_1 = (c + c) / -(b + b)
else
tmp_1 = t_1
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = (-4.0 * a) * c;
double t_1 = (Math.sqrt(t_0) - b) / (a + a);
double tmp_1;
if (b <= -8.4e-137) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / (2.0 * b));
} else {
tmp_2 = (Math.sqrt(Math.abs(t_0)) - b) / (a + a);
}
tmp_1 = tmp_2;
} else if (b <= 390000000000.0) {
double tmp_3;
if (b >= 0.0) {
tmp_3 = c * (-2.0 / Math.sqrt(-(4.0 * (a * c))));
} else {
tmp_3 = t_1;
}
tmp_1 = tmp_3;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = t_1;
}
return tmp_1;
}
def code(a, b, c): t_0 = (-4.0 * a) * c t_1 = (math.sqrt(t_0) - b) / (a + a) tmp_1 = 0 if b <= -8.4e-137: tmp_2 = 0 if b >= 0.0: tmp_2 = c * (-2.0 / (2.0 * b)) else: tmp_2 = (math.sqrt(math.fabs(t_0)) - b) / (a + a) tmp_1 = tmp_2 elif b <= 390000000000.0: tmp_3 = 0 if b >= 0.0: tmp_3 = c * (-2.0 / math.sqrt(-(4.0 * (a * c)))) else: tmp_3 = t_1 tmp_1 = tmp_3 elif b >= 0.0: tmp_1 = (c + c) / -(b + b) else: tmp_1 = t_1 return tmp_1
function code(a, b, c) t_0 = Float64(Float64(-4.0 * a) * c) t_1 = Float64(Float64(sqrt(t_0) - b) / Float64(a + a)) tmp_1 = 0.0 if (b <= -8.4e-137) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c * Float64(-2.0 / Float64(2.0 * b))); else tmp_2 = Float64(Float64(sqrt(abs(t_0)) - b) / Float64(a + a)); end tmp_1 = tmp_2; elseif (b <= 390000000000.0) tmp_3 = 0.0 if (b >= 0.0) tmp_3 = Float64(c * Float64(-2.0 / sqrt(Float64(-Float64(4.0 * Float64(a * c)))))); else tmp_3 = t_1; end tmp_1 = tmp_3; elseif (b >= 0.0) tmp_1 = Float64(Float64(c + c) / Float64(-Float64(b + b))); else tmp_1 = t_1; end return tmp_1 end
function tmp_5 = code(a, b, c) t_0 = (-4.0 * a) * c; t_1 = (sqrt(t_0) - b) / (a + a); tmp_2 = 0.0; if (b <= -8.4e-137) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c * (-2.0 / (2.0 * b)); else tmp_3 = (sqrt(abs(t_0)) - b) / (a + a); end tmp_2 = tmp_3; elseif (b <= 390000000000.0) tmp_4 = 0.0; if (b >= 0.0) tmp_4 = c * (-2.0 / sqrt(-(4.0 * (a * c)))); else tmp_4 = t_1; end tmp_2 = tmp_4; elseif (b >= 0.0) tmp_2 = (c + c) / -(b + b); else tmp_2 = t_1; end tmp_5 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(-4.0 * a), $MachinePrecision] * c), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sqrt[t$95$0], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, -8.4e-137], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(2.0 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[Abs[t$95$0], $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]], If[LessEqual[b, 390000000000.0], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[Sqrt[(-N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1], If[GreaterEqual[b, 0.0], N[(N[(c + c), $MachinePrecision] / (-N[(b + b), $MachinePrecision])), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
t_0 := \left(-4 \cdot a\right) \cdot c\\
t_1 := \frac{\sqrt{t\_0} - b}{a + a}\\
\mathbf{if}\;b \leq -8.4 \cdot 10^{-137}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left|t\_0\right|} - b}{a + a}\\
\end{array}\\
\mathbf{elif}\;b \leq 390000000000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{\sqrt{-4 \cdot \left(a \cdot c\right)}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{-\left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if b < -8.3999999999999997e-137Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
Taylor expanded in b around inf
lower-*.f6454.6%
Applied rewrites54.6%
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
sqr-abs-revN/A
mul-fabsN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lower-fabs.f6459.3%
Applied rewrites59.3%
if -8.3999999999999997e-137 < b < 3.9e11Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
Taylor expanded in b around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-*.f6433.9%
Applied rewrites33.9%
if 3.9e11 < b Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
Taylor expanded in b around inf
lower-*.f6454.6%
Applied rewrites54.6%
lift-*.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
count-2-revN/A
lift-+.f64N/A
lower-neg.f6454.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6454.7%
Applied rewrites54.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (/ (- (sqrt (* (* -4.0 a) c)) b) (+ a a))))
(if (<= b 390000000000.0)
(if (>= b 0.0) (* c (/ -2.0 (sqrt (- (* 4.0 (* a c)))))) t_0)
(if (>= b 0.0) (/ (+ c c) (- (+ b b))) t_0))))double code(double a, double b, double c) {
double t_0 = (sqrt(((-4.0 * a) * c)) - b) / (a + a);
double tmp_1;
if (b <= 390000000000.0) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / sqrt(-(4.0 * (a * c))));
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = t_0;
}
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
t_0 = (sqrt((((-4.0d0) * a) * c)) - b) / (a + a)
if (b <= 390000000000.0d0) then
if (b >= 0.0d0) then
tmp_2 = c * ((-2.0d0) / sqrt(-(4.0d0 * (a * c))))
else
tmp_2 = t_0
end if
tmp_1 = tmp_2
else if (b >= 0.0d0) then
tmp_1 = (c + c) / -(b + b)
else
tmp_1 = t_0
end if
code = tmp_1
end function
public static double code(double a, double b, double c) {
double t_0 = (Math.sqrt(((-4.0 * a) * c)) - b) / (a + a);
double tmp_1;
if (b <= 390000000000.0) {
double tmp_2;
if (b >= 0.0) {
tmp_2 = c * (-2.0 / Math.sqrt(-(4.0 * (a * c))));
} else {
tmp_2 = t_0;
}
tmp_1 = tmp_2;
} else if (b >= 0.0) {
tmp_1 = (c + c) / -(b + b);
} else {
tmp_1 = t_0;
}
return tmp_1;
}
def code(a, b, c): t_0 = (math.sqrt(((-4.0 * a) * c)) - b) / (a + a) tmp_1 = 0 if b <= 390000000000.0: tmp_2 = 0 if b >= 0.0: tmp_2 = c * (-2.0 / math.sqrt(-(4.0 * (a * c)))) else: tmp_2 = t_0 tmp_1 = tmp_2 elif b >= 0.0: tmp_1 = (c + c) / -(b + b) else: tmp_1 = t_0 return tmp_1
function code(a, b, c) t_0 = Float64(Float64(sqrt(Float64(Float64(-4.0 * a) * c)) - b) / Float64(a + a)) tmp_1 = 0.0 if (b <= 390000000000.0) tmp_2 = 0.0 if (b >= 0.0) tmp_2 = Float64(c * Float64(-2.0 / sqrt(Float64(-Float64(4.0 * Float64(a * c)))))); else tmp_2 = t_0; end tmp_1 = tmp_2; elseif (b >= 0.0) tmp_1 = Float64(Float64(c + c) / Float64(-Float64(b + b))); else tmp_1 = t_0; end return tmp_1 end
function tmp_4 = code(a, b, c) t_0 = (sqrt(((-4.0 * a) * c)) - b) / (a + a); tmp_2 = 0.0; if (b <= 390000000000.0) tmp_3 = 0.0; if (b >= 0.0) tmp_3 = c * (-2.0 / sqrt(-(4.0 * (a * c)))); else tmp_3 = t_0; end tmp_2 = tmp_3; elseif (b >= 0.0) tmp_2 = (c + c) / -(b + b); else tmp_2 = t_0; end tmp_4 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 390000000000.0], If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[Sqrt[(-N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0], If[GreaterEqual[b, 0.0], N[(N[(c + c), $MachinePrecision] / (-N[(b + b), $MachinePrecision])), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{\sqrt{\left(-4 \cdot a\right) \cdot c} - b}{a + a}\\
\mathbf{if}\;b \leq 390000000000:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{\sqrt{-4 \cdot \left(a \cdot c\right)}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}\\
\mathbf{elif}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{-\left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if b < 3.9e11Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
Taylor expanded in b around 0
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-*.f6433.9%
Applied rewrites33.9%
if 3.9e11 < b Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
Taylor expanded in b around inf
lower-*.f6454.6%
Applied rewrites54.6%
lift-*.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
count-2-revN/A
lift-+.f64N/A
lower-neg.f6454.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6454.7%
Applied rewrites54.7%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (/ (+ c c) (- (+ b b))) (/ (- (sqrt (* (* -4.0 a) c)) b) (+ a a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (c + c) / -(b + b);
} else {
tmp = (sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
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 = (c + c) / -(b + b)
else
tmp = (sqrt((((-4.0d0) * a) * c)) - b) / (a + a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = (c + c) / -(b + b);
} else {
tmp = (Math.sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = (c + c) / -(b + b) else: tmp = (math.sqrt(((-4.0 * a) * c)) - b) / (a + a) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(Float64(c + c) / Float64(-Float64(b + b))); else tmp = Float64(Float64(sqrt(Float64(Float64(-4.0 * a) * c)) - b) / Float64(a + a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = (c + c) / -(b + b); else tmp = (sqrt(((-4.0 * a) * c)) - b) / (a + a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(N[(c + c), $MachinePrecision] / (-N[(b + b), $MachinePrecision])), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;\frac{c + c}{-\left(b + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c} - b}{a + a}\\
\end{array}
Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
Taylor expanded in b around inf
lower-*.f6454.6%
Applied rewrites54.6%
lift-*.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
lift-*.f64N/A
count-2-revN/A
lift-+.f64N/A
lower-neg.f6454.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6454.7%
Applied rewrites54.7%
(FPCore (a b c) :precision binary64 (if (>= b 0.0) (* c (/ -2.0 (* 2.0 b))) (/ (- (sqrt (* (* -4.0 a) c)) b) (+ a a))))
double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c * (-2.0 / (2.0 * b));
} else {
tmp = (sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
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 = c * ((-2.0d0) / (2.0d0 * b))
else
tmp = (sqrt((((-4.0d0) * a) * c)) - b) / (a + a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b >= 0.0) {
tmp = c * (-2.0 / (2.0 * b));
} else {
tmp = (Math.sqrt(((-4.0 * a) * c)) - b) / (a + a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b >= 0.0: tmp = c * (-2.0 / (2.0 * b)) else: tmp = (math.sqrt(((-4.0 * a) * c)) - b) / (a + a) return tmp
function code(a, b, c) tmp = 0.0 if (b >= 0.0) tmp = Float64(c * Float64(-2.0 / Float64(2.0 * b))); else tmp = Float64(Float64(sqrt(Float64(Float64(-4.0 * a) * c)) - b) / Float64(a + a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b >= 0.0) tmp = c * (-2.0 / (2.0 * b)); else tmp = (sqrt(((-4.0 * a) * c)) - b) / (a + a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[GreaterEqual[b, 0.0], N[(c * N[(-2.0 / N[(2.0 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(N[(-4.0 * a), $MachinePrecision] * c), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a + a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;b \geq 0:\\
\;\;\;\;c \cdot \frac{-2}{2 \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(-4 \cdot a\right) \cdot c} - b}{a + a}\\
\end{array}
Initial program 72.0%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6456.2%
Applied rewrites56.2%
Taylor expanded in a around inf
lower-*.f64N/A
lower-*.f6440.8%
Applied rewrites40.8%
Applied rewrites40.8%
Taylor expanded in b around inf
lower-*.f6454.6%
Applied rewrites54.6%
herbie shell --seed 2025258
(FPCore (a b c)
:name "jeff quadratic root 2"
:precision binary64
(if (>= b 0.0) (/ (* 2.0 c) (- (- b) (sqrt (- (* b b) (* (* 4.0 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))))