
(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}
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}
Herbie found 7 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}
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}
(FPCore (x y)
:precision binary64
(fmin
(fmin
(fmax (- x) (fmax (- x 0.1) (fmax (- y 1.0) (- y))))
(fmin
(fmax (- 0.45 x) (fmax (- x 0.55) (fmax (- y 0.275) (- y))))
(fmin
(- (hypot (- 0.7 y) (- 0.775 x)) 0.075)
(fmax (- 0.725 x) (fmax (- x 0.825) (fmax (- y) (- y 0.55)))))))
(fmax
(- -0.275 0.275)
(fmax
(- 0.175 -0.275)
(fmax (- 0.275 y) (fmax (fmax (- x 0.55) (- y 0.55)) (- x)))))))double code(double x, double y) {
return fmin(fmin(fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))), fmin(fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y))), fmin((hypot((0.7 - y), (0.775 - x)) - 0.075), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))));
}
public static double code(double x, double y) {
return fmin(fmin(fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))), fmin(fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y))), fmin((Math.hypot((0.7 - y), (0.775 - x)) - 0.075), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))));
}
def code(x, y): return fmin(fmin(fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))), fmin(fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y))), fmin((math.hypot((0.7 - y), (0.775 - x)) - 0.075), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))))
function code(x, y) return fmin(fmin(fmax(Float64(-x), fmax(Float64(x - 0.1), fmax(Float64(y - 1.0), Float64(-y)))), fmin(fmax(Float64(0.45 - x), fmax(Float64(x - 0.55), fmax(Float64(y - 0.275), Float64(-y)))), fmin(Float64(hypot(Float64(0.7 - y), Float64(0.775 - x)) - 0.075), fmax(Float64(0.725 - x), fmax(Float64(x - 0.825), fmax(Float64(-y), Float64(y - 0.55))))))), fmax(Float64(-0.275 - 0.275), fmax(Float64(0.175 - -0.275), fmax(Float64(0.275 - y), fmax(fmax(Float64(x - 0.55), Float64(y - 0.55)), Float64(-x)))))) end
function tmp = code(x, y) tmp = min(min(max(-x, max((x - 0.1), max((y - 1.0), -y))), min(max((0.45 - x), max((x - 0.55), max((y - 0.275), -y))), min((hypot((0.7 - y), (0.775 - x)) - 0.075), max((0.725 - x), max((x - 0.825), max(-y, (y - 0.55))))))), max((-0.275 - 0.275), max((0.175 - -0.275), max((0.275 - y), max(max((x - 0.55), (y - 0.55)), -x))))); end
code[x_, y_] := N[Min[N[Min[N[Max[(-x), N[Max[N[(x - 0.1), $MachinePrecision], N[Max[N[(y - 1.0), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Min[N[Max[N[(0.45 - x), $MachinePrecision], N[Max[N[(x - 0.55), $MachinePrecision], N[Max[N[(y - 0.275), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Min[N[(N[Sqrt[N[(0.7 - y), $MachinePrecision] ^ 2 + N[(0.775 - x), $MachinePrecision] ^ 2], $MachinePrecision] - 0.075), $MachinePrecision], N[Max[N[(0.725 - x), $MachinePrecision], N[Max[N[(x - 0.825), $MachinePrecision], N[Max[(-y), N[(y - 0.55), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[(-0.275 - 0.275), $MachinePrecision], N[Max[N[(0.175 - -0.275), $MachinePrecision], N[Max[N[(0.275 - y), $MachinePrecision], N[Max[N[Max[N[(x - 0.55), $MachinePrecision], N[(y - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\mathsf{min}\left(\mathsf{min}\left(\mathsf{max}\left(-x, \mathsf{max}\left(x - 0.1, \mathsf{max}\left(y - 1, -y\right)\right)\right), \mathsf{min}\left(\mathsf{max}\left(0.45 - x, \mathsf{max}\left(x - 0.55, \mathsf{max}\left(y - 0.275, -y\right)\right)\right), \mathsf{min}\left(\mathsf{hypot}\left(0.7 - y, 0.775 - x\right) - 0.075, \mathsf{max}\left(0.725 - x, \mathsf{max}\left(x - 0.825, \mathsf{max}\left(-y, y - 0.55\right)\right)\right)\right)\right)\right), \mathsf{max}\left(-0.275 - 0.275, \mathsf{max}\left(0.175 - -0.275, \mathsf{max}\left(0.275 - y, \mathsf{max}\left(\mathsf{max}\left(x - 0.55, y - 0.55\right), -x\right)\right)\right)\right)\right)
Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax (- 0.45 x) (fmax (- x 0.55) (fmax (- y 0.275) (- y)))))
(t_1 (fmax (- x 0.825) (fmax (- y) (- y 0.55))))
(t_2 (fmax (- x) (fmax (- x 0.1) (fmax (- y 1.0) (- y)))))
(t_3
(fmax
(- -0.275 0.275)
(fmax
(- 0.175 -0.275)
(fmax (- 0.275 y) (fmax (fmax (- x 0.55) (- y 0.55)) (- x)))))))
(if (<= x -4.8e+76)
(fmin
(fmin
t_2
(fmin
t_0
(fmin
(* -1.0 (* x (- 1.0 (* 0.7 (/ 1.0 x)))))
(fmax (- 0.725 x) t_1))))
t_3)
(fmin
(fmin
t_2
(fmin
t_0
(fmin (- (hypot (- 0.7 y) (- 0.775 x)) 0.075) (fmax 0.725 t_1))))
t_3))))double code(double x, double y) {
double t_0 = fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y)));
double t_1 = fmax((x - 0.825), fmax(-y, (y - 0.55)));
double t_2 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y)));
double t_3 = fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x))));
double tmp;
if (x <= -4.8e+76) {
tmp = fmin(fmin(t_2, fmin(t_0, fmin((-1.0 * (x * (1.0 - (0.7 * (1.0 / x))))), fmax((0.725 - x), t_1)))), t_3);
} else {
tmp = fmin(fmin(t_2, fmin(t_0, fmin((hypot((0.7 - y), (0.775 - x)) - 0.075), fmax(0.725, t_1)))), t_3);
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y)));
double t_1 = fmax((x - 0.825), fmax(-y, (y - 0.55)));
double t_2 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y)));
double t_3 = fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x))));
double tmp;
if (x <= -4.8e+76) {
tmp = fmin(fmin(t_2, fmin(t_0, fmin((-1.0 * (x * (1.0 - (0.7 * (1.0 / x))))), fmax((0.725 - x), t_1)))), t_3);
} else {
tmp = fmin(fmin(t_2, fmin(t_0, fmin((Math.hypot((0.7 - y), (0.775 - x)) - 0.075), fmax(0.725, t_1)))), t_3);
}
return tmp;
}
def code(x, y): t_0 = fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y))) t_1 = fmax((x - 0.825), fmax(-y, (y - 0.55))) t_2 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))) t_3 = fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))) tmp = 0 if x <= -4.8e+76: tmp = fmin(fmin(t_2, fmin(t_0, fmin((-1.0 * (x * (1.0 - (0.7 * (1.0 / x))))), fmax((0.725 - x), t_1)))), t_3) else: tmp = fmin(fmin(t_2, fmin(t_0, fmin((math.hypot((0.7 - y), (0.775 - x)) - 0.075), fmax(0.725, t_1)))), t_3) return tmp
function code(x, y) t_0 = fmax(Float64(0.45 - x), fmax(Float64(x - 0.55), fmax(Float64(y - 0.275), Float64(-y)))) t_1 = fmax(Float64(x - 0.825), fmax(Float64(-y), Float64(y - 0.55))) t_2 = fmax(Float64(-x), fmax(Float64(x - 0.1), fmax(Float64(y - 1.0), Float64(-y)))) t_3 = fmax(Float64(-0.275 - 0.275), fmax(Float64(0.175 - -0.275), fmax(Float64(0.275 - y), fmax(fmax(Float64(x - 0.55), Float64(y - 0.55)), Float64(-x))))) tmp = 0.0 if (x <= -4.8e+76) tmp = fmin(fmin(t_2, fmin(t_0, fmin(Float64(-1.0 * Float64(x * Float64(1.0 - Float64(0.7 * Float64(1.0 / x))))), fmax(Float64(0.725 - x), t_1)))), t_3); else tmp = fmin(fmin(t_2, fmin(t_0, fmin(Float64(hypot(Float64(0.7 - y), Float64(0.775 - x)) - 0.075), fmax(0.725, t_1)))), t_3); end return tmp end
function tmp_2 = code(x, y) t_0 = max((0.45 - x), max((x - 0.55), max((y - 0.275), -y))); t_1 = max((x - 0.825), max(-y, (y - 0.55))); t_2 = max(-x, max((x - 0.1), max((y - 1.0), -y))); t_3 = max((-0.275 - 0.275), max((0.175 - -0.275), max((0.275 - y), max(max((x - 0.55), (y - 0.55)), -x)))); tmp = 0.0; if (x <= -4.8e+76) tmp = min(min(t_2, min(t_0, min((-1.0 * (x * (1.0 - (0.7 * (1.0 / x))))), max((0.725 - x), t_1)))), t_3); else tmp = min(min(t_2, min(t_0, min((hypot((0.7 - y), (0.775 - x)) - 0.075), max(0.725, t_1)))), t_3); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[N[(0.45 - x), $MachinePrecision], N[Max[N[(x - 0.55), $MachinePrecision], N[Max[N[(y - 0.275), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[(x - 0.825), $MachinePrecision], N[Max[(-y), N[(y - 0.55), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[(-x), N[Max[N[(x - 0.1), $MachinePrecision], N[Max[N[(y - 1.0), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Max[N[(-0.275 - 0.275), $MachinePrecision], N[Max[N[(0.175 - -0.275), $MachinePrecision], N[Max[N[(0.275 - y), $MachinePrecision], N[Max[N[Max[N[(x - 0.55), $MachinePrecision], N[(y - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -4.8e+76], N[Min[N[Min[t$95$2, N[Min[t$95$0, N[Min[N[(-1.0 * N[(x * N[(1.0 - N[(0.7 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Max[N[(0.725 - x), $MachinePrecision], t$95$1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$3], $MachinePrecision], N[Min[N[Min[t$95$2, N[Min[t$95$0, N[Min[N[(N[Sqrt[N[(0.7 - y), $MachinePrecision] ^ 2 + N[(0.775 - x), $MachinePrecision] ^ 2], $MachinePrecision] - 0.075), $MachinePrecision], N[Max[0.725, t$95$1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$3], $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(0.45 - x, \mathsf{max}\left(x - 0.55, \mathsf{max}\left(y - 0.275, -y\right)\right)\right)\\
t_1 := \mathsf{max}\left(x - 0.825, \mathsf{max}\left(-y, y - 0.55\right)\right)\\
t_2 := \mathsf{max}\left(-x, \mathsf{max}\left(x - 0.1, \mathsf{max}\left(y - 1, -y\right)\right)\right)\\
t_3 := \mathsf{max}\left(-0.275 - 0.275, \mathsf{max}\left(0.175 - -0.275, \mathsf{max}\left(0.275 - y, \mathsf{max}\left(\mathsf{max}\left(x - 0.55, y - 0.55\right), -x\right)\right)\right)\right)\\
\mathbf{if}\;x \leq -4.8 \cdot 10^{+76}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(t\_2, \mathsf{min}\left(t\_0, \mathsf{min}\left(-1 \cdot \left(x \cdot \left(1 - 0.7 \cdot \frac{1}{x}\right)\right), \mathsf{max}\left(0.725 - x, t\_1\right)\right)\right)\right), t\_3\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(t\_2, \mathsf{min}\left(t\_0, \mathsf{min}\left(\mathsf{hypot}\left(0.7 - y, 0.775 - x\right) - 0.075, \mathsf{max}\left(0.725, t\_1\right)\right)\right)\right), t\_3\right)\\
\end{array}
if x < -4.8e76Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6445.6%
Applied rewrites45.6%
if -4.8e76 < x Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites82.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax (- 0.45 x) (fmax (- x 0.55) (fmax (- y 0.275) (- y)))))
(t_1 (fmax (- 0.725 x) (fmax (- x 0.825) (fmax (- y) (- y 0.55)))))
(t_2 (fmax (- x) (fmax (- x 0.1) (fmax (- y 1.0) (- y)))))
(t_3
(fmax
(- -0.275 0.275)
(fmax
(- 0.175 -0.275)
(fmax (- 0.275 y) (fmax (fmax (- x 0.55) (- y 0.55)) (- x)))))))
(if (<= x -1.8e+25)
(fmin
(fmin t_2 (fmin t_0 (fmin (* -1.0 (* x (- 1.0 (* 0.7 (/ 1.0 x))))) t_1)))
t_3)
(if (<= x 9.5e+20)
(fmin
(fmin
t_2
(fmin t_0 (fmin (* -1.0 (* y (- 1.0 (* 0.625 (/ 1.0 y))))) t_1)))
t_3)
(fmin
(fmin t_2 (fmin t_0 (fmin (* x (- 1.0 (* 0.85 (/ 1.0 x)))) t_1)))
t_3)))))double code(double x, double y) {
double t_0 = fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y)));
double t_1 = fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))));
double t_2 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y)));
double t_3 = fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x))));
double tmp;
if (x <= -1.8e+25) {
tmp = fmin(fmin(t_2, fmin(t_0, fmin((-1.0 * (x * (1.0 - (0.7 * (1.0 / x))))), t_1))), t_3);
} else if (x <= 9.5e+20) {
tmp = fmin(fmin(t_2, fmin(t_0, fmin((-1.0 * (y * (1.0 - (0.625 * (1.0 / y))))), t_1))), t_3);
} else {
tmp = fmin(fmin(t_2, fmin(t_0, fmin((x * (1.0 - (0.85 * (1.0 / x)))), 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((0.45d0 - x), fmax((x - 0.55d0), fmax((y - 0.275d0), -y)))
t_1 = fmax((0.725d0 - x), fmax((x - 0.825d0), fmax(-y, (y - 0.55d0))))
t_2 = fmax(-x, fmax((x - 0.1d0), fmax((y - 1.0d0), -y)))
t_3 = fmax(((-0.275d0) - 0.275d0), fmax((0.175d0 - (-0.275d0)), fmax((0.275d0 - y), fmax(fmax((x - 0.55d0), (y - 0.55d0)), -x))))
if (x <= (-1.8d+25)) then
tmp = fmin(fmin(t_2, fmin(t_0, fmin(((-1.0d0) * (x * (1.0d0 - (0.7d0 * (1.0d0 / x))))), t_1))), t_3)
else if (x <= 9.5d+20) then
tmp = fmin(fmin(t_2, fmin(t_0, fmin(((-1.0d0) * (y * (1.0d0 - (0.625d0 * (1.0d0 / y))))), t_1))), t_3)
else
tmp = fmin(fmin(t_2, fmin(t_0, fmin((x * (1.0d0 - (0.85d0 * (1.0d0 / x)))), t_1))), t_3)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y)));
double t_1 = fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))));
double t_2 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y)));
double t_3 = fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x))));
double tmp;
if (x <= -1.8e+25) {
tmp = fmin(fmin(t_2, fmin(t_0, fmin((-1.0 * (x * (1.0 - (0.7 * (1.0 / x))))), t_1))), t_3);
} else if (x <= 9.5e+20) {
tmp = fmin(fmin(t_2, fmin(t_0, fmin((-1.0 * (y * (1.0 - (0.625 * (1.0 / y))))), t_1))), t_3);
} else {
tmp = fmin(fmin(t_2, fmin(t_0, fmin((x * (1.0 - (0.85 * (1.0 / x)))), t_1))), t_3);
}
return tmp;
}
def code(x, y): t_0 = fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y))) t_1 = fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55)))) t_2 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))) t_3 = fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))) tmp = 0 if x <= -1.8e+25: tmp = fmin(fmin(t_2, fmin(t_0, fmin((-1.0 * (x * (1.0 - (0.7 * (1.0 / x))))), t_1))), t_3) elif x <= 9.5e+20: tmp = fmin(fmin(t_2, fmin(t_0, fmin((-1.0 * (y * (1.0 - (0.625 * (1.0 / y))))), t_1))), t_3) else: tmp = fmin(fmin(t_2, fmin(t_0, fmin((x * (1.0 - (0.85 * (1.0 / x)))), t_1))), t_3) return tmp
function code(x, y) t_0 = fmax(Float64(0.45 - x), fmax(Float64(x - 0.55), fmax(Float64(y - 0.275), Float64(-y)))) t_1 = fmax(Float64(0.725 - x), fmax(Float64(x - 0.825), fmax(Float64(-y), Float64(y - 0.55)))) t_2 = fmax(Float64(-x), fmax(Float64(x - 0.1), fmax(Float64(y - 1.0), Float64(-y)))) t_3 = fmax(Float64(-0.275 - 0.275), fmax(Float64(0.175 - -0.275), fmax(Float64(0.275 - y), fmax(fmax(Float64(x - 0.55), Float64(y - 0.55)), Float64(-x))))) tmp = 0.0 if (x <= -1.8e+25) tmp = fmin(fmin(t_2, fmin(t_0, fmin(Float64(-1.0 * Float64(x * Float64(1.0 - Float64(0.7 * Float64(1.0 / x))))), t_1))), t_3); elseif (x <= 9.5e+20) tmp = fmin(fmin(t_2, fmin(t_0, fmin(Float64(-1.0 * Float64(y * Float64(1.0 - Float64(0.625 * Float64(1.0 / y))))), t_1))), t_3); else tmp = fmin(fmin(t_2, fmin(t_0, fmin(Float64(x * Float64(1.0 - Float64(0.85 * Float64(1.0 / x)))), t_1))), t_3); end return tmp end
function tmp_2 = code(x, y) t_0 = max((0.45 - x), max((x - 0.55), max((y - 0.275), -y))); t_1 = max((0.725 - x), max((x - 0.825), max(-y, (y - 0.55)))); t_2 = max(-x, max((x - 0.1), max((y - 1.0), -y))); t_3 = max((-0.275 - 0.275), max((0.175 - -0.275), max((0.275 - y), max(max((x - 0.55), (y - 0.55)), -x)))); tmp = 0.0; if (x <= -1.8e+25) tmp = min(min(t_2, min(t_0, min((-1.0 * (x * (1.0 - (0.7 * (1.0 / x))))), t_1))), t_3); elseif (x <= 9.5e+20) tmp = min(min(t_2, min(t_0, min((-1.0 * (y * (1.0 - (0.625 * (1.0 / y))))), t_1))), t_3); else tmp = min(min(t_2, min(t_0, min((x * (1.0 - (0.85 * (1.0 / x)))), t_1))), t_3); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[N[(0.45 - x), $MachinePrecision], N[Max[N[(x - 0.55), $MachinePrecision], N[Max[N[(y - 0.275), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[(0.725 - x), $MachinePrecision], N[Max[N[(x - 0.825), $MachinePrecision], N[Max[(-y), N[(y - 0.55), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[(-x), N[Max[N[(x - 0.1), $MachinePrecision], N[Max[N[(y - 1.0), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Max[N[(-0.275 - 0.275), $MachinePrecision], N[Max[N[(0.175 - -0.275), $MachinePrecision], N[Max[N[(0.275 - y), $MachinePrecision], N[Max[N[Max[N[(x - 0.55), $MachinePrecision], N[(y - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.8e+25], N[Min[N[Min[t$95$2, N[Min[t$95$0, N[Min[N[(-1.0 * N[(x * N[(1.0 - N[(0.7 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$3], $MachinePrecision], If[LessEqual[x, 9.5e+20], N[Min[N[Min[t$95$2, N[Min[t$95$0, N[Min[N[(-1.0 * N[(y * N[(1.0 - N[(0.625 * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$3], $MachinePrecision], N[Min[N[Min[t$95$2, N[Min[t$95$0, N[Min[N[(x * N[(1.0 - N[(0.85 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$3], $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(0.45 - x, \mathsf{max}\left(x - 0.55, \mathsf{max}\left(y - 0.275, -y\right)\right)\right)\\
t_1 := \mathsf{max}\left(0.725 - x, \mathsf{max}\left(x - 0.825, \mathsf{max}\left(-y, y - 0.55\right)\right)\right)\\
t_2 := \mathsf{max}\left(-x, \mathsf{max}\left(x - 0.1, \mathsf{max}\left(y - 1, -y\right)\right)\right)\\
t_3 := \mathsf{max}\left(-0.275 - 0.275, \mathsf{max}\left(0.175 - -0.275, \mathsf{max}\left(0.275 - y, \mathsf{max}\left(\mathsf{max}\left(x - 0.55, y - 0.55\right), -x\right)\right)\right)\right)\\
\mathbf{if}\;x \leq -1.8 \cdot 10^{+25}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(t\_2, \mathsf{min}\left(t\_0, \mathsf{min}\left(-1 \cdot \left(x \cdot \left(1 - 0.7 \cdot \frac{1}{x}\right)\right), t\_1\right)\right)\right), t\_3\right)\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+20}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(t\_2, \mathsf{min}\left(t\_0, \mathsf{min}\left(-1 \cdot \left(y \cdot \left(1 - 0.625 \cdot \frac{1}{y}\right)\right), t\_1\right)\right)\right), t\_3\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(t\_2, \mathsf{min}\left(t\_0, \mathsf{min}\left(x \cdot \left(1 - 0.85 \cdot \frac{1}{x}\right), t\_1\right)\right)\right), t\_3\right)\\
\end{array}
if x < -1.80000000000000008e25Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6445.6%
Applied rewrites45.6%
if -1.80000000000000008e25 < x < 9.5e20Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in y around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6445.7%
Applied rewrites45.7%
if 9.5e20 < x Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6419.5%
Applied rewrites19.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax (- 0.45 x) (fmax (- x 0.55) (fmax (- y 0.275) (- y)))))
(t_1 (fmax (- 0.725 x) (fmax (- x 0.825) (fmax (- y) (- y 0.55)))))
(t_2 (fmax (- x) (fmax (- x 0.1) (fmax (- y 1.0) (- y)))))
(t_3
(fmax
(- -0.275 0.275)
(fmax
(- 0.175 -0.275)
(fmax (- 0.275 y) (fmax (fmax (- x 0.55) (- y 0.55)) (- x)))))))
(if (<= x 0.78)
(fmin
(fmin t_2 (fmin t_0 (fmin (* -1.0 (* x (- 1.0 (* 0.7 (/ 1.0 x))))) t_1)))
t_3)
(fmin
(fmin
t_2
(fmin t_0 (fmin (- (* x (- 1.0 (* 0.775 (/ 1.0 x)))) 0.075) t_1)))
t_3))))double code(double x, double y) {
double t_0 = fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y)));
double t_1 = fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))));
double t_2 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y)));
double t_3 = fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x))));
double tmp;
if (x <= 0.78) {
tmp = fmin(fmin(t_2, fmin(t_0, fmin((-1.0 * (x * (1.0 - (0.7 * (1.0 / x))))), t_1))), t_3);
} else {
tmp = fmin(fmin(t_2, fmin(t_0, fmin(((x * (1.0 - (0.775 * (1.0 / x)))) - 0.075), 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((0.45d0 - x), fmax((x - 0.55d0), fmax((y - 0.275d0), -y)))
t_1 = fmax((0.725d0 - x), fmax((x - 0.825d0), fmax(-y, (y - 0.55d0))))
t_2 = fmax(-x, fmax((x - 0.1d0), fmax((y - 1.0d0), -y)))
t_3 = fmax(((-0.275d0) - 0.275d0), fmax((0.175d0 - (-0.275d0)), fmax((0.275d0 - y), fmax(fmax((x - 0.55d0), (y - 0.55d0)), -x))))
if (x <= 0.78d0) then
tmp = fmin(fmin(t_2, fmin(t_0, fmin(((-1.0d0) * (x * (1.0d0 - (0.7d0 * (1.0d0 / x))))), t_1))), t_3)
else
tmp = fmin(fmin(t_2, fmin(t_0, fmin(((x * (1.0d0 - (0.775d0 * (1.0d0 / x)))) - 0.075d0), t_1))), t_3)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y)));
double t_1 = fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))));
double t_2 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y)));
double t_3 = fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x))));
double tmp;
if (x <= 0.78) {
tmp = fmin(fmin(t_2, fmin(t_0, fmin((-1.0 * (x * (1.0 - (0.7 * (1.0 / x))))), t_1))), t_3);
} else {
tmp = fmin(fmin(t_2, fmin(t_0, fmin(((x * (1.0 - (0.775 * (1.0 / x)))) - 0.075), t_1))), t_3);
}
return tmp;
}
def code(x, y): t_0 = fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y))) t_1 = fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55)))) t_2 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))) t_3 = fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))) tmp = 0 if x <= 0.78: tmp = fmin(fmin(t_2, fmin(t_0, fmin((-1.0 * (x * (1.0 - (0.7 * (1.0 / x))))), t_1))), t_3) else: tmp = fmin(fmin(t_2, fmin(t_0, fmin(((x * (1.0 - (0.775 * (1.0 / x)))) - 0.075), t_1))), t_3) return tmp
function code(x, y) t_0 = fmax(Float64(0.45 - x), fmax(Float64(x - 0.55), fmax(Float64(y - 0.275), Float64(-y)))) t_1 = fmax(Float64(0.725 - x), fmax(Float64(x - 0.825), fmax(Float64(-y), Float64(y - 0.55)))) t_2 = fmax(Float64(-x), fmax(Float64(x - 0.1), fmax(Float64(y - 1.0), Float64(-y)))) t_3 = fmax(Float64(-0.275 - 0.275), fmax(Float64(0.175 - -0.275), fmax(Float64(0.275 - y), fmax(fmax(Float64(x - 0.55), Float64(y - 0.55)), Float64(-x))))) tmp = 0.0 if (x <= 0.78) tmp = fmin(fmin(t_2, fmin(t_0, fmin(Float64(-1.0 * Float64(x * Float64(1.0 - Float64(0.7 * Float64(1.0 / x))))), t_1))), t_3); else tmp = fmin(fmin(t_2, fmin(t_0, fmin(Float64(Float64(x * Float64(1.0 - Float64(0.775 * Float64(1.0 / x)))) - 0.075), t_1))), t_3); end return tmp end
function tmp_2 = code(x, y) t_0 = max((0.45 - x), max((x - 0.55), max((y - 0.275), -y))); t_1 = max((0.725 - x), max((x - 0.825), max(-y, (y - 0.55)))); t_2 = max(-x, max((x - 0.1), max((y - 1.0), -y))); t_3 = max((-0.275 - 0.275), max((0.175 - -0.275), max((0.275 - y), max(max((x - 0.55), (y - 0.55)), -x)))); tmp = 0.0; if (x <= 0.78) tmp = min(min(t_2, min(t_0, min((-1.0 * (x * (1.0 - (0.7 * (1.0 / x))))), t_1))), t_3); else tmp = min(min(t_2, min(t_0, min(((x * (1.0 - (0.775 * (1.0 / x)))) - 0.075), t_1))), t_3); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[N[(0.45 - x), $MachinePrecision], N[Max[N[(x - 0.55), $MachinePrecision], N[Max[N[(y - 0.275), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[(0.725 - x), $MachinePrecision], N[Max[N[(x - 0.825), $MachinePrecision], N[Max[(-y), N[(y - 0.55), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[(-x), N[Max[N[(x - 0.1), $MachinePrecision], N[Max[N[(y - 1.0), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Max[N[(-0.275 - 0.275), $MachinePrecision], N[Max[N[(0.175 - -0.275), $MachinePrecision], N[Max[N[(0.275 - y), $MachinePrecision], N[Max[N[Max[N[(x - 0.55), $MachinePrecision], N[(y - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 0.78], N[Min[N[Min[t$95$2, N[Min[t$95$0, N[Min[N[(-1.0 * N[(x * N[(1.0 - N[(0.7 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$3], $MachinePrecision], N[Min[N[Min[t$95$2, N[Min[t$95$0, N[Min[N[(N[(x * N[(1.0 - N[(0.775 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.075), $MachinePrecision], t$95$1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$3], $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(0.45 - x, \mathsf{max}\left(x - 0.55, \mathsf{max}\left(y - 0.275, -y\right)\right)\right)\\
t_1 := \mathsf{max}\left(0.725 - x, \mathsf{max}\left(x - 0.825, \mathsf{max}\left(-y, y - 0.55\right)\right)\right)\\
t_2 := \mathsf{max}\left(-x, \mathsf{max}\left(x - 0.1, \mathsf{max}\left(y - 1, -y\right)\right)\right)\\
t_3 := \mathsf{max}\left(-0.275 - 0.275, \mathsf{max}\left(0.175 - -0.275, \mathsf{max}\left(0.275 - y, \mathsf{max}\left(\mathsf{max}\left(x - 0.55, y - 0.55\right), -x\right)\right)\right)\right)\\
\mathbf{if}\;x \leq 0.78:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(t\_2, \mathsf{min}\left(t\_0, \mathsf{min}\left(-1 \cdot \left(x \cdot \left(1 - 0.7 \cdot \frac{1}{x}\right)\right), t\_1\right)\right)\right), t\_3\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(t\_2, \mathsf{min}\left(t\_0, \mathsf{min}\left(x \cdot \left(1 - 0.775 \cdot \frac{1}{x}\right) - 0.075, t\_1\right)\right)\right), t\_3\right)\\
\end{array}
if x < 0.78000000000000003Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6445.6%
Applied rewrites45.6%
if 0.78000000000000003 < x Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6419.5%
Applied rewrites19.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax (- 0.725 x) (fmax (- x 0.825) (fmax (- y) (- y 0.55)))))
(t_1 (fmax (- 0.45 x) (fmax (- x 0.55) (fmax (- y 0.275) (- y)))))
(t_2 (fmax (- x) (fmax (- x 0.1) (fmax (- y 1.0) (- y)))))
(t_3
(fmax
(- -0.275 0.275)
(fmax
(- 0.175 -0.275)
(fmax (- 0.275 y) (fmax (fmax (- x 0.55) (- y 0.55)) (- x)))))))
(if (<= x 0.84)
(fmin
(fmin t_2 (fmin t_1 (fmin (* y (- 1.0 (* 0.775 (/ 1.0 y)))) t_0)))
t_3)
(fmin
(fmin
t_2
(fmin t_1 (fmin (- (* x (- 1.0 (* 0.775 (/ 1.0 x)))) 0.075) t_0)))
t_3))))double code(double x, double y) {
double t_0 = fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))));
double t_1 = fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y)));
double t_2 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y)));
double t_3 = fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x))));
double tmp;
if (x <= 0.84) {
tmp = fmin(fmin(t_2, fmin(t_1, fmin((y * (1.0 - (0.775 * (1.0 / y)))), t_0))), t_3);
} else {
tmp = fmin(fmin(t_2, fmin(t_1, fmin(((x * (1.0 - (0.775 * (1.0 / x)))) - 0.075), t_0))), 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((0.725d0 - x), fmax((x - 0.825d0), fmax(-y, (y - 0.55d0))))
t_1 = fmax((0.45d0 - x), fmax((x - 0.55d0), fmax((y - 0.275d0), -y)))
t_2 = fmax(-x, fmax((x - 0.1d0), fmax((y - 1.0d0), -y)))
t_3 = fmax(((-0.275d0) - 0.275d0), fmax((0.175d0 - (-0.275d0)), fmax((0.275d0 - y), fmax(fmax((x - 0.55d0), (y - 0.55d0)), -x))))
if (x <= 0.84d0) then
tmp = fmin(fmin(t_2, fmin(t_1, fmin((y * (1.0d0 - (0.775d0 * (1.0d0 / y)))), t_0))), t_3)
else
tmp = fmin(fmin(t_2, fmin(t_1, fmin(((x * (1.0d0 - (0.775d0 * (1.0d0 / x)))) - 0.075d0), t_0))), t_3)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))));
double t_1 = fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y)));
double t_2 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y)));
double t_3 = fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x))));
double tmp;
if (x <= 0.84) {
tmp = fmin(fmin(t_2, fmin(t_1, fmin((y * (1.0 - (0.775 * (1.0 / y)))), t_0))), t_3);
} else {
tmp = fmin(fmin(t_2, fmin(t_1, fmin(((x * (1.0 - (0.775 * (1.0 / x)))) - 0.075), t_0))), t_3);
}
return tmp;
}
def code(x, y): t_0 = fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55)))) t_1 = fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y))) t_2 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))) t_3 = fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))) tmp = 0 if x <= 0.84: tmp = fmin(fmin(t_2, fmin(t_1, fmin((y * (1.0 - (0.775 * (1.0 / y)))), t_0))), t_3) else: tmp = fmin(fmin(t_2, fmin(t_1, fmin(((x * (1.0 - (0.775 * (1.0 / x)))) - 0.075), t_0))), t_3) return tmp
function code(x, y) t_0 = fmax(Float64(0.725 - x), fmax(Float64(x - 0.825), fmax(Float64(-y), Float64(y - 0.55)))) t_1 = fmax(Float64(0.45 - x), fmax(Float64(x - 0.55), fmax(Float64(y - 0.275), Float64(-y)))) t_2 = fmax(Float64(-x), fmax(Float64(x - 0.1), fmax(Float64(y - 1.0), Float64(-y)))) t_3 = fmax(Float64(-0.275 - 0.275), fmax(Float64(0.175 - -0.275), fmax(Float64(0.275 - y), fmax(fmax(Float64(x - 0.55), Float64(y - 0.55)), Float64(-x))))) tmp = 0.0 if (x <= 0.84) tmp = fmin(fmin(t_2, fmin(t_1, fmin(Float64(y * Float64(1.0 - Float64(0.775 * Float64(1.0 / y)))), t_0))), t_3); else tmp = fmin(fmin(t_2, fmin(t_1, fmin(Float64(Float64(x * Float64(1.0 - Float64(0.775 * Float64(1.0 / x)))) - 0.075), t_0))), t_3); end return tmp end
function tmp_2 = code(x, y) t_0 = max((0.725 - x), max((x - 0.825), max(-y, (y - 0.55)))); t_1 = max((0.45 - x), max((x - 0.55), max((y - 0.275), -y))); t_2 = max(-x, max((x - 0.1), max((y - 1.0), -y))); t_3 = max((-0.275 - 0.275), max((0.175 - -0.275), max((0.275 - y), max(max((x - 0.55), (y - 0.55)), -x)))); tmp = 0.0; if (x <= 0.84) tmp = min(min(t_2, min(t_1, min((y * (1.0 - (0.775 * (1.0 / y)))), t_0))), t_3); else tmp = min(min(t_2, min(t_1, min(((x * (1.0 - (0.775 * (1.0 / x)))) - 0.075), t_0))), t_3); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[N[(0.725 - x), $MachinePrecision], N[Max[N[(x - 0.825), $MachinePrecision], N[Max[(-y), N[(y - 0.55), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[(0.45 - x), $MachinePrecision], N[Max[N[(x - 0.55), $MachinePrecision], N[Max[N[(y - 0.275), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[(-x), N[Max[N[(x - 0.1), $MachinePrecision], N[Max[N[(y - 1.0), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Max[N[(-0.275 - 0.275), $MachinePrecision], N[Max[N[(0.175 - -0.275), $MachinePrecision], N[Max[N[(0.275 - y), $MachinePrecision], N[Max[N[Max[N[(x - 0.55), $MachinePrecision], N[(y - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 0.84], N[Min[N[Min[t$95$2, N[Min[t$95$1, N[Min[N[(y * N[(1.0 - N[(0.775 * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$3], $MachinePrecision], N[Min[N[Min[t$95$2, N[Min[t$95$1, N[Min[N[(N[(x * N[(1.0 - N[(0.775 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.075), $MachinePrecision], t$95$0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$3], $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(0.725 - x, \mathsf{max}\left(x - 0.825, \mathsf{max}\left(-y, y - 0.55\right)\right)\right)\\
t_1 := \mathsf{max}\left(0.45 - x, \mathsf{max}\left(x - 0.55, \mathsf{max}\left(y - 0.275, -y\right)\right)\right)\\
t_2 := \mathsf{max}\left(-x, \mathsf{max}\left(x - 0.1, \mathsf{max}\left(y - 1, -y\right)\right)\right)\\
t_3 := \mathsf{max}\left(-0.275 - 0.275, \mathsf{max}\left(0.175 - -0.275, \mathsf{max}\left(0.275 - y, \mathsf{max}\left(\mathsf{max}\left(x - 0.55, y - 0.55\right), -x\right)\right)\right)\right)\\
\mathbf{if}\;x \leq 0.84:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(t\_2, \mathsf{min}\left(t\_1, \mathsf{min}\left(y \cdot \left(1 - 0.775 \cdot \frac{1}{y}\right), t\_0\right)\right)\right), t\_3\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(t\_2, \mathsf{min}\left(t\_1, \mathsf{min}\left(x \cdot \left(1 - 0.775 \cdot \frac{1}{x}\right) - 0.075, t\_0\right)\right)\right), t\_3\right)\\
\end{array}
if x < 0.839999999999999969Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6420.8%
Applied rewrites20.8%
if 0.839999999999999969 < x Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6419.5%
Applied rewrites19.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax (- 0.725 x) (fmax (- x 0.825) (fmax (- y) (- y 0.55)))))
(t_1 (fmax (- 0.45 x) (fmax (- x 0.55) (fmax (- y 0.275) (- y)))))
(t_2 (fmax (- x) (fmax (- x 0.1) (fmax (- y 1.0) (- y)))))
(t_3
(fmax
(- -0.275 0.275)
(fmax
(- 0.175 -0.275)
(fmax (- 0.275 y) (fmax (fmax (- x 0.55) (- y 0.55)) (- x)))))))
(if (<= x 0.84)
(fmin
(fmin t_2 (fmin t_1 (fmin (* y (- 1.0 (* 0.775 (/ 1.0 y)))) t_0)))
t_3)
(fmin
(fmin t_2 (fmin t_1 (fmin (* x (- 1.0 (* 0.85 (/ 1.0 x)))) t_0)))
t_3))))double code(double x, double y) {
double t_0 = fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))));
double t_1 = fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y)));
double t_2 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y)));
double t_3 = fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x))));
double tmp;
if (x <= 0.84) {
tmp = fmin(fmin(t_2, fmin(t_1, fmin((y * (1.0 - (0.775 * (1.0 / y)))), t_0))), t_3);
} else {
tmp = fmin(fmin(t_2, fmin(t_1, fmin((x * (1.0 - (0.85 * (1.0 / x)))), t_0))), 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((0.725d0 - x), fmax((x - 0.825d0), fmax(-y, (y - 0.55d0))))
t_1 = fmax((0.45d0 - x), fmax((x - 0.55d0), fmax((y - 0.275d0), -y)))
t_2 = fmax(-x, fmax((x - 0.1d0), fmax((y - 1.0d0), -y)))
t_3 = fmax(((-0.275d0) - 0.275d0), fmax((0.175d0 - (-0.275d0)), fmax((0.275d0 - y), fmax(fmax((x - 0.55d0), (y - 0.55d0)), -x))))
if (x <= 0.84d0) then
tmp = fmin(fmin(t_2, fmin(t_1, fmin((y * (1.0d0 - (0.775d0 * (1.0d0 / y)))), t_0))), t_3)
else
tmp = fmin(fmin(t_2, fmin(t_1, fmin((x * (1.0d0 - (0.85d0 * (1.0d0 / x)))), t_0))), t_3)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))));
double t_1 = fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y)));
double t_2 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y)));
double t_3 = fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x))));
double tmp;
if (x <= 0.84) {
tmp = fmin(fmin(t_2, fmin(t_1, fmin((y * (1.0 - (0.775 * (1.0 / y)))), t_0))), t_3);
} else {
tmp = fmin(fmin(t_2, fmin(t_1, fmin((x * (1.0 - (0.85 * (1.0 / x)))), t_0))), t_3);
}
return tmp;
}
def code(x, y): t_0 = fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55)))) t_1 = fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y))) t_2 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))) t_3 = fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))) tmp = 0 if x <= 0.84: tmp = fmin(fmin(t_2, fmin(t_1, fmin((y * (1.0 - (0.775 * (1.0 / y)))), t_0))), t_3) else: tmp = fmin(fmin(t_2, fmin(t_1, fmin((x * (1.0 - (0.85 * (1.0 / x)))), t_0))), t_3) return tmp
function code(x, y) t_0 = fmax(Float64(0.725 - x), fmax(Float64(x - 0.825), fmax(Float64(-y), Float64(y - 0.55)))) t_1 = fmax(Float64(0.45 - x), fmax(Float64(x - 0.55), fmax(Float64(y - 0.275), Float64(-y)))) t_2 = fmax(Float64(-x), fmax(Float64(x - 0.1), fmax(Float64(y - 1.0), Float64(-y)))) t_3 = fmax(Float64(-0.275 - 0.275), fmax(Float64(0.175 - -0.275), fmax(Float64(0.275 - y), fmax(fmax(Float64(x - 0.55), Float64(y - 0.55)), Float64(-x))))) tmp = 0.0 if (x <= 0.84) tmp = fmin(fmin(t_2, fmin(t_1, fmin(Float64(y * Float64(1.0 - Float64(0.775 * Float64(1.0 / y)))), t_0))), t_3); else tmp = fmin(fmin(t_2, fmin(t_1, fmin(Float64(x * Float64(1.0 - Float64(0.85 * Float64(1.0 / x)))), t_0))), t_3); end return tmp end
function tmp_2 = code(x, y) t_0 = max((0.725 - x), max((x - 0.825), max(-y, (y - 0.55)))); t_1 = max((0.45 - x), max((x - 0.55), max((y - 0.275), -y))); t_2 = max(-x, max((x - 0.1), max((y - 1.0), -y))); t_3 = max((-0.275 - 0.275), max((0.175 - -0.275), max((0.275 - y), max(max((x - 0.55), (y - 0.55)), -x)))); tmp = 0.0; if (x <= 0.84) tmp = min(min(t_2, min(t_1, min((y * (1.0 - (0.775 * (1.0 / y)))), t_0))), t_3); else tmp = min(min(t_2, min(t_1, min((x * (1.0 - (0.85 * (1.0 / x)))), t_0))), t_3); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[N[(0.725 - x), $MachinePrecision], N[Max[N[(x - 0.825), $MachinePrecision], N[Max[(-y), N[(y - 0.55), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[(0.45 - x), $MachinePrecision], N[Max[N[(x - 0.55), $MachinePrecision], N[Max[N[(y - 0.275), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[(-x), N[Max[N[(x - 0.1), $MachinePrecision], N[Max[N[(y - 1.0), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Max[N[(-0.275 - 0.275), $MachinePrecision], N[Max[N[(0.175 - -0.275), $MachinePrecision], N[Max[N[(0.275 - y), $MachinePrecision], N[Max[N[Max[N[(x - 0.55), $MachinePrecision], N[(y - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 0.84], N[Min[N[Min[t$95$2, N[Min[t$95$1, N[Min[N[(y * N[(1.0 - N[(0.775 * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$3], $MachinePrecision], N[Min[N[Min[t$95$2, N[Min[t$95$1, N[Min[N[(x * N[(1.0 - N[(0.85 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$3], $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(0.725 - x, \mathsf{max}\left(x - 0.825, \mathsf{max}\left(-y, y - 0.55\right)\right)\right)\\
t_1 := \mathsf{max}\left(0.45 - x, \mathsf{max}\left(x - 0.55, \mathsf{max}\left(y - 0.275, -y\right)\right)\right)\\
t_2 := \mathsf{max}\left(-x, \mathsf{max}\left(x - 0.1, \mathsf{max}\left(y - 1, -y\right)\right)\right)\\
t_3 := \mathsf{max}\left(-0.275 - 0.275, \mathsf{max}\left(0.175 - -0.275, \mathsf{max}\left(0.275 - y, \mathsf{max}\left(\mathsf{max}\left(x - 0.55, y - 0.55\right), -x\right)\right)\right)\right)\\
\mathbf{if}\;x \leq 0.84:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(t\_2, \mathsf{min}\left(t\_1, \mathsf{min}\left(y \cdot \left(1 - 0.775 \cdot \frac{1}{y}\right), t\_0\right)\right)\right), t\_3\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(t\_2, \mathsf{min}\left(t\_1, \mathsf{min}\left(x \cdot \left(1 - 0.85 \cdot \frac{1}{x}\right), t\_0\right)\right)\right), t\_3\right)\\
\end{array}
if x < 0.839999999999999969Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6420.8%
Applied rewrites20.8%
if 0.839999999999999969 < x Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6419.5%
Applied rewrites19.5%
(FPCore (x y)
:precision binary64
(fmin
(fmin
(fmax (- x) (fmax (- x 0.1) (fmax (- y 1.0) (- y))))
(fmin
(fmax (- 0.45 x) (fmax (- x 0.55) (fmax (- y 0.275) (- y))))
(fmin
(* x (- 1.0 (* 0.85 (/ 1.0 x))))
(fmax (- 0.725 x) (fmax (- x 0.825) (fmax (- y) (- y 0.55)))))))
(fmax
(- -0.275 0.275)
(fmax
(- 0.175 -0.275)
(fmax (- 0.275 y) (fmax (fmax (- x 0.55) (- y 0.55)) (- x)))))))double code(double x, double y) {
return fmin(fmin(fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))), fmin(fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y))), fmin((x * (1.0 - (0.85 * (1.0 / x)))), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))));
}
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(fmax(-x, fmax((x - 0.1d0), fmax((y - 1.0d0), -y))), fmin(fmax((0.45d0 - x), fmax((x - 0.55d0), fmax((y - 0.275d0), -y))), fmin((x * (1.0d0 - (0.85d0 * (1.0d0 / x)))), fmax((0.725d0 - x), fmax((x - 0.825d0), fmax(-y, (y - 0.55d0))))))), fmax(((-0.275d0) - 0.275d0), fmax((0.175d0 - (-0.275d0)), fmax((0.275d0 - y), fmax(fmax((x - 0.55d0), (y - 0.55d0)), -x)))))
end function
public static double code(double x, double y) {
return fmin(fmin(fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))), fmin(fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y))), fmin((x * (1.0 - (0.85 * (1.0 / x)))), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))));
}
def code(x, y): return fmin(fmin(fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))), fmin(fmax((0.45 - x), fmax((x - 0.55), fmax((y - 0.275), -y))), fmin((x * (1.0 - (0.85 * (1.0 / x)))), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((-0.275 - 0.275), fmax((0.175 - -0.275), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))))
function code(x, y) return fmin(fmin(fmax(Float64(-x), fmax(Float64(x - 0.1), fmax(Float64(y - 1.0), Float64(-y)))), fmin(fmax(Float64(0.45 - x), fmax(Float64(x - 0.55), fmax(Float64(y - 0.275), Float64(-y)))), fmin(Float64(x * Float64(1.0 - Float64(0.85 * Float64(1.0 / x)))), fmax(Float64(0.725 - x), fmax(Float64(x - 0.825), fmax(Float64(-y), Float64(y - 0.55))))))), fmax(Float64(-0.275 - 0.275), fmax(Float64(0.175 - -0.275), fmax(Float64(0.275 - y), fmax(fmax(Float64(x - 0.55), Float64(y - 0.55)), Float64(-x)))))) end
function tmp = code(x, y) tmp = min(min(max(-x, max((x - 0.1), max((y - 1.0), -y))), min(max((0.45 - x), max((x - 0.55), max((y - 0.275), -y))), min((x * (1.0 - (0.85 * (1.0 / x)))), max((0.725 - x), max((x - 0.825), max(-y, (y - 0.55))))))), max((-0.275 - 0.275), max((0.175 - -0.275), max((0.275 - y), max(max((x - 0.55), (y - 0.55)), -x))))); end
code[x_, y_] := N[Min[N[Min[N[Max[(-x), N[Max[N[(x - 0.1), $MachinePrecision], N[Max[N[(y - 1.0), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Min[N[Max[N[(0.45 - x), $MachinePrecision], N[Max[N[(x - 0.55), $MachinePrecision], N[Max[N[(y - 0.275), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Min[N[(x * N[(1.0 - N[(0.85 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Max[N[(0.725 - x), $MachinePrecision], N[Max[N[(x - 0.825), $MachinePrecision], N[Max[(-y), N[(y - 0.55), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[(-0.275 - 0.275), $MachinePrecision], N[Max[N[(0.175 - -0.275), $MachinePrecision], N[Max[N[(0.275 - y), $MachinePrecision], N[Max[N[Max[N[(x - 0.55), $MachinePrecision], N[(y - 0.55), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\mathsf{min}\left(\mathsf{min}\left(\mathsf{max}\left(-x, \mathsf{max}\left(x - 0.1, \mathsf{max}\left(y - 1, -y\right)\right)\right), \mathsf{min}\left(\mathsf{max}\left(0.45 - x, \mathsf{max}\left(x - 0.55, \mathsf{max}\left(y - 0.275, -y\right)\right)\right), \mathsf{min}\left(x \cdot \left(1 - 0.85 \cdot \frac{1}{x}\right), \mathsf{max}\left(0.725 - x, \mathsf{max}\left(x - 0.825, \mathsf{max}\left(-y, y - 0.55\right)\right)\right)\right)\right)\right), \mathsf{max}\left(-0.275 - 0.275, \mathsf{max}\left(0.175 - -0.275, \mathsf{max}\left(0.275 - y, \mathsf{max}\left(\mathsf{max}\left(x - 0.55, y - 0.55\right), -x\right)\right)\right)\right)\right)
Initial program 100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f64100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6419.5%
Applied rewrites19.5%
herbie shell --seed 2025183
(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))))