
(FPCore (x y)
:precision binary64
(/
(+
2.0
(*
(*
(* (sqrt 2.0) (- (sin x) (/ (sin y) 16.0)))
(- (sin y) (/ (sin x) 16.0)))
(- (cos x) (cos y))))
(*
3.0
(+
(+ 1.0 (* (/ (- (sqrt 5.0) 1.0) 2.0) (cos x)))
(* (/ (- 3.0 (sqrt 5.0)) 2.0) (cos y))))))double code(double x, double y) {
return (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * (sin(y) - (sin(x) / 16.0))) * (cos(x) - cos(y)))) / (3.0 * ((1.0 + (((sqrt(5.0) - 1.0) / 2.0) * cos(x))) + (((3.0 - sqrt(5.0)) / 2.0) * cos(y))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (2.0d0 + (((sqrt(2.0d0) * (sin(x) - (sin(y) / 16.0d0))) * (sin(y) - (sin(x) / 16.0d0))) * (cos(x) - cos(y)))) / (3.0d0 * ((1.0d0 + (((sqrt(5.0d0) - 1.0d0) / 2.0d0) * cos(x))) + (((3.0d0 - sqrt(5.0d0)) / 2.0d0) * cos(y))))
end function
public static double code(double x, double y) {
return (2.0 + (((Math.sqrt(2.0) * (Math.sin(x) - (Math.sin(y) / 16.0))) * (Math.sin(y) - (Math.sin(x) / 16.0))) * (Math.cos(x) - Math.cos(y)))) / (3.0 * ((1.0 + (((Math.sqrt(5.0) - 1.0) / 2.0) * Math.cos(x))) + (((3.0 - Math.sqrt(5.0)) / 2.0) * Math.cos(y))));
}
def code(x, y): return (2.0 + (((math.sqrt(2.0) * (math.sin(x) - (math.sin(y) / 16.0))) * (math.sin(y) - (math.sin(x) / 16.0))) * (math.cos(x) - math.cos(y)))) / (3.0 * ((1.0 + (((math.sqrt(5.0) - 1.0) / 2.0) * math.cos(x))) + (((3.0 - math.sqrt(5.0)) / 2.0) * math.cos(y))))
function code(x, y) return Float64(Float64(2.0 + Float64(Float64(Float64(sqrt(2.0) * Float64(sin(x) - Float64(sin(y) / 16.0))) * Float64(sin(y) - Float64(sin(x) / 16.0))) * Float64(cos(x) - cos(y)))) / Float64(3.0 * Float64(Float64(1.0 + Float64(Float64(Float64(sqrt(5.0) - 1.0) / 2.0) * cos(x))) + Float64(Float64(Float64(3.0 - sqrt(5.0)) / 2.0) * cos(y))))) end
function tmp = code(x, y) tmp = (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * (sin(y) - (sin(x) / 16.0))) * (cos(x) - cos(y)))) / (3.0 * ((1.0 + (((sqrt(5.0) - 1.0) / 2.0) * cos(x))) + (((3.0 - sqrt(5.0)) / 2.0) * cos(y)))); end
code[x_, y_] := N[(N[(2.0 + N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * N[(N[(1.0 + N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision] / 2.0), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right) + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)}
Herbie found 37 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y)
:precision binary64
(/
(+
2.0
(*
(*
(* (sqrt 2.0) (- (sin x) (/ (sin y) 16.0)))
(- (sin y) (/ (sin x) 16.0)))
(- (cos x) (cos y))))
(*
3.0
(+
(+ 1.0 (* (/ (- (sqrt 5.0) 1.0) 2.0) (cos x)))
(* (/ (- 3.0 (sqrt 5.0)) 2.0) (cos y))))))double code(double x, double y) {
return (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * (sin(y) - (sin(x) / 16.0))) * (cos(x) - cos(y)))) / (3.0 * ((1.0 + (((sqrt(5.0) - 1.0) / 2.0) * cos(x))) + (((3.0 - sqrt(5.0)) / 2.0) * cos(y))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (2.0d0 + (((sqrt(2.0d0) * (sin(x) - (sin(y) / 16.0d0))) * (sin(y) - (sin(x) / 16.0d0))) * (cos(x) - cos(y)))) / (3.0d0 * ((1.0d0 + (((sqrt(5.0d0) - 1.0d0) / 2.0d0) * cos(x))) + (((3.0d0 - sqrt(5.0d0)) / 2.0d0) * cos(y))))
end function
public static double code(double x, double y) {
return (2.0 + (((Math.sqrt(2.0) * (Math.sin(x) - (Math.sin(y) / 16.0))) * (Math.sin(y) - (Math.sin(x) / 16.0))) * (Math.cos(x) - Math.cos(y)))) / (3.0 * ((1.0 + (((Math.sqrt(5.0) - 1.0) / 2.0) * Math.cos(x))) + (((3.0 - Math.sqrt(5.0)) / 2.0) * Math.cos(y))));
}
def code(x, y): return (2.0 + (((math.sqrt(2.0) * (math.sin(x) - (math.sin(y) / 16.0))) * (math.sin(y) - (math.sin(x) / 16.0))) * (math.cos(x) - math.cos(y)))) / (3.0 * ((1.0 + (((math.sqrt(5.0) - 1.0) / 2.0) * math.cos(x))) + (((3.0 - math.sqrt(5.0)) / 2.0) * math.cos(y))))
function code(x, y) return Float64(Float64(2.0 + Float64(Float64(Float64(sqrt(2.0) * Float64(sin(x) - Float64(sin(y) / 16.0))) * Float64(sin(y) - Float64(sin(x) / 16.0))) * Float64(cos(x) - cos(y)))) / Float64(3.0 * Float64(Float64(1.0 + Float64(Float64(Float64(sqrt(5.0) - 1.0) / 2.0) * cos(x))) + Float64(Float64(Float64(3.0 - sqrt(5.0)) / 2.0) * cos(y))))) end
function tmp = code(x, y) tmp = (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * (sin(y) - (sin(x) / 16.0))) * (cos(x) - cos(y)))) / (3.0 * ((1.0 + (((sqrt(5.0) - 1.0) / 2.0) * cos(x))) + (((3.0 - sqrt(5.0)) / 2.0) * cos(y)))); end
code[x_, y_] := N[(N[(2.0 + N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * N[(N[(1.0 + N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision] / 2.0), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(1 + \frac{\sqrt{5} - 1}{2} \cdot \cos x\right) + \frac{3 - \sqrt{5}}{2} \cdot \cos y\right)}
(FPCore (x y)
:precision binary64
(/
(+
2.0
(*
(*
(* (sqrt 2.0) (- (sin x) (/ (sin y) 16.0)))
(- (sin y) (/ (sin x) 16.0)))
(- (cos x) (cos y))))
(+
3.0
(*
(-
(* (* 0.5 (- (sqrt 5.0) 1.0)) (cos x))
(* (* (* (- 1.0 (/ 3.0 (sqrt 5.0))) (sqrt 5.0)) 0.5) (cos y)))
3.0))))double code(double x, double y) {
return (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * (sin(y) - (sin(x) / 16.0))) * (cos(x) - cos(y)))) / (3.0 + ((((0.5 * (sqrt(5.0) - 1.0)) * cos(x)) - ((((1.0 - (3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (2.0d0 + (((sqrt(2.0d0) * (sin(x) - (sin(y) / 16.0d0))) * (sin(y) - (sin(x) / 16.0d0))) * (cos(x) - cos(y)))) / (3.0d0 + ((((0.5d0 * (sqrt(5.0d0) - 1.0d0)) * cos(x)) - ((((1.0d0 - (3.0d0 / sqrt(5.0d0))) * sqrt(5.0d0)) * 0.5d0) * cos(y))) * 3.0d0))
end function
public static double code(double x, double y) {
return (2.0 + (((Math.sqrt(2.0) * (Math.sin(x) - (Math.sin(y) / 16.0))) * (Math.sin(y) - (Math.sin(x) / 16.0))) * (Math.cos(x) - Math.cos(y)))) / (3.0 + ((((0.5 * (Math.sqrt(5.0) - 1.0)) * Math.cos(x)) - ((((1.0 - (3.0 / Math.sqrt(5.0))) * Math.sqrt(5.0)) * 0.5) * Math.cos(y))) * 3.0));
}
def code(x, y): return (2.0 + (((math.sqrt(2.0) * (math.sin(x) - (math.sin(y) / 16.0))) * (math.sin(y) - (math.sin(x) / 16.0))) * (math.cos(x) - math.cos(y)))) / (3.0 + ((((0.5 * (math.sqrt(5.0) - 1.0)) * math.cos(x)) - ((((1.0 - (3.0 / math.sqrt(5.0))) * math.sqrt(5.0)) * 0.5) * math.cos(y))) * 3.0))
function code(x, y) return Float64(Float64(2.0 + Float64(Float64(Float64(sqrt(2.0) * Float64(sin(x) - Float64(sin(y) / 16.0))) * Float64(sin(y) - Float64(sin(x) / 16.0))) * Float64(cos(x) - cos(y)))) / Float64(3.0 + Float64(Float64(Float64(Float64(0.5 * Float64(sqrt(5.0) - 1.0)) * cos(x)) - Float64(Float64(Float64(Float64(1.0 - Float64(3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0))) end
function tmp = code(x, y) tmp = (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * (sin(y) - (sin(x) / 16.0))) * (cos(x) - cos(y)))) / (3.0 + ((((0.5 * (sqrt(5.0) - 1.0)) * cos(x)) - ((((1.0 - (3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0)); end
code[x_, y_] := N[(N[(2.0 + N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(N[(N[(0.5 * N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[(1.0 - N[(3.0 / N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(\cos x - \cos y\right)}{3 + \left(\left(0.5 \cdot \left(\sqrt{5} - 1\right)\right) \cdot \cos x - \left(\left(\left(1 - \frac{3}{\sqrt{5}}\right) \cdot \sqrt{5}\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3}
Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f6499.3%
Applied rewrites99.3%
(FPCore (x y)
:precision binary64
(/
(+
2.0
(*
(- (sin y) (* 0.0625 (sin x)))
(*
(* (- (sin x) (* 0.0625 (sin y))) (sqrt 2.0))
(- (cos x) (cos y)))))
(+
3.0
(*
(-
(* (* 0.5 (- 2.23606797749979 1.0)) (cos x))
(* (* (- 2.23606797749979 3.0) 0.5) (cos y)))
3.0))))double code(double x, double y) {
return (2.0 + ((sin(y) - (0.0625 * sin(x))) * (((sin(x) - (0.0625 * sin(y))) * sqrt(2.0)) * (cos(x) - cos(y))))) / (3.0 + ((((0.5 * (2.23606797749979 - 1.0)) * cos(x)) - (((2.23606797749979 - 3.0) * 0.5) * cos(y))) * 3.0));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (2.0d0 + ((sin(y) - (0.0625d0 * sin(x))) * (((sin(x) - (0.0625d0 * sin(y))) * sqrt(2.0d0)) * (cos(x) - cos(y))))) / (3.0d0 + ((((0.5d0 * (2.23606797749979d0 - 1.0d0)) * cos(x)) - (((2.23606797749979d0 - 3.0d0) * 0.5d0) * cos(y))) * 3.0d0))
end function
public static double code(double x, double y) {
return (2.0 + ((Math.sin(y) - (0.0625 * Math.sin(x))) * (((Math.sin(x) - (0.0625 * Math.sin(y))) * Math.sqrt(2.0)) * (Math.cos(x) - Math.cos(y))))) / (3.0 + ((((0.5 * (2.23606797749979 - 1.0)) * Math.cos(x)) - (((2.23606797749979 - 3.0) * 0.5) * Math.cos(y))) * 3.0));
}
def code(x, y): return (2.0 + ((math.sin(y) - (0.0625 * math.sin(x))) * (((math.sin(x) - (0.0625 * math.sin(y))) * math.sqrt(2.0)) * (math.cos(x) - math.cos(y))))) / (3.0 + ((((0.5 * (2.23606797749979 - 1.0)) * math.cos(x)) - (((2.23606797749979 - 3.0) * 0.5) * math.cos(y))) * 3.0))
function code(x, y) return Float64(Float64(2.0 + Float64(Float64(sin(y) - Float64(0.0625 * sin(x))) * Float64(Float64(Float64(sin(x) - Float64(0.0625 * sin(y))) * sqrt(2.0)) * Float64(cos(x) - cos(y))))) / Float64(3.0 + Float64(Float64(Float64(Float64(0.5 * Float64(2.23606797749979 - 1.0)) * cos(x)) - Float64(Float64(Float64(2.23606797749979 - 3.0) * 0.5) * cos(y))) * 3.0))) end
function tmp = code(x, y) tmp = (2.0 + ((sin(y) - (0.0625 * sin(x))) * (((sin(x) - (0.0625 * sin(y))) * sqrt(2.0)) * (cos(x) - cos(y))))) / (3.0 + ((((0.5 * (2.23606797749979 - 1.0)) * cos(x)) - (((2.23606797749979 - 3.0) * 0.5) * cos(y))) * 3.0)); end
code[x_, y_] := N[(N[(2.0 + N[(N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Sin[x], $MachinePrecision] - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(N[(N[(0.5 * N[(2.23606797749979 - 1.0), $MachinePrecision]), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(2.23606797749979 - 3.0), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{2 + \left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\left(\left(\sin x - 0.0625 \cdot \sin y\right) \cdot \sqrt{2}\right) \cdot \left(\cos x - \cos y\right)\right)}{3 + \left(\left(0.5 \cdot \left(2.23606797749979 - 1\right)\right) \cdot \cos x - \left(\left(2.23606797749979 - 3\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3}
Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Evaluated real constant99.3%
Evaluated real constant99.3%
(FPCore (x y)
:precision binary64
(*
0.3333333333333333
(/
(+
2.0
(*
(sqrt 2.0)
(*
(- (cos x) (cos y))
(*
(- (sin x) (* 0.0625 (sin y)))
(- (sin y) (* 0.0625 (sin x)))))))
(+
1.0
(+
(* 0.5 (* (cos x) (- 2.23606797749979 1.0)))
(* 0.5 (* (cos y) (- 3.0 2.23606797749979))))))))double code(double x, double y) {
return 0.3333333333333333 * ((2.0 + (sqrt(2.0) * ((cos(x) - cos(y)) * ((sin(x) - (0.0625 * sin(y))) * (sin(y) - (0.0625 * sin(x))))))) / (1.0 + ((0.5 * (cos(x) * (2.23606797749979 - 1.0))) + (0.5 * (cos(y) * (3.0 - 2.23606797749979))))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.3333333333333333d0 * ((2.0d0 + (sqrt(2.0d0) * ((cos(x) - cos(y)) * ((sin(x) - (0.0625d0 * sin(y))) * (sin(y) - (0.0625d0 * sin(x))))))) / (1.0d0 + ((0.5d0 * (cos(x) * (2.23606797749979d0 - 1.0d0))) + (0.5d0 * (cos(y) * (3.0d0 - 2.23606797749979d0))))))
end function
public static double code(double x, double y) {
return 0.3333333333333333 * ((2.0 + (Math.sqrt(2.0) * ((Math.cos(x) - Math.cos(y)) * ((Math.sin(x) - (0.0625 * Math.sin(y))) * (Math.sin(y) - (0.0625 * Math.sin(x))))))) / (1.0 + ((0.5 * (Math.cos(x) * (2.23606797749979 - 1.0))) + (0.5 * (Math.cos(y) * (3.0 - 2.23606797749979))))));
}
def code(x, y): return 0.3333333333333333 * ((2.0 + (math.sqrt(2.0) * ((math.cos(x) - math.cos(y)) * ((math.sin(x) - (0.0625 * math.sin(y))) * (math.sin(y) - (0.0625 * math.sin(x))))))) / (1.0 + ((0.5 * (math.cos(x) * (2.23606797749979 - 1.0))) + (0.5 * (math.cos(y) * (3.0 - 2.23606797749979))))))
function code(x, y) return Float64(0.3333333333333333 * Float64(Float64(2.0 + Float64(sqrt(2.0) * Float64(Float64(cos(x) - cos(y)) * Float64(Float64(sin(x) - Float64(0.0625 * sin(y))) * Float64(sin(y) - Float64(0.0625 * sin(x))))))) / Float64(1.0 + Float64(Float64(0.5 * Float64(cos(x) * Float64(2.23606797749979 - 1.0))) + Float64(0.5 * Float64(cos(y) * Float64(3.0 - 2.23606797749979))))))) end
function tmp = code(x, y) tmp = 0.3333333333333333 * ((2.0 + (sqrt(2.0) * ((cos(x) - cos(y)) * ((sin(x) - (0.0625 * sin(y))) * (sin(y) - (0.0625 * sin(x))))))) / (1.0 + ((0.5 * (cos(x) * (2.23606797749979 - 1.0))) + (0.5 * (cos(y) * (3.0 - 2.23606797749979)))))); end
code[x_, y_] := N[(0.3333333333333333 * N[(N[(2.0 + N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[x], $MachinePrecision] - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(0.5 * N[(N[Cos[x], $MachinePrecision] * N[(2.23606797749979 - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[Cos[y], $MachinePrecision] * N[(3.0 - 2.23606797749979), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
0.3333333333333333 \cdot \frac{2 + \sqrt{2} \cdot \left(\left(\cos x - \cos y\right) \cdot \left(\left(\sin x - 0.0625 \cdot \sin y\right) \cdot \left(\sin y - 0.0625 \cdot \sin x\right)\right)\right)}{1 + \left(0.5 \cdot \left(\cos x \cdot \left(2.23606797749979 - 1\right)\right) + 0.5 \cdot \left(\cos y \cdot \left(3 - 2.23606797749979\right)\right)\right)}
Initial program 99.3%
Taylor expanded in x around inf
Applied rewrites99.2%
Evaluated real constant99.2%
Evaluated real constant99.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (cos x) (cos y)))
(t_1 (* (* 0.5 (- (sqrt 5.0) 1.0)) (cos x)))
(t_2
(/
(+
2.0
(*
(sin y)
(* (* (- (sin x) (* 0.0625 (sin y))) (sqrt 2.0)) t_0)))
(+
3.0
(* (- t_1 (* (* (- (sqrt 5.0) 3.0) 0.5) (cos y))) 3.0)))))
(if (<= y -3.8)
t_2
(if (<= y 2.9)
(/
(+
2.0
(*
(*
(* (sqrt 2.0) (- (sin x) (* 0.0625 y)))
(- (sin y) (/ (sin x) 16.0)))
t_0))
(+
3.0
(*
(-
t_1
(*
(* (* (- 1.0 (/ 3.0 (sqrt 5.0))) (sqrt 5.0)) 0.5)
(cos y)))
3.0)))
t_2))))double code(double x, double y) {
double t_0 = cos(x) - cos(y);
double t_1 = (0.5 * (sqrt(5.0) - 1.0)) * cos(x);
double t_2 = (2.0 + (sin(y) * (((sin(x) - (0.0625 * sin(y))) * sqrt(2.0)) * t_0))) / (3.0 + ((t_1 - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0));
double tmp;
if (y <= -3.8) {
tmp = t_2;
} else if (y <= 2.9) {
tmp = (2.0 + (((sqrt(2.0) * (sin(x) - (0.0625 * y))) * (sin(y) - (sin(x) / 16.0))) * t_0)) / (3.0 + ((t_1 - ((((1.0 - (3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0));
} else {
tmp = t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(x) - cos(y)
t_1 = (0.5d0 * (sqrt(5.0d0) - 1.0d0)) * cos(x)
t_2 = (2.0d0 + (sin(y) * (((sin(x) - (0.0625d0 * sin(y))) * sqrt(2.0d0)) * t_0))) / (3.0d0 + ((t_1 - (((sqrt(5.0d0) - 3.0d0) * 0.5d0) * cos(y))) * 3.0d0))
if (y <= (-3.8d0)) then
tmp = t_2
else if (y <= 2.9d0) then
tmp = (2.0d0 + (((sqrt(2.0d0) * (sin(x) - (0.0625d0 * y))) * (sin(y) - (sin(x) / 16.0d0))) * t_0)) / (3.0d0 + ((t_1 - ((((1.0d0 - (3.0d0 / sqrt(5.0d0))) * sqrt(5.0d0)) * 0.5d0) * cos(y))) * 3.0d0))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.cos(x) - Math.cos(y);
double t_1 = (0.5 * (Math.sqrt(5.0) - 1.0)) * Math.cos(x);
double t_2 = (2.0 + (Math.sin(y) * (((Math.sin(x) - (0.0625 * Math.sin(y))) * Math.sqrt(2.0)) * t_0))) / (3.0 + ((t_1 - (((Math.sqrt(5.0) - 3.0) * 0.5) * Math.cos(y))) * 3.0));
double tmp;
if (y <= -3.8) {
tmp = t_2;
} else if (y <= 2.9) {
tmp = (2.0 + (((Math.sqrt(2.0) * (Math.sin(x) - (0.0625 * y))) * (Math.sin(y) - (Math.sin(x) / 16.0))) * t_0)) / (3.0 + ((t_1 - ((((1.0 - (3.0 / Math.sqrt(5.0))) * Math.sqrt(5.0)) * 0.5) * Math.cos(y))) * 3.0));
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y): t_0 = math.cos(x) - math.cos(y) t_1 = (0.5 * (math.sqrt(5.0) - 1.0)) * math.cos(x) t_2 = (2.0 + (math.sin(y) * (((math.sin(x) - (0.0625 * math.sin(y))) * math.sqrt(2.0)) * t_0))) / (3.0 + ((t_1 - (((math.sqrt(5.0) - 3.0) * 0.5) * math.cos(y))) * 3.0)) tmp = 0 if y <= -3.8: tmp = t_2 elif y <= 2.9: tmp = (2.0 + (((math.sqrt(2.0) * (math.sin(x) - (0.0625 * y))) * (math.sin(y) - (math.sin(x) / 16.0))) * t_0)) / (3.0 + ((t_1 - ((((1.0 - (3.0 / math.sqrt(5.0))) * math.sqrt(5.0)) * 0.5) * math.cos(y))) * 3.0)) else: tmp = t_2 return tmp
function code(x, y) t_0 = Float64(cos(x) - cos(y)) t_1 = Float64(Float64(0.5 * Float64(sqrt(5.0) - 1.0)) * cos(x)) t_2 = Float64(Float64(2.0 + Float64(sin(y) * Float64(Float64(Float64(sin(x) - Float64(0.0625 * sin(y))) * sqrt(2.0)) * t_0))) / Float64(3.0 + Float64(Float64(t_1 - Float64(Float64(Float64(sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0))) tmp = 0.0 if (y <= -3.8) tmp = t_2; elseif (y <= 2.9) tmp = Float64(Float64(2.0 + Float64(Float64(Float64(sqrt(2.0) * Float64(sin(x) - Float64(0.0625 * y))) * Float64(sin(y) - Float64(sin(x) / 16.0))) * t_0)) / Float64(3.0 + Float64(Float64(t_1 - Float64(Float64(Float64(Float64(1.0 - Float64(3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0))); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y) t_0 = cos(x) - cos(y); t_1 = (0.5 * (sqrt(5.0) - 1.0)) * cos(x); t_2 = (2.0 + (sin(y) * (((sin(x) - (0.0625 * sin(y))) * sqrt(2.0)) * t_0))) / (3.0 + ((t_1 - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0)); tmp = 0.0; if (y <= -3.8) tmp = t_2; elseif (y <= 2.9) tmp = (2.0 + (((sqrt(2.0) * (sin(x) - (0.0625 * y))) * (sin(y) - (sin(x) / 16.0))) * t_0)) / (3.0 + ((t_1 - ((((1.0 - (3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0)); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 * N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(2.0 + N[(N[Sin[y], $MachinePrecision] * N[(N[(N[(N[Sin[x], $MachinePrecision] - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(t$95$1 - N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.8], t$95$2, If[LessEqual[y, 2.9], N[(N[(2.0 + N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] - N[(0.0625 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(t$95$1 - N[(N[(N[(N[(1.0 - N[(3.0 / N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
t_0 := \cos x - \cos y\\
t_1 := \left(0.5 \cdot \left(\sqrt{5} - 1\right)\right) \cdot \cos x\\
t_2 := \frac{2 + \sin y \cdot \left(\left(\left(\sin x - 0.0625 \cdot \sin y\right) \cdot \sqrt{2}\right) \cdot t\_0\right)}{3 + \left(t\_1 - \left(\left(\sqrt{5} - 3\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3}\\
\mathbf{if}\;y \leq -3.8:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 2.9:\\
\;\;\;\;\frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - 0.0625 \cdot y\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot t\_0}{3 + \left(t\_1 - \left(\left(\left(1 - \frac{3}{\sqrt{5}}\right) \cdot \sqrt{5}\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if y < -3.7999999999999998 or 2.8999999999999999 < y Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in x around 0
lower-sin.f6464.3%
Applied rewrites64.3%
if -3.7999999999999998 < y < 2.8999999999999999Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f6499.3%
Applied rewrites99.3%
Taylor expanded in y around 0
lower-*.f6450.3%
Applied rewrites50.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (cos x) (cos y)))
(t_1
(+
3.0
(*
(-
(* (* 0.5 (- (sqrt 5.0) 1.0)) (cos x))
(* (* (- (sqrt 5.0) 3.0) 0.5) (cos y)))
3.0)))
(t_2
(/
(+
2.0
(*
(sin y)
(* (* (- (sin x) (* 0.0625 (sin y))) (sqrt 2.0)) t_0)))
t_1)))
(if (<= y -3.8)
t_2
(if (<= y 2.9)
(/
(+
2.0
(*
(- (sin y) (* 0.0625 (sin x)))
(* (* (- (sin x) (* 0.0625 y)) (sqrt 2.0)) t_0)))
t_1)
t_2))))double code(double x, double y) {
double t_0 = cos(x) - cos(y);
double t_1 = 3.0 + ((((0.5 * (sqrt(5.0) - 1.0)) * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0);
double t_2 = (2.0 + (sin(y) * (((sin(x) - (0.0625 * sin(y))) * sqrt(2.0)) * t_0))) / t_1;
double tmp;
if (y <= -3.8) {
tmp = t_2;
} else if (y <= 2.9) {
tmp = (2.0 + ((sin(y) - (0.0625 * sin(x))) * (((sin(x) - (0.0625 * y)) * sqrt(2.0)) * t_0))) / t_1;
} else {
tmp = t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(x) - cos(y)
t_1 = 3.0d0 + ((((0.5d0 * (sqrt(5.0d0) - 1.0d0)) * cos(x)) - (((sqrt(5.0d0) - 3.0d0) * 0.5d0) * cos(y))) * 3.0d0)
t_2 = (2.0d0 + (sin(y) * (((sin(x) - (0.0625d0 * sin(y))) * sqrt(2.0d0)) * t_0))) / t_1
if (y <= (-3.8d0)) then
tmp = t_2
else if (y <= 2.9d0) then
tmp = (2.0d0 + ((sin(y) - (0.0625d0 * sin(x))) * (((sin(x) - (0.0625d0 * y)) * sqrt(2.0d0)) * t_0))) / t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.cos(x) - Math.cos(y);
double t_1 = 3.0 + ((((0.5 * (Math.sqrt(5.0) - 1.0)) * Math.cos(x)) - (((Math.sqrt(5.0) - 3.0) * 0.5) * Math.cos(y))) * 3.0);
double t_2 = (2.0 + (Math.sin(y) * (((Math.sin(x) - (0.0625 * Math.sin(y))) * Math.sqrt(2.0)) * t_0))) / t_1;
double tmp;
if (y <= -3.8) {
tmp = t_2;
} else if (y <= 2.9) {
tmp = (2.0 + ((Math.sin(y) - (0.0625 * Math.sin(x))) * (((Math.sin(x) - (0.0625 * y)) * Math.sqrt(2.0)) * t_0))) / t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y): t_0 = math.cos(x) - math.cos(y) t_1 = 3.0 + ((((0.5 * (math.sqrt(5.0) - 1.0)) * math.cos(x)) - (((math.sqrt(5.0) - 3.0) * 0.5) * math.cos(y))) * 3.0) t_2 = (2.0 + (math.sin(y) * (((math.sin(x) - (0.0625 * math.sin(y))) * math.sqrt(2.0)) * t_0))) / t_1 tmp = 0 if y <= -3.8: tmp = t_2 elif y <= 2.9: tmp = (2.0 + ((math.sin(y) - (0.0625 * math.sin(x))) * (((math.sin(x) - (0.0625 * y)) * math.sqrt(2.0)) * t_0))) / t_1 else: tmp = t_2 return tmp
function code(x, y) t_0 = Float64(cos(x) - cos(y)) t_1 = Float64(3.0 + Float64(Float64(Float64(Float64(0.5 * Float64(sqrt(5.0) - 1.0)) * cos(x)) - Float64(Float64(Float64(sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0)) t_2 = Float64(Float64(2.0 + Float64(sin(y) * Float64(Float64(Float64(sin(x) - Float64(0.0625 * sin(y))) * sqrt(2.0)) * t_0))) / t_1) tmp = 0.0 if (y <= -3.8) tmp = t_2; elseif (y <= 2.9) tmp = Float64(Float64(2.0 + Float64(Float64(sin(y) - Float64(0.0625 * sin(x))) * Float64(Float64(Float64(sin(x) - Float64(0.0625 * y)) * sqrt(2.0)) * t_0))) / t_1); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y) t_0 = cos(x) - cos(y); t_1 = 3.0 + ((((0.5 * (sqrt(5.0) - 1.0)) * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0); t_2 = (2.0 + (sin(y) * (((sin(x) - (0.0625 * sin(y))) * sqrt(2.0)) * t_0))) / t_1; tmp = 0.0; if (y <= -3.8) tmp = t_2; elseif (y <= 2.9) tmp = (2.0 + ((sin(y) - (0.0625 * sin(x))) * (((sin(x) - (0.0625 * y)) * sqrt(2.0)) * t_0))) / t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(3.0 + N[(N[(N[(N[(0.5 * N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(2.0 + N[(N[Sin[y], $MachinePrecision] * N[(N[(N[(N[Sin[x], $MachinePrecision] - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[y, -3.8], t$95$2, If[LessEqual[y, 2.9], N[(N[(2.0 + N[(N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Sin[x], $MachinePrecision] - N[(0.0625 * y), $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
t_0 := \cos x - \cos y\\
t_1 := 3 + \left(\left(0.5 \cdot \left(\sqrt{5} - 1\right)\right) \cdot \cos x - \left(\left(\sqrt{5} - 3\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3\\
t_2 := \frac{2 + \sin y \cdot \left(\left(\left(\sin x - 0.0625 \cdot \sin y\right) \cdot \sqrt{2}\right) \cdot t\_0\right)}{t\_1}\\
\mathbf{if}\;y \leq -3.8:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 2.9:\\
\;\;\;\;\frac{2 + \left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\left(\left(\sin x - 0.0625 \cdot y\right) \cdot \sqrt{2}\right) \cdot t\_0\right)}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if y < -3.7999999999999998 or 2.8999999999999999 < y Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in x around 0
lower-sin.f6464.3%
Applied rewrites64.3%
if -3.7999999999999998 < y < 2.8999999999999999Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in y around 0
lower-*.f6450.2%
Applied rewrites50.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (cos x) (cos y)))
(t_1
(+
3.0
(*
(-
(* (* 0.5 (- (sqrt 5.0) 1.0)) (cos x))
(* (* (- (sqrt 5.0) 3.0) 0.5) (cos y)))
3.0)))
(t_2
(/
(+
2.0
(*
(- (sin y) (* 0.0625 (sin x)))
(* (* (sin x) (sqrt 2.0)) t_0)))
t_1)))
(if (<= x -0.035)
t_2
(if (<= x 1.45e-5)
(/
(+
2.0
(*
(- (sin y) (* 0.0625 x))
(* (* (- (sin x) (* 0.0625 (sin y))) (sqrt 2.0)) t_0)))
t_1)
t_2))))double code(double x, double y) {
double t_0 = cos(x) - cos(y);
double t_1 = 3.0 + ((((0.5 * (sqrt(5.0) - 1.0)) * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0);
double t_2 = (2.0 + ((sin(y) - (0.0625 * sin(x))) * ((sin(x) * sqrt(2.0)) * t_0))) / t_1;
double tmp;
if (x <= -0.035) {
tmp = t_2;
} else if (x <= 1.45e-5) {
tmp = (2.0 + ((sin(y) - (0.0625 * x)) * (((sin(x) - (0.0625 * sin(y))) * sqrt(2.0)) * t_0))) / t_1;
} else {
tmp = t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(x) - cos(y)
t_1 = 3.0d0 + ((((0.5d0 * (sqrt(5.0d0) - 1.0d0)) * cos(x)) - (((sqrt(5.0d0) - 3.0d0) * 0.5d0) * cos(y))) * 3.0d0)
t_2 = (2.0d0 + ((sin(y) - (0.0625d0 * sin(x))) * ((sin(x) * sqrt(2.0d0)) * t_0))) / t_1
if (x <= (-0.035d0)) then
tmp = t_2
else if (x <= 1.45d-5) then
tmp = (2.0d0 + ((sin(y) - (0.0625d0 * x)) * (((sin(x) - (0.0625d0 * sin(y))) * sqrt(2.0d0)) * t_0))) / t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.cos(x) - Math.cos(y);
double t_1 = 3.0 + ((((0.5 * (Math.sqrt(5.0) - 1.0)) * Math.cos(x)) - (((Math.sqrt(5.0) - 3.0) * 0.5) * Math.cos(y))) * 3.0);
double t_2 = (2.0 + ((Math.sin(y) - (0.0625 * Math.sin(x))) * ((Math.sin(x) * Math.sqrt(2.0)) * t_0))) / t_1;
double tmp;
if (x <= -0.035) {
tmp = t_2;
} else if (x <= 1.45e-5) {
tmp = (2.0 + ((Math.sin(y) - (0.0625 * x)) * (((Math.sin(x) - (0.0625 * Math.sin(y))) * Math.sqrt(2.0)) * t_0))) / t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y): t_0 = math.cos(x) - math.cos(y) t_1 = 3.0 + ((((0.5 * (math.sqrt(5.0) - 1.0)) * math.cos(x)) - (((math.sqrt(5.0) - 3.0) * 0.5) * math.cos(y))) * 3.0) t_2 = (2.0 + ((math.sin(y) - (0.0625 * math.sin(x))) * ((math.sin(x) * math.sqrt(2.0)) * t_0))) / t_1 tmp = 0 if x <= -0.035: tmp = t_2 elif x <= 1.45e-5: tmp = (2.0 + ((math.sin(y) - (0.0625 * x)) * (((math.sin(x) - (0.0625 * math.sin(y))) * math.sqrt(2.0)) * t_0))) / t_1 else: tmp = t_2 return tmp
function code(x, y) t_0 = Float64(cos(x) - cos(y)) t_1 = Float64(3.0 + Float64(Float64(Float64(Float64(0.5 * Float64(sqrt(5.0) - 1.0)) * cos(x)) - Float64(Float64(Float64(sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0)) t_2 = Float64(Float64(2.0 + Float64(Float64(sin(y) - Float64(0.0625 * sin(x))) * Float64(Float64(sin(x) * sqrt(2.0)) * t_0))) / t_1) tmp = 0.0 if (x <= -0.035) tmp = t_2; elseif (x <= 1.45e-5) tmp = Float64(Float64(2.0 + Float64(Float64(sin(y) - Float64(0.0625 * x)) * Float64(Float64(Float64(sin(x) - Float64(0.0625 * sin(y))) * sqrt(2.0)) * t_0))) / t_1); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y) t_0 = cos(x) - cos(y); t_1 = 3.0 + ((((0.5 * (sqrt(5.0) - 1.0)) * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0); t_2 = (2.0 + ((sin(y) - (0.0625 * sin(x))) * ((sin(x) * sqrt(2.0)) * t_0))) / t_1; tmp = 0.0; if (x <= -0.035) tmp = t_2; elseif (x <= 1.45e-5) tmp = (2.0 + ((sin(y) - (0.0625 * x)) * (((sin(x) - (0.0625 * sin(y))) * sqrt(2.0)) * t_0))) / t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(3.0 + N[(N[(N[(N[(0.5 * N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(2.0 + N[(N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[x], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[x, -0.035], t$95$2, If[LessEqual[x, 1.45e-5], N[(N[(2.0 + N[(N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * x), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Sin[x], $MachinePrecision] - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
t_0 := \cos x - \cos y\\
t_1 := 3 + \left(\left(0.5 \cdot \left(\sqrt{5} - 1\right)\right) \cdot \cos x - \left(\left(\sqrt{5} - 3\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3\\
t_2 := \frac{2 + \left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\left(\sin x \cdot \sqrt{2}\right) \cdot t\_0\right)}{t\_1}\\
\mathbf{if}\;x \leq -0.035:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{2 + \left(\sin y - 0.0625 \cdot x\right) \cdot \left(\left(\left(\sin x - 0.0625 \cdot \sin y\right) \cdot \sqrt{2}\right) \cdot t\_0\right)}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if x < -0.035000000000000003 or 1.45e-5 < x Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f6463.4%
Applied rewrites63.4%
if -0.035000000000000003 < x < 1.45e-5Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in x around 0
lower-*.f6451.5%
Applied rewrites51.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (sqrt 5.0) 3.0))
(t_1 (* (* 0.5 (- (sqrt 5.0) 1.0)) (cos x)))
(t_2
(*
(* (- (sin x) (* 0.0625 (sin y))) (sqrt 2.0))
(- (cos x) (cos y))))
(t_3
(/
(+ 2.0 (* (sin y) t_2))
(+ 3.0 (* (- t_1 (* (* t_0 0.5) (cos y))) 3.0)))))
(if (<= y -19.5)
t_3
(if (<= y 2.16e-7)
(/
(+ 2.0 (* (- (sin y) (* 0.0625 (sin x))) t_2))
(+ 3.0 (* (- t_1 (* 0.5 t_0)) 3.0)))
t_3))))double code(double x, double y) {
double t_0 = sqrt(5.0) - 3.0;
double t_1 = (0.5 * (sqrt(5.0) - 1.0)) * cos(x);
double t_2 = ((sin(x) - (0.0625 * sin(y))) * sqrt(2.0)) * (cos(x) - cos(y));
double t_3 = (2.0 + (sin(y) * t_2)) / (3.0 + ((t_1 - ((t_0 * 0.5) * cos(y))) * 3.0));
double tmp;
if (y <= -19.5) {
tmp = t_3;
} else if (y <= 2.16e-7) {
tmp = (2.0 + ((sin(y) - (0.0625 * sin(x))) * t_2)) / (3.0 + ((t_1 - (0.5 * t_0)) * 3.0));
} else {
tmp = t_3;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sqrt(5.0d0) - 3.0d0
t_1 = (0.5d0 * (sqrt(5.0d0) - 1.0d0)) * cos(x)
t_2 = ((sin(x) - (0.0625d0 * sin(y))) * sqrt(2.0d0)) * (cos(x) - cos(y))
t_3 = (2.0d0 + (sin(y) * t_2)) / (3.0d0 + ((t_1 - ((t_0 * 0.5d0) * cos(y))) * 3.0d0))
if (y <= (-19.5d0)) then
tmp = t_3
else if (y <= 2.16d-7) then
tmp = (2.0d0 + ((sin(y) - (0.0625d0 * sin(x))) * t_2)) / (3.0d0 + ((t_1 - (0.5d0 * t_0)) * 3.0d0))
else
tmp = t_3
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.sqrt(5.0) - 3.0;
double t_1 = (0.5 * (Math.sqrt(5.0) - 1.0)) * Math.cos(x);
double t_2 = ((Math.sin(x) - (0.0625 * Math.sin(y))) * Math.sqrt(2.0)) * (Math.cos(x) - Math.cos(y));
double t_3 = (2.0 + (Math.sin(y) * t_2)) / (3.0 + ((t_1 - ((t_0 * 0.5) * Math.cos(y))) * 3.0));
double tmp;
if (y <= -19.5) {
tmp = t_3;
} else if (y <= 2.16e-7) {
tmp = (2.0 + ((Math.sin(y) - (0.0625 * Math.sin(x))) * t_2)) / (3.0 + ((t_1 - (0.5 * t_0)) * 3.0));
} else {
tmp = t_3;
}
return tmp;
}
def code(x, y): t_0 = math.sqrt(5.0) - 3.0 t_1 = (0.5 * (math.sqrt(5.0) - 1.0)) * math.cos(x) t_2 = ((math.sin(x) - (0.0625 * math.sin(y))) * math.sqrt(2.0)) * (math.cos(x) - math.cos(y)) t_3 = (2.0 + (math.sin(y) * t_2)) / (3.0 + ((t_1 - ((t_0 * 0.5) * math.cos(y))) * 3.0)) tmp = 0 if y <= -19.5: tmp = t_3 elif y <= 2.16e-7: tmp = (2.0 + ((math.sin(y) - (0.0625 * math.sin(x))) * t_2)) / (3.0 + ((t_1 - (0.5 * t_0)) * 3.0)) else: tmp = t_3 return tmp
function code(x, y) t_0 = Float64(sqrt(5.0) - 3.0) t_1 = Float64(Float64(0.5 * Float64(sqrt(5.0) - 1.0)) * cos(x)) t_2 = Float64(Float64(Float64(sin(x) - Float64(0.0625 * sin(y))) * sqrt(2.0)) * Float64(cos(x) - cos(y))) t_3 = Float64(Float64(2.0 + Float64(sin(y) * t_2)) / Float64(3.0 + Float64(Float64(t_1 - Float64(Float64(t_0 * 0.5) * cos(y))) * 3.0))) tmp = 0.0 if (y <= -19.5) tmp = t_3; elseif (y <= 2.16e-7) tmp = Float64(Float64(2.0 + Float64(Float64(sin(y) - Float64(0.0625 * sin(x))) * t_2)) / Float64(3.0 + Float64(Float64(t_1 - Float64(0.5 * t_0)) * 3.0))); else tmp = t_3; end return tmp end
function tmp_2 = code(x, y) t_0 = sqrt(5.0) - 3.0; t_1 = (0.5 * (sqrt(5.0) - 1.0)) * cos(x); t_2 = ((sin(x) - (0.0625 * sin(y))) * sqrt(2.0)) * (cos(x) - cos(y)); t_3 = (2.0 + (sin(y) * t_2)) / (3.0 + ((t_1 - ((t_0 * 0.5) * cos(y))) * 3.0)); tmp = 0.0; if (y <= -19.5) tmp = t_3; elseif (y <= 2.16e-7) tmp = (2.0 + ((sin(y) - (0.0625 * sin(x))) * t_2)) / (3.0 + ((t_1 - (0.5 * t_0)) * 3.0)); else tmp = t_3; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 * N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[Sin[x], $MachinePrecision] - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(2.0 + N[(N[Sin[y], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(t$95$1 - N[(N[(t$95$0 * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -19.5], t$95$3, If[LessEqual[y, 2.16e-7], N[(N[(2.0 + N[(N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(t$95$1 - N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
t_0 := \sqrt{5} - 3\\
t_1 := \left(0.5 \cdot \left(\sqrt{5} - 1\right)\right) \cdot \cos x\\
t_2 := \left(\left(\sin x - 0.0625 \cdot \sin y\right) \cdot \sqrt{2}\right) \cdot \left(\cos x - \cos y\right)\\
t_3 := \frac{2 + \sin y \cdot t\_2}{3 + \left(t\_1 - \left(t\_0 \cdot 0.5\right) \cdot \cos y\right) \cdot 3}\\
\mathbf{if}\;y \leq -19.5:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;y \leq 2.16 \cdot 10^{-7}:\\
\;\;\;\;\frac{2 + \left(\sin y - 0.0625 \cdot \sin x\right) \cdot t\_2}{3 + \left(t\_1 - 0.5 \cdot t\_0\right) \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
if y < -19.5 or 2.16e-7 < y Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in x around 0
lower-sin.f6464.3%
Applied rewrites64.3%
if -19.5 < y < 2.16e-7Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f6459.7%
Applied rewrites59.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (cos x) (cos y)))
(t_1 (- (sin x) (* 0.0625 (sin y))))
(t_2 (- (sqrt 5.0) 1.0))
(t_3
(/
(+ 2.0 (* (sin y) (* (* t_1 (sqrt 2.0)) t_0)))
(+
3.0
(*
(-
(* (* 0.5 t_2) (cos x))
(* (* (- (sqrt 5.0) 3.0) 0.5) (cos y)))
3.0)))))
(if (<= y -19.5)
t_3
(if (<= y 2.16e-7)
(*
0.3333333333333333
(/
(+
2.0
(*
(sqrt 2.0)
(* t_0 (* t_1 (- (sin y) (* 0.0625 (sin x)))))))
(+
1.0
(+ (* 0.5 (* (cos x) t_2)) (* 0.5 (- 3.0 (sqrt 5.0)))))))
t_3))))double code(double x, double y) {
double t_0 = cos(x) - cos(y);
double t_1 = sin(x) - (0.0625 * sin(y));
double t_2 = sqrt(5.0) - 1.0;
double t_3 = (2.0 + (sin(y) * ((t_1 * sqrt(2.0)) * t_0))) / (3.0 + ((((0.5 * t_2) * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0));
double tmp;
if (y <= -19.5) {
tmp = t_3;
} else if (y <= 2.16e-7) {
tmp = 0.3333333333333333 * ((2.0 + (sqrt(2.0) * (t_0 * (t_1 * (sin(y) - (0.0625 * sin(x))))))) / (1.0 + ((0.5 * (cos(x) * t_2)) + (0.5 * (3.0 - sqrt(5.0))))));
} else {
tmp = t_3;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(x) - cos(y)
t_1 = sin(x) - (0.0625d0 * sin(y))
t_2 = sqrt(5.0d0) - 1.0d0
t_3 = (2.0d0 + (sin(y) * ((t_1 * sqrt(2.0d0)) * t_0))) / (3.0d0 + ((((0.5d0 * t_2) * cos(x)) - (((sqrt(5.0d0) - 3.0d0) * 0.5d0) * cos(y))) * 3.0d0))
if (y <= (-19.5d0)) then
tmp = t_3
else if (y <= 2.16d-7) then
tmp = 0.3333333333333333d0 * ((2.0d0 + (sqrt(2.0d0) * (t_0 * (t_1 * (sin(y) - (0.0625d0 * sin(x))))))) / (1.0d0 + ((0.5d0 * (cos(x) * t_2)) + (0.5d0 * (3.0d0 - sqrt(5.0d0))))))
else
tmp = t_3
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.cos(x) - Math.cos(y);
double t_1 = Math.sin(x) - (0.0625 * Math.sin(y));
double t_2 = Math.sqrt(5.0) - 1.0;
double t_3 = (2.0 + (Math.sin(y) * ((t_1 * Math.sqrt(2.0)) * t_0))) / (3.0 + ((((0.5 * t_2) * Math.cos(x)) - (((Math.sqrt(5.0) - 3.0) * 0.5) * Math.cos(y))) * 3.0));
double tmp;
if (y <= -19.5) {
tmp = t_3;
} else if (y <= 2.16e-7) {
tmp = 0.3333333333333333 * ((2.0 + (Math.sqrt(2.0) * (t_0 * (t_1 * (Math.sin(y) - (0.0625 * Math.sin(x))))))) / (1.0 + ((0.5 * (Math.cos(x) * t_2)) + (0.5 * (3.0 - Math.sqrt(5.0))))));
} else {
tmp = t_3;
}
return tmp;
}
def code(x, y): t_0 = math.cos(x) - math.cos(y) t_1 = math.sin(x) - (0.0625 * math.sin(y)) t_2 = math.sqrt(5.0) - 1.0 t_3 = (2.0 + (math.sin(y) * ((t_1 * math.sqrt(2.0)) * t_0))) / (3.0 + ((((0.5 * t_2) * math.cos(x)) - (((math.sqrt(5.0) - 3.0) * 0.5) * math.cos(y))) * 3.0)) tmp = 0 if y <= -19.5: tmp = t_3 elif y <= 2.16e-7: tmp = 0.3333333333333333 * ((2.0 + (math.sqrt(2.0) * (t_0 * (t_1 * (math.sin(y) - (0.0625 * math.sin(x))))))) / (1.0 + ((0.5 * (math.cos(x) * t_2)) + (0.5 * (3.0 - math.sqrt(5.0)))))) else: tmp = t_3 return tmp
function code(x, y) t_0 = Float64(cos(x) - cos(y)) t_1 = Float64(sin(x) - Float64(0.0625 * sin(y))) t_2 = Float64(sqrt(5.0) - 1.0) t_3 = Float64(Float64(2.0 + Float64(sin(y) * Float64(Float64(t_1 * sqrt(2.0)) * t_0))) / Float64(3.0 + Float64(Float64(Float64(Float64(0.5 * t_2) * cos(x)) - Float64(Float64(Float64(sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0))) tmp = 0.0 if (y <= -19.5) tmp = t_3; elseif (y <= 2.16e-7) tmp = Float64(0.3333333333333333 * Float64(Float64(2.0 + Float64(sqrt(2.0) * Float64(t_0 * Float64(t_1 * Float64(sin(y) - Float64(0.0625 * sin(x))))))) / Float64(1.0 + Float64(Float64(0.5 * Float64(cos(x) * t_2)) + Float64(0.5 * Float64(3.0 - sqrt(5.0))))))); else tmp = t_3; end return tmp end
function tmp_2 = code(x, y) t_0 = cos(x) - cos(y); t_1 = sin(x) - (0.0625 * sin(y)); t_2 = sqrt(5.0) - 1.0; t_3 = (2.0 + (sin(y) * ((t_1 * sqrt(2.0)) * t_0))) / (3.0 + ((((0.5 * t_2) * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0)); tmp = 0.0; if (y <= -19.5) tmp = t_3; elseif (y <= 2.16e-7) tmp = 0.3333333333333333 * ((2.0 + (sqrt(2.0) * (t_0 * (t_1 * (sin(y) - (0.0625 * sin(x))))))) / (1.0 + ((0.5 * (cos(x) * t_2)) + (0.5 * (3.0 - sqrt(5.0)))))); else tmp = t_3; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[x], $MachinePrecision] - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[(2.0 + N[(N[Sin[y], $MachinePrecision] * N[(N[(t$95$1 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(N[(N[(0.5 * t$95$2), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -19.5], t$95$3, If[LessEqual[y, 2.16e-7], N[(0.3333333333333333 * N[(N[(2.0 + N[(N[Sqrt[2.0], $MachinePrecision] * N[(t$95$0 * N[(t$95$1 * N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(0.5 * N[(N[Cos[x], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
t_0 := \cos x - \cos y\\
t_1 := \sin x - 0.0625 \cdot \sin y\\
t_2 := \sqrt{5} - 1\\
t_3 := \frac{2 + \sin y \cdot \left(\left(t\_1 \cdot \sqrt{2}\right) \cdot t\_0\right)}{3 + \left(\left(0.5 \cdot t\_2\right) \cdot \cos x - \left(\left(\sqrt{5} - 3\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3}\\
\mathbf{if}\;y \leq -19.5:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;y \leq 2.16 \cdot 10^{-7}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{2 + \sqrt{2} \cdot \left(t\_0 \cdot \left(t\_1 \cdot \left(\sin y - 0.0625 \cdot \sin x\right)\right)\right)}{1 + \left(0.5 \cdot \left(\cos x \cdot t\_2\right) + 0.5 \cdot \left(3 - \sqrt{5}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
if y < -19.5 or 2.16e-7 < y Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in x around 0
lower-sin.f6464.3%
Applied rewrites64.3%
if -19.5 < y < 2.16e-7Initial program 99.3%
Taylor expanded in x around inf
Applied rewrites99.2%
Taylor expanded in y around 0
lower--.f64N/A
lower-sqrt.f6459.7%
Applied rewrites59.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* 0.5 (- (sqrt 5.0) 1.0)))
(t_1
(/
(+
2.0
(*
(- (sin y) (* 0.0625 (sin x)))
(* (* (sin x) (sqrt 2.0)) (- (cos x) (cos y)))))
(+
3.0
(*
(- (* t_0 (cos x)) (* (* (- (sqrt 5.0) 3.0) 0.5) (cos y)))
3.0)))))
(if (<= x -175000000.0)
t_1
(if (<= x 1.45e-5)
(/
(+
2.0
(*
(*
(* (sqrt 2.0) (- (sin x) (/ (sin y) 16.0)))
(- (sin y) (/ (sin x) 16.0)))
(- 1.0 (cos y))))
(+
3.0
(*
(-
(* t_0 1.0)
(*
(* (* (- 1.0 (/ 3.0 (sqrt 5.0))) (sqrt 5.0)) 0.5)
(cos y)))
3.0)))
t_1))))double code(double x, double y) {
double t_0 = 0.5 * (sqrt(5.0) - 1.0);
double t_1 = (2.0 + ((sin(y) - (0.0625 * sin(x))) * ((sin(x) * sqrt(2.0)) * (cos(x) - cos(y))))) / (3.0 + (((t_0 * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0));
double tmp;
if (x <= -175000000.0) {
tmp = t_1;
} else if (x <= 1.45e-5) {
tmp = (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * (sin(y) - (sin(x) / 16.0))) * (1.0 - cos(y)))) / (3.0 + (((t_0 * 1.0) - ((((1.0 - (3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * (sqrt(5.0d0) - 1.0d0)
t_1 = (2.0d0 + ((sin(y) - (0.0625d0 * sin(x))) * ((sin(x) * sqrt(2.0d0)) * (cos(x) - cos(y))))) / (3.0d0 + (((t_0 * cos(x)) - (((sqrt(5.0d0) - 3.0d0) * 0.5d0) * cos(y))) * 3.0d0))
if (x <= (-175000000.0d0)) then
tmp = t_1
else if (x <= 1.45d-5) then
tmp = (2.0d0 + (((sqrt(2.0d0) * (sin(x) - (sin(y) / 16.0d0))) * (sin(y) - (sin(x) / 16.0d0))) * (1.0d0 - cos(y)))) / (3.0d0 + (((t_0 * 1.0d0) - ((((1.0d0 - (3.0d0 / sqrt(5.0d0))) * sqrt(5.0d0)) * 0.5d0) * cos(y))) * 3.0d0))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 0.5 * (Math.sqrt(5.0) - 1.0);
double t_1 = (2.0 + ((Math.sin(y) - (0.0625 * Math.sin(x))) * ((Math.sin(x) * Math.sqrt(2.0)) * (Math.cos(x) - Math.cos(y))))) / (3.0 + (((t_0 * Math.cos(x)) - (((Math.sqrt(5.0) - 3.0) * 0.5) * Math.cos(y))) * 3.0));
double tmp;
if (x <= -175000000.0) {
tmp = t_1;
} else if (x <= 1.45e-5) {
tmp = (2.0 + (((Math.sqrt(2.0) * (Math.sin(x) - (Math.sin(y) / 16.0))) * (Math.sin(y) - (Math.sin(x) / 16.0))) * (1.0 - Math.cos(y)))) / (3.0 + (((t_0 * 1.0) - ((((1.0 - (3.0 / Math.sqrt(5.0))) * Math.sqrt(5.0)) * 0.5) * Math.cos(y))) * 3.0));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = 0.5 * (math.sqrt(5.0) - 1.0) t_1 = (2.0 + ((math.sin(y) - (0.0625 * math.sin(x))) * ((math.sin(x) * math.sqrt(2.0)) * (math.cos(x) - math.cos(y))))) / (3.0 + (((t_0 * math.cos(x)) - (((math.sqrt(5.0) - 3.0) * 0.5) * math.cos(y))) * 3.0)) tmp = 0 if x <= -175000000.0: tmp = t_1 elif x <= 1.45e-5: tmp = (2.0 + (((math.sqrt(2.0) * (math.sin(x) - (math.sin(y) / 16.0))) * (math.sin(y) - (math.sin(x) / 16.0))) * (1.0 - math.cos(y)))) / (3.0 + (((t_0 * 1.0) - ((((1.0 - (3.0 / math.sqrt(5.0))) * math.sqrt(5.0)) * 0.5) * math.cos(y))) * 3.0)) else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(0.5 * Float64(sqrt(5.0) - 1.0)) t_1 = Float64(Float64(2.0 + Float64(Float64(sin(y) - Float64(0.0625 * sin(x))) * Float64(Float64(sin(x) * sqrt(2.0)) * Float64(cos(x) - cos(y))))) / Float64(3.0 + Float64(Float64(Float64(t_0 * cos(x)) - Float64(Float64(Float64(sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0))) tmp = 0.0 if (x <= -175000000.0) tmp = t_1; elseif (x <= 1.45e-5) tmp = Float64(Float64(2.0 + Float64(Float64(Float64(sqrt(2.0) * Float64(sin(x) - Float64(sin(y) / 16.0))) * Float64(sin(y) - Float64(sin(x) / 16.0))) * Float64(1.0 - cos(y)))) / Float64(3.0 + Float64(Float64(Float64(t_0 * 1.0) - Float64(Float64(Float64(Float64(1.0 - Float64(3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = 0.5 * (sqrt(5.0) - 1.0); t_1 = (2.0 + ((sin(y) - (0.0625 * sin(x))) * ((sin(x) * sqrt(2.0)) * (cos(x) - cos(y))))) / (3.0 + (((t_0 * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0)); tmp = 0.0; if (x <= -175000000.0) tmp = t_1; elseif (x <= 1.45e-5) tmp = (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * (sin(y) - (sin(x) / 16.0))) * (1.0 - cos(y)))) / (3.0 + (((t_0 * 1.0) - ((((1.0 - (3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(0.5 * N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 + N[(N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[x], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(N[(t$95$0 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -175000000.0], t$95$1, If[LessEqual[x, 1.45e-5], N[(N[(2.0 + N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(N[(t$95$0 * 1.0), $MachinePrecision] - N[(N[(N[(N[(1.0 - N[(3.0 / N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := 0.5 \cdot \left(\sqrt{5} - 1\right)\\
t_1 := \frac{2 + \left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\left(\sin x \cdot \sqrt{2}\right) \cdot \left(\cos x - \cos y\right)\right)}{3 + \left(t\_0 \cdot \cos x - \left(\left(\sqrt{5} - 3\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3}\\
\mathbf{if}\;x \leq -175000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(1 - \cos y\right)}{3 + \left(t\_0 \cdot 1 - \left(\left(\left(1 - \frac{3}{\sqrt{5}}\right) \cdot \sqrt{5}\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if x < -1.75e8 or 1.45e-5 < x Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-sin.f64N/A
lower-sqrt.f6463.4%
Applied rewrites63.4%
if -1.75e8 < x < 1.45e-5Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f6499.3%
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites62.8%
Taylor expanded in x around 0
Applied rewrites60.1%
(FPCore (x y)
:precision binary64
(let* ((t_0
(+
3.0
(*
(-
(* (* 0.5 (- (sqrt 5.0) 1.0)) (cos x))
(* (* (- (sqrt 5.0) 3.0) 0.5) (cos y)))
3.0)))
(t_1
(/
(+
2.0
(*
(sin y)
(*
(* (- (sin x) (* 0.0625 (sin y))) (sqrt 2.0))
(- (cos x) (cos y)))))
t_0)))
(if (<= y -0.046)
t_1
(if (<= y 0.034)
(/
(+
2.0
(*
(- (sin y) (* 0.0625 (sin x)))
(* (sin x) (* (sqrt 2.0) (- (cos x) 1.0)))))
t_0)
t_1))))double code(double x, double y) {
double t_0 = 3.0 + ((((0.5 * (sqrt(5.0) - 1.0)) * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0);
double t_1 = (2.0 + (sin(y) * (((sin(x) - (0.0625 * sin(y))) * sqrt(2.0)) * (cos(x) - cos(y))))) / t_0;
double tmp;
if (y <= -0.046) {
tmp = t_1;
} else if (y <= 0.034) {
tmp = (2.0 + ((sin(y) - (0.0625 * sin(x))) * (sin(x) * (sqrt(2.0) * (cos(x) - 1.0))))) / t_0;
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 3.0d0 + ((((0.5d0 * (sqrt(5.0d0) - 1.0d0)) * cos(x)) - (((sqrt(5.0d0) - 3.0d0) * 0.5d0) * cos(y))) * 3.0d0)
t_1 = (2.0d0 + (sin(y) * (((sin(x) - (0.0625d0 * sin(y))) * sqrt(2.0d0)) * (cos(x) - cos(y))))) / t_0
if (y <= (-0.046d0)) then
tmp = t_1
else if (y <= 0.034d0) then
tmp = (2.0d0 + ((sin(y) - (0.0625d0 * sin(x))) * (sin(x) * (sqrt(2.0d0) * (cos(x) - 1.0d0))))) / t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 3.0 + ((((0.5 * (Math.sqrt(5.0) - 1.0)) * Math.cos(x)) - (((Math.sqrt(5.0) - 3.0) * 0.5) * Math.cos(y))) * 3.0);
double t_1 = (2.0 + (Math.sin(y) * (((Math.sin(x) - (0.0625 * Math.sin(y))) * Math.sqrt(2.0)) * (Math.cos(x) - Math.cos(y))))) / t_0;
double tmp;
if (y <= -0.046) {
tmp = t_1;
} else if (y <= 0.034) {
tmp = (2.0 + ((Math.sin(y) - (0.0625 * Math.sin(x))) * (Math.sin(x) * (Math.sqrt(2.0) * (Math.cos(x) - 1.0))))) / t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = 3.0 + ((((0.5 * (math.sqrt(5.0) - 1.0)) * math.cos(x)) - (((math.sqrt(5.0) - 3.0) * 0.5) * math.cos(y))) * 3.0) t_1 = (2.0 + (math.sin(y) * (((math.sin(x) - (0.0625 * math.sin(y))) * math.sqrt(2.0)) * (math.cos(x) - math.cos(y))))) / t_0 tmp = 0 if y <= -0.046: tmp = t_1 elif y <= 0.034: tmp = (2.0 + ((math.sin(y) - (0.0625 * math.sin(x))) * (math.sin(x) * (math.sqrt(2.0) * (math.cos(x) - 1.0))))) / t_0 else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(3.0 + Float64(Float64(Float64(Float64(0.5 * Float64(sqrt(5.0) - 1.0)) * cos(x)) - Float64(Float64(Float64(sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0)) t_1 = Float64(Float64(2.0 + Float64(sin(y) * Float64(Float64(Float64(sin(x) - Float64(0.0625 * sin(y))) * sqrt(2.0)) * Float64(cos(x) - cos(y))))) / t_0) tmp = 0.0 if (y <= -0.046) tmp = t_1; elseif (y <= 0.034) tmp = Float64(Float64(2.0 + Float64(Float64(sin(y) - Float64(0.0625 * sin(x))) * Float64(sin(x) * Float64(sqrt(2.0) * Float64(cos(x) - 1.0))))) / t_0); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = 3.0 + ((((0.5 * (sqrt(5.0) - 1.0)) * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0); t_1 = (2.0 + (sin(y) * (((sin(x) - (0.0625 * sin(y))) * sqrt(2.0)) * (cos(x) - cos(y))))) / t_0; tmp = 0.0; if (y <= -0.046) tmp = t_1; elseif (y <= 0.034) tmp = (2.0 + ((sin(y) - (0.0625 * sin(x))) * (sin(x) * (sqrt(2.0) * (cos(x) - 1.0))))) / t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(3.0 + N[(N[(N[(N[(0.5 * N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 + N[(N[Sin[y], $MachinePrecision] * N[(N[(N[(N[Sin[x], $MachinePrecision] - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]}, If[LessEqual[y, -0.046], t$95$1, If[LessEqual[y, 0.034], N[(N[(2.0 + N[(N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := 3 + \left(\left(0.5 \cdot \left(\sqrt{5} - 1\right)\right) \cdot \cos x - \left(\left(\sqrt{5} - 3\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3\\
t_1 := \frac{2 + \sin y \cdot \left(\left(\left(\sin x - 0.0625 \cdot \sin y\right) \cdot \sqrt{2}\right) \cdot \left(\cos x - \cos y\right)\right)}{t\_0}\\
\mathbf{if}\;y \leq -0.046:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 0.034:\\
\;\;\;\;\frac{2 + \left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x \cdot \left(\sqrt{2} \cdot \left(\cos x - 1\right)\right)\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -0.045999999999999999 or 0.034000000000000002 < y Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in x around 0
lower-sin.f6464.3%
Applied rewrites64.3%
if -0.045999999999999999 < y < 0.034000000000000002Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6461.7%
Applied rewrites61.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (cos x) (cos y))) (t_1 (- (sqrt 5.0) 1.0)))
(if (<= y -0.046)
(/
(+
2.0
(* (* (* (sqrt 2.0) (- (sin x) (/ (sin y) 16.0))) (sin y)) t_0))
(*
3.0
(-
(+ (* (* 0.5 (- 3.0 2.23606797749979)) (cos y)) 1.0)
(* (* (- 1.0 2.23606797749979) 0.5) (cos x)))))
(if (<= y 0.034)
(/
(+
2.0
(*
(- (sin y) (* 0.0625 (sin x)))
(* (sin x) (* (sqrt 2.0) (- (cos x) 1.0)))))
(+
3.0
(*
(-
(* (* 0.5 t_1) (cos x))
(* (* (- (sqrt 5.0) 3.0) 0.5) (cos y)))
3.0)))
(*
(*
(-
(*
(* (* (sin y) (sqrt 2.0)) (- (sin x) (* 0.0625 (sin y))))
t_0)
-2.0)
0.3333333333333333)
(/
1.0
(+
1.0
(*
0.5
(+ (* (cos x) t_1) (* (- 3.0 (sqrt 5.0)) (cos y)))))))))))double code(double x, double y) {
double t_0 = cos(x) - cos(y);
double t_1 = sqrt(5.0) - 1.0;
double tmp;
if (y <= -0.046) {
tmp = (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * sin(y)) * t_0)) / (3.0 * ((((0.5 * (3.0 - 2.23606797749979)) * cos(y)) + 1.0) - (((1.0 - 2.23606797749979) * 0.5) * cos(x))));
} else if (y <= 0.034) {
tmp = (2.0 + ((sin(y) - (0.0625 * sin(x))) * (sin(x) * (sqrt(2.0) * (cos(x) - 1.0))))) / (3.0 + ((((0.5 * t_1) * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0));
} else {
tmp = (((((sin(y) * sqrt(2.0)) * (sin(x) - (0.0625 * sin(y)))) * t_0) - -2.0) * 0.3333333333333333) * (1.0 / (1.0 + (0.5 * ((cos(x) * t_1) + ((3.0 - sqrt(5.0)) * cos(y))))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(x) - cos(y)
t_1 = sqrt(5.0d0) - 1.0d0
if (y <= (-0.046d0)) then
tmp = (2.0d0 + (((sqrt(2.0d0) * (sin(x) - (sin(y) / 16.0d0))) * sin(y)) * t_0)) / (3.0d0 * ((((0.5d0 * (3.0d0 - 2.23606797749979d0)) * cos(y)) + 1.0d0) - (((1.0d0 - 2.23606797749979d0) * 0.5d0) * cos(x))))
else if (y <= 0.034d0) then
tmp = (2.0d0 + ((sin(y) - (0.0625d0 * sin(x))) * (sin(x) * (sqrt(2.0d0) * (cos(x) - 1.0d0))))) / (3.0d0 + ((((0.5d0 * t_1) * cos(x)) - (((sqrt(5.0d0) - 3.0d0) * 0.5d0) * cos(y))) * 3.0d0))
else
tmp = (((((sin(y) * sqrt(2.0d0)) * (sin(x) - (0.0625d0 * sin(y)))) * t_0) - (-2.0d0)) * 0.3333333333333333d0) * (1.0d0 / (1.0d0 + (0.5d0 * ((cos(x) * t_1) + ((3.0d0 - sqrt(5.0d0)) * cos(y))))))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.cos(x) - Math.cos(y);
double t_1 = Math.sqrt(5.0) - 1.0;
double tmp;
if (y <= -0.046) {
tmp = (2.0 + (((Math.sqrt(2.0) * (Math.sin(x) - (Math.sin(y) / 16.0))) * Math.sin(y)) * t_0)) / (3.0 * ((((0.5 * (3.0 - 2.23606797749979)) * Math.cos(y)) + 1.0) - (((1.0 - 2.23606797749979) * 0.5) * Math.cos(x))));
} else if (y <= 0.034) {
tmp = (2.0 + ((Math.sin(y) - (0.0625 * Math.sin(x))) * (Math.sin(x) * (Math.sqrt(2.0) * (Math.cos(x) - 1.0))))) / (3.0 + ((((0.5 * t_1) * Math.cos(x)) - (((Math.sqrt(5.0) - 3.0) * 0.5) * Math.cos(y))) * 3.0));
} else {
tmp = (((((Math.sin(y) * Math.sqrt(2.0)) * (Math.sin(x) - (0.0625 * Math.sin(y)))) * t_0) - -2.0) * 0.3333333333333333) * (1.0 / (1.0 + (0.5 * ((Math.cos(x) * t_1) + ((3.0 - Math.sqrt(5.0)) * Math.cos(y))))));
}
return tmp;
}
def code(x, y): t_0 = math.cos(x) - math.cos(y) t_1 = math.sqrt(5.0) - 1.0 tmp = 0 if y <= -0.046: tmp = (2.0 + (((math.sqrt(2.0) * (math.sin(x) - (math.sin(y) / 16.0))) * math.sin(y)) * t_0)) / (3.0 * ((((0.5 * (3.0 - 2.23606797749979)) * math.cos(y)) + 1.0) - (((1.0 - 2.23606797749979) * 0.5) * math.cos(x)))) elif y <= 0.034: tmp = (2.0 + ((math.sin(y) - (0.0625 * math.sin(x))) * (math.sin(x) * (math.sqrt(2.0) * (math.cos(x) - 1.0))))) / (3.0 + ((((0.5 * t_1) * math.cos(x)) - (((math.sqrt(5.0) - 3.0) * 0.5) * math.cos(y))) * 3.0)) else: tmp = (((((math.sin(y) * math.sqrt(2.0)) * (math.sin(x) - (0.0625 * math.sin(y)))) * t_0) - -2.0) * 0.3333333333333333) * (1.0 / (1.0 + (0.5 * ((math.cos(x) * t_1) + ((3.0 - math.sqrt(5.0)) * math.cos(y)))))) return tmp
function code(x, y) t_0 = Float64(cos(x) - cos(y)) t_1 = Float64(sqrt(5.0) - 1.0) tmp = 0.0 if (y <= -0.046) tmp = Float64(Float64(2.0 + Float64(Float64(Float64(sqrt(2.0) * Float64(sin(x) - Float64(sin(y) / 16.0))) * sin(y)) * t_0)) / Float64(3.0 * Float64(Float64(Float64(Float64(0.5 * Float64(3.0 - 2.23606797749979)) * cos(y)) + 1.0) - Float64(Float64(Float64(1.0 - 2.23606797749979) * 0.5) * cos(x))))); elseif (y <= 0.034) tmp = Float64(Float64(2.0 + Float64(Float64(sin(y) - Float64(0.0625 * sin(x))) * Float64(sin(x) * Float64(sqrt(2.0) * Float64(cos(x) - 1.0))))) / Float64(3.0 + Float64(Float64(Float64(Float64(0.5 * t_1) * cos(x)) - Float64(Float64(Float64(sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0))); else tmp = Float64(Float64(Float64(Float64(Float64(Float64(sin(y) * sqrt(2.0)) * Float64(sin(x) - Float64(0.0625 * sin(y)))) * t_0) - -2.0) * 0.3333333333333333) * Float64(1.0 / Float64(1.0 + Float64(0.5 * Float64(Float64(cos(x) * t_1) + Float64(Float64(3.0 - sqrt(5.0)) * cos(y))))))); end return tmp end
function tmp_2 = code(x, y) t_0 = cos(x) - cos(y); t_1 = sqrt(5.0) - 1.0; tmp = 0.0; if (y <= -0.046) tmp = (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * sin(y)) * t_0)) / (3.0 * ((((0.5 * (3.0 - 2.23606797749979)) * cos(y)) + 1.0) - (((1.0 - 2.23606797749979) * 0.5) * cos(x)))); elseif (y <= 0.034) tmp = (2.0 + ((sin(y) - (0.0625 * sin(x))) * (sin(x) * (sqrt(2.0) * (cos(x) - 1.0))))) / (3.0 + ((((0.5 * t_1) * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0)); else tmp = (((((sin(y) * sqrt(2.0)) * (sin(x) - (0.0625 * sin(y)))) * t_0) - -2.0) * 0.3333333333333333) * (1.0 / (1.0 + (0.5 * ((cos(x) * t_1) + ((3.0 - sqrt(5.0)) * cos(y)))))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[y, -0.046], N[(N[(2.0 + N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(3.0 * N[(N[(N[(N[(0.5 * N[(3.0 - 2.23606797749979), $MachinePrecision]), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(N[(1.0 - 2.23606797749979), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.034], N[(N[(2.0 + N[(N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(N[(N[(0.5 * t$95$1), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[Sin[y], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] - -2.0), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] * N[(1.0 / N[(1.0 + N[(0.5 * N[(N[(N[Cos[x], $MachinePrecision] * t$95$1), $MachinePrecision] + N[(N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \cos x - \cos y\\
t_1 := \sqrt{5} - 1\\
\mathbf{if}\;y \leq -0.046:\\
\;\;\;\;\frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \sin y\right) \cdot t\_0}{3 \cdot \left(\left(\left(0.5 \cdot \left(3 - 2.23606797749979\right)\right) \cdot \cos y + 1\right) - \left(\left(1 - 2.23606797749979\right) \cdot 0.5\right) \cdot \cos x\right)}\\
\mathbf{elif}\;y \leq 0.034:\\
\;\;\;\;\frac{2 + \left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x \cdot \left(\sqrt{2} \cdot \left(\cos x - 1\right)\right)\right)}{3 + \left(\left(0.5 \cdot t\_1\right) \cdot \cos x - \left(\left(\sqrt{5} - 3\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\left(\sin y \cdot \sqrt{2}\right) \cdot \left(\sin x - 0.0625 \cdot \sin y\right)\right) \cdot t\_0 - -2\right) \cdot 0.3333333333333333\right) \cdot \frac{1}{1 + 0.5 \cdot \left(\cos x \cdot t\_1 + \left(3 - \sqrt{5}\right) \cdot \cos y\right)}\\
\end{array}
if y < -0.045999999999999999Initial program 99.3%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
associate-+r-N/A
lower--.f64N/A
lower-+.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
Taylor expanded in x around 0
lower-sin.f6464.3%
Applied rewrites64.3%
Evaluated real constant64.3%
Evaluated real constant64.3%
if -0.045999999999999999 < y < 0.034000000000000002Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6461.7%
Applied rewrites61.7%
if 0.034000000000000002 < y Initial program 99.3%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
associate-+r-N/A
lower--.f64N/A
lower-+.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
Taylor expanded in x around 0
lower-sin.f6464.3%
Applied rewrites64.3%
Applied rewrites64.2%
(FPCore (x y)
:precision binary64
(let* ((t_0
(/
(+
2.0
(*
(* (* (sqrt 2.0) (- (sin x) (/ (sin y) 16.0))) (sin y))
(- (cos x) (cos y))))
(*
3.0
(-
(+ (* (* 0.5 (- 3.0 2.23606797749979)) (cos y)) 1.0)
(* (* (- 1.0 2.23606797749979) 0.5) (cos x)))))))
(if (<= y -0.046)
t_0
(if (<= y 0.034)
(/
(+
2.0
(*
(- (sin y) (* 0.0625 (sin x)))
(* (sin x) (* (sqrt 2.0) (- (cos x) 1.0)))))
(+
3.0
(*
(-
(* (* 0.5 (- (sqrt 5.0) 1.0)) (cos x))
(* (* (- (sqrt 5.0) 3.0) 0.5) (cos y)))
3.0)))
t_0))))double code(double x, double y) {
double t_0 = (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * sin(y)) * (cos(x) - cos(y)))) / (3.0 * ((((0.5 * (3.0 - 2.23606797749979)) * cos(y)) + 1.0) - (((1.0 - 2.23606797749979) * 0.5) * cos(x))));
double tmp;
if (y <= -0.046) {
tmp = t_0;
} else if (y <= 0.034) {
tmp = (2.0 + ((sin(y) - (0.0625 * sin(x))) * (sin(x) * (sqrt(2.0) * (cos(x) - 1.0))))) / (3.0 + ((((0.5 * (sqrt(5.0) - 1.0)) * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = (2.0d0 + (((sqrt(2.0d0) * (sin(x) - (sin(y) / 16.0d0))) * sin(y)) * (cos(x) - cos(y)))) / (3.0d0 * ((((0.5d0 * (3.0d0 - 2.23606797749979d0)) * cos(y)) + 1.0d0) - (((1.0d0 - 2.23606797749979d0) * 0.5d0) * cos(x))))
if (y <= (-0.046d0)) then
tmp = t_0
else if (y <= 0.034d0) then
tmp = (2.0d0 + ((sin(y) - (0.0625d0 * sin(x))) * (sin(x) * (sqrt(2.0d0) * (cos(x) - 1.0d0))))) / (3.0d0 + ((((0.5d0 * (sqrt(5.0d0) - 1.0d0)) * cos(x)) - (((sqrt(5.0d0) - 3.0d0) * 0.5d0) * cos(y))) * 3.0d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (2.0 + (((Math.sqrt(2.0) * (Math.sin(x) - (Math.sin(y) / 16.0))) * Math.sin(y)) * (Math.cos(x) - Math.cos(y)))) / (3.0 * ((((0.5 * (3.0 - 2.23606797749979)) * Math.cos(y)) + 1.0) - (((1.0 - 2.23606797749979) * 0.5) * Math.cos(x))));
double tmp;
if (y <= -0.046) {
tmp = t_0;
} else if (y <= 0.034) {
tmp = (2.0 + ((Math.sin(y) - (0.0625 * Math.sin(x))) * (Math.sin(x) * (Math.sqrt(2.0) * (Math.cos(x) - 1.0))))) / (3.0 + ((((0.5 * (Math.sqrt(5.0) - 1.0)) * Math.cos(x)) - (((Math.sqrt(5.0) - 3.0) * 0.5) * Math.cos(y))) * 3.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (2.0 + (((math.sqrt(2.0) * (math.sin(x) - (math.sin(y) / 16.0))) * math.sin(y)) * (math.cos(x) - math.cos(y)))) / (3.0 * ((((0.5 * (3.0 - 2.23606797749979)) * math.cos(y)) + 1.0) - (((1.0 - 2.23606797749979) * 0.5) * math.cos(x)))) tmp = 0 if y <= -0.046: tmp = t_0 elif y <= 0.034: tmp = (2.0 + ((math.sin(y) - (0.0625 * math.sin(x))) * (math.sin(x) * (math.sqrt(2.0) * (math.cos(x) - 1.0))))) / (3.0 + ((((0.5 * (math.sqrt(5.0) - 1.0)) * math.cos(x)) - (((math.sqrt(5.0) - 3.0) * 0.5) * math.cos(y))) * 3.0)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(2.0 + Float64(Float64(Float64(sqrt(2.0) * Float64(sin(x) - Float64(sin(y) / 16.0))) * sin(y)) * Float64(cos(x) - cos(y)))) / Float64(3.0 * Float64(Float64(Float64(Float64(0.5 * Float64(3.0 - 2.23606797749979)) * cos(y)) + 1.0) - Float64(Float64(Float64(1.0 - 2.23606797749979) * 0.5) * cos(x))))) tmp = 0.0 if (y <= -0.046) tmp = t_0; elseif (y <= 0.034) tmp = Float64(Float64(2.0 + Float64(Float64(sin(y) - Float64(0.0625 * sin(x))) * Float64(sin(x) * Float64(sqrt(2.0) * Float64(cos(x) - 1.0))))) / Float64(3.0 + Float64(Float64(Float64(Float64(0.5 * Float64(sqrt(5.0) - 1.0)) * cos(x)) - Float64(Float64(Float64(sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * sin(y)) * (cos(x) - cos(y)))) / (3.0 * ((((0.5 * (3.0 - 2.23606797749979)) * cos(y)) + 1.0) - (((1.0 - 2.23606797749979) * 0.5) * cos(x)))); tmp = 0.0; if (y <= -0.046) tmp = t_0; elseif (y <= 0.034) tmp = (2.0 + ((sin(y) - (0.0625 * sin(x))) * (sin(x) * (sqrt(2.0) * (cos(x) - 1.0))))) / (3.0 + ((((0.5 * (sqrt(5.0) - 1.0)) * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(2.0 + N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * N[(N[(N[(N[(0.5 * N[(3.0 - 2.23606797749979), $MachinePrecision]), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(N[(1.0 - 2.23606797749979), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.046], t$95$0, If[LessEqual[y, 0.034], N[(N[(2.0 + N[(N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(N[(N[(0.5 * N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \sin y\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(\left(\left(0.5 \cdot \left(3 - 2.23606797749979\right)\right) \cdot \cos y + 1\right) - \left(\left(1 - 2.23606797749979\right) \cdot 0.5\right) \cdot \cos x\right)}\\
\mathbf{if}\;y \leq -0.046:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 0.034:\\
\;\;\;\;\frac{2 + \left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x \cdot \left(\sqrt{2} \cdot \left(\cos x - 1\right)\right)\right)}{3 + \left(\left(0.5 \cdot \left(\sqrt{5} - 1\right)\right) \cdot \cos x - \left(\left(\sqrt{5} - 3\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -0.045999999999999999 or 0.034000000000000002 < y Initial program 99.3%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
associate-+r-N/A
lower--.f64N/A
lower-+.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
Taylor expanded in x around 0
lower-sin.f6464.3%
Applied rewrites64.3%
Evaluated real constant64.3%
Evaluated real constant64.3%
if -0.045999999999999999 < y < 0.034000000000000002Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6461.7%
Applied rewrites61.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* 0.5 (- (sqrt 5.0) 1.0)))
(t_1
(/
(+
2.0
(*
(- (sin y) (* 0.0625 (sin x)))
(* (sin x) (* (sqrt 2.0) (- (cos x) 1.0)))))
(+
3.0
(*
(- (* t_0 (cos x)) (* (* (- (sqrt 5.0) 3.0) 0.5) (cos y)))
3.0)))))
(if (<= x -2.3e+27)
t_1
(if (<= x 1.45e-5)
(/
(+
2.0
(*
(*
(* (sqrt 2.0) (- (sin x) (/ (sin y) 16.0)))
(- (sin y) (/ (sin x) 16.0)))
(- 1.0 (cos y))))
(+
3.0
(*
(-
(* t_0 1.0)
(*
(* (* (- 1.0 (/ 3.0 (sqrt 5.0))) (sqrt 5.0)) 0.5)
(cos y)))
3.0)))
t_1))))double code(double x, double y) {
double t_0 = 0.5 * (sqrt(5.0) - 1.0);
double t_1 = (2.0 + ((sin(y) - (0.0625 * sin(x))) * (sin(x) * (sqrt(2.0) * (cos(x) - 1.0))))) / (3.0 + (((t_0 * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0));
double tmp;
if (x <= -2.3e+27) {
tmp = t_1;
} else if (x <= 1.45e-5) {
tmp = (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * (sin(y) - (sin(x) / 16.0))) * (1.0 - cos(y)))) / (3.0 + (((t_0 * 1.0) - ((((1.0 - (3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * (sqrt(5.0d0) - 1.0d0)
t_1 = (2.0d0 + ((sin(y) - (0.0625d0 * sin(x))) * (sin(x) * (sqrt(2.0d0) * (cos(x) - 1.0d0))))) / (3.0d0 + (((t_0 * cos(x)) - (((sqrt(5.0d0) - 3.0d0) * 0.5d0) * cos(y))) * 3.0d0))
if (x <= (-2.3d+27)) then
tmp = t_1
else if (x <= 1.45d-5) then
tmp = (2.0d0 + (((sqrt(2.0d0) * (sin(x) - (sin(y) / 16.0d0))) * (sin(y) - (sin(x) / 16.0d0))) * (1.0d0 - cos(y)))) / (3.0d0 + (((t_0 * 1.0d0) - ((((1.0d0 - (3.0d0 / sqrt(5.0d0))) * sqrt(5.0d0)) * 0.5d0) * cos(y))) * 3.0d0))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 0.5 * (Math.sqrt(5.0) - 1.0);
double t_1 = (2.0 + ((Math.sin(y) - (0.0625 * Math.sin(x))) * (Math.sin(x) * (Math.sqrt(2.0) * (Math.cos(x) - 1.0))))) / (3.0 + (((t_0 * Math.cos(x)) - (((Math.sqrt(5.0) - 3.0) * 0.5) * Math.cos(y))) * 3.0));
double tmp;
if (x <= -2.3e+27) {
tmp = t_1;
} else if (x <= 1.45e-5) {
tmp = (2.0 + (((Math.sqrt(2.0) * (Math.sin(x) - (Math.sin(y) / 16.0))) * (Math.sin(y) - (Math.sin(x) / 16.0))) * (1.0 - Math.cos(y)))) / (3.0 + (((t_0 * 1.0) - ((((1.0 - (3.0 / Math.sqrt(5.0))) * Math.sqrt(5.0)) * 0.5) * Math.cos(y))) * 3.0));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = 0.5 * (math.sqrt(5.0) - 1.0) t_1 = (2.0 + ((math.sin(y) - (0.0625 * math.sin(x))) * (math.sin(x) * (math.sqrt(2.0) * (math.cos(x) - 1.0))))) / (3.0 + (((t_0 * math.cos(x)) - (((math.sqrt(5.0) - 3.0) * 0.5) * math.cos(y))) * 3.0)) tmp = 0 if x <= -2.3e+27: tmp = t_1 elif x <= 1.45e-5: tmp = (2.0 + (((math.sqrt(2.0) * (math.sin(x) - (math.sin(y) / 16.0))) * (math.sin(y) - (math.sin(x) / 16.0))) * (1.0 - math.cos(y)))) / (3.0 + (((t_0 * 1.0) - ((((1.0 - (3.0 / math.sqrt(5.0))) * math.sqrt(5.0)) * 0.5) * math.cos(y))) * 3.0)) else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(0.5 * Float64(sqrt(5.0) - 1.0)) t_1 = Float64(Float64(2.0 + Float64(Float64(sin(y) - Float64(0.0625 * sin(x))) * Float64(sin(x) * Float64(sqrt(2.0) * Float64(cos(x) - 1.0))))) / Float64(3.0 + Float64(Float64(Float64(t_0 * cos(x)) - Float64(Float64(Float64(sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0))) tmp = 0.0 if (x <= -2.3e+27) tmp = t_1; elseif (x <= 1.45e-5) tmp = Float64(Float64(2.0 + Float64(Float64(Float64(sqrt(2.0) * Float64(sin(x) - Float64(sin(y) / 16.0))) * Float64(sin(y) - Float64(sin(x) / 16.0))) * Float64(1.0 - cos(y)))) / Float64(3.0 + Float64(Float64(Float64(t_0 * 1.0) - Float64(Float64(Float64(Float64(1.0 - Float64(3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = 0.5 * (sqrt(5.0) - 1.0); t_1 = (2.0 + ((sin(y) - (0.0625 * sin(x))) * (sin(x) * (sqrt(2.0) * (cos(x) - 1.0))))) / (3.0 + (((t_0 * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0)); tmp = 0.0; if (x <= -2.3e+27) tmp = t_1; elseif (x <= 1.45e-5) tmp = (2.0 + (((sqrt(2.0) * (sin(x) - (sin(y) / 16.0))) * (sin(y) - (sin(x) / 16.0))) * (1.0 - cos(y)))) / (3.0 + (((t_0 * 1.0) - ((((1.0 - (3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(0.5 * N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 + N[(N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(N[(t$95$0 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.3e+27], t$95$1, If[LessEqual[x, 1.45e-5], N[(N[(2.0 + N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] - N[(N[Sin[y], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] - N[(N[Sin[x], $MachinePrecision] / 16.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(N[(t$95$0 * 1.0), $MachinePrecision] - N[(N[(N[(N[(1.0 - N[(3.0 / N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := 0.5 \cdot \left(\sqrt{5} - 1\right)\\
t_1 := \frac{2 + \left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x \cdot \left(\sqrt{2} \cdot \left(\cos x - 1\right)\right)\right)}{3 + \left(t\_0 \cdot \cos x - \left(\left(\sqrt{5} - 3\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3}\\
\mathbf{if}\;x \leq -2.3 \cdot 10^{+27}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{2 + \left(\left(\sqrt{2} \cdot \left(\sin x - \frac{\sin y}{16}\right)\right) \cdot \left(\sin y - \frac{\sin x}{16}\right)\right) \cdot \left(1 - \cos y\right)}{3 + \left(t\_0 \cdot 1 - \left(\left(\left(1 - \frac{3}{\sqrt{5}}\right) \cdot \sqrt{5}\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if x < -2.3000000000000001e27 or 1.45e-5 < x Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6461.7%
Applied rewrites61.7%
if -2.3000000000000001e27 < x < 1.45e-5Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f6499.3%
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites62.8%
Taylor expanded in x around 0
Applied rewrites60.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (* (- (sqrt 5.0) 3.0) 0.5) (cos y)))
(t_1 (- (sin y) (* 0.0625 (sin x))))
(t_2 (* 0.5 (- (sqrt 5.0) 1.0)))
(t_3
(/
(+ 2.0 (* t_1 (* (sin x) (* (sqrt 2.0) (- (cos x) 1.0)))))
(+ 3.0 (* (- (* t_2 (cos x)) t_0) 3.0)))))
(if (<= x -2.3e+27)
t_3
(if (<= x 1.45e-5)
(/
(+
2.0
(*
t_1
(*
(* (- (sin x) (* 0.0625 (sin y))) (sqrt 2.0))
(- 1.0 (cos y)))))
(+ 3.0 (* (- (* t_2 1.0) t_0) 3.0)))
t_3))))double code(double x, double y) {
double t_0 = ((sqrt(5.0) - 3.0) * 0.5) * cos(y);
double t_1 = sin(y) - (0.0625 * sin(x));
double t_2 = 0.5 * (sqrt(5.0) - 1.0);
double t_3 = (2.0 + (t_1 * (sin(x) * (sqrt(2.0) * (cos(x) - 1.0))))) / (3.0 + (((t_2 * cos(x)) - t_0) * 3.0));
double tmp;
if (x <= -2.3e+27) {
tmp = t_3;
} else if (x <= 1.45e-5) {
tmp = (2.0 + (t_1 * (((sin(x) - (0.0625 * sin(y))) * sqrt(2.0)) * (1.0 - cos(y))))) / (3.0 + (((t_2 * 1.0) - t_0) * 3.0));
} else {
tmp = t_3;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = ((sqrt(5.0d0) - 3.0d0) * 0.5d0) * cos(y)
t_1 = sin(y) - (0.0625d0 * sin(x))
t_2 = 0.5d0 * (sqrt(5.0d0) - 1.0d0)
t_3 = (2.0d0 + (t_1 * (sin(x) * (sqrt(2.0d0) * (cos(x) - 1.0d0))))) / (3.0d0 + (((t_2 * cos(x)) - t_0) * 3.0d0))
if (x <= (-2.3d+27)) then
tmp = t_3
else if (x <= 1.45d-5) then
tmp = (2.0d0 + (t_1 * (((sin(x) - (0.0625d0 * sin(y))) * sqrt(2.0d0)) * (1.0d0 - cos(y))))) / (3.0d0 + (((t_2 * 1.0d0) - t_0) * 3.0d0))
else
tmp = t_3
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = ((Math.sqrt(5.0) - 3.0) * 0.5) * Math.cos(y);
double t_1 = Math.sin(y) - (0.0625 * Math.sin(x));
double t_2 = 0.5 * (Math.sqrt(5.0) - 1.0);
double t_3 = (2.0 + (t_1 * (Math.sin(x) * (Math.sqrt(2.0) * (Math.cos(x) - 1.0))))) / (3.0 + (((t_2 * Math.cos(x)) - t_0) * 3.0));
double tmp;
if (x <= -2.3e+27) {
tmp = t_3;
} else if (x <= 1.45e-5) {
tmp = (2.0 + (t_1 * (((Math.sin(x) - (0.0625 * Math.sin(y))) * Math.sqrt(2.0)) * (1.0 - Math.cos(y))))) / (3.0 + (((t_2 * 1.0) - t_0) * 3.0));
} else {
tmp = t_3;
}
return tmp;
}
def code(x, y): t_0 = ((math.sqrt(5.0) - 3.0) * 0.5) * math.cos(y) t_1 = math.sin(y) - (0.0625 * math.sin(x)) t_2 = 0.5 * (math.sqrt(5.0) - 1.0) t_3 = (2.0 + (t_1 * (math.sin(x) * (math.sqrt(2.0) * (math.cos(x) - 1.0))))) / (3.0 + (((t_2 * math.cos(x)) - t_0) * 3.0)) tmp = 0 if x <= -2.3e+27: tmp = t_3 elif x <= 1.45e-5: tmp = (2.0 + (t_1 * (((math.sin(x) - (0.0625 * math.sin(y))) * math.sqrt(2.0)) * (1.0 - math.cos(y))))) / (3.0 + (((t_2 * 1.0) - t_0) * 3.0)) else: tmp = t_3 return tmp
function code(x, y) t_0 = Float64(Float64(Float64(sqrt(5.0) - 3.0) * 0.5) * cos(y)) t_1 = Float64(sin(y) - Float64(0.0625 * sin(x))) t_2 = Float64(0.5 * Float64(sqrt(5.0) - 1.0)) t_3 = Float64(Float64(2.0 + Float64(t_1 * Float64(sin(x) * Float64(sqrt(2.0) * Float64(cos(x) - 1.0))))) / Float64(3.0 + Float64(Float64(Float64(t_2 * cos(x)) - t_0) * 3.0))) tmp = 0.0 if (x <= -2.3e+27) tmp = t_3; elseif (x <= 1.45e-5) tmp = Float64(Float64(2.0 + Float64(t_1 * Float64(Float64(Float64(sin(x) - Float64(0.0625 * sin(y))) * sqrt(2.0)) * Float64(1.0 - cos(y))))) / Float64(3.0 + Float64(Float64(Float64(t_2 * 1.0) - t_0) * 3.0))); else tmp = t_3; end return tmp end
function tmp_2 = code(x, y) t_0 = ((sqrt(5.0) - 3.0) * 0.5) * cos(y); t_1 = sin(y) - (0.0625 * sin(x)); t_2 = 0.5 * (sqrt(5.0) - 1.0); t_3 = (2.0 + (t_1 * (sin(x) * (sqrt(2.0) * (cos(x) - 1.0))))) / (3.0 + (((t_2 * cos(x)) - t_0) * 3.0)); tmp = 0.0; if (x <= -2.3e+27) tmp = t_3; elseif (x <= 1.45e-5) tmp = (2.0 + (t_1 * (((sin(x) - (0.0625 * sin(y))) * sqrt(2.0)) * (1.0 - cos(y))))) / (3.0 + (((t_2 * 1.0) - t_0) * 3.0)); else tmp = t_3; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(0.5 * N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(2.0 + N[(t$95$1 * N[(N[Sin[x], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(N[(t$95$2 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.3e+27], t$95$3, If[LessEqual[x, 1.45e-5], N[(N[(2.0 + N[(t$95$1 * N[(N[(N[(N[Sin[x], $MachinePrecision] - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(N[(t$95$2 * 1.0), $MachinePrecision] - t$95$0), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
t_0 := \left(\left(\sqrt{5} - 3\right) \cdot 0.5\right) \cdot \cos y\\
t_1 := \sin y - 0.0625 \cdot \sin x\\
t_2 := 0.5 \cdot \left(\sqrt{5} - 1\right)\\
t_3 := \frac{2 + t\_1 \cdot \left(\sin x \cdot \left(\sqrt{2} \cdot \left(\cos x - 1\right)\right)\right)}{3 + \left(t\_2 \cdot \cos x - t\_0\right) \cdot 3}\\
\mathbf{if}\;x \leq -2.3 \cdot 10^{+27}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{2 + t\_1 \cdot \left(\left(\left(\sin x - 0.0625 \cdot \sin y\right) \cdot \sqrt{2}\right) \cdot \left(1 - \cos y\right)\right)}{3 + \left(t\_2 \cdot 1 - t\_0\right) \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
if x < -2.3000000000000001e27 or 1.45e-5 < x Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6461.7%
Applied rewrites61.7%
if -2.3000000000000001e27 < x < 1.45e-5Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites62.7%
Taylor expanded in x around 0
Applied rewrites60.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* 0.5 (- (sqrt 5.0) 1.0)))
(t_1
(/
(+
2.0
(*
(- (sin y) (* 0.0625 (sin x)))
(* (sin x) (* (sqrt 2.0) (- (cos x) 1.0)))))
(+
3.0
(*
(- (* t_0 (cos x)) (* (* (- (sqrt 5.0) 3.0) 0.5) (cos y)))
3.0)))))
(if (<= x -3.5)
t_1
(if (<= x 1.45e-5)
(/
(+
2.0
(*
(*
(* (sqrt 2.0) (- x (* 0.0625 (sin y))))
(- (sin y) (* 0.0625 x)))
(- (cos x) (cos y))))
(* 3.0 (+ 1.0 (+ (* 0.5 (* (cos y) (- 3.0 (sqrt 5.0)))) t_0))))
t_1))))double code(double x, double y) {
double t_0 = 0.5 * (sqrt(5.0) - 1.0);
double t_1 = (2.0 + ((sin(y) - (0.0625 * sin(x))) * (sin(x) * (sqrt(2.0) * (cos(x) - 1.0))))) / (3.0 + (((t_0 * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0));
double tmp;
if (x <= -3.5) {
tmp = t_1;
} else if (x <= 1.45e-5) {
tmp = (2.0 + (((sqrt(2.0) * (x - (0.0625 * sin(y)))) * (sin(y) - (0.0625 * x))) * (cos(x) - cos(y)))) / (3.0 * (1.0 + ((0.5 * (cos(y) * (3.0 - sqrt(5.0)))) + t_0)));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * (sqrt(5.0d0) - 1.0d0)
t_1 = (2.0d0 + ((sin(y) - (0.0625d0 * sin(x))) * (sin(x) * (sqrt(2.0d0) * (cos(x) - 1.0d0))))) / (3.0d0 + (((t_0 * cos(x)) - (((sqrt(5.0d0) - 3.0d0) * 0.5d0) * cos(y))) * 3.0d0))
if (x <= (-3.5d0)) then
tmp = t_1
else if (x <= 1.45d-5) then
tmp = (2.0d0 + (((sqrt(2.0d0) * (x - (0.0625d0 * sin(y)))) * (sin(y) - (0.0625d0 * x))) * (cos(x) - cos(y)))) / (3.0d0 * (1.0d0 + ((0.5d0 * (cos(y) * (3.0d0 - sqrt(5.0d0)))) + t_0)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 0.5 * (Math.sqrt(5.0) - 1.0);
double t_1 = (2.0 + ((Math.sin(y) - (0.0625 * Math.sin(x))) * (Math.sin(x) * (Math.sqrt(2.0) * (Math.cos(x) - 1.0))))) / (3.0 + (((t_0 * Math.cos(x)) - (((Math.sqrt(5.0) - 3.0) * 0.5) * Math.cos(y))) * 3.0));
double tmp;
if (x <= -3.5) {
tmp = t_1;
} else if (x <= 1.45e-5) {
tmp = (2.0 + (((Math.sqrt(2.0) * (x - (0.0625 * Math.sin(y)))) * (Math.sin(y) - (0.0625 * x))) * (Math.cos(x) - Math.cos(y)))) / (3.0 * (1.0 + ((0.5 * (Math.cos(y) * (3.0 - Math.sqrt(5.0)))) + t_0)));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = 0.5 * (math.sqrt(5.0) - 1.0) t_1 = (2.0 + ((math.sin(y) - (0.0625 * math.sin(x))) * (math.sin(x) * (math.sqrt(2.0) * (math.cos(x) - 1.0))))) / (3.0 + (((t_0 * math.cos(x)) - (((math.sqrt(5.0) - 3.0) * 0.5) * math.cos(y))) * 3.0)) tmp = 0 if x <= -3.5: tmp = t_1 elif x <= 1.45e-5: tmp = (2.0 + (((math.sqrt(2.0) * (x - (0.0625 * math.sin(y)))) * (math.sin(y) - (0.0625 * x))) * (math.cos(x) - math.cos(y)))) / (3.0 * (1.0 + ((0.5 * (math.cos(y) * (3.0 - math.sqrt(5.0)))) + t_0))) else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(0.5 * Float64(sqrt(5.0) - 1.0)) t_1 = Float64(Float64(2.0 + Float64(Float64(sin(y) - Float64(0.0625 * sin(x))) * Float64(sin(x) * Float64(sqrt(2.0) * Float64(cos(x) - 1.0))))) / Float64(3.0 + Float64(Float64(Float64(t_0 * cos(x)) - Float64(Float64(Float64(sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0))) tmp = 0.0 if (x <= -3.5) tmp = t_1; elseif (x <= 1.45e-5) tmp = Float64(Float64(2.0 + Float64(Float64(Float64(sqrt(2.0) * Float64(x - Float64(0.0625 * sin(y)))) * Float64(sin(y) - Float64(0.0625 * x))) * Float64(cos(x) - cos(y)))) / Float64(3.0 * Float64(1.0 + Float64(Float64(0.5 * Float64(cos(y) * Float64(3.0 - sqrt(5.0)))) + t_0)))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = 0.5 * (sqrt(5.0) - 1.0); t_1 = (2.0 + ((sin(y) - (0.0625 * sin(x))) * (sin(x) * (sqrt(2.0) * (cos(x) - 1.0))))) / (3.0 + (((t_0 * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0)); tmp = 0.0; if (x <= -3.5) tmp = t_1; elseif (x <= 1.45e-5) tmp = (2.0 + (((sqrt(2.0) * (x - (0.0625 * sin(y)))) * (sin(y) - (0.0625 * x))) * (cos(x) - cos(y)))) / (3.0 * (1.0 + ((0.5 * (cos(y) * (3.0 - sqrt(5.0)))) + t_0))); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(0.5 * N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 + N[(N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[x], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(N[(t$95$0 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.5], t$95$1, If[LessEqual[x, 1.45e-5], N[(N[(2.0 + N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(x - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * N[(1.0 + N[(N[(0.5 * N[(N[Cos[y], $MachinePrecision] * N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := 0.5 \cdot \left(\sqrt{5} - 1\right)\\
t_1 := \frac{2 + \left(\sin y - 0.0625 \cdot \sin x\right) \cdot \left(\sin x \cdot \left(\sqrt{2} \cdot \left(\cos x - 1\right)\right)\right)}{3 + \left(t\_0 \cdot \cos x - \left(\left(\sqrt{5} - 3\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3}\\
\mathbf{if}\;x \leq -3.5:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{2 + \left(\left(\sqrt{2} \cdot \left(x - 0.0625 \cdot \sin y\right)\right) \cdot \left(\sin y - 0.0625 \cdot x\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(1 + \left(0.5 \cdot \left(\cos y \cdot \left(3 - \sqrt{5}\right)\right) + t\_0\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if x < -3.5 or 1.45e-5 < x Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6461.7%
Applied rewrites61.7%
if -3.5 < x < 1.45e-5Initial program 99.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f6460.1%
Applied rewrites60.1%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f64N/A
lower-sin.f6451.1%
Applied rewrites51.1%
Taylor expanded in x around 0
lower-*.f6451.1%
Applied rewrites51.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (cos x) (cos y)))
(t_1 (* 0.5 (- (sqrt 5.0) 1.0)))
(t_2 (- 3.0 (sqrt 5.0)))
(t_3 (pow (sin x) 2.0)))
(if (<= x -3.5)
(/
(+ 2.0 (* (* -0.0625 (* t_3 (sqrt 2.0))) t_0))
(*
3.0
(-
(+ (* (* 0.5 t_2) (cos y)) 1.0)
(* (* (- 1.0 (sqrt 5.0)) 0.5) (cos x)))))
(if (<= x 1.45e-5)
(/
(+
2.0
(*
(*
(* (sqrt 2.0) (- x (* 0.0625 (sin y))))
(- (sin y) (* 0.0625 x)))
t_0))
(* 3.0 (+ 1.0 (+ (* 0.5 (* (cos y) t_2)) t_1))))
(/
(+ 2.0 (* -0.0625 (* t_3 (* (sqrt 2.0) (- (cos x) 1.0)))))
(+
3.0
(*
(-
(* t_1 (cos x))
(*
(* (* (- 1.0 (/ 3.0 (sqrt 5.0))) (sqrt 5.0)) 0.5)
(cos y)))
3.0)))))))double code(double x, double y) {
double t_0 = cos(x) - cos(y);
double t_1 = 0.5 * (sqrt(5.0) - 1.0);
double t_2 = 3.0 - sqrt(5.0);
double t_3 = pow(sin(x), 2.0);
double tmp;
if (x <= -3.5) {
tmp = (2.0 + ((-0.0625 * (t_3 * sqrt(2.0))) * t_0)) / (3.0 * ((((0.5 * t_2) * cos(y)) + 1.0) - (((1.0 - sqrt(5.0)) * 0.5) * cos(x))));
} else if (x <= 1.45e-5) {
tmp = (2.0 + (((sqrt(2.0) * (x - (0.0625 * sin(y)))) * (sin(y) - (0.0625 * x))) * t_0)) / (3.0 * (1.0 + ((0.5 * (cos(y) * t_2)) + t_1)));
} else {
tmp = (2.0 + (-0.0625 * (t_3 * (sqrt(2.0) * (cos(x) - 1.0))))) / (3.0 + (((t_1 * cos(x)) - ((((1.0 - (3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(x) - cos(y)
t_1 = 0.5d0 * (sqrt(5.0d0) - 1.0d0)
t_2 = 3.0d0 - sqrt(5.0d0)
t_3 = sin(x) ** 2.0d0
if (x <= (-3.5d0)) then
tmp = (2.0d0 + (((-0.0625d0) * (t_3 * sqrt(2.0d0))) * t_0)) / (3.0d0 * ((((0.5d0 * t_2) * cos(y)) + 1.0d0) - (((1.0d0 - sqrt(5.0d0)) * 0.5d0) * cos(x))))
else if (x <= 1.45d-5) then
tmp = (2.0d0 + (((sqrt(2.0d0) * (x - (0.0625d0 * sin(y)))) * (sin(y) - (0.0625d0 * x))) * t_0)) / (3.0d0 * (1.0d0 + ((0.5d0 * (cos(y) * t_2)) + t_1)))
else
tmp = (2.0d0 + ((-0.0625d0) * (t_3 * (sqrt(2.0d0) * (cos(x) - 1.0d0))))) / (3.0d0 + (((t_1 * cos(x)) - ((((1.0d0 - (3.0d0 / sqrt(5.0d0))) * sqrt(5.0d0)) * 0.5d0) * cos(y))) * 3.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.cos(x) - Math.cos(y);
double t_1 = 0.5 * (Math.sqrt(5.0) - 1.0);
double t_2 = 3.0 - Math.sqrt(5.0);
double t_3 = Math.pow(Math.sin(x), 2.0);
double tmp;
if (x <= -3.5) {
tmp = (2.0 + ((-0.0625 * (t_3 * Math.sqrt(2.0))) * t_0)) / (3.0 * ((((0.5 * t_2) * Math.cos(y)) + 1.0) - (((1.0 - Math.sqrt(5.0)) * 0.5) * Math.cos(x))));
} else if (x <= 1.45e-5) {
tmp = (2.0 + (((Math.sqrt(2.0) * (x - (0.0625 * Math.sin(y)))) * (Math.sin(y) - (0.0625 * x))) * t_0)) / (3.0 * (1.0 + ((0.5 * (Math.cos(y) * t_2)) + t_1)));
} else {
tmp = (2.0 + (-0.0625 * (t_3 * (Math.sqrt(2.0) * (Math.cos(x) - 1.0))))) / (3.0 + (((t_1 * Math.cos(x)) - ((((1.0 - (3.0 / Math.sqrt(5.0))) * Math.sqrt(5.0)) * 0.5) * Math.cos(y))) * 3.0));
}
return tmp;
}
def code(x, y): t_0 = math.cos(x) - math.cos(y) t_1 = 0.5 * (math.sqrt(5.0) - 1.0) t_2 = 3.0 - math.sqrt(5.0) t_3 = math.pow(math.sin(x), 2.0) tmp = 0 if x <= -3.5: tmp = (2.0 + ((-0.0625 * (t_3 * math.sqrt(2.0))) * t_0)) / (3.0 * ((((0.5 * t_2) * math.cos(y)) + 1.0) - (((1.0 - math.sqrt(5.0)) * 0.5) * math.cos(x)))) elif x <= 1.45e-5: tmp = (2.0 + (((math.sqrt(2.0) * (x - (0.0625 * math.sin(y)))) * (math.sin(y) - (0.0625 * x))) * t_0)) / (3.0 * (1.0 + ((0.5 * (math.cos(y) * t_2)) + t_1))) else: tmp = (2.0 + (-0.0625 * (t_3 * (math.sqrt(2.0) * (math.cos(x) - 1.0))))) / (3.0 + (((t_1 * math.cos(x)) - ((((1.0 - (3.0 / math.sqrt(5.0))) * math.sqrt(5.0)) * 0.5) * math.cos(y))) * 3.0)) return tmp
function code(x, y) t_0 = Float64(cos(x) - cos(y)) t_1 = Float64(0.5 * Float64(sqrt(5.0) - 1.0)) t_2 = Float64(3.0 - sqrt(5.0)) t_3 = sin(x) ^ 2.0 tmp = 0.0 if (x <= -3.5) tmp = Float64(Float64(2.0 + Float64(Float64(-0.0625 * Float64(t_3 * sqrt(2.0))) * t_0)) / Float64(3.0 * Float64(Float64(Float64(Float64(0.5 * t_2) * cos(y)) + 1.0) - Float64(Float64(Float64(1.0 - sqrt(5.0)) * 0.5) * cos(x))))); elseif (x <= 1.45e-5) tmp = Float64(Float64(2.0 + Float64(Float64(Float64(sqrt(2.0) * Float64(x - Float64(0.0625 * sin(y)))) * Float64(sin(y) - Float64(0.0625 * x))) * t_0)) / Float64(3.0 * Float64(1.0 + Float64(Float64(0.5 * Float64(cos(y) * t_2)) + t_1)))); else tmp = Float64(Float64(2.0 + Float64(-0.0625 * Float64(t_3 * Float64(sqrt(2.0) * Float64(cos(x) - 1.0))))) / Float64(3.0 + Float64(Float64(Float64(t_1 * cos(x)) - Float64(Float64(Float64(Float64(1.0 - Float64(3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0))); end return tmp end
function tmp_2 = code(x, y) t_0 = cos(x) - cos(y); t_1 = 0.5 * (sqrt(5.0) - 1.0); t_2 = 3.0 - sqrt(5.0); t_3 = sin(x) ^ 2.0; tmp = 0.0; if (x <= -3.5) tmp = (2.0 + ((-0.0625 * (t_3 * sqrt(2.0))) * t_0)) / (3.0 * ((((0.5 * t_2) * cos(y)) + 1.0) - (((1.0 - sqrt(5.0)) * 0.5) * cos(x)))); elseif (x <= 1.45e-5) tmp = (2.0 + (((sqrt(2.0) * (x - (0.0625 * sin(y)))) * (sin(y) - (0.0625 * x))) * t_0)) / (3.0 * (1.0 + ((0.5 * (cos(y) * t_2)) + t_1))); else tmp = (2.0 + (-0.0625 * (t_3 * (sqrt(2.0) * (cos(x) - 1.0))))) / (3.0 + (((t_1 * cos(x)) - ((((1.0 - (3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0)); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[x, -3.5], N[(N[(2.0 + N[(N[(-0.0625 * N[(t$95$3 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(3.0 * N[(N[(N[(N[(0.5 * t$95$2), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(N[(1.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e-5], N[(N[(2.0 + N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(x - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(3.0 * N[(1.0 + N[(N[(0.5 * N[(N[Cos[y], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 + N[(-0.0625 * N[(t$95$3 * N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(N[(t$95$1 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[(1.0 - N[(3.0 / N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \cos x - \cos y\\
t_1 := 0.5 \cdot \left(\sqrt{5} - 1\right)\\
t_2 := 3 - \sqrt{5}\\
t_3 := {\sin x}^{2}\\
\mathbf{if}\;x \leq -3.5:\\
\;\;\;\;\frac{2 + \left(-0.0625 \cdot \left(t\_3 \cdot \sqrt{2}\right)\right) \cdot t\_0}{3 \cdot \left(\left(\left(0.5 \cdot t\_2\right) \cdot \cos y + 1\right) - \left(\left(1 - \sqrt{5}\right) \cdot 0.5\right) \cdot \cos x\right)}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{2 + \left(\left(\sqrt{2} \cdot \left(x - 0.0625 \cdot \sin y\right)\right) \cdot \left(\sin y - 0.0625 \cdot x\right)\right) \cdot t\_0}{3 \cdot \left(1 + \left(0.5 \cdot \left(\cos y \cdot t\_2\right) + t\_1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + -0.0625 \cdot \left(t\_3 \cdot \left(\sqrt{2} \cdot \left(\cos x - 1\right)\right)\right)}{3 + \left(t\_1 \cdot \cos x - \left(\left(\left(1 - \frac{3}{\sqrt{5}}\right) \cdot \sqrt{5}\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3}\\
\end{array}
if x < -3.5Initial program 99.3%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
associate-+r-N/A
lower--.f64N/A
lower-+.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-sqrt.f6461.7%
Applied rewrites61.7%
if -3.5 < x < 1.45e-5Initial program 99.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f6460.1%
Applied rewrites60.1%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f64N/A
lower-sin.f6451.1%
Applied rewrites51.1%
Taylor expanded in x around 0
lower-*.f6451.1%
Applied rewrites51.1%
if 1.45e-5 < x Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f6499.3%
Applied rewrites99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6461.7%
Applied rewrites61.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* 0.5 (- (sqrt 5.0) 1.0)))
(t_1
(+
2.0
(*
-0.0625
(* (pow (sin x) 2.0) (* (sqrt 2.0) (- (cos x) 1.0))))))
(t_2 (* t_0 (cos x))))
(if (<= x -3.5)
(/
t_1
(+ 3.0 (* (- t_2 (* (* (- (sqrt 5.0) 3.0) 0.5) (cos y))) 3.0)))
(if (<= x 1.45e-5)
(/
(+
2.0
(*
(*
(* (sqrt 2.0) (- x (* 0.0625 (sin y))))
(- (sin y) (* 0.0625 x)))
(- (cos x) (cos y))))
(* 3.0 (+ 1.0 (+ (* 0.5 (* (cos y) (- 3.0 (sqrt 5.0)))) t_0))))
(/
t_1
(+
3.0
(*
(-
t_2
(*
(* (* (- 1.0 (/ 3.0 (sqrt 5.0))) (sqrt 5.0)) 0.5)
(cos y)))
3.0)))))))double code(double x, double y) {
double t_0 = 0.5 * (sqrt(5.0) - 1.0);
double t_1 = 2.0 + (-0.0625 * (pow(sin(x), 2.0) * (sqrt(2.0) * (cos(x) - 1.0))));
double t_2 = t_0 * cos(x);
double tmp;
if (x <= -3.5) {
tmp = t_1 / (3.0 + ((t_2 - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0));
} else if (x <= 1.45e-5) {
tmp = (2.0 + (((sqrt(2.0) * (x - (0.0625 * sin(y)))) * (sin(y) - (0.0625 * x))) * (cos(x) - cos(y)))) / (3.0 * (1.0 + ((0.5 * (cos(y) * (3.0 - sqrt(5.0)))) + t_0)));
} else {
tmp = t_1 / (3.0 + ((t_2 - ((((1.0 - (3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 0.5d0 * (sqrt(5.0d0) - 1.0d0)
t_1 = 2.0d0 + ((-0.0625d0) * ((sin(x) ** 2.0d0) * (sqrt(2.0d0) * (cos(x) - 1.0d0))))
t_2 = t_0 * cos(x)
if (x <= (-3.5d0)) then
tmp = t_1 / (3.0d0 + ((t_2 - (((sqrt(5.0d0) - 3.0d0) * 0.5d0) * cos(y))) * 3.0d0))
else if (x <= 1.45d-5) then
tmp = (2.0d0 + (((sqrt(2.0d0) * (x - (0.0625d0 * sin(y)))) * (sin(y) - (0.0625d0 * x))) * (cos(x) - cos(y)))) / (3.0d0 * (1.0d0 + ((0.5d0 * (cos(y) * (3.0d0 - sqrt(5.0d0)))) + t_0)))
else
tmp = t_1 / (3.0d0 + ((t_2 - ((((1.0d0 - (3.0d0 / sqrt(5.0d0))) * sqrt(5.0d0)) * 0.5d0) * cos(y))) * 3.0d0))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 0.5 * (Math.sqrt(5.0) - 1.0);
double t_1 = 2.0 + (-0.0625 * (Math.pow(Math.sin(x), 2.0) * (Math.sqrt(2.0) * (Math.cos(x) - 1.0))));
double t_2 = t_0 * Math.cos(x);
double tmp;
if (x <= -3.5) {
tmp = t_1 / (3.0 + ((t_2 - (((Math.sqrt(5.0) - 3.0) * 0.5) * Math.cos(y))) * 3.0));
} else if (x <= 1.45e-5) {
tmp = (2.0 + (((Math.sqrt(2.0) * (x - (0.0625 * Math.sin(y)))) * (Math.sin(y) - (0.0625 * x))) * (Math.cos(x) - Math.cos(y)))) / (3.0 * (1.0 + ((0.5 * (Math.cos(y) * (3.0 - Math.sqrt(5.0)))) + t_0)));
} else {
tmp = t_1 / (3.0 + ((t_2 - ((((1.0 - (3.0 / Math.sqrt(5.0))) * Math.sqrt(5.0)) * 0.5) * Math.cos(y))) * 3.0));
}
return tmp;
}
def code(x, y): t_0 = 0.5 * (math.sqrt(5.0) - 1.0) t_1 = 2.0 + (-0.0625 * (math.pow(math.sin(x), 2.0) * (math.sqrt(2.0) * (math.cos(x) - 1.0)))) t_2 = t_0 * math.cos(x) tmp = 0 if x <= -3.5: tmp = t_1 / (3.0 + ((t_2 - (((math.sqrt(5.0) - 3.0) * 0.5) * math.cos(y))) * 3.0)) elif x <= 1.45e-5: tmp = (2.0 + (((math.sqrt(2.0) * (x - (0.0625 * math.sin(y)))) * (math.sin(y) - (0.0625 * x))) * (math.cos(x) - math.cos(y)))) / (3.0 * (1.0 + ((0.5 * (math.cos(y) * (3.0 - math.sqrt(5.0)))) + t_0))) else: tmp = t_1 / (3.0 + ((t_2 - ((((1.0 - (3.0 / math.sqrt(5.0))) * math.sqrt(5.0)) * 0.5) * math.cos(y))) * 3.0)) return tmp
function code(x, y) t_0 = Float64(0.5 * Float64(sqrt(5.0) - 1.0)) t_1 = Float64(2.0 + Float64(-0.0625 * Float64((sin(x) ^ 2.0) * Float64(sqrt(2.0) * Float64(cos(x) - 1.0))))) t_2 = Float64(t_0 * cos(x)) tmp = 0.0 if (x <= -3.5) tmp = Float64(t_1 / Float64(3.0 + Float64(Float64(t_2 - Float64(Float64(Float64(sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0))); elseif (x <= 1.45e-5) tmp = Float64(Float64(2.0 + Float64(Float64(Float64(sqrt(2.0) * Float64(x - Float64(0.0625 * sin(y)))) * Float64(sin(y) - Float64(0.0625 * x))) * Float64(cos(x) - cos(y)))) / Float64(3.0 * Float64(1.0 + Float64(Float64(0.5 * Float64(cos(y) * Float64(3.0 - sqrt(5.0)))) + t_0)))); else tmp = Float64(t_1 / Float64(3.0 + Float64(Float64(t_2 - Float64(Float64(Float64(Float64(1.0 - Float64(3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0))); end return tmp end
function tmp_2 = code(x, y) t_0 = 0.5 * (sqrt(5.0) - 1.0); t_1 = 2.0 + (-0.0625 * ((sin(x) ^ 2.0) * (sqrt(2.0) * (cos(x) - 1.0)))); t_2 = t_0 * cos(x); tmp = 0.0; if (x <= -3.5) tmp = t_1 / (3.0 + ((t_2 - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0)); elseif (x <= 1.45e-5) tmp = (2.0 + (((sqrt(2.0) * (x - (0.0625 * sin(y)))) * (sin(y) - (0.0625 * x))) * (cos(x) - cos(y)))) / (3.0 * (1.0 + ((0.5 * (cos(y) * (3.0 - sqrt(5.0)))) + t_0))); else tmp = t_1 / (3.0 + ((t_2 - ((((1.0 - (3.0 / sqrt(5.0))) * sqrt(5.0)) * 0.5) * cos(y))) * 3.0)); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(0.5 * N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 + N[(-0.0625 * N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[Cos[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.5], N[(t$95$1 / N[(3.0 + N[(N[(t$95$2 - N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e-5], N[(N[(2.0 + N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(x - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * N[(1.0 + N[(N[(0.5 * N[(N[Cos[y], $MachinePrecision] * N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[(3.0 + N[(N[(t$95$2 - N[(N[(N[(N[(1.0 - N[(3.0 / N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := 0.5 \cdot \left(\sqrt{5} - 1\right)\\
t_1 := 2 + -0.0625 \cdot \left({\sin x}^{2} \cdot \left(\sqrt{2} \cdot \left(\cos x - 1\right)\right)\right)\\
t_2 := t\_0 \cdot \cos x\\
\mathbf{if}\;x \leq -3.5:\\
\;\;\;\;\frac{t\_1}{3 + \left(t\_2 - \left(\left(\sqrt{5} - 3\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{2 + \left(\left(\sqrt{2} \cdot \left(x - 0.0625 \cdot \sin y\right)\right) \cdot \left(\sin y - 0.0625 \cdot x\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(1 + \left(0.5 \cdot \left(\cos y \cdot \left(3 - \sqrt{5}\right)\right) + t\_0\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{3 + \left(t\_2 - \left(\left(\left(1 - \frac{3}{\sqrt{5}}\right) \cdot \sqrt{5}\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3}\\
\end{array}
if x < -3.5Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6461.7%
Applied rewrites61.7%
if -3.5 < x < 1.45e-5Initial program 99.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f6460.1%
Applied rewrites60.1%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f64N/A
lower-sin.f6451.1%
Applied rewrites51.1%
Taylor expanded in x around 0
lower-*.f6451.1%
Applied rewrites51.1%
if 1.45e-5 < x Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f6499.3%
Applied rewrites99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6461.7%
Applied rewrites61.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (cos x) 1.0))
(t_1 (* 0.5 (* (cos y) (- 3.0 (sqrt 5.0)))))
(t_2 (- (sqrt 5.0) 1.0))
(t_3 (* 0.5 t_2))
(t_4 (pow (sin x) 2.0)))
(if (<= x -3.5)
(/
(+ 2.0 (* -0.0625 (* t_4 (* (sqrt 2.0) t_0))))
(+
3.0
(*
(- (* t_3 (cos x)) (* (* (- (sqrt 5.0) 3.0) 0.5) (cos y)))
3.0)))
(if (<= x 1.45e-5)
(/
(+
2.0
(*
(*
(* (sqrt 2.0) (- x (* 0.0625 (sin y))))
(- (sin y) (* 0.0625 x)))
(- (cos x) (cos y))))
(* 3.0 (+ 1.0 (+ t_1 t_3))))
(*
0.3333333333333333
(/
(+ 2.0 (* (sqrt 2.0) (* -0.0625 (* t_4 t_0))))
(+ 1.0 (+ (* 0.5 (* (cos x) t_2)) t_1))))))))double code(double x, double y) {
double t_0 = cos(x) - 1.0;
double t_1 = 0.5 * (cos(y) * (3.0 - sqrt(5.0)));
double t_2 = sqrt(5.0) - 1.0;
double t_3 = 0.5 * t_2;
double t_4 = pow(sin(x), 2.0);
double tmp;
if (x <= -3.5) {
tmp = (2.0 + (-0.0625 * (t_4 * (sqrt(2.0) * t_0)))) / (3.0 + (((t_3 * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0));
} else if (x <= 1.45e-5) {
tmp = (2.0 + (((sqrt(2.0) * (x - (0.0625 * sin(y)))) * (sin(y) - (0.0625 * x))) * (cos(x) - cos(y)))) / (3.0 * (1.0 + (t_1 + t_3)));
} else {
tmp = 0.3333333333333333 * ((2.0 + (sqrt(2.0) * (-0.0625 * (t_4 * t_0)))) / (1.0 + ((0.5 * (cos(x) * t_2)) + t_1)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = cos(x) - 1.0d0
t_1 = 0.5d0 * (cos(y) * (3.0d0 - sqrt(5.0d0)))
t_2 = sqrt(5.0d0) - 1.0d0
t_3 = 0.5d0 * t_2
t_4 = sin(x) ** 2.0d0
if (x <= (-3.5d0)) then
tmp = (2.0d0 + ((-0.0625d0) * (t_4 * (sqrt(2.0d0) * t_0)))) / (3.0d0 + (((t_3 * cos(x)) - (((sqrt(5.0d0) - 3.0d0) * 0.5d0) * cos(y))) * 3.0d0))
else if (x <= 1.45d-5) then
tmp = (2.0d0 + (((sqrt(2.0d0) * (x - (0.0625d0 * sin(y)))) * (sin(y) - (0.0625d0 * x))) * (cos(x) - cos(y)))) / (3.0d0 * (1.0d0 + (t_1 + t_3)))
else
tmp = 0.3333333333333333d0 * ((2.0d0 + (sqrt(2.0d0) * ((-0.0625d0) * (t_4 * t_0)))) / (1.0d0 + ((0.5d0 * (cos(x) * t_2)) + t_1)))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.cos(x) - 1.0;
double t_1 = 0.5 * (Math.cos(y) * (3.0 - Math.sqrt(5.0)));
double t_2 = Math.sqrt(5.0) - 1.0;
double t_3 = 0.5 * t_2;
double t_4 = Math.pow(Math.sin(x), 2.0);
double tmp;
if (x <= -3.5) {
tmp = (2.0 + (-0.0625 * (t_4 * (Math.sqrt(2.0) * t_0)))) / (3.0 + (((t_3 * Math.cos(x)) - (((Math.sqrt(5.0) - 3.0) * 0.5) * Math.cos(y))) * 3.0));
} else if (x <= 1.45e-5) {
tmp = (2.0 + (((Math.sqrt(2.0) * (x - (0.0625 * Math.sin(y)))) * (Math.sin(y) - (0.0625 * x))) * (Math.cos(x) - Math.cos(y)))) / (3.0 * (1.0 + (t_1 + t_3)));
} else {
tmp = 0.3333333333333333 * ((2.0 + (Math.sqrt(2.0) * (-0.0625 * (t_4 * t_0)))) / (1.0 + ((0.5 * (Math.cos(x) * t_2)) + t_1)));
}
return tmp;
}
def code(x, y): t_0 = math.cos(x) - 1.0 t_1 = 0.5 * (math.cos(y) * (3.0 - math.sqrt(5.0))) t_2 = math.sqrt(5.0) - 1.0 t_3 = 0.5 * t_2 t_4 = math.pow(math.sin(x), 2.0) tmp = 0 if x <= -3.5: tmp = (2.0 + (-0.0625 * (t_4 * (math.sqrt(2.0) * t_0)))) / (3.0 + (((t_3 * math.cos(x)) - (((math.sqrt(5.0) - 3.0) * 0.5) * math.cos(y))) * 3.0)) elif x <= 1.45e-5: tmp = (2.0 + (((math.sqrt(2.0) * (x - (0.0625 * math.sin(y)))) * (math.sin(y) - (0.0625 * x))) * (math.cos(x) - math.cos(y)))) / (3.0 * (1.0 + (t_1 + t_3))) else: tmp = 0.3333333333333333 * ((2.0 + (math.sqrt(2.0) * (-0.0625 * (t_4 * t_0)))) / (1.0 + ((0.5 * (math.cos(x) * t_2)) + t_1))) return tmp
function code(x, y) t_0 = Float64(cos(x) - 1.0) t_1 = Float64(0.5 * Float64(cos(y) * Float64(3.0 - sqrt(5.0)))) t_2 = Float64(sqrt(5.0) - 1.0) t_3 = Float64(0.5 * t_2) t_4 = sin(x) ^ 2.0 tmp = 0.0 if (x <= -3.5) tmp = Float64(Float64(2.0 + Float64(-0.0625 * Float64(t_4 * Float64(sqrt(2.0) * t_0)))) / Float64(3.0 + Float64(Float64(Float64(t_3 * cos(x)) - Float64(Float64(Float64(sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0))); elseif (x <= 1.45e-5) tmp = Float64(Float64(2.0 + Float64(Float64(Float64(sqrt(2.0) * Float64(x - Float64(0.0625 * sin(y)))) * Float64(sin(y) - Float64(0.0625 * x))) * Float64(cos(x) - cos(y)))) / Float64(3.0 * Float64(1.0 + Float64(t_1 + t_3)))); else tmp = Float64(0.3333333333333333 * Float64(Float64(2.0 + Float64(sqrt(2.0) * Float64(-0.0625 * Float64(t_4 * t_0)))) / Float64(1.0 + Float64(Float64(0.5 * Float64(cos(x) * t_2)) + t_1)))); end return tmp end
function tmp_2 = code(x, y) t_0 = cos(x) - 1.0; t_1 = 0.5 * (cos(y) * (3.0 - sqrt(5.0))); t_2 = sqrt(5.0) - 1.0; t_3 = 0.5 * t_2; t_4 = sin(x) ^ 2.0; tmp = 0.0; if (x <= -3.5) tmp = (2.0 + (-0.0625 * (t_4 * (sqrt(2.0) * t_0)))) / (3.0 + (((t_3 * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0)); elseif (x <= 1.45e-5) tmp = (2.0 + (((sqrt(2.0) * (x - (0.0625 * sin(y)))) * (sin(y) - (0.0625 * x))) * (cos(x) - cos(y)))) / (3.0 * (1.0 + (t_1 + t_3))); else tmp = 0.3333333333333333 * ((2.0 + (sqrt(2.0) * (-0.0625 * (t_4 * t_0)))) / (1.0 + ((0.5 * (cos(x) * t_2)) + t_1))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(N[Cos[y], $MachinePrecision] * N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$3 = N[(0.5 * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[x, -3.5], N[(N[(2.0 + N[(-0.0625 * N[(t$95$4 * N[(N[Sqrt[2.0], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(N[(t$95$3 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e-5], N[(N[(2.0 + N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(x - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sin[y], $MachinePrecision] - N[(0.0625 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * N[(1.0 + N[(t$95$1 + t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[(N[(2.0 + N[(N[Sqrt[2.0], $MachinePrecision] * N[(-0.0625 * N[(t$95$4 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(0.5 * N[(N[Cos[x], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \cos x - 1\\
t_1 := 0.5 \cdot \left(\cos y \cdot \left(3 - \sqrt{5}\right)\right)\\
t_2 := \sqrt{5} - 1\\
t_3 := 0.5 \cdot t\_2\\
t_4 := {\sin x}^{2}\\
\mathbf{if}\;x \leq -3.5:\\
\;\;\;\;\frac{2 + -0.0625 \cdot \left(t\_4 \cdot \left(\sqrt{2} \cdot t\_0\right)\right)}{3 + \left(t\_3 \cdot \cos x - \left(\left(\sqrt{5} - 3\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{2 + \left(\left(\sqrt{2} \cdot \left(x - 0.0625 \cdot \sin y\right)\right) \cdot \left(\sin y - 0.0625 \cdot x\right)\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(1 + \left(t\_1 + t\_3\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{2 + \sqrt{2} \cdot \left(-0.0625 \cdot \left(t\_4 \cdot t\_0\right)\right)}{1 + \left(0.5 \cdot \left(\cos x \cdot t\_2\right) + t\_1\right)}\\
\end{array}
if x < -3.5Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6461.7%
Applied rewrites61.7%
if -3.5 < x < 1.45e-5Initial program 99.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f6460.1%
Applied rewrites60.1%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f64N/A
lower-sin.f6451.1%
Applied rewrites51.1%
Taylor expanded in x around 0
lower-*.f6451.1%
Applied rewrites51.1%
if 1.45e-5 < x Initial program 99.3%
Taylor expanded in x around inf
Applied rewrites99.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower--.f64N/A
lower-cos.f6461.7%
Applied rewrites61.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (cos x) 1.0))
(t_1 (* 0.5 (* (cos y) (- 3.0 (sqrt 5.0)))))
(t_2 (- (sqrt 5.0) 1.0))
(t_3 (* 0.5 t_2))
(t_4 (pow (sin x) 2.0)))
(if (<= x -1550.0)
(/
(+ 2.0 (* -0.0625 (* t_4 (* (sqrt 2.0) t_0))))
(+
3.0
(*
(- (* t_3 (cos x)) (* (* (- (sqrt 5.0) 3.0) 0.5) (cos y)))
3.0)))
(if (<= x 1.45e-5)
(/
(+
2.0
(*
(* (* (sqrt 2.0) (- x (* 0.0625 (sin y)))) (sin y))
(- (cos x) (cos y))))
(* 3.0 (+ 1.0 (+ t_1 t_3))))
(*
0.3333333333333333
(/
(+ 2.0 (* (sqrt 2.0) (* -0.0625 (* t_4 t_0))))
(+ 1.0 (+ (* 0.5 (* (cos x) t_2)) t_1))))))))double code(double x, double y) {
double t_0 = cos(x) - 1.0;
double t_1 = 0.5 * (cos(y) * (3.0 - sqrt(5.0)));
double t_2 = sqrt(5.0) - 1.0;
double t_3 = 0.5 * t_2;
double t_4 = pow(sin(x), 2.0);
double tmp;
if (x <= -1550.0) {
tmp = (2.0 + (-0.0625 * (t_4 * (sqrt(2.0) * t_0)))) / (3.0 + (((t_3 * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0));
} else if (x <= 1.45e-5) {
tmp = (2.0 + (((sqrt(2.0) * (x - (0.0625 * sin(y)))) * sin(y)) * (cos(x) - cos(y)))) / (3.0 * (1.0 + (t_1 + t_3)));
} else {
tmp = 0.3333333333333333 * ((2.0 + (sqrt(2.0) * (-0.0625 * (t_4 * t_0)))) / (1.0 + ((0.5 * (cos(x) * t_2)) + t_1)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = cos(x) - 1.0d0
t_1 = 0.5d0 * (cos(y) * (3.0d0 - sqrt(5.0d0)))
t_2 = sqrt(5.0d0) - 1.0d0
t_3 = 0.5d0 * t_2
t_4 = sin(x) ** 2.0d0
if (x <= (-1550.0d0)) then
tmp = (2.0d0 + ((-0.0625d0) * (t_4 * (sqrt(2.0d0) * t_0)))) / (3.0d0 + (((t_3 * cos(x)) - (((sqrt(5.0d0) - 3.0d0) * 0.5d0) * cos(y))) * 3.0d0))
else if (x <= 1.45d-5) then
tmp = (2.0d0 + (((sqrt(2.0d0) * (x - (0.0625d0 * sin(y)))) * sin(y)) * (cos(x) - cos(y)))) / (3.0d0 * (1.0d0 + (t_1 + t_3)))
else
tmp = 0.3333333333333333d0 * ((2.0d0 + (sqrt(2.0d0) * ((-0.0625d0) * (t_4 * t_0)))) / (1.0d0 + ((0.5d0 * (cos(x) * t_2)) + t_1)))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.cos(x) - 1.0;
double t_1 = 0.5 * (Math.cos(y) * (3.0 - Math.sqrt(5.0)));
double t_2 = Math.sqrt(5.0) - 1.0;
double t_3 = 0.5 * t_2;
double t_4 = Math.pow(Math.sin(x), 2.0);
double tmp;
if (x <= -1550.0) {
tmp = (2.0 + (-0.0625 * (t_4 * (Math.sqrt(2.0) * t_0)))) / (3.0 + (((t_3 * Math.cos(x)) - (((Math.sqrt(5.0) - 3.0) * 0.5) * Math.cos(y))) * 3.0));
} else if (x <= 1.45e-5) {
tmp = (2.0 + (((Math.sqrt(2.0) * (x - (0.0625 * Math.sin(y)))) * Math.sin(y)) * (Math.cos(x) - Math.cos(y)))) / (3.0 * (1.0 + (t_1 + t_3)));
} else {
tmp = 0.3333333333333333 * ((2.0 + (Math.sqrt(2.0) * (-0.0625 * (t_4 * t_0)))) / (1.0 + ((0.5 * (Math.cos(x) * t_2)) + t_1)));
}
return tmp;
}
def code(x, y): t_0 = math.cos(x) - 1.0 t_1 = 0.5 * (math.cos(y) * (3.0 - math.sqrt(5.0))) t_2 = math.sqrt(5.0) - 1.0 t_3 = 0.5 * t_2 t_4 = math.pow(math.sin(x), 2.0) tmp = 0 if x <= -1550.0: tmp = (2.0 + (-0.0625 * (t_4 * (math.sqrt(2.0) * t_0)))) / (3.0 + (((t_3 * math.cos(x)) - (((math.sqrt(5.0) - 3.0) * 0.5) * math.cos(y))) * 3.0)) elif x <= 1.45e-5: tmp = (2.0 + (((math.sqrt(2.0) * (x - (0.0625 * math.sin(y)))) * math.sin(y)) * (math.cos(x) - math.cos(y)))) / (3.0 * (1.0 + (t_1 + t_3))) else: tmp = 0.3333333333333333 * ((2.0 + (math.sqrt(2.0) * (-0.0625 * (t_4 * t_0)))) / (1.0 + ((0.5 * (math.cos(x) * t_2)) + t_1))) return tmp
function code(x, y) t_0 = Float64(cos(x) - 1.0) t_1 = Float64(0.5 * Float64(cos(y) * Float64(3.0 - sqrt(5.0)))) t_2 = Float64(sqrt(5.0) - 1.0) t_3 = Float64(0.5 * t_2) t_4 = sin(x) ^ 2.0 tmp = 0.0 if (x <= -1550.0) tmp = Float64(Float64(2.0 + Float64(-0.0625 * Float64(t_4 * Float64(sqrt(2.0) * t_0)))) / Float64(3.0 + Float64(Float64(Float64(t_3 * cos(x)) - Float64(Float64(Float64(sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0))); elseif (x <= 1.45e-5) tmp = Float64(Float64(2.0 + Float64(Float64(Float64(sqrt(2.0) * Float64(x - Float64(0.0625 * sin(y)))) * sin(y)) * Float64(cos(x) - cos(y)))) / Float64(3.0 * Float64(1.0 + Float64(t_1 + t_3)))); else tmp = Float64(0.3333333333333333 * Float64(Float64(2.0 + Float64(sqrt(2.0) * Float64(-0.0625 * Float64(t_4 * t_0)))) / Float64(1.0 + Float64(Float64(0.5 * Float64(cos(x) * t_2)) + t_1)))); end return tmp end
function tmp_2 = code(x, y) t_0 = cos(x) - 1.0; t_1 = 0.5 * (cos(y) * (3.0 - sqrt(5.0))); t_2 = sqrt(5.0) - 1.0; t_3 = 0.5 * t_2; t_4 = sin(x) ^ 2.0; tmp = 0.0; if (x <= -1550.0) tmp = (2.0 + (-0.0625 * (t_4 * (sqrt(2.0) * t_0)))) / (3.0 + (((t_3 * cos(x)) - (((sqrt(5.0) - 3.0) * 0.5) * cos(y))) * 3.0)); elseif (x <= 1.45e-5) tmp = (2.0 + (((sqrt(2.0) * (x - (0.0625 * sin(y)))) * sin(y)) * (cos(x) - cos(y)))) / (3.0 * (1.0 + (t_1 + t_3))); else tmp = 0.3333333333333333 * ((2.0 + (sqrt(2.0) * (-0.0625 * (t_4 * t_0)))) / (1.0 + ((0.5 * (cos(x) * t_2)) + t_1))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(N[Cos[y], $MachinePrecision] * N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$3 = N[(0.5 * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[x, -1550.0], N[(N[(2.0 + N[(-0.0625 * N[(t$95$4 * N[(N[Sqrt[2.0], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(N[(N[(t$95$3 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e-5], N[(N[(2.0 + N[(N[(N[(N[Sqrt[2.0], $MachinePrecision] * N[(x - N[(0.0625 * N[Sin[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[y], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * N[(1.0 + N[(t$95$1 + t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[(N[(2.0 + N[(N[Sqrt[2.0], $MachinePrecision] * N[(-0.0625 * N[(t$95$4 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(0.5 * N[(N[Cos[x], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \cos x - 1\\
t_1 := 0.5 \cdot \left(\cos y \cdot \left(3 - \sqrt{5}\right)\right)\\
t_2 := \sqrt{5} - 1\\
t_3 := 0.5 \cdot t\_2\\
t_4 := {\sin x}^{2}\\
\mathbf{if}\;x \leq -1550:\\
\;\;\;\;\frac{2 + -0.0625 \cdot \left(t\_4 \cdot \left(\sqrt{2} \cdot t\_0\right)\right)}{3 + \left(t\_3 \cdot \cos x - \left(\left(\sqrt{5} - 3\right) \cdot 0.5\right) \cdot \cos y\right) \cdot 3}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{2 + \left(\left(\sqrt{2} \cdot \left(x - 0.0625 \cdot \sin y\right)\right) \cdot \sin y\right) \cdot \left(\cos x - \cos y\right)}{3 \cdot \left(1 + \left(t\_1 + t\_3\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{2 + \sqrt{2} \cdot \left(-0.0625 \cdot \left(t\_4 \cdot t\_0\right)\right)}{1 + \left(0.5 \cdot \left(\cos x \cdot t\_2\right) + t\_1\right)}\\
\end{array}
if x < -1550Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.3%
Applied rewrites99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6461.7%
Applied rewrites61.7%
if -1550 < x < 1.45e-5Initial program 99.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f6460.1%
Applied rewrites60.1%
Taylor expanded in x around 0
lower--.f64N/A
lower-*.f64N/A
lower-sin.f6451.1%
Applied rewrites51.1%
Taylor expanded in x around 0
lower-sin.f6453.3%
Applied rewrites53.3%
if 1.45e-5 < x Initial program 99.3%
Taylor expanded in x around inf
Applied rewrites99.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower--.f64N/A
lower-cos.f6461.7%
Applied rewrites61.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 3.0 (sqrt 5.0)))
(t_1
(+
2.0
(*
-0.0625
(* (pow (sin y) 2.0) (* (sqrt 2.0) (- 1.0 (cos y)))))))
(t_2 (* 0.5 (* (cos x) (- (sqrt 5.0) 1.0)))))
(if (<= y -19.5)
(/ t_1 (* 3.0 (+ 1.0 (+ t_2 (* 0.5 (* (cos y) t_0))))))
(if (<= y 2.16e-7)
(*
0.3333333333333333
(/
(+
2.0
(*
-0.0625
(* (pow (sin x) 2.0) (* (sqrt 2.0) (- (cos x) 1.0)))))
(+ 1.0 (+ t_2 0.38196601125010515))))
(/
t_1
(*
3.0
(-
(+ (* (* 0.5 t_0) (cos y)) 1.0)
(* (* (- 1.0 (sqrt 5.0)) 0.5) (cos x)))))))))double code(double x, double y) {
double t_0 = 3.0 - sqrt(5.0);
double t_1 = 2.0 + (-0.0625 * (pow(sin(y), 2.0) * (sqrt(2.0) * (1.0 - cos(y)))));
double t_2 = 0.5 * (cos(x) * (sqrt(5.0) - 1.0));
double tmp;
if (y <= -19.5) {
tmp = t_1 / (3.0 * (1.0 + (t_2 + (0.5 * (cos(y) * t_0)))));
} else if (y <= 2.16e-7) {
tmp = 0.3333333333333333 * ((2.0 + (-0.0625 * (pow(sin(x), 2.0) * (sqrt(2.0) * (cos(x) - 1.0))))) / (1.0 + (t_2 + 0.38196601125010515)));
} else {
tmp = t_1 / (3.0 * ((((0.5 * t_0) * cos(y)) + 1.0) - (((1.0 - sqrt(5.0)) * 0.5) * cos(x))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 3.0d0 - sqrt(5.0d0)
t_1 = 2.0d0 + ((-0.0625d0) * ((sin(y) ** 2.0d0) * (sqrt(2.0d0) * (1.0d0 - cos(y)))))
t_2 = 0.5d0 * (cos(x) * (sqrt(5.0d0) - 1.0d0))
if (y <= (-19.5d0)) then
tmp = t_1 / (3.0d0 * (1.0d0 + (t_2 + (0.5d0 * (cos(y) * t_0)))))
else if (y <= 2.16d-7) then
tmp = 0.3333333333333333d0 * ((2.0d0 + ((-0.0625d0) * ((sin(x) ** 2.0d0) * (sqrt(2.0d0) * (cos(x) - 1.0d0))))) / (1.0d0 + (t_2 + 0.38196601125010515d0)))
else
tmp = t_1 / (3.0d0 * ((((0.5d0 * t_0) * cos(y)) + 1.0d0) - (((1.0d0 - sqrt(5.0d0)) * 0.5d0) * cos(x))))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 3.0 - Math.sqrt(5.0);
double t_1 = 2.0 + (-0.0625 * (Math.pow(Math.sin(y), 2.0) * (Math.sqrt(2.0) * (1.0 - Math.cos(y)))));
double t_2 = 0.5 * (Math.cos(x) * (Math.sqrt(5.0) - 1.0));
double tmp;
if (y <= -19.5) {
tmp = t_1 / (3.0 * (1.0 + (t_2 + (0.5 * (Math.cos(y) * t_0)))));
} else if (y <= 2.16e-7) {
tmp = 0.3333333333333333 * ((2.0 + (-0.0625 * (Math.pow(Math.sin(x), 2.0) * (Math.sqrt(2.0) * (Math.cos(x) - 1.0))))) / (1.0 + (t_2 + 0.38196601125010515)));
} else {
tmp = t_1 / (3.0 * ((((0.5 * t_0) * Math.cos(y)) + 1.0) - (((1.0 - Math.sqrt(5.0)) * 0.5) * Math.cos(x))));
}
return tmp;
}
def code(x, y): t_0 = 3.0 - math.sqrt(5.0) t_1 = 2.0 + (-0.0625 * (math.pow(math.sin(y), 2.0) * (math.sqrt(2.0) * (1.0 - math.cos(y))))) t_2 = 0.5 * (math.cos(x) * (math.sqrt(5.0) - 1.0)) tmp = 0 if y <= -19.5: tmp = t_1 / (3.0 * (1.0 + (t_2 + (0.5 * (math.cos(y) * t_0))))) elif y <= 2.16e-7: tmp = 0.3333333333333333 * ((2.0 + (-0.0625 * (math.pow(math.sin(x), 2.0) * (math.sqrt(2.0) * (math.cos(x) - 1.0))))) / (1.0 + (t_2 + 0.38196601125010515))) else: tmp = t_1 / (3.0 * ((((0.5 * t_0) * math.cos(y)) + 1.0) - (((1.0 - math.sqrt(5.0)) * 0.5) * math.cos(x)))) return tmp
function code(x, y) t_0 = Float64(3.0 - sqrt(5.0)) t_1 = Float64(2.0 + Float64(-0.0625 * Float64((sin(y) ^ 2.0) * Float64(sqrt(2.0) * Float64(1.0 - cos(y)))))) t_2 = Float64(0.5 * Float64(cos(x) * Float64(sqrt(5.0) - 1.0))) tmp = 0.0 if (y <= -19.5) tmp = Float64(t_1 / Float64(3.0 * Float64(1.0 + Float64(t_2 + Float64(0.5 * Float64(cos(y) * t_0)))))); elseif (y <= 2.16e-7) tmp = Float64(0.3333333333333333 * Float64(Float64(2.0 + Float64(-0.0625 * Float64((sin(x) ^ 2.0) * Float64(sqrt(2.0) * Float64(cos(x) - 1.0))))) / Float64(1.0 + Float64(t_2 + 0.38196601125010515)))); else tmp = Float64(t_1 / Float64(3.0 * Float64(Float64(Float64(Float64(0.5 * t_0) * cos(y)) + 1.0) - Float64(Float64(Float64(1.0 - sqrt(5.0)) * 0.5) * cos(x))))); end return tmp end
function tmp_2 = code(x, y) t_0 = 3.0 - sqrt(5.0); t_1 = 2.0 + (-0.0625 * ((sin(y) ^ 2.0) * (sqrt(2.0) * (1.0 - cos(y))))); t_2 = 0.5 * (cos(x) * (sqrt(5.0) - 1.0)); tmp = 0.0; if (y <= -19.5) tmp = t_1 / (3.0 * (1.0 + (t_2 + (0.5 * (cos(y) * t_0))))); elseif (y <= 2.16e-7) tmp = 0.3333333333333333 * ((2.0 + (-0.0625 * ((sin(x) ^ 2.0) * (sqrt(2.0) * (cos(x) - 1.0))))) / (1.0 + (t_2 + 0.38196601125010515))); else tmp = t_1 / (3.0 * ((((0.5 * t_0) * cos(y)) + 1.0) - (((1.0 - sqrt(5.0)) * 0.5) * cos(x)))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 + N[(-0.0625 * N[(N[Power[N[Sin[y], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(0.5 * N[(N[Cos[x], $MachinePrecision] * N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -19.5], N[(t$95$1 / N[(3.0 * N[(1.0 + N[(t$95$2 + N[(0.5 * N[(N[Cos[y], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.16e-7], N[(0.3333333333333333 * N[(N[(2.0 + N[(-0.0625 * N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(t$95$2 + 0.38196601125010515), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[(3.0 * N[(N[(N[(N[(0.5 * t$95$0), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(N[(1.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := 3 - \sqrt{5}\\
t_1 := 2 + -0.0625 \cdot \left({\sin y}^{2} \cdot \left(\sqrt{2} \cdot \left(1 - \cos y\right)\right)\right)\\
t_2 := 0.5 \cdot \left(\cos x \cdot \left(\sqrt{5} - 1\right)\right)\\
\mathbf{if}\;y \leq -19.5:\\
\;\;\;\;\frac{t\_1}{3 \cdot \left(1 + \left(t\_2 + 0.5 \cdot \left(\cos y \cdot t\_0\right)\right)\right)}\\
\mathbf{elif}\;y \leq 2.16 \cdot 10^{-7}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{2 + -0.0625 \cdot \left({\sin x}^{2} \cdot \left(\sqrt{2} \cdot \left(\cos x - 1\right)\right)\right)}{1 + \left(t\_2 + 0.38196601125010515\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{3 \cdot \left(\left(\left(0.5 \cdot t\_0\right) \cdot \cos y + 1\right) - \left(\left(1 - \sqrt{5}\right) \cdot 0.5\right) \cdot \cos x\right)}\\
\end{array}
if y < -19.5Initial program 99.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f6460.1%
Applied rewrites60.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6459.6%
Applied rewrites59.6%
Taylor expanded in x around inf
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f6462.5%
Applied rewrites62.5%
if -19.5 < y < 2.16e-7Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Evaluated real constant59.4%
if 2.16e-7 < y Initial program 99.3%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
associate-+r-N/A
lower--.f64N/A
lower-+.f64N/A
lift-/.f64N/A
mult-flipN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6462.5%
Applied rewrites62.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* 0.5 (* (cos x) (- (sqrt 5.0) 1.0))))
(t_1
(/
(+
2.0
(*
-0.0625
(* (pow (sin y) 2.0) (* (sqrt 2.0) (- 1.0 (cos y))))))
(*
3.0
(+ 1.0 (+ t_0 (* 0.5 (* (cos y) (- 3.0 (sqrt 5.0))))))))))
(if (<= y -19.5)
t_1
(if (<= y 2.16e-7)
(*
0.3333333333333333
(/
(+
2.0
(*
-0.0625
(* (pow (sin x) 2.0) (* (sqrt 2.0) (- (cos x) 1.0)))))
(+ 1.0 (+ t_0 0.38196601125010515))))
t_1))))double code(double x, double y) {
double t_0 = 0.5 * (cos(x) * (sqrt(5.0) - 1.0));
double t_1 = (2.0 + (-0.0625 * (pow(sin(y), 2.0) * (sqrt(2.0) * (1.0 - cos(y)))))) / (3.0 * (1.0 + (t_0 + (0.5 * (cos(y) * (3.0 - sqrt(5.0)))))));
double tmp;
if (y <= -19.5) {
tmp = t_1;
} else if (y <= 2.16e-7) {
tmp = 0.3333333333333333 * ((2.0 + (-0.0625 * (pow(sin(x), 2.0) * (sqrt(2.0) * (cos(x) - 1.0))))) / (1.0 + (t_0 + 0.38196601125010515)));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * (cos(x) * (sqrt(5.0d0) - 1.0d0))
t_1 = (2.0d0 + ((-0.0625d0) * ((sin(y) ** 2.0d0) * (sqrt(2.0d0) * (1.0d0 - cos(y)))))) / (3.0d0 * (1.0d0 + (t_0 + (0.5d0 * (cos(y) * (3.0d0 - sqrt(5.0d0)))))))
if (y <= (-19.5d0)) then
tmp = t_1
else if (y <= 2.16d-7) then
tmp = 0.3333333333333333d0 * ((2.0d0 + ((-0.0625d0) * ((sin(x) ** 2.0d0) * (sqrt(2.0d0) * (cos(x) - 1.0d0))))) / (1.0d0 + (t_0 + 0.38196601125010515d0)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 0.5 * (Math.cos(x) * (Math.sqrt(5.0) - 1.0));
double t_1 = (2.0 + (-0.0625 * (Math.pow(Math.sin(y), 2.0) * (Math.sqrt(2.0) * (1.0 - Math.cos(y)))))) / (3.0 * (1.0 + (t_0 + (0.5 * (Math.cos(y) * (3.0 - Math.sqrt(5.0)))))));
double tmp;
if (y <= -19.5) {
tmp = t_1;
} else if (y <= 2.16e-7) {
tmp = 0.3333333333333333 * ((2.0 + (-0.0625 * (Math.pow(Math.sin(x), 2.0) * (Math.sqrt(2.0) * (Math.cos(x) - 1.0))))) / (1.0 + (t_0 + 0.38196601125010515)));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = 0.5 * (math.cos(x) * (math.sqrt(5.0) - 1.0)) t_1 = (2.0 + (-0.0625 * (math.pow(math.sin(y), 2.0) * (math.sqrt(2.0) * (1.0 - math.cos(y)))))) / (3.0 * (1.0 + (t_0 + (0.5 * (math.cos(y) * (3.0 - math.sqrt(5.0))))))) tmp = 0 if y <= -19.5: tmp = t_1 elif y <= 2.16e-7: tmp = 0.3333333333333333 * ((2.0 + (-0.0625 * (math.pow(math.sin(x), 2.0) * (math.sqrt(2.0) * (math.cos(x) - 1.0))))) / (1.0 + (t_0 + 0.38196601125010515))) else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(0.5 * Float64(cos(x) * Float64(sqrt(5.0) - 1.0))) t_1 = Float64(Float64(2.0 + Float64(-0.0625 * Float64((sin(y) ^ 2.0) * Float64(sqrt(2.0) * Float64(1.0 - cos(y)))))) / Float64(3.0 * Float64(1.0 + Float64(t_0 + Float64(0.5 * Float64(cos(y) * Float64(3.0 - sqrt(5.0)))))))) tmp = 0.0 if (y <= -19.5) tmp = t_1; elseif (y <= 2.16e-7) tmp = Float64(0.3333333333333333 * Float64(Float64(2.0 + Float64(-0.0625 * Float64((sin(x) ^ 2.0) * Float64(sqrt(2.0) * Float64(cos(x) - 1.0))))) / Float64(1.0 + Float64(t_0 + 0.38196601125010515)))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = 0.5 * (cos(x) * (sqrt(5.0) - 1.0)); t_1 = (2.0 + (-0.0625 * ((sin(y) ^ 2.0) * (sqrt(2.0) * (1.0 - cos(y)))))) / (3.0 * (1.0 + (t_0 + (0.5 * (cos(y) * (3.0 - sqrt(5.0))))))); tmp = 0.0; if (y <= -19.5) tmp = t_1; elseif (y <= 2.16e-7) tmp = 0.3333333333333333 * ((2.0 + (-0.0625 * ((sin(x) ^ 2.0) * (sqrt(2.0) * (cos(x) - 1.0))))) / (1.0 + (t_0 + 0.38196601125010515))); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(0.5 * N[(N[Cos[x], $MachinePrecision] * N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 + N[(-0.0625 * N[(N[Power[N[Sin[y], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * N[(1.0 + N[(t$95$0 + N[(0.5 * N[(N[Cos[y], $MachinePrecision] * N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -19.5], t$95$1, If[LessEqual[y, 2.16e-7], N[(0.3333333333333333 * N[(N[(2.0 + N[(-0.0625 * N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(t$95$0 + 0.38196601125010515), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := 0.5 \cdot \left(\cos x \cdot \left(\sqrt{5} - 1\right)\right)\\
t_1 := \frac{2 + -0.0625 \cdot \left({\sin y}^{2} \cdot \left(\sqrt{2} \cdot \left(1 - \cos y\right)\right)\right)}{3 \cdot \left(1 + \left(t\_0 + 0.5 \cdot \left(\cos y \cdot \left(3 - \sqrt{5}\right)\right)\right)\right)}\\
\mathbf{if}\;y \leq -19.5:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.16 \cdot 10^{-7}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{2 + -0.0625 \cdot \left({\sin x}^{2} \cdot \left(\sqrt{2} \cdot \left(\cos x - 1\right)\right)\right)}{1 + \left(t\_0 + 0.38196601125010515\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -19.5 or 2.16e-7 < y Initial program 99.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f6460.1%
Applied rewrites60.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6459.6%
Applied rewrites59.6%
Taylor expanded in x around inf
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f6462.5%
Applied rewrites62.5%
if -19.5 < y < 2.16e-7Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Evaluated real constant59.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* 0.5 (* (cos x) (- (sqrt 5.0) 1.0))))
(t_1
(*
0.3333333333333333
(/
(+
2.0
(*
(sqrt 2.0)
(* -0.0625 (* (pow (sin y) 2.0) (- 1.0 (cos y))))))
(+ 1.0 (+ t_0 (* 0.5 (* (cos y) (- 3.0 (sqrt 5.0))))))))))
(if (<= y -19.5)
t_1
(if (<= y 2.16e-7)
(*
0.3333333333333333
(/
(+
2.0
(*
-0.0625
(* (pow (sin x) 2.0) (* (sqrt 2.0) (- (cos x) 1.0)))))
(+ 1.0 (+ t_0 0.38196601125010515))))
t_1))))double code(double x, double y) {
double t_0 = 0.5 * (cos(x) * (sqrt(5.0) - 1.0));
double t_1 = 0.3333333333333333 * ((2.0 + (sqrt(2.0) * (-0.0625 * (pow(sin(y), 2.0) * (1.0 - cos(y)))))) / (1.0 + (t_0 + (0.5 * (cos(y) * (3.0 - sqrt(5.0)))))));
double tmp;
if (y <= -19.5) {
tmp = t_1;
} else if (y <= 2.16e-7) {
tmp = 0.3333333333333333 * ((2.0 + (-0.0625 * (pow(sin(x), 2.0) * (sqrt(2.0) * (cos(x) - 1.0))))) / (1.0 + (t_0 + 0.38196601125010515)));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * (cos(x) * (sqrt(5.0d0) - 1.0d0))
t_1 = 0.3333333333333333d0 * ((2.0d0 + (sqrt(2.0d0) * ((-0.0625d0) * ((sin(y) ** 2.0d0) * (1.0d0 - cos(y)))))) / (1.0d0 + (t_0 + (0.5d0 * (cos(y) * (3.0d0 - sqrt(5.0d0)))))))
if (y <= (-19.5d0)) then
tmp = t_1
else if (y <= 2.16d-7) then
tmp = 0.3333333333333333d0 * ((2.0d0 + ((-0.0625d0) * ((sin(x) ** 2.0d0) * (sqrt(2.0d0) * (cos(x) - 1.0d0))))) / (1.0d0 + (t_0 + 0.38196601125010515d0)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 0.5 * (Math.cos(x) * (Math.sqrt(5.0) - 1.0));
double t_1 = 0.3333333333333333 * ((2.0 + (Math.sqrt(2.0) * (-0.0625 * (Math.pow(Math.sin(y), 2.0) * (1.0 - Math.cos(y)))))) / (1.0 + (t_0 + (0.5 * (Math.cos(y) * (3.0 - Math.sqrt(5.0)))))));
double tmp;
if (y <= -19.5) {
tmp = t_1;
} else if (y <= 2.16e-7) {
tmp = 0.3333333333333333 * ((2.0 + (-0.0625 * (Math.pow(Math.sin(x), 2.0) * (Math.sqrt(2.0) * (Math.cos(x) - 1.0))))) / (1.0 + (t_0 + 0.38196601125010515)));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = 0.5 * (math.cos(x) * (math.sqrt(5.0) - 1.0)) t_1 = 0.3333333333333333 * ((2.0 + (math.sqrt(2.0) * (-0.0625 * (math.pow(math.sin(y), 2.0) * (1.0 - math.cos(y)))))) / (1.0 + (t_0 + (0.5 * (math.cos(y) * (3.0 - math.sqrt(5.0))))))) tmp = 0 if y <= -19.5: tmp = t_1 elif y <= 2.16e-7: tmp = 0.3333333333333333 * ((2.0 + (-0.0625 * (math.pow(math.sin(x), 2.0) * (math.sqrt(2.0) * (math.cos(x) - 1.0))))) / (1.0 + (t_0 + 0.38196601125010515))) else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(0.5 * Float64(cos(x) * Float64(sqrt(5.0) - 1.0))) t_1 = Float64(0.3333333333333333 * Float64(Float64(2.0 + Float64(sqrt(2.0) * Float64(-0.0625 * Float64((sin(y) ^ 2.0) * Float64(1.0 - cos(y)))))) / Float64(1.0 + Float64(t_0 + Float64(0.5 * Float64(cos(y) * Float64(3.0 - sqrt(5.0)))))))) tmp = 0.0 if (y <= -19.5) tmp = t_1; elseif (y <= 2.16e-7) tmp = Float64(0.3333333333333333 * Float64(Float64(2.0 + Float64(-0.0625 * Float64((sin(x) ^ 2.0) * Float64(sqrt(2.0) * Float64(cos(x) - 1.0))))) / Float64(1.0 + Float64(t_0 + 0.38196601125010515)))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = 0.5 * (cos(x) * (sqrt(5.0) - 1.0)); t_1 = 0.3333333333333333 * ((2.0 + (sqrt(2.0) * (-0.0625 * ((sin(y) ^ 2.0) * (1.0 - cos(y)))))) / (1.0 + (t_0 + (0.5 * (cos(y) * (3.0 - sqrt(5.0))))))); tmp = 0.0; if (y <= -19.5) tmp = t_1; elseif (y <= 2.16e-7) tmp = 0.3333333333333333 * ((2.0 + (-0.0625 * ((sin(x) ^ 2.0) * (sqrt(2.0) * (cos(x) - 1.0))))) / (1.0 + (t_0 + 0.38196601125010515))); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(0.5 * N[(N[Cos[x], $MachinePrecision] * N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.3333333333333333 * N[(N[(2.0 + N[(N[Sqrt[2.0], $MachinePrecision] * N[(-0.0625 * N[(N[Power[N[Sin[y], $MachinePrecision], 2.0], $MachinePrecision] * N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(t$95$0 + N[(0.5 * N[(N[Cos[y], $MachinePrecision] * N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -19.5], t$95$1, If[LessEqual[y, 2.16e-7], N[(0.3333333333333333 * N[(N[(2.0 + N[(-0.0625 * N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(t$95$0 + 0.38196601125010515), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := 0.5 \cdot \left(\cos x \cdot \left(\sqrt{5} - 1\right)\right)\\
t_1 := 0.3333333333333333 \cdot \frac{2 + \sqrt{2} \cdot \left(-0.0625 \cdot \left({\sin y}^{2} \cdot \left(1 - \cos y\right)\right)\right)}{1 + \left(t\_0 + 0.5 \cdot \left(\cos y \cdot \left(3 - \sqrt{5}\right)\right)\right)}\\
\mathbf{if}\;y \leq -19.5:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.16 \cdot 10^{-7}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{2 + -0.0625 \cdot \left({\sin x}^{2} \cdot \left(\sqrt{2} \cdot \left(\cos x - 1\right)\right)\right)}{1 + \left(t\_0 + 0.38196601125010515\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if y < -19.5 or 2.16e-7 < y Initial program 99.3%
Taylor expanded in x around inf
Applied rewrites99.2%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower--.f64N/A
lower-cos.f6462.4%
Applied rewrites62.4%
if -19.5 < y < 2.16e-7Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Evaluated real constant59.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (sqrt 5.0) 1.0))
(t_1
(*
0.3333333333333333
(/
(+
2.0
(*
(sqrt 2.0)
(* -0.0625 (* (pow (sin x) 2.0) (- (cos x) 1.0)))))
(+
1.0
(+
(* 0.5 (* (cos x) t_0))
(* 0.5 (* (cos y) (- 3.0 (sqrt 5.0))))))))))
(if (<= x -0.024)
t_1
(if (<= x 1.45e-5)
(/
(+
2.0
(*
-0.0625
(* (pow (sin y) 2.0) (* (sqrt 2.0) (- 1.0 (cos y))))))
(+
3.0
(*
3.0
(-
(* 0.5 t_0)
(*
0.5
(*
(cos y)
(* (sqrt 5.0) (- 1.0 (* 3.0 (/ 1.0 (sqrt 5.0)))))))))))
t_1))))double code(double x, double y) {
double t_0 = sqrt(5.0) - 1.0;
double t_1 = 0.3333333333333333 * ((2.0 + (sqrt(2.0) * (-0.0625 * (pow(sin(x), 2.0) * (cos(x) - 1.0))))) / (1.0 + ((0.5 * (cos(x) * t_0)) + (0.5 * (cos(y) * (3.0 - sqrt(5.0)))))));
double tmp;
if (x <= -0.024) {
tmp = t_1;
} else if (x <= 1.45e-5) {
tmp = (2.0 + (-0.0625 * (pow(sin(y), 2.0) * (sqrt(2.0) * (1.0 - cos(y)))))) / (3.0 + (3.0 * ((0.5 * t_0) - (0.5 * (cos(y) * (sqrt(5.0) * (1.0 - (3.0 * (1.0 / sqrt(5.0))))))))));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt(5.0d0) - 1.0d0
t_1 = 0.3333333333333333d0 * ((2.0d0 + (sqrt(2.0d0) * ((-0.0625d0) * ((sin(x) ** 2.0d0) * (cos(x) - 1.0d0))))) / (1.0d0 + ((0.5d0 * (cos(x) * t_0)) + (0.5d0 * (cos(y) * (3.0d0 - sqrt(5.0d0)))))))
if (x <= (-0.024d0)) then
tmp = t_1
else if (x <= 1.45d-5) then
tmp = (2.0d0 + ((-0.0625d0) * ((sin(y) ** 2.0d0) * (sqrt(2.0d0) * (1.0d0 - cos(y)))))) / (3.0d0 + (3.0d0 * ((0.5d0 * t_0) - (0.5d0 * (cos(y) * (sqrt(5.0d0) * (1.0d0 - (3.0d0 * (1.0d0 / sqrt(5.0d0))))))))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.sqrt(5.0) - 1.0;
double t_1 = 0.3333333333333333 * ((2.0 + (Math.sqrt(2.0) * (-0.0625 * (Math.pow(Math.sin(x), 2.0) * (Math.cos(x) - 1.0))))) / (1.0 + ((0.5 * (Math.cos(x) * t_0)) + (0.5 * (Math.cos(y) * (3.0 - Math.sqrt(5.0)))))));
double tmp;
if (x <= -0.024) {
tmp = t_1;
} else if (x <= 1.45e-5) {
tmp = (2.0 + (-0.0625 * (Math.pow(Math.sin(y), 2.0) * (Math.sqrt(2.0) * (1.0 - Math.cos(y)))))) / (3.0 + (3.0 * ((0.5 * t_0) - (0.5 * (Math.cos(y) * (Math.sqrt(5.0) * (1.0 - (3.0 * (1.0 / Math.sqrt(5.0))))))))));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = math.sqrt(5.0) - 1.0 t_1 = 0.3333333333333333 * ((2.0 + (math.sqrt(2.0) * (-0.0625 * (math.pow(math.sin(x), 2.0) * (math.cos(x) - 1.0))))) / (1.0 + ((0.5 * (math.cos(x) * t_0)) + (0.5 * (math.cos(y) * (3.0 - math.sqrt(5.0))))))) tmp = 0 if x <= -0.024: tmp = t_1 elif x <= 1.45e-5: tmp = (2.0 + (-0.0625 * (math.pow(math.sin(y), 2.0) * (math.sqrt(2.0) * (1.0 - math.cos(y)))))) / (3.0 + (3.0 * ((0.5 * t_0) - (0.5 * (math.cos(y) * (math.sqrt(5.0) * (1.0 - (3.0 * (1.0 / math.sqrt(5.0)))))))))) else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(sqrt(5.0) - 1.0) t_1 = Float64(0.3333333333333333 * Float64(Float64(2.0 + Float64(sqrt(2.0) * Float64(-0.0625 * Float64((sin(x) ^ 2.0) * Float64(cos(x) - 1.0))))) / Float64(1.0 + Float64(Float64(0.5 * Float64(cos(x) * t_0)) + Float64(0.5 * Float64(cos(y) * Float64(3.0 - sqrt(5.0)))))))) tmp = 0.0 if (x <= -0.024) tmp = t_1; elseif (x <= 1.45e-5) tmp = Float64(Float64(2.0 + Float64(-0.0625 * Float64((sin(y) ^ 2.0) * Float64(sqrt(2.0) * Float64(1.0 - cos(y)))))) / Float64(3.0 + Float64(3.0 * Float64(Float64(0.5 * t_0) - Float64(0.5 * Float64(cos(y) * Float64(sqrt(5.0) * Float64(1.0 - Float64(3.0 * Float64(1.0 / sqrt(5.0))))))))))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = sqrt(5.0) - 1.0; t_1 = 0.3333333333333333 * ((2.0 + (sqrt(2.0) * (-0.0625 * ((sin(x) ^ 2.0) * (cos(x) - 1.0))))) / (1.0 + ((0.5 * (cos(x) * t_0)) + (0.5 * (cos(y) * (3.0 - sqrt(5.0))))))); tmp = 0.0; if (x <= -0.024) tmp = t_1; elseif (x <= 1.45e-5) tmp = (2.0 + (-0.0625 * ((sin(y) ^ 2.0) * (sqrt(2.0) * (1.0 - cos(y)))))) / (3.0 + (3.0 * ((0.5 * t_0) - (0.5 * (cos(y) * (sqrt(5.0) * (1.0 - (3.0 * (1.0 / sqrt(5.0)))))))))); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(0.3333333333333333 * N[(N[(2.0 + N[(N[Sqrt[2.0], $MachinePrecision] * N[(-0.0625 * N[(N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(0.5 * N[(N[Cos[x], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[Cos[y], $MachinePrecision] * N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.024], t$95$1, If[LessEqual[x, 1.45e-5], N[(N[(2.0 + N[(-0.0625 * N[(N[Power[N[Sin[y], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(3.0 * N[(N[(0.5 * t$95$0), $MachinePrecision] - N[(0.5 * N[(N[Cos[y], $MachinePrecision] * N[(N[Sqrt[5.0], $MachinePrecision] * N[(1.0 - N[(3.0 * N[(1.0 / N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \sqrt{5} - 1\\
t_1 := 0.3333333333333333 \cdot \frac{2 + \sqrt{2} \cdot \left(-0.0625 \cdot \left({\sin x}^{2} \cdot \left(\cos x - 1\right)\right)\right)}{1 + \left(0.5 \cdot \left(\cos x \cdot t\_0\right) + 0.5 \cdot \left(\cos y \cdot \left(3 - \sqrt{5}\right)\right)\right)}\\
\mathbf{if}\;x \leq -0.024:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{2 + -0.0625 \cdot \left({\sin y}^{2} \cdot \left(\sqrt{2} \cdot \left(1 - \cos y\right)\right)\right)}{3 + 3 \cdot \left(0.5 \cdot t\_0 - 0.5 \cdot \left(\cos y \cdot \left(\sqrt{5} \cdot \left(1 - 3 \cdot \frac{1}{\sqrt{5}}\right)\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if x < -0.024 or 1.45e-5 < x Initial program 99.3%
Taylor expanded in x around inf
Applied rewrites99.2%
Taylor expanded in y around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower--.f64N/A
lower-cos.f6461.7%
Applied rewrites61.7%
if -0.024 < x < 1.45e-5Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f6499.3%
Applied rewrites99.3%
Taylor expanded in x around 0
lower-/.f64N/A
Applied rewrites59.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* (- (cos x) 1.0) (sqrt 2.0)))
(t_1 (- (sqrt 5.0) 1.0))
(t_2 (- (* (- (* t_1 (cos x)) (- (sqrt 5.0) 3.0)) 0.5) -1.0))
(t_3 (- 0.5 (* 0.5 (cos (* 2.0 x))))))
(if (<= x -175000000.0)
(*
0.3333333333333333
(/ 1.0 (/ t_2 (- (* (* -0.0625 t_0) t_3) -2.0))))
(if (<= x 1.45e-5)
(/
(+
2.0
(*
-0.0625
(* (pow (sin y) 2.0) (* (sqrt 2.0) (- 1.0 (cos y))))))
(+
3.0
(*
3.0
(-
(* 0.5 t_1)
(*
0.5
(*
(cos y)
(* (sqrt 5.0) (- 1.0 (* 3.0 (/ 1.0 (sqrt 5.0)))))))))))
(*
0.3333333333333333
(- (/ 2.0 t_2) (/ (* (* 0.0625 t_0) t_3) t_2)))))))double code(double x, double y) {
double t_0 = (cos(x) - 1.0) * sqrt(2.0);
double t_1 = sqrt(5.0) - 1.0;
double t_2 = (((t_1 * cos(x)) - (sqrt(5.0) - 3.0)) * 0.5) - -1.0;
double t_3 = 0.5 - (0.5 * cos((2.0 * x)));
double tmp;
if (x <= -175000000.0) {
tmp = 0.3333333333333333 * (1.0 / (t_2 / (((-0.0625 * t_0) * t_3) - -2.0)));
} else if (x <= 1.45e-5) {
tmp = (2.0 + (-0.0625 * (pow(sin(y), 2.0) * (sqrt(2.0) * (1.0 - cos(y)))))) / (3.0 + (3.0 * ((0.5 * t_1) - (0.5 * (cos(y) * (sqrt(5.0) * (1.0 - (3.0 * (1.0 / sqrt(5.0))))))))));
} else {
tmp = 0.3333333333333333 * ((2.0 / t_2) - (((0.0625 * t_0) * t_3) / t_2));
}
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 = (cos(x) - 1.0d0) * sqrt(2.0d0)
t_1 = sqrt(5.0d0) - 1.0d0
t_2 = (((t_1 * cos(x)) - (sqrt(5.0d0) - 3.0d0)) * 0.5d0) - (-1.0d0)
t_3 = 0.5d0 - (0.5d0 * cos((2.0d0 * x)))
if (x <= (-175000000.0d0)) then
tmp = 0.3333333333333333d0 * (1.0d0 / (t_2 / ((((-0.0625d0) * t_0) * t_3) - (-2.0d0))))
else if (x <= 1.45d-5) then
tmp = (2.0d0 + ((-0.0625d0) * ((sin(y) ** 2.0d0) * (sqrt(2.0d0) * (1.0d0 - cos(y)))))) / (3.0d0 + (3.0d0 * ((0.5d0 * t_1) - (0.5d0 * (cos(y) * (sqrt(5.0d0) * (1.0d0 - (3.0d0 * (1.0d0 / sqrt(5.0d0))))))))))
else
tmp = 0.3333333333333333d0 * ((2.0d0 / t_2) - (((0.0625d0 * t_0) * t_3) / t_2))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (Math.cos(x) - 1.0) * Math.sqrt(2.0);
double t_1 = Math.sqrt(5.0) - 1.0;
double t_2 = (((t_1 * Math.cos(x)) - (Math.sqrt(5.0) - 3.0)) * 0.5) - -1.0;
double t_3 = 0.5 - (0.5 * Math.cos((2.0 * x)));
double tmp;
if (x <= -175000000.0) {
tmp = 0.3333333333333333 * (1.0 / (t_2 / (((-0.0625 * t_0) * t_3) - -2.0)));
} else if (x <= 1.45e-5) {
tmp = (2.0 + (-0.0625 * (Math.pow(Math.sin(y), 2.0) * (Math.sqrt(2.0) * (1.0 - Math.cos(y)))))) / (3.0 + (3.0 * ((0.5 * t_1) - (0.5 * (Math.cos(y) * (Math.sqrt(5.0) * (1.0 - (3.0 * (1.0 / Math.sqrt(5.0))))))))));
} else {
tmp = 0.3333333333333333 * ((2.0 / t_2) - (((0.0625 * t_0) * t_3) / t_2));
}
return tmp;
}
def code(x, y): t_0 = (math.cos(x) - 1.0) * math.sqrt(2.0) t_1 = math.sqrt(5.0) - 1.0 t_2 = (((t_1 * math.cos(x)) - (math.sqrt(5.0) - 3.0)) * 0.5) - -1.0 t_3 = 0.5 - (0.5 * math.cos((2.0 * x))) tmp = 0 if x <= -175000000.0: tmp = 0.3333333333333333 * (1.0 / (t_2 / (((-0.0625 * t_0) * t_3) - -2.0))) elif x <= 1.45e-5: tmp = (2.0 + (-0.0625 * (math.pow(math.sin(y), 2.0) * (math.sqrt(2.0) * (1.0 - math.cos(y)))))) / (3.0 + (3.0 * ((0.5 * t_1) - (0.5 * (math.cos(y) * (math.sqrt(5.0) * (1.0 - (3.0 * (1.0 / math.sqrt(5.0)))))))))) else: tmp = 0.3333333333333333 * ((2.0 / t_2) - (((0.0625 * t_0) * t_3) / t_2)) return tmp
function code(x, y) t_0 = Float64(Float64(cos(x) - 1.0) * sqrt(2.0)) t_1 = Float64(sqrt(5.0) - 1.0) t_2 = Float64(Float64(Float64(Float64(t_1 * cos(x)) - Float64(sqrt(5.0) - 3.0)) * 0.5) - -1.0) t_3 = Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * x)))) tmp = 0.0 if (x <= -175000000.0) tmp = Float64(0.3333333333333333 * Float64(1.0 / Float64(t_2 / Float64(Float64(Float64(-0.0625 * t_0) * t_3) - -2.0)))); elseif (x <= 1.45e-5) tmp = Float64(Float64(2.0 + Float64(-0.0625 * Float64((sin(y) ^ 2.0) * Float64(sqrt(2.0) * Float64(1.0 - cos(y)))))) / Float64(3.0 + Float64(3.0 * Float64(Float64(0.5 * t_1) - Float64(0.5 * Float64(cos(y) * Float64(sqrt(5.0) * Float64(1.0 - Float64(3.0 * Float64(1.0 / sqrt(5.0))))))))))); else tmp = Float64(0.3333333333333333 * Float64(Float64(2.0 / t_2) - Float64(Float64(Float64(0.0625 * t_0) * t_3) / t_2))); end return tmp end
function tmp_2 = code(x, y) t_0 = (cos(x) - 1.0) * sqrt(2.0); t_1 = sqrt(5.0) - 1.0; t_2 = (((t_1 * cos(x)) - (sqrt(5.0) - 3.0)) * 0.5) - -1.0; t_3 = 0.5 - (0.5 * cos((2.0 * x))); tmp = 0.0; if (x <= -175000000.0) tmp = 0.3333333333333333 * (1.0 / (t_2 / (((-0.0625 * t_0) * t_3) - -2.0))); elseif (x <= 1.45e-5) tmp = (2.0 + (-0.0625 * ((sin(y) ^ 2.0) * (sqrt(2.0) * (1.0 - cos(y)))))) / (3.0 + (3.0 * ((0.5 * t_1) - (0.5 * (cos(y) * (sqrt(5.0) * (1.0 - (3.0 * (1.0 / sqrt(5.0)))))))))); else tmp = 0.3333333333333333 * ((2.0 / t_2) - (((0.0625 * t_0) * t_3) / t_2)); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(t$95$1 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] - -1.0), $MachinePrecision]}, Block[{t$95$3 = N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -175000000.0], N[(0.3333333333333333 * N[(1.0 / N[(t$95$2 / N[(N[(N[(-0.0625 * t$95$0), $MachinePrecision] * t$95$3), $MachinePrecision] - -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e-5], N[(N[(2.0 + N[(-0.0625 * N[(N[Power[N[Sin[y], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(3.0 * N[(N[(0.5 * t$95$1), $MachinePrecision] - N[(0.5 * N[(N[Cos[y], $MachinePrecision] * N[(N[Sqrt[5.0], $MachinePrecision] * N[(1.0 - N[(3.0 * N[(1.0 / N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[(N[(2.0 / t$95$2), $MachinePrecision] - N[(N[(N[(0.0625 * t$95$0), $MachinePrecision] * t$95$3), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \left(\cos x - 1\right) \cdot \sqrt{2}\\
t_1 := \sqrt{5} - 1\\
t_2 := \left(t\_1 \cdot \cos x - \left(\sqrt{5} - 3\right)\right) \cdot 0.5 - -1\\
t_3 := 0.5 - 0.5 \cdot \cos \left(2 \cdot x\right)\\
\mathbf{if}\;x \leq -175000000:\\
\;\;\;\;0.3333333333333333 \cdot \frac{1}{\frac{t\_2}{\left(-0.0625 \cdot t\_0\right) \cdot t\_3 - -2}}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{2 + -0.0625 \cdot \left({\sin y}^{2} \cdot \left(\sqrt{2} \cdot \left(1 - \cos y\right)\right)\right)}{3 + 3 \cdot \left(0.5 \cdot t\_1 - 0.5 \cdot \left(\cos y \cdot \left(\sqrt{5} \cdot \left(1 - 3 \cdot \frac{1}{\sqrt{5}}\right)\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \left(\frac{2}{t\_2} - \frac{\left(0.0625 \cdot t\_0\right) \cdot t\_3}{t\_2}\right)\\
\end{array}
if x < -1.75e8Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Applied rewrites59.4%
if -1.75e8 < x < 1.45e-5Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f6499.3%
Applied rewrites99.3%
Taylor expanded in x around 0
lower-/.f64N/A
Applied rewrites59.6%
if 1.45e-5 < x Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Applied rewrites59.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (cos x) 1.0))
(t_1 (- (sqrt 5.0) 1.0))
(t_2 (- 0.5 (* 0.5 (cos (* 2.0 x))))))
(if (<= x -175000000.0)
(*
0.3333333333333333
(/
1.0
(/
(- (* (- (* t_1 (cos x)) (- (sqrt 5.0) 3.0)) 0.5) -1.0)
(- (* (* -0.0625 (* t_0 (sqrt 2.0))) t_2) -2.0))))
(if (<= x 1.45e-5)
(/
(+
2.0
(*
-0.0625
(* (pow (sin y) 2.0) (* (sqrt 2.0) (- 1.0 (cos y))))))
(+
3.0
(*
3.0
(-
(* 0.5 t_1)
(*
0.5
(*
(cos y)
(* (sqrt 5.0) (- 1.0 (* 3.0 (/ 1.0 (sqrt 5.0)))))))))))
(*
0.3333333333333333
(/
(+ 2.0 (* (* t_2 (sqrt 2.0)) (* t_0 -0.0625)))
(+
1.0
(+ (* 0.5 (* (cos x) t_1)) (* 0.5 (- 3.0 (sqrt 5.0)))))))))))double code(double x, double y) {
double t_0 = cos(x) - 1.0;
double t_1 = sqrt(5.0) - 1.0;
double t_2 = 0.5 - (0.5 * cos((2.0 * x)));
double tmp;
if (x <= -175000000.0) {
tmp = 0.3333333333333333 * (1.0 / (((((t_1 * cos(x)) - (sqrt(5.0) - 3.0)) * 0.5) - -1.0) / (((-0.0625 * (t_0 * sqrt(2.0))) * t_2) - -2.0)));
} else if (x <= 1.45e-5) {
tmp = (2.0 + (-0.0625 * (pow(sin(y), 2.0) * (sqrt(2.0) * (1.0 - cos(y)))))) / (3.0 + (3.0 * ((0.5 * t_1) - (0.5 * (cos(y) * (sqrt(5.0) * (1.0 - (3.0 * (1.0 / sqrt(5.0))))))))));
} else {
tmp = 0.3333333333333333 * ((2.0 + ((t_2 * sqrt(2.0)) * (t_0 * -0.0625))) / (1.0 + ((0.5 * (cos(x) * t_1)) + (0.5 * (3.0 - sqrt(5.0))))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(x) - 1.0d0
t_1 = sqrt(5.0d0) - 1.0d0
t_2 = 0.5d0 - (0.5d0 * cos((2.0d0 * x)))
if (x <= (-175000000.0d0)) then
tmp = 0.3333333333333333d0 * (1.0d0 / (((((t_1 * cos(x)) - (sqrt(5.0d0) - 3.0d0)) * 0.5d0) - (-1.0d0)) / ((((-0.0625d0) * (t_0 * sqrt(2.0d0))) * t_2) - (-2.0d0))))
else if (x <= 1.45d-5) then
tmp = (2.0d0 + ((-0.0625d0) * ((sin(y) ** 2.0d0) * (sqrt(2.0d0) * (1.0d0 - cos(y)))))) / (3.0d0 + (3.0d0 * ((0.5d0 * t_1) - (0.5d0 * (cos(y) * (sqrt(5.0d0) * (1.0d0 - (3.0d0 * (1.0d0 / sqrt(5.0d0))))))))))
else
tmp = 0.3333333333333333d0 * ((2.0d0 + ((t_2 * sqrt(2.0d0)) * (t_0 * (-0.0625d0)))) / (1.0d0 + ((0.5d0 * (cos(x) * t_1)) + (0.5d0 * (3.0d0 - sqrt(5.0d0))))))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.cos(x) - 1.0;
double t_1 = Math.sqrt(5.0) - 1.0;
double t_2 = 0.5 - (0.5 * Math.cos((2.0 * x)));
double tmp;
if (x <= -175000000.0) {
tmp = 0.3333333333333333 * (1.0 / (((((t_1 * Math.cos(x)) - (Math.sqrt(5.0) - 3.0)) * 0.5) - -1.0) / (((-0.0625 * (t_0 * Math.sqrt(2.0))) * t_2) - -2.0)));
} else if (x <= 1.45e-5) {
tmp = (2.0 + (-0.0625 * (Math.pow(Math.sin(y), 2.0) * (Math.sqrt(2.0) * (1.0 - Math.cos(y)))))) / (3.0 + (3.0 * ((0.5 * t_1) - (0.5 * (Math.cos(y) * (Math.sqrt(5.0) * (1.0 - (3.0 * (1.0 / Math.sqrt(5.0))))))))));
} else {
tmp = 0.3333333333333333 * ((2.0 + ((t_2 * Math.sqrt(2.0)) * (t_0 * -0.0625))) / (1.0 + ((0.5 * (Math.cos(x) * t_1)) + (0.5 * (3.0 - Math.sqrt(5.0))))));
}
return tmp;
}
def code(x, y): t_0 = math.cos(x) - 1.0 t_1 = math.sqrt(5.0) - 1.0 t_2 = 0.5 - (0.5 * math.cos((2.0 * x))) tmp = 0 if x <= -175000000.0: tmp = 0.3333333333333333 * (1.0 / (((((t_1 * math.cos(x)) - (math.sqrt(5.0) - 3.0)) * 0.5) - -1.0) / (((-0.0625 * (t_0 * math.sqrt(2.0))) * t_2) - -2.0))) elif x <= 1.45e-5: tmp = (2.0 + (-0.0625 * (math.pow(math.sin(y), 2.0) * (math.sqrt(2.0) * (1.0 - math.cos(y)))))) / (3.0 + (3.0 * ((0.5 * t_1) - (0.5 * (math.cos(y) * (math.sqrt(5.0) * (1.0 - (3.0 * (1.0 / math.sqrt(5.0)))))))))) else: tmp = 0.3333333333333333 * ((2.0 + ((t_2 * math.sqrt(2.0)) * (t_0 * -0.0625))) / (1.0 + ((0.5 * (math.cos(x) * t_1)) + (0.5 * (3.0 - math.sqrt(5.0)))))) return tmp
function code(x, y) t_0 = Float64(cos(x) - 1.0) t_1 = Float64(sqrt(5.0) - 1.0) t_2 = Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * x)))) tmp = 0.0 if (x <= -175000000.0) tmp = Float64(0.3333333333333333 * Float64(1.0 / Float64(Float64(Float64(Float64(Float64(t_1 * cos(x)) - Float64(sqrt(5.0) - 3.0)) * 0.5) - -1.0) / Float64(Float64(Float64(-0.0625 * Float64(t_0 * sqrt(2.0))) * t_2) - -2.0)))); elseif (x <= 1.45e-5) tmp = Float64(Float64(2.0 + Float64(-0.0625 * Float64((sin(y) ^ 2.0) * Float64(sqrt(2.0) * Float64(1.0 - cos(y)))))) / Float64(3.0 + Float64(3.0 * Float64(Float64(0.5 * t_1) - Float64(0.5 * Float64(cos(y) * Float64(sqrt(5.0) * Float64(1.0 - Float64(3.0 * Float64(1.0 / sqrt(5.0))))))))))); else tmp = Float64(0.3333333333333333 * Float64(Float64(2.0 + Float64(Float64(t_2 * sqrt(2.0)) * Float64(t_0 * -0.0625))) / Float64(1.0 + Float64(Float64(0.5 * Float64(cos(x) * t_1)) + Float64(0.5 * Float64(3.0 - sqrt(5.0))))))); end return tmp end
function tmp_2 = code(x, y) t_0 = cos(x) - 1.0; t_1 = sqrt(5.0) - 1.0; t_2 = 0.5 - (0.5 * cos((2.0 * x))); tmp = 0.0; if (x <= -175000000.0) tmp = 0.3333333333333333 * (1.0 / (((((t_1 * cos(x)) - (sqrt(5.0) - 3.0)) * 0.5) - -1.0) / (((-0.0625 * (t_0 * sqrt(2.0))) * t_2) - -2.0))); elseif (x <= 1.45e-5) tmp = (2.0 + (-0.0625 * ((sin(y) ^ 2.0) * (sqrt(2.0) * (1.0 - cos(y)))))) / (3.0 + (3.0 * ((0.5 * t_1) - (0.5 * (cos(y) * (sqrt(5.0) * (1.0 - (3.0 * (1.0 / sqrt(5.0)))))))))); else tmp = 0.3333333333333333 * ((2.0 + ((t_2 * sqrt(2.0)) * (t_0 * -0.0625))) / (1.0 + ((0.5 * (cos(x) * t_1)) + (0.5 * (3.0 - sqrt(5.0)))))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -175000000.0], N[(0.3333333333333333 * N[(1.0 / N[(N[(N[(N[(N[(t$95$1 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] - -1.0), $MachinePrecision] / N[(N[(N[(-0.0625 * N[(t$95$0 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] - -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e-5], N[(N[(2.0 + N[(-0.0625 * N[(N[Power[N[Sin[y], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(3.0 * N[(N[(0.5 * t$95$1), $MachinePrecision] - N[(0.5 * N[(N[Cos[y], $MachinePrecision] * N[(N[Sqrt[5.0], $MachinePrecision] * N[(1.0 - N[(3.0 * N[(1.0 / N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[(N[(2.0 + N[(N[(t$95$2 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * -0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(0.5 * N[(N[Cos[x], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \cos x - 1\\
t_1 := \sqrt{5} - 1\\
t_2 := 0.5 - 0.5 \cdot \cos \left(2 \cdot x\right)\\
\mathbf{if}\;x \leq -175000000:\\
\;\;\;\;0.3333333333333333 \cdot \frac{1}{\frac{\left(t\_1 \cdot \cos x - \left(\sqrt{5} - 3\right)\right) \cdot 0.5 - -1}{\left(-0.0625 \cdot \left(t\_0 \cdot \sqrt{2}\right)\right) \cdot t\_2 - -2}}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{2 + -0.0625 \cdot \left({\sin y}^{2} \cdot \left(\sqrt{2} \cdot \left(1 - \cos y\right)\right)\right)}{3 + 3 \cdot \left(0.5 \cdot t\_1 - 0.5 \cdot \left(\cos y \cdot \left(\sqrt{5} \cdot \left(1 - 3 \cdot \frac{1}{\sqrt{5}}\right)\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{2 + \left(t\_2 \cdot \sqrt{2}\right) \cdot \left(t\_0 \cdot -0.0625\right)}{1 + \left(0.5 \cdot \left(\cos x \cdot t\_1\right) + 0.5 \cdot \left(3 - \sqrt{5}\right)\right)}\\
\end{array}
if x < -1.75e8Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Applied rewrites59.4%
if -1.75e8 < x < 1.45e-5Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f6499.3%
Applied rewrites99.3%
Taylor expanded in x around 0
lower-/.f64N/A
Applied rewrites59.6%
if 1.45e-5 < x Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f6459.4%
Applied rewrites59.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (sqrt 5.0) 3.0))
(t_1 (- (cos x) 1.0))
(t_2 (- (sqrt 5.0) 1.0))
(t_3 (- 0.5 (* 0.5 (cos (* 2.0 x))))))
(if (<= x -175000000.0)
(*
0.3333333333333333
(/
1.0
(/
(- (* (- (* t_2 (cos x)) t_0) 0.5) -1.0)
(- (* (* -0.0625 (* t_1 (sqrt 2.0))) t_3) -2.0))))
(if (<= x 1.45e-5)
(/
(+
2.0
(*
-0.0625
(* (pow (sin y) 2.0) (* (sqrt 2.0) (- 1.0 (cos y))))))
(+ 3.0 (* 3.0 (- (* 0.5 t_2) (* 0.5 (* (cos y) t_0))))))
(*
0.3333333333333333
(/
(+ 2.0 (* (* t_3 (sqrt 2.0)) (* t_1 -0.0625)))
(+
1.0
(+ (* 0.5 (* (cos x) t_2)) (* 0.5 (- 3.0 (sqrt 5.0)))))))))))double code(double x, double y) {
double t_0 = sqrt(5.0) - 3.0;
double t_1 = cos(x) - 1.0;
double t_2 = sqrt(5.0) - 1.0;
double t_3 = 0.5 - (0.5 * cos((2.0 * x)));
double tmp;
if (x <= -175000000.0) {
tmp = 0.3333333333333333 * (1.0 / (((((t_2 * cos(x)) - t_0) * 0.5) - -1.0) / (((-0.0625 * (t_1 * sqrt(2.0))) * t_3) - -2.0)));
} else if (x <= 1.45e-5) {
tmp = (2.0 + (-0.0625 * (pow(sin(y), 2.0) * (sqrt(2.0) * (1.0 - cos(y)))))) / (3.0 + (3.0 * ((0.5 * t_2) - (0.5 * (cos(y) * t_0)))));
} else {
tmp = 0.3333333333333333 * ((2.0 + ((t_3 * sqrt(2.0)) * (t_1 * -0.0625))) / (1.0 + ((0.5 * (cos(x) * t_2)) + (0.5 * (3.0 - sqrt(5.0))))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sqrt(5.0d0) - 3.0d0
t_1 = cos(x) - 1.0d0
t_2 = sqrt(5.0d0) - 1.0d0
t_3 = 0.5d0 - (0.5d0 * cos((2.0d0 * x)))
if (x <= (-175000000.0d0)) then
tmp = 0.3333333333333333d0 * (1.0d0 / (((((t_2 * cos(x)) - t_0) * 0.5d0) - (-1.0d0)) / ((((-0.0625d0) * (t_1 * sqrt(2.0d0))) * t_3) - (-2.0d0))))
else if (x <= 1.45d-5) then
tmp = (2.0d0 + ((-0.0625d0) * ((sin(y) ** 2.0d0) * (sqrt(2.0d0) * (1.0d0 - cos(y)))))) / (3.0d0 + (3.0d0 * ((0.5d0 * t_2) - (0.5d0 * (cos(y) * t_0)))))
else
tmp = 0.3333333333333333d0 * ((2.0d0 + ((t_3 * sqrt(2.0d0)) * (t_1 * (-0.0625d0)))) / (1.0d0 + ((0.5d0 * (cos(x) * t_2)) + (0.5d0 * (3.0d0 - sqrt(5.0d0))))))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.sqrt(5.0) - 3.0;
double t_1 = Math.cos(x) - 1.0;
double t_2 = Math.sqrt(5.0) - 1.0;
double t_3 = 0.5 - (0.5 * Math.cos((2.0 * x)));
double tmp;
if (x <= -175000000.0) {
tmp = 0.3333333333333333 * (1.0 / (((((t_2 * Math.cos(x)) - t_0) * 0.5) - -1.0) / (((-0.0625 * (t_1 * Math.sqrt(2.0))) * t_3) - -2.0)));
} else if (x <= 1.45e-5) {
tmp = (2.0 + (-0.0625 * (Math.pow(Math.sin(y), 2.0) * (Math.sqrt(2.0) * (1.0 - Math.cos(y)))))) / (3.0 + (3.0 * ((0.5 * t_2) - (0.5 * (Math.cos(y) * t_0)))));
} else {
tmp = 0.3333333333333333 * ((2.0 + ((t_3 * Math.sqrt(2.0)) * (t_1 * -0.0625))) / (1.0 + ((0.5 * (Math.cos(x) * t_2)) + (0.5 * (3.0 - Math.sqrt(5.0))))));
}
return tmp;
}
def code(x, y): t_0 = math.sqrt(5.0) - 3.0 t_1 = math.cos(x) - 1.0 t_2 = math.sqrt(5.0) - 1.0 t_3 = 0.5 - (0.5 * math.cos((2.0 * x))) tmp = 0 if x <= -175000000.0: tmp = 0.3333333333333333 * (1.0 / (((((t_2 * math.cos(x)) - t_0) * 0.5) - -1.0) / (((-0.0625 * (t_1 * math.sqrt(2.0))) * t_3) - -2.0))) elif x <= 1.45e-5: tmp = (2.0 + (-0.0625 * (math.pow(math.sin(y), 2.0) * (math.sqrt(2.0) * (1.0 - math.cos(y)))))) / (3.0 + (3.0 * ((0.5 * t_2) - (0.5 * (math.cos(y) * t_0))))) else: tmp = 0.3333333333333333 * ((2.0 + ((t_3 * math.sqrt(2.0)) * (t_1 * -0.0625))) / (1.0 + ((0.5 * (math.cos(x) * t_2)) + (0.5 * (3.0 - math.sqrt(5.0)))))) return tmp
function code(x, y) t_0 = Float64(sqrt(5.0) - 3.0) t_1 = Float64(cos(x) - 1.0) t_2 = Float64(sqrt(5.0) - 1.0) t_3 = Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * x)))) tmp = 0.0 if (x <= -175000000.0) tmp = Float64(0.3333333333333333 * Float64(1.0 / Float64(Float64(Float64(Float64(Float64(t_2 * cos(x)) - t_0) * 0.5) - -1.0) / Float64(Float64(Float64(-0.0625 * Float64(t_1 * sqrt(2.0))) * t_3) - -2.0)))); elseif (x <= 1.45e-5) tmp = Float64(Float64(2.0 + Float64(-0.0625 * Float64((sin(y) ^ 2.0) * Float64(sqrt(2.0) * Float64(1.0 - cos(y)))))) / Float64(3.0 + Float64(3.0 * Float64(Float64(0.5 * t_2) - Float64(0.5 * Float64(cos(y) * t_0)))))); else tmp = Float64(0.3333333333333333 * Float64(Float64(2.0 + Float64(Float64(t_3 * sqrt(2.0)) * Float64(t_1 * -0.0625))) / Float64(1.0 + Float64(Float64(0.5 * Float64(cos(x) * t_2)) + Float64(0.5 * Float64(3.0 - sqrt(5.0))))))); end return tmp end
function tmp_2 = code(x, y) t_0 = sqrt(5.0) - 3.0; t_1 = cos(x) - 1.0; t_2 = sqrt(5.0) - 1.0; t_3 = 0.5 - (0.5 * cos((2.0 * x))); tmp = 0.0; if (x <= -175000000.0) tmp = 0.3333333333333333 * (1.0 / (((((t_2 * cos(x)) - t_0) * 0.5) - -1.0) / (((-0.0625 * (t_1 * sqrt(2.0))) * t_3) - -2.0))); elseif (x <= 1.45e-5) tmp = (2.0 + (-0.0625 * ((sin(y) ^ 2.0) * (sqrt(2.0) * (1.0 - cos(y)))))) / (3.0 + (3.0 * ((0.5 * t_2) - (0.5 * (cos(y) * t_0))))); else tmp = 0.3333333333333333 * ((2.0 + ((t_3 * sqrt(2.0)) * (t_1 * -0.0625))) / (1.0 + ((0.5 * (cos(x) * t_2)) + (0.5 * (3.0 - sqrt(5.0)))))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$3 = N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -175000000.0], N[(0.3333333333333333 * N[(1.0 / N[(N[(N[(N[(N[(t$95$2 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] - -1.0), $MachinePrecision] / N[(N[(N[(-0.0625 * N[(t$95$1 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision] - -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e-5], N[(N[(2.0 + N[(-0.0625 * N[(N[Power[N[Sin[y], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 + N[(3.0 * N[(N[(0.5 * t$95$2), $MachinePrecision] - N[(0.5 * N[(N[Cos[y], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[(N[(2.0 + N[(N[(t$95$3 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * -0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(0.5 * N[(N[Cos[x], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \sqrt{5} - 3\\
t_1 := \cos x - 1\\
t_2 := \sqrt{5} - 1\\
t_3 := 0.5 - 0.5 \cdot \cos \left(2 \cdot x\right)\\
\mathbf{if}\;x \leq -175000000:\\
\;\;\;\;0.3333333333333333 \cdot \frac{1}{\frac{\left(t\_2 \cdot \cos x - t\_0\right) \cdot 0.5 - -1}{\left(-0.0625 \cdot \left(t\_1 \cdot \sqrt{2}\right)\right) \cdot t\_3 - -2}}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{2 + -0.0625 \cdot \left({\sin y}^{2} \cdot \left(\sqrt{2} \cdot \left(1 - \cos y\right)\right)\right)}{3 + 3 \cdot \left(0.5 \cdot t\_2 - 0.5 \cdot \left(\cos y \cdot t\_0\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{2 + \left(t\_3 \cdot \sqrt{2}\right) \cdot \left(t\_1 \cdot -0.0625\right)}{1 + \left(0.5 \cdot \left(\cos x \cdot t\_2\right) + 0.5 \cdot \left(3 - \sqrt{5}\right)\right)}\\
\end{array}
if x < -1.75e8Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Applied rewrites59.4%
if -1.75e8 < x < 1.45e-5Initial program 99.3%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
distribute-rgt-inN/A
metadata-evalN/A
lower-+.f64N/A
lower-*.f64N/A
Applied rewrites99.3%
Taylor expanded in x around 0
lower-/.f64N/A
Applied rewrites59.6%
if 1.45e-5 < x Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f6459.4%
Applied rewrites59.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (cos x) 1.0))
(t_1 (- (sqrt 5.0) 1.0))
(t_2 (- 0.5 (* 0.5 (cos (* 2.0 x))))))
(if (<= x -175000000.0)
(*
0.3333333333333333
(/
1.0
(/
(- (* (- (* t_1 (cos x)) (- (sqrt 5.0) 3.0)) 0.5) -1.0)
(- (* (* -0.0625 (* t_0 (sqrt 2.0))) t_2) -2.0))))
(if (<= x 1.45e-5)
(/
(+
2.0
(*
-0.0625
(* (pow (sin y) 2.0) (* (sqrt 2.0) (- 1.0 (cos y))))))
(*
3.0
(+
1.0
(+ (* 0.5 (* (cos y) 0.7639320225002103)) (* 0.5 t_1)))))
(*
0.3333333333333333
(/
(+ 2.0 (* (* t_2 (sqrt 2.0)) (* t_0 -0.0625)))
(+
1.0
(+ (* 0.5 (* (cos x) t_1)) (* 0.5 (- 3.0 (sqrt 5.0)))))))))))double code(double x, double y) {
double t_0 = cos(x) - 1.0;
double t_1 = sqrt(5.0) - 1.0;
double t_2 = 0.5 - (0.5 * cos((2.0 * x)));
double tmp;
if (x <= -175000000.0) {
tmp = 0.3333333333333333 * (1.0 / (((((t_1 * cos(x)) - (sqrt(5.0) - 3.0)) * 0.5) - -1.0) / (((-0.0625 * (t_0 * sqrt(2.0))) * t_2) - -2.0)));
} else if (x <= 1.45e-5) {
tmp = (2.0 + (-0.0625 * (pow(sin(y), 2.0) * (sqrt(2.0) * (1.0 - cos(y)))))) / (3.0 * (1.0 + ((0.5 * (cos(y) * 0.7639320225002103)) + (0.5 * t_1))));
} else {
tmp = 0.3333333333333333 * ((2.0 + ((t_2 * sqrt(2.0)) * (t_0 * -0.0625))) / (1.0 + ((0.5 * (cos(x) * t_1)) + (0.5 * (3.0 - sqrt(5.0))))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(x) - 1.0d0
t_1 = sqrt(5.0d0) - 1.0d0
t_2 = 0.5d0 - (0.5d0 * cos((2.0d0 * x)))
if (x <= (-175000000.0d0)) then
tmp = 0.3333333333333333d0 * (1.0d0 / (((((t_1 * cos(x)) - (sqrt(5.0d0) - 3.0d0)) * 0.5d0) - (-1.0d0)) / ((((-0.0625d0) * (t_0 * sqrt(2.0d0))) * t_2) - (-2.0d0))))
else if (x <= 1.45d-5) then
tmp = (2.0d0 + ((-0.0625d0) * ((sin(y) ** 2.0d0) * (sqrt(2.0d0) * (1.0d0 - cos(y)))))) / (3.0d0 * (1.0d0 + ((0.5d0 * (cos(y) * 0.7639320225002103d0)) + (0.5d0 * t_1))))
else
tmp = 0.3333333333333333d0 * ((2.0d0 + ((t_2 * sqrt(2.0d0)) * (t_0 * (-0.0625d0)))) / (1.0d0 + ((0.5d0 * (cos(x) * t_1)) + (0.5d0 * (3.0d0 - sqrt(5.0d0))))))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.cos(x) - 1.0;
double t_1 = Math.sqrt(5.0) - 1.0;
double t_2 = 0.5 - (0.5 * Math.cos((2.0 * x)));
double tmp;
if (x <= -175000000.0) {
tmp = 0.3333333333333333 * (1.0 / (((((t_1 * Math.cos(x)) - (Math.sqrt(5.0) - 3.0)) * 0.5) - -1.0) / (((-0.0625 * (t_0 * Math.sqrt(2.0))) * t_2) - -2.0)));
} else if (x <= 1.45e-5) {
tmp = (2.0 + (-0.0625 * (Math.pow(Math.sin(y), 2.0) * (Math.sqrt(2.0) * (1.0 - Math.cos(y)))))) / (3.0 * (1.0 + ((0.5 * (Math.cos(y) * 0.7639320225002103)) + (0.5 * t_1))));
} else {
tmp = 0.3333333333333333 * ((2.0 + ((t_2 * Math.sqrt(2.0)) * (t_0 * -0.0625))) / (1.0 + ((0.5 * (Math.cos(x) * t_1)) + (0.5 * (3.0 - Math.sqrt(5.0))))));
}
return tmp;
}
def code(x, y): t_0 = math.cos(x) - 1.0 t_1 = math.sqrt(5.0) - 1.0 t_2 = 0.5 - (0.5 * math.cos((2.0 * x))) tmp = 0 if x <= -175000000.0: tmp = 0.3333333333333333 * (1.0 / (((((t_1 * math.cos(x)) - (math.sqrt(5.0) - 3.0)) * 0.5) - -1.0) / (((-0.0625 * (t_0 * math.sqrt(2.0))) * t_2) - -2.0))) elif x <= 1.45e-5: tmp = (2.0 + (-0.0625 * (math.pow(math.sin(y), 2.0) * (math.sqrt(2.0) * (1.0 - math.cos(y)))))) / (3.0 * (1.0 + ((0.5 * (math.cos(y) * 0.7639320225002103)) + (0.5 * t_1)))) else: tmp = 0.3333333333333333 * ((2.0 + ((t_2 * math.sqrt(2.0)) * (t_0 * -0.0625))) / (1.0 + ((0.5 * (math.cos(x) * t_1)) + (0.5 * (3.0 - math.sqrt(5.0)))))) return tmp
function code(x, y) t_0 = Float64(cos(x) - 1.0) t_1 = Float64(sqrt(5.0) - 1.0) t_2 = Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * x)))) tmp = 0.0 if (x <= -175000000.0) tmp = Float64(0.3333333333333333 * Float64(1.0 / Float64(Float64(Float64(Float64(Float64(t_1 * cos(x)) - Float64(sqrt(5.0) - 3.0)) * 0.5) - -1.0) / Float64(Float64(Float64(-0.0625 * Float64(t_0 * sqrt(2.0))) * t_2) - -2.0)))); elseif (x <= 1.45e-5) tmp = Float64(Float64(2.0 + Float64(-0.0625 * Float64((sin(y) ^ 2.0) * Float64(sqrt(2.0) * Float64(1.0 - cos(y)))))) / Float64(3.0 * Float64(1.0 + Float64(Float64(0.5 * Float64(cos(y) * 0.7639320225002103)) + Float64(0.5 * t_1))))); else tmp = Float64(0.3333333333333333 * Float64(Float64(2.0 + Float64(Float64(t_2 * sqrt(2.0)) * Float64(t_0 * -0.0625))) / Float64(1.0 + Float64(Float64(0.5 * Float64(cos(x) * t_1)) + Float64(0.5 * Float64(3.0 - sqrt(5.0))))))); end return tmp end
function tmp_2 = code(x, y) t_0 = cos(x) - 1.0; t_1 = sqrt(5.0) - 1.0; t_2 = 0.5 - (0.5 * cos((2.0 * x))); tmp = 0.0; if (x <= -175000000.0) tmp = 0.3333333333333333 * (1.0 / (((((t_1 * cos(x)) - (sqrt(5.0) - 3.0)) * 0.5) - -1.0) / (((-0.0625 * (t_0 * sqrt(2.0))) * t_2) - -2.0))); elseif (x <= 1.45e-5) tmp = (2.0 + (-0.0625 * ((sin(y) ^ 2.0) * (sqrt(2.0) * (1.0 - cos(y)))))) / (3.0 * (1.0 + ((0.5 * (cos(y) * 0.7639320225002103)) + (0.5 * t_1)))); else tmp = 0.3333333333333333 * ((2.0 + ((t_2 * sqrt(2.0)) * (t_0 * -0.0625))) / (1.0 + ((0.5 * (cos(x) * t_1)) + (0.5 * (3.0 - sqrt(5.0)))))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -175000000.0], N[(0.3333333333333333 * N[(1.0 / N[(N[(N[(N[(N[(t$95$1 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] - -1.0), $MachinePrecision] / N[(N[(N[(-0.0625 * N[(t$95$0 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] - -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e-5], N[(N[(2.0 + N[(-0.0625 * N[(N[Power[N[Sin[y], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Sqrt[2.0], $MachinePrecision] * N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * N[(1.0 + N[(N[(0.5 * N[(N[Cos[y], $MachinePrecision] * 0.7639320225002103), $MachinePrecision]), $MachinePrecision] + N[(0.5 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[(N[(2.0 + N[(N[(t$95$2 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * -0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(0.5 * N[(N[Cos[x], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \cos x - 1\\
t_1 := \sqrt{5} - 1\\
t_2 := 0.5 - 0.5 \cdot \cos \left(2 \cdot x\right)\\
\mathbf{if}\;x \leq -175000000:\\
\;\;\;\;0.3333333333333333 \cdot \frac{1}{\frac{\left(t\_1 \cdot \cos x - \left(\sqrt{5} - 3\right)\right) \cdot 0.5 - -1}{\left(-0.0625 \cdot \left(t\_0 \cdot \sqrt{2}\right)\right) \cdot t\_2 - -2}}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{2 + -0.0625 \cdot \left({\sin y}^{2} \cdot \left(\sqrt{2} \cdot \left(1 - \cos y\right)\right)\right)}{3 \cdot \left(1 + \left(0.5 \cdot \left(\cos y \cdot 0.7639320225002103\right) + 0.5 \cdot t\_1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{2 + \left(t\_2 \cdot \sqrt{2}\right) \cdot \left(t\_0 \cdot -0.0625\right)}{1 + \left(0.5 \cdot \left(\cos x \cdot t\_1\right) + 0.5 \cdot \left(3 - \sqrt{5}\right)\right)}\\
\end{array}
if x < -1.75e8Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Applied rewrites59.4%
if -1.75e8 < x < 1.45e-5Initial program 99.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f6460.1%
Applied rewrites60.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6459.6%
Applied rewrites59.6%
Evaluated real constant59.6%
if 1.45e-5 < x Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f6459.4%
Applied rewrites59.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (cos x) 1.0))
(t_1 (- 3.0 (sqrt 5.0)))
(t_2 (- (sqrt 5.0) 1.0))
(t_3 (- 0.5 (* 0.5 (cos (* 2.0 x))))))
(if (<= x -175000000.0)
(*
0.3333333333333333
(/
1.0
(/
(- (* (- (* t_2 (cos x)) (- (sqrt 5.0) 3.0)) 0.5) -1.0)
(- (* (* -0.0625 (* t_0 (sqrt 2.0))) t_3) -2.0))))
(if (<= x 1.45e-5)
(/
1.0
(/
(* (- (* 0.5 (+ t_2 (* t_1 (cos y)))) -1.0) 3.0)
(-
(*
(* -0.0625 (* (- 1.0 (cos y)) (sqrt 2.0)))
(- 0.5 (* 0.5 (cos (* 2.0 y)))))
-2.0)))
(*
0.3333333333333333
(/
(+ 2.0 (* (* t_3 (sqrt 2.0)) (* t_0 -0.0625)))
(+ 1.0 (+ (* 0.5 (* (cos x) t_2)) (* 0.5 t_1)))))))))double code(double x, double y) {
double t_0 = cos(x) - 1.0;
double t_1 = 3.0 - sqrt(5.0);
double t_2 = sqrt(5.0) - 1.0;
double t_3 = 0.5 - (0.5 * cos((2.0 * x)));
double tmp;
if (x <= -175000000.0) {
tmp = 0.3333333333333333 * (1.0 / (((((t_2 * cos(x)) - (sqrt(5.0) - 3.0)) * 0.5) - -1.0) / (((-0.0625 * (t_0 * sqrt(2.0))) * t_3) - -2.0)));
} else if (x <= 1.45e-5) {
tmp = 1.0 / ((((0.5 * (t_2 + (t_1 * cos(y)))) - -1.0) * 3.0) / (((-0.0625 * ((1.0 - cos(y)) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * y))))) - -2.0));
} else {
tmp = 0.3333333333333333 * ((2.0 + ((t_3 * sqrt(2.0)) * (t_0 * -0.0625))) / (1.0 + ((0.5 * (cos(x) * t_2)) + (0.5 * t_1))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(x) - 1.0d0
t_1 = 3.0d0 - sqrt(5.0d0)
t_2 = sqrt(5.0d0) - 1.0d0
t_3 = 0.5d0 - (0.5d0 * cos((2.0d0 * x)))
if (x <= (-175000000.0d0)) then
tmp = 0.3333333333333333d0 * (1.0d0 / (((((t_2 * cos(x)) - (sqrt(5.0d0) - 3.0d0)) * 0.5d0) - (-1.0d0)) / ((((-0.0625d0) * (t_0 * sqrt(2.0d0))) * t_3) - (-2.0d0))))
else if (x <= 1.45d-5) then
tmp = 1.0d0 / ((((0.5d0 * (t_2 + (t_1 * cos(y)))) - (-1.0d0)) * 3.0d0) / ((((-0.0625d0) * ((1.0d0 - cos(y)) * sqrt(2.0d0))) * (0.5d0 - (0.5d0 * cos((2.0d0 * y))))) - (-2.0d0)))
else
tmp = 0.3333333333333333d0 * ((2.0d0 + ((t_3 * sqrt(2.0d0)) * (t_0 * (-0.0625d0)))) / (1.0d0 + ((0.5d0 * (cos(x) * t_2)) + (0.5d0 * t_1))))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.cos(x) - 1.0;
double t_1 = 3.0 - Math.sqrt(5.0);
double t_2 = Math.sqrt(5.0) - 1.0;
double t_3 = 0.5 - (0.5 * Math.cos((2.0 * x)));
double tmp;
if (x <= -175000000.0) {
tmp = 0.3333333333333333 * (1.0 / (((((t_2 * Math.cos(x)) - (Math.sqrt(5.0) - 3.0)) * 0.5) - -1.0) / (((-0.0625 * (t_0 * Math.sqrt(2.0))) * t_3) - -2.0)));
} else if (x <= 1.45e-5) {
tmp = 1.0 / ((((0.5 * (t_2 + (t_1 * Math.cos(y)))) - -1.0) * 3.0) / (((-0.0625 * ((1.0 - Math.cos(y)) * Math.sqrt(2.0))) * (0.5 - (0.5 * Math.cos((2.0 * y))))) - -2.0));
} else {
tmp = 0.3333333333333333 * ((2.0 + ((t_3 * Math.sqrt(2.0)) * (t_0 * -0.0625))) / (1.0 + ((0.5 * (Math.cos(x) * t_2)) + (0.5 * t_1))));
}
return tmp;
}
def code(x, y): t_0 = math.cos(x) - 1.0 t_1 = 3.0 - math.sqrt(5.0) t_2 = math.sqrt(5.0) - 1.0 t_3 = 0.5 - (0.5 * math.cos((2.0 * x))) tmp = 0 if x <= -175000000.0: tmp = 0.3333333333333333 * (1.0 / (((((t_2 * math.cos(x)) - (math.sqrt(5.0) - 3.0)) * 0.5) - -1.0) / (((-0.0625 * (t_0 * math.sqrt(2.0))) * t_3) - -2.0))) elif x <= 1.45e-5: tmp = 1.0 / ((((0.5 * (t_2 + (t_1 * math.cos(y)))) - -1.0) * 3.0) / (((-0.0625 * ((1.0 - math.cos(y)) * math.sqrt(2.0))) * (0.5 - (0.5 * math.cos((2.0 * y))))) - -2.0)) else: tmp = 0.3333333333333333 * ((2.0 + ((t_3 * math.sqrt(2.0)) * (t_0 * -0.0625))) / (1.0 + ((0.5 * (math.cos(x) * t_2)) + (0.5 * t_1)))) return tmp
function code(x, y) t_0 = Float64(cos(x) - 1.0) t_1 = Float64(3.0 - sqrt(5.0)) t_2 = Float64(sqrt(5.0) - 1.0) t_3 = Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * x)))) tmp = 0.0 if (x <= -175000000.0) tmp = Float64(0.3333333333333333 * Float64(1.0 / Float64(Float64(Float64(Float64(Float64(t_2 * cos(x)) - Float64(sqrt(5.0) - 3.0)) * 0.5) - -1.0) / Float64(Float64(Float64(-0.0625 * Float64(t_0 * sqrt(2.0))) * t_3) - -2.0)))); elseif (x <= 1.45e-5) tmp = Float64(1.0 / Float64(Float64(Float64(Float64(0.5 * Float64(t_2 + Float64(t_1 * cos(y)))) - -1.0) * 3.0) / Float64(Float64(Float64(-0.0625 * Float64(Float64(1.0 - cos(y)) * sqrt(2.0))) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * y))))) - -2.0))); else tmp = Float64(0.3333333333333333 * Float64(Float64(2.0 + Float64(Float64(t_3 * sqrt(2.0)) * Float64(t_0 * -0.0625))) / Float64(1.0 + Float64(Float64(0.5 * Float64(cos(x) * t_2)) + Float64(0.5 * t_1))))); end return tmp end
function tmp_2 = code(x, y) t_0 = cos(x) - 1.0; t_1 = 3.0 - sqrt(5.0); t_2 = sqrt(5.0) - 1.0; t_3 = 0.5 - (0.5 * cos((2.0 * x))); tmp = 0.0; if (x <= -175000000.0) tmp = 0.3333333333333333 * (1.0 / (((((t_2 * cos(x)) - (sqrt(5.0) - 3.0)) * 0.5) - -1.0) / (((-0.0625 * (t_0 * sqrt(2.0))) * t_3) - -2.0))); elseif (x <= 1.45e-5) tmp = 1.0 / ((((0.5 * (t_2 + (t_1 * cos(y)))) - -1.0) * 3.0) / (((-0.0625 * ((1.0 - cos(y)) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * y))))) - -2.0)); else tmp = 0.3333333333333333 * ((2.0 + ((t_3 * sqrt(2.0)) * (t_0 * -0.0625))) / (1.0 + ((0.5 * (cos(x) * t_2)) + (0.5 * t_1)))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$3 = N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -175000000.0], N[(0.3333333333333333 * N[(1.0 / N[(N[(N[(N[(N[(t$95$2 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] - -1.0), $MachinePrecision] / N[(N[(N[(-0.0625 * N[(t$95$0 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision] - -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e-5], N[(1.0 / N[(N[(N[(N[(0.5 * N[(t$95$2 + N[(t$95$1 * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] * 3.0), $MachinePrecision] / N[(N[(N[(-0.0625 * N[(N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[(N[(2.0 + N[(N[(t$95$3 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * -0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(0.5 * N[(N[Cos[x], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] + N[(0.5 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := \cos x - 1\\
t_1 := 3 - \sqrt{5}\\
t_2 := \sqrt{5} - 1\\
t_3 := 0.5 - 0.5 \cdot \cos \left(2 \cdot x\right)\\
\mathbf{if}\;x \leq -175000000:\\
\;\;\;\;0.3333333333333333 \cdot \frac{1}{\frac{\left(t\_2 \cdot \cos x - \left(\sqrt{5} - 3\right)\right) \cdot 0.5 - -1}{\left(-0.0625 \cdot \left(t\_0 \cdot \sqrt{2}\right)\right) \cdot t\_3 - -2}}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{\frac{\left(0.5 \cdot \left(t\_2 + t\_1 \cdot \cos y\right) - -1\right) \cdot 3}{\left(-0.0625 \cdot \left(\left(1 - \cos y\right) \cdot \sqrt{2}\right)\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot y\right)\right) - -2}}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{2 + \left(t\_3 \cdot \sqrt{2}\right) \cdot \left(t\_0 \cdot -0.0625\right)}{1 + \left(0.5 \cdot \left(\cos x \cdot t\_2\right) + 0.5 \cdot t\_1\right)}\\
\end{array}
if x < -1.75e8Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Applied rewrites59.4%
if -1.75e8 < x < 1.45e-5Initial program 99.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f6460.1%
Applied rewrites60.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6459.6%
Applied rewrites59.6%
Applied rewrites59.5%
if 1.45e-5 < x Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f6459.4%
Applied rewrites59.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 3.0 (sqrt 5.0)))
(t_1 (- (cos x) 1.0))
(t_2 (- (sqrt 5.0) 1.0))
(t_3 (- 0.5 (* 0.5 (cos (* 2.0 x))))))
(if (<= x -175000000.0)
(*
0.3333333333333333
(/
1.0
(/
(- (* (- (* t_2 (cos x)) (- (sqrt 5.0) 3.0)) 0.5) -1.0)
(- (* (* -0.0625 (* t_1 (sqrt 2.0))) t_3) -2.0))))
(if (<= x 1.45e-5)
(*
(*
(-
(*
(* -0.0625 (* (- 1.0 (cos y)) (sqrt 2.0)))
(- 0.5 (* 0.5 (cos (* 2.0 y)))))
-2.0)
0.3333333333333333)
(/ 1.0 (- (* 0.5 (+ t_2 (* t_0 (cos y)))) -1.0)))
(*
0.3333333333333333
(/
(+ 2.0 (* (* t_3 (sqrt 2.0)) (* t_1 -0.0625)))
(+ 1.0 (+ (* 0.5 (* (cos x) t_2)) (* 0.5 t_0)))))))))double code(double x, double y) {
double t_0 = 3.0 - sqrt(5.0);
double t_1 = cos(x) - 1.0;
double t_2 = sqrt(5.0) - 1.0;
double t_3 = 0.5 - (0.5 * cos((2.0 * x)));
double tmp;
if (x <= -175000000.0) {
tmp = 0.3333333333333333 * (1.0 / (((((t_2 * cos(x)) - (sqrt(5.0) - 3.0)) * 0.5) - -1.0) / (((-0.0625 * (t_1 * sqrt(2.0))) * t_3) - -2.0)));
} else if (x <= 1.45e-5) {
tmp = ((((-0.0625 * ((1.0 - cos(y)) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * y))))) - -2.0) * 0.3333333333333333) * (1.0 / ((0.5 * (t_2 + (t_0 * cos(y)))) - -1.0));
} else {
tmp = 0.3333333333333333 * ((2.0 + ((t_3 * sqrt(2.0)) * (t_1 * -0.0625))) / (1.0 + ((0.5 * (cos(x) * t_2)) + (0.5 * t_0))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = 3.0d0 - sqrt(5.0d0)
t_1 = cos(x) - 1.0d0
t_2 = sqrt(5.0d0) - 1.0d0
t_3 = 0.5d0 - (0.5d0 * cos((2.0d0 * x)))
if (x <= (-175000000.0d0)) then
tmp = 0.3333333333333333d0 * (1.0d0 / (((((t_2 * cos(x)) - (sqrt(5.0d0) - 3.0d0)) * 0.5d0) - (-1.0d0)) / ((((-0.0625d0) * (t_1 * sqrt(2.0d0))) * t_3) - (-2.0d0))))
else if (x <= 1.45d-5) then
tmp = (((((-0.0625d0) * ((1.0d0 - cos(y)) * sqrt(2.0d0))) * (0.5d0 - (0.5d0 * cos((2.0d0 * y))))) - (-2.0d0)) * 0.3333333333333333d0) * (1.0d0 / ((0.5d0 * (t_2 + (t_0 * cos(y)))) - (-1.0d0)))
else
tmp = 0.3333333333333333d0 * ((2.0d0 + ((t_3 * sqrt(2.0d0)) * (t_1 * (-0.0625d0)))) / (1.0d0 + ((0.5d0 * (cos(x) * t_2)) + (0.5d0 * t_0))))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 3.0 - Math.sqrt(5.0);
double t_1 = Math.cos(x) - 1.0;
double t_2 = Math.sqrt(5.0) - 1.0;
double t_3 = 0.5 - (0.5 * Math.cos((2.0 * x)));
double tmp;
if (x <= -175000000.0) {
tmp = 0.3333333333333333 * (1.0 / (((((t_2 * Math.cos(x)) - (Math.sqrt(5.0) - 3.0)) * 0.5) - -1.0) / (((-0.0625 * (t_1 * Math.sqrt(2.0))) * t_3) - -2.0)));
} else if (x <= 1.45e-5) {
tmp = ((((-0.0625 * ((1.0 - Math.cos(y)) * Math.sqrt(2.0))) * (0.5 - (0.5 * Math.cos((2.0 * y))))) - -2.0) * 0.3333333333333333) * (1.0 / ((0.5 * (t_2 + (t_0 * Math.cos(y)))) - -1.0));
} else {
tmp = 0.3333333333333333 * ((2.0 + ((t_3 * Math.sqrt(2.0)) * (t_1 * -0.0625))) / (1.0 + ((0.5 * (Math.cos(x) * t_2)) + (0.5 * t_0))));
}
return tmp;
}
def code(x, y): t_0 = 3.0 - math.sqrt(5.0) t_1 = math.cos(x) - 1.0 t_2 = math.sqrt(5.0) - 1.0 t_3 = 0.5 - (0.5 * math.cos((2.0 * x))) tmp = 0 if x <= -175000000.0: tmp = 0.3333333333333333 * (1.0 / (((((t_2 * math.cos(x)) - (math.sqrt(5.0) - 3.0)) * 0.5) - -1.0) / (((-0.0625 * (t_1 * math.sqrt(2.0))) * t_3) - -2.0))) elif x <= 1.45e-5: tmp = ((((-0.0625 * ((1.0 - math.cos(y)) * math.sqrt(2.0))) * (0.5 - (0.5 * math.cos((2.0 * y))))) - -2.0) * 0.3333333333333333) * (1.0 / ((0.5 * (t_2 + (t_0 * math.cos(y)))) - -1.0)) else: tmp = 0.3333333333333333 * ((2.0 + ((t_3 * math.sqrt(2.0)) * (t_1 * -0.0625))) / (1.0 + ((0.5 * (math.cos(x) * t_2)) + (0.5 * t_0)))) return tmp
function code(x, y) t_0 = Float64(3.0 - sqrt(5.0)) t_1 = Float64(cos(x) - 1.0) t_2 = Float64(sqrt(5.0) - 1.0) t_3 = Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * x)))) tmp = 0.0 if (x <= -175000000.0) tmp = Float64(0.3333333333333333 * Float64(1.0 / Float64(Float64(Float64(Float64(Float64(t_2 * cos(x)) - Float64(sqrt(5.0) - 3.0)) * 0.5) - -1.0) / Float64(Float64(Float64(-0.0625 * Float64(t_1 * sqrt(2.0))) * t_3) - -2.0)))); elseif (x <= 1.45e-5) tmp = Float64(Float64(Float64(Float64(Float64(-0.0625 * Float64(Float64(1.0 - cos(y)) * sqrt(2.0))) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * y))))) - -2.0) * 0.3333333333333333) * Float64(1.0 / Float64(Float64(0.5 * Float64(t_2 + Float64(t_0 * cos(y)))) - -1.0))); else tmp = Float64(0.3333333333333333 * Float64(Float64(2.0 + Float64(Float64(t_3 * sqrt(2.0)) * Float64(t_1 * -0.0625))) / Float64(1.0 + Float64(Float64(0.5 * Float64(cos(x) * t_2)) + Float64(0.5 * t_0))))); end return tmp end
function tmp_2 = code(x, y) t_0 = 3.0 - sqrt(5.0); t_1 = cos(x) - 1.0; t_2 = sqrt(5.0) - 1.0; t_3 = 0.5 - (0.5 * cos((2.0 * x))); tmp = 0.0; if (x <= -175000000.0) tmp = 0.3333333333333333 * (1.0 / (((((t_2 * cos(x)) - (sqrt(5.0) - 3.0)) * 0.5) - -1.0) / (((-0.0625 * (t_1 * sqrt(2.0))) * t_3) - -2.0))); elseif (x <= 1.45e-5) tmp = ((((-0.0625 * ((1.0 - cos(y)) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * y))))) - -2.0) * 0.3333333333333333) * (1.0 / ((0.5 * (t_2 + (t_0 * cos(y)))) - -1.0)); else tmp = 0.3333333333333333 * ((2.0 + ((t_3 * sqrt(2.0)) * (t_1 * -0.0625))) / (1.0 + ((0.5 * (cos(x) * t_2)) + (0.5 * t_0)))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$3 = N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -175000000.0], N[(0.3333333333333333 * N[(1.0 / N[(N[(N[(N[(N[(t$95$2 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision] - -1.0), $MachinePrecision] / N[(N[(N[(-0.0625 * N[(t$95$1 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision] - -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e-5], N[(N[(N[(N[(N[(-0.0625 * N[(N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -2.0), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] * N[(1.0 / N[(N[(0.5 * N[(t$95$2 + N[(t$95$0 * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[(N[(2.0 + N[(N[(t$95$3 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * -0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(0.5 * N[(N[Cos[x], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] + N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := 3 - \sqrt{5}\\
t_1 := \cos x - 1\\
t_2 := \sqrt{5} - 1\\
t_3 := 0.5 - 0.5 \cdot \cos \left(2 \cdot x\right)\\
\mathbf{if}\;x \leq -175000000:\\
\;\;\;\;0.3333333333333333 \cdot \frac{1}{\frac{\left(t\_2 \cdot \cos x - \left(\sqrt{5} - 3\right)\right) \cdot 0.5 - -1}{\left(-0.0625 \cdot \left(t\_1 \cdot \sqrt{2}\right)\right) \cdot t\_3 - -2}}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\left(\left(\left(-0.0625 \cdot \left(\left(1 - \cos y\right) \cdot \sqrt{2}\right)\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot y\right)\right) - -2\right) \cdot 0.3333333333333333\right) \cdot \frac{1}{0.5 \cdot \left(t\_2 + t\_0 \cdot \cos y\right) - -1}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{2 + \left(t\_3 \cdot \sqrt{2}\right) \cdot \left(t\_1 \cdot -0.0625\right)}{1 + \left(0.5 \cdot \left(\cos x \cdot t\_2\right) + 0.5 \cdot t\_0\right)}\\
\end{array}
if x < -1.75e8Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Applied rewrites59.4%
if -1.75e8 < x < 1.45e-5Initial program 99.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f6460.1%
Applied rewrites60.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6459.6%
Applied rewrites59.6%
Applied rewrites59.4%
if 1.45e-5 < x Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f6459.4%
Applied rewrites59.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 0.5 (* 0.5 (cos (* 2.0 x)))))
(t_1 (- 3.0 (sqrt 5.0)))
(t_2 (- (cos x) 1.0))
(t_3 (- (sqrt 5.0) 1.0)))
(if (<= x -175000000.0)
(/
(*
(- (* (* 0.0625 (* t_2 (sqrt 2.0))) t_0) 2.0)
0.3333333333333333)
(- (* -0.5 (- (* t_3 (cos x)) (- (sqrt 5.0) 3.0))) 1.0))
(if (<= x 1.45e-5)
(*
(*
(-
(*
(* -0.0625 (* (- 1.0 (cos y)) (sqrt 2.0)))
(- 0.5 (* 0.5 (cos (* 2.0 y)))))
-2.0)
0.3333333333333333)
(/ 1.0 (- (* 0.5 (+ t_3 (* t_1 (cos y)))) -1.0)))
(*
0.3333333333333333
(/
(+ 2.0 (* (* t_0 (sqrt 2.0)) (* t_2 -0.0625)))
(+ 1.0 (+ (* 0.5 (* (cos x) t_3)) (* 0.5 t_1)))))))))double code(double x, double y) {
double t_0 = 0.5 - (0.5 * cos((2.0 * x)));
double t_1 = 3.0 - sqrt(5.0);
double t_2 = cos(x) - 1.0;
double t_3 = sqrt(5.0) - 1.0;
double tmp;
if (x <= -175000000.0) {
tmp = ((((0.0625 * (t_2 * sqrt(2.0))) * t_0) - 2.0) * 0.3333333333333333) / ((-0.5 * ((t_3 * cos(x)) - (sqrt(5.0) - 3.0))) - 1.0);
} else if (x <= 1.45e-5) {
tmp = ((((-0.0625 * ((1.0 - cos(y)) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * y))))) - -2.0) * 0.3333333333333333) * (1.0 / ((0.5 * (t_3 + (t_1 * cos(y)))) - -1.0));
} else {
tmp = 0.3333333333333333 * ((2.0 + ((t_0 * sqrt(2.0)) * (t_2 * -0.0625))) / (1.0 + ((0.5 * (cos(x) * t_3)) + (0.5 * t_1))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = 0.5d0 - (0.5d0 * cos((2.0d0 * x)))
t_1 = 3.0d0 - sqrt(5.0d0)
t_2 = cos(x) - 1.0d0
t_3 = sqrt(5.0d0) - 1.0d0
if (x <= (-175000000.0d0)) then
tmp = ((((0.0625d0 * (t_2 * sqrt(2.0d0))) * t_0) - 2.0d0) * 0.3333333333333333d0) / (((-0.5d0) * ((t_3 * cos(x)) - (sqrt(5.0d0) - 3.0d0))) - 1.0d0)
else if (x <= 1.45d-5) then
tmp = (((((-0.0625d0) * ((1.0d0 - cos(y)) * sqrt(2.0d0))) * (0.5d0 - (0.5d0 * cos((2.0d0 * y))))) - (-2.0d0)) * 0.3333333333333333d0) * (1.0d0 / ((0.5d0 * (t_3 + (t_1 * cos(y)))) - (-1.0d0)))
else
tmp = 0.3333333333333333d0 * ((2.0d0 + ((t_0 * sqrt(2.0d0)) * (t_2 * (-0.0625d0)))) / (1.0d0 + ((0.5d0 * (cos(x) * t_3)) + (0.5d0 * t_1))))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 0.5 - (0.5 * Math.cos((2.0 * x)));
double t_1 = 3.0 - Math.sqrt(5.0);
double t_2 = Math.cos(x) - 1.0;
double t_3 = Math.sqrt(5.0) - 1.0;
double tmp;
if (x <= -175000000.0) {
tmp = ((((0.0625 * (t_2 * Math.sqrt(2.0))) * t_0) - 2.0) * 0.3333333333333333) / ((-0.5 * ((t_3 * Math.cos(x)) - (Math.sqrt(5.0) - 3.0))) - 1.0);
} else if (x <= 1.45e-5) {
tmp = ((((-0.0625 * ((1.0 - Math.cos(y)) * Math.sqrt(2.0))) * (0.5 - (0.5 * Math.cos((2.0 * y))))) - -2.0) * 0.3333333333333333) * (1.0 / ((0.5 * (t_3 + (t_1 * Math.cos(y)))) - -1.0));
} else {
tmp = 0.3333333333333333 * ((2.0 + ((t_0 * Math.sqrt(2.0)) * (t_2 * -0.0625))) / (1.0 + ((0.5 * (Math.cos(x) * t_3)) + (0.5 * t_1))));
}
return tmp;
}
def code(x, y): t_0 = 0.5 - (0.5 * math.cos((2.0 * x))) t_1 = 3.0 - math.sqrt(5.0) t_2 = math.cos(x) - 1.0 t_3 = math.sqrt(5.0) - 1.0 tmp = 0 if x <= -175000000.0: tmp = ((((0.0625 * (t_2 * math.sqrt(2.0))) * t_0) - 2.0) * 0.3333333333333333) / ((-0.5 * ((t_3 * math.cos(x)) - (math.sqrt(5.0) - 3.0))) - 1.0) elif x <= 1.45e-5: tmp = ((((-0.0625 * ((1.0 - math.cos(y)) * math.sqrt(2.0))) * (0.5 - (0.5 * math.cos((2.0 * y))))) - -2.0) * 0.3333333333333333) * (1.0 / ((0.5 * (t_3 + (t_1 * math.cos(y)))) - -1.0)) else: tmp = 0.3333333333333333 * ((2.0 + ((t_0 * math.sqrt(2.0)) * (t_2 * -0.0625))) / (1.0 + ((0.5 * (math.cos(x) * t_3)) + (0.5 * t_1)))) return tmp
function code(x, y) t_0 = Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * x)))) t_1 = Float64(3.0 - sqrt(5.0)) t_2 = Float64(cos(x) - 1.0) t_3 = Float64(sqrt(5.0) - 1.0) tmp = 0.0 if (x <= -175000000.0) tmp = Float64(Float64(Float64(Float64(Float64(0.0625 * Float64(t_2 * sqrt(2.0))) * t_0) - 2.0) * 0.3333333333333333) / Float64(Float64(-0.5 * Float64(Float64(t_3 * cos(x)) - Float64(sqrt(5.0) - 3.0))) - 1.0)); elseif (x <= 1.45e-5) tmp = Float64(Float64(Float64(Float64(Float64(-0.0625 * Float64(Float64(1.0 - cos(y)) * sqrt(2.0))) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * y))))) - -2.0) * 0.3333333333333333) * Float64(1.0 / Float64(Float64(0.5 * Float64(t_3 + Float64(t_1 * cos(y)))) - -1.0))); else tmp = Float64(0.3333333333333333 * Float64(Float64(2.0 + Float64(Float64(t_0 * sqrt(2.0)) * Float64(t_2 * -0.0625))) / Float64(1.0 + Float64(Float64(0.5 * Float64(cos(x) * t_3)) + Float64(0.5 * t_1))))); end return tmp end
function tmp_2 = code(x, y) t_0 = 0.5 - (0.5 * cos((2.0 * x))); t_1 = 3.0 - sqrt(5.0); t_2 = cos(x) - 1.0; t_3 = sqrt(5.0) - 1.0; tmp = 0.0; if (x <= -175000000.0) tmp = ((((0.0625 * (t_2 * sqrt(2.0))) * t_0) - 2.0) * 0.3333333333333333) / ((-0.5 * ((t_3 * cos(x)) - (sqrt(5.0) - 3.0))) - 1.0); elseif (x <= 1.45e-5) tmp = ((((-0.0625 * ((1.0 - cos(y)) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * y))))) - -2.0) * 0.3333333333333333) * (1.0 / ((0.5 * (t_3 + (t_1 * cos(y)))) - -1.0)); else tmp = 0.3333333333333333 * ((2.0 + ((t_0 * sqrt(2.0)) * (t_2 * -0.0625))) / (1.0 + ((0.5 * (cos(x) * t_3)) + (0.5 * t_1)))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[x, -175000000.0], N[(N[(N[(N[(N[(0.0625 * N[(t$95$2 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] - 2.0), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] / N[(N[(-0.5 * N[(N[(t$95$3 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e-5], N[(N[(N[(N[(N[(-0.0625 * N[(N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -2.0), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] * N[(1.0 / N[(N[(0.5 * N[(t$95$3 + N[(t$95$1 * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[(N[(2.0 + N[(N[(t$95$0 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(t$95$2 * -0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(0.5 * N[(N[Cos[x], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision] + N[(0.5 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := 0.5 - 0.5 \cdot \cos \left(2 \cdot x\right)\\
t_1 := 3 - \sqrt{5}\\
t_2 := \cos x - 1\\
t_3 := \sqrt{5} - 1\\
\mathbf{if}\;x \leq -175000000:\\
\;\;\;\;\frac{\left(\left(0.0625 \cdot \left(t\_2 \cdot \sqrt{2}\right)\right) \cdot t\_0 - 2\right) \cdot 0.3333333333333333}{-0.5 \cdot \left(t\_3 \cdot \cos x - \left(\sqrt{5} - 3\right)\right) - 1}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\left(\left(\left(-0.0625 \cdot \left(\left(1 - \cos y\right) \cdot \sqrt{2}\right)\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot y\right)\right) - -2\right) \cdot 0.3333333333333333\right) \cdot \frac{1}{0.5 \cdot \left(t\_3 + t\_1 \cdot \cos y\right) - -1}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{2 + \left(t\_0 \cdot \sqrt{2}\right) \cdot \left(t\_2 \cdot -0.0625\right)}{1 + \left(0.5 \cdot \left(\cos x \cdot t\_3\right) + 0.5 \cdot t\_1\right)}\\
\end{array}
if x < -1.75e8Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Applied rewrites59.4%
if -1.75e8 < x < 1.45e-5Initial program 99.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f6460.1%
Applied rewrites60.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6459.6%
Applied rewrites59.6%
Applied rewrites59.4%
if 1.45e-5 < x Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f6459.4%
Applied rewrites59.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 0.5 (* 0.5 (cos (* 2.0 x)))))
(t_1 (- 3.0 (sqrt 5.0)))
(t_2 (- (cos x) 1.0))
(t_3 (- (sqrt 5.0) 1.0)))
(if (<= x -175000000.0)
(/
(*
(- (* (* 0.0625 (* t_2 (sqrt 2.0))) t_0) 2.0)
0.3333333333333333)
(- (* -0.5 (- (* t_3 (cos x)) (- (sqrt 5.0) 3.0))) 1.0))
(if (<= x 1.45e-5)
(/
(-
(*
(* -0.0625 (* (- 1.0 (cos y)) (sqrt 2.0)))
(- 0.5 (* 0.5 (cos (* 2.0 y)))))
-2.0)
(* (- (* 0.5 (+ t_3 (* t_1 (cos y)))) -1.0) 3.0))
(*
0.3333333333333333
(/
(+ 2.0 (* (* t_0 (sqrt 2.0)) (* t_2 -0.0625)))
(+ 1.0 (+ (* 0.5 (* (cos x) t_3)) (* 0.5 t_1)))))))))double code(double x, double y) {
double t_0 = 0.5 - (0.5 * cos((2.0 * x)));
double t_1 = 3.0 - sqrt(5.0);
double t_2 = cos(x) - 1.0;
double t_3 = sqrt(5.0) - 1.0;
double tmp;
if (x <= -175000000.0) {
tmp = ((((0.0625 * (t_2 * sqrt(2.0))) * t_0) - 2.0) * 0.3333333333333333) / ((-0.5 * ((t_3 * cos(x)) - (sqrt(5.0) - 3.0))) - 1.0);
} else if (x <= 1.45e-5) {
tmp = (((-0.0625 * ((1.0 - cos(y)) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * y))))) - -2.0) / (((0.5 * (t_3 + (t_1 * cos(y)))) - -1.0) * 3.0);
} else {
tmp = 0.3333333333333333 * ((2.0 + ((t_0 * sqrt(2.0)) * (t_2 * -0.0625))) / (1.0 + ((0.5 * (cos(x) * t_3)) + (0.5 * t_1))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = 0.5d0 - (0.5d0 * cos((2.0d0 * x)))
t_1 = 3.0d0 - sqrt(5.0d0)
t_2 = cos(x) - 1.0d0
t_3 = sqrt(5.0d0) - 1.0d0
if (x <= (-175000000.0d0)) then
tmp = ((((0.0625d0 * (t_2 * sqrt(2.0d0))) * t_0) - 2.0d0) * 0.3333333333333333d0) / (((-0.5d0) * ((t_3 * cos(x)) - (sqrt(5.0d0) - 3.0d0))) - 1.0d0)
else if (x <= 1.45d-5) then
tmp = ((((-0.0625d0) * ((1.0d0 - cos(y)) * sqrt(2.0d0))) * (0.5d0 - (0.5d0 * cos((2.0d0 * y))))) - (-2.0d0)) / (((0.5d0 * (t_3 + (t_1 * cos(y)))) - (-1.0d0)) * 3.0d0)
else
tmp = 0.3333333333333333d0 * ((2.0d0 + ((t_0 * sqrt(2.0d0)) * (t_2 * (-0.0625d0)))) / (1.0d0 + ((0.5d0 * (cos(x) * t_3)) + (0.5d0 * t_1))))
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 0.5 - (0.5 * Math.cos((2.0 * x)));
double t_1 = 3.0 - Math.sqrt(5.0);
double t_2 = Math.cos(x) - 1.0;
double t_3 = Math.sqrt(5.0) - 1.0;
double tmp;
if (x <= -175000000.0) {
tmp = ((((0.0625 * (t_2 * Math.sqrt(2.0))) * t_0) - 2.0) * 0.3333333333333333) / ((-0.5 * ((t_3 * Math.cos(x)) - (Math.sqrt(5.0) - 3.0))) - 1.0);
} else if (x <= 1.45e-5) {
tmp = (((-0.0625 * ((1.0 - Math.cos(y)) * Math.sqrt(2.0))) * (0.5 - (0.5 * Math.cos((2.0 * y))))) - -2.0) / (((0.5 * (t_3 + (t_1 * Math.cos(y)))) - -1.0) * 3.0);
} else {
tmp = 0.3333333333333333 * ((2.0 + ((t_0 * Math.sqrt(2.0)) * (t_2 * -0.0625))) / (1.0 + ((0.5 * (Math.cos(x) * t_3)) + (0.5 * t_1))));
}
return tmp;
}
def code(x, y): t_0 = 0.5 - (0.5 * math.cos((2.0 * x))) t_1 = 3.0 - math.sqrt(5.0) t_2 = math.cos(x) - 1.0 t_3 = math.sqrt(5.0) - 1.0 tmp = 0 if x <= -175000000.0: tmp = ((((0.0625 * (t_2 * math.sqrt(2.0))) * t_0) - 2.0) * 0.3333333333333333) / ((-0.5 * ((t_3 * math.cos(x)) - (math.sqrt(5.0) - 3.0))) - 1.0) elif x <= 1.45e-5: tmp = (((-0.0625 * ((1.0 - math.cos(y)) * math.sqrt(2.0))) * (0.5 - (0.5 * math.cos((2.0 * y))))) - -2.0) / (((0.5 * (t_3 + (t_1 * math.cos(y)))) - -1.0) * 3.0) else: tmp = 0.3333333333333333 * ((2.0 + ((t_0 * math.sqrt(2.0)) * (t_2 * -0.0625))) / (1.0 + ((0.5 * (math.cos(x) * t_3)) + (0.5 * t_1)))) return tmp
function code(x, y) t_0 = Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * x)))) t_1 = Float64(3.0 - sqrt(5.0)) t_2 = Float64(cos(x) - 1.0) t_3 = Float64(sqrt(5.0) - 1.0) tmp = 0.0 if (x <= -175000000.0) tmp = Float64(Float64(Float64(Float64(Float64(0.0625 * Float64(t_2 * sqrt(2.0))) * t_0) - 2.0) * 0.3333333333333333) / Float64(Float64(-0.5 * Float64(Float64(t_3 * cos(x)) - Float64(sqrt(5.0) - 3.0))) - 1.0)); elseif (x <= 1.45e-5) tmp = Float64(Float64(Float64(Float64(-0.0625 * Float64(Float64(1.0 - cos(y)) * sqrt(2.0))) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * y))))) - -2.0) / Float64(Float64(Float64(0.5 * Float64(t_3 + Float64(t_1 * cos(y)))) - -1.0) * 3.0)); else tmp = Float64(0.3333333333333333 * Float64(Float64(2.0 + Float64(Float64(t_0 * sqrt(2.0)) * Float64(t_2 * -0.0625))) / Float64(1.0 + Float64(Float64(0.5 * Float64(cos(x) * t_3)) + Float64(0.5 * t_1))))); end return tmp end
function tmp_2 = code(x, y) t_0 = 0.5 - (0.5 * cos((2.0 * x))); t_1 = 3.0 - sqrt(5.0); t_2 = cos(x) - 1.0; t_3 = sqrt(5.0) - 1.0; tmp = 0.0; if (x <= -175000000.0) tmp = ((((0.0625 * (t_2 * sqrt(2.0))) * t_0) - 2.0) * 0.3333333333333333) / ((-0.5 * ((t_3 * cos(x)) - (sqrt(5.0) - 3.0))) - 1.0); elseif (x <= 1.45e-5) tmp = (((-0.0625 * ((1.0 - cos(y)) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * y))))) - -2.0) / (((0.5 * (t_3 + (t_1 * cos(y)))) - -1.0) * 3.0); else tmp = 0.3333333333333333 * ((2.0 + ((t_0 * sqrt(2.0)) * (t_2 * -0.0625))) / (1.0 + ((0.5 * (cos(x) * t_3)) + (0.5 * t_1)))); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[x, -175000000.0], N[(N[(N[(N[(N[(0.0625 * N[(t$95$2 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] - 2.0), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] / N[(N[(-0.5 * N[(N[(t$95$3 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e-5], N[(N[(N[(N[(-0.0625 * N[(N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -2.0), $MachinePrecision] / N[(N[(N[(0.5 * N[(t$95$3 + N[(t$95$1 * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision], N[(0.3333333333333333 * N[(N[(2.0 + N[(N[(t$95$0 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * N[(t$95$2 * -0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(0.5 * N[(N[Cos[x], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision] + N[(0.5 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := 0.5 - 0.5 \cdot \cos \left(2 \cdot x\right)\\
t_1 := 3 - \sqrt{5}\\
t_2 := \cos x - 1\\
t_3 := \sqrt{5} - 1\\
\mathbf{if}\;x \leq -175000000:\\
\;\;\;\;\frac{\left(\left(0.0625 \cdot \left(t\_2 \cdot \sqrt{2}\right)\right) \cdot t\_0 - 2\right) \cdot 0.3333333333333333}{-0.5 \cdot \left(t\_3 \cdot \cos x - \left(\sqrt{5} - 3\right)\right) - 1}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{\left(-0.0625 \cdot \left(\left(1 - \cos y\right) \cdot \sqrt{2}\right)\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot y\right)\right) - -2}{\left(0.5 \cdot \left(t\_3 + t\_1 \cdot \cos y\right) - -1\right) \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{2 + \left(t\_0 \cdot \sqrt{2}\right) \cdot \left(t\_2 \cdot -0.0625\right)}{1 + \left(0.5 \cdot \left(\cos x \cdot t\_3\right) + 0.5 \cdot t\_1\right)}\\
\end{array}
if x < -1.75e8Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Applied rewrites59.4%
if -1.75e8 < x < 1.45e-5Initial program 99.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f6460.1%
Applied rewrites60.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6459.6%
Applied rewrites59.6%
Applied rewrites59.5%
if 1.45e-5 < x Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lift-sin.f64N/A
lift-sin.f64N/A
sqr-sin-aN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f6459.4%
Applied rewrites59.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (sqrt 5.0) 1.0))
(t_1
(-
(*
(* 0.0625 (* (- (cos x) 1.0) (sqrt 2.0)))
(- 0.5 (* 0.5 (cos (* 2.0 x)))))
2.0))
(t_2 (- (* -0.5 (- (* t_0 (cos x)) (- (sqrt 5.0) 3.0))) 1.0)))
(if (<= x -175000000.0)
(/ (* t_1 0.3333333333333333) t_2)
(if (<= x 1.45e-5)
(/
(-
(*
(* -0.0625 (* (- 1.0 (cos y)) (sqrt 2.0)))
(- 0.5 (* 0.5 (cos (* 2.0 y)))))
-2.0)
(*
(- (* 0.5 (+ t_0 (* (- 3.0 (sqrt 5.0)) (cos y)))) -1.0)
3.0))
(* (/ t_1 t_2) 0.3333333333333333)))))double code(double x, double y) {
double t_0 = sqrt(5.0) - 1.0;
double t_1 = ((0.0625 * ((cos(x) - 1.0) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * x))))) - 2.0;
double t_2 = (-0.5 * ((t_0 * cos(x)) - (sqrt(5.0) - 3.0))) - 1.0;
double tmp;
if (x <= -175000000.0) {
tmp = (t_1 * 0.3333333333333333) / t_2;
} else if (x <= 1.45e-5) {
tmp = (((-0.0625 * ((1.0 - cos(y)) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * y))))) - -2.0) / (((0.5 * (t_0 + ((3.0 - sqrt(5.0)) * cos(y)))) - -1.0) * 3.0);
} else {
tmp = (t_1 / t_2) * 0.3333333333333333;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sqrt(5.0d0) - 1.0d0
t_1 = ((0.0625d0 * ((cos(x) - 1.0d0) * sqrt(2.0d0))) * (0.5d0 - (0.5d0 * cos((2.0d0 * x))))) - 2.0d0
t_2 = ((-0.5d0) * ((t_0 * cos(x)) - (sqrt(5.0d0) - 3.0d0))) - 1.0d0
if (x <= (-175000000.0d0)) then
tmp = (t_1 * 0.3333333333333333d0) / t_2
else if (x <= 1.45d-5) then
tmp = ((((-0.0625d0) * ((1.0d0 - cos(y)) * sqrt(2.0d0))) * (0.5d0 - (0.5d0 * cos((2.0d0 * y))))) - (-2.0d0)) / (((0.5d0 * (t_0 + ((3.0d0 - sqrt(5.0d0)) * cos(y)))) - (-1.0d0)) * 3.0d0)
else
tmp = (t_1 / t_2) * 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.sqrt(5.0) - 1.0;
double t_1 = ((0.0625 * ((Math.cos(x) - 1.0) * Math.sqrt(2.0))) * (0.5 - (0.5 * Math.cos((2.0 * x))))) - 2.0;
double t_2 = (-0.5 * ((t_0 * Math.cos(x)) - (Math.sqrt(5.0) - 3.0))) - 1.0;
double tmp;
if (x <= -175000000.0) {
tmp = (t_1 * 0.3333333333333333) / t_2;
} else if (x <= 1.45e-5) {
tmp = (((-0.0625 * ((1.0 - Math.cos(y)) * Math.sqrt(2.0))) * (0.5 - (0.5 * Math.cos((2.0 * y))))) - -2.0) / (((0.5 * (t_0 + ((3.0 - Math.sqrt(5.0)) * Math.cos(y)))) - -1.0) * 3.0);
} else {
tmp = (t_1 / t_2) * 0.3333333333333333;
}
return tmp;
}
def code(x, y): t_0 = math.sqrt(5.0) - 1.0 t_1 = ((0.0625 * ((math.cos(x) - 1.0) * math.sqrt(2.0))) * (0.5 - (0.5 * math.cos((2.0 * x))))) - 2.0 t_2 = (-0.5 * ((t_0 * math.cos(x)) - (math.sqrt(5.0) - 3.0))) - 1.0 tmp = 0 if x <= -175000000.0: tmp = (t_1 * 0.3333333333333333) / t_2 elif x <= 1.45e-5: tmp = (((-0.0625 * ((1.0 - math.cos(y)) * math.sqrt(2.0))) * (0.5 - (0.5 * math.cos((2.0 * y))))) - -2.0) / (((0.5 * (t_0 + ((3.0 - math.sqrt(5.0)) * math.cos(y)))) - -1.0) * 3.0) else: tmp = (t_1 / t_2) * 0.3333333333333333 return tmp
function code(x, y) t_0 = Float64(sqrt(5.0) - 1.0) t_1 = Float64(Float64(Float64(0.0625 * Float64(Float64(cos(x) - 1.0) * sqrt(2.0))) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * x))))) - 2.0) t_2 = Float64(Float64(-0.5 * Float64(Float64(t_0 * cos(x)) - Float64(sqrt(5.0) - 3.0))) - 1.0) tmp = 0.0 if (x <= -175000000.0) tmp = Float64(Float64(t_1 * 0.3333333333333333) / t_2); elseif (x <= 1.45e-5) tmp = Float64(Float64(Float64(Float64(-0.0625 * Float64(Float64(1.0 - cos(y)) * sqrt(2.0))) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * y))))) - -2.0) / Float64(Float64(Float64(0.5 * Float64(t_0 + Float64(Float64(3.0 - sqrt(5.0)) * cos(y)))) - -1.0) * 3.0)); else tmp = Float64(Float64(t_1 / t_2) * 0.3333333333333333); end return tmp end
function tmp_2 = code(x, y) t_0 = sqrt(5.0) - 1.0; t_1 = ((0.0625 * ((cos(x) - 1.0) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * x))))) - 2.0; t_2 = (-0.5 * ((t_0 * cos(x)) - (sqrt(5.0) - 3.0))) - 1.0; tmp = 0.0; if (x <= -175000000.0) tmp = (t_1 * 0.3333333333333333) / t_2; elseif (x <= 1.45e-5) tmp = (((-0.0625 * ((1.0 - cos(y)) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * y))))) - -2.0) / (((0.5 * (t_0 + ((3.0 - sqrt(5.0)) * cos(y)))) - -1.0) * 3.0); else tmp = (t_1 / t_2) * 0.3333333333333333; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(0.0625 * N[(N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(-0.5 * N[(N[(t$95$0 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[x, -175000000.0], N[(N[(t$95$1 * 0.3333333333333333), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[x, 1.45e-5], N[(N[(N[(N[(-0.0625 * N[(N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -2.0), $MachinePrecision] / N[(N[(N[(0.5 * N[(t$95$0 + N[(N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / t$95$2), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \sqrt{5} - 1\\
t_1 := \left(0.0625 \cdot \left(\left(\cos x - 1\right) \cdot \sqrt{2}\right)\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot x\right)\right) - 2\\
t_2 := -0.5 \cdot \left(t\_0 \cdot \cos x - \left(\sqrt{5} - 3\right)\right) - 1\\
\mathbf{if}\;x \leq -175000000:\\
\;\;\;\;\frac{t\_1 \cdot 0.3333333333333333}{t\_2}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{\left(-0.0625 \cdot \left(\left(1 - \cos y\right) \cdot \sqrt{2}\right)\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot y\right)\right) - -2}{\left(0.5 \cdot \left(t\_0 + \left(3 - \sqrt{5}\right) \cdot \cos y\right) - -1\right) \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{t\_2} \cdot 0.3333333333333333\\
\end{array}
if x < -1.75e8Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Applied rewrites59.4%
if -1.75e8 < x < 1.45e-5Initial program 99.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f6460.1%
Applied rewrites60.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6459.6%
Applied rewrites59.6%
Applied rewrites59.5%
if 1.45e-5 < x Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Applied rewrites59.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (sqrt 5.0) 1.0))
(t_1
(-
(*
(* 0.0625 (* (- (cos x) 1.0) (sqrt 2.0)))
(- 0.5 (* 0.5 (cos (* 2.0 x)))))
2.0))
(t_2 (- (* -0.5 (- (* t_0 (cos x)) (- (sqrt 5.0) 3.0))) 1.0)))
(if (<= x -175000000.0)
(/ (* t_1 0.3333333333333333) t_2)
(if (<= x 1.45e-5)
(/
(*
(-
(*
(* -0.0625 (* (- 1.0 (cos y)) (sqrt 2.0)))
(- 0.5 (* 0.5 (cos (* 2.0 y)))))
-2.0)
0.3333333333333333)
(- (* 0.5 (+ t_0 (* (- 3.0 (sqrt 5.0)) (cos y)))) -1.0))
(* (/ t_1 t_2) 0.3333333333333333)))))double code(double x, double y) {
double t_0 = sqrt(5.0) - 1.0;
double t_1 = ((0.0625 * ((cos(x) - 1.0) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * x))))) - 2.0;
double t_2 = (-0.5 * ((t_0 * cos(x)) - (sqrt(5.0) - 3.0))) - 1.0;
double tmp;
if (x <= -175000000.0) {
tmp = (t_1 * 0.3333333333333333) / t_2;
} else if (x <= 1.45e-5) {
tmp = ((((-0.0625 * ((1.0 - cos(y)) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * y))))) - -2.0) * 0.3333333333333333) / ((0.5 * (t_0 + ((3.0 - sqrt(5.0)) * cos(y)))) - -1.0);
} else {
tmp = (t_1 / t_2) * 0.3333333333333333;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sqrt(5.0d0) - 1.0d0
t_1 = ((0.0625d0 * ((cos(x) - 1.0d0) * sqrt(2.0d0))) * (0.5d0 - (0.5d0 * cos((2.0d0 * x))))) - 2.0d0
t_2 = ((-0.5d0) * ((t_0 * cos(x)) - (sqrt(5.0d0) - 3.0d0))) - 1.0d0
if (x <= (-175000000.0d0)) then
tmp = (t_1 * 0.3333333333333333d0) / t_2
else if (x <= 1.45d-5) then
tmp = (((((-0.0625d0) * ((1.0d0 - cos(y)) * sqrt(2.0d0))) * (0.5d0 - (0.5d0 * cos((2.0d0 * y))))) - (-2.0d0)) * 0.3333333333333333d0) / ((0.5d0 * (t_0 + ((3.0d0 - sqrt(5.0d0)) * cos(y)))) - (-1.0d0))
else
tmp = (t_1 / t_2) * 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.sqrt(5.0) - 1.0;
double t_1 = ((0.0625 * ((Math.cos(x) - 1.0) * Math.sqrt(2.0))) * (0.5 - (0.5 * Math.cos((2.0 * x))))) - 2.0;
double t_2 = (-0.5 * ((t_0 * Math.cos(x)) - (Math.sqrt(5.0) - 3.0))) - 1.0;
double tmp;
if (x <= -175000000.0) {
tmp = (t_1 * 0.3333333333333333) / t_2;
} else if (x <= 1.45e-5) {
tmp = ((((-0.0625 * ((1.0 - Math.cos(y)) * Math.sqrt(2.0))) * (0.5 - (0.5 * Math.cos((2.0 * y))))) - -2.0) * 0.3333333333333333) / ((0.5 * (t_0 + ((3.0 - Math.sqrt(5.0)) * Math.cos(y)))) - -1.0);
} else {
tmp = (t_1 / t_2) * 0.3333333333333333;
}
return tmp;
}
def code(x, y): t_0 = math.sqrt(5.0) - 1.0 t_1 = ((0.0625 * ((math.cos(x) - 1.0) * math.sqrt(2.0))) * (0.5 - (0.5 * math.cos((2.0 * x))))) - 2.0 t_2 = (-0.5 * ((t_0 * math.cos(x)) - (math.sqrt(5.0) - 3.0))) - 1.0 tmp = 0 if x <= -175000000.0: tmp = (t_1 * 0.3333333333333333) / t_2 elif x <= 1.45e-5: tmp = ((((-0.0625 * ((1.0 - math.cos(y)) * math.sqrt(2.0))) * (0.5 - (0.5 * math.cos((2.0 * y))))) - -2.0) * 0.3333333333333333) / ((0.5 * (t_0 + ((3.0 - math.sqrt(5.0)) * math.cos(y)))) - -1.0) else: tmp = (t_1 / t_2) * 0.3333333333333333 return tmp
function code(x, y) t_0 = Float64(sqrt(5.0) - 1.0) t_1 = Float64(Float64(Float64(0.0625 * Float64(Float64(cos(x) - 1.0) * sqrt(2.0))) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * x))))) - 2.0) t_2 = Float64(Float64(-0.5 * Float64(Float64(t_0 * cos(x)) - Float64(sqrt(5.0) - 3.0))) - 1.0) tmp = 0.0 if (x <= -175000000.0) tmp = Float64(Float64(t_1 * 0.3333333333333333) / t_2); elseif (x <= 1.45e-5) tmp = Float64(Float64(Float64(Float64(Float64(-0.0625 * Float64(Float64(1.0 - cos(y)) * sqrt(2.0))) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * y))))) - -2.0) * 0.3333333333333333) / Float64(Float64(0.5 * Float64(t_0 + Float64(Float64(3.0 - sqrt(5.0)) * cos(y)))) - -1.0)); else tmp = Float64(Float64(t_1 / t_2) * 0.3333333333333333); end return tmp end
function tmp_2 = code(x, y) t_0 = sqrt(5.0) - 1.0; t_1 = ((0.0625 * ((cos(x) - 1.0) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * x))))) - 2.0; t_2 = (-0.5 * ((t_0 * cos(x)) - (sqrt(5.0) - 3.0))) - 1.0; tmp = 0.0; if (x <= -175000000.0) tmp = (t_1 * 0.3333333333333333) / t_2; elseif (x <= 1.45e-5) tmp = ((((-0.0625 * ((1.0 - cos(y)) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * y))))) - -2.0) * 0.3333333333333333) / ((0.5 * (t_0 + ((3.0 - sqrt(5.0)) * cos(y)))) - -1.0); else tmp = (t_1 / t_2) * 0.3333333333333333; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(0.0625 * N[(N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(-0.5 * N[(N[(t$95$0 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[x, -175000000.0], N[(N[(t$95$1 * 0.3333333333333333), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[x, 1.45e-5], N[(N[(N[(N[(N[(-0.0625 * N[(N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -2.0), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] / N[(N[(0.5 * N[(t$95$0 + N[(N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / t$95$2), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \sqrt{5} - 1\\
t_1 := \left(0.0625 \cdot \left(\left(\cos x - 1\right) \cdot \sqrt{2}\right)\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot x\right)\right) - 2\\
t_2 := -0.5 \cdot \left(t\_0 \cdot \cos x - \left(\sqrt{5} - 3\right)\right) - 1\\
\mathbf{if}\;x \leq -175000000:\\
\;\;\;\;\frac{t\_1 \cdot 0.3333333333333333}{t\_2}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{\left(\left(-0.0625 \cdot \left(\left(1 - \cos y\right) \cdot \sqrt{2}\right)\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot y\right)\right) - -2\right) \cdot 0.3333333333333333}{0.5 \cdot \left(t\_0 + \left(3 - \sqrt{5}\right) \cdot \cos y\right) - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{t\_2} \cdot 0.3333333333333333\\
\end{array}
if x < -1.75e8Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Applied rewrites59.4%
if -1.75e8 < x < 1.45e-5Initial program 99.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f6460.1%
Applied rewrites60.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6459.6%
Applied rewrites59.6%
Applied rewrites59.5%
if 1.45e-5 < x Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Applied rewrites59.4%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (sqrt 5.0) 1.0))
(t_1
(-
(*
(* 0.0625 (* (- (cos x) 1.0) (sqrt 2.0)))
(- 0.5 (* 0.5 (cos (* 2.0 x)))))
2.0))
(t_2 (- (* -0.5 (- (* t_0 (cos x)) (- (sqrt 5.0) 3.0))) 1.0)))
(if (<= x -175000000.0)
(/ (* t_1 0.3333333333333333) t_2)
(if (<= x 1.45e-5)
(*
(-
(*
(* -0.0625 (* (- 1.0 (cos y)) (sqrt 2.0)))
(- 0.5 (* 0.5 (cos (* 2.0 y)))))
-2.0)
(/
0.3333333333333333
(- (* 0.5 (+ t_0 (* (- 3.0 (sqrt 5.0)) (cos y)))) -1.0)))
(* (/ t_1 t_2) 0.3333333333333333)))))double code(double x, double y) {
double t_0 = sqrt(5.0) - 1.0;
double t_1 = ((0.0625 * ((cos(x) - 1.0) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * x))))) - 2.0;
double t_2 = (-0.5 * ((t_0 * cos(x)) - (sqrt(5.0) - 3.0))) - 1.0;
double tmp;
if (x <= -175000000.0) {
tmp = (t_1 * 0.3333333333333333) / t_2;
} else if (x <= 1.45e-5) {
tmp = (((-0.0625 * ((1.0 - cos(y)) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * y))))) - -2.0) * (0.3333333333333333 / ((0.5 * (t_0 + ((3.0 - sqrt(5.0)) * cos(y)))) - -1.0));
} else {
tmp = (t_1 / t_2) * 0.3333333333333333;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sqrt(5.0d0) - 1.0d0
t_1 = ((0.0625d0 * ((cos(x) - 1.0d0) * sqrt(2.0d0))) * (0.5d0 - (0.5d0 * cos((2.0d0 * x))))) - 2.0d0
t_2 = ((-0.5d0) * ((t_0 * cos(x)) - (sqrt(5.0d0) - 3.0d0))) - 1.0d0
if (x <= (-175000000.0d0)) then
tmp = (t_1 * 0.3333333333333333d0) / t_2
else if (x <= 1.45d-5) then
tmp = ((((-0.0625d0) * ((1.0d0 - cos(y)) * sqrt(2.0d0))) * (0.5d0 - (0.5d0 * cos((2.0d0 * y))))) - (-2.0d0)) * (0.3333333333333333d0 / ((0.5d0 * (t_0 + ((3.0d0 - sqrt(5.0d0)) * cos(y)))) - (-1.0d0)))
else
tmp = (t_1 / t_2) * 0.3333333333333333d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.sqrt(5.0) - 1.0;
double t_1 = ((0.0625 * ((Math.cos(x) - 1.0) * Math.sqrt(2.0))) * (0.5 - (0.5 * Math.cos((2.0 * x))))) - 2.0;
double t_2 = (-0.5 * ((t_0 * Math.cos(x)) - (Math.sqrt(5.0) - 3.0))) - 1.0;
double tmp;
if (x <= -175000000.0) {
tmp = (t_1 * 0.3333333333333333) / t_2;
} else if (x <= 1.45e-5) {
tmp = (((-0.0625 * ((1.0 - Math.cos(y)) * Math.sqrt(2.0))) * (0.5 - (0.5 * Math.cos((2.0 * y))))) - -2.0) * (0.3333333333333333 / ((0.5 * (t_0 + ((3.0 - Math.sqrt(5.0)) * Math.cos(y)))) - -1.0));
} else {
tmp = (t_1 / t_2) * 0.3333333333333333;
}
return tmp;
}
def code(x, y): t_0 = math.sqrt(5.0) - 1.0 t_1 = ((0.0625 * ((math.cos(x) - 1.0) * math.sqrt(2.0))) * (0.5 - (0.5 * math.cos((2.0 * x))))) - 2.0 t_2 = (-0.5 * ((t_0 * math.cos(x)) - (math.sqrt(5.0) - 3.0))) - 1.0 tmp = 0 if x <= -175000000.0: tmp = (t_1 * 0.3333333333333333) / t_2 elif x <= 1.45e-5: tmp = (((-0.0625 * ((1.0 - math.cos(y)) * math.sqrt(2.0))) * (0.5 - (0.5 * math.cos((2.0 * y))))) - -2.0) * (0.3333333333333333 / ((0.5 * (t_0 + ((3.0 - math.sqrt(5.0)) * math.cos(y)))) - -1.0)) else: tmp = (t_1 / t_2) * 0.3333333333333333 return tmp
function code(x, y) t_0 = Float64(sqrt(5.0) - 1.0) t_1 = Float64(Float64(Float64(0.0625 * Float64(Float64(cos(x) - 1.0) * sqrt(2.0))) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * x))))) - 2.0) t_2 = Float64(Float64(-0.5 * Float64(Float64(t_0 * cos(x)) - Float64(sqrt(5.0) - 3.0))) - 1.0) tmp = 0.0 if (x <= -175000000.0) tmp = Float64(Float64(t_1 * 0.3333333333333333) / t_2); elseif (x <= 1.45e-5) tmp = Float64(Float64(Float64(Float64(-0.0625 * Float64(Float64(1.0 - cos(y)) * sqrt(2.0))) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * y))))) - -2.0) * Float64(0.3333333333333333 / Float64(Float64(0.5 * Float64(t_0 + Float64(Float64(3.0 - sqrt(5.0)) * cos(y)))) - -1.0))); else tmp = Float64(Float64(t_1 / t_2) * 0.3333333333333333); end return tmp end
function tmp_2 = code(x, y) t_0 = sqrt(5.0) - 1.0; t_1 = ((0.0625 * ((cos(x) - 1.0) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * x))))) - 2.0; t_2 = (-0.5 * ((t_0 * cos(x)) - (sqrt(5.0) - 3.0))) - 1.0; tmp = 0.0; if (x <= -175000000.0) tmp = (t_1 * 0.3333333333333333) / t_2; elseif (x <= 1.45e-5) tmp = (((-0.0625 * ((1.0 - cos(y)) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * y))))) - -2.0) * (0.3333333333333333 / ((0.5 * (t_0 + ((3.0 - sqrt(5.0)) * cos(y)))) - -1.0)); else tmp = (t_1 / t_2) * 0.3333333333333333; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(0.0625 * N[(N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(-0.5 * N[(N[(t$95$0 * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]}, If[LessEqual[x, -175000000.0], N[(N[(t$95$1 * 0.3333333333333333), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[x, 1.45e-5], N[(N[(N[(N[(-0.0625 * N[(N[(1.0 - N[Cos[y], $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -2.0), $MachinePrecision] * N[(0.3333333333333333 / N[(N[(0.5 * N[(t$95$0 + N[(N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision] * N[Cos[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / t$95$2), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \sqrt{5} - 1\\
t_1 := \left(0.0625 \cdot \left(\left(\cos x - 1\right) \cdot \sqrt{2}\right)\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot x\right)\right) - 2\\
t_2 := -0.5 \cdot \left(t\_0 \cdot \cos x - \left(\sqrt{5} - 3\right)\right) - 1\\
\mathbf{if}\;x \leq -175000000:\\
\;\;\;\;\frac{t\_1 \cdot 0.3333333333333333}{t\_2}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\left(\left(-0.0625 \cdot \left(\left(1 - \cos y\right) \cdot \sqrt{2}\right)\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot y\right)\right) - -2\right) \cdot \frac{0.3333333333333333}{0.5 \cdot \left(t\_0 + \left(3 - \sqrt{5}\right) \cdot \cos y\right) - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{t\_2} \cdot 0.3333333333333333\\
\end{array}
if x < -1.75e8Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Applied rewrites59.4%
if -1.75e8 < x < 1.45e-5Initial program 99.3%
Taylor expanded in x around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f6460.1%
Applied rewrites60.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower--.f64N/A
lower-cos.f6459.6%
Applied rewrites59.6%
Applied rewrites59.5%
if 1.45e-5 < x Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Applied rewrites59.4%
(FPCore (x y)
:precision binary64
(*
(/
(-
(*
(* 0.0625 (* (- (cos x) 1.0) (sqrt 2.0)))
(- 0.5 (* 0.5 (cos (* 2.0 x)))))
2.0)
(-
(* -0.5 (- (* (- (sqrt 5.0) 1.0) (cos x)) (- (sqrt 5.0) 3.0)))
1.0))
0.3333333333333333))double code(double x, double y) {
return ((((0.0625 * ((cos(x) - 1.0) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * x))))) - 2.0) / ((-0.5 * (((sqrt(5.0) - 1.0) * cos(x)) - (sqrt(5.0) - 3.0))) - 1.0)) * 0.3333333333333333;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((((0.0625d0 * ((cos(x) - 1.0d0) * sqrt(2.0d0))) * (0.5d0 - (0.5d0 * cos((2.0d0 * x))))) - 2.0d0) / (((-0.5d0) * (((sqrt(5.0d0) - 1.0d0) * cos(x)) - (sqrt(5.0d0) - 3.0d0))) - 1.0d0)) * 0.3333333333333333d0
end function
public static double code(double x, double y) {
return ((((0.0625 * ((Math.cos(x) - 1.0) * Math.sqrt(2.0))) * (0.5 - (0.5 * Math.cos((2.0 * x))))) - 2.0) / ((-0.5 * (((Math.sqrt(5.0) - 1.0) * Math.cos(x)) - (Math.sqrt(5.0) - 3.0))) - 1.0)) * 0.3333333333333333;
}
def code(x, y): return ((((0.0625 * ((math.cos(x) - 1.0) * math.sqrt(2.0))) * (0.5 - (0.5 * math.cos((2.0 * x))))) - 2.0) / ((-0.5 * (((math.sqrt(5.0) - 1.0) * math.cos(x)) - (math.sqrt(5.0) - 3.0))) - 1.0)) * 0.3333333333333333
function code(x, y) return Float64(Float64(Float64(Float64(Float64(0.0625 * Float64(Float64(cos(x) - 1.0) * sqrt(2.0))) * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * x))))) - 2.0) / Float64(Float64(-0.5 * Float64(Float64(Float64(sqrt(5.0) - 1.0) * cos(x)) - Float64(sqrt(5.0) - 3.0))) - 1.0)) * 0.3333333333333333) end
function tmp = code(x, y) tmp = ((((0.0625 * ((cos(x) - 1.0) * sqrt(2.0))) * (0.5 - (0.5 * cos((2.0 * x))))) - 2.0) / ((-0.5 * (((sqrt(5.0) - 1.0) * cos(x)) - (sqrt(5.0) - 3.0))) - 1.0)) * 0.3333333333333333; end
code[x_, y_] := N[(N[(N[(N[(N[(0.0625 * N[(N[(N[Cos[x], $MachinePrecision] - 1.0), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] / N[(N[(-0.5 * N[(N[(N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision] * N[Cos[x], $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[5.0], $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]
\frac{\left(0.0625 \cdot \left(\left(\cos x - 1\right) \cdot \sqrt{2}\right)\right) \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot x\right)\right) - 2}{-0.5 \cdot \left(\left(\sqrt{5} - 1\right) \cdot \cos x - \left(\sqrt{5} - 3\right)\right) - 1} \cdot 0.3333333333333333
Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Applied rewrites59.4%
(FPCore (x y)
:precision binary64
(*
0.3333333333333333
(/
2.0
(+
1.0
(+
(* 0.5 (* (cos x) (- (sqrt 5.0) 1.0)))
(* 0.5 (- 3.0 (sqrt 5.0))))))))double code(double x, double y) {
return 0.3333333333333333 * (2.0 / (1.0 + ((0.5 * (cos(x) * (sqrt(5.0) - 1.0))) + (0.5 * (3.0 - sqrt(5.0))))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.3333333333333333d0 * (2.0d0 / (1.0d0 + ((0.5d0 * (cos(x) * (sqrt(5.0d0) - 1.0d0))) + (0.5d0 * (3.0d0 - sqrt(5.0d0))))))
end function
public static double code(double x, double y) {
return 0.3333333333333333 * (2.0 / (1.0 + ((0.5 * (Math.cos(x) * (Math.sqrt(5.0) - 1.0))) + (0.5 * (3.0 - Math.sqrt(5.0))))));
}
def code(x, y): return 0.3333333333333333 * (2.0 / (1.0 + ((0.5 * (math.cos(x) * (math.sqrt(5.0) - 1.0))) + (0.5 * (3.0 - math.sqrt(5.0))))))
function code(x, y) return Float64(0.3333333333333333 * Float64(2.0 / Float64(1.0 + Float64(Float64(0.5 * Float64(cos(x) * Float64(sqrt(5.0) - 1.0))) + Float64(0.5 * Float64(3.0 - sqrt(5.0))))))) end
function tmp = code(x, y) tmp = 0.3333333333333333 * (2.0 / (1.0 + ((0.5 * (cos(x) * (sqrt(5.0) - 1.0))) + (0.5 * (3.0 - sqrt(5.0)))))); end
code[x_, y_] := N[(0.3333333333333333 * N[(2.0 / N[(1.0 + N[(N[(0.5 * N[(N[Cos[x], $MachinePrecision] * N[(N[Sqrt[5.0], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(3.0 - N[Sqrt[5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
0.3333333333333333 \cdot \frac{2}{1 + \left(0.5 \cdot \left(\cos x \cdot \left(\sqrt{5} - 1\right)\right) + 0.5 \cdot \left(3 - \sqrt{5}\right)\right)}
Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Taylor expanded in x around 0
Applied rewrites43.0%
(FPCore (x y) :precision binary64 0.3333333333333333)
double code(double x, double y) {
return 0.3333333333333333;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.3333333333333333d0
end function
public static double code(double x, double y) {
return 0.3333333333333333;
}
def code(x, y): return 0.3333333333333333
function code(x, y) return 0.3333333333333333 end
function tmp = code(x, y) tmp = 0.3333333333333333; end
code[x_, y_] := 0.3333333333333333
0.3333333333333333
Initial program 99.3%
Taylor expanded in y around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites59.4%
Taylor expanded in x around 0
lower-/.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-sqrt.f6440.5%
Applied rewrites40.5%
Evaluated real constant40.5%
herbie shell --seed 2025258
(FPCore (x y)
:name "Diagrams.TwoD.Path.Metafont.Internal:hobbyF from diagrams-contrib-1.3.0.5"
:precision binary64
(/ (+ 2.0 (* (* (* (sqrt 2.0) (- (sin x) (/ (sin y) 16.0))) (- (sin y) (/ (sin x) 16.0))) (- (cos x) (cos y)))) (* 3.0 (+ (+ 1.0 (* (/ (- (sqrt 5.0) 1.0) 2.0) (cos x))) (* (/ (- 3.0 (sqrt 5.0)) 2.0) (cos y))))))