
(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}
Sampling outcomes in binary64 precision:
Herbie found 9 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
(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)) y)
y)))
double code(double x, double y) {
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)), y), y));
}
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)), (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)), y), y))
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)), (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)), y), y));
}
def code(x, y): 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)), y), y))
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)), 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)), y), y)) end
function tmp = code(x, y) 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)), y), y)); 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], 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], y], $MachinePrecision], y], $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), \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), y\right), y\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax (fmax (fmax (- y) (- y 0.275)) (- x 0.55)) (- 0.45 x)))
(t_1 (fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x)))
(t_2 (fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x))))
(if (<= y -1.45e+32)
(fmin
(fmin (fmin (fmin t_1 (- y)) t_0) t_2)
(fmax (fmax (fmax (fmax (fmax (- y 0.55) x) (- x)) (- 0.275 y)) y) y))
(fmin
(fmin
(fmin
(fmin
t_1
(-
(sqrt
(*
(-
(+ (+ (/ 0.600625 (* x x)) 1.0) (ratio-of-squares (- y 0.7) x))
(/ 1.55 x))
(* x x)))
0.075))
t_0)
t_2)
(fmax
(fmax (fmax (fmax (fmax (- y 0.55) (- x 0.55)) (- x)) 0.275) y)
y)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 0.275\right), x - 0.55\right), 0.45 - 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(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\\
\mathbf{if}\;y \leq -1.45 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_1, -y\right), t\_0\right), t\_2\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, x\right), -x\right), 0.275 - y\right), y\right), y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_1, \sqrt{\left(\left(\left(\frac{0.600625}{x \cdot x} + 1\right) + \mathsf{ratio\_of\_squares}\left(\left(y - 0.7\right), x\right)\right) - \frac{1.55}{x}\right) \cdot \left(x \cdot x\right)} - 0.075\right), t\_0\right), t\_2\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\right), y\right), y\right)\right)\\
\end{array}
\end{array}
if y < -1.45000000000000001e32Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in y around -inf
mul-1-negN/A
lift-neg.f6480.1
Applied rewrites80.1%
Taylor expanded in x around inf
Applied rewrites80.1%
if -1.45000000000000001e32 < y Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites99.1%
(FPCore (x y)
:precision binary64
(fmin
(fmin
(fmin
(fmin
(fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x))
(-
(sqrt
(*
(-
(+ (+ (/ 0.600625 (* x x)) 1.0) (ratio-of-squares (- y 0.7) x))
(/ 1.55 x))
(* x x)))
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)) y)
y)))\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), \sqrt{\left(\left(\left(\frac{0.600625}{x \cdot x} + 1\right) + \mathsf{ratio\_of\_squares}\left(\left(y - 0.7\right), x\right)\right) - \frac{1.55}{x}\right) \cdot \left(x \cdot x\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), y\right), y\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax (fmax (fmax (- y) (- y 0.275)) (- x 0.55)) (- 0.45 x)))
(t_1 (fmax (fmax (- y 0.55) (- x 0.55)) (- x)))
(t_2 (fmax (fmax (fmax t_1 0.275) y) y))
(t_3 (fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x)))
(t_4 (fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x))))
(if (<= x -1.22e-86)
(fmin (fmin (fmin (fmin t_3 (- x)) t_0) t_4) t_2)
(if (<= x -3.6e-229)
(fmin (fmin (fmin (fmin t_3 y) t_0) t_4) t_2)
(if (<= x -5e-310)
(fmin
(fmin (fmin (fmin t_3 (- y)) t_0) t_4)
(fmax
(fmax (fmax (fmax (fmax (- y 0.55) x) (- x)) (- 0.275 y)) y)
y))
(fmin
(fmin
(fmin
(fmin
t_3
(*
(- (+ (* (ratio-of-squares (- y 0.7) x) 0.5) 1.0) (/ 0.85 x))
x))
t_0)
t_4)
(fmax (fmax (fmax t_1 (- 0.275 y)) y) y)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 0.275\right), x - 0.55\right), 0.45 - x\right)\\
t_1 := \mathsf{max}\left(\mathsf{max}\left(y - 0.55, x - 0.55\right), -x\right)\\
t_2 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(t\_1, 0.275\right), y\right), y\right)\\
t_3 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -y\right), x - 0.825\right), 0.725 - x\right)\\
t_4 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\\
\mathbf{if}\;x \leq -1.22 \cdot 10^{-86}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_3, -x\right), t\_0\right), t\_4\right), t\_2\right)\\
\mathbf{elif}\;x \leq -3.6 \cdot 10^{-229}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_3, y\right), t\_0\right), t\_4\right), t\_2\right)\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_3, -y\right), t\_0\right), t\_4\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, x\right), -x\right), 0.275 - y\right), y\right), y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_3, \left(\left(\mathsf{ratio\_of\_squares}\left(\left(y - 0.7\right), x\right) \cdot 0.5 + 1\right) - \frac{0.85}{x}\right) \cdot x\right), t\_0\right), t\_4\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(t\_1, 0.275 - y\right), y\right), y\right)\right)\\
\end{array}
\end{array}
if x < -1.22000000000000003e-86Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in x around -inf
mul-1-negN/A
lift-neg.f6468.1
Applied rewrites68.1%
Taylor expanded in y around 0
Applied rewrites68.1%
if -1.22000000000000003e-86 < x < -3.60000000000000003e-229Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in y around inf
Applied rewrites63.3%
Taylor expanded in y around 0
Applied rewrites63.3%
if -3.60000000000000003e-229 < x < -4.999999999999985e-310Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in y around -inf
mul-1-negN/A
lift-neg.f6463.4
Applied rewrites63.4%
Taylor expanded in x around inf
Applied rewrites63.4%
if -4.999999999999985e-310 < x Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
unpow2N/A
lower-ratio-of-squares.f64N/A
lift--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6499.7
Applied rewrites99.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax (fmax (fmax (- y) (- y 0.275)) (- x 0.55)) (- 0.45 x)))
(t_1 (fmax (fmax (- y 0.55) (- x 0.55)) (- x)))
(t_2 (fmax (fmax (fmax t_1 0.275) y) y))
(t_3 (fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x)))
(t_4 (fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x)))
(t_5 (fmin (fmin (fmin (fmin t_3 y) t_0) t_4) t_2)))
(if (<= x -1.22e-86)
(fmin (fmin (fmin (fmin t_3 (- x)) t_0) t_4) t_2)
(if (<= x -3.6e-229)
t_5
(if (<= x 4.2e-89)
(fmin
(fmin (fmin (fmin t_3 (- y)) t_0) t_4)
(fmax
(fmax (fmax (fmax (fmax (- y 0.55) x) (- x)) (- 0.275 y)) y)
y))
(if (<= x 225000.0)
t_5
(fmin
(fmin (fmin (fmin t_3 (* (- 1.0 (/ 0.85 x)) x)) t_0) t_4)
(fmax (fmax (fmax t_1 (- 0.275 y)) y) y))))))))
double code(double x, double y) {
double t_0 = fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x));
double t_1 = fmax(fmax((y - 0.55), (x - 0.55)), -x);
double t_2 = fmax(fmax(fmax(t_1, 0.275), y), y);
double t_3 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_4 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_5 = fmin(fmin(fmin(fmin(t_3, y), t_0), t_4), t_2);
double tmp;
if (x <= -1.22e-86) {
tmp = fmin(fmin(fmin(fmin(t_3, -x), t_0), t_4), t_2);
} else if (x <= -3.6e-229) {
tmp = t_5;
} else if (x <= 4.2e-89) {
tmp = fmin(fmin(fmin(fmin(t_3, -y), t_0), t_4), fmax(fmax(fmax(fmax(fmax((y - 0.55), x), -x), (0.275 - y)), y), y));
} else if (x <= 225000.0) {
tmp = t_5;
} else {
tmp = fmin(fmin(fmin(fmin(t_3, ((1.0 - (0.85 / x)) * x)), t_0), t_4), fmax(fmax(fmax(t_1, (0.275 - y)), y), y));
}
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 - 0.275d0)), (x - 0.55d0)), (0.45d0 - x))
t_1 = fmax(fmax((y - 0.55d0), (x - 0.55d0)), -x)
t_2 = fmax(fmax(fmax(t_1, 0.275d0), y), y)
t_3 = fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - x))
t_4 = fmax(fmax(fmax(-y, (y - 1.0d0)), (x - 0.1d0)), -x)
t_5 = fmin(fmin(fmin(fmin(t_3, y), t_0), t_4), t_2)
if (x <= (-1.22d-86)) then
tmp = fmin(fmin(fmin(fmin(t_3, -x), t_0), t_4), t_2)
else if (x <= (-3.6d-229)) then
tmp = t_5
else if (x <= 4.2d-89) then
tmp = fmin(fmin(fmin(fmin(t_3, -y), t_0), t_4), fmax(fmax(fmax(fmax(fmax((y - 0.55d0), x), -x), (0.275d0 - y)), y), y))
else if (x <= 225000.0d0) then
tmp = t_5
else
tmp = fmin(fmin(fmin(fmin(t_3, ((1.0d0 - (0.85d0 / x)) * x)), t_0), t_4), fmax(fmax(fmax(t_1, (0.275d0 - y)), y), y))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x));
double t_1 = fmax(fmax((y - 0.55), (x - 0.55)), -x);
double t_2 = fmax(fmax(fmax(t_1, 0.275), y), y);
double t_3 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_4 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_5 = fmin(fmin(fmin(fmin(t_3, y), t_0), t_4), t_2);
double tmp;
if (x <= -1.22e-86) {
tmp = fmin(fmin(fmin(fmin(t_3, -x), t_0), t_4), t_2);
} else if (x <= -3.6e-229) {
tmp = t_5;
} else if (x <= 4.2e-89) {
tmp = fmin(fmin(fmin(fmin(t_3, -y), t_0), t_4), fmax(fmax(fmax(fmax(fmax((y - 0.55), x), -x), (0.275 - y)), y), y));
} else if (x <= 225000.0) {
tmp = t_5;
} else {
tmp = fmin(fmin(fmin(fmin(t_3, ((1.0 - (0.85 / x)) * x)), t_0), t_4), fmax(fmax(fmax(t_1, (0.275 - y)), y), y));
}
return tmp;
}
def code(x, y): t_0 = fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x)) t_1 = fmax(fmax((y - 0.55), (x - 0.55)), -x) t_2 = fmax(fmax(fmax(t_1, 0.275), y), y) t_3 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)) t_4 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x) t_5 = fmin(fmin(fmin(fmin(t_3, y), t_0), t_4), t_2) tmp = 0 if x <= -1.22e-86: tmp = fmin(fmin(fmin(fmin(t_3, -x), t_0), t_4), t_2) elif x <= -3.6e-229: tmp = t_5 elif x <= 4.2e-89: tmp = fmin(fmin(fmin(fmin(t_3, -y), t_0), t_4), fmax(fmax(fmax(fmax(fmax((y - 0.55), x), -x), (0.275 - y)), y), y)) elif x <= 225000.0: tmp = t_5 else: tmp = fmin(fmin(fmin(fmin(t_3, ((1.0 - (0.85 / x)) * x)), t_0), t_4), fmax(fmax(fmax(t_1, (0.275 - y)), y), y)) return tmp
function code(x, y) t_0 = fmax(fmax(fmax(Float64(-y), Float64(y - 0.275)), Float64(x - 0.55)), Float64(0.45 - x)) t_1 = fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)) t_2 = fmax(fmax(fmax(t_1, 0.275), y), y) t_3 = fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x)) t_4 = fmax(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x)) t_5 = fmin(fmin(fmin(fmin(t_3, y), t_0), t_4), t_2) tmp = 0.0 if (x <= -1.22e-86) tmp = fmin(fmin(fmin(fmin(t_3, Float64(-x)), t_0), t_4), t_2); elseif (x <= -3.6e-229) tmp = t_5; elseif (x <= 4.2e-89) tmp = fmin(fmin(fmin(fmin(t_3, Float64(-y)), t_0), t_4), fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), x), Float64(-x)), Float64(0.275 - y)), y), y)); elseif (x <= 225000.0) tmp = t_5; else tmp = fmin(fmin(fmin(fmin(t_3, Float64(Float64(1.0 - Float64(0.85 / x)) * x)), t_0), t_4), fmax(fmax(fmax(t_1, Float64(0.275 - y)), y), y)); end return tmp end
function tmp_2 = code(x, y) t_0 = max(max(max(-y, (y - 0.275)), (x - 0.55)), (0.45 - x)); t_1 = max(max((y - 0.55), (x - 0.55)), -x); t_2 = max(max(max(t_1, 0.275), y), y); t_3 = max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x)); t_4 = max(max(max(-y, (y - 1.0)), (x - 0.1)), -x); t_5 = min(min(min(min(t_3, y), t_0), t_4), t_2); tmp = 0.0; if (x <= -1.22e-86) tmp = min(min(min(min(t_3, -x), t_0), t_4), t_2); elseif (x <= -3.6e-229) tmp = t_5; elseif (x <= 4.2e-89) tmp = min(min(min(min(t_3, -y), t_0), t_4), max(max(max(max(max((y - 0.55), x), -x), (0.275 - y)), y), y)); elseif (x <= 225000.0) tmp = t_5; else tmp = min(min(min(min(t_3, ((1.0 - (0.85 / x)) * x)), t_0), t_4), max(max(max(t_1, (0.275 - y)), y), y)); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = 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]}, Block[{t$95$1 = N[Max[N[Max[N[(y - 0.55), $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Max[N[Max[t$95$1, 0.275], $MachinePrecision], y], $MachinePrecision], y], $MachinePrecision]}, Block[{t$95$3 = 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$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[Min[N[Min[N[Min[N[Min[t$95$3, y], $MachinePrecision], t$95$0], $MachinePrecision], t$95$4], $MachinePrecision], t$95$2], $MachinePrecision]}, If[LessEqual[x, -1.22e-86], N[Min[N[Min[N[Min[N[Min[t$95$3, (-x)], $MachinePrecision], t$95$0], $MachinePrecision], t$95$4], $MachinePrecision], t$95$2], $MachinePrecision], If[LessEqual[x, -3.6e-229], t$95$5, If[LessEqual[x, 4.2e-89], N[Min[N[Min[N[Min[N[Min[t$95$3, (-y)], $MachinePrecision], t$95$0], $MachinePrecision], t$95$4], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], x], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], y], $MachinePrecision], y], $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 225000.0], t$95$5, N[Min[N[Min[N[Min[N[Min[t$95$3, N[(N[(1.0 - N[(0.85 / x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision], t$95$0], $MachinePrecision], t$95$4], $MachinePrecision], N[Max[N[Max[N[Max[t$95$1, N[(0.275 - y), $MachinePrecision]], $MachinePrecision], y], $MachinePrecision], y], $MachinePrecision]], $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 0.275\right), x - 0.55\right), 0.45 - x\right)\\
t_1 := \mathsf{max}\left(\mathsf{max}\left(y - 0.55, x - 0.55\right), -x\right)\\
t_2 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(t\_1, 0.275\right), y\right), y\right)\\
t_3 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, -y\right), x - 0.825\right), 0.725 - x\right)\\
t_4 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\\
t_5 := \mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_3, y\right), t\_0\right), t\_4\right), t\_2\right)\\
\mathbf{if}\;x \leq -1.22 \cdot 10^{-86}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_3, -x\right), t\_0\right), t\_4\right), t\_2\right)\\
\mathbf{elif}\;x \leq -3.6 \cdot 10^{-229}:\\
\;\;\;\;t\_5\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-89}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_3, -y\right), t\_0\right), t\_4\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, x\right), -x\right), 0.275 - y\right), y\right), y\right)\right)\\
\mathbf{elif}\;x \leq 225000:\\
\;\;\;\;t\_5\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_3, \left(1 - \frac{0.85}{x}\right) \cdot x\right), t\_0\right), t\_4\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(t\_1, 0.275 - y\right), y\right), y\right)\right)\\
\end{array}
\end{array}
if x < -1.22000000000000003e-86Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in x around -inf
mul-1-negN/A
lift-neg.f6468.1
Applied rewrites68.1%
Taylor expanded in y around 0
Applied rewrites68.1%
if -1.22000000000000003e-86 < x < -3.60000000000000003e-229 or 4.2000000000000002e-89 < x < 225000Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in y around inf
Applied rewrites66.9%
Taylor expanded in y around 0
Applied rewrites66.9%
if -3.60000000000000003e-229 < x < 4.2000000000000002e-89Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in y around -inf
mul-1-negN/A
lift-neg.f6470.1
Applied rewrites70.1%
Taylor expanded in x around inf
Applied rewrites70.1%
if 225000 < x Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f6480.9
Applied rewrites80.9%
(FPCore (x y)
:precision binary64
(let* ((t_0
(fmax
(fmax (fmax (fmax (fmax (- y 0.55) (- x 0.55)) (- x)) 0.275) y)
y))
(t_1 (fmax (fmax (fmax (- y) (- y 0.275)) (- x 0.55)) (- 0.45 x)))
(t_2 (fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x)))
(t_3 (fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x)))
(t_4 (fmin (fmin (fmin (fmin t_2 y) t_1) t_3) t_0)))
(if (<= x -1.22e-86)
(fmin (fmin (fmin (fmin t_2 (- x)) t_1) t_3) t_0)
(if (<= x -3.6e-229)
t_4
(if (<= x 4.2e-89)
(fmin
(fmin (fmin (fmin t_2 (- y)) t_1) t_3)
(fmax
(fmax (fmax (fmax (fmax (- y 0.55) x) (- x)) (- 0.275 y)) y)
y))
(if (<= x 300000.0)
t_4
(fmin (fmin (fmin (fmin t_2 x) t_1) t_3) t_0)))))))
double code(double x, double y) {
double t_0 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), 0.275), y), y);
double t_1 = fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x));
double t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_3 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_4 = fmin(fmin(fmin(fmin(t_2, y), t_1), t_3), t_0);
double tmp;
if (x <= -1.22e-86) {
tmp = fmin(fmin(fmin(fmin(t_2, -x), t_1), t_3), t_0);
} else if (x <= -3.6e-229) {
tmp = t_4;
} else if (x <= 4.2e-89) {
tmp = fmin(fmin(fmin(fmin(t_2, -y), t_1), t_3), fmax(fmax(fmax(fmax(fmax((y - 0.55), x), -x), (0.275 - y)), y), y));
} else if (x <= 300000.0) {
tmp = t_4;
} else {
tmp = fmin(fmin(fmin(fmin(t_2, x), t_1), t_3), t_0);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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) :: tmp
t_0 = fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (x - 0.55d0)), -x), 0.275d0), y), y)
t_1 = fmax(fmax(fmax(-y, (y - 0.275d0)), (x - 0.55d0)), (0.45d0 - x))
t_2 = fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - x))
t_3 = fmax(fmax(fmax(-y, (y - 1.0d0)), (x - 0.1d0)), -x)
t_4 = fmin(fmin(fmin(fmin(t_2, y), t_1), t_3), t_0)
if (x <= (-1.22d-86)) then
tmp = fmin(fmin(fmin(fmin(t_2, -x), t_1), t_3), t_0)
else if (x <= (-3.6d-229)) then
tmp = t_4
else if (x <= 4.2d-89) then
tmp = fmin(fmin(fmin(fmin(t_2, -y), t_1), t_3), fmax(fmax(fmax(fmax(fmax((y - 0.55d0), x), -x), (0.275d0 - y)), y), y))
else if (x <= 300000.0d0) then
tmp = t_4
else
tmp = fmin(fmin(fmin(fmin(t_2, x), t_1), t_3), t_0)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), 0.275), y), y);
double t_1 = fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x));
double t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_3 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_4 = fmin(fmin(fmin(fmin(t_2, y), t_1), t_3), t_0);
double tmp;
if (x <= -1.22e-86) {
tmp = fmin(fmin(fmin(fmin(t_2, -x), t_1), t_3), t_0);
} else if (x <= -3.6e-229) {
tmp = t_4;
} else if (x <= 4.2e-89) {
tmp = fmin(fmin(fmin(fmin(t_2, -y), t_1), t_3), fmax(fmax(fmax(fmax(fmax((y - 0.55), x), -x), (0.275 - y)), y), y));
} else if (x <= 300000.0) {
tmp = t_4;
} else {
tmp = fmin(fmin(fmin(fmin(t_2, x), t_1), t_3), t_0);
}
return tmp;
}
def code(x, y): t_0 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), 0.275), y), y) t_1 = fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x)) t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)) t_3 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x) t_4 = fmin(fmin(fmin(fmin(t_2, y), t_1), t_3), t_0) tmp = 0 if x <= -1.22e-86: tmp = fmin(fmin(fmin(fmin(t_2, -x), t_1), t_3), t_0) elif x <= -3.6e-229: tmp = t_4 elif x <= 4.2e-89: tmp = fmin(fmin(fmin(fmin(t_2, -y), t_1), t_3), fmax(fmax(fmax(fmax(fmax((y - 0.55), x), -x), (0.275 - y)), y), y)) elif x <= 300000.0: tmp = t_4 else: tmp = fmin(fmin(fmin(fmin(t_2, x), t_1), t_3), t_0) return tmp
function code(x, y) t_0 = fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)), 0.275), y), y) t_1 = fmax(fmax(fmax(Float64(-y), Float64(y - 0.275)), Float64(x - 0.55)), Float64(0.45 - x)) t_2 = fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x)) t_3 = fmax(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x)) t_4 = fmin(fmin(fmin(fmin(t_2, y), t_1), t_3), t_0) tmp = 0.0 if (x <= -1.22e-86) tmp = fmin(fmin(fmin(fmin(t_2, Float64(-x)), t_1), t_3), t_0); elseif (x <= -3.6e-229) tmp = t_4; elseif (x <= 4.2e-89) tmp = fmin(fmin(fmin(fmin(t_2, Float64(-y)), t_1), t_3), fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), x), Float64(-x)), Float64(0.275 - y)), y), y)); elseif (x <= 300000.0) tmp = t_4; else tmp = fmin(fmin(fmin(fmin(t_2, x), t_1), t_3), t_0); end return tmp end
function tmp_2 = code(x, y) t_0 = max(max(max(max(max((y - 0.55), (x - 0.55)), -x), 0.275), y), y); t_1 = max(max(max(-y, (y - 0.275)), (x - 0.55)), (0.45 - x)); t_2 = max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x)); t_3 = max(max(max(-y, (y - 1.0)), (x - 0.1)), -x); t_4 = min(min(min(min(t_2, y), t_1), t_3), t_0); tmp = 0.0; if (x <= -1.22e-86) tmp = min(min(min(min(t_2, -x), t_1), t_3), t_0); elseif (x <= -3.6e-229) tmp = t_4; elseif (x <= 4.2e-89) tmp = min(min(min(min(t_2, -y), t_1), t_3), max(max(max(max(max((y - 0.55), x), -x), (0.275 - y)), y), y)); elseif (x <= 300000.0) tmp = t_4; else tmp = min(min(min(min(t_2, x), t_1), t_3), t_0); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], 0.275], $MachinePrecision], y], $MachinePrecision], y], $MachinePrecision]}, Block[{t$95$1 = 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]}, 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[N[Max[N[Max[(-y), N[(y - 1.0), $MachinePrecision]], $MachinePrecision], N[(x - 0.1), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]}, Block[{t$95$4 = N[Min[N[Min[N[Min[N[Min[t$95$2, y], $MachinePrecision], t$95$1], $MachinePrecision], t$95$3], $MachinePrecision], t$95$0], $MachinePrecision]}, If[LessEqual[x, -1.22e-86], N[Min[N[Min[N[Min[N[Min[t$95$2, (-x)], $MachinePrecision], t$95$1], $MachinePrecision], t$95$3], $MachinePrecision], t$95$0], $MachinePrecision], If[LessEqual[x, -3.6e-229], t$95$4, If[LessEqual[x, 4.2e-89], N[Min[N[Min[N[Min[N[Min[t$95$2, (-y)], $MachinePrecision], t$95$1], $MachinePrecision], t$95$3], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], x], $MachinePrecision], (-x)], $MachinePrecision], N[(0.275 - y), $MachinePrecision]], $MachinePrecision], y], $MachinePrecision], y], $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 300000.0], t$95$4, N[Min[N[Min[N[Min[N[Min[t$95$2, x], $MachinePrecision], t$95$1], $MachinePrecision], t$95$3], $MachinePrecision], t$95$0], $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \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\right), y\right), y\right)\\
t_1 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 0.275\right), x - 0.55\right), 0.45 - x\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(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\\
t_4 := \mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_2, y\right), t\_1\right), t\_3\right), t\_0\right)\\
\mathbf{if}\;x \leq -1.22 \cdot 10^{-86}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_2, -x\right), t\_1\right), t\_3\right), t\_0\right)\\
\mathbf{elif}\;x \leq -3.6 \cdot 10^{-229}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-89}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_2, -y\right), t\_1\right), t\_3\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - 0.55, x\right), -x\right), 0.275 - y\right), y\right), y\right)\right)\\
\mathbf{elif}\;x \leq 300000:\\
\;\;\;\;t\_4\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_2, x\right), t\_1\right), t\_3\right), t\_0\right)\\
\end{array}
\end{array}
if x < -1.22000000000000003e-86Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in x around -inf
mul-1-negN/A
lift-neg.f6468.1
Applied rewrites68.1%
Taylor expanded in y around 0
Applied rewrites68.1%
if -1.22000000000000003e-86 < x < -3.60000000000000003e-229 or 4.2000000000000002e-89 < x < 3e5Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in y around inf
Applied rewrites66.9%
Taylor expanded in y around 0
Applied rewrites66.9%
if -3.60000000000000003e-229 < x < 4.2000000000000002e-89Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in y around -inf
mul-1-negN/A
lift-neg.f6470.1
Applied rewrites70.1%
Taylor expanded in x around inf
Applied rewrites70.1%
if 3e5 < x Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites80.5%
Taylor expanded in y around 0
Applied rewrites80.5%
(FPCore (x y)
:precision binary64
(let* ((t_0
(fmax
(fmax (fmax (fmax (fmax (- y 0.55) (- x 0.55)) (- x)) 0.275) y)
y))
(t_1 (fmax (fmax (fmax (- y) (- y 0.275)) (- x 0.55)) (- 0.45 x)))
(t_2 (fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x)))
(t_3 (fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x))))
(if (<= x -1.22e-86)
(fmin (fmin (fmin (fmin t_2 (- x)) t_1) t_3) t_0)
(if (<= x 300000.0)
(fmin (fmin (fmin (fmin t_2 y) t_1) t_3) t_0)
(fmin (fmin (fmin (fmin t_2 x) t_1) t_3) t_0)))))
double code(double x, double y) {
double t_0 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), 0.275), y), y);
double t_1 = fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x));
double t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_3 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double tmp;
if (x <= -1.22e-86) {
tmp = fmin(fmin(fmin(fmin(t_2, -x), t_1), t_3), t_0);
} else if (x <= 300000.0) {
tmp = fmin(fmin(fmin(fmin(t_2, y), t_1), t_3), t_0);
} else {
tmp = fmin(fmin(fmin(fmin(t_2, x), t_1), t_3), t_0);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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) :: tmp
t_0 = fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (x - 0.55d0)), -x), 0.275d0), y), y)
t_1 = fmax(fmax(fmax(-y, (y - 0.275d0)), (x - 0.55d0)), (0.45d0 - x))
t_2 = fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - x))
t_3 = fmax(fmax(fmax(-y, (y - 1.0d0)), (x - 0.1d0)), -x)
if (x <= (-1.22d-86)) then
tmp = fmin(fmin(fmin(fmin(t_2, -x), t_1), t_3), t_0)
else if (x <= 300000.0d0) then
tmp = fmin(fmin(fmin(fmin(t_2, y), t_1), t_3), t_0)
else
tmp = fmin(fmin(fmin(fmin(t_2, x), t_1), t_3), t_0)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), 0.275), y), y);
double t_1 = fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x));
double t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_3 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double tmp;
if (x <= -1.22e-86) {
tmp = fmin(fmin(fmin(fmin(t_2, -x), t_1), t_3), t_0);
} else if (x <= 300000.0) {
tmp = fmin(fmin(fmin(fmin(t_2, y), t_1), t_3), t_0);
} else {
tmp = fmin(fmin(fmin(fmin(t_2, x), t_1), t_3), t_0);
}
return tmp;
}
def code(x, y): t_0 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), 0.275), y), y) t_1 = fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x)) t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)) t_3 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x) tmp = 0 if x <= -1.22e-86: tmp = fmin(fmin(fmin(fmin(t_2, -x), t_1), t_3), t_0) elif x <= 300000.0: tmp = fmin(fmin(fmin(fmin(t_2, y), t_1), t_3), t_0) else: tmp = fmin(fmin(fmin(fmin(t_2, x), t_1), t_3), t_0) return tmp
function code(x, y) t_0 = fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)), 0.275), y), y) t_1 = fmax(fmax(fmax(Float64(-y), Float64(y - 0.275)), Float64(x - 0.55)), Float64(0.45 - x)) t_2 = fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x)) t_3 = fmax(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x)) tmp = 0.0 if (x <= -1.22e-86) tmp = fmin(fmin(fmin(fmin(t_2, Float64(-x)), t_1), t_3), t_0); elseif (x <= 300000.0) tmp = fmin(fmin(fmin(fmin(t_2, y), t_1), t_3), t_0); else tmp = fmin(fmin(fmin(fmin(t_2, x), t_1), t_3), t_0); end return tmp end
function tmp_2 = code(x, y) t_0 = max(max(max(max(max((y - 0.55), (x - 0.55)), -x), 0.275), y), y); t_1 = max(max(max(-y, (y - 0.275)), (x - 0.55)), (0.45 - x)); t_2 = max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x)); t_3 = max(max(max(-y, (y - 1.0)), (x - 0.1)), -x); tmp = 0.0; if (x <= -1.22e-86) tmp = min(min(min(min(t_2, -x), t_1), t_3), t_0); elseif (x <= 300000.0) tmp = min(min(min(min(t_2, y), t_1), t_3), t_0); else tmp = min(min(min(min(t_2, x), t_1), t_3), t_0); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], 0.275], $MachinePrecision], y], $MachinePrecision], y], $MachinePrecision]}, Block[{t$95$1 = 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]}, 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[N[Max[N[Max[(-y), N[(y - 1.0), $MachinePrecision]], $MachinePrecision], N[(x - 0.1), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]}, If[LessEqual[x, -1.22e-86], N[Min[N[Min[N[Min[N[Min[t$95$2, (-x)], $MachinePrecision], t$95$1], $MachinePrecision], t$95$3], $MachinePrecision], t$95$0], $MachinePrecision], If[LessEqual[x, 300000.0], N[Min[N[Min[N[Min[N[Min[t$95$2, y], $MachinePrecision], t$95$1], $MachinePrecision], t$95$3], $MachinePrecision], t$95$0], $MachinePrecision], N[Min[N[Min[N[Min[N[Min[t$95$2, x], $MachinePrecision], t$95$1], $MachinePrecision], t$95$3], $MachinePrecision], t$95$0], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \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\right), y\right), y\right)\\
t_1 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 0.275\right), x - 0.55\right), 0.45 - x\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(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\\
\mathbf{if}\;x \leq -1.22 \cdot 10^{-86}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_2, -x\right), t\_1\right), t\_3\right), t\_0\right)\\
\mathbf{elif}\;x \leq 300000:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_2, y\right), t\_1\right), t\_3\right), t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_2, x\right), t\_1\right), t\_3\right), t\_0\right)\\
\end{array}
\end{array}
if x < -1.22000000000000003e-86Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in x around -inf
mul-1-negN/A
lift-neg.f6468.1
Applied rewrites68.1%
Taylor expanded in y around 0
Applied rewrites68.1%
if -1.22000000000000003e-86 < x < 3e5Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in y around inf
Applied rewrites48.3%
Taylor expanded in y around 0
Applied rewrites48.3%
if 3e5 < x Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites80.5%
Taylor expanded in y around 0
Applied rewrites80.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x)))
(t_1 (fmax (fmax (fmax (- y) (- y 1.0)) (- x 0.1)) (- x)))
(t_2 (fmax (fmax (fmax (- y) (- y 0.275)) (- x 0.55)) (- 0.45 x)))
(t_3
(fmax
(fmax (fmax (fmax (fmax (- y 0.55) (- x 0.55)) (- x)) 0.275) y)
y)))
(if (<= x 300000.0)
(fmin (fmin (fmin (fmin t_0 y) t_2) t_1) t_3)
(fmin (fmin (fmin (fmin t_0 x) t_2) t_1) t_3))))
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(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_2 = fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x));
double t_3 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), 0.275), y), y);
double tmp;
if (x <= 300000.0) {
tmp = fmin(fmin(fmin(fmin(t_0, y), t_2), t_1), t_3);
} else {
tmp = fmin(fmin(fmin(fmin(t_0, x), t_2), t_1), t_3);
}
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) :: tmp
t_0 = fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - x))
t_1 = fmax(fmax(fmax(-y, (y - 1.0d0)), (x - 0.1d0)), -x)
t_2 = fmax(fmax(fmax(-y, (y - 0.275d0)), (x - 0.55d0)), (0.45d0 - x))
t_3 = fmax(fmax(fmax(fmax(fmax((y - 0.55d0), (x - 0.55d0)), -x), 0.275d0), y), y)
if (x <= 300000.0d0) then
tmp = fmin(fmin(fmin(fmin(t_0, y), t_2), t_1), t_3)
else
tmp = fmin(fmin(fmin(fmin(t_0, x), t_2), t_1), t_3)
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(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_2 = fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x));
double t_3 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), 0.275), y), y);
double tmp;
if (x <= 300000.0) {
tmp = fmin(fmin(fmin(fmin(t_0, y), t_2), t_1), t_3);
} else {
tmp = fmin(fmin(fmin(fmin(t_0, x), t_2), t_1), t_3);
}
return tmp;
}
def code(x, y): t_0 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)) t_1 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x) t_2 = fmax(fmax(fmax(-y, (y - 0.275)), (x - 0.55)), (0.45 - x)) t_3 = fmax(fmax(fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), 0.275), y), y) tmp = 0 if x <= 300000.0: tmp = fmin(fmin(fmin(fmin(t_0, y), t_2), t_1), t_3) else: tmp = fmin(fmin(fmin(fmin(t_0, x), t_2), t_1), t_3) 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(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x)) t_2 = fmax(fmax(fmax(Float64(-y), Float64(y - 0.275)), Float64(x - 0.55)), Float64(0.45 - x)) t_3 = fmax(fmax(fmax(fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)), 0.275), y), y) tmp = 0.0 if (x <= 300000.0) tmp = fmin(fmin(fmin(fmin(t_0, y), t_2), t_1), t_3); else tmp = fmin(fmin(fmin(fmin(t_0, x), t_2), t_1), t_3); 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(max(max(-y, (y - 1.0)), (x - 0.1)), -x); t_2 = max(max(max(-y, (y - 0.275)), (x - 0.55)), (0.45 - x)); t_3 = max(max(max(max(max((y - 0.55), (x - 0.55)), -x), 0.275), y), y); tmp = 0.0; if (x <= 300000.0) tmp = min(min(min(min(t_0, y), t_2), t_1), t_3); else tmp = min(min(min(min(t_0, x), t_2), t_1), t_3); 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[N[Max[N[Max[(-y), N[(y - 1.0), $MachinePrecision]], $MachinePrecision], N[(x - 0.1), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]}, Block[{t$95$2 = 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]}, Block[{t$95$3 = N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 0.55), $MachinePrecision], N[(x - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], 0.275], $MachinePrecision], y], $MachinePrecision], y], $MachinePrecision]}, If[LessEqual[x, 300000.0], N[Min[N[Min[N[Min[N[Min[t$95$0, y], $MachinePrecision], t$95$2], $MachinePrecision], t$95$1], $MachinePrecision], t$95$3], $MachinePrecision], N[Min[N[Min[N[Min[N[Min[t$95$0, x], $MachinePrecision], t$95$2], $MachinePrecision], t$95$1], $MachinePrecision], t$95$3], $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(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - 0.1\right), -x\right)\\
t_2 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 0.275\right), x - 0.55\right), 0.45 - x\right)\\
t_3 := \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\right), y\right), y\right)\\
\mathbf{if}\;x \leq 300000:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_0, y\right), t\_2\right), t\_1\right), t\_3\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_0, x\right), t\_2\right), t\_1\right), t\_3\right)\\
\end{array}
\end{array}
if x < 3e5Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in y around inf
Applied rewrites33.1%
Taylor expanded in y around 0
Applied rewrites33.1%
if 3e5 < x Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites80.5%
Taylor expanded in y around 0
Applied rewrites80.5%
(FPCore (x y)
:precision binary64
(fmin
(fmin
(fmin
(fmin (fmax (fmax (fmax (- y 0.55) (- y)) (- x 0.825)) (- 0.725 x)) x)
(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) y)))
double code(double x, double y) {
return fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)), x), 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), y));
}
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)), x), 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), y))
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)), x), 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), y));
}
def code(x, y): return fmin(fmin(fmin(fmin(fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)), x), 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), y))
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)), x), 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)), 0.275), y), y)) end
function tmp = code(x, y) tmp = min(min(min(min(max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x)), x), 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), y)); 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], x], $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], 0.275], $MachinePrecision], y], $MachinePrecision], y], $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), x\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\right), y\right), y\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in y around inf
Applied rewrites100.0%
Taylor expanded in y around -inf
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites29.9%
Taylor expanded in y around 0
Applied rewrites29.9%
herbie shell --seed 2025058
(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))))