
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Herbie found 33 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (cos lambda2)))
(t_1 (* (sin lambda1) (sin lambda2))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(/
(fma (pow (cos lambda1) 3.0) (pow (cos lambda2) 3.0) (pow t_1 3.0))
(fma t_0 t_0 (- (* t_1 t_1) (* t_0 t_1)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * cos(lambda2);
double t_1 = sin(lambda1) * sin(lambda2);
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * (fma(pow(cos(lambda1), 3.0), pow(cos(lambda2), 3.0), pow(t_1, 3.0)) / fma(t_0, t_0, ((t_1 * t_1) - (t_0 * t_1)))))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * cos(lambda2)) t_1 = Float64(sin(lambda1) * sin(lambda2)) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * Float64(fma((cos(lambda1) ^ 3.0), (cos(lambda2) ^ 3.0), (t_1 ^ 3.0)) / fma(t_0, t_0, Float64(Float64(t_1 * t_1) - Float64(t_0 * t_1))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Power[N[Cos[lambda1], $MachinePrecision], 3.0], $MachinePrecision] * N[Power[N[Cos[lambda2], $MachinePrecision], 3.0], $MachinePrecision] + N[Power[t$95$1, 3.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * t$95$0 + N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \cos \lambda_2\\
t_1 := \sin \lambda_1 \cdot \sin \lambda_2\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \frac{\mathsf{fma}\left({\cos \lambda_1}^{3}, {\cos \lambda_2}^{3}, {t\_1}^{3}\right)}{\mathsf{fma}\left(t\_0, t\_0, t\_1 \cdot t\_1 - t\_0 \cdot t\_1\right)}}
\end{array}
\end{array}
Initial program 79.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.6
Applied rewrites89.6%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip3-+N/A
lower-/.f64N/A
Applied rewrites99.7%
lift-+.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
unpow-prod-downN/A
lift-pow.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
lower-pow.f64N/A
lift-cos.f64N/A
lower-pow.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-pow.f6499.7
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (cos lambda2)))
(t_1 (* (sin lambda1) (sin lambda2))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(/
(+ (pow t_0 3.0) (pow t_1 3.0))
(fma t_0 t_0 (- (* t_1 t_1) (* t_0 t_1)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * cos(lambda2);
double t_1 = sin(lambda1) * sin(lambda2);
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * ((pow(t_0, 3.0) + pow(t_1, 3.0)) / fma(t_0, t_0, ((t_1 * t_1) - (t_0 * t_1)))))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * cos(lambda2)) t_1 = Float64(sin(lambda1) * sin(lambda2)) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * Float64(Float64((t_0 ^ 3.0) + (t_1 ^ 3.0)) / fma(t_0, t_0, Float64(Float64(t_1 * t_1) - Float64(t_0 * t_1))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Power[t$95$0, 3.0], $MachinePrecision] + N[Power[t$95$1, 3.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * t$95$0 + N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \cos \lambda_2\\
t_1 := \sin \lambda_1 \cdot \sin \lambda_2\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \frac{{t\_0}^{3} + {t\_1}^{3}}{\mathsf{fma}\left(t\_0, t\_0, t\_1 \cdot t\_1 - t\_0 \cdot t\_1\right)}}
\end{array}
\end{array}
Initial program 79.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.6
Applied rewrites89.6%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip3-+N/A
lower-/.f64N/A
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 79.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.6
Applied rewrites89.6%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin phi1) (cos phi2)))
(t_2
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* t_1 (cos lambda2))))))
(if (<= lambda2 -1.8e-5)
t_2
(if (<= lambda2 0.00018)
(atan2
(* (fma (- lambda2) (cos lambda1) (sin lambda1)) (cos phi2))
(- t_0 (* t_1 (fma (sin lambda1) lambda2 (cos lambda1)))))
t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin(phi1) * cos(phi2);
double t_2 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))));
double tmp;
if (lambda2 <= -1.8e-5) {
tmp = t_2;
} else if (lambda2 <= 0.00018) {
tmp = atan2((fma(-lambda2, cos(lambda1), sin(lambda1)) * cos(phi2)), (t_0 - (t_1 * fma(sin(lambda1), lambda2, cos(lambda1)))));
} else {
tmp = t_2;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) t_2 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda2)))) tmp = 0.0 if (lambda2 <= -1.8e-5) tmp = t_2; elseif (lambda2 <= 0.00018) tmp = atan(Float64(fma(Float64(-lambda2), cos(lambda1), sin(lambda1)) * cos(phi2)), Float64(t_0 - Float64(t_1 * fma(sin(lambda1), lambda2, cos(lambda1))))); else tmp = t_2; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -1.8e-5], t$95$2, If[LessEqual[lambda2, 0.00018], N[ArcTan[N[(N[((-lambda2) * N[Cos[lambda1], $MachinePrecision] + N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[Sin[lambda1], $MachinePrecision] * lambda2 + N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
t_2 := \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\mathbf{if}\;\lambda_2 \leq -1.8 \cdot 10^{-5}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_2 \leq 0.00018:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(-\lambda_2, \cos \lambda_1, \sin \lambda_1\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \mathsf{fma}\left(\sin \lambda_1, \lambda_2, \cos \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if lambda2 < -1.80000000000000005e-5 or 1.80000000000000011e-4 < lambda2 Initial program 61.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.1
Applied rewrites80.1%
Taylor expanded in lambda1 around 0
sin-+PI/2-revN/A
cos-neg-revN/A
lift-cos.f6479.9
Applied rewrites79.9%
if -1.80000000000000005e-5 < lambda2 < 1.80000000000000011e-4Initial program 99.5%
Taylor expanded in lambda2 around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6499.5
Applied rewrites99.5%
Taylor expanded in lambda2 around 0
sin-+PI/2-revN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2))) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 79.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.6
Applied rewrites89.6%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6489.6
Applied rewrites89.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 79.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.6
Applied rewrites89.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))
(t_1 (- (* (cos phi1) (sin phi2)) t_0))
(t_2 (* (sin lambda1) (cos lambda2))))
(if (<= phi1 -400000000000.0)
(atan2 (* (- t_2 (sin lambda2)) (cos phi2)) t_1)
(if (<= phi1 24000000.0)
(atan2
(* (- t_2 (* (cos lambda1) (sin lambda2))) (cos phi2))
(- (* (fma (* phi1 phi1) -0.5 1.0) (sin phi2)) t_0))
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2));
double t_1 = (cos(phi1) * sin(phi2)) - t_0;
double t_2 = sin(lambda1) * cos(lambda2);
double tmp;
if (phi1 <= -400000000000.0) {
tmp = atan2(((t_2 - sin(lambda2)) * cos(phi2)), t_1);
} else if (phi1 <= 24000000.0) {
tmp = atan2(((t_2 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((fma((phi1 * phi1), -0.5, 1.0) * sin(phi2)) - t_0));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), t_1);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) t_1 = Float64(Float64(cos(phi1) * sin(phi2)) - t_0) t_2 = Float64(sin(lambda1) * cos(lambda2)) tmp = 0.0 if (phi1 <= -400000000000.0) tmp = atan(Float64(Float64(t_2 - sin(lambda2)) * cos(phi2)), t_1); elseif (phi1 <= 24000000.0) tmp = atan(Float64(Float64(t_2 - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(fma(Float64(phi1 * phi1), -0.5, 1.0) * sin(phi2)) - t_0)); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), t_1); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -400000000000.0], N[ArcTan[N[(N[(t$95$2 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision], If[LessEqual[phi1, 24000000.0], N[ArcTan[N[(N[(t$95$2 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2 - t\_0\\
t_2 := \sin \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -400000000000:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_2 - \sin \lambda_2\right) \cdot \cos \phi_2}{t\_1}\\
\mathbf{elif}\;\phi_1 \leq 24000000:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.5, 1\right) \cdot \sin \phi_2 - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_1}\\
\end{array}
\end{array}
if phi1 < -4e11Initial program 78.1%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.8
Applied rewrites80.8%
Taylor expanded in lambda1 around 0
lift-sin.f6478.9
Applied rewrites78.9%
if -4e11 < phi1 < 2.4e7Initial program 82.2%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.7
Applied rewrites98.7%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6497.6
Applied rewrites97.6%
if 2.4e7 < phi1 Initial program 76.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))
(t_1 (- (* (cos phi1) (sin phi2)) t_0))
(t_2 (* (sin lambda1) (cos lambda2))))
(if (<= phi1 -23.5)
(atan2 (* (- t_2 (sin lambda2)) (cos phi2)) t_1)
(if (<= phi1 24000000.0)
(atan2
(* (- t_2 (* (cos lambda1) (sin lambda2))) (cos phi2))
(- (sin phi2) t_0))
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2));
double t_1 = (cos(phi1) * sin(phi2)) - t_0;
double t_2 = sin(lambda1) * cos(lambda2);
double tmp;
if (phi1 <= -23.5) {
tmp = atan2(((t_2 - sin(lambda2)) * cos(phi2)), t_1);
} else if (phi1 <= 24000000.0) {
tmp = atan2(((t_2 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - t_0));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), t_1);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))
t_1 = (cos(phi1) * sin(phi2)) - t_0
t_2 = sin(lambda1) * cos(lambda2)
if (phi1 <= (-23.5d0)) then
tmp = atan2(((t_2 - sin(lambda2)) * cos(phi2)), t_1)
else if (phi1 <= 24000000.0d0) then
tmp = atan2(((t_2 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - t_0))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), t_1)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2));
double t_1 = (Math.cos(phi1) * Math.sin(phi2)) - t_0;
double t_2 = Math.sin(lambda1) * Math.cos(lambda2);
double tmp;
if (phi1 <= -23.5) {
tmp = Math.atan2(((t_2 - Math.sin(lambda2)) * Math.cos(phi2)), t_1);
} else if (phi1 <= 24000000.0) {
tmp = Math.atan2(((t_2 - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - t_0));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), t_1);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = (math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)) t_1 = (math.cos(phi1) * math.sin(phi2)) - t_0 t_2 = math.sin(lambda1) * math.cos(lambda2) tmp = 0 if phi1 <= -23.5: tmp = math.atan2(((t_2 - math.sin(lambda2)) * math.cos(phi2)), t_1) elif phi1 <= 24000000.0: tmp = math.atan2(((t_2 - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - t_0)) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), t_1) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) t_1 = Float64(Float64(cos(phi1) * sin(phi2)) - t_0) t_2 = Float64(sin(lambda1) * cos(lambda2)) tmp = 0.0 if (phi1 <= -23.5) tmp = atan(Float64(Float64(t_2 - sin(lambda2)) * cos(phi2)), t_1); elseif (phi1 <= 24000000.0) tmp = atan(Float64(Float64(t_2 - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - t_0)); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), t_1); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)); t_1 = (cos(phi1) * sin(phi2)) - t_0; t_2 = sin(lambda1) * cos(lambda2); tmp = 0.0; if (phi1 <= -23.5) tmp = atan2(((t_2 - sin(lambda2)) * cos(phi2)), t_1); elseif (phi1 <= 24000000.0) tmp = atan2(((t_2 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - t_0)); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), t_1); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -23.5], N[ArcTan[N[(N[(t$95$2 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision], If[LessEqual[phi1, 24000000.0], N[ArcTan[N[(N[(t$95$2 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2 - t\_0\\
t_2 := \sin \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -23.5:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_2 - \sin \lambda_2\right) \cdot \cos \phi_2}{t\_1}\\
\mathbf{elif}\;\phi_1 \leq 24000000:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_1}\\
\end{array}
\end{array}
if phi1 < -23.5Initial program 78.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.8
Applied rewrites80.8%
Taylor expanded in lambda1 around 0
lift-sin.f6478.9
Applied rewrites78.9%
if -23.5 < phi1 < 2.4e7Initial program 82.3%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.1
Applied rewrites99.1%
Taylor expanded in phi1 around 0
lift-sin.f6498.3
Applied rewrites98.3%
if 2.4e7 < phi1 Initial program 76.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_0)))
(t_2 (* (sin lambda1) (cos lambda2))))
(if (<= phi1 -6.6e-6)
(atan2 (* (- t_2 (sin lambda2)) (cos phi2)) t_1)
(if (<= phi1 0.066)
(atan2
(* (- t_2 (* (cos lambda1) (sin lambda2))) (cos phi2))
(fma (* -1.0 phi1) (* t_0 (cos phi2)) (sin phi2)))
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = (cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0);
double t_2 = sin(lambda1) * cos(lambda2);
double tmp;
if (phi1 <= -6.6e-6) {
tmp = atan2(((t_2 - sin(lambda2)) * cos(phi2)), t_1);
} else if (phi1 <= 0.066) {
tmp = atan2(((t_2 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), fma((-1.0 * phi1), (t_0 * cos(phi2)), sin(phi2)));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), t_1);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0)) t_2 = Float64(sin(lambda1) * cos(lambda2)) tmp = 0.0 if (phi1 <= -6.6e-6) tmp = atan(Float64(Float64(t_2 - sin(lambda2)) * cos(phi2)), t_1); elseif (phi1 <= 0.066) tmp = atan(Float64(Float64(t_2 - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(Float64(-1.0 * phi1), Float64(t_0 * cos(phi2)), sin(phi2))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), t_1); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -6.6e-6], N[ArcTan[N[(N[(t$95$2 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision], If[LessEqual[phi1, 0.066], N[ArcTan[N[(N[(t$95$2 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(-1.0 * phi1), $MachinePrecision] * N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\\
t_2 := \sin \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -6.6 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_2 - \sin \lambda_2\right) \cdot \cos \phi_2}{t\_1}\\
\mathbf{elif}\;\phi_1 \leq 0.066:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-1 \cdot \phi_1, t\_0 \cdot \cos \phi_2, \sin \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_1}\\
\end{array}
\end{array}
if phi1 < -6.60000000000000034e-6Initial program 77.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.7
Applied rewrites80.7%
Taylor expanded in lambda1 around 0
lift-sin.f6478.8
Applied rewrites78.8%
if -6.60000000000000034e-6 < phi1 < 0.066000000000000003Initial program 82.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.6
Applied rewrites99.6%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-sin.f6499.4
Applied rewrites99.4%
if 0.066000000000000003 < phi1 Initial program 76.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_0)))
(t_2 (* (cos lambda1) (sin lambda2))))
(if (<= phi1 -3.3e-6)
(atan2 (* (- (sin lambda1) t_2) (cos phi2)) t_1)
(if (<= phi1 0.066)
(atan2
(* (- (* (sin lambda1) (cos lambda2)) t_2) (cos phi2))
(fma (* -1.0 phi1) (* t_0 (cos phi2)) (sin phi2)))
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = (cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0);
double t_2 = cos(lambda1) * sin(lambda2);
double tmp;
if (phi1 <= -3.3e-6) {
tmp = atan2(((sin(lambda1) - t_2) * cos(phi2)), t_1);
} else if (phi1 <= 0.066) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_2) * cos(phi2)), fma((-1.0 * phi1), (t_0 * cos(phi2)), sin(phi2)));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), t_1);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0)) t_2 = Float64(cos(lambda1) * sin(lambda2)) tmp = 0.0 if (phi1 <= -3.3e-6) tmp = atan(Float64(Float64(sin(lambda1) - t_2) * cos(phi2)), t_1); elseif (phi1 <= 0.066) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - t_2) * cos(phi2)), fma(Float64(-1.0 * phi1), Float64(t_0 * cos(phi2)), sin(phi2))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), t_1); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -3.3e-6], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$2), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision], If[LessEqual[phi1, 0.066], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(-1.0 * phi1), $MachinePrecision] * N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\\
t_2 := \cos \lambda_1 \cdot \sin \lambda_2\\
\mathbf{if}\;\phi_1 \leq -3.3 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_2\right) \cdot \cos \phi_2}{t\_1}\\
\mathbf{elif}\;\phi_1 \leq 0.066:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-1 \cdot \phi_1, t\_0 \cdot \cos \phi_2, \sin \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_1}\\
\end{array}
\end{array}
if phi1 < -3.30000000000000017e-6Initial program 77.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.7
Applied rewrites80.7%
Taylor expanded in lambda2 around 0
lift-sin.f6478.8
Applied rewrites78.8%
if -3.30000000000000017e-6 < phi1 < 0.066000000000000003Initial program 82.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.6
Applied rewrites99.6%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-sin.f6499.4
Applied rewrites99.4%
if 0.066000000000000003 < phi1 Initial program 76.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_0)))))
(if (<= phi1 -6.6e-6)
t_1
(if (<= phi1 0.066)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(fma (* -1.0 phi1) (* t_0 (cos phi2)) (sin phi2)))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)));
double tmp;
if (phi1 <= -6.6e-6) {
tmp = t_1;
} else if (phi1 <= 0.066) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), fma((-1.0 * phi1), (t_0 * cos(phi2)), sin(phi2)));
} else {
tmp = t_1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))) tmp = 0.0 if (phi1 <= -6.6e-6) tmp = t_1; elseif (phi1 <= 0.066) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(Float64(-1.0 * phi1), Float64(t_0 * cos(phi2)), sin(phi2))); else tmp = t_1; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -6.6e-6], t$95$1, If[LessEqual[phi1, 0.066], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(-1.0 * phi1), $MachinePrecision] * N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\
\mathbf{if}\;\phi_1 \leq -6.6 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 0.066:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-1 \cdot \phi_1, t\_0 \cdot \cos \phi_2, \sin \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi1 < -6.60000000000000034e-6 or 0.066000000000000003 < phi1 Initial program 77.3%
if -6.60000000000000034e-6 < phi1 < 0.066000000000000003Initial program 82.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.6
Applied rewrites99.6%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-sin.f6499.4
Applied rewrites99.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
(if (<= phi1 -1.25e-73)
t_0
(if (<= phi1 4.6e-17)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
double tmp;
if (phi1 <= -1.25e-73) {
tmp = t_0;
} else if (phi1 <= 4.6e-17) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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) :: tmp
t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
if (phi1 <= (-1.25d-73)) then
tmp = t_0
else if (phi1 <= 4.6d-17) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
double tmp;
if (phi1 <= -1.25e-73) {
tmp = t_0;
} else if (phi1 <= 4.6e-17) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) tmp = 0 if phi1 <= -1.25e-73: tmp = t_0 elif phi1 <= 4.6e-17: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (phi1 <= -1.25e-73) tmp = t_0; elseif (phi1 <= 4.6e-17) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); tmp = 0.0; if (phi1 <= -1.25e-73) tmp = t_0; elseif (phi1 <= 4.6e-17) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.25e-73], t$95$0, If[LessEqual[phi1, 4.6e-17], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;\phi_1 \leq -1.25 \cdot 10^{-73}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 4.6 \cdot 10^{-17}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi1 < -1.25e-73 or 4.60000000000000018e-17 < phi1 Initial program 77.8%
if -1.25e-73 < phi1 < 4.60000000000000018e-17Initial program 82.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in phi1 around 0
lift-sin.f6498.0
Applied rewrites98.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (<= lambda2 -0.0032)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
(if (<= lambda2 7.6e+28)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* (cos lambda1) (cos phi2)) (sin phi1))))
(atan2
(* (sin (- lambda2)) (cos phi2))
(- t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if (lambda2 <= -0.0032) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else if (lambda2 <= 7.6e+28) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1))));
} else {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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) :: tmp
t_0 = cos(phi1) * sin(phi2)
if (lambda2 <= (-0.0032d0)) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
else if (lambda2 <= 7.6d+28) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1))))
else
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (lambda2 <= -0.0032) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else if (lambda2 <= 7.6e+28) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - ((Math.cos(lambda1) * Math.cos(phi2)) * Math.sin(phi1))));
} else {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if lambda2 <= -0.0032: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) elif lambda2 <= 7.6e+28: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - ((math.cos(lambda1) * math.cos(phi2)) * math.sin(phi1)))) else: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_0 - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda2 <= -0.0032) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); elseif (lambda2 <= 7.6e+28) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(lambda1) * cos(phi2)) * sin(phi1)))); else tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if (lambda2 <= -0.0032) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); elseif (lambda2 <= 7.6e+28) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1)))); else tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -0.0032], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 7.6e+28], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -0.0032:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{elif}\;\lambda_2 \leq 7.6 \cdot 10^{+28}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda2 < -0.00320000000000000015Initial program 61.1%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6479.8
Applied rewrites79.8%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites53.9%
Taylor expanded in phi1 around 0
lift-sin.f6458.2
Applied rewrites58.2%
if -0.00320000000000000015 < lambda2 < 7.5999999999999998e28Initial program 97.7%
Taylor expanded in lambda2 around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-sin.f6496.6
Applied rewrites96.6%
if 7.5999999999999998e28 < lambda2 Initial program 60.0%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6459.7
Applied rewrites59.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_1 (* (cos phi1) (sin phi2))))
(if (<= lambda2 -0.0032)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
(if (<= lambda2 5.2e-5)
(atan2 t_0 (- t_1 (* (* (cos lambda1) (cos phi2)) (sin phi1))))
(atan2 t_0 (- t_1 (* (* (sin phi1) (cos phi2)) (cos lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double t_1 = cos(phi1) * sin(phi2);
double tmp;
if (lambda2 <= -0.0032) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else if (lambda2 <= 5.2e-5) {
tmp = atan2(t_0, (t_1 - ((cos(lambda1) * cos(phi2)) * sin(phi1))));
} else {
tmp = atan2(t_0, (t_1 - ((sin(phi1) * cos(phi2)) * cos(lambda2))));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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) :: tmp
t_0 = sin((lambda1 - lambda2)) * cos(phi2)
t_1 = cos(phi1) * sin(phi2)
if (lambda2 <= (-0.0032d0)) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
else if (lambda2 <= 5.2d-5) then
tmp = atan2(t_0, (t_1 - ((cos(lambda1) * cos(phi2)) * sin(phi1))))
else
tmp = atan2(t_0, (t_1 - ((sin(phi1) * cos(phi2)) * cos(lambda2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (lambda2 <= -0.0032) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else if (lambda2 <= 5.2e-5) {
tmp = Math.atan2(t_0, (t_1 - ((Math.cos(lambda1) * Math.cos(phi2)) * Math.sin(phi1))));
} else {
tmp = Math.atan2(t_0, (t_1 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos(lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * math.cos(phi2) t_1 = math.cos(phi1) * math.sin(phi2) tmp = 0 if lambda2 <= -0.0032: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) elif lambda2 <= 5.2e-5: tmp = math.atan2(t_0, (t_1 - ((math.cos(lambda1) * math.cos(phi2)) * math.sin(phi1)))) else: tmp = math.atan2(t_0, (t_1 - ((math.sin(phi1) * math.cos(phi2)) * math.cos(lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) t_1 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda2 <= -0.0032) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); elseif (lambda2 <= 5.2e-5) tmp = atan(t_0, Float64(t_1 - Float64(Float64(cos(lambda1) * cos(phi2)) * sin(phi1)))); else tmp = atan(t_0, Float64(t_1 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)) * cos(phi2); t_1 = cos(phi1) * sin(phi2); tmp = 0.0; if (lambda2 <= -0.0032) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); elseif (lambda2 <= 5.2e-5) tmp = atan2(t_0, (t_1 - ((cos(lambda1) * cos(phi2)) * sin(phi1)))); else tmp = atan2(t_0, (t_1 - ((sin(phi1) * cos(phi2)) * cos(lambda2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -0.0032], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 5.2e-5], N[ArcTan[t$95$0 / N[(t$95$1 - N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -0.0032:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{elif}\;\lambda_2 \leq 5.2 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{t\_1 - \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2}\\
\end{array}
\end{array}
if lambda2 < -0.00320000000000000015Initial program 61.1%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6479.8
Applied rewrites79.8%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites53.9%
Taylor expanded in phi1 around 0
lift-sin.f6458.2
Applied rewrites58.2%
if -0.00320000000000000015 < lambda2 < 5.19999999999999968e-5Initial program 99.4%
Taylor expanded in lambda2 around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-sin.f6499.3
Applied rewrites99.3%
if 5.19999999999999968e-5 < lambda2 Initial program 60.7%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6460.6
Applied rewrites60.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))))
(if (<= lambda2 -0.0032)
t_0
(if (<= lambda2 0.082)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (cos lambda1) (cos phi2)) (sin phi1))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
double tmp;
if (lambda2 <= -0.0032) {
tmp = t_0;
} else if (lambda2 <= 0.082) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(lambda1) * cos(phi2)) * sin(phi1))));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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) :: tmp
t_0 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
if (lambda2 <= (-0.0032d0)) then
tmp = t_0
else if (lambda2 <= 0.082d0) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(lambda1) * cos(phi2)) * sin(phi1))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
double tmp;
if (lambda2 <= -0.0032) {
tmp = t_0;
} else if (lambda2 <= 0.082) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(lambda1) * Math.cos(phi2)) * Math.sin(phi1))));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) tmp = 0 if lambda2 <= -0.0032: tmp = t_0 elif lambda2 <= 0.082: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(lambda1) * math.cos(phi2)) * math.sin(phi1)))) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)) tmp = 0.0 if (lambda2 <= -0.0032) tmp = t_0; elseif (lambda2 <= 0.082) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(lambda1) * cos(phi2)) * sin(phi1)))); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); tmp = 0.0; if (lambda2 <= -0.0032) tmp = t_0; elseif (lambda2 <= 0.082) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(lambda1) * cos(phi2)) * sin(phi1)))); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -0.0032], t$95$0, If[LessEqual[lambda2, 0.082], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\lambda_2 \leq -0.0032:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_2 \leq 0.082:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda2 < -0.00320000000000000015 or 0.0820000000000000034 < lambda2 Initial program 60.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.0
Applied rewrites80.0%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites54.9%
Taylor expanded in phi1 around 0
lift-sin.f6459.2
Applied rewrites59.2%
if -0.00320000000000000015 < lambda2 < 0.0820000000000000034Initial program 99.3%
Taylor expanded in lambda2 around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-sin.f6499.1
Applied rewrites99.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= phi1 -1.25e-73)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (sin phi1) t_1)))
(if (<= phi1 0.066)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* (* (sin phi1) (cos phi2)) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.25e-73) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (sin(phi1) * t_1)));
} else if (phi1 <= 0.066) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * t_1)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
if (phi1 <= (-1.25d-73)) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (sin(phi1) * t_1)))
else if (phi1 <= 0.066d0) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
else
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * t_1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.25e-73) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - (Math.sin(phi1) * t_1)));
} else if (phi1 <= 0.066) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) tmp = 0 if phi1 <= -1.25e-73: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - (math.sin(phi1) * t_1))) elif phi1 <= 0.066: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - ((math.sin(phi1) * math.cos(phi2)) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -1.25e-73) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(sin(phi1) * t_1))); elseif (phi1 <= 0.066) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -1.25e-73) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (sin(phi1) * t_1))); elseif (phi1 <= 0.066) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * t_1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.25e-73], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 0.066], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.25 \cdot 10^{-73}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \sin \phi_1 \cdot t\_1}\\
\mathbf{elif}\;\phi_1 \leq 0.066:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_1}\\
\end{array}
\end{array}
if phi1 < -1.25e-73Initial program 78.8%
Taylor expanded in phi2 around 0
lift-sin.f6456.7
Applied rewrites56.7%
if -1.25e-73 < phi1 < 0.066000000000000003Initial program 82.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.6
Applied rewrites99.6%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.5%
Taylor expanded in phi1 around 0
lift-sin.f6497.2
Applied rewrites97.2%
if 0.066000000000000003 < phi1 Initial program 76.6%
Taylor expanded in lambda1 around inf
Applied rewrites45.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (sin phi1) (cos (- lambda1 lambda2)))))))
(if (<= phi1 -1.25e-73)
t_0
(if (<= phi1 0.066)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))));
double tmp;
if (phi1 <= -1.25e-73) {
tmp = t_0;
} else if (phi1 <= 0.066) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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) :: tmp
t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))))
if (phi1 <= (-1.25d-73)) then
tmp = t_0
else if (phi1 <= 0.066d0) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
double tmp;
if (phi1 <= -1.25e-73) {
tmp = t_0;
} else if (phi1 <= 0.066) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) tmp = 0 if phi1 <= -1.25e-73: tmp = t_0 elif phi1 <= 0.066: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (phi1 <= -1.25e-73) tmp = t_0; elseif (phi1 <= 0.066) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2))))); tmp = 0.0; if (phi1 <= -1.25e-73) tmp = t_0; elseif (phi1 <= 0.066) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.25e-73], t$95$0, If[LessEqual[phi1, 0.066], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;\phi_1 \leq -1.25 \cdot 10^{-73}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 0.066:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi1 < -1.25e-73 or 0.066000000000000003 < phi1 Initial program 77.8%
Taylor expanded in phi2 around 0
lift-sin.f6453.5
Applied rewrites53.5%
if -1.25e-73 < phi1 < 0.066000000000000003Initial program 82.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.6
Applied rewrites99.6%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.5%
Taylor expanded in phi1 around 0
lift-sin.f6497.2
Applied rewrites97.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(sin phi2)
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
(if (<= phi1 -1.25e-73)
t_0
(if (<= phi1 4.6e-17)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
double tmp;
if (phi1 <= -1.25e-73) {
tmp = t_0;
} else if (phi1 <= 4.6e-17) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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) :: tmp
t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
if (phi1 <= (-1.25d-73)) then
tmp = t_0
else if (phi1 <= 4.6d-17) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (Math.sin(phi2) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
double tmp;
if (phi1 <= -1.25e-73) {
tmp = t_0;
} else if (phi1 <= 4.6e-17) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) tmp = 0 if phi1 <= -1.25e-73: tmp = t_0 elif phi1 <= 4.6e-17: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (phi1 <= -1.25e-73) tmp = t_0; elseif (phi1 <= 4.6e-17) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); tmp = 0.0; if (phi1 <= -1.25e-73) tmp = t_0; elseif (phi1 <= 4.6e-17) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.25e-73], t$95$0, If[LessEqual[phi1, 4.6e-17], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;\phi_1 \leq -1.25 \cdot 10^{-73}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 4.6 \cdot 10^{-17}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi1 < -1.25e-73 or 4.60000000000000018e-17 < phi1 Initial program 77.8%
Taylor expanded in phi1 around 0
lift-sin.f6452.9
Applied rewrites52.9%
if -1.25e-73 < phi1 < 4.60000000000000018e-17Initial program 82.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in phi1 around 0
lift-sin.f6498.0
Applied rewrites98.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (* (cos (- lambda1 lambda2)) (sin phi1))))))
(if (<= phi1 -2.6e-20)
t_0
(if (<= phi1 0.066)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), -(cos((lambda1 - lambda2)) * sin(phi1)));
double tmp;
if (phi1 <= -2.6e-20) {
tmp = t_0;
} else if (phi1 <= 0.066) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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) :: tmp
t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), -(cos((lambda1 - lambda2)) * sin(phi1)))
if (phi1 <= (-2.6d-20)) then
tmp = t_0
else if (phi1 <= 0.066d0) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), -(Math.cos((lambda1 - lambda2)) * Math.sin(phi1)));
double tmp;
if (phi1 <= -2.6e-20) {
tmp = t_0;
} else if (phi1 <= 0.066) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), -(math.cos((lambda1 - lambda2)) * math.sin(phi1))) tmp = 0 if phi1 <= -2.6e-20: tmp = t_0 elif phi1 <= 0.066: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(-Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))) tmp = 0.0 if (phi1 <= -2.6e-20) tmp = t_0; elseif (phi1 <= 0.066) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), -(cos((lambda1 - lambda2)) * sin(phi1))); tmp = 0.0; if (phi1 <= -2.6e-20) tmp = t_0; elseif (phi1 <= 0.066) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / (-N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision])], $MachinePrecision]}, If[LessEqual[phi1, -2.6e-20], t$95$0, If[LessEqual[phi1, 0.066], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{-\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{if}\;\phi_1 \leq -2.6 \cdot 10^{-20}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 0.066:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi1 < -2.59999999999999995e-20 or 0.066000000000000003 < phi1 Initial program 77.4%
Taylor expanded in phi2 around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6448.0
Applied rewrites48.0%
if -2.59999999999999995e-20 < phi1 < 0.066000000000000003Initial program 82.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.6
Applied rewrites99.6%
Taylor expanded in phi1 around 0
sin-+PI/2-revN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.6%
Taylor expanded in phi1 around 0
lift-sin.f6496.9
Applied rewrites96.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_2 (atan2 t_1 (- (* t_0 (sin phi1))))))
(if (<= phi1 -5e-5)
t_2
(if (<= phi1 0.066)
(atan2 t_1 (fma (* -1.0 phi1) (* t_0 (cos phi2)) (sin phi2)))
t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double t_2 = atan2(t_1, -(t_0 * sin(phi1)));
double tmp;
if (phi1 <= -5e-5) {
tmp = t_2;
} else if (phi1 <= 0.066) {
tmp = atan2(t_1, fma((-1.0 * phi1), (t_0 * cos(phi2)), sin(phi2)));
} else {
tmp = t_2;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) t_2 = atan(t_1, Float64(-Float64(t_0 * sin(phi1)))) tmp = 0.0 if (phi1 <= -5e-5) tmp = t_2; elseif (phi1 <= 0.066) tmp = atan(t_1, fma(Float64(-1.0 * phi1), Float64(t_0 * cos(phi2)), sin(phi2))); else tmp = t_2; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[t$95$1 / (-N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision])], $MachinePrecision]}, If[LessEqual[phi1, -5e-5], t$95$2, If[LessEqual[phi1, 0.066], N[ArcTan[t$95$1 / N[(N[(-1.0 * phi1), $MachinePrecision] * N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \tan^{-1}_* \frac{t\_1}{-t\_0 \cdot \sin \phi_1}\\
\mathbf{if}\;\phi_1 \leq -5 \cdot 10^{-5}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 0.066:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(-1 \cdot \phi_1, t\_0 \cdot \cos \phi_2, \sin \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if phi1 < -5.00000000000000024e-5 or 0.066000000000000003 < phi1 Initial program 77.3%
Taylor expanded in phi2 around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6448.0
Applied rewrites48.0%
if -5.00000000000000024e-5 < phi1 < 0.066000000000000003Initial program 82.5%
Taylor expanded in phi1 around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-sin.f6482.4
Applied rewrites82.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (atan2 (* t_0 (cos phi2)) (sin phi2))))
(if (<= phi2 -0.029)
t_1
(if (<= phi2 55000.0)
(atan2
(* t_0 1.0)
(- (* phi2 (cos phi1)) (* (cos (- lambda1 lambda2)) (sin phi1))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = atan2((t_0 * cos(phi2)), sin(phi2));
double tmp;
if (phi2 <= -0.029) {
tmp = t_1;
} else if (phi2 <= 55000.0) {
tmp = atan2((t_0 * 1.0), ((phi2 * cos(phi1)) - (cos((lambda1 - lambda2)) * sin(phi1))));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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) :: tmp
t_0 = sin((lambda1 - lambda2))
t_1 = atan2((t_0 * cos(phi2)), sin(phi2))
if (phi2 <= (-0.029d0)) then
tmp = t_1
else if (phi2 <= 55000.0d0) then
tmp = atan2((t_0 * 1.0d0), ((phi2 * cos(phi1)) - (cos((lambda1 - lambda2)) * sin(phi1))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double t_1 = Math.atan2((t_0 * Math.cos(phi2)), Math.sin(phi2));
double tmp;
if (phi2 <= -0.029) {
tmp = t_1;
} else if (phi2 <= 55000.0) {
tmp = Math.atan2((t_0 * 1.0), ((phi2 * Math.cos(phi1)) - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = math.atan2((t_0 * math.cos(phi2)), math.sin(phi2)) tmp = 0 if phi2 <= -0.029: tmp = t_1 elif phi2 <= 55000.0: tmp = math.atan2((t_0 * 1.0), ((phi2 * math.cos(phi1)) - (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = atan(Float64(t_0 * cos(phi2)), sin(phi2)) tmp = 0.0 if (phi2 <= -0.029) tmp = t_1; elseif (phi2 <= 55000.0) tmp = atan(Float64(t_0 * 1.0), Float64(Float64(phi2 * cos(phi1)) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = atan2((t_0 * cos(phi2)), sin(phi2)); tmp = 0.0; if (phi2 <= -0.029) tmp = t_1; elseif (phi2 <= 55000.0) tmp = atan2((t_0 * 1.0), ((phi2 * cos(phi1)) - (cos((lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.029], t$95$1, If[LessEqual[phi2, 55000.0], N[ArcTan[N[(t$95$0 * 1.0), $MachinePrecision] / N[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\phi_2 \leq -0.029:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 55000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot 1}{\phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -0.0290000000000000015 or 55000 < phi2 Initial program 77.6%
Taylor expanded in phi1 around 0
lift-sin.f6448.5
Applied rewrites48.5%
if -0.0290000000000000015 < phi2 < 55000Initial program 82.1%
Taylor expanded in phi1 around 0
lift-sin.f6448.9
Applied rewrites48.9%
Taylor expanded in phi2 around 0
Applied rewrites48.4%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lower--.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6481.1
Applied rewrites81.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_1 (atan2 t_0 (- (* (cos (- lambda1 lambda2)) (sin phi1))))))
(if (<= phi1 -2.6e-20)
t_1
(if (<= phi1 0.066) (atan2 t_0 (sin phi2)) t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double t_1 = atan2(t_0, -(cos((lambda1 - lambda2)) * sin(phi1)));
double tmp;
if (phi1 <= -2.6e-20) {
tmp = t_1;
} else if (phi1 <= 0.066) {
tmp = atan2(t_0, sin(phi2));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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) :: tmp
t_0 = sin((lambda1 - lambda2)) * cos(phi2)
t_1 = atan2(t_0, -(cos((lambda1 - lambda2)) * sin(phi1)))
if (phi1 <= (-2.6d-20)) then
tmp = t_1
else if (phi1 <= 0.066d0) then
tmp = atan2(t_0, sin(phi2))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double t_1 = Math.atan2(t_0, -(Math.cos((lambda1 - lambda2)) * Math.sin(phi1)));
double tmp;
if (phi1 <= -2.6e-20) {
tmp = t_1;
} else if (phi1 <= 0.066) {
tmp = Math.atan2(t_0, Math.sin(phi2));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * math.cos(phi2) t_1 = math.atan2(t_0, -(math.cos((lambda1 - lambda2)) * math.sin(phi1))) tmp = 0 if phi1 <= -2.6e-20: tmp = t_1 elif phi1 <= 0.066: tmp = math.atan2(t_0, math.sin(phi2)) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) t_1 = atan(t_0, Float64(-Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))) tmp = 0.0 if (phi1 <= -2.6e-20) tmp = t_1; elseif (phi1 <= 0.066) tmp = atan(t_0, sin(phi2)); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)) * cos(phi2); t_1 = atan2(t_0, -(cos((lambda1 - lambda2)) * sin(phi1))); tmp = 0.0; if (phi1 <= -2.6e-20) tmp = t_1; elseif (phi1 <= 0.066) tmp = atan2(t_0, sin(phi2)); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[t$95$0 / (-N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision])], $MachinePrecision]}, If[LessEqual[phi1, -2.6e-20], t$95$1, If[LessEqual[phi1, 0.066], N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
t_1 := \tan^{-1}_* \frac{t\_0}{-\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{if}\;\phi_1 \leq -2.6 \cdot 10^{-20}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 0.066:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi1 < -2.59999999999999995e-20 or 0.066000000000000003 < phi1 Initial program 77.4%
Taylor expanded in phi2 around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6448.0
Applied rewrites48.0%
if -2.59999999999999995e-20 < phi1 < 0.066000000000000003Initial program 82.5%
Taylor expanded in phi1 around 0
lift-sin.f6479.7
Applied rewrites79.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (atan2 (* t_0 (cos phi2)) (sin phi2))))
(if (<= phi2 -1.7e-14)
t_1
(if (<= phi2 7.2e-16)
(atan2 (* t_0 1.0) (* -1.0 (* (cos (- lambda1 lambda2)) (sin phi1))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = atan2((t_0 * cos(phi2)), sin(phi2));
double tmp;
if (phi2 <= -1.7e-14) {
tmp = t_1;
} else if (phi2 <= 7.2e-16) {
tmp = atan2((t_0 * 1.0), (-1.0 * (cos((lambda1 - lambda2)) * sin(phi1))));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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) :: tmp
t_0 = sin((lambda1 - lambda2))
t_1 = atan2((t_0 * cos(phi2)), sin(phi2))
if (phi2 <= (-1.7d-14)) then
tmp = t_1
else if (phi2 <= 7.2d-16) then
tmp = atan2((t_0 * 1.0d0), ((-1.0d0) * (cos((lambda1 - lambda2)) * sin(phi1))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double t_1 = Math.atan2((t_0 * Math.cos(phi2)), Math.sin(phi2));
double tmp;
if (phi2 <= -1.7e-14) {
tmp = t_1;
} else if (phi2 <= 7.2e-16) {
tmp = Math.atan2((t_0 * 1.0), (-1.0 * (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = math.atan2((t_0 * math.cos(phi2)), math.sin(phi2)) tmp = 0 if phi2 <= -1.7e-14: tmp = t_1 elif phi2 <= 7.2e-16: tmp = math.atan2((t_0 * 1.0), (-1.0 * (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = atan(Float64(t_0 * cos(phi2)), sin(phi2)) tmp = 0.0 if (phi2 <= -1.7e-14) tmp = t_1; elseif (phi2 <= 7.2e-16) tmp = atan(Float64(t_0 * 1.0), Float64(-1.0 * Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = atan2((t_0 * cos(phi2)), sin(phi2)); tmp = 0.0; if (phi2 <= -1.7e-14) tmp = t_1; elseif (phi2 <= 7.2e-16) tmp = atan2((t_0 * 1.0), (-1.0 * (cos((lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -1.7e-14], t$95$1, If[LessEqual[phi2, 7.2e-16], N[ArcTan[N[(t$95$0 * 1.0), $MachinePrecision] / N[(-1.0 * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\phi_2 \leq -1.7 \cdot 10^{-14}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 7.2 \cdot 10^{-16}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot 1}{-1 \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -1.70000000000000001e-14 or 7.19999999999999965e-16 < phi2 Initial program 77.8%
Taylor expanded in phi1 around 0
lift-sin.f6448.7
Applied rewrites48.7%
if -1.70000000000000001e-14 < phi2 < 7.19999999999999965e-16Initial program 82.1%
Taylor expanded in phi1 around 0
lift-sin.f6448.7
Applied rewrites48.7%
Taylor expanded in phi2 around 0
Applied rewrites48.7%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6479.9
Applied rewrites79.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (atan2 (* (sin (- lambda2)) (cos phi2)) (sin phi2))))
(if (<= lambda2 -3.25e-24)
t_0
(if (<= lambda2 7.5e-82)
(atan2 (* (sin lambda1) (cos phi2)) (sin phi2))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin(-lambda2) * cos(phi2)), sin(phi2));
double tmp;
if (lambda2 <= -3.25e-24) {
tmp = t_0;
} else if (lambda2 <= 7.5e-82) {
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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) :: tmp
t_0 = atan2((sin(-lambda2) * cos(phi2)), sin(phi2))
if (lambda2 <= (-3.25d-24)) then
tmp = t_0
else if (lambda2 <= 7.5d-82) then
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), Math.sin(phi2));
double tmp;
if (lambda2 <= -3.25e-24) {
tmp = t_0;
} else if (lambda2 <= 7.5e-82) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((math.sin(-lambda2) * math.cos(phi2)), math.sin(phi2)) tmp = 0 if lambda2 <= -3.25e-24: tmp = t_0 elif lambda2 <= 7.5e-82: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), math.sin(phi2)) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), sin(phi2)) tmp = 0.0 if (lambda2 <= -3.25e-24) tmp = t_0; elseif (lambda2 <= 7.5e-82) tmp = atan(Float64(sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((sin(-lambda2) * cos(phi2)), sin(phi2)); tmp = 0.0; if (lambda2 <= -3.25e-24) tmp = t_0; elseif (lambda2 <= 7.5e-82) tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -3.25e-24], t$95$0, If[LessEqual[lambda2, 7.5e-82], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\lambda_2 \leq -3.25 \cdot 10^{-24}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_2 \leq 7.5 \cdot 10^{-82}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda2 < -3.25e-24 or 7.4999999999999997e-82 < lambda2 Initial program 65.7%
Taylor expanded in phi1 around 0
lift-sin.f6442.9
Applied rewrites42.9%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lift-neg.f6439.8
Applied rewrites39.8%
if -3.25e-24 < lambda2 < 7.4999999999999997e-82Initial program 99.7%
Taylor expanded in phi1 around 0
lift-sin.f6456.9
Applied rewrites56.9%
Taylor expanded in lambda1 around inf
Applied rewrites48.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -3.0)
(atan2 (* (sin lambda1) (cos phi2)) (sin phi2))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(*
(fma
(-
(*
(fma (* phi2 phi2) -0.0001984126984126984 0.008333333333333333)
(* phi2 phi2))
0.16666666666666666)
(* phi2 phi2)
1.0)
phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -3.0) {
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (fma(((fma((phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * (phi2 * phi2)) - 0.16666666666666666), (phi2 * phi2), 1.0) * phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -3.0) tmp = atan(Float64(sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(fma(Float64(Float64(fma(Float64(phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * Float64(phi2 * phi2)) - 0.16666666666666666), Float64(phi2 * phi2), 1.0) * phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -3.0], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -3:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.0001984126984126984, 0.008333333333333333\right) \cdot \left(\phi_2 \cdot \phi_2\right) - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2}\\
\end{array}
\end{array}
if phi2 < -3Initial program 77.8%
Taylor expanded in phi1 around 0
lift-sin.f6449.2
Applied rewrites49.2%
Taylor expanded in lambda1 around inf
Applied rewrites29.4%
if -3 < phi2 Initial program 80.5%
Taylor expanded in phi1 around 0
lift-sin.f6448.5
Applied rewrites48.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites40.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), Math.sin(phi2));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), math.sin(phi2))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), sin(phi2)) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}
\end{array}
Initial program 79.8%
Taylor expanded in phi1 around 0
lift-sin.f6448.7
Applied rewrites48.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 -3.1)
(atan2 t_0 phi2)
(atan2
t_0
(*
(fma
(-
(*
(fma (* phi2 phi2) -0.0001984126984126984 0.008333333333333333)
(* phi2 phi2))
0.16666666666666666)
(* phi2 phi2)
1.0)
phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi2 <= -3.1) {
tmp = atan2(t_0, phi2);
} else {
tmp = atan2(t_0, (fma(((fma((phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * (phi2 * phi2)) - 0.16666666666666666), (phi2 * phi2), 1.0) * phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi2 <= -3.1) tmp = atan(t_0, phi2); else tmp = atan(t_0, Float64(fma(Float64(Float64(fma(Float64(phi2 * phi2), -0.0001984126984126984, 0.008333333333333333) * Float64(phi2 * phi2)) - 0.16666666666666666), Float64(phi2 * phi2), 1.0) * phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -3.1], N[ArcTan[t$95$0 / phi2], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(N[(N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.0001984126984126984 + 0.008333333333333333), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -3.1:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.0001984126984126984, 0.008333333333333333\right) \cdot \left(\phi_2 \cdot \phi_2\right) - 0.16666666666666666, \phi_2 \cdot \phi_2, 1\right) \cdot \phi_2}\\
\end{array}
\end{array}
if phi2 < -3.10000000000000009Initial program 77.8%
Taylor expanded in phi1 around 0
lift-sin.f6449.2
Applied rewrites49.2%
Taylor expanded in phi2 around 0
Applied rewrites25.9%
if -3.10000000000000009 < phi2 Initial program 80.5%
Taylor expanded in phi1 around 0
lift-sin.f6448.5
Applied rewrites48.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites40.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 27000000.0)
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) phi2)
(atan2
(* (+ lambda1 (* lambda2 (- (* 0.5 (* lambda1 lambda1)) 1.0))) (cos phi2))
(sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 27000000.0) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2);
} else {
tmp = atan2(((lambda1 + (lambda2 * ((0.5 * (lambda1 * lambda1)) - 1.0))) * cos(phi2)), sin(phi2));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 27000000.0d0) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2)
else
tmp = atan2(((lambda1 + (lambda2 * ((0.5d0 * (lambda1 * lambda1)) - 1.0d0))) * cos(phi2)), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 27000000.0) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), phi2);
} else {
tmp = Math.atan2(((lambda1 + (lambda2 * ((0.5 * (lambda1 * lambda1)) - 1.0))) * Math.cos(phi2)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 27000000.0: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), phi2) else: tmp = math.atan2(((lambda1 + (lambda2 * ((0.5 * (lambda1 * lambda1)) - 1.0))) * math.cos(phi2)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 27000000.0) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), phi2); else tmp = atan(Float64(Float64(lambda1 + Float64(lambda2 * Float64(Float64(0.5 * Float64(lambda1 * lambda1)) - 1.0))) * cos(phi2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 27000000.0) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2); else tmp = atan2(((lambda1 + (lambda2 * ((0.5 * (lambda1 * lambda1)) - 1.0))) * cos(phi2)), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 27000000.0], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[(lambda1 + N[(lambda2 * N[(N[(0.5 * N[(lambda1 * lambda1), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 27000000:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\lambda_1 + \lambda_2 \cdot \left(0.5 \cdot \left(\lambda_1 \cdot \lambda_1\right) - 1\right)\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < 2.7e7Initial program 80.6%
Taylor expanded in phi1 around 0
lift-sin.f6449.0
Applied rewrites49.0%
Taylor expanded in phi2 around 0
Applied rewrites40.6%
if 2.7e7 < phi2 Initial program 77.4%
Taylor expanded in phi1 around 0
lift-sin.f6447.8
Applied rewrites47.8%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-neg-revN/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-negN/A
lower-neg.f64N/A
lift-sin.f6435.7
Applied rewrites35.7%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6422.9
Applied rewrites22.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 7500000.0) (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) phi2) (atan2 (* lambda1 (cos phi2)) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 7500000.0) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2);
} else {
tmp = atan2((lambda1 * cos(phi2)), sin(phi2));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 7500000.0d0) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2)
else
tmp = atan2((lambda1 * cos(phi2)), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 7500000.0) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), phi2);
} else {
tmp = Math.atan2((lambda1 * Math.cos(phi2)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 7500000.0: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), phi2) else: tmp = math.atan2((lambda1 * math.cos(phi2)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 7500000.0) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), phi2); else tmp = atan(Float64(lambda1 * cos(phi2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 7500000.0) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2); else tmp = atan2((lambda1 * cos(phi2)), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 7500000.0], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(lambda1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 7500000:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < 7.5e6Initial program 80.6%
Taylor expanded in phi1 around 0
lift-sin.f6449.0
Applied rewrites49.0%
Taylor expanded in phi2 around 0
Applied rewrites40.7%
if 7.5e6 < phi2 Initial program 77.4%
Taylor expanded in phi1 around 0
lift-sin.f6447.9
Applied rewrites47.9%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-neg-revN/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-negN/A
lower-neg.f64N/A
lift-sin.f6435.8
Applied rewrites35.8%
Taylor expanded in lambda2 around 0
Applied rewrites16.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -3.05e+16)
(atan2 (* lambda1 (cos phi2)) (sin phi2))
(atan2
(* (sin (- lambda1 lambda2)) 1.0)
(* phi2 (+ 1.0 (* -0.16666666666666666 (* phi2 phi2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -3.05e+16) {
tmp = atan2((lambda1 * cos(phi2)), sin(phi2));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2)))));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= (-3.05d+16)) then
tmp = atan2((lambda1 * cos(phi2)), sin(phi2))
else
tmp = atan2((sin((lambda1 - lambda2)) * 1.0d0), (phi2 * (1.0d0 + ((-0.16666666666666666d0) * (phi2 * phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -3.05e+16) {
tmp = Math.atan2((lambda1 * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * 1.0), (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= -3.05e+16: tmp = math.atan2((lambda1 * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * 1.0), (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -3.05e+16) tmp = atan(Float64(lambda1 * cos(phi2)), sin(phi2)); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), Float64(phi2 * Float64(1.0 + Float64(-0.16666666666666666 * Float64(phi2 * phi2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= -3.05e+16) tmp = atan2((lambda1 * cos(phi2)), sin(phi2)); else tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -3.05e+16], N[ArcTan[N[(lambda1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[(phi2 * N[(1.0 + N[(-0.16666666666666666 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -3.05 \cdot 10^{+16}:\\
\;\;\;\;\tan^{-1}_* \frac{\lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2 \cdot \left(1 + -0.16666666666666666 \cdot \left(\phi_2 \cdot \phi_2\right)\right)}\\
\end{array}
\end{array}
if phi2 < -3.05e16Initial program 77.8%
Taylor expanded in phi1 around 0
lift-sin.f6449.4
Applied rewrites49.4%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-neg-revN/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
sin-negN/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-negN/A
lower-neg.f64N/A
lift-sin.f6437.8
Applied rewrites37.8%
Taylor expanded in lambda2 around 0
Applied rewrites17.7%
if -3.05e16 < phi2 Initial program 80.5%
Taylor expanded in phi1 around 0
lift-sin.f6448.5
Applied rewrites48.5%
Taylor expanded in phi2 around 0
Applied rewrites36.7%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6436.5
Applied rewrites36.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -1.55)
(atan2 (* (sin (* -1.0 lambda2)) 1.0) phi2)
(atan2
(* (sin (- lambda1 lambda2)) 1.0)
(* phi2 (+ 1.0 (* -0.16666666666666666 (* phi2 phi2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -1.55) {
tmp = atan2((sin((-1.0 * lambda2)) * 1.0), phi2);
} else {
tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2)))));
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= (-1.55d0)) then
tmp = atan2((sin(((-1.0d0) * lambda2)) * 1.0d0), phi2)
else
tmp = atan2((sin((lambda1 - lambda2)) * 1.0d0), (phi2 * (1.0d0 + ((-0.16666666666666666d0) * (phi2 * phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -1.55) {
tmp = Math.atan2((Math.sin((-1.0 * lambda2)) * 1.0), phi2);
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * 1.0), (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= -1.55: tmp = math.atan2((math.sin((-1.0 * lambda2)) * 1.0), phi2) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * 1.0), (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -1.55) tmp = atan(Float64(sin(Float64(-1.0 * lambda2)) * 1.0), phi2); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), Float64(phi2 * Float64(1.0 + Float64(-0.16666666666666666 * Float64(phi2 * phi2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= -1.55) tmp = atan2((sin((-1.0 * lambda2)) * 1.0), phi2); else tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -1.55], N[ArcTan[N[(N[Sin[N[(-1.0 * lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[(phi2 * N[(1.0 + N[(-0.16666666666666666 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -1.55:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-1 \cdot \lambda_2\right) \cdot 1}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2 \cdot \left(1 + -0.16666666666666666 \cdot \left(\phi_2 \cdot \phi_2\right)\right)}\\
\end{array}
\end{array}
if phi2 < -1.55000000000000004Initial program 77.8%
Taylor expanded in phi1 around 0
lift-sin.f6449.2
Applied rewrites49.2%
Taylor expanded in phi2 around 0
Applied rewrites15.2%
Taylor expanded in phi2 around 0
Applied rewrites15.0%
Taylor expanded in lambda1 around 0
lower-*.f6414.9
Applied rewrites14.9%
if -1.55000000000000004 < phi2 Initial program 80.5%
Taylor expanded in phi1 around 0
lift-sin.f6448.5
Applied rewrites48.5%
Taylor expanded in phi2 around 0
Applied rewrites37.2%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6437.1
Applied rewrites37.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 -3400.0) (atan2 (* (sin (* -1.0 lambda2)) 1.0) phi2) (atan2 (sin (- lambda1 lambda2)) phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -3400.0) {
tmp = atan2((sin((-1.0 * lambda2)) * 1.0), phi2);
} else {
tmp = atan2(sin((lambda1 - lambda2)), phi2);
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= (-3400.0d0)) then
tmp = atan2((sin(((-1.0d0) * lambda2)) * 1.0d0), phi2)
else
tmp = atan2(sin((lambda1 - lambda2)), phi2)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -3400.0) {
tmp = Math.atan2((Math.sin((-1.0 * lambda2)) * 1.0), phi2);
} else {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), phi2);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= -3400.0: tmp = math.atan2((math.sin((-1.0 * lambda2)) * 1.0), phi2) else: tmp = math.atan2(math.sin((lambda1 - lambda2)), phi2) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -3400.0) tmp = atan(Float64(sin(Float64(-1.0 * lambda2)) * 1.0), phi2); else tmp = atan(sin(Float64(lambda1 - lambda2)), phi2); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= -3400.0) tmp = atan2((sin((-1.0 * lambda2)) * 1.0), phi2); else tmp = atan2(sin((lambda1 - lambda2)), phi2); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -3400.0], N[ArcTan[N[(N[Sin[N[(-1.0 * lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / phi2], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -3400:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-1 \cdot \lambda_2\right) \cdot 1}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2}\\
\end{array}
\end{array}
if phi2 < -3400Initial program 77.7%
Taylor expanded in phi1 around 0
lift-sin.f6449.2
Applied rewrites49.2%
Taylor expanded in phi2 around 0
Applied rewrites15.2%
Taylor expanded in phi2 around 0
Applied rewrites15.0%
Taylor expanded in lambda1 around 0
lower-*.f6414.9
Applied rewrites14.9%
if -3400 < phi2 Initial program 80.6%
Taylor expanded in phi1 around 0
lift-sin.f6448.5
Applied rewrites48.5%
Taylor expanded in phi2 around 0
Applied rewrites37.1%
Taylor expanded in phi2 around 0
Applied rewrites33.7%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6433.7
Applied rewrites33.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) phi2))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), phi2);
}
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(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin((lambda1 - lambda2)), phi2)
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), phi2);
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), phi2)
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), phi2) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), phi2); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / phi2], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2}
\end{array}
Initial program 79.8%
Taylor expanded in phi1 around 0
lift-sin.f6448.7
Applied rewrites48.7%
Taylor expanded in phi2 around 0
Applied rewrites31.4%
Taylor expanded in phi2 around 0
Applied rewrites28.9%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6428.9
Applied rewrites28.9%
herbie shell --seed 2025087
(FPCore (lambda1 lambda2 phi1 phi2)
:name "Bearing on a great circle"
:precision binary64
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))