
(FPCore (x y)
:precision binary64
(let* ((t_0 (sqrt (+ (pow (- y 11/40) 2) (pow (- x 11/40) 2)))))
(fmin
(fmin
(fmin
(fmin
(fmax (fmax (fmax (- y 11/20) (- y)) (- x 33/40)) (- 29/40 x))
(- (sqrt (+ (pow (- y 7/10) 2) (pow (- x 31/40) 2))) 3/40))
(fmax (fmax (fmax (- y) (- y 11/40)) (- x 11/20)) (- 9/20 x)))
(fmax (fmax (fmax (- y) (- y 1)) (- x 1/10)) (- x)))
(fmax
(fmax
(fmax (fmax (fmax (- y 11/20) (- x 11/20)) (- x)) (- 11/40 y))
(- 7/40 t_0))
(- t_0 11/40)))))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 - 11/40), $MachinePrecision], 2], $MachinePrecision] + N[Power[N[(x - 11/40), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Min[N[Min[N[Min[N[Min[N[Max[N[Max[N[Max[N[(y - 11/20), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 33/40), $MachinePrecision]], $MachinePrecision], N[(29/40 - x), $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[N[(N[Power[N[(y - 7/10), $MachinePrecision], 2], $MachinePrecision] + N[Power[N[(x - 31/40), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 3/40), $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 11/40), $MachinePrecision]], $MachinePrecision], N[(x - 11/20), $MachinePrecision]], $MachinePrecision], N[(9/20 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 1), $MachinePrecision]], $MachinePrecision], N[(x - 1/10), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 11/20), $MachinePrecision], N[(x - 11/20), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(11/40 - y), $MachinePrecision]], $MachinePrecision], N[(7/40 - t$95$0), $MachinePrecision]], $MachinePrecision], N[(t$95$0 - 11/40), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
t_0 := \sqrt{{\left(y - \frac{11}{40}\right)}^{2} + {\left(x - \frac{11}{40}\right)}^{2}}\\
\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{20}, -y\right), x - \frac{33}{40}\right), \frac{29}{40} - x\right), \sqrt{{\left(y - \frac{7}{10}\right)}^{2} + {\left(x - \frac{31}{40}\right)}^{2}} - \frac{3}{40}\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - \frac{11}{40}\right), x - \frac{11}{20}\right), \frac{9}{20} - x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - \frac{1}{10}\right), -x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{20}, x - \frac{11}{20}\right), -x\right), \frac{11}{40} - y\right), \frac{7}{40} - t\_0\right), t\_0 - \frac{11}{40}\right)\right)
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y)
:precision binary64
(let* ((t_0 (sqrt (+ (pow (- y 11/40) 2) (pow (- x 11/40) 2)))))
(fmin
(fmin
(fmin
(fmin
(fmax (fmax (fmax (- y 11/20) (- y)) (- x 33/40)) (- 29/40 x))
(- (sqrt (+ (pow (- y 7/10) 2) (pow (- x 31/40) 2))) 3/40))
(fmax (fmax (fmax (- y) (- y 11/40)) (- x 11/20)) (- 9/20 x)))
(fmax (fmax (fmax (- y) (- y 1)) (- x 1/10)) (- x)))
(fmax
(fmax
(fmax (fmax (fmax (- y 11/20) (- x 11/20)) (- x)) (- 11/40 y))
(- 7/40 t_0))
(- t_0 11/40)))))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 - 11/40), $MachinePrecision], 2], $MachinePrecision] + N[Power[N[(x - 11/40), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Min[N[Min[N[Min[N[Min[N[Max[N[Max[N[Max[N[(y - 11/20), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 33/40), $MachinePrecision]], $MachinePrecision], N[(29/40 - x), $MachinePrecision]], $MachinePrecision], N[(N[Sqrt[N[(N[Power[N[(y - 7/10), $MachinePrecision], 2], $MachinePrecision] + N[Power[N[(x - 31/40), $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 3/40), $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 11/40), $MachinePrecision]], $MachinePrecision], N[(x - 11/20), $MachinePrecision]], $MachinePrecision], N[(9/20 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 1), $MachinePrecision]], $MachinePrecision], N[(x - 1/10), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 11/20), $MachinePrecision], N[(x - 11/20), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(11/40 - y), $MachinePrecision]], $MachinePrecision], N[(7/40 - t$95$0), $MachinePrecision]], $MachinePrecision], N[(t$95$0 - 11/40), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
t_0 := \sqrt{{\left(y - \frac{11}{40}\right)}^{2} + {\left(x - \frac{11}{40}\right)}^{2}}\\
\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{20}, -y\right), x - \frac{33}{40}\right), \frac{29}{40} - x\right), \sqrt{{\left(y - \frac{7}{10}\right)}^{2} + {\left(x - \frac{31}{40}\right)}^{2}} - \frac{3}{40}\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - \frac{11}{40}\right), x - \frac{11}{20}\right), \frac{9}{20} - x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - \frac{1}{10}\right), -x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{20}, x - \frac{11}{20}\right), -x\right), \frac{11}{40} - y\right), \frac{7}{40} - t\_0\right), t\_0 - \frac{11}{40}\right)\right)
\end{array}
(FPCore (x y)
:precision binary64
(let* ((t_0 (sqrt (+ 121/1600 (* (- 11/40 y) (- 11/40 y))))))
(fmin
(fmin
(fmax (- x) (fmax (- x 1/10) (fmax (- y 1) (- y))))
(fmin
(fmax (- 9/20 x) (fmax (- x 11/20) (fmax (- y 11/40) (- y))))
(fmin
(-
(sqrt
(+ (* (- 31/40 x) (- 31/40 x)) (* (- 7/10 y) (- 7/10 y))))
3/40)
(fmax
(- 29/40 x)
(fmax (- x 33/40) (fmax (- y) (- y 11/20)))))))
(fmax
(- t_0 11/40)
(fmax
(- 7/40 t_0)
(fmax
(- 11/40 y)
(fmax (fmax (- x 11/20) (- y 11/20)) (- x))))))))double code(double x, double y) {
double t_0 = sqrt((0.075625 + ((0.275 - y) * (0.275 - 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((sqrt((((0.775 - x) * (0.775 - x)) + ((0.7 - y) * (0.7 - y)))) - 0.075), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((t_0 - 0.275), fmax((0.175 - t_0), 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
real(8) :: t_0
t_0 = sqrt((0.075625d0 + ((0.275d0 - y) * (0.275d0 - 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((sqrt((((0.775d0 - x) * (0.775d0 - x)) + ((0.7d0 - y) * (0.7d0 - y)))) - 0.075d0), fmax((0.725d0 - x), fmax((x - 0.825d0), fmax(-y, (y - 0.55d0))))))), fmax((t_0 - 0.275d0), fmax((0.175d0 - t_0), fmax((0.275d0 - y), fmax(fmax((x - 0.55d0), (y - 0.55d0)), -x)))))
end function
public static double code(double x, double y) {
double t_0 = Math.sqrt((0.075625 + ((0.275 - y) * (0.275 - 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.sqrt((((0.775 - x) * (0.775 - x)) + ((0.7 - y) * (0.7 - y)))) - 0.075), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((t_0 - 0.275), fmax((0.175 - t_0), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))));
}
def code(x, y): t_0 = math.sqrt((0.075625 + ((0.275 - y) * (0.275 - 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.sqrt((((0.775 - x) * (0.775 - x)) + ((0.7 - y) * (0.7 - y)))) - 0.075), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((t_0 - 0.275), fmax((0.175 - t_0), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))))
function code(x, y) t_0 = sqrt(Float64(0.075625 + Float64(Float64(0.275 - y) * Float64(0.275 - 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(sqrt(Float64(Float64(Float64(0.775 - x) * Float64(0.775 - x)) + Float64(Float64(0.7 - y) * Float64(0.7 - y)))) - 0.075), fmax(Float64(0.725 - x), fmax(Float64(x - 0.825), fmax(Float64(-y), Float64(y - 0.55))))))), fmax(Float64(t_0 - 0.275), fmax(Float64(0.175 - t_0), fmax(Float64(0.275 - y), fmax(fmax(Float64(x - 0.55), Float64(y - 0.55)), Float64(-x)))))) end
function tmp = code(x, y) t_0 = sqrt((0.075625 + ((0.275 - y) * (0.275 - 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((sqrt((((0.775 - x) * (0.775 - x)) + ((0.7 - y) * (0.7 - y)))) - 0.075), max((0.725 - x), max((x - 0.825), max(-y, (y - 0.55))))))), max((t_0 - 0.275), max((0.175 - t_0), max((0.275 - y), max(max((x - 0.55), (y - 0.55)), -x))))); end
code[x_, y_] := Block[{t$95$0 = N[Sqrt[N[(121/1600 + N[(N[(11/40 - y), $MachinePrecision] * N[(11/40 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Min[N[Min[N[Max[(-x), N[Max[N[(x - 1/10), $MachinePrecision], N[Max[N[(y - 1), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Min[N[Max[N[(9/20 - x), $MachinePrecision], N[Max[N[(x - 11/20), $MachinePrecision], N[Max[N[(y - 11/40), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Min[N[(N[Sqrt[N[(N[(N[(31/40 - x), $MachinePrecision] * N[(31/40 - x), $MachinePrecision]), $MachinePrecision] + N[(N[(7/10 - y), $MachinePrecision] * N[(7/10 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 3/40), $MachinePrecision], N[Max[N[(29/40 - x), $MachinePrecision], N[Max[N[(x - 33/40), $MachinePrecision], N[Max[(-y), N[(y - 11/20), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[(t$95$0 - 11/40), $MachinePrecision], N[Max[N[(7/40 - t$95$0), $MachinePrecision], N[Max[N[(11/40 - y), $MachinePrecision], N[Max[N[Max[N[(x - 11/20), $MachinePrecision], N[(y - 11/20), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
t_0 := \sqrt{\frac{121}{1600} + \left(\frac{11}{40} - y\right) \cdot \left(\frac{11}{40} - y\right)}\\
\mathsf{min}\left(\mathsf{min}\left(\mathsf{max}\left(-x, \mathsf{max}\left(x - \frac{1}{10}, \mathsf{max}\left(y - 1, -y\right)\right)\right), \mathsf{min}\left(\mathsf{max}\left(\frac{9}{20} - x, \mathsf{max}\left(x - \frac{11}{20}, \mathsf{max}\left(y - \frac{11}{40}, -y\right)\right)\right), \mathsf{min}\left(\sqrt{\left(\frac{31}{40} - x\right) \cdot \left(\frac{31}{40} - x\right) + \left(\frac{7}{10} - y\right) \cdot \left(\frac{7}{10} - y\right)} - \frac{3}{40}, \mathsf{max}\left(\frac{29}{40} - x, \mathsf{max}\left(x - \frac{33}{40}, \mathsf{max}\left(-y, y - \frac{11}{20}\right)\right)\right)\right)\right)\right), \mathsf{max}\left(t\_0 - \frac{11}{40}, \mathsf{max}\left(\frac{7}{40} - t\_0, \mathsf{max}\left(\frac{11}{40} - y, \mathsf{max}\left(\mathsf{max}\left(x - \frac{11}{20}, y - \frac{11}{20}\right), -x\right)\right)\right)\right)\right)
\end{array}
Initial program 100.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 (- 9/20 x) (fmax (- x 11/20) (fmax (- y 11/40) (- y)))))
(t_1
(fmax
(- 29/40 x)
(fmax (- x 33/40) (fmax (- y) (- y 11/20)))))
(t_2 (sqrt (+ 121/1600 (* (- 11/40 y) (- 11/40 y)))))
(t_3 (sqrt (+ 121/1600 (+ 121/1600 (* -11/20 y)))))
(t_4 (fmax (- x) (fmax (- x 1/10) (fmax (- y 1) (- y)))))
(t_5
(fmax
(- 11/40 y)
(fmax (fmax (- x 11/20) (- y 11/20)) (- x))))
(t_6 (fmax (- t_2 11/40) (fmax (- 7/40 t_2) t_5))))
(if (<= y -1360000000000000000)
(fmin
(fmin
t_4
(fmin
t_0
(fmin
(- (sqrt (+ 961/1600 (* (- 7/10 y) (- 7/10 y)))) 3/40)
t_1)))
(fmax (- t_3 11/40) (fmax (- 7/40 t_3) t_5)))
(if (<= y 175000000000)
(fmin
(fmin
t_4
(fmin
t_0
(fmin
(- (sqrt (+ (* (- 31/40 x) (- 31/40 x)) 49/100)) 3/40)
t_1)))
t_6)
(fmin
(fmin
t_4
(fmin
t_0
(fmin
(- (sqrt (+ 961/1600 (+ 49/100 (* -7/5 y)))) 3/40)
t_1)))
t_6)))))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 = sqrt((0.075625 + ((0.275 - y) * (0.275 - y))));
double t_3 = sqrt((0.075625 + (0.075625 + (-0.55 * y))));
double t_4 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y)));
double t_5 = fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x));
double t_6 = fmax((t_2 - 0.275), fmax((0.175 - t_2), t_5));
double tmp;
if (y <= -1.36e+18) {
tmp = fmin(fmin(t_4, fmin(t_0, fmin((sqrt((0.600625 + ((0.7 - y) * (0.7 - y)))) - 0.075), t_1))), fmax((t_3 - 0.275), fmax((0.175 - t_3), t_5)));
} else if (y <= 175000000000.0) {
tmp = fmin(fmin(t_4, fmin(t_0, fmin((sqrt((((0.775 - x) * (0.775 - x)) + 0.49)) - 0.075), t_1))), t_6);
} else {
tmp = fmin(fmin(t_4, fmin(t_0, fmin((sqrt((0.600625 + (0.49 + (-1.4 * y)))) - 0.075), t_1))), t_6);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: 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 = sqrt((0.075625d0 + ((0.275d0 - y) * (0.275d0 - y))))
t_3 = sqrt((0.075625d0 + (0.075625d0 + ((-0.55d0) * y))))
t_4 = fmax(-x, fmax((x - 0.1d0), fmax((y - 1.0d0), -y)))
t_5 = fmax((0.275d0 - y), fmax(fmax((x - 0.55d0), (y - 0.55d0)), -x))
t_6 = fmax((t_2 - 0.275d0), fmax((0.175d0 - t_2), t_5))
if (y <= (-1.36d+18)) then
tmp = fmin(fmin(t_4, fmin(t_0, fmin((sqrt((0.600625d0 + ((0.7d0 - y) * (0.7d0 - y)))) - 0.075d0), t_1))), fmax((t_3 - 0.275d0), fmax((0.175d0 - t_3), t_5)))
else if (y <= 175000000000.0d0) then
tmp = fmin(fmin(t_4, fmin(t_0, fmin((sqrt((((0.775d0 - x) * (0.775d0 - x)) + 0.49d0)) - 0.075d0), t_1))), t_6)
else
tmp = fmin(fmin(t_4, fmin(t_0, fmin((sqrt((0.600625d0 + (0.49d0 + ((-1.4d0) * y)))) - 0.075d0), t_1))), t_6)
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 = Math.sqrt((0.075625 + ((0.275 - y) * (0.275 - y))));
double t_3 = Math.sqrt((0.075625 + (0.075625 + (-0.55 * y))));
double t_4 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y)));
double t_5 = fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x));
double t_6 = fmax((t_2 - 0.275), fmax((0.175 - t_2), t_5));
double tmp;
if (y <= -1.36e+18) {
tmp = fmin(fmin(t_4, fmin(t_0, fmin((Math.sqrt((0.600625 + ((0.7 - y) * (0.7 - y)))) - 0.075), t_1))), fmax((t_3 - 0.275), fmax((0.175 - t_3), t_5)));
} else if (y <= 175000000000.0) {
tmp = fmin(fmin(t_4, fmin(t_0, fmin((Math.sqrt((((0.775 - x) * (0.775 - x)) + 0.49)) - 0.075), t_1))), t_6);
} else {
tmp = fmin(fmin(t_4, fmin(t_0, fmin((Math.sqrt((0.600625 + (0.49 + (-1.4 * y)))) - 0.075), t_1))), t_6);
}
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 = math.sqrt((0.075625 + ((0.275 - y) * (0.275 - y)))) t_3 = math.sqrt((0.075625 + (0.075625 + (-0.55 * y)))) t_4 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))) t_5 = fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)) t_6 = fmax((t_2 - 0.275), fmax((0.175 - t_2), t_5)) tmp = 0 if y <= -1.36e+18: tmp = fmin(fmin(t_4, fmin(t_0, fmin((math.sqrt((0.600625 + ((0.7 - y) * (0.7 - y)))) - 0.075), t_1))), fmax((t_3 - 0.275), fmax((0.175 - t_3), t_5))) elif y <= 175000000000.0: tmp = fmin(fmin(t_4, fmin(t_0, fmin((math.sqrt((((0.775 - x) * (0.775 - x)) + 0.49)) - 0.075), t_1))), t_6) else: tmp = fmin(fmin(t_4, fmin(t_0, fmin((math.sqrt((0.600625 + (0.49 + (-1.4 * y)))) - 0.075), t_1))), t_6) 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 = sqrt(Float64(0.075625 + Float64(Float64(0.275 - y) * Float64(0.275 - y)))) t_3 = sqrt(Float64(0.075625 + Float64(0.075625 + Float64(-0.55 * y)))) t_4 = fmax(Float64(-x), fmax(Float64(x - 0.1), fmax(Float64(y - 1.0), Float64(-y)))) t_5 = fmax(Float64(0.275 - y), fmax(fmax(Float64(x - 0.55), Float64(y - 0.55)), Float64(-x))) t_6 = fmax(Float64(t_2 - 0.275), fmax(Float64(0.175 - t_2), t_5)) tmp = 0.0 if (y <= -1.36e+18) tmp = fmin(fmin(t_4, fmin(t_0, fmin(Float64(sqrt(Float64(0.600625 + Float64(Float64(0.7 - y) * Float64(0.7 - y)))) - 0.075), t_1))), fmax(Float64(t_3 - 0.275), fmax(Float64(0.175 - t_3), t_5))); elseif (y <= 175000000000.0) tmp = fmin(fmin(t_4, fmin(t_0, fmin(Float64(sqrt(Float64(Float64(Float64(0.775 - x) * Float64(0.775 - x)) + 0.49)) - 0.075), t_1))), t_6); else tmp = fmin(fmin(t_4, fmin(t_0, fmin(Float64(sqrt(Float64(0.600625 + Float64(0.49 + Float64(-1.4 * y)))) - 0.075), t_1))), t_6); 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 = sqrt((0.075625 + ((0.275 - y) * (0.275 - y)))); t_3 = sqrt((0.075625 + (0.075625 + (-0.55 * y)))); t_4 = max(-x, max((x - 0.1), max((y - 1.0), -y))); t_5 = max((0.275 - y), max(max((x - 0.55), (y - 0.55)), -x)); t_6 = max((t_2 - 0.275), max((0.175 - t_2), t_5)); tmp = 0.0; if (y <= -1.36e+18) tmp = min(min(t_4, min(t_0, min((sqrt((0.600625 + ((0.7 - y) * (0.7 - y)))) - 0.075), t_1))), max((t_3 - 0.275), max((0.175 - t_3), t_5))); elseif (y <= 175000000000.0) tmp = min(min(t_4, min(t_0, min((sqrt((((0.775 - x) * (0.775 - x)) + 0.49)) - 0.075), t_1))), t_6); else tmp = min(min(t_4, min(t_0, min((sqrt((0.600625 + (0.49 + (-1.4 * y)))) - 0.075), t_1))), t_6); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[N[(9/20 - x), $MachinePrecision], N[Max[N[(x - 11/20), $MachinePrecision], N[Max[N[(y - 11/40), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[(29/40 - x), $MachinePrecision], N[Max[N[(x - 33/40), $MachinePrecision], N[Max[(-y), N[(y - 11/20), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(121/1600 + N[(N[(11/40 - y), $MachinePrecision] * N[(11/40 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(121/1600 + N[(121/1600 + N[(-11/20 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Max[(-x), N[Max[N[(x - 1/10), $MachinePrecision], N[Max[N[(y - 1), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Max[N[(11/40 - y), $MachinePrecision], N[Max[N[Max[N[(x - 11/20), $MachinePrecision], N[(y - 11/20), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[Max[N[(t$95$2 - 11/40), $MachinePrecision], N[Max[N[(7/40 - t$95$2), $MachinePrecision], t$95$5], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, -1360000000000000000], N[Min[N[Min[t$95$4, N[Min[t$95$0, N[Min[N[(N[Sqrt[N[(961/1600 + N[(N[(7/10 - y), $MachinePrecision] * N[(7/10 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 3/40), $MachinePrecision], t$95$1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[(t$95$3 - 11/40), $MachinePrecision], N[Max[N[(7/40 - t$95$3), $MachinePrecision], t$95$5], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], If[LessEqual[y, 175000000000], N[Min[N[Min[t$95$4, N[Min[t$95$0, N[Min[N[(N[Sqrt[N[(N[(N[(31/40 - x), $MachinePrecision] * N[(31/40 - x), $MachinePrecision]), $MachinePrecision] + 49/100), $MachinePrecision]], $MachinePrecision] - 3/40), $MachinePrecision], t$95$1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$6], $MachinePrecision], N[Min[N[Min[t$95$4, N[Min[t$95$0, N[Min[N[(N[Sqrt[N[(961/1600 + N[(49/100 + N[(-7/5 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 3/40), $MachinePrecision], t$95$1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], t$95$6], $MachinePrecision]]]]]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\frac{9}{20} - x, \mathsf{max}\left(x - \frac{11}{20}, \mathsf{max}\left(y - \frac{11}{40}, -y\right)\right)\right)\\
t_1 := \mathsf{max}\left(\frac{29}{40} - x, \mathsf{max}\left(x - \frac{33}{40}, \mathsf{max}\left(-y, y - \frac{11}{20}\right)\right)\right)\\
t_2 := \sqrt{\frac{121}{1600} + \left(\frac{11}{40} - y\right) \cdot \left(\frac{11}{40} - y\right)}\\
t_3 := \sqrt{\frac{121}{1600} + \left(\frac{121}{1600} + \frac{-11}{20} \cdot y\right)}\\
t_4 := \mathsf{max}\left(-x, \mathsf{max}\left(x - \frac{1}{10}, \mathsf{max}\left(y - 1, -y\right)\right)\right)\\
t_5 := \mathsf{max}\left(\frac{11}{40} - y, \mathsf{max}\left(\mathsf{max}\left(x - \frac{11}{20}, y - \frac{11}{20}\right), -x\right)\right)\\
t_6 := \mathsf{max}\left(t\_2 - \frac{11}{40}, \mathsf{max}\left(\frac{7}{40} - t\_2, t\_5\right)\right)\\
\mathbf{if}\;y \leq -1360000000000000000:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(t\_4, \mathsf{min}\left(t\_0, \mathsf{min}\left(\sqrt{\frac{961}{1600} + \left(\frac{7}{10} - y\right) \cdot \left(\frac{7}{10} - y\right)} - \frac{3}{40}, t\_1\right)\right)\right), \mathsf{max}\left(t\_3 - \frac{11}{40}, \mathsf{max}\left(\frac{7}{40} - t\_3, t\_5\right)\right)\right)\\
\mathbf{elif}\;y \leq 175000000000:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(t\_4, \mathsf{min}\left(t\_0, \mathsf{min}\left(\sqrt{\left(\frac{31}{40} - x\right) \cdot \left(\frac{31}{40} - x\right) + \frac{49}{100}} - \frac{3}{40}, t\_1\right)\right)\right), t\_6\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(t\_4, \mathsf{min}\left(t\_0, \mathsf{min}\left(\sqrt{\frac{961}{1600} + \left(\frac{49}{100} + \frac{-7}{5} \cdot y\right)} - \frac{3}{40}, t\_1\right)\right)\right), t\_6\right)\\
\end{array}
if y < -1.36e18Initial program 100.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 rewrites67.3%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6467.3%
Applied rewrites67.3%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6467.3%
Applied rewrites67.3%
if -1.36e18 < y < 1.75e11Initial program 100.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 0
Applied rewrites67.6%
if 1.75e11 < y Initial program 100.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 rewrites67.3%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6453.3%
Applied rewrites53.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (sqrt (+ 121/1600 (* (- 11/40 y) (- 11/40 y)))))
(t_1
(fmax
(- 29/40 x)
(fmax (- x 33/40) (fmax (- y) (- y 11/20)))))
(t_2 (fmax (- y 11/40) (- y)))
(t_3 (fmax (- 9/20 x) (fmax (- x 11/20) t_2)))
(t_4 (+ 121/1600 (* -11/20 y)))
(t_5 (sqrt (- t_4 -121/1600)))
(t_6 (sqrt (+ 121/1600 t_4)))
(t_7 (fmax (- x) (fmax (- x 1/10) (fmax (- y 1) (- y)))))
(t_8
(fmax
(- 11/40 y)
(fmax (fmax (- x 11/20) (- y 11/20)) (- x)))))
(if (<=
x
-8800000000000000556875001097646508093080599899488642761462511839288125067997806619442847277532594798465145260063326208)
(fmin
(fmin
t_7
(fmin
t_3
(fmin (- (sqrt (+ 961/1600 (+ 49/100 (* -7/5 y)))) 3/40) t_1)))
(fmax (- t_0 11/40) (fmax (- 7/40 t_0) t_8)))
(if (<=
x
1099999999999999953047992824289067898647737620629778026314407398146330515818776269443231535172468045026639048876010540311227423034645026439161984163400934852815417106123650664788656128)
(fmin
(fmin
t_7
(fmin
t_3
(fmin
(- (sqrt (+ 961/1600 (* (- 7/10 y) (- 7/10 y)))) 3/40)
t_1)))
(fmax (- t_6 11/40) (fmax (- 7/40 t_6) t_8)))
(fmin
(fmin
(fmin
(fmax (fmax t_2 (- x 11/20)) (- 9/20 x))
(fmin
(- x 17/20)
(fmax
(fmax (fmax (- y 11/20) (- y)) (- x 33/40))
(- 29/40 x))))
(fmax (fmax (fmax (- y) (- y 1)) (- x 1/10)) (- x)))
(fmax
(fmax
(fmax
(fmax (fmax (- y 11/20) (- x 11/20)) (- x))
(- 11/40 y))
(- 7/40 t_5))
(- t_5 11/40)))))))double code(double x, double y) {
double t_0 = sqrt((0.075625 + ((0.275 - y) * (0.275 - y))));
double t_1 = fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))));
double t_2 = fmax((y - 0.275), -y);
double t_3 = fmax((0.45 - x), fmax((x - 0.55), t_2));
double t_4 = 0.075625 + (-0.55 * y);
double t_5 = sqrt((t_4 - -0.075625));
double t_6 = sqrt((0.075625 + t_4));
double t_7 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y)));
double t_8 = fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x));
double tmp;
if (x <= -8.8e+117) {
tmp = fmin(fmin(t_7, fmin(t_3, fmin((sqrt((0.600625 + (0.49 + (-1.4 * y)))) - 0.075), t_1))), fmax((t_0 - 0.275), fmax((0.175 - t_0), t_8)));
} else if (x <= 1.1e+183) {
tmp = fmin(fmin(t_7, fmin(t_3, fmin((sqrt((0.600625 + ((0.7 - y) * (0.7 - y)))) - 0.075), t_1))), fmax((t_6 - 0.275), fmax((0.175 - t_6), t_8)));
} else {
tmp = fmin(fmin(fmin(fmax(fmax(t_2, (x - 0.55)), (0.45 - x)), fmin((x - 0.85), fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - 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_5)), (t_5 - 0.275)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: t_7
real(8) :: t_8
real(8) :: tmp
t_0 = sqrt((0.075625d0 + ((0.275d0 - y) * (0.275d0 - y))))
t_1 = fmax((0.725d0 - x), fmax((x - 0.825d0), fmax(-y, (y - 0.55d0))))
t_2 = fmax((y - 0.275d0), -y)
t_3 = fmax((0.45d0 - x), fmax((x - 0.55d0), t_2))
t_4 = 0.075625d0 + ((-0.55d0) * y)
t_5 = sqrt((t_4 - (-0.075625d0)))
t_6 = sqrt((0.075625d0 + t_4))
t_7 = fmax(-x, fmax((x - 0.1d0), fmax((y - 1.0d0), -y)))
t_8 = fmax((0.275d0 - y), fmax(fmax((x - 0.55d0), (y - 0.55d0)), -x))
if (x <= (-8.8d+117)) then
tmp = fmin(fmin(t_7, fmin(t_3, fmin((sqrt((0.600625d0 + (0.49d0 + ((-1.4d0) * y)))) - 0.075d0), t_1))), fmax((t_0 - 0.275d0), fmax((0.175d0 - t_0), t_8)))
else if (x <= 1.1d+183) then
tmp = fmin(fmin(t_7, fmin(t_3, fmin((sqrt((0.600625d0 + ((0.7d0 - y) * (0.7d0 - y)))) - 0.075d0), t_1))), fmax((t_6 - 0.275d0), fmax((0.175d0 - t_6), t_8)))
else
tmp = fmin(fmin(fmin(fmax(fmax(t_2, (x - 0.55d0)), (0.45d0 - x)), fmin((x - 0.85d0), fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - 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_5)), (t_5 - 0.275d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.sqrt((0.075625 + ((0.275 - y) * (0.275 - y))));
double t_1 = fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))));
double t_2 = fmax((y - 0.275), -y);
double t_3 = fmax((0.45 - x), fmax((x - 0.55), t_2));
double t_4 = 0.075625 + (-0.55 * y);
double t_5 = Math.sqrt((t_4 - -0.075625));
double t_6 = Math.sqrt((0.075625 + t_4));
double t_7 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y)));
double t_8 = fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x));
double tmp;
if (x <= -8.8e+117) {
tmp = fmin(fmin(t_7, fmin(t_3, fmin((Math.sqrt((0.600625 + (0.49 + (-1.4 * y)))) - 0.075), t_1))), fmax((t_0 - 0.275), fmax((0.175 - t_0), t_8)));
} else if (x <= 1.1e+183) {
tmp = fmin(fmin(t_7, fmin(t_3, fmin((Math.sqrt((0.600625 + ((0.7 - y) * (0.7 - y)))) - 0.075), t_1))), fmax((t_6 - 0.275), fmax((0.175 - t_6), t_8)));
} else {
tmp = fmin(fmin(fmin(fmax(fmax(t_2, (x - 0.55)), (0.45 - x)), fmin((x - 0.85), fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - 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_5)), (t_5 - 0.275)));
}
return tmp;
}
def code(x, y): t_0 = math.sqrt((0.075625 + ((0.275 - y) * (0.275 - y)))) t_1 = fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55)))) t_2 = fmax((y - 0.275), -y) t_3 = fmax((0.45 - x), fmax((x - 0.55), t_2)) t_4 = 0.075625 + (-0.55 * y) t_5 = math.sqrt((t_4 - -0.075625)) t_6 = math.sqrt((0.075625 + t_4)) t_7 = fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))) t_8 = fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)) tmp = 0 if x <= -8.8e+117: tmp = fmin(fmin(t_7, fmin(t_3, fmin((math.sqrt((0.600625 + (0.49 + (-1.4 * y)))) - 0.075), t_1))), fmax((t_0 - 0.275), fmax((0.175 - t_0), t_8))) elif x <= 1.1e+183: tmp = fmin(fmin(t_7, fmin(t_3, fmin((math.sqrt((0.600625 + ((0.7 - y) * (0.7 - y)))) - 0.075), t_1))), fmax((t_6 - 0.275), fmax((0.175 - t_6), t_8))) else: tmp = fmin(fmin(fmin(fmax(fmax(t_2, (x - 0.55)), (0.45 - x)), fmin((x - 0.85), fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - 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_5)), (t_5 - 0.275))) return tmp
function code(x, y) t_0 = sqrt(Float64(0.075625 + Float64(Float64(0.275 - y) * Float64(0.275 - y)))) t_1 = fmax(Float64(0.725 - x), fmax(Float64(x - 0.825), fmax(Float64(-y), Float64(y - 0.55)))) t_2 = fmax(Float64(y - 0.275), Float64(-y)) t_3 = fmax(Float64(0.45 - x), fmax(Float64(x - 0.55), t_2)) t_4 = Float64(0.075625 + Float64(-0.55 * y)) t_5 = sqrt(Float64(t_4 - -0.075625)) t_6 = sqrt(Float64(0.075625 + t_4)) t_7 = fmax(Float64(-x), fmax(Float64(x - 0.1), fmax(Float64(y - 1.0), Float64(-y)))) t_8 = fmax(Float64(0.275 - y), fmax(fmax(Float64(x - 0.55), Float64(y - 0.55)), Float64(-x))) tmp = 0.0 if (x <= -8.8e+117) tmp = fmin(fmin(t_7, fmin(t_3, fmin(Float64(sqrt(Float64(0.600625 + Float64(0.49 + Float64(-1.4 * y)))) - 0.075), t_1))), fmax(Float64(t_0 - 0.275), fmax(Float64(0.175 - t_0), t_8))); elseif (x <= 1.1e+183) tmp = fmin(fmin(t_7, fmin(t_3, fmin(Float64(sqrt(Float64(0.600625 + Float64(Float64(0.7 - y) * Float64(0.7 - y)))) - 0.075), t_1))), fmax(Float64(t_6 - 0.275), fmax(Float64(0.175 - t_6), t_8))); else tmp = fmin(fmin(fmin(fmax(fmax(t_2, Float64(x - 0.55)), Float64(0.45 - x)), fmin(Float64(x - 0.85), fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - 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_5)), Float64(t_5 - 0.275))); end return tmp end
function tmp_2 = code(x, y) t_0 = sqrt((0.075625 + ((0.275 - y) * (0.275 - y)))); t_1 = max((0.725 - x), max((x - 0.825), max(-y, (y - 0.55)))); t_2 = max((y - 0.275), -y); t_3 = max((0.45 - x), max((x - 0.55), t_2)); t_4 = 0.075625 + (-0.55 * y); t_5 = sqrt((t_4 - -0.075625)); t_6 = sqrt((0.075625 + t_4)); t_7 = max(-x, max((x - 0.1), max((y - 1.0), -y))); t_8 = max((0.275 - y), max(max((x - 0.55), (y - 0.55)), -x)); tmp = 0.0; if (x <= -8.8e+117) tmp = min(min(t_7, min(t_3, min((sqrt((0.600625 + (0.49 + (-1.4 * y)))) - 0.075), t_1))), max((t_0 - 0.275), max((0.175 - t_0), t_8))); elseif (x <= 1.1e+183) tmp = min(min(t_7, min(t_3, min((sqrt((0.600625 + ((0.7 - y) * (0.7 - y)))) - 0.075), t_1))), max((t_6 - 0.275), max((0.175 - t_6), t_8))); else tmp = min(min(min(max(max(t_2, (x - 0.55)), (0.45 - x)), min((x - 0.85), max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - 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_5)), (t_5 - 0.275))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Sqrt[N[(121/1600 + N[(N[(11/40 - y), $MachinePrecision] * N[(11/40 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[(29/40 - x), $MachinePrecision], N[Max[N[(x - 33/40), $MachinePrecision], N[Max[(-y), N[(y - 11/20), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[(y - 11/40), $MachinePrecision], (-y)], $MachinePrecision]}, Block[{t$95$3 = N[Max[N[(9/20 - x), $MachinePrecision], N[Max[N[(x - 11/20), $MachinePrecision], t$95$2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(121/1600 + N[(-11/20 * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(t$95$4 - -121/1600), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[Sqrt[N[(121/1600 + t$95$4), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$7 = N[Max[(-x), N[Max[N[(x - 1/10), $MachinePrecision], N[Max[N[(y - 1), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$8 = N[Max[N[(11/40 - y), $MachinePrecision], N[Max[N[Max[N[(x - 11/20), $MachinePrecision], N[(y - 11/20), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -8800000000000000556875001097646508093080599899488642761462511839288125067997806619442847277532594798465145260063326208], N[Min[N[Min[t$95$7, N[Min[t$95$3, N[Min[N[(N[Sqrt[N[(961/1600 + N[(49/100 + N[(-7/5 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 3/40), $MachinePrecision], t$95$1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[(t$95$0 - 11/40), $MachinePrecision], N[Max[N[(7/40 - t$95$0), $MachinePrecision], t$95$8], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1099999999999999953047992824289067898647737620629778026314407398146330515818776269443231535172468045026639048876010540311227423034645026439161984163400934852815417106123650664788656128], N[Min[N[Min[t$95$7, N[Min[t$95$3, N[Min[N[(N[Sqrt[N[(961/1600 + N[(N[(7/10 - y), $MachinePrecision] * N[(7/10 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 3/40), $MachinePrecision], t$95$1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[(t$95$6 - 11/40), $MachinePrecision], N[Max[N[(7/40 - t$95$6), $MachinePrecision], t$95$8], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Min[N[Min[N[Min[N[Max[N[Max[t$95$2, N[(x - 11/20), $MachinePrecision]], $MachinePrecision], N[(9/20 - x), $MachinePrecision]], $MachinePrecision], N[Min[N[(x - 17/20), $MachinePrecision], N[Max[N[Max[N[Max[N[(y - 11/20), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 33/40), $MachinePrecision]], $MachinePrecision], N[(29/40 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 1), $MachinePrecision]], $MachinePrecision], N[(x - 1/10), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 11/20), $MachinePrecision], N[(x - 11/20), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(11/40 - y), $MachinePrecision]], $MachinePrecision], N[(7/40 - t$95$5), $MachinePrecision]], $MachinePrecision], N[(t$95$5 - 11/40), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]]]]]]]]]
\begin{array}{l}
t_0 := \sqrt{\frac{121}{1600} + \left(\frac{11}{40} - y\right) \cdot \left(\frac{11}{40} - y\right)}\\
t_1 := \mathsf{max}\left(\frac{29}{40} - x, \mathsf{max}\left(x - \frac{33}{40}, \mathsf{max}\left(-y, y - \frac{11}{20}\right)\right)\right)\\
t_2 := \mathsf{max}\left(y - \frac{11}{40}, -y\right)\\
t_3 := \mathsf{max}\left(\frac{9}{20} - x, \mathsf{max}\left(x - \frac{11}{20}, t\_2\right)\right)\\
t_4 := \frac{121}{1600} + \frac{-11}{20} \cdot y\\
t_5 := \sqrt{t\_4 - \frac{-121}{1600}}\\
t_6 := \sqrt{\frac{121}{1600} + t\_4}\\
t_7 := \mathsf{max}\left(-x, \mathsf{max}\left(x - \frac{1}{10}, \mathsf{max}\left(y - 1, -y\right)\right)\right)\\
t_8 := \mathsf{max}\left(\frac{11}{40} - y, \mathsf{max}\left(\mathsf{max}\left(x - \frac{11}{20}, y - \frac{11}{20}\right), -x\right)\right)\\
\mathbf{if}\;x \leq -8800000000000000556875001097646508093080599899488642761462511839288125067997806619442847277532594798465145260063326208:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(t\_7, \mathsf{min}\left(t\_3, \mathsf{min}\left(\sqrt{\frac{961}{1600} + \left(\frac{49}{100} + \frac{-7}{5} \cdot y\right)} - \frac{3}{40}, t\_1\right)\right)\right), \mathsf{max}\left(t\_0 - \frac{11}{40}, \mathsf{max}\left(\frac{7}{40} - t\_0, t\_8\right)\right)\right)\\
\mathbf{elif}\;x \leq 1099999999999999953047992824289067898647737620629778026314407398146330515818776269443231535172468045026639048876010540311227423034645026439161984163400934852815417106123650664788656128:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(t\_7, \mathsf{min}\left(t\_3, \mathsf{min}\left(\sqrt{\frac{961}{1600} + \left(\frac{7}{10} - y\right) \cdot \left(\frac{7}{10} - y\right)} - \frac{3}{40}, t\_1\right)\right)\right), \mathsf{max}\left(t\_6 - \frac{11}{40}, \mathsf{max}\left(\frac{7}{40} - t\_6, t\_8\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{max}\left(\mathsf{max}\left(t\_2, x - \frac{11}{20}\right), \frac{9}{20} - x\right), \mathsf{min}\left(x - \frac{17}{20}, \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{20}, -y\right), x - \frac{33}{40}\right), \frac{29}{40} - x\right)\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - \frac{1}{10}\right), -x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{20}, x - \frac{11}{20}\right), -x\right), \frac{11}{40} - y\right), \frac{7}{40} - t\_5\right), t\_5 - \frac{11}{40}\right)\right)\\
\end{array}
if x < -8.8000000000000006e117Initial program 100.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 rewrites67.3%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6453.3%
Applied rewrites53.3%
if -8.8000000000000006e117 < x < 1.1e183Initial program 100.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 rewrites67.3%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6467.3%
Applied rewrites67.3%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6467.3%
Applied rewrites67.3%
if 1.1e183 < x Initial program 100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6419.6%
Applied rewrites19.6%
Applied rewrites19.6%
Taylor expanded in x around 0
Applied rewrites19.6%
Taylor expanded in x around 0
Applied rewrites19.6%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6419.6%
Applied rewrites19.6%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6419.6%
Applied rewrites19.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 121/1600 (* -11/20 y)))
(t_1 (sqrt (- t_0 -121/1600)))
(t_2 (fmax (- y 11/40) (- y)))
(t_3 (sqrt (+ 121/1600 t_0))))
(if (<=
x
1099999999999999953047992824289067898647737620629778026314407398146330515818776269443231535172468045026639048876010540311227423034645026439161984163400934852815417106123650664788656128)
(fmin
(fmin
(fmax (- x) (fmax (- x 1/10) (fmax (- y 1) (- y))))
(fmin
(fmax (- 9/20 x) (fmax (- x 11/20) t_2))
(fmin
(- (sqrt (+ 961/1600 (* (- 7/10 y) (- 7/10 y)))) 3/40)
(fmax
(- 29/40 x)
(fmax (- x 33/40) (fmax (- y) (- y 11/20)))))))
(fmax
(- t_3 11/40)
(fmax
(- 7/40 t_3)
(fmax
(- 11/40 y)
(fmax (fmax (- x 11/20) (- y 11/20)) (- x))))))
(fmin
(fmin
(fmin
(fmax (fmax t_2 (- x 11/20)) (- 9/20 x))
(fmin
(- x 17/20)
(fmax
(fmax (fmax (- y 11/20) (- y)) (- x 33/40))
(- 29/40 x))))
(fmax (fmax (fmax (- y) (- y 1)) (- x 1/10)) (- x)))
(fmax
(fmax
(fmax (fmax (fmax (- y 11/20) (- x 11/20)) (- x)) (- 11/40 y))
(- 7/40 t_1))
(- t_1 11/40))))))double code(double x, double y) {
double t_0 = 0.075625 + (-0.55 * y);
double t_1 = sqrt((t_0 - -0.075625));
double t_2 = fmax((y - 0.275), -y);
double t_3 = sqrt((0.075625 + t_0));
double tmp;
if (x <= 1.1e+183) {
tmp = fmin(fmin(fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))), fmin(fmax((0.45 - x), fmax((x - 0.55), t_2)), fmin((sqrt((0.600625 + ((0.7 - y) * (0.7 - y)))) - 0.075), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((t_3 - 0.275), fmax((0.175 - t_3), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))));
} else {
tmp = fmin(fmin(fmin(fmax(fmax(t_2, (x - 0.55)), (0.45 - x)), fmin((x - 0.85), fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - 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_1)), (t_1 - 0.275)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = 0.075625d0 + ((-0.55d0) * y)
t_1 = sqrt((t_0 - (-0.075625d0)))
t_2 = fmax((y - 0.275d0), -y)
t_3 = sqrt((0.075625d0 + t_0))
if (x <= 1.1d+183) then
tmp = fmin(fmin(fmax(-x, fmax((x - 0.1d0), fmax((y - 1.0d0), -y))), fmin(fmax((0.45d0 - x), fmax((x - 0.55d0), t_2)), fmin((sqrt((0.600625d0 + ((0.7d0 - y) * (0.7d0 - y)))) - 0.075d0), fmax((0.725d0 - x), fmax((x - 0.825d0), fmax(-y, (y - 0.55d0))))))), fmax((t_3 - 0.275d0), fmax((0.175d0 - t_3), fmax((0.275d0 - y), fmax(fmax((x - 0.55d0), (y - 0.55d0)), -x)))))
else
tmp = fmin(fmin(fmin(fmax(fmax(t_2, (x - 0.55d0)), (0.45d0 - x)), fmin((x - 0.85d0), fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - 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_1)), (t_1 - 0.275d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 0.075625 + (-0.55 * y);
double t_1 = Math.sqrt((t_0 - -0.075625));
double t_2 = fmax((y - 0.275), -y);
double t_3 = Math.sqrt((0.075625 + t_0));
double tmp;
if (x <= 1.1e+183) {
tmp = fmin(fmin(fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))), fmin(fmax((0.45 - x), fmax((x - 0.55), t_2)), fmin((Math.sqrt((0.600625 + ((0.7 - y) * (0.7 - y)))) - 0.075), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((t_3 - 0.275), fmax((0.175 - t_3), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))));
} else {
tmp = fmin(fmin(fmin(fmax(fmax(t_2, (x - 0.55)), (0.45 - x)), fmin((x - 0.85), fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - 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_1)), (t_1 - 0.275)));
}
return tmp;
}
def code(x, y): t_0 = 0.075625 + (-0.55 * y) t_1 = math.sqrt((t_0 - -0.075625)) t_2 = fmax((y - 0.275), -y) t_3 = math.sqrt((0.075625 + t_0)) tmp = 0 if x <= 1.1e+183: tmp = fmin(fmin(fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))), fmin(fmax((0.45 - x), fmax((x - 0.55), t_2)), fmin((math.sqrt((0.600625 + ((0.7 - y) * (0.7 - y)))) - 0.075), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((t_3 - 0.275), fmax((0.175 - t_3), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x))))) else: tmp = fmin(fmin(fmin(fmax(fmax(t_2, (x - 0.55)), (0.45 - x)), fmin((x - 0.85), fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - 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_1)), (t_1 - 0.275))) return tmp
function code(x, y) t_0 = Float64(0.075625 + Float64(-0.55 * y)) t_1 = sqrt(Float64(t_0 - -0.075625)) t_2 = fmax(Float64(y - 0.275), Float64(-y)) t_3 = sqrt(Float64(0.075625 + t_0)) tmp = 0.0 if (x <= 1.1e+183) tmp = 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), t_2)), fmin(Float64(sqrt(Float64(0.600625 + Float64(Float64(0.7 - y) * Float64(0.7 - y)))) - 0.075), fmax(Float64(0.725 - x), fmax(Float64(x - 0.825), fmax(Float64(-y), Float64(y - 0.55))))))), fmax(Float64(t_3 - 0.275), fmax(Float64(0.175 - t_3), fmax(Float64(0.275 - y), fmax(fmax(Float64(x - 0.55), Float64(y - 0.55)), Float64(-x)))))); else tmp = fmin(fmin(fmin(fmax(fmax(t_2, Float64(x - 0.55)), Float64(0.45 - x)), fmin(Float64(x - 0.85), fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - 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_1)), Float64(t_1 - 0.275))); end return tmp end
function tmp_2 = code(x, y) t_0 = 0.075625 + (-0.55 * y); t_1 = sqrt((t_0 - -0.075625)); t_2 = max((y - 0.275), -y); t_3 = sqrt((0.075625 + t_0)); tmp = 0.0; if (x <= 1.1e+183) tmp = min(min(max(-x, max((x - 0.1), max((y - 1.0), -y))), min(max((0.45 - x), max((x - 0.55), t_2)), min((sqrt((0.600625 + ((0.7 - y) * (0.7 - y)))) - 0.075), max((0.725 - x), max((x - 0.825), max(-y, (y - 0.55))))))), max((t_3 - 0.275), max((0.175 - t_3), max((0.275 - y), max(max((x - 0.55), (y - 0.55)), -x))))); else tmp = min(min(min(max(max(t_2, (x - 0.55)), (0.45 - x)), min((x - 0.85), max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - 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_1)), (t_1 - 0.275))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(121/1600 + N[(-11/20 * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(t$95$0 - -121/1600), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[(y - 11/40), $MachinePrecision], (-y)], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(121/1600 + t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1099999999999999953047992824289067898647737620629778026314407398146330515818776269443231535172468045026639048876010540311227423034645026439161984163400934852815417106123650664788656128], N[Min[N[Min[N[Max[(-x), N[Max[N[(x - 1/10), $MachinePrecision], N[Max[N[(y - 1), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Min[N[Max[N[(9/20 - x), $MachinePrecision], N[Max[N[(x - 11/20), $MachinePrecision], t$95$2], $MachinePrecision]], $MachinePrecision], N[Min[N[(N[Sqrt[N[(961/1600 + N[(N[(7/10 - y), $MachinePrecision] * N[(7/10 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - 3/40), $MachinePrecision], N[Max[N[(29/40 - x), $MachinePrecision], N[Max[N[(x - 33/40), $MachinePrecision], N[Max[(-y), N[(y - 11/20), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[(t$95$3 - 11/40), $MachinePrecision], N[Max[N[(7/40 - t$95$3), $MachinePrecision], N[Max[N[(11/40 - y), $MachinePrecision], N[Max[N[Max[N[(x - 11/20), $MachinePrecision], N[(y - 11/20), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Min[N[Min[N[Min[N[Max[N[Max[t$95$2, N[(x - 11/20), $MachinePrecision]], $MachinePrecision], N[(9/20 - x), $MachinePrecision]], $MachinePrecision], N[Min[N[(x - 17/20), $MachinePrecision], N[Max[N[Max[N[Max[N[(y - 11/20), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 33/40), $MachinePrecision]], $MachinePrecision], N[(29/40 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 1), $MachinePrecision]], $MachinePrecision], N[(x - 1/10), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 11/20), $MachinePrecision], N[(x - 11/20), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(11/40 - y), $MachinePrecision]], $MachinePrecision], N[(7/40 - t$95$1), $MachinePrecision]], $MachinePrecision], N[(t$95$1 - 11/40), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \frac{121}{1600} + \frac{-11}{20} \cdot y\\
t_1 := \sqrt{t\_0 - \frac{-121}{1600}}\\
t_2 := \mathsf{max}\left(y - \frac{11}{40}, -y\right)\\
t_3 := \sqrt{\frac{121}{1600} + t\_0}\\
\mathbf{if}\;x \leq 1099999999999999953047992824289067898647737620629778026314407398146330515818776269443231535172468045026639048876010540311227423034645026439161984163400934852815417106123650664788656128:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{max}\left(-x, \mathsf{max}\left(x - \frac{1}{10}, \mathsf{max}\left(y - 1, -y\right)\right)\right), \mathsf{min}\left(\mathsf{max}\left(\frac{9}{20} - x, \mathsf{max}\left(x - \frac{11}{20}, t\_2\right)\right), \mathsf{min}\left(\sqrt{\frac{961}{1600} + \left(\frac{7}{10} - y\right) \cdot \left(\frac{7}{10} - y\right)} - \frac{3}{40}, \mathsf{max}\left(\frac{29}{40} - x, \mathsf{max}\left(x - \frac{33}{40}, \mathsf{max}\left(-y, y - \frac{11}{20}\right)\right)\right)\right)\right)\right), \mathsf{max}\left(t\_3 - \frac{11}{40}, \mathsf{max}\left(\frac{7}{40} - t\_3, \mathsf{max}\left(\frac{11}{40} - y, \mathsf{max}\left(\mathsf{max}\left(x - \frac{11}{20}, y - \frac{11}{20}\right), -x\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{max}\left(\mathsf{max}\left(t\_2, x - \frac{11}{20}\right), \frac{9}{20} - x\right), \mathsf{min}\left(x - \frac{17}{20}, \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{20}, -y\right), x - \frac{33}{40}\right), \frac{29}{40} - x\right)\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - \frac{1}{10}\right), -x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{20}, x - \frac{11}{20}\right), -x\right), \frac{11}{40} - y\right), \frac{7}{40} - t\_1\right), t\_1 - \frac{11}{40}\right)\right)\\
\end{array}
if x < 1.1e183Initial program 100.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 rewrites67.3%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6467.3%
Applied rewrites67.3%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6467.3%
Applied rewrites67.3%
if 1.1e183 < x Initial program 100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6419.6%
Applied rewrites19.6%
Applied rewrites19.6%
Taylor expanded in x around 0
Applied rewrites19.6%
Taylor expanded in x around 0
Applied rewrites19.6%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6419.6%
Applied rewrites19.6%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6419.6%
Applied rewrites19.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (- 11/40 y) (- 11/40 y)))
(t_1
(fmax
(fmax (fmax (- y 11/20) (- y)) (- x 33/40))
(- 29/40 x)))
(t_2 (fmax (- y 11/40) (- y)))
(t_3 (fmax (fmax t_2 (- x 11/20)) (- 9/20 x)))
(t_4
(fmax
(fmax (fmax (- y 11/20) (- x 11/20)) (- x))
(- 11/40 y)))
(t_5 (sqrt (+ 121/1600 t_0)))
(t_6 (sqrt (- (+ 121/1600 (* -11/20 y)) -121/1600)))
(t_7 (fmax (fmax (fmax (- y) (- y 1)) (- x 1/10)) (- x)))
(t_8 (sqrt (+ t_0 121/1600))))
(if (<=
x
-1915619426082361/2993155353253689176481146537402947624255349848014848)
(fmin
(fmin (fmin (fmin (- y 31/40) t_1) t_3) t_7)
(fmax (fmax t_4 (- 7/40 t_8)) (- t_8 11/40)))
(if (<= x 8196551321814303/4503599627370496)
(fmin
(fmin
(fmax (- x) (fmax (- x 1/10) (fmax (- y 1) (- y))))
(fmin
(fmax (- 9/20 x) (fmax (- x 11/20) t_2))
(fmin
(- (sqrt (+ 961/1600 49/100)) 3/40)
(fmax
(- 29/40 x)
(fmax (- x 33/40) (fmax (- y) (- y 11/20)))))))
(fmax
(- t_5 11/40)
(fmax
(- 7/40 t_5)
(fmax
(- 11/40 y)
(fmax (fmax (- x 11/20) (- y 11/20)) (- x))))))
(fmin
(fmin (fmin t_3 (fmin (- x 17/20) t_1)) t_7)
(fmax (fmax t_4 (- 7/40 t_6)) (- t_6 11/40)))))))double code(double x, double y) {
double t_0 = (0.275 - y) * (0.275 - y);
double t_1 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_2 = fmax((y - 0.275), -y);
double t_3 = fmax(fmax(t_2, (x - 0.55)), (0.45 - x));
double t_4 = fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y));
double t_5 = sqrt((0.075625 + t_0));
double t_6 = sqrt(((0.075625 + (-0.55 * y)) - -0.075625));
double t_7 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_8 = sqrt((t_0 + 0.075625));
double tmp;
if (x <= -6.4e-37) {
tmp = fmin(fmin(fmin(fmin((y - 0.775), t_1), t_3), t_7), fmax(fmax(t_4, (0.175 - t_8)), (t_8 - 0.275)));
} else if (x <= 1.82) {
tmp = fmin(fmin(fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))), fmin(fmax((0.45 - x), fmax((x - 0.55), t_2)), fmin((sqrt((0.600625 + 0.49)) - 0.075), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((t_5 - 0.275), fmax((0.175 - t_5), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))));
} else {
tmp = fmin(fmin(fmin(t_3, fmin((x - 0.85), t_1)), t_7), fmax(fmax(t_4, (0.175 - t_6)), (t_6 - 0.275)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: t_7
real(8) :: t_8
real(8) :: tmp
t_0 = (0.275d0 - y) * (0.275d0 - y)
t_1 = fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - x))
t_2 = fmax((y - 0.275d0), -y)
t_3 = fmax(fmax(t_2, (x - 0.55d0)), (0.45d0 - x))
t_4 = fmax(fmax(fmax((y - 0.55d0), (x - 0.55d0)), -x), (0.275d0 - y))
t_5 = sqrt((0.075625d0 + t_0))
t_6 = sqrt(((0.075625d0 + ((-0.55d0) * y)) - (-0.075625d0)))
t_7 = fmax(fmax(fmax(-y, (y - 1.0d0)), (x - 0.1d0)), -x)
t_8 = sqrt((t_0 + 0.075625d0))
if (x <= (-6.4d-37)) then
tmp = fmin(fmin(fmin(fmin((y - 0.775d0), t_1), t_3), t_7), fmax(fmax(t_4, (0.175d0 - t_8)), (t_8 - 0.275d0)))
else if (x <= 1.82d0) then
tmp = fmin(fmin(fmax(-x, fmax((x - 0.1d0), fmax((y - 1.0d0), -y))), fmin(fmax((0.45d0 - x), fmax((x - 0.55d0), t_2)), fmin((sqrt((0.600625d0 + 0.49d0)) - 0.075d0), fmax((0.725d0 - x), fmax((x - 0.825d0), fmax(-y, (y - 0.55d0))))))), fmax((t_5 - 0.275d0), fmax((0.175d0 - t_5), fmax((0.275d0 - y), fmax(fmax((x - 0.55d0), (y - 0.55d0)), -x)))))
else
tmp = fmin(fmin(fmin(t_3, fmin((x - 0.85d0), t_1)), t_7), fmax(fmax(t_4, (0.175d0 - t_6)), (t_6 - 0.275d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (0.275 - y) * (0.275 - y);
double t_1 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_2 = fmax((y - 0.275), -y);
double t_3 = fmax(fmax(t_2, (x - 0.55)), (0.45 - x));
double t_4 = fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y));
double t_5 = Math.sqrt((0.075625 + t_0));
double t_6 = Math.sqrt(((0.075625 + (-0.55 * y)) - -0.075625));
double t_7 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_8 = Math.sqrt((t_0 + 0.075625));
double tmp;
if (x <= -6.4e-37) {
tmp = fmin(fmin(fmin(fmin((y - 0.775), t_1), t_3), t_7), fmax(fmax(t_4, (0.175 - t_8)), (t_8 - 0.275)));
} else if (x <= 1.82) {
tmp = fmin(fmin(fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))), fmin(fmax((0.45 - x), fmax((x - 0.55), t_2)), fmin((Math.sqrt((0.600625 + 0.49)) - 0.075), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((t_5 - 0.275), fmax((0.175 - t_5), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))));
} else {
tmp = fmin(fmin(fmin(t_3, fmin((x - 0.85), t_1)), t_7), fmax(fmax(t_4, (0.175 - t_6)), (t_6 - 0.275)));
}
return tmp;
}
def code(x, y): t_0 = (0.275 - y) * (0.275 - y) t_1 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)) t_2 = fmax((y - 0.275), -y) t_3 = fmax(fmax(t_2, (x - 0.55)), (0.45 - x)) t_4 = fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)) t_5 = math.sqrt((0.075625 + t_0)) t_6 = math.sqrt(((0.075625 + (-0.55 * y)) - -0.075625)) t_7 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x) t_8 = math.sqrt((t_0 + 0.075625)) tmp = 0 if x <= -6.4e-37: tmp = fmin(fmin(fmin(fmin((y - 0.775), t_1), t_3), t_7), fmax(fmax(t_4, (0.175 - t_8)), (t_8 - 0.275))) elif x <= 1.82: tmp = fmin(fmin(fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))), fmin(fmax((0.45 - x), fmax((x - 0.55), t_2)), fmin((math.sqrt((0.600625 + 0.49)) - 0.075), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((t_5 - 0.275), fmax((0.175 - t_5), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x))))) else: tmp = fmin(fmin(fmin(t_3, fmin((x - 0.85), t_1)), t_7), fmax(fmax(t_4, (0.175 - t_6)), (t_6 - 0.275))) return tmp
function code(x, y) t_0 = Float64(Float64(0.275 - y) * Float64(0.275 - y)) t_1 = fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x)) t_2 = fmax(Float64(y - 0.275), Float64(-y)) t_3 = fmax(fmax(t_2, Float64(x - 0.55)), Float64(0.45 - x)) t_4 = fmax(fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)), Float64(0.275 - y)) t_5 = sqrt(Float64(0.075625 + t_0)) t_6 = sqrt(Float64(Float64(0.075625 + Float64(-0.55 * y)) - -0.075625)) t_7 = fmax(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x)) t_8 = sqrt(Float64(t_0 + 0.075625)) tmp = 0.0 if (x <= -6.4e-37) tmp = fmin(fmin(fmin(fmin(Float64(y - 0.775), t_1), t_3), t_7), fmax(fmax(t_4, Float64(0.175 - t_8)), Float64(t_8 - 0.275))); elseif (x <= 1.82) tmp = 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), t_2)), fmin(Float64(sqrt(Float64(0.600625 + 0.49)) - 0.075), fmax(Float64(0.725 - x), fmax(Float64(x - 0.825), fmax(Float64(-y), Float64(y - 0.55))))))), fmax(Float64(t_5 - 0.275), fmax(Float64(0.175 - t_5), fmax(Float64(0.275 - y), fmax(fmax(Float64(x - 0.55), Float64(y - 0.55)), Float64(-x)))))); else tmp = fmin(fmin(fmin(t_3, fmin(Float64(x - 0.85), t_1)), t_7), fmax(fmax(t_4, Float64(0.175 - t_6)), Float64(t_6 - 0.275))); end return tmp end
function tmp_2 = code(x, y) t_0 = (0.275 - y) * (0.275 - y); t_1 = max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x)); t_2 = max((y - 0.275), -y); t_3 = max(max(t_2, (x - 0.55)), (0.45 - x)); t_4 = max(max(max((y - 0.55), (x - 0.55)), -x), (0.275 - y)); t_5 = sqrt((0.075625 + t_0)); t_6 = sqrt(((0.075625 + (-0.55 * y)) - -0.075625)); t_7 = max(max(max(-y, (y - 1.0)), (x - 0.1)), -x); t_8 = sqrt((t_0 + 0.075625)); tmp = 0.0; if (x <= -6.4e-37) tmp = min(min(min(min((y - 0.775), t_1), t_3), t_7), max(max(t_4, (0.175 - t_8)), (t_8 - 0.275))); elseif (x <= 1.82) tmp = min(min(max(-x, max((x - 0.1), max((y - 1.0), -y))), min(max((0.45 - x), max((x - 0.55), t_2)), min((sqrt((0.600625 + 0.49)) - 0.075), max((0.725 - x), max((x - 0.825), max(-y, (y - 0.55))))))), max((t_5 - 0.275), max((0.175 - t_5), max((0.275 - y), max(max((x - 0.55), (y - 0.55)), -x))))); else tmp = min(min(min(t_3, min((x - 0.85), t_1)), t_7), max(max(t_4, (0.175 - t_6)), (t_6 - 0.275))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(11/40 - y), $MachinePrecision] * N[(11/40 - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Max[N[Max[N[(y - 11/20), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 33/40), $MachinePrecision]], $MachinePrecision], N[(29/40 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[(y - 11/40), $MachinePrecision], (-y)], $MachinePrecision]}, Block[{t$95$3 = N[Max[N[Max[t$95$2, N[(x - 11/20), $MachinePrecision]], $MachinePrecision], N[(9/20 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Max[N[Max[N[Max[N[(y - 11/20), $MachinePrecision], N[(x - 11/20), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(11/40 - y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(121/1600 + t$95$0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[Sqrt[N[(N[(121/1600 + N[(-11/20 * y), $MachinePrecision]), $MachinePrecision] - -121/1600), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$7 = N[Max[N[Max[N[Max[(-y), N[(y - 1), $MachinePrecision]], $MachinePrecision], N[(x - 1/10), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]}, Block[{t$95$8 = N[Sqrt[N[(t$95$0 + 121/1600), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1915619426082361/2993155353253689176481146537402947624255349848014848], N[Min[N[Min[N[Min[N[Min[N[(y - 31/40), $MachinePrecision], t$95$1], $MachinePrecision], t$95$3], $MachinePrecision], t$95$7], $MachinePrecision], N[Max[N[Max[t$95$4, N[(7/40 - t$95$8), $MachinePrecision]], $MachinePrecision], N[(t$95$8 - 11/40), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 8196551321814303/4503599627370496], N[Min[N[Min[N[Max[(-x), N[Max[N[(x - 1/10), $MachinePrecision], N[Max[N[(y - 1), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Min[N[Max[N[(9/20 - x), $MachinePrecision], N[Max[N[(x - 11/20), $MachinePrecision], t$95$2], $MachinePrecision]], $MachinePrecision], N[Min[N[(N[Sqrt[N[(961/1600 + 49/100), $MachinePrecision]], $MachinePrecision] - 3/40), $MachinePrecision], N[Max[N[(29/40 - x), $MachinePrecision], N[Max[N[(x - 33/40), $MachinePrecision], N[Max[(-y), N[(y - 11/20), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[(t$95$5 - 11/40), $MachinePrecision], N[Max[N[(7/40 - t$95$5), $MachinePrecision], N[Max[N[(11/40 - y), $MachinePrecision], N[Max[N[Max[N[(x - 11/20), $MachinePrecision], N[(y - 11/20), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Min[N[Min[N[Min[t$95$3, N[Min[N[(x - 17/20), $MachinePrecision], t$95$1], $MachinePrecision]], $MachinePrecision], t$95$7], $MachinePrecision], N[Max[N[Max[t$95$4, N[(7/40 - t$95$6), $MachinePrecision]], $MachinePrecision], N[(t$95$6 - 11/40), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]]]]]]]]]
\begin{array}{l}
t_0 := \left(\frac{11}{40} - y\right) \cdot \left(\frac{11}{40} - y\right)\\
t_1 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{20}, -y\right), x - \frac{33}{40}\right), \frac{29}{40} - x\right)\\
t_2 := \mathsf{max}\left(y - \frac{11}{40}, -y\right)\\
t_3 := \mathsf{max}\left(\mathsf{max}\left(t\_2, x - \frac{11}{20}\right), \frac{9}{20} - x\right)\\
t_4 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{20}, x - \frac{11}{20}\right), -x\right), \frac{11}{40} - y\right)\\
t_5 := \sqrt{\frac{121}{1600} + t\_0}\\
t_6 := \sqrt{\left(\frac{121}{1600} + \frac{-11}{20} \cdot y\right) - \frac{-121}{1600}}\\
t_7 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - \frac{1}{10}\right), -x\right)\\
t_8 := \sqrt{t\_0 + \frac{121}{1600}}\\
\mathbf{if}\;x \leq \frac{-1915619426082361}{2993155353253689176481146537402947624255349848014848}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(y - \frac{31}{40}, t\_1\right), t\_3\right), t\_7\right), \mathsf{max}\left(\mathsf{max}\left(t\_4, \frac{7}{40} - t\_8\right), t\_8 - \frac{11}{40}\right)\right)\\
\mathbf{elif}\;x \leq \frac{8196551321814303}{4503599627370496}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{max}\left(-x, \mathsf{max}\left(x - \frac{1}{10}, \mathsf{max}\left(y - 1, -y\right)\right)\right), \mathsf{min}\left(\mathsf{max}\left(\frac{9}{20} - x, \mathsf{max}\left(x - \frac{11}{20}, t\_2\right)\right), \mathsf{min}\left(\sqrt{\frac{961}{1600} + \frac{49}{100}} - \frac{3}{40}, \mathsf{max}\left(\frac{29}{40} - x, \mathsf{max}\left(x - \frac{33}{40}, \mathsf{max}\left(-y, y - \frac{11}{20}\right)\right)\right)\right)\right)\right), \mathsf{max}\left(t\_5 - \frac{11}{40}, \mathsf{max}\left(\frac{7}{40} - t\_5, \mathsf{max}\left(\frac{11}{40} - y, \mathsf{max}\left(\mathsf{max}\left(x - \frac{11}{20}, y - \frac{11}{20}\right), -x\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_3, \mathsf{min}\left(x - \frac{17}{20}, t\_1\right)\right), t\_7\right), \mathsf{max}\left(\mathsf{max}\left(t\_4, \frac{7}{40} - t\_6\right), t\_6 - \frac{11}{40}\right)\right)\\
\end{array}
if x < -6.3999999999999998e-37Initial program 100.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.6%
Applied rewrites20.6%
Applied rewrites20.6%
if -6.3999999999999998e-37 < x < 1.8200000000000001Initial program 100.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 rewrites67.3%
Taylor expanded in y around 0
Applied rewrites28.7%
if 1.8200000000000001 < x Initial program 100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6419.6%
Applied rewrites19.6%
Applied rewrites19.6%
Taylor expanded in x around 0
Applied rewrites19.6%
Taylor expanded in x around 0
Applied rewrites19.6%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6419.6%
Applied rewrites19.6%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6419.6%
Applied rewrites19.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (fmax (- y 11/40) (- y)))
(t_1 (* (- 11/40 y) (- 11/40 y)))
(t_2 (sqrt (+ t_1 121/1600)))
(t_3 (sqrt (+ 121/1600 t_1))))
(if (<= y 3246626956972881/36893488147419103232)
(fmin
(fmin
(fmax (- x) (fmax (- x 1/10) (fmax (- y 1) (- y))))
(fmin
(fmax (- 9/20 x) (fmax (- x 11/20) t_0))
(fmin
(* x 1)
(fmax
(- 29/40 x)
(fmax (- x 33/40) (fmax (- y) (- y 11/20)))))))
(fmax
(- t_3 11/40)
(fmax
(- 7/40 t_3)
(fmax
(- 11/40 y)
(fmax (fmax (- x 11/20) (- y 11/20)) (- x))))))
(fmin
(fmin
(fmin
(fmin
(- y 31/40)
(fmax
(fmax (fmax (- y 11/20) (- y)) (- x 33/40))
(- 29/40 x)))
(fmax (fmax t_0 (- x 11/20)) (- 9/20 x)))
(fmax (fmax (fmax (- y) (- y 1)) (- x 1/10)) (- x)))
(fmax
(fmax
(fmax (fmax (fmax (- y 11/20) (- x 11/20)) (- x)) (- 11/40 y))
(- 7/40 t_2))
(- t_2 11/40))))))double code(double x, double y) {
double t_0 = fmax((y - 0.275), -y);
double t_1 = (0.275 - y) * (0.275 - y);
double t_2 = sqrt((t_1 + 0.075625));
double t_3 = sqrt((0.075625 + t_1));
double tmp;
if (y <= 8.8e-5) {
tmp = fmin(fmin(fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))), fmin(fmax((0.45 - x), fmax((x - 0.55), t_0)), fmin((x * 1.0), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((t_3 - 0.275), fmax((0.175 - t_3), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))));
} else {
tmp = fmin(fmin(fmin(fmin((y - 0.775), fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x))), fmax(fmax(t_0, (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_2)), (t_2 - 0.275)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = fmax((y - 0.275d0), -y)
t_1 = (0.275d0 - y) * (0.275d0 - y)
t_2 = sqrt((t_1 + 0.075625d0))
t_3 = sqrt((0.075625d0 + t_1))
if (y <= 8.8d-5) then
tmp = fmin(fmin(fmax(-x, fmax((x - 0.1d0), fmax((y - 1.0d0), -y))), fmin(fmax((0.45d0 - x), fmax((x - 0.55d0), t_0)), fmin((x * 1.0d0), fmax((0.725d0 - x), fmax((x - 0.825d0), fmax(-y, (y - 0.55d0))))))), fmax((t_3 - 0.275d0), fmax((0.175d0 - t_3), fmax((0.275d0 - y), fmax(fmax((x - 0.55d0), (y - 0.55d0)), -x)))))
else
tmp = fmin(fmin(fmin(fmin((y - 0.775d0), fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - x))), fmax(fmax(t_0, (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_2)), (t_2 - 0.275d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax((y - 0.275), -y);
double t_1 = (0.275 - y) * (0.275 - y);
double t_2 = Math.sqrt((t_1 + 0.075625));
double t_3 = Math.sqrt((0.075625 + t_1));
double tmp;
if (y <= 8.8e-5) {
tmp = fmin(fmin(fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))), fmin(fmax((0.45 - x), fmax((x - 0.55), t_0)), fmin((x * 1.0), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((t_3 - 0.275), fmax((0.175 - t_3), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x)))));
} else {
tmp = fmin(fmin(fmin(fmin((y - 0.775), fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x))), fmax(fmax(t_0, (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_2)), (t_2 - 0.275)));
}
return tmp;
}
def code(x, y): t_0 = fmax((y - 0.275), -y) t_1 = (0.275 - y) * (0.275 - y) t_2 = math.sqrt((t_1 + 0.075625)) t_3 = math.sqrt((0.075625 + t_1)) tmp = 0 if y <= 8.8e-5: tmp = fmin(fmin(fmax(-x, fmax((x - 0.1), fmax((y - 1.0), -y))), fmin(fmax((0.45 - x), fmax((x - 0.55), t_0)), fmin((x * 1.0), fmax((0.725 - x), fmax((x - 0.825), fmax(-y, (y - 0.55))))))), fmax((t_3 - 0.275), fmax((0.175 - t_3), fmax((0.275 - y), fmax(fmax((x - 0.55), (y - 0.55)), -x))))) else: tmp = fmin(fmin(fmin(fmin((y - 0.775), fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x))), fmax(fmax(t_0, (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_2)), (t_2 - 0.275))) return tmp
function code(x, y) t_0 = fmax(Float64(y - 0.275), Float64(-y)) t_1 = Float64(Float64(0.275 - y) * Float64(0.275 - y)) t_2 = sqrt(Float64(t_1 + 0.075625)) t_3 = sqrt(Float64(0.075625 + t_1)) tmp = 0.0 if (y <= 8.8e-5) tmp = 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), t_0)), fmin(Float64(x * 1.0), fmax(Float64(0.725 - x), fmax(Float64(x - 0.825), fmax(Float64(-y), Float64(y - 0.55))))))), fmax(Float64(t_3 - 0.275), fmax(Float64(0.175 - t_3), fmax(Float64(0.275 - y), fmax(fmax(Float64(x - 0.55), Float64(y - 0.55)), Float64(-x)))))); else tmp = fmin(fmin(fmin(fmin(Float64(y - 0.775), fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x))), fmax(fmax(t_0, 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_2)), Float64(t_2 - 0.275))); end return tmp end
function tmp_2 = code(x, y) t_0 = max((y - 0.275), -y); t_1 = (0.275 - y) * (0.275 - y); t_2 = sqrt((t_1 + 0.075625)); t_3 = sqrt((0.075625 + t_1)); tmp = 0.0; if (y <= 8.8e-5) tmp = min(min(max(-x, max((x - 0.1), max((y - 1.0), -y))), min(max((0.45 - x), max((x - 0.55), t_0)), min((x * 1.0), max((0.725 - x), max((x - 0.825), max(-y, (y - 0.55))))))), max((t_3 - 0.275), max((0.175 - t_3), max((0.275 - y), max(max((x - 0.55), (y - 0.55)), -x))))); else tmp = min(min(min(min((y - 0.775), max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x))), max(max(t_0, (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_2)), (t_2 - 0.275))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[N[(y - 11/40), $MachinePrecision], (-y)], $MachinePrecision]}, Block[{t$95$1 = N[(N[(11/40 - y), $MachinePrecision] * N[(11/40 - y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(t$95$1 + 121/1600), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(121/1600 + t$95$1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 3246626956972881/36893488147419103232], N[Min[N[Min[N[Max[(-x), N[Max[N[(x - 1/10), $MachinePrecision], N[Max[N[(y - 1), $MachinePrecision], (-y)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Min[N[Max[N[(9/20 - x), $MachinePrecision], N[Max[N[(x - 11/20), $MachinePrecision], t$95$0], $MachinePrecision]], $MachinePrecision], N[Min[N[(x * 1), $MachinePrecision], N[Max[N[(29/40 - x), $MachinePrecision], N[Max[N[(x - 33/40), $MachinePrecision], N[Max[(-y), N[(y - 11/20), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[(t$95$3 - 11/40), $MachinePrecision], N[Max[N[(7/40 - t$95$3), $MachinePrecision], N[Max[N[(11/40 - y), $MachinePrecision], N[Max[N[Max[N[(x - 11/20), $MachinePrecision], N[(y - 11/20), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Min[N[Min[N[Min[N[Min[N[(y - 31/40), $MachinePrecision], N[Max[N[Max[N[Max[N[(y - 11/20), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 33/40), $MachinePrecision]], $MachinePrecision], N[(29/40 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[t$95$0, N[(x - 11/20), $MachinePrecision]], $MachinePrecision], N[(9/20 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 1), $MachinePrecision]], $MachinePrecision], N[(x - 1/10), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 11/20), $MachinePrecision], N[(x - 11/20), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(11/40 - y), $MachinePrecision]], $MachinePrecision], N[(7/40 - t$95$2), $MachinePrecision]], $MachinePrecision], N[(t$95$2 - 11/40), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(y - \frac{11}{40}, -y\right)\\
t_1 := \left(\frac{11}{40} - y\right) \cdot \left(\frac{11}{40} - y\right)\\
t_2 := \sqrt{t\_1 + \frac{121}{1600}}\\
t_3 := \sqrt{\frac{121}{1600} + t\_1}\\
\mathbf{if}\;y \leq \frac{3246626956972881}{36893488147419103232}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{max}\left(-x, \mathsf{max}\left(x - \frac{1}{10}, \mathsf{max}\left(y - 1, -y\right)\right)\right), \mathsf{min}\left(\mathsf{max}\left(\frac{9}{20} - x, \mathsf{max}\left(x - \frac{11}{20}, t\_0\right)\right), \mathsf{min}\left(x \cdot 1, \mathsf{max}\left(\frac{29}{40} - x, \mathsf{max}\left(x - \frac{33}{40}, \mathsf{max}\left(-y, y - \frac{11}{20}\right)\right)\right)\right)\right)\right), \mathsf{max}\left(t\_3 - \frac{11}{40}, \mathsf{max}\left(\frac{7}{40} - t\_3, \mathsf{max}\left(\frac{11}{40} - y, \mathsf{max}\left(\mathsf{max}\left(x - \frac{11}{20}, y - \frac{11}{20}\right), -x\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(y - \frac{31}{40}, \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{20}, -y\right), x - \frac{33}{40}\right), \frac{29}{40} - x\right)\right), \mathsf{max}\left(\mathsf{max}\left(t\_0, x - \frac{11}{20}\right), \frac{9}{20} - x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - \frac{1}{10}\right), -x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{20}, x - \frac{11}{20}\right), -x\right), \frac{11}{40} - y\right), \frac{7}{40} - t\_2\right), t\_2 - \frac{11}{40}\right)\right)\\
\end{array}
if y < 8.7999999999999998e-5Initial program 100.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.6%
Applied rewrites19.6%
Taylor expanded in x around inf
Applied rewrites29.4%
if 8.7999999999999998e-5 < y Initial program 100.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.6%
Applied rewrites20.6%
Applied rewrites20.6%
(FPCore (x y)
:precision binary64
(let* ((t_0
(fmax (fmax (fmax (- y 11/40) (- y)) (- x 11/20)) (- 9/20 x)))
(t_1
(fmax
(fmax (fmax (- y 11/20) (- x 11/20)) (- x))
(- 11/40 y)))
(t_2
(fmax
(fmax (fmax (- y 11/20) (- y)) (- x 33/40))
(- 29/40 x)))
(t_3 (sqrt (- (+ 121/1600 (* -11/20 y)) -121/1600)))
(t_4 (fmax (fmax (fmax (- y) (- y 1)) (- x 1/10)) (- x)))
(t_5 (sqrt (+ (* (- 11/40 y) (- 11/40 y)) 121/1600))))
(if (<= x 780000000)
(fmin
(fmin (fmin (fmin (- y 31/40) t_2) t_0) t_4)
(fmax (fmax t_1 (- 7/40 t_5)) (- t_5 11/40)))
(fmin
(fmin (fmin t_0 (fmin (- x 17/20) t_2)) t_4)
(fmax (fmax t_1 (- 7/40 t_3)) (- t_3 11/40))))))double code(double x, double y) {
double t_0 = fmax(fmax(fmax((y - 0.275), -y), (x - 0.55)), (0.45 - x));
double t_1 = fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y));
double t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_3 = sqrt(((0.075625 + (-0.55 * y)) - -0.075625));
double t_4 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_5 = sqrt((((0.275 - y) * (0.275 - y)) + 0.075625));
double tmp;
if (x <= 780000000.0) {
tmp = fmin(fmin(fmin(fmin((y - 0.775), t_2), t_0), t_4), fmax(fmax(t_1, (0.175 - t_5)), (t_5 - 0.275)));
} else {
tmp = fmin(fmin(fmin(t_0, fmin((x - 0.85), t_2)), t_4), fmax(fmax(t_1, (0.175 - t_3)), (t_3 - 0.275)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = fmax(fmax(fmax((y - 0.275d0), -y), (x - 0.55d0)), (0.45d0 - x))
t_1 = fmax(fmax(fmax((y - 0.55d0), (x - 0.55d0)), -x), (0.275d0 - y))
t_2 = fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - x))
t_3 = sqrt(((0.075625d0 + ((-0.55d0) * y)) - (-0.075625d0)))
t_4 = fmax(fmax(fmax(-y, (y - 1.0d0)), (x - 0.1d0)), -x)
t_5 = sqrt((((0.275d0 - y) * (0.275d0 - y)) + 0.075625d0))
if (x <= 780000000.0d0) then
tmp = fmin(fmin(fmin(fmin((y - 0.775d0), t_2), t_0), t_4), fmax(fmax(t_1, (0.175d0 - t_5)), (t_5 - 0.275d0)))
else
tmp = fmin(fmin(fmin(t_0, fmin((x - 0.85d0), t_2)), t_4), fmax(fmax(t_1, (0.175d0 - t_3)), (t_3 - 0.275d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = fmax(fmax(fmax((y - 0.275), -y), (x - 0.55)), (0.45 - x));
double t_1 = fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y));
double t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x));
double t_3 = Math.sqrt(((0.075625 + (-0.55 * y)) - -0.075625));
double t_4 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x);
double t_5 = Math.sqrt((((0.275 - y) * (0.275 - y)) + 0.075625));
double tmp;
if (x <= 780000000.0) {
tmp = fmin(fmin(fmin(fmin((y - 0.775), t_2), t_0), t_4), fmax(fmax(t_1, (0.175 - t_5)), (t_5 - 0.275)));
} else {
tmp = fmin(fmin(fmin(t_0, fmin((x - 0.85), t_2)), t_4), fmax(fmax(t_1, (0.175 - t_3)), (t_3 - 0.275)));
}
return tmp;
}
def code(x, y): t_0 = fmax(fmax(fmax((y - 0.275), -y), (x - 0.55)), (0.45 - x)) t_1 = fmax(fmax(fmax((y - 0.55), (x - 0.55)), -x), (0.275 - y)) t_2 = fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - x)) t_3 = math.sqrt(((0.075625 + (-0.55 * y)) - -0.075625)) t_4 = fmax(fmax(fmax(-y, (y - 1.0)), (x - 0.1)), -x) t_5 = math.sqrt((((0.275 - y) * (0.275 - y)) + 0.075625)) tmp = 0 if x <= 780000000.0: tmp = fmin(fmin(fmin(fmin((y - 0.775), t_2), t_0), t_4), fmax(fmax(t_1, (0.175 - t_5)), (t_5 - 0.275))) else: tmp = fmin(fmin(fmin(t_0, fmin((x - 0.85), t_2)), t_4), fmax(fmax(t_1, (0.175 - t_3)), (t_3 - 0.275))) return tmp
function code(x, y) t_0 = fmax(fmax(fmax(Float64(y - 0.275), Float64(-y)), Float64(x - 0.55)), Float64(0.45 - x)) t_1 = fmax(fmax(fmax(Float64(y - 0.55), Float64(x - 0.55)), Float64(-x)), Float64(0.275 - y)) t_2 = fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - x)) t_3 = sqrt(Float64(Float64(0.075625 + Float64(-0.55 * y)) - -0.075625)) t_4 = fmax(fmax(fmax(Float64(-y), Float64(y - 1.0)), Float64(x - 0.1)), Float64(-x)) t_5 = sqrt(Float64(Float64(Float64(0.275 - y) * Float64(0.275 - y)) + 0.075625)) tmp = 0.0 if (x <= 780000000.0) tmp = fmin(fmin(fmin(fmin(Float64(y - 0.775), t_2), t_0), t_4), fmax(fmax(t_1, Float64(0.175 - t_5)), Float64(t_5 - 0.275))); else tmp = fmin(fmin(fmin(t_0, fmin(Float64(x - 0.85), t_2)), t_4), fmax(fmax(t_1, Float64(0.175 - t_3)), Float64(t_3 - 0.275))); end return tmp end
function tmp_2 = code(x, y) t_0 = max(max(max((y - 0.275), -y), (x - 0.55)), (0.45 - x)); t_1 = max(max(max((y - 0.55), (x - 0.55)), -x), (0.275 - y)); t_2 = max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - x)); t_3 = sqrt(((0.075625 + (-0.55 * y)) - -0.075625)); t_4 = max(max(max(-y, (y - 1.0)), (x - 0.1)), -x); t_5 = sqrt((((0.275 - y) * (0.275 - y)) + 0.075625)); tmp = 0.0; if (x <= 780000000.0) tmp = min(min(min(min((y - 0.775), t_2), t_0), t_4), max(max(t_1, (0.175 - t_5)), (t_5 - 0.275))); else tmp = min(min(min(t_0, min((x - 0.85), t_2)), t_4), max(max(t_1, (0.175 - t_3)), (t_3 - 0.275))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[Max[N[Max[N[Max[N[(y - 11/40), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 11/20), $MachinePrecision]], $MachinePrecision], N[(9/20 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Max[N[Max[N[Max[N[(y - 11/20), $MachinePrecision], N[(x - 11/20), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(11/40 - y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Max[N[Max[N[Max[N[(y - 11/20), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 33/40), $MachinePrecision]], $MachinePrecision], N[(29/40 - x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(N[(121/1600 + N[(-11/20 * y), $MachinePrecision]), $MachinePrecision] - -121/1600), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Max[N[Max[N[Max[(-y), N[(y - 1), $MachinePrecision]], $MachinePrecision], N[(x - 1/10), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(N[(N[(11/40 - y), $MachinePrecision] * N[(11/40 - y), $MachinePrecision]), $MachinePrecision] + 121/1600), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 780000000], N[Min[N[Min[N[Min[N[Min[N[(y - 31/40), $MachinePrecision], t$95$2], $MachinePrecision], t$95$0], $MachinePrecision], t$95$4], $MachinePrecision], N[Max[N[Max[t$95$1, N[(7/40 - t$95$5), $MachinePrecision]], $MachinePrecision], N[(t$95$5 - 11/40), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Min[N[Min[N[Min[t$95$0, N[Min[N[(x - 17/20), $MachinePrecision], t$95$2], $MachinePrecision]], $MachinePrecision], t$95$4], $MachinePrecision], N[Max[N[Max[t$95$1, N[(7/40 - t$95$3), $MachinePrecision]], $MachinePrecision], N[(t$95$3 - 11/40), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{40}, -y\right), x - \frac{11}{20}\right), \frac{9}{20} - x\right)\\
t_1 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{20}, x - \frac{11}{20}\right), -x\right), \frac{11}{40} - y\right)\\
t_2 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{20}, -y\right), x - \frac{33}{40}\right), \frac{29}{40} - x\right)\\
t_3 := \sqrt{\left(\frac{121}{1600} + \frac{-11}{20} \cdot y\right) - \frac{-121}{1600}}\\
t_4 := \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - \frac{1}{10}\right), -x\right)\\
t_5 := \sqrt{\left(\frac{11}{40} - y\right) \cdot \left(\frac{11}{40} - y\right) + \frac{121}{1600}}\\
\mathbf{if}\;x \leq 780000000:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(y - \frac{31}{40}, t\_2\right), t\_0\right), t\_4\right), \mathsf{max}\left(\mathsf{max}\left(t\_1, \frac{7}{40} - t\_5\right), t\_5 - \frac{11}{40}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(t\_0, \mathsf{min}\left(x - \frac{17}{20}, t\_2\right)\right), t\_4\right), \mathsf{max}\left(\mathsf{max}\left(t\_1, \frac{7}{40} - t\_3\right), t\_3 - \frac{11}{40}\right)\right)\\
\end{array}
if x < 7.8e8Initial program 100.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.6%
Applied rewrites20.6%
Applied rewrites20.6%
if 7.8e8 < x Initial program 100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6419.6%
Applied rewrites19.6%
Applied rewrites19.6%
Taylor expanded in x around 0
Applied rewrites19.6%
Taylor expanded in x around 0
Applied rewrites19.6%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6419.6%
Applied rewrites19.6%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6419.6%
Applied rewrites19.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (sqrt (- (+ 121/1600 (* -11/20 y)) -121/1600))))
(fmin
(fmin
(fmin
(fmax (fmax (fmax (- y 11/40) (- y)) (- x 11/20)) (- 9/20 x))
(fmin
(- x 17/20)
(fmax (fmax (fmax (- y 11/20) (- y)) (- x 33/40)) (- 29/40 x))))
(fmax (fmax (fmax (- y) (- y 1)) (- x 1/10)) (- x)))
(fmax
(fmax
(fmax (fmax (fmax (- y 11/20) (- x 11/20)) (- x)) (- 11/40 y))
(- 7/40 t_0))
(- t_0 11/40)))))double code(double x, double y) {
double t_0 = sqrt(((0.075625 + (-0.55 * y)) - -0.075625));
return fmin(fmin(fmin(fmax(fmax(fmax((y - 0.275), -y), (x - 0.55)), (0.45 - x)), fmin((x - 0.85), fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - 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(((0.075625d0 + ((-0.55d0) * y)) - (-0.075625d0)))
code = fmin(fmin(fmin(fmax(fmax(fmax((y - 0.275d0), -y), (x - 0.55d0)), (0.45d0 - x)), fmin((x - 0.85d0), fmax(fmax(fmax((y - 0.55d0), -y), (x - 0.825d0)), (0.725d0 - 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(((0.075625 + (-0.55 * y)) - -0.075625));
return fmin(fmin(fmin(fmax(fmax(fmax((y - 0.275), -y), (x - 0.55)), (0.45 - x)), fmin((x - 0.85), fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - 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(((0.075625 + (-0.55 * y)) - -0.075625)) return fmin(fmin(fmin(fmax(fmax(fmax((y - 0.275), -y), (x - 0.55)), (0.45 - x)), fmin((x - 0.85), fmax(fmax(fmax((y - 0.55), -y), (x - 0.825)), (0.725 - 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(0.075625 + Float64(-0.55 * y)) - -0.075625)) return fmin(fmin(fmin(fmax(fmax(fmax(Float64(y - 0.275), Float64(-y)), Float64(x - 0.55)), Float64(0.45 - x)), fmin(Float64(x - 0.85), fmax(fmax(fmax(Float64(y - 0.55), Float64(-y)), Float64(x - 0.825)), Float64(0.725 - 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(((0.075625 + (-0.55 * y)) - -0.075625)); tmp = min(min(min(max(max(max((y - 0.275), -y), (x - 0.55)), (0.45 - x)), min((x - 0.85), max(max(max((y - 0.55), -y), (x - 0.825)), (0.725 - 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[(121/1600 + N[(-11/20 * y), $MachinePrecision]), $MachinePrecision] - -121/1600), $MachinePrecision]], $MachinePrecision]}, N[Min[N[Min[N[Min[N[Max[N[Max[N[Max[N[(y - 11/40), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 11/20), $MachinePrecision]], $MachinePrecision], N[(9/20 - x), $MachinePrecision]], $MachinePrecision], N[Min[N[(x - 17/20), $MachinePrecision], N[Max[N[Max[N[Max[N[(y - 11/20), $MachinePrecision], (-y)], $MachinePrecision], N[(x - 33/40), $MachinePrecision]], $MachinePrecision], N[(29/40 - x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[(-y), N[(y - 1), $MachinePrecision]], $MachinePrecision], N[(x - 1/10), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision]], $MachinePrecision], N[Max[N[Max[N[Max[N[Max[N[Max[N[(y - 11/20), $MachinePrecision], N[(x - 11/20), $MachinePrecision]], $MachinePrecision], (-x)], $MachinePrecision], N[(11/40 - y), $MachinePrecision]], $MachinePrecision], N[(7/40 - t$95$0), $MachinePrecision]], $MachinePrecision], N[(t$95$0 - 11/40), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
t_0 := \sqrt{\left(\frac{121}{1600} + \frac{-11}{20} \cdot y\right) - \frac{-121}{1600}}\\
\mathsf{min}\left(\mathsf{min}\left(\mathsf{min}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{40}, -y\right), x - \frac{11}{20}\right), \frac{9}{20} - x\right), \mathsf{min}\left(x - \frac{17}{20}, \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{20}, -y\right), x - \frac{33}{40}\right), \frac{29}{40} - x\right)\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(-y, y - 1\right), x - \frac{1}{10}\right), -x\right)\right), \mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(\mathsf{max}\left(y - \frac{11}{20}, x - \frac{11}{20}\right), -x\right), \frac{11}{40} - y\right), \frac{7}{40} - t\_0\right), t\_0 - \frac{11}{40}\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around inf
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-/.f6419.6%
Applied rewrites19.6%
Applied rewrites19.6%
Taylor expanded in x around 0
Applied rewrites19.6%
Taylor expanded in x around 0
Applied rewrites19.6%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6419.6%
Applied rewrites19.6%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6419.6%
Applied rewrites19.6%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (x y)
:name "The letters hi in the upper-right quadrant"
:precision binary64
(fmin (fmin (fmin (fmin (fmax (fmax (fmax (- y 11/20) (- y)) (- x 33/40)) (- 29/40 x)) (- (sqrt (+ (pow (- y 7/10) 2) (pow (- x 31/40) 2))) 3/40)) (fmax (fmax (fmax (- y) (- y 11/40)) (- x 11/20)) (- 9/20 x))) (fmax (fmax (fmax (- y) (- y 1)) (- x 1/10)) (- x))) (fmax (fmax (fmax (fmax (fmax (- y 11/20) (- x 11/20)) (- x)) (- 11/40 y)) (- 7/40 (sqrt (+ (pow (- y 11/40) 2) (pow (- x 11/40) 2))))) (- (sqrt (+ (pow (- y 11/40) 2) (pow (- x 11/40) 2))) 11/40))))