
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
Herbie found 30 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+
(pow
(-
(* (sin (* 0.5 phi1)) (cos (* phi2 0.5)))
(* (cos (* 0.5 phi1)) (sin (* phi2 0.5))))
2.0)
(*
(cos phi1)
(*
(cos phi2)
(pow
(-
(* (cos (* 0.5 lambda2)) (sin (* 0.5 lambda1)))
(* (cos (* 0.5 lambda1)) (sin (* 0.5 lambda2))))
2.0))))))
(* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0)))))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((0.5 * phi1)) * cos((phi2 * 0.5))) - (cos((0.5 * phi1)) * sin((phi2 * 0.5)))), 2.0) + (cos(phi1) * (cos(phi2) * pow(((cos((0.5 * lambda2)) * sin((0.5 * lambda1))) - (cos((0.5 * lambda1)) * sin((0.5 * lambda2)))), 2.0)));
return R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = (((sin((0.5d0 * phi1)) * cos((phi2 * 0.5d0))) - (cos((0.5d0 * phi1)) * sin((phi2 * 0.5d0)))) ** 2.0d0) + (cos(phi1) * (cos(phi2) * (((cos((0.5d0 * lambda2)) * sin((0.5d0 * lambda1))) - (cos((0.5d0 * lambda1)) * sin((0.5d0 * lambda2)))) ** 2.0d0)))
code = r * (2.0d0 * atan2(sqrt(t_0), sqrt((1.0d0 - t_0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.sin((0.5 * phi1)) * Math.cos((phi2 * 0.5))) - (Math.cos((0.5 * phi1)) * Math.sin((phi2 * 0.5)))), 2.0) + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(((Math.cos((0.5 * lambda2)) * Math.sin((0.5 * lambda1))) - (Math.cos((0.5 * lambda1)) * Math.sin((0.5 * lambda2)))), 2.0)));
return R * (2.0 * Math.atan2(Math.sqrt(t_0), Math.sqrt((1.0 - t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((0.5 * phi1)) * math.cos((phi2 * 0.5))) - (math.cos((0.5 * phi1)) * math.sin((phi2 * 0.5)))), 2.0) + (math.cos(phi1) * (math.cos(phi2) * math.pow(((math.cos((0.5 * lambda2)) * math.sin((0.5 * lambda1))) - (math.cos((0.5 * lambda1)) * math.sin((0.5 * lambda2)))), 2.0))) return R * (2.0 * math.atan2(math.sqrt(t_0), math.sqrt((1.0 - t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64((Float64(Float64(sin(Float64(0.5 * phi1)) * cos(Float64(phi2 * 0.5))) - Float64(cos(Float64(0.5 * phi1)) * sin(Float64(phi2 * 0.5)))) ^ 2.0) + Float64(cos(phi1) * Float64(cos(phi2) * (Float64(Float64(cos(Float64(0.5 * lambda2)) * sin(Float64(0.5 * lambda1))) - Float64(cos(Float64(0.5 * lambda1)) * sin(Float64(0.5 * lambda2)))) ^ 2.0)))) return Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = (((sin((0.5 * phi1)) * cos((phi2 * 0.5))) - (cos((0.5 * phi1)) * sin((phi2 * 0.5)))) ^ 2.0) + (cos(phi1) * (cos(phi2) * (((cos((0.5 * lambda2)) * sin((0.5 * lambda1))) - (cos((0.5 * lambda1)) * sin((0.5 * lambda2)))) ^ 2.0))); tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Power[N[(N[(N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[(N[(N[Cos[N[(0.5 * lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := {\left(\sin \left(0.5 \cdot \phi_1\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2} + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\left(\cos \left(0.5 \cdot \lambda_2\right) \cdot \sin \left(0.5 \cdot \lambda_1\right) - \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin \left(0.5 \cdot \lambda_2\right)\right)}^{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)
\end{array}
Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
Applied rewrites76.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
Applied rewrites98.6%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
Applied rewrites98.6%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
Applied rewrites98.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 lambda2)))
(t_1 (* (sin (* 0.5 phi1)) (cos (* phi2 0.5))))
(t_2 (* (cos (* 0.5 lambda2)) (sin (* 0.5 lambda1))))
(t_3
(*
(cos phi1)
(*
(cos phi2)
(pow (- t_2 (* (cos (* 0.5 lambda1)) t_0)) 2.0))))
(t_4 (+ (pow (- t_1 (sin (* 0.5 phi2))) 2.0) t_3))
(t_5
(+
(pow (- t_1 (* (cos (* 0.5 phi1)) (sin (* phi2 0.5)))) 2.0)
(* (cos phi1) (* (cos phi2) (pow (- t_2 t_0) 2.0)))))
(t_6 (+ t_3 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))
(if (<= lambda1 -0.36)
(* R (* 2.0 (atan2 (sqrt t_4) (sqrt (- 1.0 t_4)))))
(if (<= lambda1 120.0)
(* R (* 2.0 (atan2 (sqrt t_5) (sqrt (- 1.0 t_5)))))
(* R (* 2.0 (atan2 (sqrt t_6) (sqrt (- 1.0 t_6)))))))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * lambda2));
double t_1 = sin((0.5 * phi1)) * cos((phi2 * 0.5));
double t_2 = cos((0.5 * lambda2)) * sin((0.5 * lambda1));
double t_3 = cos(phi1) * (cos(phi2) * pow((t_2 - (cos((0.5 * lambda1)) * t_0)), 2.0));
double t_4 = pow((t_1 - sin((0.5 * phi2))), 2.0) + t_3;
double t_5 = pow((t_1 - (cos((0.5 * phi1)) * sin((phi2 * 0.5)))), 2.0) + (cos(phi1) * (cos(phi2) * pow((t_2 - t_0), 2.0)));
double t_6 = t_3 + pow(sin((0.5 * (phi1 - phi2))), 2.0);
double tmp;
if (lambda1 <= -0.36) {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4))));
} else if (lambda1 <= 120.0) {
tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_5))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_6), sqrt((1.0 - t_6))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = sin((0.5d0 * lambda2))
t_1 = sin((0.5d0 * phi1)) * cos((phi2 * 0.5d0))
t_2 = cos((0.5d0 * lambda2)) * sin((0.5d0 * lambda1))
t_3 = cos(phi1) * (cos(phi2) * ((t_2 - (cos((0.5d0 * lambda1)) * t_0)) ** 2.0d0))
t_4 = ((t_1 - sin((0.5d0 * phi2))) ** 2.0d0) + t_3
t_5 = ((t_1 - (cos((0.5d0 * phi1)) * sin((phi2 * 0.5d0)))) ** 2.0d0) + (cos(phi1) * (cos(phi2) * ((t_2 - t_0) ** 2.0d0)))
t_6 = t_3 + (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)
if (lambda1 <= (-0.36d0)) then
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt((1.0d0 - t_4))))
else if (lambda1 <= 120.0d0) then
tmp = r * (2.0d0 * atan2(sqrt(t_5), sqrt((1.0d0 - t_5))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_6), sqrt((1.0d0 - t_6))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((0.5 * lambda2));
double t_1 = Math.sin((0.5 * phi1)) * Math.cos((phi2 * 0.5));
double t_2 = Math.cos((0.5 * lambda2)) * Math.sin((0.5 * lambda1));
double t_3 = Math.cos(phi1) * (Math.cos(phi2) * Math.pow((t_2 - (Math.cos((0.5 * lambda1)) * t_0)), 2.0));
double t_4 = Math.pow((t_1 - Math.sin((0.5 * phi2))), 2.0) + t_3;
double t_5 = Math.pow((t_1 - (Math.cos((0.5 * phi1)) * Math.sin((phi2 * 0.5)))), 2.0) + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow((t_2 - t_0), 2.0)));
double t_6 = t_3 + Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0);
double tmp;
if (lambda1 <= -0.36) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt((1.0 - t_4))));
} else if (lambda1 <= 120.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_5), Math.sqrt((1.0 - t_5))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_6), Math.sqrt((1.0 - t_6))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((0.5 * lambda2)) t_1 = math.sin((0.5 * phi1)) * math.cos((phi2 * 0.5)) t_2 = math.cos((0.5 * lambda2)) * math.sin((0.5 * lambda1)) t_3 = math.cos(phi1) * (math.cos(phi2) * math.pow((t_2 - (math.cos((0.5 * lambda1)) * t_0)), 2.0)) t_4 = math.pow((t_1 - math.sin((0.5 * phi2))), 2.0) + t_3 t_5 = math.pow((t_1 - (math.cos((0.5 * phi1)) * math.sin((phi2 * 0.5)))), 2.0) + (math.cos(phi1) * (math.cos(phi2) * math.pow((t_2 - t_0), 2.0))) t_6 = t_3 + math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0) tmp = 0 if lambda1 <= -0.36: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt((1.0 - t_4)))) elif lambda1 <= 120.0: tmp = R * (2.0 * math.atan2(math.sqrt(t_5), math.sqrt((1.0 - t_5)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_6), math.sqrt((1.0 - t_6)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * lambda2)) t_1 = Float64(sin(Float64(0.5 * phi1)) * cos(Float64(phi2 * 0.5))) t_2 = Float64(cos(Float64(0.5 * lambda2)) * sin(Float64(0.5 * lambda1))) t_3 = Float64(cos(phi1) * Float64(cos(phi2) * (Float64(t_2 - Float64(cos(Float64(0.5 * lambda1)) * t_0)) ^ 2.0))) t_4 = Float64((Float64(t_1 - sin(Float64(0.5 * phi2))) ^ 2.0) + t_3) t_5 = Float64((Float64(t_1 - Float64(cos(Float64(0.5 * phi1)) * sin(Float64(phi2 * 0.5)))) ^ 2.0) + Float64(cos(phi1) * Float64(cos(phi2) * (Float64(t_2 - t_0) ^ 2.0)))) t_6 = Float64(t_3 + (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)) tmp = 0.0 if (lambda1 <= -0.36) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(1.0 - t_4))))); elseif (lambda1 <= 120.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_5), sqrt(Float64(1.0 - t_5))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_6), sqrt(Float64(1.0 - t_6))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * lambda2)); t_1 = sin((0.5 * phi1)) * cos((phi2 * 0.5)); t_2 = cos((0.5 * lambda2)) * sin((0.5 * lambda1)); t_3 = cos(phi1) * (cos(phi2) * ((t_2 - (cos((0.5 * lambda1)) * t_0)) ^ 2.0)); t_4 = ((t_1 - sin((0.5 * phi2))) ^ 2.0) + t_3; t_5 = ((t_1 - (cos((0.5 * phi1)) * sin((phi2 * 0.5)))) ^ 2.0) + (cos(phi1) * (cos(phi2) * ((t_2 - t_0) ^ 2.0))); t_6 = t_3 + (sin((0.5 * (phi1 - phi2))) ^ 2.0); tmp = 0.0; if (lambda1 <= -0.36) tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4)))); elseif (lambda1 <= 120.0) tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_5)))); else tmp = R * (2.0 * atan2(sqrt(t_6), sqrt((1.0 - t_6)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[N[(0.5 * lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[(t$95$2 - N[(N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Power[N[(t$95$1 - N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[(N[Power[N[(t$95$1 - N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[(t$95$2 - t$95$0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(t$95$3 + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -0.36], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 120.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$5], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$6], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$6), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \lambda_2\right)\\
t_1 := \sin \left(0.5 \cdot \phi_1\right) \cdot \cos \left(\phi_2 \cdot 0.5\right)\\
t_2 := \cos \left(0.5 \cdot \lambda_2\right) \cdot \sin \left(0.5 \cdot \lambda_1\right)\\
t_3 := \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\left(t\_2 - \cos \left(0.5 \cdot \lambda_1\right) \cdot t\_0\right)}^{2}\right)\\
t_4 := {\left(t\_1 - \sin \left(0.5 \cdot \phi_2\right)\right)}^{2} + t\_3\\
t_5 := {\left(t\_1 - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2} + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\left(t\_2 - t\_0\right)}^{2}\right)\\
t_6 := t\_3 + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\\
\mathbf{if}\;\lambda_1 \leq -0.36:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{1 - t\_4}}\right)\\
\mathbf{elif}\;\lambda_1 \leq 120:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5}}{\sqrt{1 - t\_5}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_6}}{\sqrt{1 - t\_6}}\right)\\
\end{array}
if lambda1 < -0.35999999999999999Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
Applied rewrites76.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
Applied rewrites98.6%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
Applied rewrites98.6%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
Applied rewrites98.6%
Taylor expanded in phi1 around 0
lower-sin.f64N/A
lower-*.f6477.5%
Applied rewrites77.5%
Taylor expanded in phi1 around 0
lower-sin.f64N/A
lower-*.f6475.3%
Applied rewrites75.3%
if -0.35999999999999999 < lambda1 < 120Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
Applied rewrites76.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
Applied rewrites98.6%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
Applied rewrites98.6%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
Applied rewrites98.6%
Taylor expanded in lambda1 around 0
lower-sin.f64N/A
lower-*.f6478.5%
Applied rewrites78.5%
Taylor expanded in lambda1 around 0
lower-sin.f64N/A
lower-*.f6477.2%
Applied rewrites77.2%
if 120 < lambda1 Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
Taylor expanded in lambda1 around inf
lower-+.f64N/A
Applied rewrites75.9%
Taylor expanded in lambda1 around inf
lower-+.f64N/A
Applied rewrites75.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (cos (* phi2 0.5)))
(t_2
(+
(pow
(-
(* (sin (* phi1 0.5)) t_1)
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0)))
(t_3
(*
(cos phi1)
(*
(cos phi2)
(pow
(-
(* (cos (* 0.5 lambda2)) (sin (* 0.5 lambda1)))
(* (cos (* 0.5 lambda1)) (sin (* 0.5 lambda2))))
2.0))))
(t_4 (+ t_3 (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
(t_5
(+
(pow (- (* (sin (* 0.5 phi1)) t_1) (sin (* 0.5 phi2))) 2.0)
t_3)))
(if (<= lambda1 -1750.0)
(* R (* 2.0 (atan2 (sqrt t_5) (sqrt (- 1.0 t_5)))))
(if (<= lambda1 135.0)
(* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2)))))
(* R (* 2.0 (atan2 (sqrt t_4) (sqrt (- 1.0 t_4)))))))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos((phi2 * 0.5));
double t_2 = pow(((sin((phi1 * 0.5)) * t_1) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
double t_3 = cos(phi1) * (cos(phi2) * pow(((cos((0.5 * lambda2)) * sin((0.5 * lambda1))) - (cos((0.5 * lambda1)) * sin((0.5 * lambda2)))), 2.0));
double t_4 = t_3 + pow(sin((0.5 * (phi1 - phi2))), 2.0);
double t_5 = pow(((sin((0.5 * phi1)) * t_1) - sin((0.5 * phi2))), 2.0) + t_3;
double tmp;
if (lambda1 <= -1750.0) {
tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_5))));
} else if (lambda1 <= 135.0) {
tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4))));
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos((phi2 * 0.5d0))
t_2 = (((sin((phi1 * 0.5d0)) * t_1) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
t_3 = cos(phi1) * (cos(phi2) * (((cos((0.5d0 * lambda2)) * sin((0.5d0 * lambda1))) - (cos((0.5d0 * lambda1)) * sin((0.5d0 * lambda2)))) ** 2.0d0))
t_4 = t_3 + (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)
t_5 = (((sin((0.5d0 * phi1)) * t_1) - sin((0.5d0 * phi2))) ** 2.0d0) + t_3
if (lambda1 <= (-1750.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt(t_5), sqrt((1.0d0 - t_5))))
else if (lambda1 <= 135.0d0) then
tmp = r * (2.0d0 * atan2(sqrt(t_2), sqrt((1.0d0 - t_2))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt((1.0d0 - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos((phi2 * 0.5));
double t_2 = Math.pow(((Math.sin((phi1 * 0.5)) * t_1) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
double t_3 = Math.cos(phi1) * (Math.cos(phi2) * Math.pow(((Math.cos((0.5 * lambda2)) * Math.sin((0.5 * lambda1))) - (Math.cos((0.5 * lambda1)) * Math.sin((0.5 * lambda2)))), 2.0));
double t_4 = t_3 + Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0);
double t_5 = Math.pow(((Math.sin((0.5 * phi1)) * t_1) - Math.sin((0.5 * phi2))), 2.0) + t_3;
double tmp;
if (lambda1 <= -1750.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_5), Math.sqrt((1.0 - t_5))));
} else if (lambda1 <= 135.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_2), Math.sqrt((1.0 - t_2))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt((1.0 - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos((phi2 * 0.5)) t_2 = math.pow(((math.sin((phi1 * 0.5)) * t_1) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) t_3 = math.cos(phi1) * (math.cos(phi2) * math.pow(((math.cos((0.5 * lambda2)) * math.sin((0.5 * lambda1))) - (math.cos((0.5 * lambda1)) * math.sin((0.5 * lambda2)))), 2.0)) t_4 = t_3 + math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0) t_5 = math.pow(((math.sin((0.5 * phi1)) * t_1) - math.sin((0.5 * phi2))), 2.0) + t_3 tmp = 0 if lambda1 <= -1750.0: tmp = R * (2.0 * math.atan2(math.sqrt(t_5), math.sqrt((1.0 - t_5)))) elif lambda1 <= 135.0: tmp = R * (2.0 * math.atan2(math.sqrt(t_2), math.sqrt((1.0 - t_2)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt((1.0 - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = cos(Float64(phi2 * 0.5)) t_2 = Float64((Float64(Float64(sin(Float64(phi1 * 0.5)) * t_1) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) t_3 = Float64(cos(phi1) * Float64(cos(phi2) * (Float64(Float64(cos(Float64(0.5 * lambda2)) * sin(Float64(0.5 * lambda1))) - Float64(cos(Float64(0.5 * lambda1)) * sin(Float64(0.5 * lambda2)))) ^ 2.0))) t_4 = Float64(t_3 + (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)) t_5 = Float64((Float64(Float64(sin(Float64(0.5 * phi1)) * t_1) - sin(Float64(0.5 * phi2))) ^ 2.0) + t_3) tmp = 0.0 if (lambda1 <= -1750.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_5), sqrt(Float64(1.0 - t_5))))); elseif (lambda1 <= 135.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(1.0 - t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos((phi2 * 0.5)); t_2 = (((sin((phi1 * 0.5)) * t_1) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); t_3 = cos(phi1) * (cos(phi2) * (((cos((0.5 * lambda2)) * sin((0.5 * lambda1))) - (cos((0.5 * lambda1)) * sin((0.5 * lambda2)))) ^ 2.0)); t_4 = t_3 + (sin((0.5 * (phi1 - phi2))) ^ 2.0); t_5 = (((sin((0.5 * phi1)) * t_1) - sin((0.5 * phi2))) ^ 2.0) + t_3; tmp = 0.0; if (lambda1 <= -1750.0) tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_5)))); elseif (lambda1 <= 135.0) tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2)))); else tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[(N[(N[Cos[N[(0.5 * lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[Power[N[(N[(N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision] - N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$3), $MachinePrecision]}, If[LessEqual[lambda1, -1750.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$5], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 135.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \left(\phi_2 \cdot 0.5\right)\\
t_2 := {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot t\_1 - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
t_3 := \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\left(\cos \left(0.5 \cdot \lambda_2\right) \cdot \sin \left(0.5 \cdot \lambda_1\right) - \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin \left(0.5 \cdot \lambda_2\right)\right)}^{2}\right)\\
t_4 := t\_3 + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\\
t_5 := {\left(\sin \left(0.5 \cdot \phi_1\right) \cdot t\_1 - \sin \left(0.5 \cdot \phi_2\right)\right)}^{2} + t\_3\\
\mathbf{if}\;\lambda_1 \leq -1750:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5}}{\sqrt{1 - t\_5}}\right)\\
\mathbf{elif}\;\lambda_1 \leq 135:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{1 - t\_4}}\right)\\
\end{array}
if lambda1 < -1750Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
Applied rewrites76.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
Applied rewrites98.6%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
Applied rewrites98.6%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
Applied rewrites98.6%
Taylor expanded in phi1 around 0
lower-sin.f64N/A
lower-*.f6477.5%
Applied rewrites77.5%
Taylor expanded in phi1 around 0
lower-sin.f64N/A
lower-*.f6475.3%
Applied rewrites75.3%
if -1750 < lambda1 < 135Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.9%
Applied rewrites61.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6477.8%
Applied rewrites77.8%
if 135 < lambda1 Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
Taylor expanded in lambda1 around inf
lower-+.f64N/A
Applied rewrites75.9%
Taylor expanded in lambda1 around inf
lower-+.f64N/A
Applied rewrites75.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow
(-
(* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0)))
(t_2
(+
(*
(cos phi1)
(*
(cos phi2)
(pow
(-
(* (cos (* 0.5 lambda2)) (sin (* 0.5 lambda1)))
(* (cos (* 0.5 lambda1)) (sin (* 0.5 lambda2))))
2.0)))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
(t_3 (* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2)))))))
(if (<= lambda1 -1750.0)
t_3
(if (<= lambda1 135.0)
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))
t_3))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
double t_2 = (cos(phi1) * (cos(phi2) * pow(((cos((0.5 * lambda2)) * sin((0.5 * lambda1))) - (cos((0.5 * lambda1)) * sin((0.5 * lambda2)))), 2.0))) + pow(sin((0.5 * (phi1 - phi2))), 2.0);
double t_3 = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
double tmp;
if (lambda1 <= -1750.0) {
tmp = t_3;
} else if (lambda1 <= 135.0) {
tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
} 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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (((sin((phi1 * 0.5d0)) * cos((phi2 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
t_2 = (cos(phi1) * (cos(phi2) * (((cos((0.5d0 * lambda2)) * sin((0.5d0 * lambda1))) - (cos((0.5d0 * lambda1)) * sin((0.5d0 * lambda2)))) ** 2.0d0))) + (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)
t_3 = r * (2.0d0 * atan2(sqrt(t_2), sqrt((1.0d0 - t_2))))
if (lambda1 <= (-1750.0d0)) then
tmp = t_3
else if (lambda1 <= 135.0d0) then
tmp = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
else
tmp = t_3
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((phi2 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
double t_2 = (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(((Math.cos((0.5 * lambda2)) * Math.sin((0.5 * lambda1))) - (Math.cos((0.5 * lambda1)) * Math.sin((0.5 * lambda2)))), 2.0))) + Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0);
double t_3 = R * (2.0 * Math.atan2(Math.sqrt(t_2), Math.sqrt((1.0 - t_2))));
double tmp;
if (lambda1 <= -1750.0) {
tmp = t_3;
} else if (lambda1 <= 135.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
} else {
tmp = t_3;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(((math.sin((phi1 * 0.5)) * math.cos((phi2 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) t_2 = (math.cos(phi1) * (math.cos(phi2) * math.pow(((math.cos((0.5 * lambda2)) * math.sin((0.5 * lambda1))) - (math.cos((0.5 * lambda1)) * math.sin((0.5 * lambda2)))), 2.0))) + math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0) t_3 = R * (2.0 * math.atan2(math.sqrt(t_2), math.sqrt((1.0 - t_2)))) tmp = 0 if lambda1 <= -1750.0: tmp = t_3 elif lambda1 <= 135.0: tmp = R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1)))) else: tmp = t_3 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) t_2 = Float64(Float64(cos(phi1) * Float64(cos(phi2) * (Float64(Float64(cos(Float64(0.5 * lambda2)) * sin(Float64(0.5 * lambda1))) - Float64(cos(Float64(0.5 * lambda1)) * sin(Float64(0.5 * lambda2)))) ^ 2.0))) + (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)) t_3 = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))) tmp = 0.0 if (lambda1 <= -1750.0) tmp = t_3; elseif (lambda1 <= 135.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))); else tmp = t_3; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); t_2 = (cos(phi1) * (cos(phi2) * (((cos((0.5 * lambda2)) * sin((0.5 * lambda1))) - (cos((0.5 * lambda1)) * sin((0.5 * lambda2)))) ^ 2.0))) + (sin((0.5 * (phi1 - phi2))) ^ 2.0); t_3 = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2)))); tmp = 0.0; if (lambda1 <= -1750.0) tmp = t_3; elseif (lambda1 <= 135.0) tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); else tmp = t_3; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[(N[(N[Cos[N[(0.5 * lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -1750.0], t$95$3, If[LessEqual[lambda1, 135.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
t_2 := \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\left(\cos \left(0.5 \cdot \lambda_2\right) \cdot \sin \left(0.5 \cdot \lambda_1\right) - \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin \left(0.5 \cdot \lambda_2\right)\right)}^{2}\right) + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\\
t_3 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{if}\;\lambda_1 \leq -1750:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\lambda_1 \leq 135:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
if lambda1 < -1750 or 135 < lambda1 Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
Taylor expanded in lambda1 around inf
lower-+.f64N/A
Applied rewrites75.9%
Taylor expanded in lambda1 around inf
lower-+.f64N/A
Applied rewrites75.9%
if -1750 < lambda1 < 135Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.9%
Applied rewrites61.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6477.8%
Applied rewrites77.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+
(*
(cos phi1)
(*
(cos phi2)
(pow
(-
(* (cos (* 0.5 lambda2)) (sin (* 0.5 lambda1)))
(* (cos (* 0.5 lambda1)) (sin (* 0.5 lambda2))))
2.0)))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
(t_1 (* (cos (* 1.0 (- lambda1 lambda2))) 0.5))
(t_2 (* (cos phi2) (cos phi1)))
(t_3 (* 0.5 (+ t_2 (* (sin phi2) (sin phi1)))))
(t_4 (* (- 0.5 (* 0.5 (- (+ 0.5 t_1) (- 0.5 t_1)))) t_2))
(t_5
(*
(atan2 (sqrt (+ t_4 (- 0.5 t_3))) (sqrt (- (+ 0.5 t_3) t_4)))
(* 2.0 R))))
(if (<= phi1 -2.1e-8)
t_5
(if (<= phi1 7.2e+47)
(* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0)))))
t_5))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(phi1) * (cos(phi2) * pow(((cos((0.5 * lambda2)) * sin((0.5 * lambda1))) - (cos((0.5 * lambda1)) * sin((0.5 * lambda2)))), 2.0))) + pow(sin((0.5 * (phi1 - phi2))), 2.0);
double t_1 = cos((1.0 * (lambda1 - lambda2))) * 0.5;
double t_2 = cos(phi2) * cos(phi1);
double t_3 = 0.5 * (t_2 + (sin(phi2) * sin(phi1)));
double t_4 = (0.5 - (0.5 * ((0.5 + t_1) - (0.5 - t_1)))) * t_2;
double t_5 = atan2(sqrt((t_4 + (0.5 - t_3))), sqrt(((0.5 + t_3) - t_4))) * (2.0 * R);
double tmp;
if (phi1 <= -2.1e-8) {
tmp = t_5;
} else if (phi1 <= 7.2e+47) {
tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
} else {
tmp = t_5;
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = (cos(phi1) * (cos(phi2) * (((cos((0.5d0 * lambda2)) * sin((0.5d0 * lambda1))) - (cos((0.5d0 * lambda1)) * sin((0.5d0 * lambda2)))) ** 2.0d0))) + (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)
t_1 = cos((1.0d0 * (lambda1 - lambda2))) * 0.5d0
t_2 = cos(phi2) * cos(phi1)
t_3 = 0.5d0 * (t_2 + (sin(phi2) * sin(phi1)))
t_4 = (0.5d0 - (0.5d0 * ((0.5d0 + t_1) - (0.5d0 - t_1)))) * t_2
t_5 = atan2(sqrt((t_4 + (0.5d0 - t_3))), sqrt(((0.5d0 + t_3) - t_4))) * (2.0d0 * r)
if (phi1 <= (-2.1d-8)) then
tmp = t_5
else if (phi1 <= 7.2d+47) then
tmp = r * (2.0d0 * atan2(sqrt(t_0), sqrt((1.0d0 - t_0))))
else
tmp = t_5
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(((Math.cos((0.5 * lambda2)) * Math.sin((0.5 * lambda1))) - (Math.cos((0.5 * lambda1)) * Math.sin((0.5 * lambda2)))), 2.0))) + Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0);
double t_1 = Math.cos((1.0 * (lambda1 - lambda2))) * 0.5;
double t_2 = Math.cos(phi2) * Math.cos(phi1);
double t_3 = 0.5 * (t_2 + (Math.sin(phi2) * Math.sin(phi1)));
double t_4 = (0.5 - (0.5 * ((0.5 + t_1) - (0.5 - t_1)))) * t_2;
double t_5 = Math.atan2(Math.sqrt((t_4 + (0.5 - t_3))), Math.sqrt(((0.5 + t_3) - t_4))) * (2.0 * R);
double tmp;
if (phi1 <= -2.1e-8) {
tmp = t_5;
} else if (phi1 <= 7.2e+47) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_0), Math.sqrt((1.0 - t_0))));
} else {
tmp = t_5;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.cos(phi1) * (math.cos(phi2) * math.pow(((math.cos((0.5 * lambda2)) * math.sin((0.5 * lambda1))) - (math.cos((0.5 * lambda1)) * math.sin((0.5 * lambda2)))), 2.0))) + math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0) t_1 = math.cos((1.0 * (lambda1 - lambda2))) * 0.5 t_2 = math.cos(phi2) * math.cos(phi1) t_3 = 0.5 * (t_2 + (math.sin(phi2) * math.sin(phi1))) t_4 = (0.5 - (0.5 * ((0.5 + t_1) - (0.5 - t_1)))) * t_2 t_5 = math.atan2(math.sqrt((t_4 + (0.5 - t_3))), math.sqrt(((0.5 + t_3) - t_4))) * (2.0 * R) tmp = 0 if phi1 <= -2.1e-8: tmp = t_5 elif phi1 <= 7.2e+47: tmp = R * (2.0 * math.atan2(math.sqrt(t_0), math.sqrt((1.0 - t_0)))) else: tmp = t_5 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(phi1) * Float64(cos(phi2) * (Float64(Float64(cos(Float64(0.5 * lambda2)) * sin(Float64(0.5 * lambda1))) - Float64(cos(Float64(0.5 * lambda1)) * sin(Float64(0.5 * lambda2)))) ^ 2.0))) + (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)) t_1 = Float64(cos(Float64(1.0 * Float64(lambda1 - lambda2))) * 0.5) t_2 = Float64(cos(phi2) * cos(phi1)) t_3 = Float64(0.5 * Float64(t_2 + Float64(sin(phi2) * sin(phi1)))) t_4 = Float64(Float64(0.5 - Float64(0.5 * Float64(Float64(0.5 + t_1) - Float64(0.5 - t_1)))) * t_2) t_5 = Float64(atan(sqrt(Float64(t_4 + Float64(0.5 - t_3))), sqrt(Float64(Float64(0.5 + t_3) - t_4))) * Float64(2.0 * R)) tmp = 0.0 if (phi1 <= -2.1e-8) tmp = t_5; elseif (phi1 <= 7.2e+47) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))); else tmp = t_5; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (cos(phi1) * (cos(phi2) * (((cos((0.5 * lambda2)) * sin((0.5 * lambda1))) - (cos((0.5 * lambda1)) * sin((0.5 * lambda2)))) ^ 2.0))) + (sin((0.5 * (phi1 - phi2))) ^ 2.0); t_1 = cos((1.0 * (lambda1 - lambda2))) * 0.5; t_2 = cos(phi2) * cos(phi1); t_3 = 0.5 * (t_2 + (sin(phi2) * sin(phi1))); t_4 = (0.5 - (0.5 * ((0.5 + t_1) - (0.5 - t_1)))) * t_2; t_5 = atan2(sqrt((t_4 + (0.5 - t_3))), sqrt(((0.5 + t_3) - t_4))) * (2.0 * R); tmp = 0.0; if (phi1 <= -2.1e-8) tmp = t_5; elseif (phi1 <= 7.2e+47) tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0)))); else tmp = t_5; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[(N[(N[Cos[N[(0.5 * lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[N[(1.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(0.5 * N[(t$95$2 + N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(0.5 - N[(0.5 * N[(N[(0.5 + t$95$1), $MachinePrecision] - N[(0.5 - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$5 = N[(N[ArcTan[N[Sqrt[N[(t$95$4 + N[(0.5 - t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + t$95$3), $MachinePrecision] - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -2.1e-8], t$95$5, If[LessEqual[phi1, 7.2e+47], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$5]]]]]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\left(\cos \left(0.5 \cdot \lambda_2\right) \cdot \sin \left(0.5 \cdot \lambda_1\right) - \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin \left(0.5 \cdot \lambda_2\right)\right)}^{2}\right) + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\\
t_1 := \cos \left(1 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot 0.5\\
t_2 := \cos \phi_2 \cdot \cos \phi_1\\
t_3 := 0.5 \cdot \left(t\_2 + \sin \phi_2 \cdot \sin \phi_1\right)\\
t_4 := \left(0.5 - 0.5 \cdot \left(\left(0.5 + t\_1\right) - \left(0.5 - t\_1\right)\right)\right) \cdot t\_2\\
t_5 := \tan^{-1}_* \frac{\sqrt{t\_4 + \left(0.5 - t\_3\right)}}{\sqrt{\left(0.5 + t\_3\right) - t\_4}} \cdot \left(2 \cdot R\right)\\
\mathbf{if}\;\phi_1 \leq -2.1 \cdot 10^{-8}:\\
\;\;\;\;t\_5\\
\mathbf{elif}\;\phi_1 \leq 7.2 \cdot 10^{+47}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_5\\
\end{array}
if phi1 < -2.0999999999999999e-8 or 7.2000000000000002e47 < phi1 Initial program 60.9%
Applied rewrites56.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6457.0%
Applied rewrites57.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6472.9%
Applied rewrites72.9%
lift-cos.f64N/A
lift-*.f64N/A
cos-2N/A
sqr-sin-a-revN/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f64N/A
Applied rewrites72.9%
lift-cos.f64N/A
lift-*.f64N/A
cos-2N/A
sqr-sin-a-revN/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f64N/A
Applied rewrites72.9%
if -2.0999999999999999e-8 < phi1 < 7.2000000000000002e47Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
Taylor expanded in lambda1 around inf
lower-+.f64N/A
Applied rewrites75.9%
Taylor expanded in lambda1 around inf
lower-+.f64N/A
Applied rewrites75.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+
(*
(cos phi2)
(pow
(-
(* (cos (* 0.5 lambda2)) (sin (* 0.5 lambda1)))
(* (cos (* 0.5 lambda1)) (sin (* 0.5 lambda2))))
2.0))
(pow (sin (* -0.5 phi2)) 2.0)))
(t_1 (* (cos (* 1.0 (- lambda1 lambda2))) 0.5))
(t_2 (* (cos phi2) (cos phi1)))
(t_3 (* 0.5 (+ t_2 (* (sin phi2) (sin phi1)))))
(t_4 (* (- 0.5 (* 0.5 (- (+ 0.5 t_1) (- 0.5 t_1)))) t_2))
(t_5
(*
(atan2 (sqrt (+ t_4 (- 0.5 t_3))) (sqrt (- (+ 0.5 t_3) t_4)))
(* 2.0 R))))
(if (<= phi1 -2.1e-8)
t_5
(if (<= phi1 3800000000000.0)
(* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0)))))
t_5))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(phi2) * pow(((cos((0.5 * lambda2)) * sin((0.5 * lambda1))) - (cos((0.5 * lambda1)) * sin((0.5 * lambda2)))), 2.0)) + pow(sin((-0.5 * phi2)), 2.0);
double t_1 = cos((1.0 * (lambda1 - lambda2))) * 0.5;
double t_2 = cos(phi2) * cos(phi1);
double t_3 = 0.5 * (t_2 + (sin(phi2) * sin(phi1)));
double t_4 = (0.5 - (0.5 * ((0.5 + t_1) - (0.5 - t_1)))) * t_2;
double t_5 = atan2(sqrt((t_4 + (0.5 - t_3))), sqrt(((0.5 + t_3) - t_4))) * (2.0 * R);
double tmp;
if (phi1 <= -2.1e-8) {
tmp = t_5;
} else if (phi1 <= 3800000000000.0) {
tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
} else {
tmp = t_5;
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = (cos(phi2) * (((cos((0.5d0 * lambda2)) * sin((0.5d0 * lambda1))) - (cos((0.5d0 * lambda1)) * sin((0.5d0 * lambda2)))) ** 2.0d0)) + (sin(((-0.5d0) * phi2)) ** 2.0d0)
t_1 = cos((1.0d0 * (lambda1 - lambda2))) * 0.5d0
t_2 = cos(phi2) * cos(phi1)
t_3 = 0.5d0 * (t_2 + (sin(phi2) * sin(phi1)))
t_4 = (0.5d0 - (0.5d0 * ((0.5d0 + t_1) - (0.5d0 - t_1)))) * t_2
t_5 = atan2(sqrt((t_4 + (0.5d0 - t_3))), sqrt(((0.5d0 + t_3) - t_4))) * (2.0d0 * r)
if (phi1 <= (-2.1d-8)) then
tmp = t_5
else if (phi1 <= 3800000000000.0d0) then
tmp = r * (2.0d0 * atan2(sqrt(t_0), sqrt((1.0d0 - t_0))))
else
tmp = t_5
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.cos(phi2) * Math.pow(((Math.cos((0.5 * lambda2)) * Math.sin((0.5 * lambda1))) - (Math.cos((0.5 * lambda1)) * Math.sin((0.5 * lambda2)))), 2.0)) + Math.pow(Math.sin((-0.5 * phi2)), 2.0);
double t_1 = Math.cos((1.0 * (lambda1 - lambda2))) * 0.5;
double t_2 = Math.cos(phi2) * Math.cos(phi1);
double t_3 = 0.5 * (t_2 + (Math.sin(phi2) * Math.sin(phi1)));
double t_4 = (0.5 - (0.5 * ((0.5 + t_1) - (0.5 - t_1)))) * t_2;
double t_5 = Math.atan2(Math.sqrt((t_4 + (0.5 - t_3))), Math.sqrt(((0.5 + t_3) - t_4))) * (2.0 * R);
double tmp;
if (phi1 <= -2.1e-8) {
tmp = t_5;
} else if (phi1 <= 3800000000000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_0), Math.sqrt((1.0 - t_0))));
} else {
tmp = t_5;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.cos(phi2) * math.pow(((math.cos((0.5 * lambda2)) * math.sin((0.5 * lambda1))) - (math.cos((0.5 * lambda1)) * math.sin((0.5 * lambda2)))), 2.0)) + math.pow(math.sin((-0.5 * phi2)), 2.0) t_1 = math.cos((1.0 * (lambda1 - lambda2))) * 0.5 t_2 = math.cos(phi2) * math.cos(phi1) t_3 = 0.5 * (t_2 + (math.sin(phi2) * math.sin(phi1))) t_4 = (0.5 - (0.5 * ((0.5 + t_1) - (0.5 - t_1)))) * t_2 t_5 = math.atan2(math.sqrt((t_4 + (0.5 - t_3))), math.sqrt(((0.5 + t_3) - t_4))) * (2.0 * R) tmp = 0 if phi1 <= -2.1e-8: tmp = t_5 elif phi1 <= 3800000000000.0: tmp = R * (2.0 * math.atan2(math.sqrt(t_0), math.sqrt((1.0 - t_0)))) else: tmp = t_5 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(phi2) * (Float64(Float64(cos(Float64(0.5 * lambda2)) * sin(Float64(0.5 * lambda1))) - Float64(cos(Float64(0.5 * lambda1)) * sin(Float64(0.5 * lambda2)))) ^ 2.0)) + (sin(Float64(-0.5 * phi2)) ^ 2.0)) t_1 = Float64(cos(Float64(1.0 * Float64(lambda1 - lambda2))) * 0.5) t_2 = Float64(cos(phi2) * cos(phi1)) t_3 = Float64(0.5 * Float64(t_2 + Float64(sin(phi2) * sin(phi1)))) t_4 = Float64(Float64(0.5 - Float64(0.5 * Float64(Float64(0.5 + t_1) - Float64(0.5 - t_1)))) * t_2) t_5 = Float64(atan(sqrt(Float64(t_4 + Float64(0.5 - t_3))), sqrt(Float64(Float64(0.5 + t_3) - t_4))) * Float64(2.0 * R)) tmp = 0.0 if (phi1 <= -2.1e-8) tmp = t_5; elseif (phi1 <= 3800000000000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))); else tmp = t_5; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (cos(phi2) * (((cos((0.5 * lambda2)) * sin((0.5 * lambda1))) - (cos((0.5 * lambda1)) * sin((0.5 * lambda2)))) ^ 2.0)) + (sin((-0.5 * phi2)) ^ 2.0); t_1 = cos((1.0 * (lambda1 - lambda2))) * 0.5; t_2 = cos(phi2) * cos(phi1); t_3 = 0.5 * (t_2 + (sin(phi2) * sin(phi1))); t_4 = (0.5 - (0.5 * ((0.5 + t_1) - (0.5 - t_1)))) * t_2; t_5 = atan2(sqrt((t_4 + (0.5 - t_3))), sqrt(((0.5 + t_3) - t_4))) * (2.0 * R); tmp = 0.0; if (phi1 <= -2.1e-8) tmp = t_5; elseif (phi1 <= 3800000000000.0) tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0)))); else tmp = t_5; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[(N[(N[Cos[N[(0.5 * lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[N[(1.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(0.5 * N[(t$95$2 + N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(0.5 - N[(0.5 * N[(N[(0.5 + t$95$1), $MachinePrecision] - N[(0.5 - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$5 = N[(N[ArcTan[N[Sqrt[N[(t$95$4 + N[(0.5 - t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + t$95$3), $MachinePrecision] - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -2.1e-8], t$95$5, If[LessEqual[phi1, 3800000000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$5]]]]]]]]
\begin{array}{l}
t_0 := \cos \phi_2 \cdot {\left(\cos \left(0.5 \cdot \lambda_2\right) \cdot \sin \left(0.5 \cdot \lambda_1\right) - \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin \left(0.5 \cdot \lambda_2\right)\right)}^{2} + {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\\
t_1 := \cos \left(1 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot 0.5\\
t_2 := \cos \phi_2 \cdot \cos \phi_1\\
t_3 := 0.5 \cdot \left(t\_2 + \sin \phi_2 \cdot \sin \phi_1\right)\\
t_4 := \left(0.5 - 0.5 \cdot \left(\left(0.5 + t\_1\right) - \left(0.5 - t\_1\right)\right)\right) \cdot t\_2\\
t_5 := \tan^{-1}_* \frac{\sqrt{t\_4 + \left(0.5 - t\_3\right)}}{\sqrt{\left(0.5 + t\_3\right) - t\_4}} \cdot \left(2 \cdot R\right)\\
\mathbf{if}\;\phi_1 \leq -2.1 \cdot 10^{-8}:\\
\;\;\;\;t\_5\\
\mathbf{elif}\;\phi_1 \leq 3800000000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_5\\
\end{array}
if phi1 < -2.0999999999999999e-8 or 3.8e12 < phi1 Initial program 60.9%
Applied rewrites56.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6457.0%
Applied rewrites57.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6472.9%
Applied rewrites72.9%
lift-cos.f64N/A
lift-*.f64N/A
cos-2N/A
sqr-sin-a-revN/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f64N/A
Applied rewrites72.9%
lift-cos.f64N/A
lift-*.f64N/A
cos-2N/A
sqr-sin-a-revN/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift--.f64N/A
Applied rewrites72.9%
if -2.0999999999999999e-8 < phi1 < 3.8e12Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
Taylor expanded in phi1 around 0
lower-+.f64N/A
Applied rewrites55.3%
Taylor expanded in phi1 around 0
lower-+.f64N/A
Applied rewrites55.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (cos phi1)))
(t_1 (* (- 0.5 (* (cos (* 1.0 (- lambda1 lambda2))) 0.5)) t_0))
(t_2 (* 0.5 (+ t_0 (* (sin phi2) (sin phi1)))))
(t_3 (+ 0.5 t_2))
(t_4 (- 0.5 t_2))
(t_5
(+
(*
(cos phi2)
(pow
(-
(* (cos (* 0.5 lambda2)) (sin (* 0.5 lambda1)))
(* (cos (* 0.5 lambda1)) (sin (* 0.5 lambda2))))
2.0))
(pow (sin (* -0.5 phi2)) 2.0)))
(t_6 (* (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0) t_0)))
(if (<= phi1 -2.1e-8)
(* (atan2 (sqrt (+ t_6 t_4)) (sqrt (- t_3 t_6))) (* 2.0 R))
(if (<= phi1 3800000000000.0)
(* R (* 2.0 (atan2 (sqrt t_5) (sqrt (- 1.0 t_5)))))
(* (atan2 (sqrt (+ t_1 t_4)) (sqrt (- t_3 t_1))) (* 2.0 R))))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * cos(phi1);
double t_1 = (0.5 - (cos((1.0 * (lambda1 - lambda2))) * 0.5)) * t_0;
double t_2 = 0.5 * (t_0 + (sin(phi2) * sin(phi1)));
double t_3 = 0.5 + t_2;
double t_4 = 0.5 - t_2;
double t_5 = (cos(phi2) * pow(((cos((0.5 * lambda2)) * sin((0.5 * lambda1))) - (cos((0.5 * lambda1)) * sin((0.5 * lambda2)))), 2.0)) + pow(sin((-0.5 * phi2)), 2.0);
double t_6 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0) * t_0;
double tmp;
if (phi1 <= -2.1e-8) {
tmp = atan2(sqrt((t_6 + t_4)), sqrt((t_3 - t_6))) * (2.0 * R);
} else if (phi1 <= 3800000000000.0) {
tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_5))));
} else {
tmp = atan2(sqrt((t_1 + t_4)), sqrt((t_3 - t_1))) * (2.0 * R);
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = cos(phi2) * cos(phi1)
t_1 = (0.5d0 - (cos((1.0d0 * (lambda1 - lambda2))) * 0.5d0)) * t_0
t_2 = 0.5d0 * (t_0 + (sin(phi2) * sin(phi1)))
t_3 = 0.5d0 + t_2
t_4 = 0.5d0 - t_2
t_5 = (cos(phi2) * (((cos((0.5d0 * lambda2)) * sin((0.5d0 * lambda1))) - (cos((0.5d0 * lambda1)) * sin((0.5d0 * lambda2)))) ** 2.0d0)) + (sin(((-0.5d0) * phi2)) ** 2.0d0)
t_6 = (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0) * t_0
if (phi1 <= (-2.1d-8)) then
tmp = atan2(sqrt((t_6 + t_4)), sqrt((t_3 - t_6))) * (2.0d0 * r)
else if (phi1 <= 3800000000000.0d0) then
tmp = r * (2.0d0 * atan2(sqrt(t_5), sqrt((1.0d0 - t_5))))
else
tmp = atan2(sqrt((t_1 + t_4)), sqrt((t_3 - t_1))) * (2.0d0 * r)
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.cos(phi1);
double t_1 = (0.5 - (Math.cos((1.0 * (lambda1 - lambda2))) * 0.5)) * t_0;
double t_2 = 0.5 * (t_0 + (Math.sin(phi2) * Math.sin(phi1)));
double t_3 = 0.5 + t_2;
double t_4 = 0.5 - t_2;
double t_5 = (Math.cos(phi2) * Math.pow(((Math.cos((0.5 * lambda2)) * Math.sin((0.5 * lambda1))) - (Math.cos((0.5 * lambda1)) * Math.sin((0.5 * lambda2)))), 2.0)) + Math.pow(Math.sin((-0.5 * phi2)), 2.0);
double t_6 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0) * t_0;
double tmp;
if (phi1 <= -2.1e-8) {
tmp = Math.atan2(Math.sqrt((t_6 + t_4)), Math.sqrt((t_3 - t_6))) * (2.0 * R);
} else if (phi1 <= 3800000000000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_5), Math.sqrt((1.0 - t_5))));
} else {
tmp = Math.atan2(Math.sqrt((t_1 + t_4)), Math.sqrt((t_3 - t_1))) * (2.0 * R);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.cos(phi1) t_1 = (0.5 - (math.cos((1.0 * (lambda1 - lambda2))) * 0.5)) * t_0 t_2 = 0.5 * (t_0 + (math.sin(phi2) * math.sin(phi1))) t_3 = 0.5 + t_2 t_4 = 0.5 - t_2 t_5 = (math.cos(phi2) * math.pow(((math.cos((0.5 * lambda2)) * math.sin((0.5 * lambda1))) - (math.cos((0.5 * lambda1)) * math.sin((0.5 * lambda2)))), 2.0)) + math.pow(math.sin((-0.5 * phi2)), 2.0) t_6 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) * t_0 tmp = 0 if phi1 <= -2.1e-8: tmp = math.atan2(math.sqrt((t_6 + t_4)), math.sqrt((t_3 - t_6))) * (2.0 * R) elif phi1 <= 3800000000000.0: tmp = R * (2.0 * math.atan2(math.sqrt(t_5), math.sqrt((1.0 - t_5)))) else: tmp = math.atan2(math.sqrt((t_1 + t_4)), math.sqrt((t_3 - t_1))) * (2.0 * R) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * cos(phi1)) t_1 = Float64(Float64(0.5 - Float64(cos(Float64(1.0 * Float64(lambda1 - lambda2))) * 0.5)) * t_0) t_2 = Float64(0.5 * Float64(t_0 + Float64(sin(phi2) * sin(phi1)))) t_3 = Float64(0.5 + t_2) t_4 = Float64(0.5 - t_2) t_5 = Float64(Float64(cos(phi2) * (Float64(Float64(cos(Float64(0.5 * lambda2)) * sin(Float64(0.5 * lambda1))) - Float64(cos(Float64(0.5 * lambda1)) * sin(Float64(0.5 * lambda2)))) ^ 2.0)) + (sin(Float64(-0.5 * phi2)) ^ 2.0)) t_6 = Float64((sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0) * t_0) tmp = 0.0 if (phi1 <= -2.1e-8) tmp = Float64(atan(sqrt(Float64(t_6 + t_4)), sqrt(Float64(t_3 - t_6))) * Float64(2.0 * R)); elseif (phi1 <= 3800000000000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_5), sqrt(Float64(1.0 - t_5))))); else tmp = Float64(atan(sqrt(Float64(t_1 + t_4)), sqrt(Float64(t_3 - t_1))) * Float64(2.0 * R)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * cos(phi1); t_1 = (0.5 - (cos((1.0 * (lambda1 - lambda2))) * 0.5)) * t_0; t_2 = 0.5 * (t_0 + (sin(phi2) * sin(phi1))); t_3 = 0.5 + t_2; t_4 = 0.5 - t_2; t_5 = (cos(phi2) * (((cos((0.5 * lambda2)) * sin((0.5 * lambda1))) - (cos((0.5 * lambda1)) * sin((0.5 * lambda2)))) ^ 2.0)) + (sin((-0.5 * phi2)) ^ 2.0); t_6 = (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0) * t_0; tmp = 0.0; if (phi1 <= -2.1e-8) tmp = atan2(sqrt((t_6 + t_4)), sqrt((t_3 - t_6))) * (2.0 * R); elseif (phi1 <= 3800000000000.0) tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_5)))); else tmp = atan2(sqrt((t_1 + t_4)), sqrt((t_3 - t_1))) * (2.0 * R); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 - N[(N[Cos[N[(1.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(0.5 * N[(t$95$0 + N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(0.5 + t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(0.5 - t$95$2), $MachinePrecision]}, Block[{t$95$5 = N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[(N[(N[Cos[N[(0.5 * lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[phi1, -2.1e-8], N[(N[ArcTan[N[Sqrt[N[(t$95$6 + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$3 - t$95$6), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 3800000000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$5], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$3 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \cos \phi_1\\
t_1 := \left(0.5 - \cos \left(1 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot 0.5\right) \cdot t\_0\\
t_2 := 0.5 \cdot \left(t\_0 + \sin \phi_2 \cdot \sin \phi_1\right)\\
t_3 := 0.5 + t\_2\\
t_4 := 0.5 - t\_2\\
t_5 := \cos \phi_2 \cdot {\left(\cos \left(0.5 \cdot \lambda_2\right) \cdot \sin \left(0.5 \cdot \lambda_1\right) - \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin \left(0.5 \cdot \lambda_2\right)\right)}^{2} + {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\\
t_6 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} \cdot t\_0\\
\mathbf{if}\;\phi_1 \leq -2.1 \cdot 10^{-8}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_6 + t\_4}}{\sqrt{t\_3 - t\_6}} \cdot \left(2 \cdot R\right)\\
\mathbf{elif}\;\phi_1 \leq 3800000000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5}}{\sqrt{1 - t\_5}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_1 + t\_4}}{\sqrt{t\_3 - t\_1}} \cdot \left(2 \cdot R\right)\\
\end{array}
if phi1 < -2.0999999999999999e-8Initial program 60.9%
Applied rewrites56.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6457.0%
Applied rewrites57.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6472.9%
Applied rewrites72.9%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
unpow2N/A
lift-pow.f6475.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.4%
Applied rewrites75.4%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
sqr-sin-a-revN/A
lift-sin.f64N/A
lift-sin.f64N/A
unpow2N/A
lift-pow.f6475.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.3%
Applied rewrites75.3%
if -2.0999999999999999e-8 < phi1 < 3.8e12Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
Taylor expanded in phi1 around 0
lower-+.f64N/A
Applied rewrites55.3%
Taylor expanded in phi1 around 0
lower-+.f64N/A
Applied rewrites55.5%
if 3.8e12 < phi1 Initial program 60.9%
Applied rewrites56.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6457.0%
Applied rewrites57.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6472.9%
Applied rewrites72.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
lower-*.f6472.9%
Applied rewrites72.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
lower-*.f6472.9%
Applied rewrites72.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (cos phi1)))
(t_1 (* 0.5 (+ t_0 (* (sin phi2) (sin phi1)))))
(t_2 (* (- 0.5 (* (cos (* 1.0 (- lambda1 lambda2))) 0.5)) t_0))
(t_3
(*
(atan2 (sqrt (+ t_2 (- 0.5 t_1))) (sqrt (- (+ 0.5 t_1) t_2)))
(* 2.0 R)))
(t_4
(+
(*
(cos phi1)
(pow
(-
(* (cos (* 0.5 lambda2)) (sin (* 0.5 lambda1)))
(* (cos (* 0.5 lambda1)) (sin (* 0.5 lambda2))))
2.0))
(pow (sin (* 0.5 phi1)) 2.0))))
(if (<= phi2 -1.14e-10)
t_3
(if (<= phi2 3.1e-6)
(* R (* 2.0 (atan2 (sqrt t_4) (sqrt (- 1.0 t_4)))))
t_3))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * cos(phi1);
double t_1 = 0.5 * (t_0 + (sin(phi2) * sin(phi1)));
double t_2 = (0.5 - (cos((1.0 * (lambda1 - lambda2))) * 0.5)) * t_0;
double t_3 = atan2(sqrt((t_2 + (0.5 - t_1))), sqrt(((0.5 + t_1) - t_2))) * (2.0 * R);
double t_4 = (cos(phi1) * pow(((cos((0.5 * lambda2)) * sin((0.5 * lambda1))) - (cos((0.5 * lambda1)) * sin((0.5 * lambda2)))), 2.0)) + pow(sin((0.5 * phi1)), 2.0);
double tmp;
if (phi2 <= -1.14e-10) {
tmp = t_3;
} else if (phi2 <= 3.1e-6) {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4))));
} 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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
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(phi2) * cos(phi1)
t_1 = 0.5d0 * (t_0 + (sin(phi2) * sin(phi1)))
t_2 = (0.5d0 - (cos((1.0d0 * (lambda1 - lambda2))) * 0.5d0)) * t_0
t_3 = atan2(sqrt((t_2 + (0.5d0 - t_1))), sqrt(((0.5d0 + t_1) - t_2))) * (2.0d0 * r)
t_4 = (cos(phi1) * (((cos((0.5d0 * lambda2)) * sin((0.5d0 * lambda1))) - (cos((0.5d0 * lambda1)) * sin((0.5d0 * lambda2)))) ** 2.0d0)) + (sin((0.5d0 * phi1)) ** 2.0d0)
if (phi2 <= (-1.14d-10)) then
tmp = t_3
else if (phi2 <= 3.1d-6) then
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt((1.0d0 - t_4))))
else
tmp = t_3
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.cos(phi1);
double t_1 = 0.5 * (t_0 + (Math.sin(phi2) * Math.sin(phi1)));
double t_2 = (0.5 - (Math.cos((1.0 * (lambda1 - lambda2))) * 0.5)) * t_0;
double t_3 = Math.atan2(Math.sqrt((t_2 + (0.5 - t_1))), Math.sqrt(((0.5 + t_1) - t_2))) * (2.0 * R);
double t_4 = (Math.cos(phi1) * Math.pow(((Math.cos((0.5 * lambda2)) * Math.sin((0.5 * lambda1))) - (Math.cos((0.5 * lambda1)) * Math.sin((0.5 * lambda2)))), 2.0)) + Math.pow(Math.sin((0.5 * phi1)), 2.0);
double tmp;
if (phi2 <= -1.14e-10) {
tmp = t_3;
} else if (phi2 <= 3.1e-6) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt((1.0 - t_4))));
} else {
tmp = t_3;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.cos(phi1) t_1 = 0.5 * (t_0 + (math.sin(phi2) * math.sin(phi1))) t_2 = (0.5 - (math.cos((1.0 * (lambda1 - lambda2))) * 0.5)) * t_0 t_3 = math.atan2(math.sqrt((t_2 + (0.5 - t_1))), math.sqrt(((0.5 + t_1) - t_2))) * (2.0 * R) t_4 = (math.cos(phi1) * math.pow(((math.cos((0.5 * lambda2)) * math.sin((0.5 * lambda1))) - (math.cos((0.5 * lambda1)) * math.sin((0.5 * lambda2)))), 2.0)) + math.pow(math.sin((0.5 * phi1)), 2.0) tmp = 0 if phi2 <= -1.14e-10: tmp = t_3 elif phi2 <= 3.1e-6: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt((1.0 - t_4)))) else: tmp = t_3 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * cos(phi1)) t_1 = Float64(0.5 * Float64(t_0 + Float64(sin(phi2) * sin(phi1)))) t_2 = Float64(Float64(0.5 - Float64(cos(Float64(1.0 * Float64(lambda1 - lambda2))) * 0.5)) * t_0) t_3 = Float64(atan(sqrt(Float64(t_2 + Float64(0.5 - t_1))), sqrt(Float64(Float64(0.5 + t_1) - t_2))) * Float64(2.0 * R)) t_4 = Float64(Float64(cos(phi1) * (Float64(Float64(cos(Float64(0.5 * lambda2)) * sin(Float64(0.5 * lambda1))) - Float64(cos(Float64(0.5 * lambda1)) * sin(Float64(0.5 * lambda2)))) ^ 2.0)) + (sin(Float64(0.5 * phi1)) ^ 2.0)) tmp = 0.0 if (phi2 <= -1.14e-10) tmp = t_3; elseif (phi2 <= 3.1e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(1.0 - t_4))))); else tmp = t_3; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * cos(phi1); t_1 = 0.5 * (t_0 + (sin(phi2) * sin(phi1))); t_2 = (0.5 - (cos((1.0 * (lambda1 - lambda2))) * 0.5)) * t_0; t_3 = atan2(sqrt((t_2 + (0.5 - t_1))), sqrt(((0.5 + t_1) - t_2))) * (2.0 * R); t_4 = (cos(phi1) * (((cos((0.5 * lambda2)) * sin((0.5 * lambda1))) - (cos((0.5 * lambda1)) * sin((0.5 * lambda2)))) ^ 2.0)) + (sin((0.5 * phi1)) ^ 2.0); tmp = 0.0; if (phi2 <= -1.14e-10) tmp = t_3; elseif (phi2 <= 3.1e-6) tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4)))); else tmp = t_3; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(t$95$0 + N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(0.5 - N[(N[Cos[N[(1.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$3 = N[(N[ArcTan[N[Sqrt[N[(t$95$2 + N[(0.5 - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[(N[(N[Cos[N[(0.5 * lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -1.14e-10], t$95$3, If[LessEqual[phi2, 3.1e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]]
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \cos \phi_1\\
t_1 := 0.5 \cdot \left(t\_0 + \sin \phi_2 \cdot \sin \phi_1\right)\\
t_2 := \left(0.5 - \cos \left(1 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot 0.5\right) \cdot t\_0\\
t_3 := \tan^{-1}_* \frac{\sqrt{t\_2 + \left(0.5 - t\_1\right)}}{\sqrt{\left(0.5 + t\_1\right) - t\_2}} \cdot \left(2 \cdot R\right)\\
t_4 := \cos \phi_1 \cdot {\left(\cos \left(0.5 \cdot \lambda_2\right) \cdot \sin \left(0.5 \cdot \lambda_1\right) - \cos \left(0.5 \cdot \lambda_1\right) \cdot \sin \left(0.5 \cdot \lambda_2\right)\right)}^{2} + {\sin \left(0.5 \cdot \phi_1\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -1.14 \cdot 10^{-10}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\phi_2 \leq 3.1 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{1 - t\_4}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
if phi2 < -1.1399999999999999e-10 or 3.1e-6 < phi2 Initial program 60.9%
Applied rewrites56.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6457.0%
Applied rewrites57.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6472.9%
Applied rewrites72.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
lower-*.f6472.9%
Applied rewrites72.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
lower-*.f6472.9%
Applied rewrites72.9%
if -1.1399999999999999e-10 < phi2 < 3.1e-6Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
Taylor expanded in phi2 around 0
lower-+.f64N/A
Applied rewrites56.5%
Taylor expanded in phi2 around 0
lower-+.f64N/A
Applied rewrites56.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (cos phi1)))
(t_1 (* 0.5 (+ t_0 (* (sin phi2) (sin phi1)))))
(t_2 (* (- 0.5 (* (cos (* 1.0 (- lambda1 lambda2))) 0.5)) t_0))
(t_3
(*
(cos phi1)
(-
0.5
(*
0.5
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2)))))))
(t_4
(*
(atan2 (sqrt (+ t_2 (- 0.5 t_1))) (sqrt (- (+ 0.5 t_1) t_2)))
(* 2.0 R)))
(t_5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2)))))))
(if (<= phi2 -1.14e-10)
t_4
(if (<= phi2 3.1e-6)
(*
(atan2 (sqrt (+ t_3 (- 0.5 t_5))) (sqrt (- (+ 0.5 t_5) t_3)))
(* 2.0 R))
t_4))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * cos(phi1);
double t_1 = 0.5 * (t_0 + (sin(phi2) * sin(phi1)));
double t_2 = (0.5 - (cos((1.0 * (lambda1 - lambda2))) * 0.5)) * t_0;
double t_3 = cos(phi1) * (0.5 - (0.5 * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))));
double t_4 = atan2(sqrt((t_2 + (0.5 - t_1))), sqrt(((0.5 + t_1) - t_2))) * (2.0 * R);
double t_5 = 0.5 * cos((2.0 * (0.5 * (phi1 - phi2))));
double tmp;
if (phi2 <= -1.14e-10) {
tmp = t_4;
} else if (phi2 <= 3.1e-6) {
tmp = atan2(sqrt((t_3 + (0.5 - t_5))), sqrt(((0.5 + t_5) - t_3))) * (2.0 * R);
} else {
tmp = t_4;
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = cos(phi2) * cos(phi1)
t_1 = 0.5d0 * (t_0 + (sin(phi2) * sin(phi1)))
t_2 = (0.5d0 - (cos((1.0d0 * (lambda1 - lambda2))) * 0.5d0)) * t_0
t_3 = cos(phi1) * (0.5d0 - (0.5d0 * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))))
t_4 = atan2(sqrt((t_2 + (0.5d0 - t_1))), sqrt(((0.5d0 + t_1) - t_2))) * (2.0d0 * r)
t_5 = 0.5d0 * cos((2.0d0 * (0.5d0 * (phi1 - phi2))))
if (phi2 <= (-1.14d-10)) then
tmp = t_4
else if (phi2 <= 3.1d-6) then
tmp = atan2(sqrt((t_3 + (0.5d0 - t_5))), sqrt(((0.5d0 + t_5) - t_3))) * (2.0d0 * r)
else
tmp = t_4
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.cos(phi1);
double t_1 = 0.5 * (t_0 + (Math.sin(phi2) * Math.sin(phi1)));
double t_2 = (0.5 - (Math.cos((1.0 * (lambda1 - lambda2))) * 0.5)) * t_0;
double t_3 = Math.cos(phi1) * (0.5 - (0.5 * ((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(lambda2)))));
double t_4 = Math.atan2(Math.sqrt((t_2 + (0.5 - t_1))), Math.sqrt(((0.5 + t_1) - t_2))) * (2.0 * R);
double t_5 = 0.5 * Math.cos((2.0 * (0.5 * (phi1 - phi2))));
double tmp;
if (phi2 <= -1.14e-10) {
tmp = t_4;
} else if (phi2 <= 3.1e-6) {
tmp = Math.atan2(Math.sqrt((t_3 + (0.5 - t_5))), Math.sqrt(((0.5 + t_5) - t_3))) * (2.0 * R);
} else {
tmp = t_4;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.cos(phi1) t_1 = 0.5 * (t_0 + (math.sin(phi2) * math.sin(phi1))) t_2 = (0.5 - (math.cos((1.0 * (lambda1 - lambda2))) * 0.5)) * t_0 t_3 = math.cos(phi1) * (0.5 - (0.5 * ((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda1) * math.sin(lambda2))))) t_4 = math.atan2(math.sqrt((t_2 + (0.5 - t_1))), math.sqrt(((0.5 + t_1) - t_2))) * (2.0 * R) t_5 = 0.5 * math.cos((2.0 * (0.5 * (phi1 - phi2)))) tmp = 0 if phi2 <= -1.14e-10: tmp = t_4 elif phi2 <= 3.1e-6: tmp = math.atan2(math.sqrt((t_3 + (0.5 - t_5))), math.sqrt(((0.5 + t_5) - t_3))) * (2.0 * R) else: tmp = t_4 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * cos(phi1)) t_1 = Float64(0.5 * Float64(t_0 + Float64(sin(phi2) * sin(phi1)))) t_2 = Float64(Float64(0.5 - Float64(cos(Float64(1.0 * Float64(lambda1 - lambda2))) * 0.5)) * t_0) t_3 = Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))) t_4 = Float64(atan(sqrt(Float64(t_2 + Float64(0.5 - t_1))), sqrt(Float64(Float64(0.5 + t_1) - t_2))) * Float64(2.0 * R)) t_5 = Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2))))) tmp = 0.0 if (phi2 <= -1.14e-10) tmp = t_4; elseif (phi2 <= 3.1e-6) tmp = Float64(atan(sqrt(Float64(t_3 + Float64(0.5 - t_5))), sqrt(Float64(Float64(0.5 + t_5) - t_3))) * Float64(2.0 * R)); else tmp = t_4; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * cos(phi1); t_1 = 0.5 * (t_0 + (sin(phi2) * sin(phi1))); t_2 = (0.5 - (cos((1.0 * (lambda1 - lambda2))) * 0.5)) * t_0; t_3 = cos(phi1) * (0.5 - (0.5 * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))); t_4 = atan2(sqrt((t_2 + (0.5 - t_1))), sqrt(((0.5 + t_1) - t_2))) * (2.0 * R); t_5 = 0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))); tmp = 0.0; if (phi2 <= -1.14e-10) tmp = t_4; elseif (phi2 <= 3.1e-6) tmp = atan2(sqrt((t_3 + (0.5 - t_5))), sqrt(((0.5 + t_5) - t_3))) * (2.0 * R); else tmp = t_4; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(t$95$0 + N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(0.5 - N[(N[Cos[N[(1.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[ArcTan[N[Sqrt[N[(t$95$2 + N[(0.5 - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -1.14e-10], t$95$4, If[LessEqual[phi2, 3.1e-6], N[(N[ArcTan[N[Sqrt[N[(t$95$3 + N[(0.5 - t$95$5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + t$95$5), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision], t$95$4]]]]]]]]
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \cos \phi_1\\
t_1 := 0.5 \cdot \left(t\_0 + \sin \phi_2 \cdot \sin \phi_1\right)\\
t_2 := \left(0.5 - \cos \left(1 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot 0.5\right) \cdot t\_0\\
t_3 := \cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
t_4 := \tan^{-1}_* \frac{\sqrt{t\_2 + \left(0.5 - t\_1\right)}}{\sqrt{\left(0.5 + t\_1\right) - t\_2}} \cdot \left(2 \cdot R\right)\\
t_5 := 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\\
\mathbf{if}\;\phi_2 \leq -1.14 \cdot 10^{-10}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;\phi_2 \leq 3.1 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_3 + \left(0.5 - t\_5\right)}}{\sqrt{\left(0.5 + t\_5\right) - t\_3}} \cdot \left(2 \cdot R\right)\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\end{array}
if phi2 < -1.1399999999999999e-10 or 3.1e-6 < phi2 Initial program 60.9%
Applied rewrites56.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6457.0%
Applied rewrites57.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6472.9%
Applied rewrites72.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
lower-*.f6472.9%
Applied rewrites72.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
lower-*.f6472.9%
Applied rewrites72.9%
if -1.1399999999999999e-10 < phi2 < 3.1e-6Initial program 60.9%
Applied rewrites56.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6447.6%
Applied rewrites47.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6445.6%
Applied rewrites45.6%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6445.9%
Applied rewrites45.9%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6455.9%
Applied rewrites55.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))
(t_1
(*
0.5
(+ (* (cos phi1) (cos phi2)) (* (sin phi1) (sin phi2)))))
(t_2
(*
(cos phi1)
(-
0.5
(*
0.5
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2)))))))
(t_3
(*
(cos phi1)
(* (cos phi2) (- 0.5 (* 0.5 (cos (- lambda1 lambda2)))))))
(t_4
(*
(atan2 (sqrt (- (+ 0.5 t_3) t_1)) (sqrt (- (+ 0.5 t_1) t_3)))
(* 2.0 R))))
(if (<= phi2 -1.14e-10)
t_4
(if (<= phi2 3.1e-6)
(*
(atan2 (sqrt (+ t_2 (- 0.5 t_0))) (sqrt (- (+ 0.5 t_0) t_2)))
(* 2.0 R))
t_4))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 * cos((2.0 * (0.5 * (phi1 - phi2))));
double t_1 = 0.5 * ((cos(phi1) * cos(phi2)) + (sin(phi1) * sin(phi2)));
double t_2 = cos(phi1) * (0.5 - (0.5 * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))));
double t_3 = cos(phi1) * (cos(phi2) * (0.5 - (0.5 * cos((lambda1 - lambda2)))));
double t_4 = atan2(sqrt(((0.5 + t_3) - t_1)), sqrt(((0.5 + t_1) - t_3))) * (2.0 * R);
double tmp;
if (phi2 <= -1.14e-10) {
tmp = t_4;
} else if (phi2 <= 3.1e-6) {
tmp = atan2(sqrt((t_2 + (0.5 - t_0))), sqrt(((0.5 + t_0) - t_2))) * (2.0 * R);
} else {
tmp = t_4;
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
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 = 0.5d0 * cos((2.0d0 * (0.5d0 * (phi1 - phi2))))
t_1 = 0.5d0 * ((cos(phi1) * cos(phi2)) + (sin(phi1) * sin(phi2)))
t_2 = cos(phi1) * (0.5d0 - (0.5d0 * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))))
t_3 = cos(phi1) * (cos(phi2) * (0.5d0 - (0.5d0 * cos((lambda1 - lambda2)))))
t_4 = atan2(sqrt(((0.5d0 + t_3) - t_1)), sqrt(((0.5d0 + t_1) - t_3))) * (2.0d0 * r)
if (phi2 <= (-1.14d-10)) then
tmp = t_4
else if (phi2 <= 3.1d-6) then
tmp = atan2(sqrt((t_2 + (0.5d0 - t_0))), sqrt(((0.5d0 + t_0) - t_2))) * (2.0d0 * r)
else
tmp = t_4
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 * Math.cos((2.0 * (0.5 * (phi1 - phi2))));
double t_1 = 0.5 * ((Math.cos(phi1) * Math.cos(phi2)) + (Math.sin(phi1) * Math.sin(phi2)));
double t_2 = Math.cos(phi1) * (0.5 - (0.5 * ((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(lambda2)))));
double t_3 = Math.cos(phi1) * (Math.cos(phi2) * (0.5 - (0.5 * Math.cos((lambda1 - lambda2)))));
double t_4 = Math.atan2(Math.sqrt(((0.5 + t_3) - t_1)), Math.sqrt(((0.5 + t_1) - t_3))) * (2.0 * R);
double tmp;
if (phi2 <= -1.14e-10) {
tmp = t_4;
} else if (phi2 <= 3.1e-6) {
tmp = Math.atan2(Math.sqrt((t_2 + (0.5 - t_0))), Math.sqrt(((0.5 + t_0) - t_2))) * (2.0 * R);
} else {
tmp = t_4;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = 0.5 * math.cos((2.0 * (0.5 * (phi1 - phi2)))) t_1 = 0.5 * ((math.cos(phi1) * math.cos(phi2)) + (math.sin(phi1) * math.sin(phi2))) t_2 = math.cos(phi1) * (0.5 - (0.5 * ((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda1) * math.sin(lambda2))))) t_3 = math.cos(phi1) * (math.cos(phi2) * (0.5 - (0.5 * math.cos((lambda1 - lambda2))))) t_4 = math.atan2(math.sqrt(((0.5 + t_3) - t_1)), math.sqrt(((0.5 + t_1) - t_3))) * (2.0 * R) tmp = 0 if phi2 <= -1.14e-10: tmp = t_4 elif phi2 <= 3.1e-6: tmp = math.atan2(math.sqrt((t_2 + (0.5 - t_0))), math.sqrt(((0.5 + t_0) - t_2))) * (2.0 * R) else: tmp = t_4 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2))))) t_1 = Float64(0.5 * Float64(Float64(cos(phi1) * cos(phi2)) + Float64(sin(phi1) * sin(phi2)))) t_2 = Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))) t_3 = Float64(cos(phi1) * Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))))) t_4 = Float64(atan(sqrt(Float64(Float64(0.5 + t_3) - t_1)), sqrt(Float64(Float64(0.5 + t_1) - t_3))) * Float64(2.0 * R)) tmp = 0.0 if (phi2 <= -1.14e-10) tmp = t_4; elseif (phi2 <= 3.1e-6) tmp = Float64(atan(sqrt(Float64(t_2 + Float64(0.5 - t_0))), sqrt(Float64(Float64(0.5 + t_0) - t_2))) * Float64(2.0 * R)); else tmp = t_4; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = 0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))); t_1 = 0.5 * ((cos(phi1) * cos(phi2)) + (sin(phi1) * sin(phi2))); t_2 = cos(phi1) * (0.5 - (0.5 * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))); t_3 = cos(phi1) * (cos(phi2) * (0.5 - (0.5 * cos((lambda1 - lambda2))))); t_4 = atan2(sqrt(((0.5 + t_3) - t_1)), sqrt(((0.5 + t_1) - t_3))) * (2.0 * R); tmp = 0.0; if (phi2 <= -1.14e-10) tmp = t_4; elseif (phi2 <= 3.1e-6) tmp = atan2(sqrt((t_2 + (0.5 - t_0))), sqrt(((0.5 + t_0) - t_2))) * (2.0 * R); else tmp = t_4; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[ArcTan[N[Sqrt[N[(N[(0.5 + t$95$3), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + t$95$1), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -1.14e-10], t$95$4, If[LessEqual[phi2, 3.1e-6], N[(N[ArcTan[N[Sqrt[N[(t$95$2 + N[(0.5 - t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + t$95$0), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision], t$95$4]]]]]]]
\begin{array}{l}
t_0 := 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\\
t_1 := 0.5 \cdot \left(\cos \phi_1 \cdot \cos \phi_2 + \sin \phi_1 \cdot \sin \phi_2\right)\\
t_2 := \cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
t_3 := \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\\
t_4 := \tan^{-1}_* \frac{\sqrt{\left(0.5 + t\_3\right) - t\_1}}{\sqrt{\left(0.5 + t\_1\right) - t\_3}} \cdot \left(2 \cdot R\right)\\
\mathbf{if}\;\phi_2 \leq -1.14 \cdot 10^{-10}:\\
\;\;\;\;t\_4\\
\mathbf{elif}\;\phi_2 \leq 3.1 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_2 + \left(0.5 - t\_0\right)}}{\sqrt{\left(0.5 + t\_0\right) - t\_2}} \cdot \left(2 \cdot R\right)\\
\mathbf{else}:\\
\;\;\;\;t\_4\\
\end{array}
if phi2 < -1.1399999999999999e-10 or 3.1e-6 < phi2 Initial program 60.9%
Applied rewrites56.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6457.0%
Applied rewrites57.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6472.9%
Applied rewrites72.9%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6437.6%
Applied rewrites37.6%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6433.9%
Applied rewrites33.9%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
Applied rewrites72.9%
if -1.1399999999999999e-10 < phi2 < 3.1e-6Initial program 60.9%
Applied rewrites56.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6447.6%
Applied rewrites47.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6445.6%
Applied rewrites45.6%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6445.9%
Applied rewrites45.9%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6455.9%
Applied rewrites55.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(cos phi1)
(-
0.5
(*
0.5
(+
(* (cos lambda2) (cos lambda1))
(* (sin lambda2) (sin lambda1)))))))
(t_1 (* 0.5 (cos phi2)))
(t_2 (* (cos phi2) (- 0.5 (* 0.5 (cos (- lambda1 lambda2))))))
(t_3 (* (cos phi2) (cos phi1)))
(t_4 (* 0.5 (cos phi1)))
(t_5
(*
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))
t_3))
(t_6 (* 0.5 (+ t_3 (* (sin phi2) (sin phi1))))))
(if (<= phi2 -6.1e+18)
(*
(atan2 (sqrt (+ t_5 (- 0.5 t_6))) (sqrt (- (+ 0.5 t_1) t_2)))
(* 2.0 R))
(if (<= phi2 3.1e-6)
(*
(atan2 (sqrt (+ t_0 (- 0.5 t_4))) (sqrt (- (+ 0.5 t_4) t_0)))
(* 2.0 R))
(*
(atan2 (sqrt (- (+ 0.5 t_2) t_1)) (sqrt (- (+ 0.5 t_6) t_5)))
(* 2.0 R))))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * (0.5 - (0.5 * ((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1)))));
double t_1 = 0.5 * cos(phi2);
double t_2 = cos(phi2) * (0.5 - (0.5 * cos((lambda1 - lambda2))));
double t_3 = cos(phi2) * cos(phi1);
double t_4 = 0.5 * cos(phi1);
double t_5 = (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * t_3;
double t_6 = 0.5 * (t_3 + (sin(phi2) * sin(phi1)));
double tmp;
if (phi2 <= -6.1e+18) {
tmp = atan2(sqrt((t_5 + (0.5 - t_6))), sqrt(((0.5 + t_1) - t_2))) * (2.0 * R);
} else if (phi2 <= 3.1e-6) {
tmp = atan2(sqrt((t_0 + (0.5 - t_4))), sqrt(((0.5 + t_4) - t_0))) * (2.0 * R);
} else {
tmp = atan2(sqrt(((0.5 + t_2) - t_1)), sqrt(((0.5 + t_6) - t_5))) * (2.0 * R);
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = cos(phi1) * (0.5d0 - (0.5d0 * ((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1)))))
t_1 = 0.5d0 * cos(phi2)
t_2 = cos(phi2) * (0.5d0 - (0.5d0 * cos((lambda1 - lambda2))))
t_3 = cos(phi2) * cos(phi1)
t_4 = 0.5d0 * cos(phi1)
t_5 = (0.5d0 - (0.5d0 * cos((2.0d0 * (0.5d0 * (lambda1 - lambda2)))))) * t_3
t_6 = 0.5d0 * (t_3 + (sin(phi2) * sin(phi1)))
if (phi2 <= (-6.1d+18)) then
tmp = atan2(sqrt((t_5 + (0.5d0 - t_6))), sqrt(((0.5d0 + t_1) - t_2))) * (2.0d0 * r)
else if (phi2 <= 3.1d-6) then
tmp = atan2(sqrt((t_0 + (0.5d0 - t_4))), sqrt(((0.5d0 + t_4) - t_0))) * (2.0d0 * r)
else
tmp = atan2(sqrt(((0.5d0 + t_2) - t_1)), sqrt(((0.5d0 + t_6) - t_5))) * (2.0d0 * r)
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * (0.5 - (0.5 * ((Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda2) * Math.sin(lambda1)))));
double t_1 = 0.5 * Math.cos(phi2);
double t_2 = Math.cos(phi2) * (0.5 - (0.5 * Math.cos((lambda1 - lambda2))));
double t_3 = Math.cos(phi2) * Math.cos(phi1);
double t_4 = 0.5 * Math.cos(phi1);
double t_5 = (0.5 - (0.5 * Math.cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * t_3;
double t_6 = 0.5 * (t_3 + (Math.sin(phi2) * Math.sin(phi1)));
double tmp;
if (phi2 <= -6.1e+18) {
tmp = Math.atan2(Math.sqrt((t_5 + (0.5 - t_6))), Math.sqrt(((0.5 + t_1) - t_2))) * (2.0 * R);
} else if (phi2 <= 3.1e-6) {
tmp = Math.atan2(Math.sqrt((t_0 + (0.5 - t_4))), Math.sqrt(((0.5 + t_4) - t_0))) * (2.0 * R);
} else {
tmp = Math.atan2(Math.sqrt(((0.5 + t_2) - t_1)), Math.sqrt(((0.5 + t_6) - t_5))) * (2.0 * R);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * (0.5 - (0.5 * ((math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda2) * math.sin(lambda1))))) t_1 = 0.5 * math.cos(phi2) t_2 = math.cos(phi2) * (0.5 - (0.5 * math.cos((lambda1 - lambda2)))) t_3 = math.cos(phi2) * math.cos(phi1) t_4 = 0.5 * math.cos(phi1) t_5 = (0.5 - (0.5 * math.cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * t_3 t_6 = 0.5 * (t_3 + (math.sin(phi2) * math.sin(phi1))) tmp = 0 if phi2 <= -6.1e+18: tmp = math.atan2(math.sqrt((t_5 + (0.5 - t_6))), math.sqrt(((0.5 + t_1) - t_2))) * (2.0 * R) elif phi2 <= 3.1e-6: tmp = math.atan2(math.sqrt((t_0 + (0.5 - t_4))), math.sqrt(((0.5 + t_4) - t_0))) * (2.0 * R) else: tmp = math.atan2(math.sqrt(((0.5 + t_2) - t_1)), math.sqrt(((0.5 + t_6) - t_5))) * (2.0 * R) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda2) * sin(lambda1)))))) t_1 = Float64(0.5 * cos(phi2)) t_2 = Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))) t_3 = Float64(cos(phi2) * cos(phi1)) t_4 = Float64(0.5 * cos(phi1)) t_5 = Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2)))))) * t_3) t_6 = Float64(0.5 * Float64(t_3 + Float64(sin(phi2) * sin(phi1)))) tmp = 0.0 if (phi2 <= -6.1e+18) tmp = Float64(atan(sqrt(Float64(t_5 + Float64(0.5 - t_6))), sqrt(Float64(Float64(0.5 + t_1) - t_2))) * Float64(2.0 * R)); elseif (phi2 <= 3.1e-6) tmp = Float64(atan(sqrt(Float64(t_0 + Float64(0.5 - t_4))), sqrt(Float64(Float64(0.5 + t_4) - t_0))) * Float64(2.0 * R)); else tmp = Float64(atan(sqrt(Float64(Float64(0.5 + t_2) - t_1)), sqrt(Float64(Float64(0.5 + t_6) - t_5))) * Float64(2.0 * R)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * (0.5 - (0.5 * ((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1))))); t_1 = 0.5 * cos(phi2); t_2 = cos(phi2) * (0.5 - (0.5 * cos((lambda1 - lambda2)))); t_3 = cos(phi2) * cos(phi1); t_4 = 0.5 * cos(phi1); t_5 = (0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * t_3; t_6 = 0.5 * (t_3 + (sin(phi2) * sin(phi1))); tmp = 0.0; if (phi2 <= -6.1e+18) tmp = atan2(sqrt((t_5 + (0.5 - t_6))), sqrt(((0.5 + t_1) - t_2))) * (2.0 * R); elseif (phi2 <= 3.1e-6) tmp = atan2(sqrt((t_0 + (0.5 - t_4))), sqrt(((0.5 + t_4) - t_0))) * (2.0 * R); else tmp = atan2(sqrt(((0.5 + t_2) - t_1)), sqrt(((0.5 + t_6) - t_5))) * (2.0 * R); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]}, Block[{t$95$6 = N[(0.5 * N[(t$95$3 + N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -6.1e+18], N[(N[ArcTan[N[Sqrt[N[(t$95$5 + N[(0.5 - t$95$6), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 3.1e-6], N[(N[ArcTan[N[Sqrt[N[(t$95$0 + N[(0.5 - t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + t$95$4), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision], N[(N[ArcTan[N[Sqrt[N[(N[(0.5 + t$95$2), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + t$95$6), $MachinePrecision] - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_2 \cdot \sin \lambda_1\right)\right)\\
t_1 := 0.5 \cdot \cos \phi_2\\
t_2 := \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
t_3 := \cos \phi_2 \cdot \cos \phi_1\\
t_4 := 0.5 \cdot \cos \phi_1\\
t_5 := \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right) \cdot t\_3\\
t_6 := 0.5 \cdot \left(t\_3 + \sin \phi_2 \cdot \sin \phi_1\right)\\
\mathbf{if}\;\phi_2 \leq -6.1 \cdot 10^{+18}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_5 + \left(0.5 - t\_6\right)}}{\sqrt{\left(0.5 + t\_1\right) - t\_2}} \cdot \left(2 \cdot R\right)\\
\mathbf{elif}\;\phi_2 \leq 3.1 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_0 + \left(0.5 - t\_4\right)}}{\sqrt{\left(0.5 + t\_4\right) - t\_0}} \cdot \left(2 \cdot R\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{\left(0.5 + t\_2\right) - t\_1}}{\sqrt{\left(0.5 + t\_6\right) - t\_5}} \cdot \left(2 \cdot R\right)\\
\end{array}
if phi2 < -6.1e18Initial program 60.9%
Applied rewrites56.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6457.0%
Applied rewrites57.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6472.9%
Applied rewrites72.9%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6444.1%
Applied rewrites44.1%
if -6.1e18 < phi2 < 3.1e-6Initial program 60.9%
Applied rewrites56.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6447.6%
Applied rewrites47.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6445.6%
Applied rewrites45.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6440.3%
Applied rewrites40.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6442.5%
Applied rewrites42.5%
lift-cos.f64N/A
cos-neg-revN/A
lift--.f64N/A
sub-negate-revN/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6442.8%
Applied rewrites42.8%
lift-cos.f64N/A
cos-neg-revN/A
lift--.f64N/A
sub-negate-revN/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6452.8%
Applied rewrites52.8%
if 3.1e-6 < phi2 Initial program 60.9%
Applied rewrites56.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6457.0%
Applied rewrites57.0%
lift-cos.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
*-lft-identityN/A
lift--.f64N/A
sub-negate-revN/A
cos-neg-revN/A
cos-diffN/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6472.9%
Applied rewrites72.9%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f6442.7%
Applied rewrites42.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0)))
(sqrt
(fabs
(-
(+ 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))
(*
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))
(* (cos phi2) (cos phi1)))))))))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0))), sqrt(fabs(((0.5 + (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))) - ((0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * (cos(phi2) * cos(phi1))))))));
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0))), sqrt(abs(((0.5d0 + (0.5d0 * cos((2.0d0 * (0.5d0 * (phi1 - phi2)))))) - ((0.5d0 - (0.5d0 * cos((2.0d0 * (0.5d0 * (lambda1 - lambda2)))))) * (cos(phi2) * cos(phi1))))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0))), Math.sqrt(Math.abs(((0.5 + (0.5 * Math.cos((2.0 * (0.5 * (phi1 - phi2)))))) - ((0.5 - (0.5 * Math.cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * (Math.cos(phi2) * Math.cos(phi1))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0))), math.sqrt(math.fabs(((0.5 + (0.5 * math.cos((2.0 * (0.5 * (phi1 - phi2)))))) - ((0.5 - (0.5 * math.cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * (math.cos(phi2) * math.cos(phi1))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0))), sqrt(abs(Float64(Float64(0.5 + Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))) - Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2)))))) * Float64(cos(phi2) * cos(phi1))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0))), sqrt(abs(((0.5 + (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))) - ((0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * (cos(phi2) * cos(phi1)))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Abs[N[(N[(0.5 + N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0}}{\sqrt{\left|\left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right) - \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right) \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)\right|}}\right)
\end{array}
Initial program 60.9%
Applied rewrites61.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* 0.5 (- lambda1 lambda2)))
(t_1
(*
(- 0.5 (* 0.5 (cos (* 2.0 t_0))))
(* (cos phi2) (cos phi1))))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3
(*
0.5
(cos
(*
2.0
(*
0.5
(-
(+ (* 0.5 (- phi1 phi2)) (* 0.5 phi1))
(* phi2 0.5)))))))
(t_4
(+
(* (cos phi2) (pow (sin t_0) 2.0))
(pow (sin (* -0.5 phi2)) 2.0))))
(if (<=
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_2) t_2))
0.002)
(* R (* 2.0 (atan2 (sqrt t_4) (sqrt (- 1.0 t_4)))))
(*
(atan2 (sqrt (+ t_1 (- 0.5 t_3))) (sqrt (- (+ 0.5 t_3) t_1)))
(* 2.0 R)))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 * (lambda1 - lambda2);
double t_1 = (0.5 - (0.5 * cos((2.0 * t_0)))) * (cos(phi2) * cos(phi1));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = 0.5 * cos((2.0 * (0.5 * (((0.5 * (phi1 - phi2)) + (0.5 * phi1)) - (phi2 * 0.5)))));
double t_4 = (cos(phi2) * pow(sin(t_0), 2.0)) + pow(sin((-0.5 * phi2)), 2.0);
double tmp;
if ((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_2) * t_2)) <= 0.002) {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4))));
} else {
tmp = atan2(sqrt((t_1 + (0.5 - t_3))), sqrt(((0.5 + t_3) - t_1))) * (2.0 * R);
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
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 = 0.5d0 * (lambda1 - lambda2)
t_1 = (0.5d0 - (0.5d0 * cos((2.0d0 * t_0)))) * (cos(phi2) * cos(phi1))
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = 0.5d0 * cos((2.0d0 * (0.5d0 * (((0.5d0 * (phi1 - phi2)) + (0.5d0 * phi1)) - (phi2 * 0.5d0)))))
t_4 = (cos(phi2) * (sin(t_0) ** 2.0d0)) + (sin(((-0.5d0) * phi2)) ** 2.0d0)
if (((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_2) * t_2)) <= 0.002d0) then
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt((1.0d0 - t_4))))
else
tmp = atan2(sqrt((t_1 + (0.5d0 - t_3))), sqrt(((0.5d0 + t_3) - t_1))) * (2.0d0 * r)
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 * (lambda1 - lambda2);
double t_1 = (0.5 - (0.5 * Math.cos((2.0 * t_0)))) * (Math.cos(phi2) * Math.cos(phi1));
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = 0.5 * Math.cos((2.0 * (0.5 * (((0.5 * (phi1 - phi2)) + (0.5 * phi1)) - (phi2 * 0.5)))));
double t_4 = (Math.cos(phi2) * Math.pow(Math.sin(t_0), 2.0)) + Math.pow(Math.sin((-0.5 * phi2)), 2.0);
double tmp;
if ((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_2) * t_2)) <= 0.002) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt((1.0 - t_4))));
} else {
tmp = Math.atan2(Math.sqrt((t_1 + (0.5 - t_3))), Math.sqrt(((0.5 + t_3) - t_1))) * (2.0 * R);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = 0.5 * (lambda1 - lambda2) t_1 = (0.5 - (0.5 * math.cos((2.0 * t_0)))) * (math.cos(phi2) * math.cos(phi1)) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = 0.5 * math.cos((2.0 * (0.5 * (((0.5 * (phi1 - phi2)) + (0.5 * phi1)) - (phi2 * 0.5))))) t_4 = (math.cos(phi2) * math.pow(math.sin(t_0), 2.0)) + math.pow(math.sin((-0.5 * phi2)), 2.0) tmp = 0 if (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_2) * t_2)) <= 0.002: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt((1.0 - t_4)))) else: tmp = math.atan2(math.sqrt((t_1 + (0.5 - t_3))), math.sqrt(((0.5 + t_3) - t_1))) * (2.0 * R) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(0.5 * Float64(lambda1 - lambda2)) t_1 = Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_0)))) * Float64(cos(phi2) * cos(phi1))) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(Float64(Float64(0.5 * Float64(phi1 - phi2)) + Float64(0.5 * phi1)) - Float64(phi2 * 0.5)))))) t_4 = Float64(Float64(cos(phi2) * (sin(t_0) ^ 2.0)) + (sin(Float64(-0.5 * phi2)) ^ 2.0)) tmp = 0.0 if (Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_2) * t_2)) <= 0.002) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(1.0 - t_4))))); else tmp = Float64(atan(sqrt(Float64(t_1 + Float64(0.5 - t_3))), sqrt(Float64(Float64(0.5 + t_3) - t_1))) * Float64(2.0 * R)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = 0.5 * (lambda1 - lambda2); t_1 = (0.5 - (0.5 * cos((2.0 * t_0)))) * (cos(phi2) * cos(phi1)); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = 0.5 * cos((2.0 * (0.5 * (((0.5 * (phi1 - phi2)) + (0.5 * phi1)) - (phi2 * 0.5))))); t_4 = (cos(phi2) * (sin(t_0) ^ 2.0)) + (sin((-0.5 * phi2)) ^ 2.0); tmp = 0.0; if (((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_2) * t_2)) <= 0.002) tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_4)))); else tmp = atan2(sqrt((t_1 + (0.5 - t_3))), sqrt(((0.5 + t_3) - t_1))) * (2.0 * R); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(N[(N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision] + N[(0.5 * phi1), $MachinePrecision]), $MachinePrecision] - N[(phi2 * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[t$95$0], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision], 0.002], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + t$95$3), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := 0.5 \cdot \left(\lambda_1 - \lambda_2\right)\\
t_1 := \left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_0\right)\right) \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\left(0.5 \cdot \left(\phi_1 - \phi_2\right) + 0.5 \cdot \phi_1\right) - \phi_2 \cdot 0.5\right)\right)\right)\\
t_4 := \cos \phi_2 \cdot {\sin t\_0}^{2} + {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\\
\mathbf{if}\;{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\right) \cdot t\_2 \leq 0.002:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{1 - t\_4}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - t\_3\right)}}{\sqrt{\left(0.5 + t\_3\right) - t\_1}} \cdot \left(2 \cdot R\right)\\
\end{array}
if (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) < 2e-3Initial program 60.9%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f6445.6%
Applied rewrites45.6%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f6445.7%
Applied rewrites45.7%
if 2e-3 < (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) Initial program 60.9%
Applied rewrites56.0%
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-outN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flipN/A
lift--.f64N/A
div-subN/A
associate-+r-N/A
lower--.f64N/A
lower-+.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6456.0%
Applied rewrites56.0%
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-outN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flipN/A
lift--.f64N/A
div-subN/A
associate-+r-N/A
lower--.f64N/A
lower-+.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6456.0%
Applied rewrites56.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0)))
(sqrt
(-
(+ 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))
(*
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- lambda1 lambda2))))))
(* (cos phi2) (cos phi1))))))))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0))), sqrt(((0.5 + (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))) - ((0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * (cos(phi2) * cos(phi1)))))));
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0))), sqrt(((0.5d0 + (0.5d0 * cos((2.0d0 * (0.5d0 * (phi1 - phi2)))))) - ((0.5d0 - (0.5d0 * cos((2.0d0 * (0.5d0 * (lambda1 - lambda2)))))) * (cos(phi2) * cos(phi1)))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0))), Math.sqrt(((0.5 + (0.5 * Math.cos((2.0 * (0.5 * (phi1 - phi2)))))) - ((0.5 - (0.5 * Math.cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * (Math.cos(phi2) * Math.cos(phi1)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0))), math.sqrt(((0.5 + (0.5 * math.cos((2.0 * (0.5 * (phi1 - phi2)))))) - ((0.5 - (0.5 * math.cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * (math.cos(phi2) * math.cos(phi1)))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0))), sqrt(Float64(Float64(0.5 + Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))) - Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2)))))) * Float64(cos(phi2) * cos(phi1)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0))), sqrt(((0.5 + (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))) - ((0.5 - (0.5 * cos((2.0 * (0.5 * (lambda1 - lambda2)))))) * (cos(phi2) * cos(phi1))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0}}{\sqrt{\left(0.5 + 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right) - \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right) \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)}}\right)
\end{array}
Initial program 60.9%
Applied rewrites61.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* 0.5 (- lambda1 lambda2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2
(*
0.5
(cos
(*
2.0
(*
0.5
(-
(+ (* 0.5 (- phi1 phi2)) (* 0.5 phi1))
(* phi2 0.5)))))))
(t_3
(+
(* (cos phi1) (pow (sin t_0) 2.0))
(pow (sin (* 0.5 phi1)) 2.0)))
(t_4
(*
(- 0.5 (* 0.5 (cos (* 2.0 t_0))))
(* (cos phi2) (cos phi1)))))
(if (<=
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_1) t_1))
0.015)
(* R (* 2.0 (atan2 (sqrt t_3) (sqrt (- 1.0 t_3)))))
(*
(atan2 (sqrt (+ t_4 (- 0.5 t_2))) (sqrt (- (+ 0.5 t_2) t_4)))
(* 2.0 R)))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 * (lambda1 - lambda2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = 0.5 * cos((2.0 * (0.5 * (((0.5 * (phi1 - phi2)) + (0.5 * phi1)) - (phi2 * 0.5)))));
double t_3 = (cos(phi1) * pow(sin(t_0), 2.0)) + pow(sin((0.5 * phi1)), 2.0);
double t_4 = (0.5 - (0.5 * cos((2.0 * t_0)))) * (cos(phi2) * cos(phi1));
double tmp;
if ((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 0.015) {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_3))));
} else {
tmp = atan2(sqrt((t_4 + (0.5 - t_2))), sqrt(((0.5 + t_2) - t_4))) * (2.0 * R);
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
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 = 0.5d0 * (lambda1 - lambda2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = 0.5d0 * cos((2.0d0 * (0.5d0 * (((0.5d0 * (phi1 - phi2)) + (0.5d0 * phi1)) - (phi2 * 0.5d0)))))
t_3 = (cos(phi1) * (sin(t_0) ** 2.0d0)) + (sin((0.5d0 * phi1)) ** 2.0d0)
t_4 = (0.5d0 - (0.5d0 * cos((2.0d0 * t_0)))) * (cos(phi2) * cos(phi1))
if (((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 0.015d0) then
tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt((1.0d0 - t_3))))
else
tmp = atan2(sqrt((t_4 + (0.5d0 - t_2))), sqrt(((0.5d0 + t_2) - t_4))) * (2.0d0 * r)
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 * (lambda1 - lambda2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = 0.5 * Math.cos((2.0 * (0.5 * (((0.5 * (phi1 - phi2)) + (0.5 * phi1)) - (phi2 * 0.5)))));
double t_3 = (Math.cos(phi1) * Math.pow(Math.sin(t_0), 2.0)) + Math.pow(Math.sin((0.5 * phi1)), 2.0);
double t_4 = (0.5 - (0.5 * Math.cos((2.0 * t_0)))) * (Math.cos(phi2) * Math.cos(phi1));
double tmp;
if ((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_1) * t_1)) <= 0.015) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt((1.0 - t_3))));
} else {
tmp = Math.atan2(Math.sqrt((t_4 + (0.5 - t_2))), Math.sqrt(((0.5 + t_2) - t_4))) * (2.0 * R);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = 0.5 * (lambda1 - lambda2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = 0.5 * math.cos((2.0 * (0.5 * (((0.5 * (phi1 - phi2)) + (0.5 * phi1)) - (phi2 * 0.5))))) t_3 = (math.cos(phi1) * math.pow(math.sin(t_0), 2.0)) + math.pow(math.sin((0.5 * phi1)), 2.0) t_4 = (0.5 - (0.5 * math.cos((2.0 * t_0)))) * (math.cos(phi2) * math.cos(phi1)) tmp = 0 if (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_1) * t_1)) <= 0.015: tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt((1.0 - t_3)))) else: tmp = math.atan2(math.sqrt((t_4 + (0.5 - t_2))), math.sqrt(((0.5 + t_2) - t_4))) * (2.0 * R) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(0.5 * Float64(lambda1 - lambda2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(Float64(Float64(0.5 * Float64(phi1 - phi2)) + Float64(0.5 * phi1)) - Float64(phi2 * 0.5)))))) t_3 = Float64(Float64(cos(phi1) * (sin(t_0) ^ 2.0)) + (sin(Float64(0.5 * phi1)) ^ 2.0)) t_4 = Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_0)))) * Float64(cos(phi2) * cos(phi1))) tmp = 0.0 if (Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 0.015) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - t_3))))); else tmp = Float64(atan(sqrt(Float64(t_4 + Float64(0.5 - t_2))), sqrt(Float64(Float64(0.5 + t_2) - t_4))) * Float64(2.0 * R)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = 0.5 * (lambda1 - lambda2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = 0.5 * cos((2.0 * (0.5 * (((0.5 * (phi1 - phi2)) + (0.5 * phi1)) - (phi2 * 0.5))))); t_3 = (cos(phi1) * (sin(t_0) ^ 2.0)) + (sin((0.5 * phi1)) ^ 2.0); t_4 = (0.5 - (0.5 * cos((2.0 * t_0)))) * (cos(phi2) * cos(phi1)); tmp = 0.0; if (((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 0.015) tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_3)))); else tmp = atan2(sqrt((t_4 + (0.5 - t_2))), sqrt(((0.5 + t_2) - t_4))) * (2.0 * R); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(N[(N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision] + N[(0.5 * phi1), $MachinePrecision]), $MachinePrecision] - N[(phi2 * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[t$95$0], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 0.015], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[ArcTan[N[Sqrt[N[(t$95$4 + N[(0.5 - t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + t$95$2), $MachinePrecision] - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := 0.5 \cdot \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\left(0.5 \cdot \left(\phi_1 - \phi_2\right) + 0.5 \cdot \phi_1\right) - \phi_2 \cdot 0.5\right)\right)\right)\\
t_3 := \cos \phi_1 \cdot {\sin t\_0}^{2} + {\sin \left(0.5 \cdot \phi_1\right)}^{2}\\
t_4 := \left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_0\right)\right) \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)\\
\mathbf{if}\;{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) \cdot t\_1 \leq 0.015:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_4 + \left(0.5 - t\_2\right)}}{\sqrt{\left(0.5 + t\_2\right) - t\_4}} \cdot \left(2 \cdot R\right)\\
\end{array}
if (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) < 0.014999999999999999Initial program 60.9%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f6446.1%
Applied rewrites46.1%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f6446.3%
Applied rewrites46.3%
if 0.014999999999999999 < (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) Initial program 60.9%
Applied rewrites56.0%
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-outN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flipN/A
lift--.f64N/A
div-subN/A
associate-+r-N/A
lower--.f64N/A
lower-+.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6456.0%
Applied rewrites56.0%
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-outN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flipN/A
lift--.f64N/A
div-subN/A
associate-+r-N/A
lower--.f64N/A
lower-+.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6456.0%
Applied rewrites56.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* 0.5 (- lambda1 lambda2)))
(t_1 (pow (sin t_0) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3
(*
(- 0.5 (* 0.5 (cos (* 2.0 t_0))))
(* (cos phi2) (cos phi1))))
(t_4
(*
0.5
(cos
(*
2.0
(*
0.5
(-
(+ (* 0.5 (- phi1 phi2)) (* 0.5 phi1))
(* phi2 0.5))))))))
(if (<=
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_2) t_2))
0.002)
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi1) t_1) (pow (sin (* 0.5 phi1)) 2.0)))
(sqrt
(-
1.0
(+ (* (cos phi2) t_1) (pow (sin (* -0.5 phi2)) 2.0)))))))
(*
(atan2 (sqrt (+ t_3 (- 0.5 t_4))) (sqrt (- (+ 0.5 t_4) t_3)))
(* 2.0 R)))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 * (lambda1 - lambda2);
double t_1 = pow(sin(t_0), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = (0.5 - (0.5 * cos((2.0 * t_0)))) * (cos(phi2) * cos(phi1));
double t_4 = 0.5 * cos((2.0 * (0.5 * (((0.5 * (phi1 - phi2)) + (0.5 * phi1)) - (phi2 * 0.5)))));
double tmp;
if ((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_2) * t_2)) <= 0.002) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_1) + pow(sin((0.5 * phi1)), 2.0))), sqrt((1.0 - ((cos(phi2) * t_1) + pow(sin((-0.5 * phi2)), 2.0))))));
} else {
tmp = atan2(sqrt((t_3 + (0.5 - t_4))), sqrt(((0.5 + t_4) - t_3))) * (2.0 * R);
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
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 = 0.5d0 * (lambda1 - lambda2)
t_1 = sin(t_0) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = (0.5d0 - (0.5d0 * cos((2.0d0 * t_0)))) * (cos(phi2) * cos(phi1))
t_4 = 0.5d0 * cos((2.0d0 * (0.5d0 * (((0.5d0 * (phi1 - phi2)) + (0.5d0 * phi1)) - (phi2 * 0.5d0)))))
if (((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_2) * t_2)) <= 0.002d0) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * t_1) + (sin((0.5d0 * phi1)) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi2) * t_1) + (sin(((-0.5d0) * phi2)) ** 2.0d0))))))
else
tmp = atan2(sqrt((t_3 + (0.5d0 - t_4))), sqrt(((0.5d0 + t_4) - t_3))) * (2.0d0 * r)
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 * (lambda1 - lambda2);
double t_1 = Math.pow(Math.sin(t_0), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = (0.5 - (0.5 * Math.cos((2.0 * t_0)))) * (Math.cos(phi2) * Math.cos(phi1));
double t_4 = 0.5 * Math.cos((2.0 * (0.5 * (((0.5 * (phi1 - phi2)) + (0.5 * phi1)) - (phi2 * 0.5)))));
double tmp;
if ((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_2) * t_2)) <= 0.002) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * t_1) + Math.pow(Math.sin((0.5 * phi1)), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi2) * t_1) + Math.pow(Math.sin((-0.5 * phi2)), 2.0))))));
} else {
tmp = Math.atan2(Math.sqrt((t_3 + (0.5 - t_4))), Math.sqrt(((0.5 + t_4) - t_3))) * (2.0 * R);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = 0.5 * (lambda1 - lambda2) t_1 = math.pow(math.sin(t_0), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = (0.5 - (0.5 * math.cos((2.0 * t_0)))) * (math.cos(phi2) * math.cos(phi1)) t_4 = 0.5 * math.cos((2.0 * (0.5 * (((0.5 * (phi1 - phi2)) + (0.5 * phi1)) - (phi2 * 0.5))))) tmp = 0 if (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_2) * t_2)) <= 0.002: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * t_1) + math.pow(math.sin((0.5 * phi1)), 2.0))), math.sqrt((1.0 - ((math.cos(phi2) * t_1) + math.pow(math.sin((-0.5 * phi2)), 2.0)))))) else: tmp = math.atan2(math.sqrt((t_3 + (0.5 - t_4))), math.sqrt(((0.5 + t_4) - t_3))) * (2.0 * R) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(0.5 * Float64(lambda1 - lambda2)) t_1 = sin(t_0) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_0)))) * Float64(cos(phi2) * cos(phi1))) t_4 = Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(Float64(Float64(0.5 * Float64(phi1 - phi2)) + Float64(0.5 * phi1)) - Float64(phi2 * 0.5)))))) tmp = 0.0 if (Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_2) * t_2)) <= 0.002) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * t_1) + (sin(Float64(0.5 * phi1)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_1) + (sin(Float64(-0.5 * phi2)) ^ 2.0))))))); else tmp = Float64(atan(sqrt(Float64(t_3 + Float64(0.5 - t_4))), sqrt(Float64(Float64(0.5 + t_4) - t_3))) * Float64(2.0 * R)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = 0.5 * (lambda1 - lambda2); t_1 = sin(t_0) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = (0.5 - (0.5 * cos((2.0 * t_0)))) * (cos(phi2) * cos(phi1)); t_4 = 0.5 * cos((2.0 * (0.5 * (((0.5 * (phi1 - phi2)) + (0.5 * phi1)) - (phi2 * 0.5))))); tmp = 0.0; if (((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_2) * t_2)) <= 0.002) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_1) + (sin((0.5 * phi1)) ^ 2.0))), sqrt((1.0 - ((cos(phi2) * t_1) + (sin((-0.5 * phi2)) ^ 2.0)))))); else tmp = atan2(sqrt((t_3 + (0.5 - t_4))), sqrt(((0.5 + t_4) - t_3))) * (2.0 * R); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[t$95$0], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(N[(N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision] + N[(0.5 * phi1), $MachinePrecision]), $MachinePrecision] - N[(phi2 * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision], 0.002], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[ArcTan[N[Sqrt[N[(t$95$3 + N[(0.5 - t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + t$95$4), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := 0.5 \cdot \left(\lambda_1 - \lambda_2\right)\\
t_1 := {\sin t\_0}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_0\right)\right) \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)\\
t_4 := 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\left(0.5 \cdot \left(\phi_1 - \phi_2\right) + 0.5 \cdot \phi_1\right) - \phi_2 \cdot 0.5\right)\right)\right)\\
\mathbf{if}\;{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\right) \cdot t\_2 \leq 0.002:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot t\_1 + {\sin \left(0.5 \cdot \phi_1\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_1 + {\sin \left(-0.5 \cdot \phi_2\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_3 + \left(0.5 - t\_4\right)}}{\sqrt{\left(0.5 + t\_4\right) - t\_3}} \cdot \left(2 \cdot R\right)\\
\end{array}
if (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) < 2e-3Initial program 60.9%
Taylor expanded in phi2 around 0
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f6446.1%
Applied rewrites46.1%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f6433.3%
Applied rewrites33.3%
if 2e-3 < (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) Initial program 60.9%
Applied rewrites56.0%
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-outN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flipN/A
lift--.f64N/A
div-subN/A
associate-+r-N/A
lower--.f64N/A
lower-+.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6456.0%
Applied rewrites56.0%
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-outN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flipN/A
lift--.f64N/A
div-subN/A
associate-+r-N/A
lower--.f64N/A
lower-+.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6456.0%
Applied rewrites56.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* 0.5 (- lambda1 lambda2)))
(t_1
(*
(- 0.5 (* 0.5 (cos (* 2.0 t_0))))
(* (cos phi2) (cos phi1))))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_4
(*
0.5
(cos
(*
2.0
(*
0.5
(-
(+ (* 0.5 (- phi1 phi2)) (* 0.5 phi1))
(* phi2 0.5))))))))
(if (<= (+ t_3 (* (* (* (cos phi1) (cos phi2)) t_2) t_2)) 2e-43)
(*
R
(*
2.0
(atan2
(sqrt (pow (sin t_0) 2.0))
(sqrt
(-
1.0
(+
t_3
(*
(* (* (cos phi1) (sin (+ (* PI 0.5) phi2))) t_2)
t_2)))))))
(*
(atan2 (sqrt (+ t_1 (- 0.5 t_4))) (sqrt (- (+ 0.5 t_4) t_1)))
(* 2.0 R)))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 * (lambda1 - lambda2);
double t_1 = (0.5 - (0.5 * cos((2.0 * t_0)))) * (cos(phi2) * cos(phi1));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_4 = 0.5 * cos((2.0 * (0.5 * (((0.5 * (phi1 - phi2)) + (0.5 * phi1)) - (phi2 * 0.5)))));
double tmp;
if ((t_3 + (((cos(phi1) * cos(phi2)) * t_2) * t_2)) <= 2e-43) {
tmp = R * (2.0 * atan2(sqrt(pow(sin(t_0), 2.0)), sqrt((1.0 - (t_3 + (((cos(phi1) * sin(((((double) M_PI) * 0.5) + phi2))) * t_2) * t_2))))));
} else {
tmp = atan2(sqrt((t_1 + (0.5 - t_4))), sqrt(((0.5 + t_4) - t_1))) * (2.0 * R);
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 * (lambda1 - lambda2);
double t_1 = (0.5 - (0.5 * Math.cos((2.0 * t_0)))) * (Math.cos(phi2) * Math.cos(phi1));
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_4 = 0.5 * Math.cos((2.0 * (0.5 * (((0.5 * (phi1 - phi2)) + (0.5 * phi1)) - (phi2 * 0.5)))));
double tmp;
if ((t_3 + (((Math.cos(phi1) * Math.cos(phi2)) * t_2) * t_2)) <= 2e-43) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(Math.pow(Math.sin(t_0), 2.0)), Math.sqrt((1.0 - (t_3 + (((Math.cos(phi1) * Math.sin(((Math.PI * 0.5) + phi2))) * t_2) * t_2))))));
} else {
tmp = Math.atan2(Math.sqrt((t_1 + (0.5 - t_4))), Math.sqrt(((0.5 + t_4) - t_1))) * (2.0 * R);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = 0.5 * (lambda1 - lambda2) t_1 = (0.5 - (0.5 * math.cos((2.0 * t_0)))) * (math.cos(phi2) * math.cos(phi1)) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_4 = 0.5 * math.cos((2.0 * (0.5 * (((0.5 * (phi1 - phi2)) + (0.5 * phi1)) - (phi2 * 0.5))))) tmp = 0 if (t_3 + (((math.cos(phi1) * math.cos(phi2)) * t_2) * t_2)) <= 2e-43: tmp = R * (2.0 * math.atan2(math.sqrt(math.pow(math.sin(t_0), 2.0)), math.sqrt((1.0 - (t_3 + (((math.cos(phi1) * math.sin(((math.pi * 0.5) + phi2))) * t_2) * t_2)))))) else: tmp = math.atan2(math.sqrt((t_1 + (0.5 - t_4))), math.sqrt(((0.5 + t_4) - t_1))) * (2.0 * R) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(0.5 * Float64(lambda1 - lambda2)) t_1 = Float64(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * t_0)))) * Float64(cos(phi2) * cos(phi1))) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_4 = Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(Float64(Float64(0.5 * Float64(phi1 - phi2)) + Float64(0.5 * phi1)) - Float64(phi2 * 0.5)))))) tmp = 0.0 if (Float64(t_3 + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_2) * t_2)) <= 2e-43) tmp = Float64(R * Float64(2.0 * atan(sqrt((sin(t_0) ^ 2.0)), sqrt(Float64(1.0 - Float64(t_3 + Float64(Float64(Float64(cos(phi1) * sin(Float64(Float64(pi * 0.5) + phi2))) * t_2) * t_2))))))); else tmp = Float64(atan(sqrt(Float64(t_1 + Float64(0.5 - t_4))), sqrt(Float64(Float64(0.5 + t_4) - t_1))) * Float64(2.0 * R)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = 0.5 * (lambda1 - lambda2); t_1 = (0.5 - (0.5 * cos((2.0 * t_0)))) * (cos(phi2) * cos(phi1)); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_4 = 0.5 * cos((2.0 * (0.5 * (((0.5 * (phi1 - phi2)) + (0.5 * phi1)) - (phi2 * 0.5))))); tmp = 0.0; if ((t_3 + (((cos(phi1) * cos(phi2)) * t_2) * t_2)) <= 2e-43) tmp = R * (2.0 * atan2(sqrt((sin(t_0) ^ 2.0)), sqrt((1.0 - (t_3 + (((cos(phi1) * sin(((pi * 0.5) + phi2))) * t_2) * t_2)))))); else tmp = atan2(sqrt((t_1 + (0.5 - t_4))), sqrt(((0.5 + t_4) - t_1))) * (2.0 * R); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(N[(N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision] + N[(0.5 * phi1), $MachinePrecision]), $MachinePrecision] - N[(phi2 * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$3 + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision], 2e-43], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[Power[N[Sin[t$95$0], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[N[(N[(Pi * 0.5), $MachinePrecision] + phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + t$95$4), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
t_0 := 0.5 \cdot \left(\lambda_1 - \lambda_2\right)\\
t_1 := \left(0.5 - 0.5 \cdot \cos \left(2 \cdot t\_0\right)\right) \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_4 := 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\left(0.5 \cdot \left(\phi_1 - \phi_2\right) + 0.5 \cdot \phi_1\right) - \phi_2 \cdot 0.5\right)\right)\right)\\
\mathbf{if}\;t\_3 + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\right) \cdot t\_2 \leq 2 \cdot 10^{-43}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin t\_0}^{2}}}{\sqrt{1 - \left(t\_3 + \left(\left(\cos \phi_1 \cdot \sin \left(\pi \cdot 0.5 + \phi_2\right)\right) \cdot t\_2\right) \cdot t\_2\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - t\_4\right)}}{\sqrt{\left(0.5 + t\_4\right) - t\_1}} \cdot \left(2 \cdot R\right)\\
\end{array}
if (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) < 2.0000000000000002e-43Initial program 60.9%
Taylor expanded in phi2 around 0
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f6446.1%
Applied rewrites46.1%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-PI.f64N/A
mult-flip-revN/A
metadata-evalN/A
lift-*.f6445.1%
Applied rewrites45.1%
Taylor expanded in phi1 around 0
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower--.f6428.4%
Applied rewrites28.4%
if 2.0000000000000002e-43 < (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) Initial program 60.9%
Applied rewrites56.0%
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-outN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flipN/A
lift--.f64N/A
div-subN/A
associate-+r-N/A
lower--.f64N/A
lower-+.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6456.0%
Applied rewrites56.0%
*-lft-identityN/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-outN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flipN/A
lift--.f64N/A
div-subN/A
associate-+r-N/A
lower--.f64N/A
lower-+.f64N/A
mult-flip-revN/A
metadata-evalN/A
*-commutativeN/A
lift-*.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6456.0%
Applied rewrites56.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(- 0.5 (* (cos (- lambda2 lambda1)) 0.5))
(* (cos phi2) (cos phi1))))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_3 (cos (- phi2 phi1))))
(if (<= (+ t_2 (* (* (* (cos phi1) (cos phi2)) t_1) t_1)) 2e-43)
(*
R
(*
2.0
(atan2
(sqrt (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(sqrt
(-
1.0
(+
t_2
(*
(* (* (cos phi1) (sin (+ (* PI 0.5) phi2))) t_1)
t_1)))))))
(*
(atan2
(sqrt (+ t_0 (- 0.5 (* t_3 0.5))))
(sqrt (- (* (+ t_3 1.0) 0.5) t_0)))
(+ R R)))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (0.5 - (cos((lambda2 - lambda1)) * 0.5)) * (cos(phi2) * cos(phi1));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_3 = cos((phi2 - phi1));
double tmp;
if ((t_2 + (((cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 2e-43) {
tmp = R * (2.0 * atan2(sqrt(pow(sin((0.5 * (lambda1 - lambda2))), 2.0)), sqrt((1.0 - (t_2 + (((cos(phi1) * sin(((((double) M_PI) * 0.5) + phi2))) * t_1) * t_1))))));
} else {
tmp = atan2(sqrt((t_0 + (0.5 - (t_3 * 0.5)))), sqrt((((t_3 + 1.0) * 0.5) - t_0))) * (R + R);
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (0.5 - (Math.cos((lambda2 - lambda1)) * 0.5)) * (Math.cos(phi2) * Math.cos(phi1));
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_3 = Math.cos((phi2 - phi1));
double tmp;
if ((t_2 + (((Math.cos(phi1) * Math.cos(phi2)) * t_1) * t_1)) <= 2e-43) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)), Math.sqrt((1.0 - (t_2 + (((Math.cos(phi1) * Math.sin(((Math.PI * 0.5) + phi2))) * t_1) * t_1))))));
} else {
tmp = Math.atan2(Math.sqrt((t_0 + (0.5 - (t_3 * 0.5)))), Math.sqrt((((t_3 + 1.0) * 0.5) - t_0))) * (R + R);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (0.5 - (math.cos((lambda2 - lambda1)) * 0.5)) * (math.cos(phi2) * math.cos(phi1)) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_3 = math.cos((phi2 - phi1)) tmp = 0 if (t_2 + (((math.cos(phi1) * math.cos(phi2)) * t_1) * t_1)) <= 2e-43: tmp = R * (2.0 * math.atan2(math.sqrt(math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)), math.sqrt((1.0 - (t_2 + (((math.cos(phi1) * math.sin(((math.pi * 0.5) + phi2))) * t_1) * t_1)))))) else: tmp = math.atan2(math.sqrt((t_0 + (0.5 - (t_3 * 0.5)))), math.sqrt((((t_3 + 1.0) * 0.5) - t_0))) * (R + R) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(0.5 - Float64(cos(Float64(lambda2 - lambda1)) * 0.5)) * Float64(cos(phi2) * cos(phi1))) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_3 = cos(Float64(phi2 - phi1)) tmp = 0.0 if (Float64(t_2 + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 2e-43) tmp = Float64(R * Float64(2.0 * atan(sqrt((sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)), sqrt(Float64(1.0 - Float64(t_2 + Float64(Float64(Float64(cos(phi1) * sin(Float64(Float64(pi * 0.5) + phi2))) * t_1) * t_1))))))); else tmp = Float64(atan(sqrt(Float64(t_0 + Float64(0.5 - Float64(t_3 * 0.5)))), sqrt(Float64(Float64(Float64(t_3 + 1.0) * 0.5) - t_0))) * Float64(R + R)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (0.5 - (cos((lambda2 - lambda1)) * 0.5)) * (cos(phi2) * cos(phi1)); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_3 = cos((phi2 - phi1)); tmp = 0.0; if ((t_2 + (((cos(phi1) * cos(phi2)) * t_1) * t_1)) <= 2e-43) tmp = R * (2.0 * atan2(sqrt((sin((0.5 * (lambda1 - lambda2))) ^ 2.0)), sqrt((1.0 - (t_2 + (((cos(phi1) * sin(((pi * 0.5) + phi2))) * t_1) * t_1)))))); else tmp = atan2(sqrt((t_0 + (0.5 - (t_3 * 0.5)))), sqrt((((t_3 + 1.0) * 0.5) - t_0))) * (R + R); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(0.5 - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[(phi2 - phi1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$2 + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 2e-43], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[N[(N[(Pi * 0.5), $MachinePrecision] + phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[ArcTan[N[Sqrt[N[(t$95$0 + N[(0.5 - N[(t$95$3 * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(N[(t$95$3 + 1.0), $MachinePrecision] * 0.5), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R + R), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \left(0.5 - \cos \left(\lambda_2 - \lambda_1\right) \cdot 0.5\right) \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_3 := \cos \left(\phi_2 - \phi_1\right)\\
\mathbf{if}\;t\_2 + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) \cdot t\_1 \leq 2 \cdot 10^{-43}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{1 - \left(t\_2 + \left(\left(\cos \phi_1 \cdot \sin \left(\pi \cdot 0.5 + \phi_2\right)\right) \cdot t\_1\right) \cdot t\_1\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_0 + \left(0.5 - t\_3 \cdot 0.5\right)}}{\sqrt{\left(t\_3 + 1\right) \cdot 0.5 - t\_0}} \cdot \left(R + R\right)\\
\end{array}
if (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) < 2.0000000000000002e-43Initial program 60.9%
Taylor expanded in phi2 around 0
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f6446.1%
Applied rewrites46.1%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-PI.f64N/A
mult-flip-revN/A
metadata-evalN/A
lift-*.f6445.1%
Applied rewrites45.1%
Taylor expanded in phi1 around 0
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower--.f6428.4%
Applied rewrites28.4%
if 2.0000000000000002e-43 < (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
Applied rewrites56.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- phi2 phi1)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_1) t_1)))
(t_3
(*
(- 0.5 (* (cos (- lambda2 lambda1)) 0.5))
(* (cos phi2) (cos phi1)))))
(if (<= t_2 2e-43)
(*
R
(*
2.0
(atan2
(sqrt (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(sqrt (- 1.0 t_2)))))
(*
(atan2
(sqrt (+ t_3 (- 0.5 (* t_0 0.5))))
(sqrt (- (* (+ t_0 1.0) 0.5) t_3)))
(+ R R)))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 - phi1));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_1) * t_1);
double t_3 = (0.5 - (cos((lambda2 - lambda1)) * 0.5)) * (cos(phi2) * cos(phi1));
double tmp;
if (t_2 <= 2e-43) {
tmp = R * (2.0 * atan2(sqrt(pow(sin((0.5 * (lambda1 - lambda2))), 2.0)), sqrt((1.0 - t_2))));
} else {
tmp = atan2(sqrt((t_3 + (0.5 - (t_0 * 0.5)))), sqrt((((t_0 + 1.0) * 0.5) - t_3))) * (R + R);
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos((phi2 - phi1))
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_1) * t_1)
t_3 = (0.5d0 - (cos((lambda2 - lambda1)) * 0.5d0)) * (cos(phi2) * cos(phi1))
if (t_2 <= 2d-43) then
tmp = r * (2.0d0 * atan2(sqrt((sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)), sqrt((1.0d0 - t_2))))
else
tmp = atan2(sqrt((t_3 + (0.5d0 - (t_0 * 0.5d0)))), sqrt((((t_0 + 1.0d0) * 0.5d0) - t_3))) * (r + r)
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((phi2 - phi1));
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_1) * t_1);
double t_3 = (0.5 - (Math.cos((lambda2 - lambda1)) * 0.5)) * (Math.cos(phi2) * Math.cos(phi1));
double tmp;
if (t_2 <= 2e-43) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)), Math.sqrt((1.0 - t_2))));
} else {
tmp = Math.atan2(Math.sqrt((t_3 + (0.5 - (t_0 * 0.5)))), Math.sqrt((((t_0 + 1.0) * 0.5) - t_3))) * (R + R);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((phi2 - phi1)) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_1) * t_1) t_3 = (0.5 - (math.cos((lambda2 - lambda1)) * 0.5)) * (math.cos(phi2) * math.cos(phi1)) tmp = 0 if t_2 <= 2e-43: tmp = R * (2.0 * math.atan2(math.sqrt(math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)), math.sqrt((1.0 - t_2)))) else: tmp = math.atan2(math.sqrt((t_3 + (0.5 - (t_0 * 0.5)))), math.sqrt((((t_0 + 1.0) * 0.5) - t_3))) * (R + R) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 - phi1)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_1) * t_1)) t_3 = Float64(Float64(0.5 - Float64(cos(Float64(lambda2 - lambda1)) * 0.5)) * Float64(cos(phi2) * cos(phi1))) tmp = 0.0 if (t_2 <= 2e-43) tmp = Float64(R * Float64(2.0 * atan(sqrt((sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)), sqrt(Float64(1.0 - t_2))))); else tmp = Float64(atan(sqrt(Float64(t_3 + Float64(0.5 - Float64(t_0 * 0.5)))), sqrt(Float64(Float64(Float64(t_0 + 1.0) * 0.5) - t_3))) * Float64(R + R)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi2 - phi1)); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_1) * t_1); t_3 = (0.5 - (cos((lambda2 - lambda1)) * 0.5)) * (cos(phi2) * cos(phi1)); tmp = 0.0; if (t_2 <= 2e-43) tmp = R * (2.0 * atan2(sqrt((sin((0.5 * (lambda1 - lambda2))) ^ 2.0)), sqrt((1.0 - t_2)))); else tmp = atan2(sqrt((t_3 + (0.5 - (t_0 * 0.5)))), sqrt((((t_0 + 1.0) * 0.5) - t_3))) * (R + R); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 - phi1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(0.5 - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 2e-43], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[ArcTan[N[Sqrt[N[(t$95$3 + N[(0.5 - N[(t$95$0 * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(N[(t$95$0 + 1.0), $MachinePrecision] * 0.5), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R + R), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \cos \left(\phi_2 - \phi_1\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) \cdot t\_1\\
t_3 := \left(0.5 - \cos \left(\lambda_2 - \lambda_1\right) \cdot 0.5\right) \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)\\
\mathbf{if}\;t\_2 \leq 2 \cdot 10^{-43}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_3 + \left(0.5 - t\_0 \cdot 0.5\right)}}{\sqrt{\left(t\_0 + 1\right) \cdot 0.5 - t\_3}} \cdot \left(R + R\right)\\
\end{array}
if (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) < 2.0000000000000002e-43Initial program 60.9%
Taylor expanded in phi2 around 0
lower-sqrt.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f6446.1%
Applied rewrites46.1%
Taylor expanded in phi1 around 0
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower--.f6429.5%
Applied rewrites29.5%
if 2.0000000000000002e-43 < (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
Applied rewrites56.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (- 0.5 (* 0.5 (cos (- lambda1 lambda2))))))
(t_1
(-
(+
0.5
(* (cos phi2) (- 0.5 (* 0.5 (cos (- lambda2 lambda1))))))
(* 0.5 (cos phi2))))
(t_2 (* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
(if (<= phi2 -0.26)
t_2
(if (<= phi2 3.1e-6)
(*
(atan2
(sqrt
(+ t_0 (- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))
(sqrt
(-
(+ 0.5 (+ (* 0.5 (cos phi1)) (* 0.5 (* phi2 (sin phi1)))))
t_0)))
(* 2.0 R))
t_2))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2))));
double t_1 = (0.5 + (cos(phi2) * (0.5 - (0.5 * cos((lambda2 - lambda1)))))) - (0.5 * cos(phi2));
double t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
double tmp;
if (phi2 <= -0.26) {
tmp = t_2;
} else if (phi2 <= 3.1e-6) {
tmp = atan2(sqrt((t_0 + (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))), sqrt(((0.5 + ((0.5 * cos(phi1)) + (0.5 * (phi2 * sin(phi1))))) - t_0))) * (2.0 * R);
} 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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * (0.5d0 - (0.5d0 * cos((lambda1 - lambda2))))
t_1 = (0.5d0 + (cos(phi2) * (0.5d0 - (0.5d0 * cos((lambda2 - lambda1)))))) - (0.5d0 * cos(phi2))
t_2 = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
if (phi2 <= (-0.26d0)) then
tmp = t_2
else if (phi2 <= 3.1d-6) then
tmp = atan2(sqrt((t_0 + (0.5d0 - (0.5d0 * cos((2.0d0 * (0.5d0 * (phi1 - phi2)))))))), sqrt(((0.5d0 + ((0.5d0 * cos(phi1)) + (0.5d0 * (phi2 * sin(phi1))))) - t_0))) * (2.0d0 * r)
else
tmp = t_2
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * (0.5 - (0.5 * Math.cos((lambda1 - lambda2))));
double t_1 = (0.5 + (Math.cos(phi2) * (0.5 - (0.5 * Math.cos((lambda2 - lambda1)))))) - (0.5 * Math.cos(phi2));
double t_2 = R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
double tmp;
if (phi2 <= -0.26) {
tmp = t_2;
} else if (phi2 <= 3.1e-6) {
tmp = Math.atan2(Math.sqrt((t_0 + (0.5 - (0.5 * Math.cos((2.0 * (0.5 * (phi1 - phi2)))))))), Math.sqrt(((0.5 + ((0.5 * Math.cos(phi1)) + (0.5 * (phi2 * Math.sin(phi1))))) - t_0))) * (2.0 * R);
} else {
tmp = t_2;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * (0.5 - (0.5 * math.cos((lambda1 - lambda2)))) t_1 = (0.5 + (math.cos(phi2) * (0.5 - (0.5 * math.cos((lambda2 - lambda1)))))) - (0.5 * math.cos(phi2)) t_2 = R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1)))) tmp = 0 if phi2 <= -0.26: tmp = t_2 elif phi2 <= 3.1e-6: tmp = math.atan2(math.sqrt((t_0 + (0.5 - (0.5 * math.cos((2.0 * (0.5 * (phi1 - phi2)))))))), math.sqrt(((0.5 + ((0.5 * math.cos(phi1)) + (0.5 * (phi2 * math.sin(phi1))))) - t_0))) * (2.0 * R) else: tmp = t_2 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))) t_1 = Float64(Float64(0.5 + Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda2 - lambda1)))))) - Float64(0.5 * cos(phi2))) t_2 = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) tmp = 0.0 if (phi2 <= -0.26) tmp = t_2; elseif (phi2 <= 3.1e-6) tmp = Float64(atan(sqrt(Float64(t_0 + Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))), sqrt(Float64(Float64(0.5 + Float64(Float64(0.5 * cos(phi1)) + Float64(0.5 * Float64(phi2 * sin(phi1))))) - t_0))) * Float64(2.0 * R)); else tmp = t_2; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2)))); t_1 = (0.5 + (cos(phi2) * (0.5 - (0.5 * cos((lambda2 - lambda1)))))) - (0.5 * cos(phi2)); t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); tmp = 0.0; if (phi2 <= -0.26) tmp = t_2; elseif (phi2 <= 3.1e-6) tmp = atan2(sqrt((t_0 + (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))), sqrt(((0.5 + ((0.5 * cos(phi1)) + (0.5 * (phi2 * sin(phi1))))) - t_0))) * (2.0 * R); else tmp = t_2; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 + N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.26], t$95$2, If[LessEqual[phi2, 3.1e-6], N[(N[ArcTan[N[Sqrt[N[(t$95$0 + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + N[(N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(phi2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
t_1 := \left(0.5 + \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\right) - 0.5 \cdot \cos \phi_2\\
t_2 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{if}\;\phi_2 \leq -0.26:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_2 \leq 3.1 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_0 + \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}{\sqrt{\left(0.5 + \left(0.5 \cdot \cos \phi_1 + 0.5 \cdot \left(\phi_2 \cdot \sin \phi_1\right)\right)\right) - t\_0}} \cdot \left(2 \cdot R\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if phi2 < -0.26000000000000001 or 3.1e-6 < phi2 Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
Applied rewrites56.3%
Applied rewrites55.9%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f6441.7%
Applied rewrites41.7%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f6441.9%
Applied rewrites41.9%
if -0.26000000000000001 < phi2 < 3.1e-6Initial program 60.9%
Applied rewrites56.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6447.6%
Applied rewrites47.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6445.6%
Applied rewrites45.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f6437.4%
Applied rewrites37.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (- 0.5 (* 0.5 (cos (- lambda1 lambda2))))))
(t_1 (* 0.5 (cos phi1)))
(t_2
(-
(+
0.5
(* (cos phi2) (- 0.5 (* 0.5 (cos (- lambda2 lambda1))))))
(* 0.5 (cos phi2))))
(t_3 (* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2)))))))
(if (<= phi2 -95000.0)
t_3
(if (<= phi2 3.1e-6)
(*
(atan2
(sqrt (+ t_0 (- 0.5 t_1)))
(sqrt (- (+ 0.5 (+ t_1 (* 0.5 (* phi2 (sin phi1))))) t_0)))
(* 2.0 R))
t_3))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2))));
double t_1 = 0.5 * cos(phi1);
double t_2 = (0.5 + (cos(phi2) * (0.5 - (0.5 * cos((lambda2 - lambda1)))))) - (0.5 * cos(phi2));
double t_3 = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
double tmp;
if (phi2 <= -95000.0) {
tmp = t_3;
} else if (phi2 <= 3.1e-6) {
tmp = atan2(sqrt((t_0 + (0.5 - t_1))), sqrt(((0.5 + (t_1 + (0.5 * (phi2 * sin(phi1))))) - t_0))) * (2.0 * R);
} 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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * (0.5d0 - (0.5d0 * cos((lambda1 - lambda2))))
t_1 = 0.5d0 * cos(phi1)
t_2 = (0.5d0 + (cos(phi2) * (0.5d0 - (0.5d0 * cos((lambda2 - lambda1)))))) - (0.5d0 * cos(phi2))
t_3 = r * (2.0d0 * atan2(sqrt(t_2), sqrt((1.0d0 - t_2))))
if (phi2 <= (-95000.0d0)) then
tmp = t_3
else if (phi2 <= 3.1d-6) then
tmp = atan2(sqrt((t_0 + (0.5d0 - t_1))), sqrt(((0.5d0 + (t_1 + (0.5d0 * (phi2 * sin(phi1))))) - t_0))) * (2.0d0 * r)
else
tmp = t_3
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * (0.5 - (0.5 * Math.cos((lambda1 - lambda2))));
double t_1 = 0.5 * Math.cos(phi1);
double t_2 = (0.5 + (Math.cos(phi2) * (0.5 - (0.5 * Math.cos((lambda2 - lambda1)))))) - (0.5 * Math.cos(phi2));
double t_3 = R * (2.0 * Math.atan2(Math.sqrt(t_2), Math.sqrt((1.0 - t_2))));
double tmp;
if (phi2 <= -95000.0) {
tmp = t_3;
} else if (phi2 <= 3.1e-6) {
tmp = Math.atan2(Math.sqrt((t_0 + (0.5 - t_1))), Math.sqrt(((0.5 + (t_1 + (0.5 * (phi2 * Math.sin(phi1))))) - t_0))) * (2.0 * R);
} else {
tmp = t_3;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * (0.5 - (0.5 * math.cos((lambda1 - lambda2)))) t_1 = 0.5 * math.cos(phi1) t_2 = (0.5 + (math.cos(phi2) * (0.5 - (0.5 * math.cos((lambda2 - lambda1)))))) - (0.5 * math.cos(phi2)) t_3 = R * (2.0 * math.atan2(math.sqrt(t_2), math.sqrt((1.0 - t_2)))) tmp = 0 if phi2 <= -95000.0: tmp = t_3 elif phi2 <= 3.1e-6: tmp = math.atan2(math.sqrt((t_0 + (0.5 - t_1))), math.sqrt(((0.5 + (t_1 + (0.5 * (phi2 * math.sin(phi1))))) - t_0))) * (2.0 * R) else: tmp = t_3 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))) t_1 = Float64(0.5 * cos(phi1)) t_2 = Float64(Float64(0.5 + Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda2 - lambda1)))))) - Float64(0.5 * cos(phi2))) t_3 = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))) tmp = 0.0 if (phi2 <= -95000.0) tmp = t_3; elseif (phi2 <= 3.1e-6) tmp = Float64(atan(sqrt(Float64(t_0 + Float64(0.5 - t_1))), sqrt(Float64(Float64(0.5 + Float64(t_1 + Float64(0.5 * Float64(phi2 * sin(phi1))))) - t_0))) * Float64(2.0 * R)); else tmp = t_3; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2)))); t_1 = 0.5 * cos(phi1); t_2 = (0.5 + (cos(phi2) * (0.5 - (0.5 * cos((lambda2 - lambda1)))))) - (0.5 * cos(phi2)); t_3 = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2)))); tmp = 0.0; if (phi2 <= -95000.0) tmp = t_3; elseif (phi2 <= 3.1e-6) tmp = atan2(sqrt((t_0 + (0.5 - t_1))), sqrt(((0.5 + (t_1 + (0.5 * (phi2 * sin(phi1))))) - t_0))) * (2.0 * R); else tmp = t_3; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(0.5 + N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -95000.0], t$95$3, If[LessEqual[phi2, 3.1e-6], N[(N[ArcTan[N[Sqrt[N[(t$95$0 + N[(0.5 - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + N[(t$95$1 + N[(0.5 * N[(phi2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
t_1 := 0.5 \cdot \cos \phi_1\\
t_2 := \left(0.5 + \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\right) - 0.5 \cdot \cos \phi_2\\
t_3 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{if}\;\phi_2 \leq -95000:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\phi_2 \leq 3.1 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_0 + \left(0.5 - t\_1\right)}}{\sqrt{\left(0.5 + \left(t\_1 + 0.5 \cdot \left(\phi_2 \cdot \sin \phi_1\right)\right)\right) - t\_0}} \cdot \left(2 \cdot R\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
if phi2 < -95000 or 3.1e-6 < phi2 Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
Applied rewrites56.3%
Applied rewrites55.9%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f6441.7%
Applied rewrites41.7%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f6441.9%
Applied rewrites41.9%
if -95000 < phi2 < 3.1e-6Initial program 60.9%
Applied rewrites56.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6447.6%
Applied rewrites47.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6445.6%
Applied rewrites45.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6440.3%
Applied rewrites40.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6442.5%
Applied rewrites42.5%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f6436.6%
Applied rewrites36.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* 0.5 (cos phi1)))
(t_1 (* (cos phi1) (- 0.5 (* 0.5 (cos (- lambda1 lambda2))))))
(t_2
(-
(+
0.5
(* (cos phi2) (- 0.5 (* 0.5 (cos (- lambda2 lambda1))))))
(* 0.5 (cos phi2))))
(t_3 (* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_2)))))))
(if (<= phi2 -1.2e+15)
t_3
(if (<= phi2 3.1e-6)
(*
(atan2
(sqrt (+ t_1 (- (+ 0.5 (* -0.5 (* phi2 (sin phi1)))) t_0)))
(sqrt (- (+ 0.5 t_0) t_1)))
(* 2.0 R))
t_3))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 * cos(phi1);
double t_1 = cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2))));
double t_2 = (0.5 + (cos(phi2) * (0.5 - (0.5 * cos((lambda2 - lambda1)))))) - (0.5 * cos(phi2));
double t_3 = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2))));
double tmp;
if (phi2 <= -1.2e+15) {
tmp = t_3;
} else if (phi2 <= 3.1e-6) {
tmp = atan2(sqrt((t_1 + ((0.5 + (-0.5 * (phi2 * sin(phi1)))) - t_0))), sqrt(((0.5 + t_0) - t_1))) * (2.0 * R);
} 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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = 0.5d0 * cos(phi1)
t_1 = cos(phi1) * (0.5d0 - (0.5d0 * cos((lambda1 - lambda2))))
t_2 = (0.5d0 + (cos(phi2) * (0.5d0 - (0.5d0 * cos((lambda2 - lambda1)))))) - (0.5d0 * cos(phi2))
t_3 = r * (2.0d0 * atan2(sqrt(t_2), sqrt((1.0d0 - t_2))))
if (phi2 <= (-1.2d+15)) then
tmp = t_3
else if (phi2 <= 3.1d-6) then
tmp = atan2(sqrt((t_1 + ((0.5d0 + ((-0.5d0) * (phi2 * sin(phi1)))) - t_0))), sqrt(((0.5d0 + t_0) - t_1))) * (2.0d0 * r)
else
tmp = t_3
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 * Math.cos(phi1);
double t_1 = Math.cos(phi1) * (0.5 - (0.5 * Math.cos((lambda1 - lambda2))));
double t_2 = (0.5 + (Math.cos(phi2) * (0.5 - (0.5 * Math.cos((lambda2 - lambda1)))))) - (0.5 * Math.cos(phi2));
double t_3 = R * (2.0 * Math.atan2(Math.sqrt(t_2), Math.sqrt((1.0 - t_2))));
double tmp;
if (phi2 <= -1.2e+15) {
tmp = t_3;
} else if (phi2 <= 3.1e-6) {
tmp = Math.atan2(Math.sqrt((t_1 + ((0.5 + (-0.5 * (phi2 * Math.sin(phi1)))) - t_0))), Math.sqrt(((0.5 + t_0) - t_1))) * (2.0 * R);
} else {
tmp = t_3;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = 0.5 * math.cos(phi1) t_1 = math.cos(phi1) * (0.5 - (0.5 * math.cos((lambda1 - lambda2)))) t_2 = (0.5 + (math.cos(phi2) * (0.5 - (0.5 * math.cos((lambda2 - lambda1)))))) - (0.5 * math.cos(phi2)) t_3 = R * (2.0 * math.atan2(math.sqrt(t_2), math.sqrt((1.0 - t_2)))) tmp = 0 if phi2 <= -1.2e+15: tmp = t_3 elif phi2 <= 3.1e-6: tmp = math.atan2(math.sqrt((t_1 + ((0.5 + (-0.5 * (phi2 * math.sin(phi1)))) - t_0))), math.sqrt(((0.5 + t_0) - t_1))) * (2.0 * R) else: tmp = t_3 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(0.5 * cos(phi1)) t_1 = Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))) t_2 = Float64(Float64(0.5 + Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda2 - lambda1)))))) - Float64(0.5 * cos(phi2))) t_3 = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_2))))) tmp = 0.0 if (phi2 <= -1.2e+15) tmp = t_3; elseif (phi2 <= 3.1e-6) tmp = Float64(atan(sqrt(Float64(t_1 + Float64(Float64(0.5 + Float64(-0.5 * Float64(phi2 * sin(phi1)))) - t_0))), sqrt(Float64(Float64(0.5 + t_0) - t_1))) * Float64(2.0 * R)); else tmp = t_3; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = 0.5 * cos(phi1); t_1 = cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2)))); t_2 = (0.5 + (cos(phi2) * (0.5 - (0.5 * cos((lambda2 - lambda1)))))) - (0.5 * cos(phi2)); t_3 = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_2)))); tmp = 0.0; if (phi2 <= -1.2e+15) tmp = t_3; elseif (phi2 <= 3.1e-6) tmp = atan2(sqrt((t_1 + ((0.5 + (-0.5 * (phi2 * sin(phi1)))) - t_0))), sqrt(((0.5 + t_0) - t_1))) * (2.0 * R); else tmp = t_3; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(0.5 + N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -1.2e+15], t$95$3, If[LessEqual[phi2, 3.1e-6], N[(N[ArcTan[N[Sqrt[N[(t$95$1 + N[(N[(0.5 + N[(-0.5 * N[(phi2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + t$95$0), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
t_0 := 0.5 \cdot \cos \phi_1\\
t_1 := \cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
t_2 := \left(0.5 + \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\right) - 0.5 \cdot \cos \phi_2\\
t_3 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{if}\;\phi_2 \leq -1.2 \cdot 10^{+15}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\phi_2 \leq 3.1 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_1 + \left(\left(0.5 + -0.5 \cdot \left(\phi_2 \cdot \sin \phi_1\right)\right) - t\_0\right)}}{\sqrt{\left(0.5 + t\_0\right) - t\_1}} \cdot \left(2 \cdot R\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
if phi2 < -1.2e15 or 3.1e-6 < phi2 Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
Applied rewrites56.3%
Applied rewrites55.9%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f6441.7%
Applied rewrites41.7%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f6441.9%
Applied rewrites41.9%
if -1.2e15 < phi2 < 3.1e-6Initial program 60.9%
Applied rewrites56.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6447.6%
Applied rewrites47.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6445.6%
Applied rewrites45.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6440.3%
Applied rewrites40.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6442.5%
Applied rewrites42.5%
Taylor expanded in phi2 around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f6438.9%
Applied rewrites38.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1)))
(t_1
(-
(+ 0.5 (* (cos phi2) (- 0.5 (* 0.5 t_0))))
(* 0.5 (cos phi2))))
(t_2 (* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
(if (<= phi2 -8.8e+16)
t_2
(if (<= phi2 3.1e-6)
(*
(atan2
(sqrt
(+
(* (cos phi1) (- 0.5 (* 0.5 (cos (- lambda1 lambda2)))))
(- 0.5 (* 0.5 (cos (* 2.0 (* 0.5 (- phi1 phi2))))))))
(sqrt
(+
0.5
(-
(* (cos (* 1.0 (- phi1 phi2))) 0.5)
(* (- 0.5 (* t_0 0.5)) (cos phi1))))))
(* 2.0 R))
t_2))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double t_1 = (0.5 + (cos(phi2) * (0.5 - (0.5 * t_0)))) - (0.5 * cos(phi2));
double t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
double tmp;
if (phi2 <= -8.8e+16) {
tmp = t_2;
} else if (phi2 <= 3.1e-6) {
tmp = atan2(sqrt(((cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2))))) + (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))), sqrt((0.5 + ((cos((1.0 * (phi1 - phi2))) * 0.5) - ((0.5 - (t_0 * 0.5)) * cos(phi1)))))) * (2.0 * R);
} 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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos((lambda2 - lambda1))
t_1 = (0.5d0 + (cos(phi2) * (0.5d0 - (0.5d0 * t_0)))) - (0.5d0 * cos(phi2))
t_2 = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
if (phi2 <= (-8.8d+16)) then
tmp = t_2
else if (phi2 <= 3.1d-6) then
tmp = atan2(sqrt(((cos(phi1) * (0.5d0 - (0.5d0 * cos((lambda1 - lambda2))))) + (0.5d0 - (0.5d0 * cos((2.0d0 * (0.5d0 * (phi1 - phi2)))))))), sqrt((0.5d0 + ((cos((1.0d0 * (phi1 - phi2))) * 0.5d0) - ((0.5d0 - (t_0 * 0.5d0)) * cos(phi1)))))) * (2.0d0 * r)
else
tmp = t_2
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda2 - lambda1));
double t_1 = (0.5 + (Math.cos(phi2) * (0.5 - (0.5 * t_0)))) - (0.5 * Math.cos(phi2));
double t_2 = R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
double tmp;
if (phi2 <= -8.8e+16) {
tmp = t_2;
} else if (phi2 <= 3.1e-6) {
tmp = Math.atan2(Math.sqrt(((Math.cos(phi1) * (0.5 - (0.5 * Math.cos((lambda1 - lambda2))))) + (0.5 - (0.5 * Math.cos((2.0 * (0.5 * (phi1 - phi2)))))))), Math.sqrt((0.5 + ((Math.cos((1.0 * (phi1 - phi2))) * 0.5) - ((0.5 - (t_0 * 0.5)) * Math.cos(phi1)))))) * (2.0 * R);
} else {
tmp = t_2;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) t_1 = (0.5 + (math.cos(phi2) * (0.5 - (0.5 * t_0)))) - (0.5 * math.cos(phi2)) t_2 = R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1)))) tmp = 0 if phi2 <= -8.8e+16: tmp = t_2 elif phi2 <= 3.1e-6: tmp = math.atan2(math.sqrt(((math.cos(phi1) * (0.5 - (0.5 * math.cos((lambda1 - lambda2))))) + (0.5 - (0.5 * math.cos((2.0 * (0.5 * (phi1 - phi2)))))))), math.sqrt((0.5 + ((math.cos((1.0 * (phi1 - phi2))) * 0.5) - ((0.5 - (t_0 * 0.5)) * math.cos(phi1)))))) * (2.0 * R) else: tmp = t_2 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) t_1 = Float64(Float64(0.5 + Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * t_0)))) - Float64(0.5 * cos(phi2))) t_2 = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) tmp = 0.0 if (phi2 <= -8.8e+16) tmp = t_2; elseif (phi2 <= 3.1e-6) tmp = Float64(atan(sqrt(Float64(Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))) + Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2)))))))), sqrt(Float64(0.5 + Float64(Float64(cos(Float64(1.0 * Float64(phi1 - phi2))) * 0.5) - Float64(Float64(0.5 - Float64(t_0 * 0.5)) * cos(phi1)))))) * Float64(2.0 * R)); else tmp = t_2; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda2 - lambda1)); t_1 = (0.5 + (cos(phi2) * (0.5 - (0.5 * t_0)))) - (0.5 * cos(phi2)); t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); tmp = 0.0; if (phi2 <= -8.8e+16) tmp = t_2; elseif (phi2 <= 3.1e-6) tmp = atan2(sqrt(((cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2))))) + (0.5 - (0.5 * cos((2.0 * (0.5 * (phi1 - phi2)))))))), sqrt((0.5 + ((cos((1.0 * (phi1 - phi2))) * 0.5) - ((0.5 - (t_0 * 0.5)) * cos(phi1)))))) * (2.0 * R); else tmp = t_2; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 + N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -8.8e+16], t$95$2, If[LessEqual[phi2, 3.1e-6], N[(N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[(N[Cos[N[(1.0 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision] - N[(N[(0.5 - N[(t$95$0 * 0.5), $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \left(0.5 + \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot t\_0\right)\right) - 0.5 \cdot \cos \phi_2\\
t_2 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{if}\;\phi_2 \leq -8.8 \cdot 10^{+16}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_2 \leq 3.1 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) + \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}}{\sqrt{0.5 + \left(\cos \left(1 \cdot \left(\phi_1 - \phi_2\right)\right) \cdot 0.5 - \left(0.5 - t\_0 \cdot 0.5\right) \cdot \cos \phi_1\right)}} \cdot \left(2 \cdot R\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if phi2 < -8.8e16 or 3.1e-6 < phi2 Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
Applied rewrites56.3%
Applied rewrites55.9%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f6441.7%
Applied rewrites41.7%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f6441.9%
Applied rewrites41.9%
if -8.8e16 < phi2 < 3.1e-6Initial program 60.9%
Applied rewrites56.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6447.6%
Applied rewrites47.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6445.6%
Applied rewrites45.6%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lower-+.f64N/A
lower--.f6445.6%
Applied rewrites45.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1)))
(t_1
(-
(+ 0.5 (* (cos phi2) (- 0.5 (* 0.5 t_0))))
(* 0.5 (cos phi2))))
(t_2 (* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
(if (<= phi2 -6.1e+18)
t_2
(if (<= phi2 3.1e-6)
(*
(atan2
(sqrt
(+
(* (cos phi1) (- 0.5 (* 0.5 (cos (- lambda1 lambda2)))))
(- 0.5 (* 0.5 (cos phi1)))))
(sqrt
(+
0.5
(- (* (cos phi1) 0.5) (* (- 0.5 (* t_0 0.5)) (cos phi1))))))
(* 2.0 R))
t_2))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double t_1 = (0.5 + (cos(phi2) * (0.5 - (0.5 * t_0)))) - (0.5 * cos(phi2));
double t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
double tmp;
if (phi2 <= -6.1e+18) {
tmp = t_2;
} else if (phi2 <= 3.1e-6) {
tmp = atan2(sqrt(((cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2))))) + (0.5 - (0.5 * cos(phi1))))), sqrt((0.5 + ((cos(phi1) * 0.5) - ((0.5 - (t_0 * 0.5)) * cos(phi1)))))) * (2.0 * R);
} 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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos((lambda2 - lambda1))
t_1 = (0.5d0 + (cos(phi2) * (0.5d0 - (0.5d0 * t_0)))) - (0.5d0 * cos(phi2))
t_2 = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
if (phi2 <= (-6.1d+18)) then
tmp = t_2
else if (phi2 <= 3.1d-6) then
tmp = atan2(sqrt(((cos(phi1) * (0.5d0 - (0.5d0 * cos((lambda1 - lambda2))))) + (0.5d0 - (0.5d0 * cos(phi1))))), sqrt((0.5d0 + ((cos(phi1) * 0.5d0) - ((0.5d0 - (t_0 * 0.5d0)) * cos(phi1)))))) * (2.0d0 * r)
else
tmp = t_2
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda2 - lambda1));
double t_1 = (0.5 + (Math.cos(phi2) * (0.5 - (0.5 * t_0)))) - (0.5 * Math.cos(phi2));
double t_2 = R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
double tmp;
if (phi2 <= -6.1e+18) {
tmp = t_2;
} else if (phi2 <= 3.1e-6) {
tmp = Math.atan2(Math.sqrt(((Math.cos(phi1) * (0.5 - (0.5 * Math.cos((lambda1 - lambda2))))) + (0.5 - (0.5 * Math.cos(phi1))))), Math.sqrt((0.5 + ((Math.cos(phi1) * 0.5) - ((0.5 - (t_0 * 0.5)) * Math.cos(phi1)))))) * (2.0 * R);
} else {
tmp = t_2;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) t_1 = (0.5 + (math.cos(phi2) * (0.5 - (0.5 * t_0)))) - (0.5 * math.cos(phi2)) t_2 = R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1)))) tmp = 0 if phi2 <= -6.1e+18: tmp = t_2 elif phi2 <= 3.1e-6: tmp = math.atan2(math.sqrt(((math.cos(phi1) * (0.5 - (0.5 * math.cos((lambda1 - lambda2))))) + (0.5 - (0.5 * math.cos(phi1))))), math.sqrt((0.5 + ((math.cos(phi1) * 0.5) - ((0.5 - (t_0 * 0.5)) * math.cos(phi1)))))) * (2.0 * R) else: tmp = t_2 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) t_1 = Float64(Float64(0.5 + Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * t_0)))) - Float64(0.5 * cos(phi2))) t_2 = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) tmp = 0.0 if (phi2 <= -6.1e+18) tmp = t_2; elseif (phi2 <= 3.1e-6) tmp = Float64(atan(sqrt(Float64(Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))) + Float64(0.5 - Float64(0.5 * cos(phi1))))), sqrt(Float64(0.5 + Float64(Float64(cos(phi1) * 0.5) - Float64(Float64(0.5 - Float64(t_0 * 0.5)) * cos(phi1)))))) * Float64(2.0 * R)); else tmp = t_2; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda2 - lambda1)); t_1 = (0.5 + (cos(phi2) * (0.5 - (0.5 * t_0)))) - (0.5 * cos(phi2)); t_2 = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); tmp = 0.0; if (phi2 <= -6.1e+18) tmp = t_2; elseif (phi2 <= 3.1e-6) tmp = atan2(sqrt(((cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2))))) + (0.5 - (0.5 * cos(phi1))))), sqrt((0.5 + ((cos(phi1) * 0.5) - ((0.5 - (t_0 * 0.5)) * cos(phi1)))))) * (2.0 * R); else tmp = t_2; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 + N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -6.1e+18], t$95$2, If[LessEqual[phi2, 3.1e-6], N[(N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[(N[Cos[phi1], $MachinePrecision] * 0.5), $MachinePrecision] - N[(N[(0.5 - N[(t$95$0 * 0.5), $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \left(0.5 + \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot t\_0\right)\right) - 0.5 \cdot \cos \phi_2\\
t_2 := R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{if}\;\phi_2 \leq -6.1 \cdot 10^{+18}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_2 \leq 3.1 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) + \left(0.5 - 0.5 \cdot \cos \phi_1\right)}}{\sqrt{0.5 + \left(\cos \phi_1 \cdot 0.5 - \left(0.5 - t\_0 \cdot 0.5\right) \cdot \cos \phi_1\right)}} \cdot \left(2 \cdot R\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if phi2 < -6.1e18 or 3.1e-6 < phi2 Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
Applied rewrites56.3%
Applied rewrites55.9%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f6441.7%
Applied rewrites41.7%
Taylor expanded in phi1 around 0
lower--.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f6441.9%
Applied rewrites41.9%
if -6.1e18 < phi2 < 3.1e-6Initial program 60.9%
Applied rewrites56.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6447.6%
Applied rewrites47.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6445.6%
Applied rewrites45.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6440.3%
Applied rewrites40.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6442.5%
Applied rewrites42.5%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lower-+.f64N/A
lower--.f6442.5%
Applied rewrites42.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- phi2 phi1)))
(t_1
(*
(- 0.5 (* (cos (- lambda2 lambda1)) 0.5))
(* (cos phi2) (cos phi1)))))
(*
(atan2
(sqrt (+ t_1 (- 0.5 (* t_0 0.5))))
(sqrt (- (* (+ t_0 1.0) 0.5) t_1)))
(+ R R))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 - phi1));
double t_1 = (0.5 - (cos((lambda2 - lambda1)) * 0.5)) * (cos(phi2) * cos(phi1));
return atan2(sqrt((t_1 + (0.5 - (t_0 * 0.5)))), sqrt((((t_0 + 1.0) * 0.5) - t_1))) * (R + R);
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = cos((phi2 - phi1))
t_1 = (0.5d0 - (cos((lambda2 - lambda1)) * 0.5d0)) * (cos(phi2) * cos(phi1))
code = atan2(sqrt((t_1 + (0.5d0 - (t_0 * 0.5d0)))), sqrt((((t_0 + 1.0d0) * 0.5d0) - t_1))) * (r + r)
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((phi2 - phi1));
double t_1 = (0.5 - (Math.cos((lambda2 - lambda1)) * 0.5)) * (Math.cos(phi2) * Math.cos(phi1));
return Math.atan2(Math.sqrt((t_1 + (0.5 - (t_0 * 0.5)))), Math.sqrt((((t_0 + 1.0) * 0.5) - t_1))) * (R + R);
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((phi2 - phi1)) t_1 = (0.5 - (math.cos((lambda2 - lambda1)) * 0.5)) * (math.cos(phi2) * math.cos(phi1)) return math.atan2(math.sqrt((t_1 + (0.5 - (t_0 * 0.5)))), math.sqrt((((t_0 + 1.0) * 0.5) - t_1))) * (R + R)
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 - phi1)) t_1 = Float64(Float64(0.5 - Float64(cos(Float64(lambda2 - lambda1)) * 0.5)) * Float64(cos(phi2) * cos(phi1))) return Float64(atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(t_0 * 0.5)))), sqrt(Float64(Float64(Float64(t_0 + 1.0) * 0.5) - t_1))) * Float64(R + R)) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi2 - phi1)); t_1 = (0.5 - (cos((lambda2 - lambda1)) * 0.5)) * (cos(phi2) * cos(phi1)); tmp = atan2(sqrt((t_1 + (0.5 - (t_0 * 0.5)))), sqrt((((t_0 + 1.0) * 0.5) - t_1))) * (R + R); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 - phi1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(t$95$0 * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(N[(t$95$0 + 1.0), $MachinePrecision] * 0.5), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R + R), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \cos \left(\phi_2 - \phi_1\right)\\
t_1 := \left(0.5 - \cos \left(\lambda_2 - \lambda_1\right) \cdot 0.5\right) \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)\\
\tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - t\_0 \cdot 0.5\right)}}{\sqrt{\left(t\_0 + 1\right) \cdot 0.5 - t\_1}} \cdot \left(R + R\right)
\end{array}
Initial program 60.9%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6460.0%
Applied rewrites60.0%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.4%
Applied rewrites61.4%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6461.1%
Applied rewrites61.1%
lift-sin.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f64N/A
lower-sin.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6475.9%
Applied rewrites75.9%
Applied rewrites56.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (- 0.5 (* 0.5 (cos (- lambda2))))))
(t_1 (* 0.5 (cos phi1)))
(t_2 (- 0.5 t_1))
(t_3 (+ 0.5 t_1))
(t_4 (* (cos phi1) (- 0.5 (* 0.5 (cos lambda1)))))
(t_5
(* (atan2 (sqrt (+ t_4 t_2)) (sqrt (- t_3 t_4))) (* 2.0 R))))
(if (<= lambda1 -4.8e+15)
t_5
(if (<= lambda1 8.6e-27)
(* (atan2 (sqrt (+ t_0 t_2)) (sqrt (- t_3 t_0))) (* 2.0 R))
t_5))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * (0.5 - (0.5 * cos(-lambda2)));
double t_1 = 0.5 * cos(phi1);
double t_2 = 0.5 - t_1;
double t_3 = 0.5 + t_1;
double t_4 = cos(phi1) * (0.5 - (0.5 * cos(lambda1)));
double t_5 = atan2(sqrt((t_4 + t_2)), sqrt((t_3 - t_4))) * (2.0 * R);
double tmp;
if (lambda1 <= -4.8e+15) {
tmp = t_5;
} else if (lambda1 <= 8.6e-27) {
tmp = atan2(sqrt((t_0 + t_2)), sqrt((t_3 - t_0))) * (2.0 * R);
} else {
tmp = t_5;
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = cos(phi1) * (0.5d0 - (0.5d0 * cos(-lambda2)))
t_1 = 0.5d0 * cos(phi1)
t_2 = 0.5d0 - t_1
t_3 = 0.5d0 + t_1
t_4 = cos(phi1) * (0.5d0 - (0.5d0 * cos(lambda1)))
t_5 = atan2(sqrt((t_4 + t_2)), sqrt((t_3 - t_4))) * (2.0d0 * r)
if (lambda1 <= (-4.8d+15)) then
tmp = t_5
else if (lambda1 <= 8.6d-27) then
tmp = atan2(sqrt((t_0 + t_2)), sqrt((t_3 - t_0))) * (2.0d0 * r)
else
tmp = t_5
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * (0.5 - (0.5 * Math.cos(-lambda2)));
double t_1 = 0.5 * Math.cos(phi1);
double t_2 = 0.5 - t_1;
double t_3 = 0.5 + t_1;
double t_4 = Math.cos(phi1) * (0.5 - (0.5 * Math.cos(lambda1)));
double t_5 = Math.atan2(Math.sqrt((t_4 + t_2)), Math.sqrt((t_3 - t_4))) * (2.0 * R);
double tmp;
if (lambda1 <= -4.8e+15) {
tmp = t_5;
} else if (lambda1 <= 8.6e-27) {
tmp = Math.atan2(Math.sqrt((t_0 + t_2)), Math.sqrt((t_3 - t_0))) * (2.0 * R);
} else {
tmp = t_5;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * (0.5 - (0.5 * math.cos(-lambda2))) t_1 = 0.5 * math.cos(phi1) t_2 = 0.5 - t_1 t_3 = 0.5 + t_1 t_4 = math.cos(phi1) * (0.5 - (0.5 * math.cos(lambda1))) t_5 = math.atan2(math.sqrt((t_4 + t_2)), math.sqrt((t_3 - t_4))) * (2.0 * R) tmp = 0 if lambda1 <= -4.8e+15: tmp = t_5 elif lambda1 <= 8.6e-27: tmp = math.atan2(math.sqrt((t_0 + t_2)), math.sqrt((t_3 - t_0))) * (2.0 * R) else: tmp = t_5 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * cos(Float64(-lambda2))))) t_1 = Float64(0.5 * cos(phi1)) t_2 = Float64(0.5 - t_1) t_3 = Float64(0.5 + t_1) t_4 = Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * cos(lambda1)))) t_5 = Float64(atan(sqrt(Float64(t_4 + t_2)), sqrt(Float64(t_3 - t_4))) * Float64(2.0 * R)) tmp = 0.0 if (lambda1 <= -4.8e+15) tmp = t_5; elseif (lambda1 <= 8.6e-27) tmp = Float64(atan(sqrt(Float64(t_0 + t_2)), sqrt(Float64(t_3 - t_0))) * Float64(2.0 * R)); else tmp = t_5; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * (0.5 - (0.5 * cos(-lambda2))); t_1 = 0.5 * cos(phi1); t_2 = 0.5 - t_1; t_3 = 0.5 + t_1; t_4 = cos(phi1) * (0.5 - (0.5 * cos(lambda1))); t_5 = atan2(sqrt((t_4 + t_2)), sqrt((t_3 - t_4))) * (2.0 * R); tmp = 0.0; if (lambda1 <= -4.8e+15) tmp = t_5; elseif (lambda1 <= 8.6e-27) tmp = atan2(sqrt((t_0 + t_2)), sqrt((t_3 - t_0))) * (2.0 * R); else tmp = t_5; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[(-lambda2)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(0.5 - t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(0.5 + t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[ArcTan[N[Sqrt[N[(t$95$4 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$3 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -4.8e+15], t$95$5, If[LessEqual[lambda1, 8.6e-27], N[(N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$3 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision], t$95$5]]]]]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \cos \left(-\lambda_2\right)\right)\\
t_1 := 0.5 \cdot \cos \phi_1\\
t_2 := 0.5 - t\_1\\
t_3 := 0.5 + t\_1\\
t_4 := \cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \cos \lambda_1\right)\\
t_5 := \tan^{-1}_* \frac{\sqrt{t\_4 + t\_2}}{\sqrt{t\_3 - t\_4}} \cdot \left(2 \cdot R\right)\\
\mathbf{if}\;\lambda_1 \leq -4.8 \cdot 10^{+15}:\\
\;\;\;\;t\_5\\
\mathbf{elif}\;\lambda_1 \leq 8.6 \cdot 10^{-27}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_0 + t\_2}}{\sqrt{t\_3 - t\_0}} \cdot \left(2 \cdot R\right)\\
\mathbf{else}:\\
\;\;\;\;t\_5\\
\end{array}
if lambda1 < -4.8e15 or 8.6e-27 < lambda1 Initial program 60.9%
Applied rewrites56.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6447.6%
Applied rewrites47.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6445.6%
Applied rewrites45.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6440.3%
Applied rewrites40.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6442.5%
Applied rewrites42.5%
Taylor expanded in lambda2 around 0
lower-cos.f6431.2%
Applied rewrites31.2%
Taylor expanded in lambda2 around 0
lower-cos.f6431.0%
Applied rewrites31.0%
if -4.8e15 < lambda1 < 8.6e-27Initial program 60.9%
Applied rewrites56.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6447.6%
Applied rewrites47.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6445.6%
Applied rewrites45.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6440.3%
Applied rewrites40.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6442.5%
Applied rewrites42.5%
Taylor expanded in lambda1 around 0
lower-cos.f64N/A
lower-neg.f6431.5%
Applied rewrites31.5%
Taylor expanded in lambda1 around 0
lower-cos.f64N/A
lower-neg.f6431.3%
Applied rewrites31.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(atan2
(sqrt
(+
(* (cos phi1) (- 0.5 (* 0.5 (cos (- lambda1 lambda2)))))
(- 0.5 (* 0.5 (cos phi1)))))
(sqrt
(+
0.5
(-
(* (cos phi1) 0.5)
(* (- 0.5 (* (cos (- lambda2 lambda1)) 0.5)) (cos phi1))))))
(* 2.0 R)))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sqrt(((cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2))))) + (0.5 - (0.5 * cos(phi1))))), sqrt((0.5 + ((cos(phi1) * 0.5) - ((0.5 - (cos((lambda2 - lambda1)) * 0.5)) * cos(phi1)))))) * (2.0 * R);
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sqrt(((cos(phi1) * (0.5d0 - (0.5d0 * cos((lambda1 - lambda2))))) + (0.5d0 - (0.5d0 * cos(phi1))))), sqrt((0.5d0 + ((cos(phi1) * 0.5d0) - ((0.5d0 - (cos((lambda2 - lambda1)) * 0.5d0)) * cos(phi1)))))) * (2.0d0 * r)
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sqrt(((Math.cos(phi1) * (0.5 - (0.5 * Math.cos((lambda1 - lambda2))))) + (0.5 - (0.5 * Math.cos(phi1))))), Math.sqrt((0.5 + ((Math.cos(phi1) * 0.5) - ((0.5 - (Math.cos((lambda2 - lambda1)) * 0.5)) * Math.cos(phi1)))))) * (2.0 * R);
}
def code(R, lambda1, lambda2, phi1, phi2): return math.atan2(math.sqrt(((math.cos(phi1) * (0.5 - (0.5 * math.cos((lambda1 - lambda2))))) + (0.5 - (0.5 * math.cos(phi1))))), math.sqrt((0.5 + ((math.cos(phi1) * 0.5) - ((0.5 - (math.cos((lambda2 - lambda1)) * 0.5)) * math.cos(phi1)))))) * (2.0 * R)
function code(R, lambda1, lambda2, phi1, phi2) return Float64(atan(sqrt(Float64(Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))) + Float64(0.5 - Float64(0.5 * cos(phi1))))), sqrt(Float64(0.5 + Float64(Float64(cos(phi1) * 0.5) - Float64(Float64(0.5 - Float64(cos(Float64(lambda2 - lambda1)) * 0.5)) * cos(phi1)))))) * Float64(2.0 * R)) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = atan2(sqrt(((cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2))))) + (0.5 - (0.5 * cos(phi1))))), sqrt((0.5 + ((cos(phi1) * 0.5) - ((0.5 - (cos((lambda2 - lambda1)) * 0.5)) * cos(phi1)))))) * (2.0 * R); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[(N[Cos[phi1], $MachinePrecision] * 0.5), $MachinePrecision] - N[(N[(0.5 - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision]
\tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) + \left(0.5 - 0.5 \cdot \cos \phi_1\right)}}{\sqrt{0.5 + \left(\cos \phi_1 \cdot 0.5 - \left(0.5 - \cos \left(\lambda_2 - \lambda_1\right) \cdot 0.5\right) \cdot \cos \phi_1\right)}} \cdot \left(2 \cdot R\right)
Initial program 60.9%
Applied rewrites56.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6447.6%
Applied rewrites47.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6445.6%
Applied rewrites45.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6440.3%
Applied rewrites40.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6442.5%
Applied rewrites42.5%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lower-+.f64N/A
lower--.f6442.5%
Applied rewrites42.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) 0.5))
(t_1 (* (- 0.5 (* (cos (- lambda2 lambda1)) 0.5)) (cos phi1))))
(*
(atan2 (sqrt (- t_1 (- t_0 0.5))) (sqrt (- (- t_0 -0.5) t_1)))
(+ R R))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * 0.5;
double t_1 = (0.5 - (cos((lambda2 - lambda1)) * 0.5)) * cos(phi1);
return atan2(sqrt((t_1 - (t_0 - 0.5))), sqrt(((t_0 - -0.5) - t_1))) * (R + R);
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = cos(phi1) * 0.5d0
t_1 = (0.5d0 - (cos((lambda2 - lambda1)) * 0.5d0)) * cos(phi1)
code = atan2(sqrt((t_1 - (t_0 - 0.5d0))), sqrt(((t_0 - (-0.5d0)) - t_1))) * (r + r)
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * 0.5;
double t_1 = (0.5 - (Math.cos((lambda2 - lambda1)) * 0.5)) * Math.cos(phi1);
return Math.atan2(Math.sqrt((t_1 - (t_0 - 0.5))), Math.sqrt(((t_0 - -0.5) - t_1))) * (R + R);
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * 0.5 t_1 = (0.5 - (math.cos((lambda2 - lambda1)) * 0.5)) * math.cos(phi1) return math.atan2(math.sqrt((t_1 - (t_0 - 0.5))), math.sqrt(((t_0 - -0.5) - t_1))) * (R + R)
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * 0.5) t_1 = Float64(Float64(0.5 - Float64(cos(Float64(lambda2 - lambda1)) * 0.5)) * cos(phi1)) return Float64(atan(sqrt(Float64(t_1 - Float64(t_0 - 0.5))), sqrt(Float64(Float64(t_0 - -0.5) - t_1))) * Float64(R + R)) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * 0.5; t_1 = (0.5 - (cos((lambda2 - lambda1)) * 0.5)) * cos(phi1); tmp = atan2(sqrt((t_1 - (t_0 - 0.5))), sqrt(((t_0 - -0.5) - t_1))) * (R + R); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, N[(N[ArcTan[N[Sqrt[N[(t$95$1 - N[(t$95$0 - 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(t$95$0 - -0.5), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R + R), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot 0.5\\
t_1 := \left(0.5 - \cos \left(\lambda_2 - \lambda_1\right) \cdot 0.5\right) \cdot \cos \phi_1\\
\tan^{-1}_* \frac{\sqrt{t\_1 - \left(t\_0 - 0.5\right)}}{\sqrt{\left(t\_0 - -0.5\right) - t\_1}} \cdot \left(R + R\right)
\end{array}
Initial program 60.9%
Applied rewrites56.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6447.6%
Applied rewrites47.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6445.6%
Applied rewrites45.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6440.3%
Applied rewrites40.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6442.5%
Applied rewrites42.5%
Applied rewrites42.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (- 0.5 (* 0.5 (cos (- lambda1 lambda2))))))
(t_1 (* 0.5 (cos phi1)))
(t_2 (* (cos phi1) (- 0.5 (* 0.5 (cos lambda1)))))
(t_3
(*
(atan2 (sqrt (+ t_2 (- 0.5 t_1))) (sqrt (- (+ 0.5 t_1) t_2)))
(* 2.0 R))))
(if (<= phi1 -0.0018)
t_3
(if (<= phi1 60000000000.0)
(*
(atan2 (sqrt (+ t_0 (- 0.5 0.5))) (sqrt (- (+ 0.5 0.5) t_0)))
(* 2.0 R))
t_3))))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2))));
double t_1 = 0.5 * cos(phi1);
double t_2 = cos(phi1) * (0.5 - (0.5 * cos(lambda1)));
double t_3 = atan2(sqrt((t_2 + (0.5 - t_1))), sqrt(((0.5 + t_1) - t_2))) * (2.0 * R);
double tmp;
if (phi1 <= -0.0018) {
tmp = t_3;
} else if (phi1 <= 60000000000.0) {
tmp = atan2(sqrt((t_0 + (0.5 - 0.5))), sqrt(((0.5 + 0.5) - t_0))) * (2.0 * R);
} 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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * (0.5d0 - (0.5d0 * cos((lambda1 - lambda2))))
t_1 = 0.5d0 * cos(phi1)
t_2 = cos(phi1) * (0.5d0 - (0.5d0 * cos(lambda1)))
t_3 = atan2(sqrt((t_2 + (0.5d0 - t_1))), sqrt(((0.5d0 + t_1) - t_2))) * (2.0d0 * r)
if (phi1 <= (-0.0018d0)) then
tmp = t_3
else if (phi1 <= 60000000000.0d0) then
tmp = atan2(sqrt((t_0 + (0.5d0 - 0.5d0))), sqrt(((0.5d0 + 0.5d0) - t_0))) * (2.0d0 * r)
else
tmp = t_3
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * (0.5 - (0.5 * Math.cos((lambda1 - lambda2))));
double t_1 = 0.5 * Math.cos(phi1);
double t_2 = Math.cos(phi1) * (0.5 - (0.5 * Math.cos(lambda1)));
double t_3 = Math.atan2(Math.sqrt((t_2 + (0.5 - t_1))), Math.sqrt(((0.5 + t_1) - t_2))) * (2.0 * R);
double tmp;
if (phi1 <= -0.0018) {
tmp = t_3;
} else if (phi1 <= 60000000000.0) {
tmp = Math.atan2(Math.sqrt((t_0 + (0.5 - 0.5))), Math.sqrt(((0.5 + 0.5) - t_0))) * (2.0 * R);
} else {
tmp = t_3;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * (0.5 - (0.5 * math.cos((lambda1 - lambda2)))) t_1 = 0.5 * math.cos(phi1) t_2 = math.cos(phi1) * (0.5 - (0.5 * math.cos(lambda1))) t_3 = math.atan2(math.sqrt((t_2 + (0.5 - t_1))), math.sqrt(((0.5 + t_1) - t_2))) * (2.0 * R) tmp = 0 if phi1 <= -0.0018: tmp = t_3 elif phi1 <= 60000000000.0: tmp = math.atan2(math.sqrt((t_0 + (0.5 - 0.5))), math.sqrt(((0.5 + 0.5) - t_0))) * (2.0 * R) else: tmp = t_3 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))) t_1 = Float64(0.5 * cos(phi1)) t_2 = Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * cos(lambda1)))) t_3 = Float64(atan(sqrt(Float64(t_2 + Float64(0.5 - t_1))), sqrt(Float64(Float64(0.5 + t_1) - t_2))) * Float64(2.0 * R)) tmp = 0.0 if (phi1 <= -0.0018) tmp = t_3; elseif (phi1 <= 60000000000.0) tmp = Float64(atan(sqrt(Float64(t_0 + Float64(0.5 - 0.5))), sqrt(Float64(Float64(0.5 + 0.5) - t_0))) * Float64(2.0 * R)); else tmp = t_3; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2)))); t_1 = 0.5 * cos(phi1); t_2 = cos(phi1) * (0.5 - (0.5 * cos(lambda1))); t_3 = atan2(sqrt((t_2 + (0.5 - t_1))), sqrt(((0.5 + t_1) - t_2))) * (2.0 * R); tmp = 0.0; if (phi1 <= -0.0018) tmp = t_3; elseif (phi1 <= 60000000000.0) tmp = atan2(sqrt((t_0 + (0.5 - 0.5))), sqrt(((0.5 + 0.5) - t_0))) * (2.0 * R); else tmp = t_3; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[ArcTan[N[Sqrt[N[(t$95$2 + N[(0.5 - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.0018], t$95$3, If[LessEqual[phi1, 60000000000.0], N[(N[ArcTan[N[Sqrt[N[(t$95$0 + N[(0.5 - 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + 0.5), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
t_1 := 0.5 \cdot \cos \phi_1\\
t_2 := \cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \cos \lambda_1\right)\\
t_3 := \tan^{-1}_* \frac{\sqrt{t\_2 + \left(0.5 - t\_1\right)}}{\sqrt{\left(0.5 + t\_1\right) - t\_2}} \cdot \left(2 \cdot R\right)\\
\mathbf{if}\;\phi_1 \leq -0.0018:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\phi_1 \leq 60000000000:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_0 + \left(0.5 - 0.5\right)}}{\sqrt{\left(0.5 + 0.5\right) - t\_0}} \cdot \left(2 \cdot R\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
if phi1 < -0.0018 or 6e10 < phi1 Initial program 60.9%
Applied rewrites56.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6447.6%
Applied rewrites47.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6445.6%
Applied rewrites45.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6440.3%
Applied rewrites40.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6442.5%
Applied rewrites42.5%
Taylor expanded in lambda2 around 0
lower-cos.f6431.2%
Applied rewrites31.2%
Taylor expanded in lambda2 around 0
lower-cos.f6431.0%
Applied rewrites31.0%
if -0.0018 < phi1 < 6e10Initial program 60.9%
Applied rewrites56.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6447.6%
Applied rewrites47.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6445.6%
Applied rewrites45.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6440.3%
Applied rewrites40.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6442.5%
Applied rewrites42.5%
Taylor expanded in phi1 around 0
Applied rewrites22.6%
Taylor expanded in phi1 around 0
Applied rewrites22.5%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (let* ((t_0 (* (cos phi1) (- 0.5 (* 0.5 (cos (- lambda1 lambda2))))))) (* (atan2 (sqrt (+ t_0 (- 0.5 0.5))) (sqrt (- (+ 0.5 0.5) t_0))) (* 2.0 R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2))));
return atan2(sqrt((t_0 + (0.5 - 0.5))), sqrt(((0.5 + 0.5) - t_0))) * (2.0 * R);
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = cos(phi1) * (0.5d0 - (0.5d0 * cos((lambda1 - lambda2))))
code = atan2(sqrt((t_0 + (0.5d0 - 0.5d0))), sqrt(((0.5d0 + 0.5d0) - t_0))) * (2.0d0 * r)
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * (0.5 - (0.5 * Math.cos((lambda1 - lambda2))));
return Math.atan2(Math.sqrt((t_0 + (0.5 - 0.5))), Math.sqrt(((0.5 + 0.5) - t_0))) * (2.0 * R);
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * (0.5 - (0.5 * math.cos((lambda1 - lambda2)))) return math.atan2(math.sqrt((t_0 + (0.5 - 0.5))), math.sqrt(((0.5 + 0.5) - t_0))) * (2.0 * R)
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))) return Float64(atan(sqrt(Float64(t_0 + Float64(0.5 - 0.5))), sqrt(Float64(Float64(0.5 + 0.5) - t_0))) * Float64(2.0 * R)) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * (0.5 - (0.5 * cos((lambda1 - lambda2)))); tmp = atan2(sqrt((t_0 + (0.5 - 0.5))), sqrt(((0.5 + 0.5) - t_0))) * (2.0 * R); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[ArcTan[N[Sqrt[N[(t$95$0 + N[(0.5 - 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(0.5 + 0.5), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\tan^{-1}_* \frac{\sqrt{t\_0 + \left(0.5 - 0.5\right)}}{\sqrt{\left(0.5 + 0.5\right) - t\_0}} \cdot \left(2 \cdot R\right)
\end{array}
Initial program 60.9%
Applied rewrites56.0%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6447.6%
Applied rewrites47.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6445.6%
Applied rewrites45.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6440.3%
Applied rewrites40.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f6442.5%
Applied rewrites42.5%
Taylor expanded in phi1 around 0
Applied rewrites22.6%
Taylor expanded in phi1 around 0
Applied rewrites22.5%
herbie shell --seed 2025258
(FPCore (R lambda1 lambda2 phi1 phi2)
:name "Distance on a great circle"
:precision binary64
(* R (* 2.0 (atan2 (sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0))) (sin (/ (- lambda1 lambda2) 2.0))))) (sqrt (- 1.0 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0))) (sin (/ (- lambda1 lambda2) 2.0))))))))))