
(FPCore (x y)
:precision binary64
(let* ((t_0 (sqrt (+ (pow (- y 0.275) 2.0) (pow (- x 0.275) 2.0)))))
(fmin
(fmin
(fmin
(fmin
(fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x))
(- (sqrt (+ (pow (- y 0.7) 2.0) (pow (- x 0.775) 2.0))) 0.075))
(fmax (fmax (fmax (- y) (- y 0.275)) (- x 0.55)) (- 0.45 x)))
(fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x)))
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) (- x 0.55)) (- x)) (- 0.275 y))
(- 0.175 t_0))
(- t_0 0.275)))))
double code(double x, double y) {
double t_0 = sqrt((pow((y - 0.275), 2.0) + pow((x - 0.275), 2.0)));
return fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)), (sqrt((pow((y - 0.7), 2.0) + pow((x - 0.775), 2.0))) - 0.075)), fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - t_0)), (t_0 - 0.275)));
}
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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = sqrt((((y - 0.275d0) ** 2.0d0) + ((x - 0.275d0) ** 2.0d0)))
code = fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - x)), (sqrt((((y - 0.7d0) ** 2.0d0) + ((x - 0.775d0) ** 2.0d0))) - 0.075d0)), fmax(fmax(fmax(-y, (y - 0.275d0)), (x - 0.55d0)), (0.45d0 - x))), fmax(fmax(fmax(-y, (y - 1.0d0)), (x - 0.1d0)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (x - 0.55d0)), -x), (0.275d0 - y)), (0.175d0 - t_0)), (t_0 - 0.275d0)))
end function
public static double code(double x, double y) {
double t_0 = Math.sqrt((Math.pow((y - 0.275), 2.0) + Math.pow((x - 0.275), 2.0)));
return fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)), (Math.sqrt((Math.pow((y - 0.7), 2.0) + Math.pow((x - 0.775), 2.0))) - 0.075)), fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - t_0)), (t_0 - 0.275)));
}
def code(x, y): t_0 = math.sqrt((math.pow((y - 0.275), 2.0) + math.pow((x - 0.275), 2.0))) return fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)), (math.sqrt((math.pow((y - 0.7), 2.0) + math.pow((x - 0.775), 2.0))) - 0.075)), fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - t_0)), (t_0 - 0.275)))
function code(x, y) t_0 = sqrt(Float64((Float64(y - 0.275) ^ 2.0) + (Float64(x - 0.275) ^ 2.0))) return fmin(fmin(fmin(fmin(fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x)), Float64(sqrt(Float64((Float64(y - 0.7) ^ 2.0) + (Float64(x - 0.775) ^ 2.0))) - 0.075)), fmax(fmax(fmax(Float64(-y), Float64(y - 0.275)), Float64(x - 0.55)), Float64(0.45 - x))), fmax(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x))), fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - t_0)), Float64(t_0 - 0.275))) end
function tmp = code(x, y) t_0 = sqrt((((y - 0.275) ^ 2.0) + ((x - 0.275) ^ 2.0))); tmp = min(min(min(min(max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x)), (sqrt((((y - 0.7) ^ 2.0) + ((x - 0.775) ^ 2.0))) - 0.075)), max(max(max(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), max(max(max(-y, (y - 1.0)), (x - 0.1)), -x)), max(max(max(max(max((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - t_0)), (t_0 - 0.275))); end
code[x_, y_] := Block[{t$95$0 = N[Sqrt[N[(N[Power[N[(y - 0.275), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(x - 0.275), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Min[N[Min[N[Min[N[Min[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 0.825), $MachinePrecision]], $MachinePrecision], N[(0.725 - x), $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[N[(N[Power[N[(y - 0.7), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(x - 0.775), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.075), $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 0.275), $MachinePrecision]], $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 1.0), $MachinePrecision]], $MachinePrecision], N[(x - 0.1), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - t$95$0), $MachinePrecision]], $MachinePrecision], N[(t$95$0 - 0.275), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{{\left(y - 0.275\right)}^{2} + {\left(x - 0.275\right)}^{2}}\\
\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -y\right), x - 0.825\right), 0.725 - x\right), \sqrt{{\left(y - 0.7\right)}^{2} + {\left(x - 0.775\right)}^{2}} - 0.075\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 0.275\right), x - 0.55\right), 0.45 - x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, x - 0.55\right), -x\right), 0.275 - y\right), 0.175 - t\_0\right), t\_0 - 0.275\right)\right)
\end{array}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y)
:precision binary64
(let* ((t_0 (sqrt (+ (pow (- y 0.275) 2.0) (pow (- x 0.275) 2.0)))))
(fmin
(fmin
(fmin
(fmin
(fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x))
(- (sqrt (+ (pow (- y 0.7) 2.0) (pow (- x 0.775) 2.0))) 0.075))
(fmax (fmax (fmax (- y) (- y 0.275)) (- x 0.55)) (- 0.45 x)))
(fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x)))
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) (- x 0.55)) (- x)) (- 0.275 y))
(- 0.175 t_0))
(- t_0 0.275)))))
double code(double x, double y) {
double t_0 = sqrt((pow((y - 0.275), 2.0) + pow((x - 0.275), 2.0)));
return fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)), (sqrt((pow((y - 0.7), 2.0) + pow((x - 0.775), 2.0))) - 0.075)), fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - t_0)), (t_0 - 0.275)));
}
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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = sqrt((((y - 0.275d0) ** 2.0d0) + ((x - 0.275d0) ** 2.0d0)))
code = fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - x)), (sqrt((((y - 0.7d0) ** 2.0d0) + ((x - 0.775d0) ** 2.0d0))) - 0.075d0)), fmax(fmax(fmax(-y, (y - 0.275d0)), (x - 0.55d0)), (0.45d0 - x))), fmax(fmax(fmax(-y, (y - 1.0d0)), (x - 0.1d0)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (x - 0.55d0)), -x), (0.275d0 - y)), (0.175d0 - t_0)), (t_0 - 0.275d0)))
end function
public static double code(double x, double y) {
double t_0 = Math.sqrt((Math.pow((y - 0.275), 2.0) + Math.pow((x - 0.275), 2.0)));
return fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)), (Math.sqrt((Math.pow((y - 0.7), 2.0) + Math.pow((x - 0.775), 2.0))) - 0.075)), fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - t_0)), (t_0 - 0.275)));
}
def code(x, y): t_0 = math.sqrt((math.pow((y - 0.275), 2.0) + math.pow((x - 0.275), 2.0))) return fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)), (math.sqrt((math.pow((y - 0.7), 2.0) + math.pow((x - 0.775), 2.0))) - 0.075)), fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - t_0)), (t_0 - 0.275)))
function code(x, y) t_0 = sqrt(Float64((Float64(y - 0.275) ^ 2.0) + (Float64(x - 0.275) ^ 2.0))) return fmin(fmin(fmin(fmin(fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x)), Float64(sqrt(Float64((Float64(y - 0.7) ^ 2.0) + (Float64(x - 0.775) ^ 2.0))) - 0.075)), fmax(fmax(fmax(Float64(-y), Float64(y - 0.275)), Float64(x - 0.55)), Float64(0.45 - x))), fmax(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x))), fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - t_0)), Float64(t_0 - 0.275))) end
function tmp = code(x, y) t_0 = sqrt((((y - 0.275) ^ 2.0) + ((x - 0.275) ^ 2.0))); tmp = min(min(min(min(max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x)), (sqrt((((y - 0.7) ^ 2.0) + ((x - 0.775) ^ 2.0))) - 0.075)), max(max(max(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), max(max(max(-y, (y - 1.0)), (x - 0.1)), -x)), max(max(max(max(max((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - t_0)), (t_0 - 0.275))); end
code[x_, y_] := Block[{t$95$0 = N[Sqrt[N[(N[Power[N[(y - 0.275), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(x - 0.275), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Min[N[Min[N[Min[N[Min[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 0.825), $MachinePrecision]], $MachinePrecision], N[(0.725 - x), $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[N[(N[Power[N[(y - 0.7), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(x - 0.775), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.075), $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 0.275), $MachinePrecision]], $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 1.0), $MachinePrecision]], $MachinePrecision], N[(x - 0.1), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - t$95$0), $MachinePrecision]], $MachinePrecision], N[(t$95$0 - 0.275), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{{\left(y - 0.275\right)}^{2} + {\left(x - 0.275\right)}^{2}}\\
\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -y\right), x - 0.825\right), 0.725 - x\right), \sqrt{{\left(y - 0.7\right)}^{2} + {\left(x - 0.775\right)}^{2}} - 0.075\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 0.275\right), x - 0.55\right), 0.45 - x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, x - 0.55\right), -x\right), 0.275 - y\right), 0.175 - t\_0\right), t\_0 - 0.275\right)\right)
\end{array}
\end{array}
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (- 1.0 (/ 0.275 x)) x)))
(fmin
(fmin
(fmin
(fmin
(fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x))
(- (sqrt (+ (pow (- y 0.7) 2.0) (pow (- x 0.775) 2.0))) 0.075))
(fmax (fmax (fmax (- y) (- y 0.275)) (- x 0.55)) (- 0.45 x)))
(fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x)))
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) (- x 0.55)) (- x)) (- 0.275 y))
(- 0.175 t_0))
(- t_0 0.275)))))
double code(double x, double y) {
double t_0 = (1.0 - (0.275 / x)) * x;
return fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)), (sqrt((pow((y - 0.7), 2.0) + pow((x - 0.775), 2.0))) - 0.075)), fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - t_0)), (t_0 - 0.275)));
}
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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = (1.0d0 - (0.275d0 / x)) * x
code = fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - x)), (sqrt((((y - 0.7d0) ** 2.0d0) + ((x - 0.775d0) ** 2.0d0))) - 0.075d0)), fmax(fmax(fmax(-y, (y - 0.275d0)), (x - 0.55d0)), (0.45d0 - x))), fmax(fmax(fmax(-y, (y - 1.0d0)), (x - 0.1d0)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (x - 0.55d0)), -x), (0.275d0 - y)), (0.175d0 - t_0)), (t_0 - 0.275d0)))
end function
public static double code(double x, double y) {
double t_0 = (1.0 - (0.275 / x)) * x;
return fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)), (Math.sqrt((Math.pow((y - 0.7), 2.0) + Math.pow((x - 0.775), 2.0))) - 0.075)), fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - t_0)), (t_0 - 0.275)));
}
def code(x, y): t_0 = (1.0 - (0.275 / x)) * x return fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)), (math.sqrt((math.pow((y - 0.7), 2.0) + math.pow((x - 0.775), 2.0))) - 0.075)), fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - t_0)), (t_0 - 0.275)))
function code(x, y) t_0 = Float64(Float64(1.0 - Float64(0.275 / x)) * x) return fmin(fmin(fmin(fmin(fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x)), Float64(sqrt(Float64((Float64(y - 0.7) ^ 2.0) + (Float64(x - 0.775) ^ 2.0))) - 0.075)), fmax(fmax(fmax(Float64(-y), Float64(y - 0.275)), Float64(x - 0.55)), Float64(0.45 - x))), fmax(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x))), fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - t_0)), Float64(t_0 - 0.275))) end
function tmp = code(x, y) t_0 = (1.0 - (0.275 / x)) * x; tmp = min(min(min(min(max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x)), (sqrt((((y - 0.7) ^ 2.0) + ((x - 0.775) ^ 2.0))) - 0.075)), max(max(max(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), max(max(max(-y, (y - 1.0)), (x - 0.1)), -x)), max(max(max(max(max((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - t_0)), (t_0 - 0.275))); end
code[x_, y_] := Block[{t$95$0 = N[(N[(1.0 - N[(0.275 / x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]}, N[Min[N[Min[N[Min[N[Min[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 0.825), $MachinePrecision]], $MachinePrecision], N[(0.725 - x), $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[N[(N[Power[N[(y - 0.7), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(x - 0.775), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.075), $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 0.275), $MachinePrecision]], $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 1.0), $MachinePrecision]], $MachinePrecision], N[(x - 0.1), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - t$95$0), $MachinePrecision]], $MachinePrecision], N[(t$95$0 - 0.275), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - \frac{0.275}{x}\right) \cdot x\\
\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -y\right), x - 0.825\right), 0.725 - x\right), \sqrt{{\left(y - 0.7\right)}^{2} + {\left(x - 0.775\right)}^{2}} - 0.075\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 0.275\right), x - 0.55\right), 0.45 - x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, x - 0.55\right), -x\right), 0.275 - y\right), 0.175 - t\_0\right), t\_0 - 0.275\right)\right)
\end{array}
\end{array}
Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (hypot (- 0.275 x) (- 0.275 y))))
(fmin
(fmin
(fmin
(fmin
(fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x))
(- (hypot (- 0.775 x) (- 0.7 y)) 0.075))
(fmax (fmax (fmax (- y) (- y 0.275)) (- x 0.55)) (- 0.45 x)))
(fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x)))
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) (- x 0.55)) (- x)) (- 0.275 y))
(- 0.175 t_0))
(- t_0 0.275)))))
double code(double x, double y) {
double t_0 = hypot((0.275 - x), (0.275 - y));
return fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)), (hypot((0.775 - x), (0.7 - y)) - 0.075)), fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - t_0)), (t_0 - 0.275)));
}
public static double code(double x, double y) {
double t_0 = Math.hypot((0.275 - x), (0.275 - y));
return fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)), (Math.hypot((0.775 - x), (0.7 - y)) - 0.075)), fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - t_0)), (t_0 - 0.275)));
}
def code(x, y): t_0 = math.hypot((0.275 - x), (0.275 - y)) return fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)), (math.hypot((0.775 - x), (0.7 - y)) - 0.075)), fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - t_0)), (t_0 - 0.275)))
function code(x, y) t_0 = hypot(Float64(0.275 - x), Float64(0.275 - y)) return fmin(fmin(fmin(fmin(fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x)), Float64(hypot(Float64(0.775 - x), Float64(0.7 - y)) - 0.075)), fmax(fmax(fmax(Float64(-y), Float64(y - 0.275)), Float64(x - 0.55)), Float64(0.45 - x))), fmax(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x))), fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - t_0)), Float64(t_0 - 0.275))) end
function tmp = code(x, y) t_0 = hypot((0.275 - x), (0.275 - y)); tmp = min(min(min(min(max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x)), (hypot((0.775 - x), (0.7 - y)) - 0.075)), max(max(max(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), max(max(max(-y, (y - 1.0)), (x - 0.1)), -x)), max(max(max(max(max((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - t_0)), (t_0 - 0.275))); end
code[x_, y_] := Block[{t$95$0 = N[Sqrt[N[(0.275 - x), $MachinePrecision] ^ 2 + N[(0.275 - y), $MachinePrecision] ^ 2], $MachinePrecision]}, N[Min[N[Min[N[Min[N[Min[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 0.825), $MachinePrecision]], $MachinePrecision], N[(0.725 - x), $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[N[(0.775 - x), $MachinePrecision] ^ 2 + N[(0.7 - y), $MachinePrecision] ^ 2], $MachinePrecision] - 0.075), $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 0.275), $MachinePrecision]], $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 1.0), $MachinePrecision]], $MachinePrecision], N[(x - 0.1), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - t$95$0), $MachinePrecision]], $MachinePrecision], N[(t$95$0 - 0.275), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(0.275 - x, 0.275 - y\right)\\
\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -y\right), x - 0.825\right), 0.725 - x\right), \mathsf{hypot}\left(0.775 - x, 0.7 - y\right) - 0.075\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 0.275\right), x - 0.55\right), 0.45 - x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, x - 0.55\right), -x\right), 0.275 - y\right), 0.175 - t\_0\right), t\_0 - 0.275\right)\right)
\end{array}
\end{array}
Initial program 100.0%
Applied rewrites100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x)))
(t_1
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) (- x 0.55)) (- x)) (- 0.275 y))
(- 0.175 -0.275))
(- -0.275 0.275)))
(t_2 (fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x)))
(t_3 (fmin t_2 (- (sqrt (* y y)) 0.075)))
(t_4 (fmax (- y) (- y 0.275)))
(t_5 (fmax (fmax t_4 (- x 0.55)) (- 0.45 x))))
(if (<= y -3.4e+26)
(fmin
(fmin (fmin t_3 (fmax (fmax t_4 -0.55) (- 0.45 x))) t_0)
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) -0.55) (- x)) (- 0.275 y))
(- 0.175 -0.275))
(- -0.275 0.275)))
(if (<= y 9e+107)
(fmin
(fmin
(fmin (fmin t_2 (- (sqrt (fma (- x 1.55) x 1.090625)) 0.075)) t_5)
t_0)
t_1)
(fmin (fmin (fmin t_3 t_5) t_0) t_1)))))
double code(double x, double y) {
double t_0 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_1 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275));
double t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_3 = fmin(t_2, (sqrt((y * y)) - 0.075));
double t_4 = fmax(-y, (y - 0.275));
double t_5 = fmax(fmax(t_4, (x - 0.55)), (0.45 - x));
double tmp;
if (y <= -3.4e+26) {
tmp = fmin(fmin(fmin(t_3, fmax(fmax(t_4, -0.55), (0.45 - x))), t_0), fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)));
} else if (y <= 9e+107) {
tmp = fmin(fmin(fmin(fmin(t_2, (sqrt(fma((x - 1.55), x, 1.090625)) - 0.075)), t_5), t_0), t_1);
} else {
tmp = fmin(fmin(fmin(t_3, t_5), t_0), t_1);
}
return tmp;
}
function code(x, y) t_0 = fmax(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x)) t_1 = fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - -0.275)), Float64(-0.275 - 0.275)) t_2 = fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x)) t_3 = fmin(t_2, Float64(sqrt(Float64(y * y)) - 0.075)) t_4 = fmax(Float64(-y), Float64(y - 0.275)) t_5 = fmax(fmax(t_4, Float64(x - 0.55)), Float64(0.45 - x)) tmp = 0.0 if (y <= -3.4e+26) tmp = fmin(fmin(fmin(t_3, fmax(fmax(t_4, -0.55), Float64(0.45 - x))), t_0), fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), -0.55), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - -0.275)), Float64(-0.275 - 0.275))); elseif (y <= 9e+107) tmp = fmin(fmin(fmin(fmin(t_2, Float64(sqrt(fma(Float64(x - 1.55), x, 1.090625)) - 0.075)), t_5), t_0), t_1); else tmp = fmin(fmin(fmin(t_3, t_5), t_0), t_1); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[Max[N[Max[N[Max[(-y), N[(y - 1.0), $MachinePrecision]], $MachinePrecision], N[(x - 0.1), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - -0.275), $MachinePrecision]], $MachinePrecision], N[(-0.275 - 0.275), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 0.825), $MachinePrecision]], $MachinePrecision], N[(0.725 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Min[t$95$2, N[(N[Sqrt[N[(y * y), $MachinePrecision]], $MachinePrecision] - 0.075), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Max[(-y), N[(y - 0.275), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Max[N[Max[t$95$4, N[(x - 0.55), $MachinePrecision]], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, -3.4e+26], N[Min[N[Min[N[Min[t$95$3, N[Max[N[Max[t$95$4, -0.55], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$0], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], -0.55], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - -0.275), $MachinePrecision]], $MachinePrecision], N[(-0.275 - 0.275), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], If[LessEqual[y, 9e+107], N[Min[N[Min[N[Min[N[Min[t$95$2, N[(N[Sqrt[N[(N[(x - 1.55), $MachinePrecision] * x + 1.090625), $MachinePrecision]], $MachinePrecision] - 0.075), $MachinePrecision]], $MachinePrecision], t$95$5], $MachinePrecision], t$95$0], $MachinePrecision], t$95$1], $MachinePrecision], N[Min[N[Min[N[Min[t$95$3, t$95$5], $MachinePrecision], t$95$0], $MachinePrecision], t$95$1], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\\
t_1 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, x - 0.55\right), -x\right), 0.275 - y\right), 0.175 - -0.275\right), -0.275 - 0.275\right)\\
t_2 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -y\right), x - 0.825\right), 0.725 - x\right)\\
t_3 := \mathsf{min}\left(t\_2, \sqrt{y \cdot y} - 0.075\right)\\
t_4 := \mathsf{max}\left(-y, y - 0.275\right)\\
t_5 := \mathsf{max}\left(\mathsf{max}\left(t\_4, x - 0.55\right), 0.45 - x\right)\\
\mathbf{if}\;y \leq -3.4 \cdot 10^{+26}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_3, \mathsf{max}\left(\mathsf{max}\left(t\_4, -0.55\right), 0.45 - x\right)\right), t\_0\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -0.55\right), -x\right), 0.275 - y\right), 0.175 - -0.275\right), -0.275 - 0.275\right)\right)\\
\mathbf{elif}\;y \leq 9 \cdot 10^{+107}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_2, \sqrt{\mathsf{fma}\left(x - 1.55, x, 1.090625\right)} - 0.075\right), t\_5\right), t\_0\right), t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_3, t\_5\right), t\_0\right), t\_1\right)\\
\end{array}
\end{array}
if y < -3.4000000000000003e26Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
unpow2N/A
lower-*.f6442.6
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites41.0%
Taylor expanded in x around 0
Applied rewrites41.0%
if -3.4000000000000003e26 < y < 9e107Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in y around 0
lower-+.f64N/A
unpow-neg-2N/A
sub-negate-revN/A
pow2N/A
lower-*.f64N/A
lift--.f64N/A
lift--.f6467.1
Applied rewrites67.1%
Taylor expanded in x around 0
Applied rewrites67.1%
Taylor expanded in x around 0
Applied rewrites67.1%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6467.1
Applied rewrites67.1%
if 9e107 < y Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
unpow2N/A
lower-*.f6442.6
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites42.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x)))
(t_1
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) (- x 0.55)) (- x)) (- 0.275 y))
(- 0.175 -0.275))
(- -0.275 0.275)))
(t_2 (fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x)))
(t_3 (fmin t_2 (- (sqrt (* x x)) 0.075)))
(t_4 (fmax (- y) (- y 0.275)))
(t_5 (fmax (fmax t_4 (- x 0.55)) (- 0.45 x))))
(if (<= x -1.3e+26)
(fmin
(fmin (fmin t_3 (fmax (fmax t_4 -0.55) (- 0.45 x))) t_0)
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) -0.55) (- x)) (- 0.275 y))
(- 0.175 -0.275))
(- -0.275 0.275)))
(if (<= x 0.47)
(fmin
(fmin (fmin (fmin t_2 (* -1.0 (* y (- 1.0 (/ 0.625 y))))) t_5) t_0)
t_1)
(fmin (fmin (fmin t_3 t_5) t_0) t_1)))))
double code(double x, double y) {
double t_0 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_1 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275));
double t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_3 = fmin(t_2, (sqrt((x * x)) - 0.075));
double t_4 = fmax(-y, (y - 0.275));
double t_5 = fmax(fmax(t_4, (x - 0.55)), (0.45 - x));
double tmp;
if (x <= -1.3e+26) {
tmp = fmin(fmin(fmin(t_3, fmax(fmax(t_4, -0.55), (0.45 - x))), t_0), fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)));
} else if (x <= 0.47) {
tmp = fmin(fmin(fmin(fmin(t_2, (-1.0 * (y * (1.0 - (0.625 / y))))), t_5), t_0), t_1);
} else {
tmp = fmin(fmin(fmin(t_3, t_5), t_0), t_1);
}
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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = fmax(fmax(fmax(-y, (y - 1.0d0)), (x - 0.1d0)), -x)
t_1 = fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (x - 0.55d0)), -x), (0.275d0 - y)), (0.175d0 - (-0.275d0))), ((-0.275d0) - 0.275d0))
t_2 = fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - x))
t_3 = fmin(t_2, (sqrt((x * x)) - 0.075d0))
t_4 = fmax(-y, (y - 0.275d0))
t_5 = fmax(fmax(t_4, (x - 0.55d0)), (0.45d0 - x))
if (x <= (-1.3d+26)) then
tmp = fmin(fmin(fmin(t_3, fmax(fmax(t_4, (-0.55d0)), (0.45d0 - x))), t_0), fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (-0.55d0)), -x), (0.275d0 - y)), (0.175d0 - (-0.275d0))), ((-0.275d0) - 0.275d0)))
else if (x <= 0.47d0) then
tmp = fmin(fmin(fmin(fmin(t_2, ((-1.0d0) * (y * (1.0d0 - (0.625d0 / y))))), t_5), t_0), t_1)
else
tmp = fmin(fmin(fmin(t_3, t_5), t_0), t_1)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_1 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275));
double t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_3 = fmin(t_2, (Math.sqrt((x * x)) - 0.075));
double t_4 = fmax(-y, (y - 0.275));
double t_5 = fmax(fmax(t_4, (x - 0.55)), (0.45 - x));
double tmp;
if (x <= -1.3e+26) {
tmp = fmin(fmin(fmin(t_3, fmax(fmax(t_4, -0.55), (0.45 - x))), t_0), fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)));
} else if (x <= 0.47) {
tmp = fmin(fmin(fmin(fmin(t_2, (-1.0 * (y * (1.0 - (0.625 / y))))), t_5), t_0), t_1);
} else {
tmp = fmin(fmin(fmin(t_3, t_5), t_0), t_1);
}
return tmp;
}
def code(x, y): t_0 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x) t_1 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)) t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)) t_3 = fmin(t_2, (math.sqrt((x * x)) - 0.075)) t_4 = fmax(-y, (y - 0.275)) t_5 = fmax(fmax(t_4, (x - 0.55)), (0.45 - x)) tmp = 0 if x <= -1.3e+26: tmp = fmin(fmin(fmin(t_3, fmax(fmax(t_4, -0.55), (0.45 - x))), t_0), fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275))) elif x <= 0.47: tmp = fmin(fmin(fmin(fmin(t_2, (-1.0 * (y * (1.0 - (0.625 / y))))), t_5), t_0), t_1) else: tmp = fmin(fmin(fmin(t_3, t_5), t_0), t_1) return tmp
function code(x, y) t_0 = fmax(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x)) t_1 = fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - -0.275)), Float64(-0.275 - 0.275)) t_2 = fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x)) t_3 = fmin(t_2, Float64(sqrt(Float64(x * x)) - 0.075)) t_4 = fmax(Float64(-y), Float64(y - 0.275)) t_5 = fmax(fmax(t_4, Float64(x - 0.55)), Float64(0.45 - x)) tmp = 0.0 if (x <= -1.3e+26) tmp = fmin(fmin(fmin(t_3, fmax(fmax(t_4, -0.55), Float64(0.45 - x))), t_0), fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), -0.55), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - -0.275)), Float64(-0.275 - 0.275))); elseif (x <= 0.47) tmp = fmin(fmin(fmin(fmin(t_2, Float64(-1.0 * Float64(y * Float64(1.0 - Float64(0.625 / y))))), t_5), t_0), t_1); else tmp = fmin(fmin(fmin(t_3, t_5), t_0), t_1); end return tmp end
function tmp_2 = code(x, y) t_0 = max(max(max(-y, (y - 1.0)), (x - 0.1)), -x); t_1 = max(max(max(max(max((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)); t_2 = max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x)); t_3 = min(t_2, (sqrt((x * x)) - 0.075)); t_4 = max(-y, (y - 0.275)); t_5 = max(max(t_4, (x - 0.55)), (0.45 - x)); tmp = 0.0; if (x <= -1.3e+26) tmp = min(min(min(t_3, max(max(t_4, -0.55), (0.45 - x))), t_0), max(max(max(max(max((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275))); elseif (x <= 0.47) tmp = min(min(min(min(t_2, (-1.0 * (y * (1.0 - (0.625 / y))))), t_5), t_0), t_1); else tmp = min(min(min(t_3, t_5), t_0), t_1); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[N[Max[N[Max[(-y), N[(y - 1.0), $MachinePrecision]], $MachinePrecision], N[(x - 0.1), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - -0.275), $MachinePrecision]], $MachinePrecision], N[(-0.275 - 0.275), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 0.825), $MachinePrecision]], $MachinePrecision], N[(0.725 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Min[t$95$2, N[(N[Sqrt[N[(x * x), $MachinePrecision]], $MachinePrecision] - 0.075), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Max[(-y), N[(y - 0.275), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Max[N[Max[t$95$4, N[(x - 0.55), $MachinePrecision]], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.3e+26], N[Min[N[Min[N[Min[t$95$3, N[Max[N[Max[t$95$4, -0.55], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$0], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], -0.55], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - -0.275), $MachinePrecision]], $MachinePrecision], N[(-0.275 - 0.275), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 0.47], N[Min[N[Min[N[Min[N[Min[t$95$2, N[(-1.0 * N[(y * N[(1.0 - N[(0.625 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$5], $MachinePrecision], t$95$0], $MachinePrecision], t$95$1], $MachinePrecision], N[Min[N[Min[N[Min[t$95$3, t$95$5], $MachinePrecision], t$95$0], $MachinePrecision], t$95$1], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\\
t_1 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, x - 0.55\right), -x\right), 0.275 - y\right), 0.175 - -0.275\right), -0.275 - 0.275\right)\\
t_2 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -y\right), x - 0.825\right), 0.725 - x\right)\\
t_3 := \mathsf{min}\left(t\_2, \sqrt{x \cdot x} - 0.075\right)\\
t_4 := \mathsf{max}\left(-y, y - 0.275\right)\\
t_5 := \mathsf{max}\left(\mathsf{max}\left(t\_4, x - 0.55\right), 0.45 - x\right)\\
\mathbf{if}\;x \leq -1.3 \cdot 10^{+26}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_3, \mathsf{max}\left(\mathsf{max}\left(t\_4, -0.55\right), 0.45 - x\right)\right), t\_0\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -0.55\right), -x\right), 0.275 - y\right), 0.175 - -0.275\right), -0.275 - 0.275\right)\right)\\
\mathbf{elif}\;x \leq 0.47:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_2, -1 \cdot \left(y \cdot \left(1 - \frac{0.625}{y}\right)\right)\right), t\_5\right), t\_0\right), t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_3, t\_5\right), t\_0\right), t\_1\right)\\
\end{array}
\end{array}
if x < -1.30000000000000001e26Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
unpow2N/A
lower-*.f6441.4
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites23.5%
Taylor expanded in x around 0
Applied rewrites23.5%
if -1.30000000000000001e26 < x < 0.46999999999999997Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f6445.8
Applied rewrites45.8%
Taylor expanded in x around 0
Applied rewrites45.8%
Taylor expanded in x around 0
Applied rewrites45.8%
if 0.46999999999999997 < x Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
unpow2N/A
lower-*.f6441.4
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites41.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x)))
(t_1
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) (- x 0.55)) (- x)) (- 0.275 y))
(- 0.175 -0.275))
(- -0.275 0.275)))
(t_2 (fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x)))
(t_3 (fmax (- y) (- y 0.275)))
(t_4 (fmax (fmax t_3 (- x 0.55)) (- 0.45 x)))
(t_5 (fmin t_2 (- (sqrt (* x x)) 0.075)))
(t_6 (fmax (fmax t_3 -0.55) (- 0.45 x)))
(t_7
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) -0.55) (- x)) (- 0.275 y))
(- 0.175 -0.275))
(- -0.275 0.275)))
(t_8 (fmin t_2 (- (sqrt (* y y)) 0.075))))
(if (<= x -1.9e+26)
(fmin (fmin (fmin t_5 t_6) t_0) t_7)
(if (<= x -2.5e-10)
(fmin (fmin (fmin t_8 t_6) t_0) t_7)
(if (<= x 1.9e-277)
(fmin (fmin (fmin (fmin t_2 0.625) t_4) t_0) t_1)
(if (<= x 1.1e+87)
(fmin (fmin (fmin t_8 t_4) t_0) t_1)
(fmin (fmin (fmin t_5 t_4) t_0) t_1)))))))
double code(double x, double y) {
double t_0 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_1 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275));
double t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_3 = fmax(-y, (y - 0.275));
double t_4 = fmax(fmax(t_3, (x - 0.55)), (0.45 - x));
double t_5 = fmin(t_2, (sqrt((x * x)) - 0.075));
double t_6 = fmax(fmax(t_3, -0.55), (0.45 - x));
double t_7 = fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275));
double t_8 = fmin(t_2, (sqrt((y * y)) - 0.075));
double tmp;
if (x <= -1.9e+26) {
tmp = fmin(fmin(fmin(t_5, t_6), t_0), t_7);
} else if (x <= -2.5e-10) {
tmp = fmin(fmin(fmin(t_8, t_6), t_0), t_7);
} else if (x <= 1.9e-277) {
tmp = fmin(fmin(fmin(fmin(t_2, 0.625), t_4), t_0), t_1);
} else if (x <= 1.1e+87) {
tmp = fmin(fmin(fmin(t_8, t_4), t_0), t_1);
} else {
tmp = fmin(fmin(fmin(t_5, t_4), t_0), t_1);
}
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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: t_7
real(8) :: t_8
real(8) :: tmp
t_0 = fmax(fmax(fmax(-y, (y - 1.0d0)), (x - 0.1d0)), -x)
t_1 = fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (x - 0.55d0)), -x), (0.275d0 - y)), (0.175d0 - (-0.275d0))), ((-0.275d0) - 0.275d0))
t_2 = fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - x))
t_3 = fmax(-y, (y - 0.275d0))
t_4 = fmax(fmax(t_3, (x - 0.55d0)), (0.45d0 - x))
t_5 = fmin(t_2, (sqrt((x * x)) - 0.075d0))
t_6 = fmax(fmax(t_3, (-0.55d0)), (0.45d0 - x))
t_7 = fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (-0.55d0)), -x), (0.275d0 - y)), (0.175d0 - (-0.275d0))), ((-0.275d0) - 0.275d0))
t_8 = fmin(t_2, (sqrt((y * y)) - 0.075d0))
if (x <= (-1.9d+26)) then
tmp = fmin(fmin(fmin(t_5, t_6), t_0), t_7)
else if (x <= (-2.5d-10)) then
tmp = fmin(fmin(fmin(t_8, t_6), t_0), t_7)
else if (x <= 1.9d-277) then
tmp = fmin(fmin(fmin(fmin(t_2, 0.625d0), t_4), t_0), t_1)
else if (x <= 1.1d+87) then
tmp = fmin(fmin(fmin(t_8, t_4), t_0), t_1)
else
tmp = fmin(fmin(fmin(t_5, t_4), t_0), t_1)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_1 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275));
double t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_3 = fmax(-y, (y - 0.275));
double t_4 = fmax(fmax(t_3, (x - 0.55)), (0.45 - x));
double t_5 = fmin(t_2, (Math.sqrt((x * x)) - 0.075));
double t_6 = fmax(fmax(t_3, -0.55), (0.45 - x));
double t_7 = fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275));
double t_8 = fmin(t_2, (Math.sqrt((y * y)) - 0.075));
double tmp;
if (x <= -1.9e+26) {
tmp = fmin(fmin(fmin(t_5, t_6), t_0), t_7);
} else if (x <= -2.5e-10) {
tmp = fmin(fmin(fmin(t_8, t_6), t_0), t_7);
} else if (x <= 1.9e-277) {
tmp = fmin(fmin(fmin(fmin(t_2, 0.625), t_4), t_0), t_1);
} else if (x <= 1.1e+87) {
tmp = fmin(fmin(fmin(t_8, t_4), t_0), t_1);
} else {
tmp = fmin(fmin(fmin(t_5, t_4), t_0), t_1);
}
return tmp;
}
def code(x, y): t_0 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x) t_1 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)) t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)) t_3 = fmax(-y, (y - 0.275)) t_4 = fmax(fmax(t_3, (x - 0.55)), (0.45 - x)) t_5 = fmin(t_2, (math.sqrt((x * x)) - 0.075)) t_6 = fmax(fmax(t_3, -0.55), (0.45 - x)) t_7 = fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)) t_8 = fmin(t_2, (math.sqrt((y * y)) - 0.075)) tmp = 0 if x <= -1.9e+26: tmp = fmin(fmin(fmin(t_5, t_6), t_0), t_7) elif x <= -2.5e-10: tmp = fmin(fmin(fmin(t_8, t_6), t_0), t_7) elif x <= 1.9e-277: tmp = fmin(fmin(fmin(fmin(t_2, 0.625), t_4), t_0), t_1) elif x <= 1.1e+87: tmp = fmin(fmin(fmin(t_8, t_4), t_0), t_1) else: tmp = fmin(fmin(fmin(t_5, t_4), t_0), t_1) return tmp
function code(x, y) t_0 = fmax(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x)) t_1 = fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - -0.275)), Float64(-0.275 - 0.275)) t_2 = fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x)) t_3 = fmax(Float64(-y), Float64(y - 0.275)) t_4 = fmax(fmax(t_3, Float64(x - 0.55)), Float64(0.45 - x)) t_5 = fmin(t_2, Float64(sqrt(Float64(x * x)) - 0.075)) t_6 = fmax(fmax(t_3, -0.55), Float64(0.45 - x)) t_7 = fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), -0.55), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - -0.275)), Float64(-0.275 - 0.275)) t_8 = fmin(t_2, Float64(sqrt(Float64(y * y)) - 0.075)) tmp = 0.0 if (x <= -1.9e+26) tmp = fmin(fmin(fmin(t_5, t_6), t_0), t_7); elseif (x <= -2.5e-10) tmp = fmin(fmin(fmin(t_8, t_6), t_0), t_7); elseif (x <= 1.9e-277) tmp = fmin(fmin(fmin(fmin(t_2, 0.625), t_4), t_0), t_1); elseif (x <= 1.1e+87) tmp = fmin(fmin(fmin(t_8, t_4), t_0), t_1); else tmp = fmin(fmin(fmin(t_5, t_4), t_0), t_1); end return tmp end
function tmp_2 = code(x, y) t_0 = max(max(max(-y, (y - 1.0)), (x - 0.1)), -x); t_1 = max(max(max(max(max((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)); t_2 = max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x)); t_3 = max(-y, (y - 0.275)); t_4 = max(max(t_3, (x - 0.55)), (0.45 - x)); t_5 = min(t_2, (sqrt((x * x)) - 0.075)); t_6 = max(max(t_3, -0.55), (0.45 - x)); t_7 = max(max(max(max(max((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)); t_8 = min(t_2, (sqrt((y * y)) - 0.075)); tmp = 0.0; if (x <= -1.9e+26) tmp = min(min(min(t_5, t_6), t_0), t_7); elseif (x <= -2.5e-10) tmp = min(min(min(t_8, t_6), t_0), t_7); elseif (x <= 1.9e-277) tmp = min(min(min(min(t_2, 0.625), t_4), t_0), t_1); elseif (x <= 1.1e+87) tmp = min(min(min(t_8, t_4), t_0), t_1); else tmp = min(min(min(t_5, t_4), t_0), t_1); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[N[Max[N[Max[(-y), N[(y - 1.0), $MachinePrecision]], $MachinePrecision], N[(x - 0.1), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - -0.275), $MachinePrecision]], $MachinePrecision], N[(-0.275 - 0.275), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 0.825), $MachinePrecision]], $MachinePrecision], N[(0.725 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Max[(-y), N[(y - 0.275), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Max[N[Max[t$95$3, N[(x - 0.55), $MachinePrecision]], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Min[t$95$2, N[(N[Sqrt[N[(x * x), $MachinePrecision]], $MachinePrecision] - 0.075), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[Max[N[Max[t$95$3, -0.55], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$7 = N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], -0.55], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - -0.275), $MachinePrecision]], $MachinePrecision], N[(-0.275 - 0.275), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$8 = N[Min[t$95$2, N[(N[Sqrt[N[(y * y), $MachinePrecision]], $MachinePrecision] - 0.075), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.9e+26], N[Min[N[Min[N[Min[t$95$5, t$95$6], $MachinePrecision], t$95$0], $MachinePrecision], t$95$7], $MachinePrecision], If[LessEqual[x, -2.5e-10], N[Min[N[Min[N[Min[t$95$8, t$95$6], $MachinePrecision], t$95$0], $MachinePrecision], t$95$7], $MachinePrecision], If[LessEqual[x, 1.9e-277], N[Min[N[Min[N[Min[N[Min[t$95$2, 0.625], $MachinePrecision], t$95$4], $MachinePrecision], t$95$0], $MachinePrecision], t$95$1], $MachinePrecision], If[LessEqual[x, 1.1e+87], N[Min[N[Min[N[Min[t$95$8, t$95$4], $MachinePrecision], t$95$0], $MachinePrecision], t$95$1], $MachinePrecision], N[Min[N[Min[N[Min[t$95$5, t$95$4], $MachinePrecision], t$95$0], $MachinePrecision], t$95$1], $MachinePrecision]]]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\\
t_1 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, x - 0.55\right), -x\right), 0.275 - y\right), 0.175 - -0.275\right), -0.275 - 0.275\right)\\
t_2 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -y\right), x - 0.825\right), 0.725 - x\right)\\
t_3 := \mathsf{max}\left(-y, y - 0.275\right)\\
t_4 := \mathsf{max}\left(\mathsf{max}\left(t\_3, x - 0.55\right), 0.45 - x\right)\\
t_5 := \mathsf{min}\left(t\_2, \sqrt{x \cdot x} - 0.075\right)\\
t_6 := \mathsf{max}\left(\mathsf{max}\left(t\_3, -0.55\right), 0.45 - x\right)\\
t_7 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -0.55\right), -x\right), 0.275 - y\right), 0.175 - -0.275\right), -0.275 - 0.275\right)\\
t_8 := \mathsf{min}\left(t\_2, \sqrt{y \cdot y} - 0.075\right)\\
\mathbf{if}\;x \leq -1.9 \cdot 10^{+26}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_5, t\_6\right), t\_0\right), t\_7\right)\\
\mathbf{elif}\;x \leq -2.5 \cdot 10^{-10}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_8, t\_6\right), t\_0\right), t\_7\right)\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-277}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_2, 0.625\right), t\_4\right), t\_0\right), t\_1\right)\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+87}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_8, t\_4\right), t\_0\right), t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_5, t\_4\right), t\_0\right), t\_1\right)\\
\end{array}
\end{array}
if x < -1.9000000000000001e26Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
unpow2N/A
lower-*.f6441.4
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites23.5%
Taylor expanded in x around 0
Applied rewrites23.5%
if -1.9000000000000001e26 < x < -2.50000000000000016e-10Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
unpow2N/A
lower-*.f6442.6
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites41.0%
Taylor expanded in x around 0
Applied rewrites41.0%
if -2.50000000000000016e-10 < x < 1.89999999999999993e-277Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f6445.8
Applied rewrites45.8%
Taylor expanded in x around 0
Applied rewrites45.8%
Taylor expanded in x around 0
Applied rewrites45.8%
Taylor expanded in y around 0
Applied rewrites28.8%
if 1.89999999999999993e-277 < x < 1.1e87Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
unpow2N/A
lower-*.f6442.6
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites42.6%
if 1.1e87 < x Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
unpow2N/A
lower-*.f6441.4
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites41.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x)))
(t_1
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) (- x 0.55)) (- x)) (- 0.275 y))
(- 0.175 -0.275))
(- -0.275 0.275)))
(t_2 (fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x)))
(t_3 (fmax (- y) (- y 0.275)))
(t_4 (fmax (fmax t_3 (- x 0.55)) (- 0.45 x)))
(t_5 (fmin t_2 (- (sqrt (* x x)) 0.075)))
(t_6 (fmax (fmax t_3 -0.55) (- 0.45 x)))
(t_7
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) -0.55) (- x)) (- 0.275 y))
(- 0.175 -0.275))
(- -0.275 0.275)))
(t_8
(fmin (fmin (fmin (fmin t_2 (- (sqrt (* y y)) 0.075)) t_6) t_0) t_7)))
(if (<= x -1.9e+26)
(fmin (fmin (fmin t_5 t_6) t_0) t_7)
(if (<= x -2.5e-10)
t_8
(if (<= x 1.9e-277)
(fmin (fmin (fmin (fmin t_2 0.625) t_4) t_0) t_1)
(if (<= x 1.1e+87) t_8 (fmin (fmin (fmin t_5 t_4) t_0) t_1)))))))
double code(double x, double y) {
double t_0 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_1 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275));
double t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_3 = fmax(-y, (y - 0.275));
double t_4 = fmax(fmax(t_3, (x - 0.55)), (0.45 - x));
double t_5 = fmin(t_2, (sqrt((x * x)) - 0.075));
double t_6 = fmax(fmax(t_3, -0.55), (0.45 - x));
double t_7 = fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275));
double t_8 = fmin(fmin(fmin(fmin(t_2, (sqrt((y * y)) - 0.075)), t_6), t_0), t_7);
double tmp;
if (x <= -1.9e+26) {
tmp = fmin(fmin(fmin(t_5, t_6), t_0), t_7);
} else if (x <= -2.5e-10) {
tmp = t_8;
} else if (x <= 1.9e-277) {
tmp = fmin(fmin(fmin(fmin(t_2, 0.625), t_4), t_0), t_1);
} else if (x <= 1.1e+87) {
tmp = t_8;
} else {
tmp = fmin(fmin(fmin(t_5, t_4), t_0), t_1);
}
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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: t_7
real(8) :: t_8
real(8) :: tmp
t_0 = fmax(fmax(fmax(-y, (y - 1.0d0)), (x - 0.1d0)), -x)
t_1 = fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (x - 0.55d0)), -x), (0.275d0 - y)), (0.175d0 - (-0.275d0))), ((-0.275d0) - 0.275d0))
t_2 = fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - x))
t_3 = fmax(-y, (y - 0.275d0))
t_4 = fmax(fmax(t_3, (x - 0.55d0)), (0.45d0 - x))
t_5 = fmin(t_2, (sqrt((x * x)) - 0.075d0))
t_6 = fmax(fmax(t_3, (-0.55d0)), (0.45d0 - x))
t_7 = fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (-0.55d0)), -x), (0.275d0 - y)), (0.175d0 - (-0.275d0))), ((-0.275d0) - 0.275d0))
t_8 = fmin(fmin(fmin(fmin(t_2, (sqrt((y * y)) - 0.075d0)), t_6), t_0), t_7)
if (x <= (-1.9d+26)) then
tmp = fmin(fmin(fmin(t_5, t_6), t_0), t_7)
else if (x <= (-2.5d-10)) then
tmp = t_8
else if (x <= 1.9d-277) then
tmp = fmin(fmin(fmin(fmin(t_2, 0.625d0), t_4), t_0), t_1)
else if (x <= 1.1d+87) then
tmp = t_8
else
tmp = fmin(fmin(fmin(t_5, t_4), t_0), t_1)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_1 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275));
double t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_3 = fmax(-y, (y - 0.275));
double t_4 = fmax(fmax(t_3, (x - 0.55)), (0.45 - x));
double t_5 = fmin(t_2, (Math.sqrt((x * x)) - 0.075));
double t_6 = fmax(fmax(t_3, -0.55), (0.45 - x));
double t_7 = fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275));
double t_8 = fmin(fmin(fmin(fmin(t_2, (Math.sqrt((y * y)) - 0.075)), t_6), t_0), t_7);
double tmp;
if (x <= -1.9e+26) {
tmp = fmin(fmin(fmin(t_5, t_6), t_0), t_7);
} else if (x <= -2.5e-10) {
tmp = t_8;
} else if (x <= 1.9e-277) {
tmp = fmin(fmin(fmin(fmin(t_2, 0.625), t_4), t_0), t_1);
} else if (x <= 1.1e+87) {
tmp = t_8;
} else {
tmp = fmin(fmin(fmin(t_5, t_4), t_0), t_1);
}
return tmp;
}
def code(x, y): t_0 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x) t_1 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)) t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)) t_3 = fmax(-y, (y - 0.275)) t_4 = fmax(fmax(t_3, (x - 0.55)), (0.45 - x)) t_5 = fmin(t_2, (math.sqrt((x * x)) - 0.075)) t_6 = fmax(fmax(t_3, -0.55), (0.45 - x)) t_7 = fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)) t_8 = fmin(fmin(fmin(fmin(t_2, (math.sqrt((y * y)) - 0.075)), t_6), t_0), t_7) tmp = 0 if x <= -1.9e+26: tmp = fmin(fmin(fmin(t_5, t_6), t_0), t_7) elif x <= -2.5e-10: tmp = t_8 elif x <= 1.9e-277: tmp = fmin(fmin(fmin(fmin(t_2, 0.625), t_4), t_0), t_1) elif x <= 1.1e+87: tmp = t_8 else: tmp = fmin(fmin(fmin(t_5, t_4), t_0), t_1) return tmp
function code(x, y) t_0 = fmax(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x)) t_1 = fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - -0.275)), Float64(-0.275 - 0.275)) t_2 = fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x)) t_3 = fmax(Float64(-y), Float64(y - 0.275)) t_4 = fmax(fmax(t_3, Float64(x - 0.55)), Float64(0.45 - x)) t_5 = fmin(t_2, Float64(sqrt(Float64(x * x)) - 0.075)) t_6 = fmax(fmax(t_3, -0.55), Float64(0.45 - x)) t_7 = fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), -0.55), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - -0.275)), Float64(-0.275 - 0.275)) t_8 = fmin(fmin(fmin(fmin(t_2, Float64(sqrt(Float64(y * y)) - 0.075)), t_6), t_0), t_7) tmp = 0.0 if (x <= -1.9e+26) tmp = fmin(fmin(fmin(t_5, t_6), t_0), t_7); elseif (x <= -2.5e-10) tmp = t_8; elseif (x <= 1.9e-277) tmp = fmin(fmin(fmin(fmin(t_2, 0.625), t_4), t_0), t_1); elseif (x <= 1.1e+87) tmp = t_8; else tmp = fmin(fmin(fmin(t_5, t_4), t_0), t_1); end return tmp end
function tmp_2 = code(x, y) t_0 = max(max(max(-y, (y - 1.0)), (x - 0.1)), -x); t_1 = max(max(max(max(max((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)); t_2 = max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x)); t_3 = max(-y, (y - 0.275)); t_4 = max(max(t_3, (x - 0.55)), (0.45 - x)); t_5 = min(t_2, (sqrt((x * x)) - 0.075)); t_6 = max(max(t_3, -0.55), (0.45 - x)); t_7 = max(max(max(max(max((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)); t_8 = min(min(min(min(t_2, (sqrt((y * y)) - 0.075)), t_6), t_0), t_7); tmp = 0.0; if (x <= -1.9e+26) tmp = min(min(min(t_5, t_6), t_0), t_7); elseif (x <= -2.5e-10) tmp = t_8; elseif (x <= 1.9e-277) tmp = min(min(min(min(t_2, 0.625), t_4), t_0), t_1); elseif (x <= 1.1e+87) tmp = t_8; else tmp = min(min(min(t_5, t_4), t_0), t_1); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[N[Max[N[Max[(-y), N[(y - 1.0), $MachinePrecision]], $MachinePrecision], N[(x - 0.1), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - -0.275), $MachinePrecision]], $MachinePrecision], N[(-0.275 - 0.275), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 0.825), $MachinePrecision]], $MachinePrecision], N[(0.725 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Max[(-y), N[(y - 0.275), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Max[N[Max[t$95$3, N[(x - 0.55), $MachinePrecision]], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Min[t$95$2, N[(N[Sqrt[N[(x * x), $MachinePrecision]], $MachinePrecision] - 0.075), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[Max[N[Max[t$95$3, -0.55], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$7 = N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], -0.55], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - -0.275), $MachinePrecision]], $MachinePrecision], N[(-0.275 - 0.275), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$8 = N[Min[N[Min[N[Min[N[Min[t$95$2, N[(N[Sqrt[N[(y * y), $MachinePrecision]], $MachinePrecision] - 0.075), $MachinePrecision]], $MachinePrecision], t$95$6], $MachinePrecision], t$95$0], $MachinePrecision], t$95$7], $MachinePrecision]}, If[LessEqual[x, -1.9e+26], N[Min[N[Min[N[Min[t$95$5, t$95$6], $MachinePrecision], t$95$0], $MachinePrecision], t$95$7], $MachinePrecision], If[LessEqual[x, -2.5e-10], t$95$8, If[LessEqual[x, 1.9e-277], N[Min[N[Min[N[Min[N[Min[t$95$2, 0.625], $MachinePrecision], t$95$4], $MachinePrecision], t$95$0], $MachinePrecision], t$95$1], $MachinePrecision], If[LessEqual[x, 1.1e+87], t$95$8, N[Min[N[Min[N[Min[t$95$5, t$95$4], $MachinePrecision], t$95$0], $MachinePrecision], t$95$1], $MachinePrecision]]]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\\
t_1 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, x - 0.55\right), -x\right), 0.275 - y\right), 0.175 - -0.275\right), -0.275 - 0.275\right)\\
t_2 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -y\right), x - 0.825\right), 0.725 - x\right)\\
t_3 := \mathsf{max}\left(-y, y - 0.275\right)\\
t_4 := \mathsf{max}\left(\mathsf{max}\left(t\_3, x - 0.55\right), 0.45 - x\right)\\
t_5 := \mathsf{min}\left(t\_2, \sqrt{x \cdot x} - 0.075\right)\\
t_6 := \mathsf{max}\left(\mathsf{max}\left(t\_3, -0.55\right), 0.45 - x\right)\\
t_7 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -0.55\right), -x\right), 0.275 - y\right), 0.175 - -0.275\right), -0.275 - 0.275\right)\\
t_8 := \mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_2, \sqrt{y \cdot y} - 0.075\right), t\_6\right), t\_0\right), t\_7\right)\\
\mathbf{if}\;x \leq -1.9 \cdot 10^{+26}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_5, t\_6\right), t\_0\right), t\_7\right)\\
\mathbf{elif}\;x \leq -2.5 \cdot 10^{-10}:\\
\;\;\;\;t\_8\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-277}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_2, 0.625\right), t\_4\right), t\_0\right), t\_1\right)\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+87}:\\
\;\;\;\;t\_8\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_5, t\_4\right), t\_0\right), t\_1\right)\\
\end{array}
\end{array}
if x < -1.9000000000000001e26Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
unpow2N/A
lower-*.f6441.4
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites23.5%
Taylor expanded in x around 0
Applied rewrites23.5%
if -1.9000000000000001e26 < x < -2.50000000000000016e-10 or 1.89999999999999993e-277 < x < 1.1e87Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
unpow2N/A
lower-*.f6442.6
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites41.0%
Taylor expanded in x around 0
Applied rewrites41.0%
if -2.50000000000000016e-10 < x < 1.89999999999999993e-277Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f6445.8
Applied rewrites45.8%
Taylor expanded in x around 0
Applied rewrites45.8%
Taylor expanded in x around 0
Applied rewrites45.8%
Taylor expanded in y around 0
Applied rewrites28.8%
if 1.1e87 < x Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
unpow2N/A
lower-*.f6441.4
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites41.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x)))
(t_1
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) (- x 0.55)) (- x)) (- 0.275 y))
(- 0.175 -0.275))
(- -0.275 0.275)))
(t_2 (fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x)))
(t_3 (fmax (- y) (- y 0.275)))
(t_4 (fmax (fmax t_3 (- x 0.55)) (- 0.45 x)))
(t_5 (fmax (fmax t_3 -0.55) (- 0.45 x)))
(t_6
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) -0.55) (- x)) (- 0.275 y))
(- 0.175 -0.275))
(- -0.275 0.275)))
(t_7
(fmin (fmin (fmin (fmin t_2 (- (sqrt (* y y)) 0.075)) t_5) t_0) t_6)))
(if (<= x -1.9e+26)
(fmin (fmin (fmin (fmin t_2 (- (sqrt (* x x)) 0.075)) t_5) t_0) t_6)
(if (<= x -2.5e-10)
t_7
(if (<= x 1.9e-277)
(fmin (fmin (fmin (fmin t_2 0.625) t_4) t_0) t_1)
(if (<= x 1.1e+87)
t_7
(fmin (fmin (fmin (fmin t_2 (- x 0.85)) t_4) t_0) t_1)))))))
double code(double x, double y) {
double t_0 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_1 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275));
double t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_3 = fmax(-y, (y - 0.275));
double t_4 = fmax(fmax(t_3, (x - 0.55)), (0.45 - x));
double t_5 = fmax(fmax(t_3, -0.55), (0.45 - x));
double t_6 = fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275));
double t_7 = fmin(fmin(fmin(fmin(t_2, (sqrt((y * y)) - 0.075)), t_5), t_0), t_6);
double tmp;
if (x <= -1.9e+26) {
tmp = fmin(fmin(fmin(fmin(t_2, (sqrt((x * x)) - 0.075)), t_5), t_0), t_6);
} else if (x <= -2.5e-10) {
tmp = t_7;
} else if (x <= 1.9e-277) {
tmp = fmin(fmin(fmin(fmin(t_2, 0.625), t_4), t_0), t_1);
} else if (x <= 1.1e+87) {
tmp = t_7;
} else {
tmp = fmin(fmin(fmin(fmin(t_2, (x - 0.85)), t_4), t_0), t_1);
}
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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: t_7
real(8) :: tmp
t_0 = fmax(fmax(fmax(-y, (y - 1.0d0)), (x - 0.1d0)), -x)
t_1 = fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (x - 0.55d0)), -x), (0.275d0 - y)), (0.175d0 - (-0.275d0))), ((-0.275d0) - 0.275d0))
t_2 = fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - x))
t_3 = fmax(-y, (y - 0.275d0))
t_4 = fmax(fmax(t_3, (x - 0.55d0)), (0.45d0 - x))
t_5 = fmax(fmax(t_3, (-0.55d0)), (0.45d0 - x))
t_6 = fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (-0.55d0)), -x), (0.275d0 - y)), (0.175d0 - (-0.275d0))), ((-0.275d0) - 0.275d0))
t_7 = fmin(fmin(fmin(fmin(t_2, (sqrt((y * y)) - 0.075d0)), t_5), t_0), t_6)
if (x <= (-1.9d+26)) then
tmp = fmin(fmin(fmin(fmin(t_2, (sqrt((x * x)) - 0.075d0)), t_5), t_0), t_6)
else if (x <= (-2.5d-10)) then
tmp = t_7
else if (x <= 1.9d-277) then
tmp = fmin(fmin(fmin(fmin(t_2, 0.625d0), t_4), t_0), t_1)
else if (x <= 1.1d+87) then
tmp = t_7
else
tmp = fmin(fmin(fmin(fmin(t_2, (x - 0.85d0)), t_4), t_0), t_1)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_1 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275));
double t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_3 = fmax(-y, (y - 0.275));
double t_4 = fmax(fmax(t_3, (x - 0.55)), (0.45 - x));
double t_5 = fmax(fmax(t_3, -0.55), (0.45 - x));
double t_6 = fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275));
double t_7 = fmin(fmin(fmin(fmin(t_2, (Math.sqrt((y * y)) - 0.075)), t_5), t_0), t_6);
double tmp;
if (x <= -1.9e+26) {
tmp = fmin(fmin(fmin(fmin(t_2, (Math.sqrt((x * x)) - 0.075)), t_5), t_0), t_6);
} else if (x <= -2.5e-10) {
tmp = t_7;
} else if (x <= 1.9e-277) {
tmp = fmin(fmin(fmin(fmin(t_2, 0.625), t_4), t_0), t_1);
} else if (x <= 1.1e+87) {
tmp = t_7;
} else {
tmp = fmin(fmin(fmin(fmin(t_2, (x - 0.85)), t_4), t_0), t_1);
}
return tmp;
}
def code(x, y): t_0 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x) t_1 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)) t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)) t_3 = fmax(-y, (y - 0.275)) t_4 = fmax(fmax(t_3, (x - 0.55)), (0.45 - x)) t_5 = fmax(fmax(t_3, -0.55), (0.45 - x)) t_6 = fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)) t_7 = fmin(fmin(fmin(fmin(t_2, (math.sqrt((y * y)) - 0.075)), t_5), t_0), t_6) tmp = 0 if x <= -1.9e+26: tmp = fmin(fmin(fmin(fmin(t_2, (math.sqrt((x * x)) - 0.075)), t_5), t_0), t_6) elif x <= -2.5e-10: tmp = t_7 elif x <= 1.9e-277: tmp = fmin(fmin(fmin(fmin(t_2, 0.625), t_4), t_0), t_1) elif x <= 1.1e+87: tmp = t_7 else: tmp = fmin(fmin(fmin(fmin(t_2, (x - 0.85)), t_4), t_0), t_1) return tmp
function code(x, y) t_0 = fmax(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x)) t_1 = fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - -0.275)), Float64(-0.275 - 0.275)) t_2 = fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x)) t_3 = fmax(Float64(-y), Float64(y - 0.275)) t_4 = fmax(fmax(t_3, Float64(x - 0.55)), Float64(0.45 - x)) t_5 = fmax(fmax(t_3, -0.55), Float64(0.45 - x)) t_6 = fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), -0.55), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - -0.275)), Float64(-0.275 - 0.275)) t_7 = fmin(fmin(fmin(fmin(t_2, Float64(sqrt(Float64(y * y)) - 0.075)), t_5), t_0), t_6) tmp = 0.0 if (x <= -1.9e+26) tmp = fmin(fmin(fmin(fmin(t_2, Float64(sqrt(Float64(x * x)) - 0.075)), t_5), t_0), t_6); elseif (x <= -2.5e-10) tmp = t_7; elseif (x <= 1.9e-277) tmp = fmin(fmin(fmin(fmin(t_2, 0.625), t_4), t_0), t_1); elseif (x <= 1.1e+87) tmp = t_7; else tmp = fmin(fmin(fmin(fmin(t_2, Float64(x - 0.85)), t_4), t_0), t_1); end return tmp end
function tmp_2 = code(x, y) t_0 = max(max(max(-y, (y - 1.0)), (x - 0.1)), -x); t_1 = max(max(max(max(max((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)); t_2 = max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x)); t_3 = max(-y, (y - 0.275)); t_4 = max(max(t_3, (x - 0.55)), (0.45 - x)); t_5 = max(max(t_3, -0.55), (0.45 - x)); t_6 = max(max(max(max(max((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)); t_7 = min(min(min(min(t_2, (sqrt((y * y)) - 0.075)), t_5), t_0), t_6); tmp = 0.0; if (x <= -1.9e+26) tmp = min(min(min(min(t_2, (sqrt((x * x)) - 0.075)), t_5), t_0), t_6); elseif (x <= -2.5e-10) tmp = t_7; elseif (x <= 1.9e-277) tmp = min(min(min(min(t_2, 0.625), t_4), t_0), t_1); elseif (x <= 1.1e+87) tmp = t_7; else tmp = min(min(min(min(t_2, (x - 0.85)), t_4), t_0), t_1); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[N[Max[N[Max[(-y), N[(y - 1.0), $MachinePrecision]], $MachinePrecision], N[(x - 0.1), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - -0.275), $MachinePrecision]], $MachinePrecision], N[(-0.275 - 0.275), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 0.825), $MachinePrecision]], $MachinePrecision], N[(0.725 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Max[(-y), N[(y - 0.275), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Max[N[Max[t$95$3, N[(x - 0.55), $MachinePrecision]], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Max[N[Max[t$95$3, -0.55], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], -0.55], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - -0.275), $MachinePrecision]], $MachinePrecision], N[(-0.275 - 0.275), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$7 = N[Min[N[Min[N[Min[N[Min[t$95$2, N[(N[Sqrt[N[(y * y), $MachinePrecision]], $MachinePrecision] - 0.075), $MachinePrecision]], $MachinePrecision], t$95$5], $MachinePrecision], t$95$0], $MachinePrecision], t$95$6], $MachinePrecision]}, If[LessEqual[x, -1.9e+26], N[Min[N[Min[N[Min[N[Min[t$95$2, N[(N[Sqrt[N[(x * x), $MachinePrecision]], $MachinePrecision] - 0.075), $MachinePrecision]], $MachinePrecision], t$95$5], $MachinePrecision], t$95$0], $MachinePrecision], t$95$6], $MachinePrecision], If[LessEqual[x, -2.5e-10], t$95$7, If[LessEqual[x, 1.9e-277], N[Min[N[Min[N[Min[N[Min[t$95$2, 0.625], $MachinePrecision], t$95$4], $MachinePrecision], t$95$0], $MachinePrecision], t$95$1], $MachinePrecision], If[LessEqual[x, 1.1e+87], t$95$7, N[Min[N[Min[N[Min[N[Min[t$95$2, N[(x - 0.85), $MachinePrecision]], $MachinePrecision], t$95$4], $MachinePrecision], t$95$0], $MachinePrecision], t$95$1], $MachinePrecision]]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\\
t_1 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, x - 0.55\right), -x\right), 0.275 - y\right), 0.175 - -0.275\right), -0.275 - 0.275\right)\\
t_2 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -y\right), x - 0.825\right), 0.725 - x\right)\\
t_3 := \mathsf{max}\left(-y, y - 0.275\right)\\
t_4 := \mathsf{max}\left(\mathsf{max}\left(t\_3, x - 0.55\right), 0.45 - x\right)\\
t_5 := \mathsf{max}\left(\mathsf{max}\left(t\_3, -0.55\right), 0.45 - x\right)\\
t_6 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -0.55\right), -x\right), 0.275 - y\right), 0.175 - -0.275\right), -0.275 - 0.275\right)\\
t_7 := \mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_2, \sqrt{y \cdot y} - 0.075\right), t\_5\right), t\_0\right), t\_6\right)\\
\mathbf{if}\;x \leq -1.9 \cdot 10^{+26}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_2, \sqrt{x \cdot x} - 0.075\right), t\_5\right), t\_0\right), t\_6\right)\\
\mathbf{elif}\;x \leq -2.5 \cdot 10^{-10}:\\
\;\;\;\;t\_7\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-277}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_2, 0.625\right), t\_4\right), t\_0\right), t\_1\right)\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+87}:\\
\;\;\;\;t\_7\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_2, x - 0.85\right), t\_4\right), t\_0\right), t\_1\right)\\
\end{array}
\end{array}
if x < -1.9000000000000001e26Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
unpow2N/A
lower-*.f6441.4
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites23.5%
Taylor expanded in x around 0
Applied rewrites23.5%
if -1.9000000000000001e26 < x < -2.50000000000000016e-10 or 1.89999999999999993e-277 < x < 1.1e87Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
unpow2N/A
lower-*.f6442.6
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites41.0%
Taylor expanded in x around 0
Applied rewrites41.0%
if -2.50000000000000016e-10 < x < 1.89999999999999993e-277Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f6445.8
Applied rewrites45.8%
Taylor expanded in x around 0
Applied rewrites45.8%
Taylor expanded in x around 0
Applied rewrites45.8%
Taylor expanded in y around 0
Applied rewrites28.8%
if 1.1e87 < x Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f6420.1
Applied rewrites20.1%
Taylor expanded in x around 0
Applied rewrites20.1%
Taylor expanded in x around 0
Applied rewrites20.1%
Taylor expanded in x around 0
lower--.f6420.1
Applied rewrites20.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x)))
(t_1 (fmax (- y) (- y 0.275)))
(t_2 (fmax (fmax t_1 (- x 0.55)) (- 0.45 x)))
(t_3 (fmax (fmax (fmax (- y 0.55) (- x 0.55)) (- x)) (- 0.275 y)))
(t_4 (fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x)))
(t_5 (sqrt (+ (pow (- y 0.275) 2.0) (pow (- x 0.275) 2.0)))))
(if (<=
(fmin
(fmin
(fmin
(fmin
t_0
(- (sqrt (+ (pow (- y 0.7) 2.0) (pow (- x 0.775) 2.0))) 0.075))
t_2)
t_4)
(fmax (fmax t_3 (- 0.175 t_5)) (- t_5 0.275)))
0.5)
(fmin
(fmin (fmin (fmin t_0 0.625) t_2) t_4)
(fmax (fmax t_3 (- 0.175 -0.275)) (- -0.275 0.275)))
(fmin
(fmin
(fmin
(fmin t_0 (- (sqrt (* y y)) 0.075))
(fmax (fmax t_1 -0.55) (- 0.45 x)))
t_4)
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) -0.55) (- x)) (- 0.275 y))
(- 0.175 -0.275))
(- -0.275 0.275))))))
double code(double x, double y) {
double t_0 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_1 = fmax(-y, (y - 0.275));
double t_2 = fmax(fmax(t_1, (x - 0.55)), (0.45 - x));
double t_3 = fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y));
double t_4 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_5 = sqrt((pow((y - 0.275), 2.0) + pow((x - 0.275), 2.0)));
double tmp;
if (fmin(fmin(fmin(fmin(t_0, (sqrt((pow((y - 0.7), 2.0) + pow((x - 0.775), 2.0))) - 0.075)), t_2), t_4), fmax(fmax(t_3, (0.175 - t_5)), (t_5 - 0.275))) <= 0.5) {
tmp = fmin(fmin(fmin(fmin(t_0, 0.625), t_2), t_4), fmax(fmax(t_3, (0.175 - -0.275)), (-0.275 - 0.275)));
} else {
tmp = fmin(fmin(fmin(fmin(t_0, (sqrt((y * y)) - 0.075)), fmax(fmax(t_1, -0.55), (0.45 - x))), t_4), fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)));
}
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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - x))
t_1 = fmax(-y, (y - 0.275d0))
t_2 = fmax(fmax(t_1, (x - 0.55d0)), (0.45d0 - x))
t_3 = fmax(fmax(fmax((y - 0.55d0), (x - 0.55d0)), -x), (0.275d0 - y))
t_4 = fmax(fmax(fmax(-y, (y - 1.0d0)), (x - 0.1d0)), -x)
t_5 = sqrt((((y - 0.275d0) ** 2.0d0) + ((x - 0.275d0) ** 2.0d0)))
if (fmin(fmin(fmin(fmin(t_0, (sqrt((((y - 0.7d0) ** 2.0d0) + ((x - 0.775d0) ** 2.0d0))) - 0.075d0)), t_2), t_4), fmax(fmax(t_3, (0.175d0 - t_5)), (t_5 - 0.275d0))) <= 0.5d0) then
tmp = fmin(fmin(fmin(fmin(t_0, 0.625d0), t_2), t_4), fmax(fmax(t_3, (0.175d0 - (-0.275d0))), ((-0.275d0) - 0.275d0)))
else
tmp = fmin(fmin(fmin(fmin(t_0, (sqrt((y * y)) - 0.075d0)), fmax(fmax(t_1, (-0.55d0)), (0.45d0 - x))), t_4), fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (-0.55d0)), -x), (0.275d0 - y)), (0.175d0 - (-0.275d0))), ((-0.275d0) - 0.275d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_1 = fmax(-y, (y - 0.275));
double t_2 = fmax(fmax(t_1, (x - 0.55)), (0.45 - x));
double t_3 = fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y));
double t_4 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_5 = Math.sqrt((Math.pow((y - 0.275), 2.0) + Math.pow((x - 0.275), 2.0)));
double tmp;
if (fmin(fmin(fmin(fmin(t_0, (Math.sqrt((Math.pow((y - 0.7), 2.0) + Math.pow((x - 0.775), 2.0))) - 0.075)), t_2), t_4), fmax(fmax(t_3, (0.175 - t_5)), (t_5 - 0.275))) <= 0.5) {
tmp = fmin(fmin(fmin(fmin(t_0, 0.625), t_2), t_4), fmax(fmax(t_3, (0.175 - -0.275)), (-0.275 - 0.275)));
} else {
tmp = fmin(fmin(fmin(fmin(t_0, (Math.sqrt((y * y)) - 0.075)), fmax(fmax(t_1, -0.55), (0.45 - x))), t_4), fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)));
}
return tmp;
}
def code(x, y): t_0 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)) t_1 = fmax(-y, (y - 0.275)) t_2 = fmax(fmax(t_1, (x - 0.55)), (0.45 - x)) t_3 = fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)) t_4 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x) t_5 = math.sqrt((math.pow((y - 0.275), 2.0) + math.pow((x - 0.275), 2.0))) tmp = 0 if fmin(fmin(fmin(fmin(t_0, (math.sqrt((math.pow((y - 0.7), 2.0) + math.pow((x - 0.775), 2.0))) - 0.075)), t_2), t_4), fmax(fmax(t_3, (0.175 - t_5)), (t_5 - 0.275))) <= 0.5: tmp = fmin(fmin(fmin(fmin(t_0, 0.625), t_2), t_4), fmax(fmax(t_3, (0.175 - -0.275)), (-0.275 - 0.275))) else: tmp = fmin(fmin(fmin(fmin(t_0, (math.sqrt((y * y)) - 0.075)), fmax(fmax(t_1, -0.55), (0.45 - x))), t_4), fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275))) return tmp
function code(x, y) t_0 = fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x)) t_1 = fmax(Float64(-y), Float64(y - 0.275)) t_2 = fmax(fmax(t_1, Float64(x - 0.55)), Float64(0.45 - x)) t_3 = fmax(fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)), Float64(0.275 - y)) t_4 = fmax(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x)) t_5 = sqrt(Float64((Float64(y - 0.275) ^ 2.0) + (Float64(x - 0.275) ^ 2.0))) tmp = 0.0 if (fmin(fmin(fmin(fmin(t_0, Float64(sqrt(Float64((Float64(y - 0.7) ^ 2.0) + (Float64(x - 0.775) ^ 2.0))) - 0.075)), t_2), t_4), fmax(fmax(t_3, Float64(0.175 - t_5)), Float64(t_5 - 0.275))) <= 0.5) tmp = fmin(fmin(fmin(fmin(t_0, 0.625), t_2), t_4), fmax(fmax(t_3, Float64(0.175 - -0.275)), Float64(-0.275 - 0.275))); else tmp = fmin(fmin(fmin(fmin(t_0, Float64(sqrt(Float64(y * y)) - 0.075)), fmax(fmax(t_1, -0.55), Float64(0.45 - x))), t_4), fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), -0.55), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - -0.275)), Float64(-0.275 - 0.275))); end return tmp end
function tmp_2 = code(x, y) t_0 = max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x)); t_1 = max(-y, (y - 0.275)); t_2 = max(max(t_1, (x - 0.55)), (0.45 - x)); t_3 = max(max(max((y - 0.55), (x - 0.55)), -x), (0.275 - y)); t_4 = max(max(max(-y, (y - 1.0)), (x - 0.1)), -x); t_5 = sqrt((((y - 0.275) ^ 2.0) + ((x - 0.275) ^ 2.0))); tmp = 0.0; if (min(min(min(min(t_0, (sqrt((((y - 0.7) ^ 2.0) + ((x - 0.775) ^ 2.0))) - 0.075)), t_2), t_4), max(max(t_3, (0.175 - t_5)), (t_5 - 0.275))) <= 0.5) tmp = min(min(min(min(t_0, 0.625), t_2), t_4), max(max(t_3, (0.175 - -0.275)), (-0.275 - 0.275))); else tmp = min(min(min(min(t_0, (sqrt((y * y)) - 0.075)), max(max(t_1, -0.55), (0.45 - x))), t_4), max(max(max(max(max((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 0.825), $MachinePrecision]], $MachinePrecision], N[(0.725 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[(-y), N[(y - 0.275), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Max[t$95$1, N[(x - 0.55), $MachinePrecision]], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Max[N[Max[N[Max[(-y), N[(y - 1.0), $MachinePrecision]], $MachinePrecision], N[(x - 0.1), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(N[Power[N[(y - 0.275), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(x - 0.275), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Min[N[Min[N[Min[N[Min[t$95$0, N[(N[Sqrt[N[(N[Power[N[(y - 0.7), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(x - 0.775), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 0.075), $MachinePrecision]], $MachinePrecision], t$95$2], $MachinePrecision], t$95$4], $MachinePrecision], N[Max[N[Max[t$95$3, N[(0.175 - t$95$5), $MachinePrecision]], $MachinePrecision], N[(t$95$5 - 0.275), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 0.5], N[Min[N[Min[N[Min[N[Min[t$95$0, 0.625], $MachinePrecision], t$95$2], $MachinePrecision], t$95$4], $MachinePrecision], N[Max[N[Max[t$95$3, N[(0.175 - -0.275), $MachinePrecision]], $MachinePrecision], N[(-0.275 - 0.275), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Min[N[Min[N[Min[N[Min[t$95$0, N[(N[Sqrt[N[(y * y), $MachinePrecision]], $MachinePrecision] - 0.075), $MachinePrecision]], $MachinePrecision], N[Max[N[Max[t$95$1, -0.55], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$4], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], -0.55], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - -0.275), $MachinePrecision]], $MachinePrecision], N[(-0.275 - 0.275), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -y\right), x - 0.825\right), 0.725 - x\right)\\
t_1 := \mathsf{max}\left(-y, y - 0.275\right)\\
t_2 := \mathsf{max}\left(\mathsf{max}\left(t\_1, x - 0.55\right), 0.45 - x\right)\\
t_3 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, x - 0.55\right), -x\right), 0.275 - y\right)\\
t_4 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\\
t_5 := \sqrt{{\left(y - 0.275\right)}^{2} + {\left(x - 0.275\right)}^{2}}\\
\mathbf{if}\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_0, \sqrt{{\left(y - 0.7\right)}^{2} + {\left(x - 0.775\right)}^{2}} - 0.075\right), t\_2\right), t\_4\right), \mathsf{max}\left(\mathsf{max}\left(t\_3, 0.175 - t\_5\right), t\_5 - 0.275\right)\right) \leq 0.5:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_0, 0.625\right), t\_2\right), t\_4\right), \mathsf{max}\left(\mathsf{max}\left(t\_3, 0.175 - -0.275\right), -0.275 - 0.275\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_0, \sqrt{y \cdot y} - 0.075\right), \mathsf{max}\left(\mathsf{max}\left(t\_1, -0.55\right), 0.45 - x\right)\right), t\_4\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -0.55\right), -x\right), 0.275 - y\right), 0.175 - -0.275\right), -0.275 - 0.275\right)\right)\\
\end{array}
\end{array}
if (fmin.f64 (fmin.f64 (fmin.f64 (fmin.f64 (fmax.f64 (fmax.f64 (fmax.f64 (-.f64 y #s(literal 11/20 binary64)) (neg.f64 y)) (-.f64 x #s(literal 33/40 binary64))) (-.f64 #s(literal 29/40 binary64) x)) (-.f64 (sqrt.f64 (+.f64 (pow.f64 (-.f64 y #s(literal 7/10 binary64)) #s(literal 2 binary64)) (pow.f64 (-.f64 x #s(literal 31/40 binary64)) #s(literal 2 binary64)))) #s(literal 3/40 binary64))) (fmax.f64 (fmax.f64 (fmax.f64 (neg.f64 y) (-.f64 y #s(literal 11/40 binary64))) (-.f64 x #s(literal 11/20 binary64))) (-.f64 #s(literal 9/20 binary64) x))) (fmax.f64 (fmax.f64 (fmax.f64 (neg.f64 y) (-.f64 y #s(literal 1 binary64))) (-.f64 x #s(literal 1/10 binary64))) (neg.f64 x))) (fmax.f64 (fmax.f64 (fmax.f64 (fmax.f64 (fmax.f64 (-.f64 y #s(literal 11/20 binary64)) (-.f64 x #s(literal 11/20 binary64))) (neg.f64 x)) (-.f64 #s(literal 11/40 binary64) y)) (-.f64 #s(literal 7/40 binary64) (sqrt.f64 (+.f64 (pow.f64 (-.f64 y #s(literal 11/40 binary64)) #s(literal 2 binary64)) (pow.f64 (-.f64 x #s(literal 11/40 binary64)) #s(literal 2 binary64)))))) (-.f64 (sqrt.f64 (+.f64 (pow.f64 (-.f64 y #s(literal 11/40 binary64)) #s(literal 2 binary64)) (pow.f64 (-.f64 x #s(literal 11/40 binary64)) #s(literal 2 binary64)))) #s(literal 11/40 binary64)))) < 0.5Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f6445.8
Applied rewrites45.8%
Taylor expanded in x around 0
Applied rewrites45.8%
Taylor expanded in x around 0
Applied rewrites45.8%
Taylor expanded in y around 0
Applied rewrites28.8%
if 0.5 < (fmin.f64 (fmin.f64 (fmin.f64 (fmin.f64 (fmax.f64 (fmax.f64 (fmax.f64 (-.f64 y #s(literal 11/20 binary64)) (neg.f64 y)) (-.f64 x #s(literal 33/40 binary64))) (-.f64 #s(literal 29/40 binary64) x)) (-.f64 (sqrt.f64 (+.f64 (pow.f64 (-.f64 y #s(literal 7/10 binary64)) #s(literal 2 binary64)) (pow.f64 (-.f64 x #s(literal 31/40 binary64)) #s(literal 2 binary64)))) #s(literal 3/40 binary64))) (fmax.f64 (fmax.f64 (fmax.f64 (neg.f64 y) (-.f64 y #s(literal 11/40 binary64))) (-.f64 x #s(literal 11/20 binary64))) (-.f64 #s(literal 9/20 binary64) x))) (fmax.f64 (fmax.f64 (fmax.f64 (neg.f64 y) (-.f64 y #s(literal 1 binary64))) (-.f64 x #s(literal 1/10 binary64))) (neg.f64 x))) (fmax.f64 (fmax.f64 (fmax.f64 (fmax.f64 (fmax.f64 (-.f64 y #s(literal 11/20 binary64)) (-.f64 x #s(literal 11/20 binary64))) (neg.f64 x)) (-.f64 #s(literal 11/40 binary64) y)) (-.f64 #s(literal 7/40 binary64) (sqrt.f64 (+.f64 (pow.f64 (-.f64 y #s(literal 11/40 binary64)) #s(literal 2 binary64)) (pow.f64 (-.f64 x #s(literal 11/40 binary64)) #s(literal 2 binary64)))))) (-.f64 (sqrt.f64 (+.f64 (pow.f64 (-.f64 y #s(literal 11/40 binary64)) #s(literal 2 binary64)) (pow.f64 (-.f64 x #s(literal 11/40 binary64)) #s(literal 2 binary64)))) #s(literal 11/40 binary64)))) Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in y around inf
unpow2N/A
lower-*.f6442.6
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites42.6%
Taylor expanded in x around 0
Applied rewrites41.0%
Taylor expanded in x around 0
Applied rewrites41.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x)))
(t_1 (fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x)))
(t_2 (fmax (- y) (- y 0.275))))
(if (<= x -0.7)
(fmin
(fmin
(fmin
(fmin t_1 (- (sqrt (* x x)) 0.075))
(fmax (fmax t_2 -0.55) (- 0.45 x)))
t_0)
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) -0.55) (- x)) (- 0.275 y))
(- 0.175 -0.275))
(- -0.275 0.275)))
(fmin
(fmin
(fmin (fmin t_1 0.625) (fmax (fmax t_2 (- x 0.55)) (- 0.45 x)))
t_0)
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) (- x 0.55)) (- x)) (- 0.275 y))
(- 0.175 -0.275))
(- -0.275 0.275))))))
double code(double x, double y) {
double t_0 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_1 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_2 = fmax(-y, (y - 0.275));
double tmp;
if (x <= -0.7) {
tmp = fmin(fmin(fmin(fmin(t_1, (sqrt((x * x)) - 0.075)), fmax(fmax(t_2, -0.55), (0.45 - x))), t_0), fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)));
} else {
tmp = fmin(fmin(fmin(fmin(t_1, 0.625), fmax(fmax(t_2, (x - 0.55)), (0.45 - x))), t_0), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)));
}
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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = fmax(fmax(fmax(-y, (y - 1.0d0)), (x - 0.1d0)), -x)
t_1 = fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - x))
t_2 = fmax(-y, (y - 0.275d0))
if (x <= (-0.7d0)) then
tmp = fmin(fmin(fmin(fmin(t_1, (sqrt((x * x)) - 0.075d0)), fmax(fmax(t_2, (-0.55d0)), (0.45d0 - x))), t_0), fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (-0.55d0)), -x), (0.275d0 - y)), (0.175d0 - (-0.275d0))), ((-0.275d0) - 0.275d0)))
else
tmp = fmin(fmin(fmin(fmin(t_1, 0.625d0), fmax(fmax(t_2, (x - 0.55d0)), (0.45d0 - x))), t_0), fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (x - 0.55d0)), -x), (0.275d0 - y)), (0.175d0 - (-0.275d0))), ((-0.275d0) - 0.275d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_1 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_2 = fmax(-y, (y - 0.275));
double tmp;
if (x <= -0.7) {
tmp = fmin(fmin(fmin(fmin(t_1, (Math.sqrt((x * x)) - 0.075)), fmax(fmax(t_2, -0.55), (0.45 - x))), t_0), fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)));
} else {
tmp = fmin(fmin(fmin(fmin(t_1, 0.625), fmax(fmax(t_2, (x - 0.55)), (0.45 - x))), t_0), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)));
}
return tmp;
}
def code(x, y): t_0 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x) t_1 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)) t_2 = fmax(-y, (y - 0.275)) tmp = 0 if x <= -0.7: tmp = fmin(fmin(fmin(fmin(t_1, (math.sqrt((x * x)) - 0.075)), fmax(fmax(t_2, -0.55), (0.45 - x))), t_0), fmax(fmax(fmax(fmax(fmax((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275))) else: tmp = fmin(fmin(fmin(fmin(t_1, 0.625), fmax(fmax(t_2, (x - 0.55)), (0.45 - x))), t_0), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275))) return tmp
function code(x, y) t_0 = fmax(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x)) t_1 = fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x)) t_2 = fmax(Float64(-y), Float64(y - 0.275)) tmp = 0.0 if (x <= -0.7) tmp = fmin(fmin(fmin(fmin(t_1, Float64(sqrt(Float64(x * x)) - 0.075)), fmax(fmax(t_2, -0.55), Float64(0.45 - x))), t_0), fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), -0.55), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - -0.275)), Float64(-0.275 - 0.275))); else tmp = fmin(fmin(fmin(fmin(t_1, 0.625), fmax(fmax(t_2, Float64(x - 0.55)), Float64(0.45 - x))), t_0), fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - -0.275)), Float64(-0.275 - 0.275))); end return tmp end
function tmp_2 = code(x, y) t_0 = max(max(max(-y, (y - 1.0)), (x - 0.1)), -x); t_1 = max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x)); t_2 = max(-y, (y - 0.275)); tmp = 0.0; if (x <= -0.7) tmp = min(min(min(min(t_1, (sqrt((x * x)) - 0.075)), max(max(t_2, -0.55), (0.45 - x))), t_0), max(max(max(max(max((y - 0.55), -0.55), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275))); else tmp = min(min(min(min(t_1, 0.625), max(max(t_2, (x - 0.55)), (0.45 - x))), t_0), max(max(max(max(max((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[N[Max[N[Max[(-y), N[(y - 1.0), $MachinePrecision]], $MachinePrecision], N[(x - 0.1), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 0.825), $MachinePrecision]], $MachinePrecision], N[(0.725 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[(-y), N[(y - 0.275), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -0.7], N[Min[N[Min[N[Min[N[Min[t$95$1, N[(N[Sqrt[N[(x * x), $MachinePrecision]], $MachinePrecision] - 0.075), $MachinePrecision]], $MachinePrecision], N[Max[N[Max[t$95$2, -0.55], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$0], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], -0.55], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - -0.275), $MachinePrecision]], $MachinePrecision], N[(-0.275 - 0.275), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Min[N[Min[N[Min[N[Min[t$95$1, 0.625], $MachinePrecision], N[Max[N[Max[t$95$2, N[(x - 0.55), $MachinePrecision]], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$0], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - -0.275), $MachinePrecision]], $MachinePrecision], N[(-0.275 - 0.275), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\\
t_1 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -y\right), x - 0.825\right), 0.725 - x\right)\\
t_2 := \mathsf{max}\left(-y, y - 0.275\right)\\
\mathbf{if}\;x \leq -0.7:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_1, \sqrt{x \cdot x} - 0.075\right), \mathsf{max}\left(\mathsf{max}\left(t\_2, -0.55\right), 0.45 - x\right)\right), t\_0\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -0.55\right), -x\right), 0.275 - y\right), 0.175 - -0.275\right), -0.275 - 0.275\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_1, 0.625\right), \mathsf{max}\left(\mathsf{max}\left(t\_2, x - 0.55\right), 0.45 - x\right)\right), t\_0\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, x - 0.55\right), -x\right), 0.275 - y\right), 0.175 - -0.275\right), -0.275 - 0.275\right)\right)\\
\end{array}
\end{array}
if x < -0.69999999999999996Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
unpow2N/A
lower-*.f6441.4
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites41.4%
Taylor expanded in x around 0
Applied rewrites23.5%
Taylor expanded in x around 0
Applied rewrites23.5%
if -0.69999999999999996 < x Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f6445.8
Applied rewrites45.8%
Taylor expanded in x around 0
Applied rewrites45.8%
Taylor expanded in x around 0
Applied rewrites45.8%
Taylor expanded in y around 0
Applied rewrites28.8%
(FPCore (x y)
:precision binary64
(fmin
(fmin
(fmin
(fmin (fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x)) 0.625)
(fmax (fmax (fmax (- y) (- y 0.275)) (- x 0.55)) (- 0.45 x)))
(fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x)))
(fmax
(fmax
(fmax (fmax (fmax (- y 0.55) (- x 0.55)) (- x)) (- 0.275 y))
(- 0.175 -0.275))
(- -0.275 0.275))))
double code(double x, double y) {
return fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)), 0.625), fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)));
}
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(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - x)), 0.625d0), fmax(fmax(fmax(-y, (y - 0.275d0)), (x - 0.55d0)), (0.45d0 - x))), fmax(fmax(fmax(-y, (y - 1.0d0)), (x - 0.1d0)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (x - 0.55d0)), -x), (0.275d0 - y)), (0.175d0 - (-0.275d0))), ((-0.275d0) - 0.275d0)))
end function
public static double code(double x, double y) {
return fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)), 0.625), fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)));
}
def code(x, y): return fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)), 0.625), fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x)), fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275)))
function code(x, y) return fmin(fmin(fmin(fmin(fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x)), 0.625), fmax(fmax(fmax(Float64(-y), Float64(y - 0.275)), Float64(x - 0.55)), Float64(0.45 - x))), fmax(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x))), fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)), Float64(0.275 - y)), Float64(0.175 - -0.275)), Float64(-0.275 - 0.275))) end
function tmp = code(x, y) tmp = min(min(min(min(max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x)), 0.625), max(max(max(-y, (y - 0.275)), (x - 0.55)), (0.45 - x))), max(max(max(-y, (y - 1.0)), (x - 0.1)), -x)), max(max(max(max(max((y - 0.55), (x - 0.55)), -x), (0.275 - y)), (0.175 - -0.275)), (-0.275 - 0.275))); end
code[x_, y_] := N[Min[N[Min[N[Min[N[Min[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 0.825), $MachinePrecision]], $MachinePrecision], N[(0.725 - x), $MachinePrecision]], $MachinePrecision], 0.625], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 0.275), $MachinePrecision]], $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], N[(0.45 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 1.0), $MachinePrecision]], $MachinePrecision], N[(x - 0.1), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], N[(0.175 - -0.275), $MachinePrecision]], $MachinePrecision], N[(-0.275 - 0.275), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -y\right), x - 0.825\right), 0.725 - x\right), 0.625\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 0.275\right), x - 0.55\right), 0.45 - x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, x - 0.55\right), -x\right), 0.275 - y\right), 0.175 - -0.275\right), -0.275 - 0.275\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
mult-flip-revN/A
lower-/.f6445.8
Applied rewrites45.8%
Taylor expanded in x around 0
Applied rewrites45.8%
Taylor expanded in x around 0
Applied rewrites45.8%
Taylor expanded in y around 0
Applied rewrites28.8%
herbie shell --seed 2025135
(FPCore (x y)
:name "The letters hi in the upper-right quadrant"
:precision binary64
(fmin (fmin (fmin (fmin (fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x)) (- (sqrt (+ (pow (- y 0.7) 2.0) (pow (- x 0.775) 2.0))) 0.075)) (fmax (fmax (fmax (- y) (- y 0.275)) (- x 0.55)) (- 0.45 x))) (fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x))) (fmax (fmax (fmax (fmax (fmax (- y 0.55) (- x 0.55)) (- x)) (- 0.275 y)) (- 0.175 (sqrt (+ (pow (- y 0.275) 2.0) (pow (- x 0.275) 2.0))))) (- (sqrt (+ (pow (- y 0.275) 2.0) (pow (- x 0.275) 2.0))) 0.275))))