
(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}
Sampling outcomes in binary64 precision:
Herbie found 51 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 78.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.f6488.2
Applied rewrites88.2%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.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-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.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 78.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.f6488.2
Applied rewrites88.2%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.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-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.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
(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))
(/
(* (cos phi2) (* (sin phi1) (+ (pow t_0 3.0) (pow t_1 3.0))))
(-
(+ (pow t_0 2.0) (pow t_1 2.0))
(* (cos lambda1) (* (cos lambda2) 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)) - ((cos(phi2) * (sin(phi1) * (pow(t_0, 3.0) + pow(t_1, 3.0)))) / ((pow(t_0, 2.0) + pow(t_1, 2.0)) - (cos(lambda1) * (cos(lambda2) * t_1))))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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
t_0 = cos(lambda1) * cos(lambda2)
t_1 = sin(lambda1) * sin(lambda2)
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * (sin(phi1) * ((t_0 ** 3.0d0) + (t_1 ** 3.0d0)))) / (((t_0 ** 2.0d0) + (t_1 ** 2.0d0)) - (cos(lambda1) * (cos(lambda2) * t_1))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(lambda1) * Math.cos(lambda2);
double t_1 = Math.sin(lambda1) * Math.sin(lambda2);
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.cos(phi2) * (Math.sin(phi1) * (Math.pow(t_0, 3.0) + Math.pow(t_1, 3.0)))) / ((Math.pow(t_0, 2.0) + Math.pow(t_1, 2.0)) - (Math.cos(lambda1) * (Math.cos(lambda2) * t_1))))));
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda1) * math.cos(lambda2) t_1 = math.sin(lambda1) * math.sin(lambda2) 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.cos(phi2) * (math.sin(phi1) * (math.pow(t_0, 3.0) + math.pow(t_1, 3.0)))) / ((math.pow(t_0, 2.0) + math.pow(t_1, 2.0)) - (math.cos(lambda1) * (math.cos(lambda2) * 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(cos(phi2) * Float64(sin(phi1) * Float64((t_0 ^ 3.0) + (t_1 ^ 3.0)))) / Float64(Float64((t_0 ^ 2.0) + (t_1 ^ 2.0)) - Float64(cos(lambda1) * Float64(cos(lambda2) * t_1)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) t_0 = cos(lambda1) * cos(lambda2); t_1 = sin(lambda1) * sin(lambda2); tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * (sin(phi1) * ((t_0 ^ 3.0) + (t_1 ^ 3.0)))) / (((t_0 ^ 2.0) + (t_1 ^ 2.0)) - (cos(lambda1) * (cos(lambda2) * 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[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[(N[Power[t$95$0, 3.0], $MachinePrecision] + N[Power[t$95$1, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * t$95$1), $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 - \frac{\cos \phi_2 \cdot \left(\sin \phi_1 \cdot \left({t\_0}^{3} + {t\_1}^{3}\right)\right)}{\left({t\_0}^{2} + {t\_1}^{2}\right) - \cos \lambda_1 \cdot \left(\cos \lambda_2 \cdot t\_1\right)}}
\end{array}
\end{array}
Initial program 78.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.f6488.2
Applied rewrites88.2%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.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-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
flip3-+N/A
lower-/.f64N/A
Applied rewrites99.7%
Taylor expanded in lambda1 around inf
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))
(+ (* (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)) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(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) * cos(lambda2)) + (sin(lambda1) * sin(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) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(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) * math.cos(lambda2)) + (math.sin(lambda1) * math.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)) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(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) * cos(lambda2)) + (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[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $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 \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 78.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.f6488.2
Applied rewrites88.2%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.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
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma (sin lambda1) (sin lambda2) (* (cos lambda1) (cos 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(sin(lambda1), sin(lambda2), (cos(lambda1) * cos(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(sin(lambda1), sin(lambda2), Float64(cos(lambda1) * cos(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[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[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(\sin \lambda_1, \sin \lambda_2, \cos \lambda_1 \cdot \cos \lambda_2\right)}
\end{array}
Initial program 78.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.f6488.2
Applied rewrites88.2%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.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-+.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-*.f6499.7
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 78.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.f6488.2
Applied rewrites88.2%
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
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_1 (* (sin phi1) (cos phi2))))
(if (or (<= phi2 -0.102) (not (<= phi2 0.112)))
(atan2
t_0
(- (* (cos phi1) (sin phi2)) (* t_1 (cos (- lambda1 lambda2)))))
(atan2
t_0
(-
(*
(cos phi1)
(*
phi2
(fma
(* phi2 phi2)
(-
(*
(* phi2 phi2)
(fma -0.0001984126984126984 (* phi2 phi2) 0.008333333333333333))
0.16666666666666666)
1.0)))
(*
t_1
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_1 = sin(phi1) * cos(phi2);
double tmp;
if ((phi2 <= -0.102) || !(phi2 <= 0.112)) {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (t_1 * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_0, ((cos(phi1) * (phi2 * fma((phi2 * phi2), (((phi2 * phi2) * fma(-0.0001984126984126984, (phi2 * phi2), 0.008333333333333333)) - 0.16666666666666666), 1.0))) - (t_1 * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((phi2 <= -0.102) || !(phi2 <= 0.112)) tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_1 * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_0, Float64(Float64(cos(phi1) * Float64(phi2 * fma(Float64(phi2 * phi2), Float64(Float64(Float64(phi2 * phi2) * fma(-0.0001984126984126984, Float64(phi2 * phi2), 0.008333333333333333)) - 0.16666666666666666), 1.0))) - Float64(t_1 * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -0.102], N[Not[LessEqual[phi2, 0.112]], $MachinePrecision]], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(phi2 * N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * N[(-0.0001984126984126984 * N[(phi2 * phi2), $MachinePrecision] + 0.008333333333333333), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.102 \lor \neg \left(\phi_2 \leq 0.112\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \sin \phi_2 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \left(\phi_2 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \left(\phi_2 \cdot \phi_2\right) \cdot \mathsf{fma}\left(-0.0001984126984126984, \phi_2 \cdot \phi_2, 0.008333333333333333\right) - 0.16666666666666666, 1\right)\right) - t\_1 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.101999999999999993 or 0.112000000000000002 < phi2 Initial program 76.6%
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.f6488.0
Applied rewrites88.0%
if -0.101999999999999993 < phi2 < 0.112000000000000002Initial program 80.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.f6488.5
Applied rewrites88.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6499.8
Applied rewrites99.8%
Final simplification94.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))))
(if (or (<= phi2 -26000.0) (not (<= phi2 0.112)))
(atan2
t_1
(- t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(atan2
t_1
(-
t_0
(*
(*
(sin phi1)
(fma
(* phi2 phi2)
(-
(*
(* phi2 phi2)
(fma -0.001388888888888889 (* phi2 phi2) 0.041666666666666664))
0.5)
1.0))
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double tmp;
if ((phi2 <= -26000.0) || !(phi2 <= 0.112)) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * fma((phi2 * phi2), (((phi2 * phi2) * fma(-0.001388888888888889, (phi2 * phi2), 0.041666666666666664)) - 0.5), 1.0)) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) tmp = 0.0 if ((phi2 <= -26000.0) || !(phi2 <= 0.112)) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * fma(Float64(phi2 * phi2), Float64(Float64(Float64(phi2 * phi2) * fma(-0.001388888888888889, Float64(phi2 * phi2), 0.041666666666666664)) - 0.5), 1.0)) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))); 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[(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]}, If[Or[LessEqual[phi2, -26000.0], N[Not[LessEqual[phi2, 0.112]], $MachinePrecision]], N[ArcTan[t$95$1 / 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], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * N[(-0.001388888888888889 * N[(phi2 * phi2), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -26000 \lor \neg \left(\phi_2 \leq 0.112\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \left(\phi_2 \cdot \phi_2\right) \cdot \mathsf{fma}\left(-0.001388888888888889, \phi_2 \cdot \phi_2, 0.041666666666666664\right) - 0.5, 1\right)\right) \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -26000 or 0.112000000000000002 < phi2 Initial program 77.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.f6487.9
Applied rewrites87.9%
if -26000 < phi2 < 0.112000000000000002Initial program 79.7%
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.f6488.6
Applied rewrites88.6%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6499.8
Applied rewrites99.8%
Final simplification94.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(t_2 (* (sin phi1) (cos phi2))))
(if (or (<= phi2 -0.102) (not (<= phi2 0.11)))
(atan2 (* t_1 (cos phi2)) (- t_0 (* t_2 (cos (- lambda1 lambda2)))))
(atan2
(*
t_1
(fma
(* phi2 phi2)
(-
(*
(* phi2 phi2)
(fma -0.001388888888888889 (* phi2 phi2) 0.041666666666666664))
0.5)
1.0))
(-
t_0
(*
t_2
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = (sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2));
double t_2 = sin(phi1) * cos(phi2);
double tmp;
if ((phi2 <= -0.102) || !(phi2 <= 0.11)) {
tmp = atan2((t_1 * cos(phi2)), (t_0 - (t_2 * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((t_1 * fma((phi2 * phi2), (((phi2 * phi2) * fma(-0.001388888888888889, (phi2 * phi2), 0.041666666666666664)) - 0.5), 1.0)), (t_0 - (t_2 * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) t_2 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((phi2 <= -0.102) || !(phi2 <= 0.11)) tmp = atan(Float64(t_1 * cos(phi2)), Float64(t_0 - Float64(t_2 * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(t_1 * fma(Float64(phi2 * phi2), Float64(Float64(Float64(phi2 * phi2) * fma(-0.001388888888888889, Float64(phi2 * phi2), 0.041666666666666664)) - 0.5), 1.0)), Float64(t_0 - Float64(t_2 * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))); 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[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -0.102], N[Not[LessEqual[phi2, 0.11]], $MachinePrecision]], N[ArcTan[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$2 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$1 * N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * N[(-0.001388888888888889 * N[(phi2 * phi2), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$2 * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\\
t_2 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.102 \lor \neg \left(\phi_2 \leq 0.11\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot \cos \phi_2}{t\_0 - t\_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \left(\phi_2 \cdot \phi_2\right) \cdot \mathsf{fma}\left(-0.001388888888888889, \phi_2 \cdot \phi_2, 0.041666666666666664\right) - 0.5, 1\right)}{t\_0 - t\_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.101999999999999993 or 0.110000000000000001 < phi2 Initial program 76.6%
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.f6488.0
Applied rewrites88.0%
if -0.101999999999999993 < phi2 < 0.110000000000000001Initial program 80.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.f6488.5
Applied rewrites88.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6499.8
Applied rewrites99.8%
Final simplification94.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_1 (* (sin phi1) (cos phi2))))
(if (or (<= phi2 -0.07) (not (<= phi2 0.034)))
(atan2
t_0
(- (* (cos phi1) (sin phi2)) (* t_1 (cos (- lambda1 lambda2)))))
(atan2
t_0
(-
(*
(cos phi1)
(*
phi2
(fma
(* phi2 phi2)
(- (* 0.008333333333333333 (* phi2 phi2)) 0.16666666666666666)
1.0)))
(*
t_1
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_1 = sin(phi1) * cos(phi2);
double tmp;
if ((phi2 <= -0.07) || !(phi2 <= 0.034)) {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (t_1 * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_0, ((cos(phi1) * (phi2 * fma((phi2 * phi2), ((0.008333333333333333 * (phi2 * phi2)) - 0.16666666666666666), 1.0))) - (t_1 * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((phi2 <= -0.07) || !(phi2 <= 0.034)) tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_1 * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_0, Float64(Float64(cos(phi1) * Float64(phi2 * fma(Float64(phi2 * phi2), Float64(Float64(0.008333333333333333 * Float64(phi2 * phi2)) - 0.16666666666666666), 1.0))) - Float64(t_1 * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -0.07], N[Not[LessEqual[phi2, 0.034]], $MachinePrecision]], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(phi2 * N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(0.008333333333333333 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.07 \lor \neg \left(\phi_2 \leq 0.034\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \sin \phi_2 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \left(\phi_2 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, 0.008333333333333333 \cdot \left(\phi_2 \cdot \phi_2\right) - 0.16666666666666666, 1\right)\right) - t\_1 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.070000000000000007 or 0.034000000000000002 < phi2 Initial program 76.6%
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.f6488.0
Applied rewrites88.0%
if -0.070000000000000007 < phi2 < 0.034000000000000002Initial program 80.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.f6488.5
Applied rewrites88.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6499.6
Applied rewrites99.6%
Final simplification94.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_1 (* (sin phi1) (cos phi2))))
(if (or (<= phi2 -0.07) (not (<= phi2 0.033)))
(atan2
t_0
(- (* (cos phi1) (sin phi2)) (* t_1 (cos (- lambda1 lambda2)))))
(atan2
t_0
(-
(* (cos phi1) (* phi2 (fma -0.16666666666666666 (* phi2 phi2) 1.0)))
(*
t_1
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_1 = sin(phi1) * cos(phi2);
double tmp;
if ((phi2 <= -0.07) || !(phi2 <= 0.033)) {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (t_1 * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_0, ((cos(phi1) * (phi2 * fma(-0.16666666666666666, (phi2 * phi2), 1.0))) - (t_1 * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((phi2 <= -0.07) || !(phi2 <= 0.033)) tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_1 * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_0, Float64(Float64(cos(phi1) * Float64(phi2 * fma(-0.16666666666666666, Float64(phi2 * phi2), 1.0))) - Float64(t_1 * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -0.07], N[Not[LessEqual[phi2, 0.033]], $MachinePrecision]], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(phi2 * N[(-0.16666666666666666 * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.07 \lor \neg \left(\phi_2 \leq 0.033\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \sin \phi_2 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \left(\phi_2 \cdot \mathsf{fma}\left(-0.16666666666666666, \phi_2 \cdot \phi_2, 1\right)\right) - t\_1 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.070000000000000007 or 0.033000000000000002 < phi2 Initial program 76.6%
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.f6488.0
Applied rewrites88.0%
if -0.070000000000000007 < phi2 < 0.033000000000000002Initial program 80.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.f6488.5
Applied rewrites88.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6499.3
Applied rewrites99.3%
Final simplification94.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(t_2 (* (sin phi1) (cos phi2))))
(if (or (<= phi2 -0.07) (not (<= phi2 0.033)))
(atan2 (* t_1 (cos phi2)) (- t_0 (* t_2 (cos (- lambda1 lambda2)))))
(atan2
(* t_1 (fma -0.5 (* phi2 phi2) 1.0))
(-
t_0
(*
t_2
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = (sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2));
double t_2 = sin(phi1) * cos(phi2);
double tmp;
if ((phi2 <= -0.07) || !(phi2 <= 0.033)) {
tmp = atan2((t_1 * cos(phi2)), (t_0 - (t_2 * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((t_1 * fma(-0.5, (phi2 * phi2), 1.0)), (t_0 - (t_2 * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) t_2 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((phi2 <= -0.07) || !(phi2 <= 0.033)) tmp = atan(Float64(t_1 * cos(phi2)), Float64(t_0 - Float64(t_2 * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(t_1 * fma(-0.5, Float64(phi2 * phi2), 1.0)), Float64(t_0 - Float64(t_2 * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))); 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[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -0.07], N[Not[LessEqual[phi2, 0.033]], $MachinePrecision]], N[ArcTan[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$2 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$1 * N[(-0.5 * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$2 * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\\
t_2 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.07 \lor \neg \left(\phi_2 \leq 0.033\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot \cos \phi_2}{t\_0 - t\_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot \mathsf{fma}\left(-0.5, \phi_2 \cdot \phi_2, 1\right)}{t\_0 - t\_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.070000000000000007 or 0.033000000000000002 < phi2 Initial program 76.6%
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.f6488.0
Applied rewrites88.0%
if -0.070000000000000007 < phi2 < 0.033000000000000002Initial program 80.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.f6488.5
Applied rewrites88.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6499.2
Applied rewrites99.2%
Final simplification94.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))))
(if (or (<= phi2 -250000000000.0) (not (<= phi2 0.033)))
(atan2
t_1
(- t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(atan2
t_1
(-
t_0
(*
(* (sin phi1) 1.0)
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double tmp;
if ((phi2 <= -250000000000.0) || !(phi2 <= 0.033)) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * 1.0) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(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 = cos(phi1) * sin(phi2)
t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)
if ((phi2 <= (-250000000000.0d0)) .or. (.not. (phi2 <= 0.033d0))) then
tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
else
tmp = atan2(t_1, (t_0 - ((sin(phi1) * 1.0d0) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(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 t_1 = ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2);
double tmp;
if ((phi2 <= -250000000000.0) || !(phi2 <= 0.033)) {
tmp = Math.atan2(t_1, (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2(t_1, (t_0 - ((Math.sin(phi1) * 1.0) * ((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(lambda2))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2) tmp = 0 if (phi2 <= -250000000000.0) or not (phi2 <= 0.033): tmp = math.atan2(t_1, (t_0 - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2(t_1, (t_0 - ((math.sin(phi1) * 1.0) * ((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda1) * math.sin(lambda2)))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) tmp = 0.0 if ((phi2 <= -250000000000.0) || !(phi2 <= 0.033)) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * 1.0) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2); tmp = 0.0; if ((phi2 <= -250000000000.0) || ~((phi2 <= 0.033))) tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); else tmp = atan2(t_1, (t_0 - ((sin(phi1) * 1.0) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(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]}, Block[{t$95$1 = 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]}, If[Or[LessEqual[phi2, -250000000000.0], N[Not[LessEqual[phi2, 0.033]], $MachinePrecision]], N[ArcTan[t$95$1 / 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], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * 1.0), $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -250000000000 \lor \neg \left(\phi_2 \leq 0.033\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot 1\right) \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -2.5e11 or 0.033000000000000002 < phi2 Initial program 77.7%
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.f6488.4
Applied rewrites88.4%
if -2.5e11 < phi2 < 0.033000000000000002Initial program 79.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.f6488.1
Applied rewrites88.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi2 around 0
Applied rewrites98.4%
Final simplification93.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (sin phi1) (cos phi2))))
(if (or (<= phi2 -3.2e-5) (not (<= phi2 4.6e-9)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* t_1 (cos (- lambda1 lambda2)))))
(atan2
(fma (cos lambda2) (sin lambda1) (* (- (cos lambda1)) (sin lambda2)))
(-
t_0
(*
t_1
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2)))))))))
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 tmp;
if ((phi2 <= -3.2e-5) || !(phi2 <= 4.6e-9)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(fma(cos(lambda2), sin(lambda1), (-cos(lambda1) * sin(lambda2))), (t_0 - (t_1 * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((phi2 <= -3.2e-5) || !(phi2 <= 4.6e-9)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(Float64(lambda1 - lambda2))))); else tmp = atan(fma(cos(lambda2), sin(lambda1), Float64(Float64(-cos(lambda1)) * sin(lambda2))), Float64(t_0 - Float64(t_1 * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))); 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]}, If[Or[LessEqual[phi2, -3.2e-5], N[Not[LessEqual[phi2, 4.6e-9]], $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[(t$95$0 - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -3.2 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 4.6 \cdot 10^{-9}\right):\\
\;\;\;\;\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 \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\cos \lambda_2, \sin \lambda_1, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right)}{t\_0 - t\_1 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -3.19999999999999986e-5 or 4.5999999999999998e-9 < phi2 Initial program 76.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.f6487.3
Applied rewrites87.3%
if -3.19999999999999986e-5 < phi2 < 4.5999999999999998e-9Initial program 80.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.1
Applied rewrites89.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi2 around 0
sin-diff-revN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Final simplification93.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin phi1) (cos phi2)))
(t_2 (* (cos lambda1) (sin lambda2))))
(if (<= lambda2 1e-54)
(atan2
(* (- (sin lambda1) t_2) (cos phi2))
(- t_0 (* t_1 (cos (- lambda1 lambda2)))))
(atan2
(* (- (* (sin lambda1) (cos lambda2)) t_2) (cos phi2))
(- t_0 (* t_1 (cos lambda2)))))))
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 = cos(lambda1) * sin(lambda2);
double tmp;
if (lambda2 <= 1e-54) {
tmp = atan2(((sin(lambda1) - t_2) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_2) * cos(phi2)), (t_0 - (t_1 * 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) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin(phi1) * cos(phi2)
t_2 = cos(lambda1) * sin(lambda2)
if (lambda2 <= 1d-54) then
tmp = atan2(((sin(lambda1) - t_2) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2)))))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_2) * cos(phi2)), (t_0 - (t_1 * cos(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 t_1 = Math.sin(phi1) * Math.cos(phi2);
double t_2 = Math.cos(lambda1) * Math.sin(lambda2);
double tmp;
if (lambda2 <= 1e-54) {
tmp = Math.atan2(((Math.sin(lambda1) - t_2) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - t_2) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos(lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin(phi1) * math.cos(phi2) t_2 = math.cos(lambda1) * math.sin(lambda2) tmp = 0 if lambda2 <= 1e-54: tmp = math.atan2(((math.sin(lambda1) - t_2) * math.cos(phi2)), (t_0 - (t_1 * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - t_2) * math.cos(phi2)), (t_0 - (t_1 * math.cos(lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) t_2 = Float64(cos(lambda1) * sin(lambda2)) tmp = 0.0 if (lambda2 <= 1e-54) tmp = atan(Float64(Float64(sin(lambda1) - t_2) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - t_2) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin(phi1) * cos(phi2); t_2 = cos(lambda1) * sin(lambda2); tmp = 0.0; if (lambda2 <= 1e-54) tmp = atan2(((sin(lambda1) - t_2) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2))))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_2) * cos(phi2)), (t_0 - (t_1 * cos(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]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 1e-54], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$2), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\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 := \cos \lambda_1 \cdot \sin \lambda_2\\
\mathbf{if}\;\lambda_2 \leq 10^{-54}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\end{array}
\end{array}
if lambda2 < 1e-54Initial program 87.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.f6493.3
Applied rewrites93.3%
Taylor expanded in lambda2 around 0
lift-sin.f6491.3
Applied rewrites91.3%
if 1e-54 < 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.f6478.3
Applied rewrites78.3%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lift-cos.f6478.4
Applied rewrites78.4%
(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 78.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.f6488.2
Applied rewrites88.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2)))
(t_1 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))
(t_2 (- (* (cos phi1) (sin phi2)) t_1))
(t_3 (* (sin lambda1) (cos lambda2))))
(if (<= phi1 -3.3e+27)
(atan2 (* (- t_3 (sin lambda2)) (cos phi2)) t_2)
(if (<= phi1 2.85)
(atan2
(* (- t_3 t_0) (cos phi2))
(-
(*
(fma
(* phi1 phi1)
(-
(*
(* phi1 phi1)
(fma -0.001388888888888889 (* phi1 phi1) 0.041666666666666664))
0.5)
1.0)
(sin phi2))
t_1))
(atan2 (* (- (sin lambda1) t_0) (cos phi2)) t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2));
double t_2 = (cos(phi1) * sin(phi2)) - t_1;
double t_3 = sin(lambda1) * cos(lambda2);
double tmp;
if (phi1 <= -3.3e+27) {
tmp = atan2(((t_3 - sin(lambda2)) * cos(phi2)), t_2);
} else if (phi1 <= 2.85) {
tmp = atan2(((t_3 - t_0) * cos(phi2)), ((fma((phi1 * phi1), (((phi1 * phi1) * fma(-0.001388888888888889, (phi1 * phi1), 0.041666666666666664)) - 0.5), 1.0) * sin(phi2)) - t_1));
} else {
tmp = atan2(((sin(lambda1) - t_0) * cos(phi2)), t_2);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) t_1 = Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) t_2 = Float64(Float64(cos(phi1) * sin(phi2)) - t_1) t_3 = Float64(sin(lambda1) * cos(lambda2)) tmp = 0.0 if (phi1 <= -3.3e+27) tmp = atan(Float64(Float64(t_3 - sin(lambda2)) * cos(phi2)), t_2); elseif (phi1 <= 2.85) tmp = atan(Float64(Float64(t_3 - t_0) * cos(phi2)), Float64(Float64(fma(Float64(phi1 * phi1), Float64(Float64(Float64(phi1 * phi1) * fma(-0.001388888888888889, Float64(phi1 * phi1), 0.041666666666666664)) - 0.5), 1.0) * sin(phi2)) - t_1)); else tmp = atan(Float64(Float64(sin(lambda1) - t_0) * cos(phi2)), t_2); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -3.3e+27], N[ArcTan[N[(N[(t$95$3 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi1, 2.85], N[ArcTan[N[(N[(t$95$3 - t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * N[(N[(N[(phi1 * phi1), $MachinePrecision] * N[(-0.001388888888888889 * N[(phi1 * phi1), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_1 \cdot \sin \phi_2 - t\_1\\
t_3 := \sin \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -3.3 \cdot 10^{+27}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_3 - \sin \lambda_2\right) \cdot \cos \phi_2}{t\_2}\\
\mathbf{elif}\;\phi_1 \leq 2.85:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_3 - t\_0\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\phi_1 \cdot \phi_1, \left(\phi_1 \cdot \phi_1\right) \cdot \mathsf{fma}\left(-0.001388888888888889, \phi_1 \cdot \phi_1, 0.041666666666666664\right) - 0.5, 1\right) \cdot \sin \phi_2 - t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_0\right) \cdot \cos \phi_2}{t\_2}\\
\end{array}
\end{array}
if phi1 < -3.2999999999999998e27Initial program 77.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.0
Applied rewrites80.0%
Taylor expanded in lambda1 around 0
lift-sin.f6478.8
Applied rewrites78.8%
if -3.2999999999999998e27 < phi1 < 2.85000000000000009Initial program 81.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.f6499.1
Applied rewrites99.1%
Taylor expanded in phi1 around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6499.2
Applied rewrites99.2%
if 2.85000000000000009 < phi1 Initial program 73.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.f6477.7
Applied rewrites77.7%
Taylor expanded in lambda2 around 0
lift-sin.f6475.3
Applied rewrites75.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2))) (t_1 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -1.4e-6) (not (<= phi1 1.6e-115)))
(atan2
(* (- (sin lambda1) t_0) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_1)))
(atan2
(* (- (* (sin lambda1) (cos lambda2)) t_0) (cos phi2))
(fma (- phi1) (* (cos phi2) t_1) (sin phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -1.4e-6) || !(phi1 <= 1.6e-115)) {
tmp = atan2(((sin(lambda1) - t_0) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_1)));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), fma(-phi1, (cos(phi2) * t_1), sin(phi2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -1.4e-6) || !(phi1 <= 1.6e-115)) tmp = atan(Float64(Float64(sin(lambda1) - t_0) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_1))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), fma(Float64(-phi1), Float64(cos(phi2) * t_1), sin(phi2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -1.4e-6], N[Not[LessEqual[phi1, 1.6e-115]], $MachinePrecision]], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$0), $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$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[((-phi1) * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.4 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 1.6 \cdot 10^{-115}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_0\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_0\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-\phi_1, \cos \phi_2 \cdot t\_1, \sin \phi_2\right)}\\
\end{array}
\end{array}
if phi1 < -1.39999999999999994e-6 or 1.6e-115 < phi1 Initial 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.f6481.6
Applied rewrites81.6%
Taylor expanded in lambda2 around 0
lift-sin.f6479.8
Applied rewrites79.8%
if -1.39999999999999994e-6 < phi1 < 1.6e-115Initial program 79.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.8
Applied rewrites99.8%
Taylor expanded in phi1 around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Final simplification87.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_1)))
(t_3 (* (sin lambda1) (cos lambda2))))
(if (<= phi1 -1.55e-6)
(atan2 (* (- t_3 (sin lambda2)) (cos phi2)) t_2)
(if (<= phi1 1.6e-115)
(atan2
(* (- t_3 t_0) (cos phi2))
(fma (- phi1) (* (cos phi2) t_1) (sin phi2)))
(atan2 (* (- (sin lambda1) t_0) (cos phi2)) t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = (cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_1);
double t_3 = sin(lambda1) * cos(lambda2);
double tmp;
if (phi1 <= -1.55e-6) {
tmp = atan2(((t_3 - sin(lambda2)) * cos(phi2)), t_2);
} else if (phi1 <= 1.6e-115) {
tmp = atan2(((t_3 - t_0) * cos(phi2)), fma(-phi1, (cos(phi2) * t_1), sin(phi2)));
} else {
tmp = atan2(((sin(lambda1) - t_0) * cos(phi2)), t_2);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_1)) t_3 = Float64(sin(lambda1) * cos(lambda2)) tmp = 0.0 if (phi1 <= -1.55e-6) tmp = atan(Float64(Float64(t_3 - sin(lambda2)) * cos(phi2)), t_2); elseif (phi1 <= 1.6e-115) tmp = atan(Float64(Float64(t_3 - t_0) * cos(phi2)), fma(Float64(-phi1), Float64(cos(phi2) * t_1), sin(phi2))); else tmp = atan(Float64(Float64(sin(lambda1) - t_0) * cos(phi2)), t_2); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.55e-6], N[ArcTan[N[(N[(t$95$3 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi1, 1.6e-115], N[ArcTan[N[(N[(t$95$3 - t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[((-phi1) * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\\
t_3 := \sin \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -1.55 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_3 - \sin \lambda_2\right) \cdot \cos \phi_2}{t\_2}\\
\mathbf{elif}\;\phi_1 \leq 1.6 \cdot 10^{-115}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_3 - t\_0\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-\phi_1, \cos \phi_2 \cdot t\_1, \sin \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_0\right) \cdot \cos \phi_2}{t\_2}\\
\end{array}
\end{array}
if phi1 < -1.55e-6Initial 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.f6479.7
Applied rewrites79.7%
if -1.55e-6 < phi1 < 1.6e-115Initial program 79.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.8
Applied rewrites99.8%
Taylor expanded in phi1 around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
if 1.6e-115 < phi1 Initial 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.f6482.1
Applied rewrites82.1%
Taylor expanded in lambda2 around 0
lift-sin.f6480.2
Applied rewrites80.2%
Final simplification87.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -7.2e-6) (not (<= phi1 2.85)))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* t_0 (sin phi1)) (cos phi2))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(fma (- phi1) (* (cos phi2) t_0) (sin phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -7.2e-6) || !(phi1 <= 2.85)) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((t_0 * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(-phi1, (cos(phi2) * t_0), sin(phi2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -7.2e-6) || !(phi1 <= 2.85)) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(t_0 * sin(phi1)) * cos(phi2)))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(Float64(-phi1), Float64(cos(phi2) * t_0), sin(phi2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -7.2e-6], N[Not[LessEqual[phi1, 2.85]], $MachinePrecision]], 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[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $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[((-phi1) * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -7.2 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 2.85\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(t\_0 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\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(-\phi_1, \cos \phi_2 \cdot t\_0, \sin \phi_2\right)}\\
\end{array}
\end{array}
if phi1 < -7.19999999999999967e-6 or 2.85000000000000009 < phi1 Initial program 76.0%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-cos.f6476.0
Applied rewrites76.0%
if -7.19999999999999967e-6 < phi1 < 2.85000000000000009Initial program 81.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.1
Applied rewrites99.1%
Taylor expanded in phi1 around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6499.1
Applied rewrites99.1%
Final simplification86.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -3.3e+27) (not (<= phi1 2.85)))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* t_0 (sin phi1)) (cos phi2))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* (sin phi1) t_0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -3.3e+27) || !(phi1 <= 2.85)) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((t_0 * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * 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 = cos((lambda1 - lambda2))
if ((phi1 <= (-3.3d+27)) .or. (.not. (phi1 <= 2.85d0))) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((t_0 * sin(phi1)) * cos(phi2))))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -3.3e+27) || !(phi1 <= 2.85)) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((t_0 * Math.sin(phi1)) * Math.cos(phi2))));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (Math.sin(phi1) * t_0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if (phi1 <= -3.3e+27) or not (phi1 <= 2.85): tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((t_0 * math.sin(phi1)) * math.cos(phi2)))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (math.sin(phi1) * t_0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -3.3e+27) || !(phi1 <= 2.85)) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(t_0 * sin(phi1)) * cos(phi2)))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -3.3e+27) || ~((phi1 <= 2.85))) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((t_0 * sin(phi1)) * cos(phi2)))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -3.3e+27], N[Not[LessEqual[phi1, 2.85]], $MachinePrecision]], 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[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $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[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -3.3 \cdot 10^{+27} \lor \neg \left(\phi_1 \leq 2.85\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(t\_0 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\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 - \sin \phi_1 \cdot t\_0}\\
\end{array}
\end{array}
if phi1 < -3.2999999999999998e27 or 2.85000000000000009 < phi1 Initial program 75.5%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-cos.f6475.5
Applied rewrites75.5%
if -3.2999999999999998e27 < phi1 < 2.85000000000000009Initial program 81.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.f6499.1
Applied rewrites99.1%
Taylor expanded in phi2 around 0
lift-sin.f6499.1
Applied rewrites99.1%
Taylor expanded in phi1 around 0
lift-sin.f6499.1
Applied rewrites99.1%
Final simplification86.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -3.3e+27) (not (<= phi1 2.85)))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* t_1 (sin phi1)) (cos phi2))))
(atan2
(* (- (sin lambda1) (* (cos lambda1) (sin lambda2))) (cos phi2))
(- t_0 (* (sin phi1) 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 <= -3.3e+27) || !(phi1 <= 2.85)) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((t_1 * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2(((sin(lambda1) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (sin(phi1) * 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 <= (-3.3d+27)) .or. (.not. (phi1 <= 2.85d0))) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((t_1 * sin(phi1)) * cos(phi2))))
else
tmp = atan2(((sin(lambda1) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (sin(phi1) * 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 <= -3.3e+27) || !(phi1 <= 2.85)) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - ((t_1 * Math.sin(phi1)) * Math.cos(phi2))));
} else {
tmp = Math.atan2(((Math.sin(lambda1) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (Math.sin(phi1) * 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 <= -3.3e+27) or not (phi1 <= 2.85): tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - ((t_1 * math.sin(phi1)) * math.cos(phi2)))) else: tmp = math.atan2(((math.sin(lambda1) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (math.sin(phi1) * 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 <= -3.3e+27) || !(phi1 <= 2.85)) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(t_1 * sin(phi1)) * cos(phi2)))); else tmp = atan(Float64(Float64(sin(lambda1) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(sin(phi1) * 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 <= -3.3e+27) || ~((phi1 <= 2.85))) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((t_1 * sin(phi1)) * cos(phi2)))); else tmp = atan2(((sin(lambda1) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (sin(phi1) * 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[Or[LessEqual[phi1, -3.3e+27], N[Not[LessEqual[phi1, 2.85]], $MachinePrecision]], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(t$95$1 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $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 -3.3 \cdot 10^{+27} \lor \neg \left(\phi_1 \leq 2.85\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(t\_1 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \sin \phi_1 \cdot t\_1}\\
\end{array}
\end{array}
if phi1 < -3.2999999999999998e27 or 2.85000000000000009 < phi1 Initial program 75.5%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-cos.f6475.5
Applied rewrites75.5%
if -3.2999999999999998e27 < phi1 < 2.85000000000000009Initial program 81.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.f6499.1
Applied rewrites99.1%
Taylor expanded in phi2 around 0
lift-sin.f6499.1
Applied rewrites99.1%
Taylor expanded in lambda2 around 0
lift-sin.f6490.0
Applied rewrites90.0%
Final simplification82.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (* (cos lambda2) (sin phi1)) (cos phi2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2
(atan2
(* (sin lambda1) (cos phi2))
(- t_1 (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2))))))))
(if (<= lambda1 -1.8e-46)
t_2
(if (<= lambda1 2.05e-165)
(atan2 (* (- (sin lambda2)) (cos phi2)) (- t_1 t_0))
(if (<= lambda1 0.00275)
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (sin phi2) t_0))
t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(lambda2) * sin(phi1)) * cos(phi2);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = atan2((sin(lambda1) * cos(phi2)), (t_1 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
double tmp;
if (lambda1 <= -1.8e-46) {
tmp = t_2;
} else if (lambda1 <= 2.05e-165) {
tmp = atan2((-sin(lambda2) * cos(phi2)), (t_1 - t_0));
} else if (lambda1 <= 0.00275) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - t_0));
} else {
tmp = t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 = (cos(lambda2) * sin(phi1)) * cos(phi2)
t_1 = cos(phi1) * sin(phi2)
t_2 = atan2((sin(lambda1) * cos(phi2)), (t_1 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))))
if (lambda1 <= (-1.8d-46)) then
tmp = t_2
else if (lambda1 <= 2.05d-165) then
tmp = atan2((-sin(lambda2) * cos(phi2)), (t_1 - t_0))
else if (lambda1 <= 0.00275d0) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - t_0))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.cos(lambda2) * Math.sin(phi1)) * Math.cos(phi2);
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double t_2 = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_1 - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
double tmp;
if (lambda1 <= -1.8e-46) {
tmp = t_2;
} else if (lambda1 <= 2.05e-165) {
tmp = Math.atan2((-Math.sin(lambda2) * Math.cos(phi2)), (t_1 - t_0));
} else if (lambda1 <= 0.00275) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (Math.sin(phi2) - t_0));
} else {
tmp = t_2;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = (math.cos(lambda2) * math.sin(phi1)) * math.cos(phi2) t_1 = math.cos(phi1) * math.sin(phi2) t_2 = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_1 - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2)))))) tmp = 0 if lambda1 <= -1.8e-46: tmp = t_2 elif lambda1 <= 2.05e-165: tmp = math.atan2((-math.sin(lambda2) * math.cos(phi2)), (t_1 - t_0)) elif lambda1 <= 0.00275: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - t_0)) else: tmp = t_2 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_1 - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))) tmp = 0.0 if (lambda1 <= -1.8e-46) tmp = t_2; elseif (lambda1 <= 2.05e-165) tmp = atan(Float64(Float64(-sin(lambda2)) * cos(phi2)), Float64(t_1 - t_0)); elseif (lambda1 <= 0.00275) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - t_0)); else tmp = t_2; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = (cos(lambda2) * sin(phi1)) * cos(phi2); t_1 = cos(phi1) * sin(phi2); t_2 = atan2((sin(lambda1) * cos(phi2)), (t_1 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); tmp = 0.0; if (lambda1 <= -1.8e-46) tmp = t_2; elseif (lambda1 <= 2.05e-165) tmp = atan2((-sin(lambda2) * cos(phi2)), (t_1 - t_0)); elseif (lambda1 <= 0.00275) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - t_0)); else tmp = t_2; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -1.8e-46], t$95$2, If[LessEqual[lambda1, 2.05e-165], N[ArcTan[N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - t$95$0), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 0.00275], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_1 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{if}\;\lambda_1 \leq -1.8 \cdot 10^{-46}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_1 \leq 2.05 \cdot 10^{-165}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(-\sin \lambda_2\right) \cdot \cos \phi_2}{t\_1 - t\_0}\\
\mathbf{elif}\;\lambda_1 \leq 0.00275:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if lambda1 < -1.8e-46 or 0.0027499999999999998 < lambda1 Initial program 61.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.f6479.0
Applied rewrites79.0%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
Taylor expanded in lambda2 around 0
sin-diff-revN/A
lift-sin.f6463.7
Applied rewrites63.7%
Taylor expanded in lambda1 around inf
cos-diff-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
cos-diff-revN/A
lower-cos.f64N/A
lift--.f6463.5
Applied rewrites63.5%
if -1.8e-46 < lambda1 < 2.0500000000000001e-165Initial program 99.7%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-sin.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
Taylor expanded in lambda1 around 0
sin-neg-revN/A
lift-sin.f64N/A
lift-neg.f6491.3
Applied rewrites91.3%
if 2.0500000000000001e-165 < lambda1 < 0.0027499999999999998Initial program 98.0%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-sin.f64N/A
lift-cos.f6498.0
Applied rewrites98.0%
Taylor expanded in phi1 around 0
lift-sin.f6486.3
Applied rewrites86.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (or (<= phi2 -9e-24) (not (<= phi2 2.75e-59)))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* t_0 (sin phi1)) (cos phi2))))
(atan2
(fma (cos lambda2) (sin lambda1) (* (- (cos lambda1)) (sin lambda2)))
(* t_0 (- (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if ((phi2 <= -9e-24) || !(phi2 <= 2.75e-59)) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((t_0 * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2(fma(cos(lambda2), sin(lambda1), (-cos(lambda1) * sin(lambda2))), (t_0 * -sin(phi1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -9e-24) || !(phi2 <= 2.75e-59)) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(t_0 * sin(phi1)) * cos(phi2)))); else tmp = atan(fma(cos(lambda2), sin(lambda1), Float64(Float64(-cos(lambda1)) * sin(lambda2))), Float64(t_0 * Float64(-sin(phi1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -9e-24], N[Not[LessEqual[phi2, 2.75e-59]], $MachinePrecision]], 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[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -9 \cdot 10^{-24} \lor \neg \left(\phi_2 \leq 2.75 \cdot 10^{-59}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(t\_0 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\cos \lambda_2, \sin \lambda_1, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right)}{t\_0 \cdot \left(-\sin \phi_1\right)}\\
\end{array}
\end{array}
if phi2 < -8.9999999999999995e-24 or 2.75000000000000007e-59 < phi2 Initial program 77.9%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-cos.f6477.9
Applied rewrites77.9%
if -8.9999999999999995e-24 < phi2 < 2.75000000000000007e-59Initial program 79.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.f6488.7
Applied rewrites88.7%
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.f6487.3
Applied rewrites87.3%
Taylor expanded in phi2 around 0
sin-diff-revN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6487.3
Applied rewrites87.3%
Final simplification82.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* (* (cos lambda1) (cos phi2)) (sin phi1)))))
(t_2 (* (* (cos lambda2) (sin phi1)) (cos phi2))))
(if (<= lambda1 -1.8e-46)
t_1
(if (<= lambda1 2.05e-165)
(atan2 (* (- (sin lambda2)) (cos phi2)) (- t_0 t_2))
(if (<= lambda1 0.00275)
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (sin phi2) t_2))
t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1))));
double t_2 = (cos(lambda2) * sin(phi1)) * cos(phi2);
double tmp;
if (lambda1 <= -1.8e-46) {
tmp = t_1;
} else if (lambda1 <= 2.05e-165) {
tmp = atan2((-sin(lambda2) * cos(phi2)), (t_0 - t_2));
} else if (lambda1 <= 0.00275) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - t_2));
} 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) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1))))
t_2 = (cos(lambda2) * sin(phi1)) * cos(phi2)
if (lambda1 <= (-1.8d-46)) then
tmp = t_1
else if (lambda1 <= 2.05d-165) then
tmp = atan2((-sin(lambda2) * cos(phi2)), (t_0 - t_2))
else if (lambda1 <= 0.00275d0) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - t_2))
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.cos(phi1) * Math.sin(phi2);
double t_1 = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - ((Math.cos(lambda1) * Math.cos(phi2)) * Math.sin(phi1))));
double t_2 = (Math.cos(lambda2) * Math.sin(phi1)) * Math.cos(phi2);
double tmp;
if (lambda1 <= -1.8e-46) {
tmp = t_1;
} else if (lambda1 <= 2.05e-165) {
tmp = Math.atan2((-Math.sin(lambda2) * Math.cos(phi2)), (t_0 - t_2));
} else if (lambda1 <= 0.00275) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (Math.sin(phi2) - t_2));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - ((math.cos(lambda1) * math.cos(phi2)) * math.sin(phi1)))) t_2 = (math.cos(lambda2) * math.sin(phi1)) * math.cos(phi2) tmp = 0 if lambda1 <= -1.8e-46: tmp = t_1 elif lambda1 <= 2.05e-165: tmp = math.atan2((-math.sin(lambda2) * math.cos(phi2)), (t_0 - t_2)) elif lambda1 <= 0.00275: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - t_2)) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(lambda1) * cos(phi2)) * sin(phi1)))) t_2 = Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2)) tmp = 0.0 if (lambda1 <= -1.8e-46) tmp = t_1; elseif (lambda1 <= 2.05e-165) tmp = atan(Float64(Float64(-sin(lambda2)) * cos(phi2)), Float64(t_0 - t_2)); elseif (lambda1 <= 0.00275) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - t_2)); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1)))); t_2 = (cos(lambda2) * sin(phi1)) * cos(phi2); tmp = 0.0; if (lambda1 <= -1.8e-46) tmp = t_1; elseif (lambda1 <= 2.05e-165) tmp = atan2((-sin(lambda2) * cos(phi2)), (t_0 - t_2)); elseif (lambda1 <= 0.00275) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - t_2)); else tmp = 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[ArcTan[N[(N[Sin[lambda1], $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]}, Block[{t$95$2 = N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -1.8e-46], t$95$1, If[LessEqual[lambda1, 2.05e-165], N[ArcTan[N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - t$95$2), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 0.00275], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0 - \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot \sin \phi_1}\\
t_2 := \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_1 \leq -1.8 \cdot 10^{-46}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_1 \leq 2.05 \cdot 10^{-165}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(-\sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_2}\\
\mathbf{elif}\;\lambda_1 \leq 0.00275:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - t\_2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda1 < -1.8e-46 or 0.0027499999999999998 < lambda1 Initial program 61.8%
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.f6460.7
Applied rewrites60.7%
Taylor expanded in lambda1 around inf
Applied rewrites63.3%
if -1.8e-46 < lambda1 < 2.0500000000000001e-165Initial program 99.7%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-sin.f64N/A
lift-cos.f6499.7
Applied rewrites99.7%
Taylor expanded in lambda1 around 0
sin-neg-revN/A
lift-sin.f64N/A
lift-neg.f6491.3
Applied rewrites91.3%
if 2.0500000000000001e-165 < lambda1 < 0.0027499999999999998Initial program 98.0%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-sin.f64N/A
lift-cos.f6498.0
Applied rewrites98.0%
Taylor expanded in phi1 around 0
lift-sin.f6486.3
Applied rewrites86.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda1 -5.1e-5) (not (<= lambda1 0.00275)))
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2))))))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* (cos lambda2) (sin phi1)) (cos phi2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda1 <= -5.1e-5) || !(lambda1 <= 0.00275)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(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) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda1 <= (-5.1d-5)) .or. (.not. (lambda1 <= 0.00275d0))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))))
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 ((lambda1 <= -5.1e-5) || !(lambda1 <= 0.00275)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - ((Math.cos(lambda2) * Math.sin(phi1)) * Math.cos(phi2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda1 <= -5.1e-5) or not (lambda1 <= 0.00275): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2)))))) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - ((math.cos(lambda2) * math.sin(phi1)) * math.cos(phi2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda1 <= -5.1e-5) || !(lambda1 <= 0.00275)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda1 <= -5.1e-5) || ~((lambda1 <= 0.00275))) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2)))); 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[Or[LessEqual[lambda1, -5.1e-5], N[Not[LessEqual[lambda1, 0.00275]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -5.1 \cdot 10^{-5} \lor \neg \left(\lambda_1 \leq 0.00275\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\end{array}
\end{array}
if lambda1 < -5.09999999999999996e-5 or 0.0027499999999999998 < lambda1 Initial program 57.7%
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.f6476.8
Applied rewrites76.8%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
Taylor expanded in lambda2 around 0
sin-diff-revN/A
lift-sin.f6462.6
Applied rewrites62.6%
Taylor expanded in lambda1 around inf
cos-diff-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
cos-diff-revN/A
lower-cos.f64N/A
lift--.f6462.4
Applied rewrites62.4%
if -5.09999999999999996e-5 < lambda1 < 0.0027499999999999998Initial program 99.2%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-sin.f64N/A
lift-cos.f6499.2
Applied rewrites99.2%
Final simplification80.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -0.0078) (not (<= lambda2 0.0033)))
(atan2
(* (- (sin lambda2)) (cos phi2))
(- t_0 (* (* (cos lambda2) (sin phi1)) (cos phi2))))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* (cos lambda1) (cos phi2)) (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda2 <= -0.0078) || !(lambda2 <= 0.0033)) {
tmp = atan2((-sin(lambda2) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1))));
}
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.0078d0)) .or. (.not. (lambda2 <= 0.0033d0))) then
tmp = atan2((-sin(lambda2) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1))))
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.0078) || !(lambda2 <= 0.0033)) {
tmp = Math.atan2((-Math.sin(lambda2) * Math.cos(phi2)), (t_0 - ((Math.cos(lambda2) * Math.sin(phi1)) * Math.cos(phi2))));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - ((Math.cos(lambda1) * Math.cos(phi2)) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda2 <= -0.0078) or not (lambda2 <= 0.0033): tmp = math.atan2((-math.sin(lambda2) * math.cos(phi2)), (t_0 - ((math.cos(lambda2) * math.sin(phi1)) * math.cos(phi2)))) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - ((math.cos(lambda1) * math.cos(phi2)) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda2 <= -0.0078) || !(lambda2 <= 0.0033)) tmp = atan(Float64(Float64(-sin(lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2)))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(lambda1) * cos(phi2)) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda2 <= -0.0078) || ~((lambda2 <= 0.0033))) tmp = atan2((-sin(lambda2) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2)))); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda1) * cos(phi2)) * sin(phi1)))); 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[Or[LessEqual[lambda2, -0.0078], N[Not[LessEqual[lambda2, 0.0033]], $MachinePrecision]], N[ArcTan[N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 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]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -0.0078 \lor \neg \left(\lambda_2 \leq 0.0033\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(-\sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\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}\\
\end{array}
\end{array}
if lambda2 < -0.0077999999999999996 or 0.0033 < lambda2 Initial program 57.9%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-sin.f64N/A
lift-cos.f6457.9
Applied rewrites57.9%
Taylor expanded in lambda1 around 0
sin-neg-revN/A
lift-sin.f64N/A
lift-neg.f6460.7
Applied rewrites60.7%
if -0.0077999999999999996 < lambda2 < 0.0033Initial 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.4
Applied rewrites99.4%
Final simplification79.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= lambda1 -1.25e-7) (not (<= lambda1 0.00275)))
(atan2
(* (sin lambda1) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (cos lambda1) (cos phi2)) (sin phi1))))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (sin phi2) (* (* (cos lambda2) (sin phi1)) (cos phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -1.25e-7) || !(lambda1 <= 0.00275)) {
tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(lambda1) * cos(phi2)) * sin(phi1))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((cos(lambda2) * sin(phi1)) * cos(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 ((lambda1 <= (-1.25d-7)) .or. (.not. (lambda1 <= 0.00275d0))) then
tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(lambda1) * cos(phi2)) * sin(phi1))))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((cos(lambda2) * sin(phi1)) * cos(phi2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -1.25e-7) || !(lambda1 <= 0.00275)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(lambda1) * Math.cos(phi2)) * Math.sin(phi1))));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (Math.sin(phi2) - ((Math.cos(lambda2) * Math.sin(phi1)) * Math.cos(phi2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda1 <= -1.25e-7) or not (lambda1 <= 0.00275): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(lambda1) * math.cos(phi2)) * math.sin(phi1)))) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - ((math.cos(lambda2) * math.sin(phi1)) * math.cos(phi2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda1 <= -1.25e-7) || !(lambda1 <= 0.00275)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(lambda1) * cos(phi2)) * sin(phi1)))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda1 <= -1.25e-7) || ~((lambda1 <= 0.00275))) tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(lambda1) * cos(phi2)) * sin(phi1)))); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((cos(lambda2) * sin(phi1)) * cos(phi2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda1, -1.25e-7], N[Not[LessEqual[lambda1, 0.00275]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $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], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -1.25 \cdot 10^{-7} \lor \neg \left(\lambda_1 \leq 0.00275\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \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}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\end{array}
\end{array}
if lambda1 < -1.24999999999999994e-7 or 0.0027499999999999998 < lambda1 Initial program 57.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.f6457.7
Applied rewrites57.7%
Taylor expanded in lambda1 around inf
Applied rewrites62.2%
if -1.24999999999999994e-7 < lambda1 < 0.0027499999999999998Initial program 99.2%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-sin.f64N/A
lift-cos.f6499.2
Applied rewrites99.2%
Taylor expanded in phi1 around 0
lift-sin.f6482.5
Applied rewrites82.5%
Final simplification72.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -8.8e-15) (not (<= phi2 1.2e-12)))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (cos phi2) (sin phi1))))
(atan2
(fma (cos lambda2) (sin lambda1) (* (- (cos lambda1)) (sin lambda2)))
(* (cos (- lambda1 lambda2)) (- (sin phi1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -8.8e-15) || !(phi2 <= 1.2e-12)) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1))));
} else {
tmp = atan2(fma(cos(lambda2), sin(lambda1), (-cos(lambda1) * sin(lambda2))), (cos((lambda1 - lambda2)) * -sin(phi1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -8.8e-15) || !(phi2 <= 1.2e-12)) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * sin(phi1)))); else tmp = atan(fma(cos(lambda2), sin(lambda1), Float64(Float64(-cos(lambda1)) * sin(lambda2))), Float64(cos(Float64(lambda1 - lambda2)) * Float64(-sin(phi1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -8.8e-15], N[Not[LessEqual[phi2, 1.2e-12]], $MachinePrecision]], 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[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -8.8 \cdot 10^{-15} \lor \neg \left(\phi_2 \leq 1.2 \cdot 10^{-12}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\cos \lambda_2, \sin \lambda_1, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right)}{\cos \left(\lambda_1 - \lambda_2\right) \cdot \left(-\sin \phi_1\right)}\\
\end{array}
\end{array}
if phi2 < -8.79999999999999942e-15 or 1.19999999999999994e-12 < phi2 Initial program 75.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.f6466.8
Applied rewrites66.8%
Taylor expanded in lambda1 around 0
lift-cos.f6456.9
Applied rewrites56.9%
if -8.79999999999999942e-15 < phi2 < 1.19999999999999994e-12Initial program 81.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.f6489.6
Applied rewrites89.6%
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.f6486.2
Applied rewrites86.2%
Taylor expanded in phi2 around 0
sin-diff-revN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6486.2
Applied rewrites86.2%
Final simplification71.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -4.6e-10) (not (<= phi2 42000000000.0)))
(atan2
(* t_0 (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (cos phi2) (sin phi1))))
(atan2
(*
t_0
(fma
(* phi2 phi2)
(-
(*
(* phi2 phi2)
(fma -0.001388888888888889 (* phi2 phi2) 0.041666666666666664))
0.5)
1.0))
(-
(* (cos phi1) (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))
(*
(*
(sin phi1)
(fma
(* phi2 phi2)
(- (* 0.041666666666666664 (* phi2 phi2)) 0.5)
1.0))
(cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -4.6e-10) || !(phi2 <= 42000000000.0)) {
tmp = atan2((t_0 * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1))));
} else {
tmp = atan2((t_0 * fma((phi2 * phi2), (((phi2 * phi2) * fma(-0.001388888888888889, (phi2 * phi2), 0.041666666666666664)) - 0.5), 1.0)), ((cos(phi1) * (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - ((sin(phi1) * fma((phi2 * phi2), ((0.041666666666666664 * (phi2 * phi2)) - 0.5), 1.0)) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -4.6e-10) || !(phi2 <= 42000000000.0)) tmp = atan(Float64(t_0 * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * sin(phi1)))); else tmp = atan(Float64(t_0 * fma(Float64(phi2 * phi2), Float64(Float64(Float64(phi2 * phi2) * fma(-0.001388888888888889, Float64(phi2 * phi2), 0.041666666666666664)) - 0.5), 1.0)), Float64(Float64(cos(phi1) * Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - Float64(Float64(sin(phi1) * fma(Float64(phi2 * phi2), Float64(Float64(0.041666666666666664 * Float64(phi2 * phi2)) - 0.5), 1.0)) * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -4.6e-10], N[Not[LessEqual[phi2, 42000000000.0]], $MachinePrecision]], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$0 * N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * N[(-0.001388888888888889 * N[(phi2 * phi2), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(0.041666666666666664 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -4.6 \cdot 10^{-10} \lor \neg \left(\phi_2 \leq 42000000000\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \left(\phi_2 \cdot \phi_2\right) \cdot \mathsf{fma}\left(-0.001388888888888889, \phi_2 \cdot \phi_2, 0.041666666666666664\right) - 0.5, 1\right)}{\cos \phi_1 \cdot \left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2\right) - \left(\sin \phi_1 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, 0.041666666666666664 \cdot \left(\phi_2 \cdot \phi_2\right) - 0.5, 1\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -4.60000000000000014e-10 or 4.2e10 < phi2 Initial program 76.6%
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.f6467.6
Applied rewrites67.6%
Taylor expanded in lambda1 around 0
lift-cos.f6457.6
Applied rewrites57.6%
if -4.60000000000000014e-10 < phi2 < 4.2e10Initial program 80.1%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6479.0
Applied rewrites79.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.0
Applied rewrites79.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6479.1
Applied rewrites79.1%
Final simplification69.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= lambda1 -0.00098) (not (<= lambda1 0.58)))
(atan2
(* (sin lambda1) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (sin phi1) (cos (- lambda1 lambda2)))))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (sin phi2) (* (* (cos lambda2) (sin phi1)) (cos phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -0.00098) || !(lambda1 <= 0.58)) {
tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((cos(lambda2) * sin(phi1)) * cos(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 ((lambda1 <= (-0.00098d0)) .or. (.not. (lambda1 <= 0.58d0))) then
tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((cos(lambda2) * sin(phi1)) * cos(phi2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -0.00098) || !(lambda1 <= 0.58)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (Math.sin(phi2) - ((Math.cos(lambda2) * Math.sin(phi1)) * Math.cos(phi2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda1 <= -0.00098) or not (lambda1 <= 0.58): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - ((math.cos(lambda2) * math.sin(phi1)) * math.cos(phi2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda1 <= -0.00098) || !(lambda1 <= 0.58)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda1 <= -0.00098) || ~((lambda1 <= 0.58))) tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2))))); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((cos(lambda2) * sin(phi1)) * cos(phi2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda1, -0.00098], N[Not[LessEqual[lambda1, 0.58]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $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], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -0.00098 \lor \neg \left(\lambda_1 \leq 0.58\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\end{array}
\end{array}
if lambda1 < -9.7999999999999997e-4 or 0.57999999999999996 < lambda1 Initial program 57.7%
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.f6476.8
Applied rewrites76.8%
Taylor expanded in phi2 around 0
lift-sin.f6467.0
Applied rewrites67.0%
Taylor expanded in lambda2 around 0
sin-diff-revN/A
lift-sin.f6452.8
Applied rewrites52.8%
if -9.7999999999999997e-4 < lambda1 < 0.57999999999999996Initial program 99.2%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-sin.f64N/A
lift-cos.f6499.2
Applied rewrites99.2%
Taylor expanded in phi1 around 0
lift-sin.f6482.5
Applied rewrites82.5%
Final simplification67.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -0.78) (not (<= phi2 4.6e+34)))
(atan2
(* t_0 (cos phi2))
(- (sin phi2) (* (* (cos lambda1) (cos phi2)) (sin phi1))))
(atan2
(*
t_0
(fma
(* phi2 phi2)
(-
(*
(* phi2 phi2)
(fma -0.001388888888888889 (* phi2 phi2) 0.041666666666666664))
0.5)
1.0))
(-
(* (cos phi1) (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.78) || !(phi2 <= 4.6e+34)) {
tmp = atan2((t_0 * cos(phi2)), (sin(phi2) - ((cos(lambda1) * cos(phi2)) * sin(phi1))));
} else {
tmp = atan2((t_0 * fma((phi2 * phi2), (((phi2 * phi2) * fma(-0.001388888888888889, (phi2 * phi2), 0.041666666666666664)) - 0.5), 1.0)), ((cos(phi1) * (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -0.78) || !(phi2 <= 4.6e+34)) tmp = atan(Float64(t_0 * cos(phi2)), Float64(sin(phi2) - Float64(Float64(cos(lambda1) * cos(phi2)) * sin(phi1)))); else tmp = atan(Float64(t_0 * fma(Float64(phi2 * phi2), Float64(Float64(Float64(phi2 * phi2) * fma(-0.001388888888888889, Float64(phi2 * phi2), 0.041666666666666664)) - 0.5), 1.0)), Float64(Float64(cos(phi1) * Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.78], N[Not[LessEqual[phi2, 4.6e+34]], $MachinePrecision]], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$0 * N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * N[(-0.001388888888888889 * N[(phi2 * phi2), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * 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}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.78 \lor \neg \left(\phi_2 \leq 4.6 \cdot 10^{+34}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2 - \left(\cos \lambda_1 \cdot \cos \phi_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \left(\phi_2 \cdot \phi_2\right) \cdot \mathsf{fma}\left(-0.001388888888888889, \phi_2 \cdot \phi_2, 0.041666666666666664\right) - 0.5, 1\right)}{\cos \phi_1 \cdot \left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2\right) - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.78000000000000003 or 4.5999999999999996e34 < phi2 Initial program 77.0%
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.f6467.5
Applied rewrites67.5%
Taylor expanded in phi1 around 0
lift-sin.f6449.4
Applied rewrites49.4%
if -0.78000000000000003 < phi2 < 4.5999999999999996e34Initial program 79.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6476.8
Applied rewrites76.8%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6477.0
Applied rewrites77.0%
Final simplification65.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -4.6e-10) (not (<= phi2 4.6e+34)))
(atan2 (* t_0 (cos phi2)) (sin phi2))
(atan2
(*
t_0
(fma
(* phi2 phi2)
(-
(*
(* phi2 phi2)
(fma -0.001388888888888889 (* phi2 phi2) 0.041666666666666664))
0.5)
1.0))
(-
(* (cos phi1) (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -4.6e-10) || !(phi2 <= 4.6e+34)) {
tmp = atan2((t_0 * cos(phi2)), sin(phi2));
} else {
tmp = atan2((t_0 * fma((phi2 * phi2), (((phi2 * phi2) * fma(-0.001388888888888889, (phi2 * phi2), 0.041666666666666664)) - 0.5), 1.0)), ((cos(phi1) * (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -4.6e-10) || !(phi2 <= 4.6e+34)) tmp = atan(Float64(t_0 * cos(phi2)), sin(phi2)); else tmp = atan(Float64(t_0 * fma(Float64(phi2 * phi2), Float64(Float64(Float64(phi2 * phi2) * fma(-0.001388888888888889, Float64(phi2 * phi2), 0.041666666666666664)) - 0.5), 1.0)), Float64(Float64(cos(phi1) * Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -4.6e-10], N[Not[LessEqual[phi2, 4.6e+34]], $MachinePrecision]], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$0 * N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * N[(-0.001388888888888889 * N[(phi2 * phi2), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * 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}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -4.6 \cdot 10^{-10} \lor \neg \left(\phi_2 \leq 4.6 \cdot 10^{+34}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \left(\phi_2 \cdot \phi_2\right) \cdot \mathsf{fma}\left(-0.001388888888888889, \phi_2 \cdot \phi_2, 0.041666666666666664\right) - 0.5, 1\right)}{\cos \phi_1 \cdot \left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2\right) - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -4.60000000000000014e-10 or 4.5999999999999996e34 < phi2 Initial program 76.0%
Taylor expanded in phi1 around 0
lift-sin.f6448.4
Applied rewrites48.4%
if -4.60000000000000014e-10 < phi2 < 4.5999999999999996e34Initial program 80.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6477.6
Applied rewrites77.6%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6477.8
Applied rewrites77.8%
Final simplification64.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -4.6e-10) (not (<= phi2 4.6e+34)))
(atan2 (* t_0 (cos phi2)) (sin phi2))
(atan2
(*
t_0
(fma
(* phi2 phi2)
(-
(*
(* phi2 phi2)
(fma -0.001388888888888889 (* phi2 phi2) 0.041666666666666664))
0.5)
1.0))
(-
(* (cos phi1) (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))
(*
(*
(sin phi1)
(fma
(* phi2 phi2)
(- (* 0.041666666666666664 (* phi2 phi2)) 0.5)
1.0))
(cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -4.6e-10) || !(phi2 <= 4.6e+34)) {
tmp = atan2((t_0 * cos(phi2)), sin(phi2));
} else {
tmp = atan2((t_0 * fma((phi2 * phi2), (((phi2 * phi2) * fma(-0.001388888888888889, (phi2 * phi2), 0.041666666666666664)) - 0.5), 1.0)), ((cos(phi1) * (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - ((sin(phi1) * fma((phi2 * phi2), ((0.041666666666666664 * (phi2 * phi2)) - 0.5), 1.0)) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -4.6e-10) || !(phi2 <= 4.6e+34)) tmp = atan(Float64(t_0 * cos(phi2)), sin(phi2)); else tmp = atan(Float64(t_0 * fma(Float64(phi2 * phi2), Float64(Float64(Float64(phi2 * phi2) * fma(-0.001388888888888889, Float64(phi2 * phi2), 0.041666666666666664)) - 0.5), 1.0)), Float64(Float64(cos(phi1) * Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - Float64(Float64(sin(phi1) * fma(Float64(phi2 * phi2), Float64(Float64(0.041666666666666664 * Float64(phi2 * phi2)) - 0.5), 1.0)) * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -4.6e-10], N[Not[LessEqual[phi2, 4.6e+34]], $MachinePrecision]], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$0 * N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * N[(-0.001388888888888889 * N[(phi2 * phi2), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(0.041666666666666664 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -4.6 \cdot 10^{-10} \lor \neg \left(\phi_2 \leq 4.6 \cdot 10^{+34}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \left(\phi_2 \cdot \phi_2\right) \cdot \mathsf{fma}\left(-0.001388888888888889, \phi_2 \cdot \phi_2, 0.041666666666666664\right) - 0.5, 1\right)}{\cos \phi_1 \cdot \left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2\right) - \left(\sin \phi_1 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, 0.041666666666666664 \cdot \left(\phi_2 \cdot \phi_2\right) - 0.5, 1\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -4.60000000000000014e-10 or 4.5999999999999996e34 < phi2 Initial program 76.0%
Taylor expanded in phi1 around 0
lift-sin.f6448.4
Applied rewrites48.4%
if -4.60000000000000014e-10 < phi2 < 4.5999999999999996e34Initial program 80.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6477.6
Applied rewrites77.6%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6477.7
Applied rewrites77.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6477.8
Applied rewrites77.8%
Final simplification64.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -4.6e-10) (not (<= phi2 4.6e+34)))
(atan2 (* t_0 (cos phi2)) (sin phi2))
(atan2
(* t_0 (fma -0.5 (* phi2 phi2) 1.0))
(-
(* (cos phi1) (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))
(*
(*
(sin phi1)
(fma
(* phi2 phi2)
(- (* 0.041666666666666664 (* phi2 phi2)) 0.5)
1.0))
(cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -4.6e-10) || !(phi2 <= 4.6e+34)) {
tmp = atan2((t_0 * cos(phi2)), sin(phi2));
} else {
tmp = atan2((t_0 * fma(-0.5, (phi2 * phi2), 1.0)), ((cos(phi1) * (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - ((sin(phi1) * fma((phi2 * phi2), ((0.041666666666666664 * (phi2 * phi2)) - 0.5), 1.0)) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -4.6e-10) || !(phi2 <= 4.6e+34)) tmp = atan(Float64(t_0 * cos(phi2)), sin(phi2)); else tmp = atan(Float64(t_0 * fma(-0.5, Float64(phi2 * phi2), 1.0)), Float64(Float64(cos(phi1) * Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - Float64(Float64(sin(phi1) * fma(Float64(phi2 * phi2), Float64(Float64(0.041666666666666664 * Float64(phi2 * phi2)) - 0.5), 1.0)) * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -4.6e-10], N[Not[LessEqual[phi2, 4.6e+34]], $MachinePrecision]], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$0 * N[(-0.5 * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(0.041666666666666664 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -4.6 \cdot 10^{-10} \lor \neg \left(\phi_2 \leq 4.6 \cdot 10^{+34}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \mathsf{fma}\left(-0.5, \phi_2 \cdot \phi_2, 1\right)}{\cos \phi_1 \cdot \left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2\right) - \left(\sin \phi_1 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, 0.041666666666666664 \cdot \left(\phi_2 \cdot \phi_2\right) - 0.5, 1\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -4.60000000000000014e-10 or 4.5999999999999996e34 < phi2 Initial program 76.0%
Taylor expanded in phi1 around 0
lift-sin.f6448.4
Applied rewrites48.4%
if -4.60000000000000014e-10 < phi2 < 4.5999999999999996e34Initial program 80.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6477.6
Applied rewrites77.6%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6477.7
Applied rewrites77.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6477.8
Applied rewrites77.8%
Final simplification64.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (or (<= phi2 -4.6e-10) (not (<= phi2 4.6e+34)))
(atan2 t_0 (sin phi2))
(atan2
t_0
(-
(* 1.0 (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))
(*
(*
(sin phi1)
(fma
(* phi2 phi2)
(- (* 0.041666666666666664 (* phi2 phi2)) 0.5)
1.0))
(cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if ((phi2 <= -4.6e-10) || !(phi2 <= 4.6e+34)) {
tmp = atan2(t_0, sin(phi2));
} else {
tmp = atan2(t_0, ((1.0 * (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - ((sin(phi1) * fma((phi2 * phi2), ((0.041666666666666664 * (phi2 * phi2)) - 0.5), 1.0)) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if ((phi2 <= -4.6e-10) || !(phi2 <= 4.6e+34)) tmp = atan(t_0, sin(phi2)); else tmp = atan(t_0, Float64(Float64(1.0 * Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)) - Float64(Float64(sin(phi1) * fma(Float64(phi2 * phi2), Float64(Float64(0.041666666666666664 * Float64(phi2 * phi2)) - 0.5), 1.0)) * cos(Float64(lambda1 - lambda2))))); 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[Or[LessEqual[phi2, -4.6e-10], N[Not[LessEqual[phi2, 4.6e+34]], $MachinePrecision]], N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(1.0 * N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(0.041666666666666664 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $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 -4.6 \cdot 10^{-10} \lor \neg \left(\phi_2 \leq 4.6 \cdot 10^{+34}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{1 \cdot \left(\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2\right) - \left(\sin \phi_1 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, 0.041666666666666664 \cdot \left(\phi_2 \cdot \phi_2\right) - 0.5, 1\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -4.60000000000000014e-10 or 4.5999999999999996e34 < phi2 Initial program 76.0%
Taylor expanded in phi1 around 0
lift-sin.f6448.4
Applied rewrites48.4%
if -4.60000000000000014e-10 < phi2 < 4.5999999999999996e34Initial program 80.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6477.6
Applied rewrites77.6%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6477.7
Applied rewrites77.7%
Taylor expanded in phi1 around 0
Applied rewrites77.6%
Final simplification64.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (or (<= phi1 -1.28e-20) (not (<= phi1 1.1e-28)))
(atan2 t_0 (* (cos (- lambda1 lambda2)) (- (sin phi1))))
(atan2 t_0 (sin phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if ((phi1 <= -1.28e-20) || !(phi1 <= 1.1e-28)) {
tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1)));
} else {
tmp = atan2(t_0, 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) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2)) * cos(phi2)
if ((phi1 <= (-1.28d-20)) .or. (.not. (phi1 <= 1.1d-28))) then
tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1)))
else
tmp = atan2(t_0, sin(phi2))
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 tmp;
if ((phi1 <= -1.28e-20) || !(phi1 <= 1.1e-28)) {
tmp = Math.atan2(t_0, (Math.cos((lambda1 - lambda2)) * -Math.sin(phi1)));
} else {
tmp = Math.atan2(t_0, Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if (phi1 <= -1.28e-20) or not (phi1 <= 1.1e-28): tmp = math.atan2(t_0, (math.cos((lambda1 - lambda2)) * -math.sin(phi1))) else: tmp = math.atan2(t_0, math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if ((phi1 <= -1.28e-20) || !(phi1 <= 1.1e-28)) tmp = atan(t_0, Float64(cos(Float64(lambda1 - lambda2)) * Float64(-sin(phi1)))); else tmp = atan(t_0, sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if ((phi1 <= -1.28e-20) || ~((phi1 <= 1.1e-28))) tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1))); else tmp = atan2(t_0, sin(phi2)); 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]}, If[Or[LessEqual[phi1, -1.28e-20], N[Not[LessEqual[phi1, 1.1e-28]], $MachinePrecision]], N[ArcTan[t$95$0 / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[Sin[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_1 \leq -1.28 \cdot 10^{-20} \lor \neg \left(\phi_1 \leq 1.1 \cdot 10^{-28}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \left(\lambda_1 - \lambda_2\right) \cdot \left(-\sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\end{array}
\end{array}
if phi1 < -1.2800000000000001e-20 or 1.09999999999999998e-28 < phi1 Initial program 76.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.f6451.7
Applied rewrites51.7%
if -1.2800000000000001e-20 < phi1 < 1.09999999999999998e-28Initial program 81.6%
Taylor expanded in phi1 around 0
lift-sin.f6480.7
Applied rewrites80.7%
Final simplification63.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -8.8e-15) (not (<= phi2 1.02e-20)))
(atan2 (* t_0 (cos phi2)) (sin phi2))
(atan2 t_0 (* (cos (- lambda1 lambda2)) (- (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -8.8e-15) || !(phi2 <= 1.02e-20)) {
tmp = atan2((t_0 * cos(phi2)), sin(phi2));
} else {
tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1)));
}
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 = sin((lambda1 - lambda2))
if ((phi2 <= (-8.8d-15)) .or. (.not. (phi2 <= 1.02d-20))) then
tmp = atan2((t_0 * cos(phi2)), sin(phi2))
else
tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1)))
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 tmp;
if ((phi2 <= -8.8e-15) || !(phi2 <= 1.02e-20)) {
tmp = Math.atan2((t_0 * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2(t_0, (Math.cos((lambda1 - lambda2)) * -Math.sin(phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi2 <= -8.8e-15) or not (phi2 <= 1.02e-20): tmp = math.atan2((t_0 * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2(t_0, (math.cos((lambda1 - lambda2)) * -math.sin(phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -8.8e-15) || !(phi2 <= 1.02e-20)) tmp = atan(Float64(t_0 * cos(phi2)), sin(phi2)); else tmp = atan(t_0, Float64(cos(Float64(lambda1 - lambda2)) * Float64(-sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi2 <= -8.8e-15) || ~((phi2 <= 1.02e-20))) tmp = atan2((t_0 * cos(phi2)), sin(phi2)); else tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -8.8e-15], N[Not[LessEqual[phi2, 1.02e-20]], $MachinePrecision]], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -8.8 \cdot 10^{-15} \lor \neg \left(\phi_2 \leq 1.02 \cdot 10^{-20}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \left(\lambda_1 - \lambda_2\right) \cdot \left(-\sin \phi_1\right)}\\
\end{array}
\end{array}
if phi2 < -8.79999999999999942e-15 or 1.02000000000000001e-20 < phi2 Initial program 75.5%
Taylor expanded in phi1 around 0
lift-sin.f6447.4
Applied rewrites47.4%
if -8.79999999999999942e-15 < phi2 < 1.02000000000000001e-20Initial program 81.5%
Taylor expanded in phi1 around 0
lift-sin.f6444.5
Applied rewrites44.5%
Taylor expanded in phi2 around 0
sin-cos-mult-revN/A
lift-sin.f64N/A
lift--.f6444.5
Applied rewrites44.5%
Taylor expanded in phi2 around 0
Applied rewrites44.5%
Taylor expanded in phi2 around 0
lower-*.f64N/A
cos-diff-revN/A
lower-*.f64N/A
cos-diff-revN/A
lower-cos.f64N/A
lift--.f64N/A
lift-sin.f6478.7
Applied rewrites78.7%
Final simplification62.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (or (<= lambda1 -8.8e-47) (not (<= lambda1 1.5e-36))) (atan2 (* (sin lambda1) (cos phi2)) (sin phi2)) (atan2 (* (sin (- lambda2)) (cos phi2)) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -8.8e-47) || !(lambda1 <= 1.5e-36)) {
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2));
} else {
tmp = atan2((sin(-lambda2) * 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 ((lambda1 <= (-8.8d-47)) .or. (.not. (lambda1 <= 1.5d-36))) then
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2))
else
tmp = atan2((sin(-lambda2) * 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 ((lambda1 <= -8.8e-47) || !(lambda1 <= 1.5e-36)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda1 <= -8.8e-47) or not (lambda1 <= 1.5e-36): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda1 <= -8.8e-47) || !(lambda1 <= 1.5e-36)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda1 <= -8.8e-47) || ~((lambda1 <= 1.5e-36))) tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = atan2((sin(-lambda2) * cos(phi2)), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda1, -8.8e-47], N[Not[LessEqual[lambda1, 1.5e-36]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -8.8 \cdot 10^{-47} \lor \neg \left(\lambda_1 \leq 1.5 \cdot 10^{-36}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if lambda1 < -8.80000000000000075e-47 or 1.5000000000000001e-36 < lambda1 Initial program 63.4%
Taylor expanded in phi1 around 0
lift-sin.f6442.8
Applied rewrites42.8%
Taylor expanded in lambda1 around inf
Applied rewrites45.1%
if -8.80000000000000075e-47 < lambda1 < 1.5000000000000001e-36Initial program 99.8%
Taylor expanded in phi1 around 0
lift-sin.f6450.3
Applied rewrites50.3%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6445.4
Applied rewrites45.4%
Final simplification45.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (or (<= lambda1 -1.8e-46) (not (<= lambda1 1.46e-83))) (atan2 (* (sin lambda1) (cos phi2)) (sin phi2)) (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -1.8e-46) || !(lambda1 <= 1.46e-83)) {
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(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 ((lambda1 <= (-1.8d-46)) .or. (.not. (lambda1 <= 1.46d-83))) then
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -1.8e-46) || !(lambda1 <= 1.46e-83)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), phi2);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda1 <= -1.8e-46) or not (lambda1 <= 1.46e-83): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), phi2) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda1 <= -1.8e-46) || !(lambda1 <= 1.46e-83)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), phi2); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda1 <= -1.8e-46) || ~((lambda1 <= 1.46e-83))) tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda1, -1.8e-46], N[Not[LessEqual[lambda1, 1.46e-83]], $MachinePrecision]], 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] / phi2], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -1.8 \cdot 10^{-46} \lor \neg \left(\lambda_1 \leq 1.46 \cdot 10^{-83}\right):\\
\;\;\;\;\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}{\phi_2}\\
\end{array}
\end{array}
if lambda1 < -1.8e-46 or 1.4600000000000001e-83 < lambda1 Initial program 64.8%
Taylor expanded in phi1 around 0
lift-sin.f6442.9
Applied rewrites42.9%
Taylor expanded in lambda1 around inf
Applied rewrites43.9%
if -1.8e-46 < lambda1 < 1.4600000000000001e-83Initial program 99.7%
Taylor expanded in phi1 around 0
lift-sin.f6450.6
Applied rewrites50.6%
Taylor expanded in phi2 around 0
Applied rewrites38.5%
Final simplification41.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 78.5%
Taylor expanded in phi1 around 0
lift-sin.f6445.9
Applied rewrites45.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 2.15)
(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 <= 2.15) {
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 <= 2.15d0) 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 <= 2.15) {
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 <= 2.15: 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 <= 2.15) 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 <= 2.15) 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, 2.15], 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 2.15:\\
\;\;\;\;\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.14999999999999991Initial program 77.6%
Taylor expanded in phi1 around 0
lift-sin.f6445.8
Applied rewrites45.8%
Taylor expanded in phi2 around 0
Applied rewrites39.7%
if 2.14999999999999991 < phi2 Initial program 82.1%
Taylor expanded in phi1 around 0
lift-sin.f6446.4
Applied rewrites46.4%
Taylor expanded in lambda1 around 0
+-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.f6431.4
Applied rewrites31.4%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6419.5
Applied rewrites19.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 -2.2)
(atan2 t_0 phi2)
(atan2 t_0 (* phi2 (fma -0.16666666666666666 (* phi2 phi2) 1.0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi2 <= -2.2) {
tmp = atan2(t_0, phi2);
} else {
tmp = atan2(t_0, (phi2 * fma(-0.16666666666666666, (phi2 * phi2), 1.0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi2 <= -2.2) tmp = atan(t_0, phi2); else tmp = atan(t_0, Float64(phi2 * fma(-0.16666666666666666, Float64(phi2 * phi2), 1.0))); 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, -2.2], N[ArcTan[t$95$0 / phi2], $MachinePrecision], N[ArcTan[t$95$0 / N[(phi2 * N[(-0.16666666666666666 * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]), $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 -2.2:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2 \cdot \mathsf{fma}\left(-0.16666666666666666, \phi_2 \cdot \phi_2, 1\right)}\\
\end{array}
\end{array}
if phi2 < -2.2000000000000002Initial program 72.0%
Taylor expanded in phi1 around 0
lift-sin.f6446.8
Applied rewrites46.8%
Taylor expanded in phi2 around 0
Applied rewrites28.7%
if -2.2000000000000002 < phi2 Initial program 80.7%
Taylor expanded in phi1 around 0
lift-sin.f6445.6
Applied rewrites45.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6438.0
Applied rewrites38.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 1e+62) (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 <= 1e+62) {
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 <= 1d+62) 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 <= 1e+62) {
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 <= 1e+62: 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 <= 1e+62) 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 <= 1e+62) 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, 1e+62], 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 10^{+62}:\\
\;\;\;\;\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 < 1.00000000000000004e62Initial program 77.6%
Taylor expanded in phi1 around 0
lift-sin.f6444.7
Applied rewrites44.7%
Taylor expanded in phi2 around 0
Applied rewrites38.3%
if 1.00000000000000004e62 < phi2 Initial program 83.1%
Taylor expanded in phi1 around 0
lift-sin.f6452.0
Applied rewrites52.0%
Taylor expanded in lambda1 around 0
+-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.f6436.4
Applied rewrites36.4%
Taylor expanded in lambda2 around 0
Applied rewrites18.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 -0.065) (atan2 (* lambda1 (cos phi2)) (sin phi2)) (atan2 (sin (- lambda1 lambda2)) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -0.065) {
tmp = atan2((lambda1 * cos(phi2)), sin(phi2));
} else {
tmp = atan2(sin((lambda1 - lambda2)), 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 <= (-0.065d0)) then
tmp = atan2((lambda1 * cos(phi2)), sin(phi2))
else
tmp = atan2(sin((lambda1 - lambda2)), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -0.065) {
tmp = Math.atan2((lambda1 * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= -0.065: tmp = math.atan2((lambda1 * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2(math.sin((lambda1 - lambda2)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -0.065) tmp = atan(Float64(lambda1 * cos(phi2)), sin(phi2)); else tmp = atan(sin(Float64(lambda1 - lambda2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= -0.065) tmp = atan2((lambda1 * cos(phi2)), sin(phi2)); else tmp = atan2(sin((lambda1 - lambda2)), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -0.065], N[ArcTan[N[(lambda1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -0.065:\\
\;\;\;\;\tan^{-1}_* \frac{\lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < -0.065000000000000002Initial program 71.0%
Taylor expanded in phi1 around 0
lift-sin.f6446.1
Applied rewrites46.1%
Taylor expanded in lambda1 around 0
+-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.f6440.5
Applied rewrites40.5%
Taylor expanded in lambda2 around 0
Applied rewrites21.1%
if -0.065000000000000002 < phi2 Initial program 81.1%
Taylor expanded in phi1 around 0
lift-sin.f6445.8
Applied rewrites45.8%
Taylor expanded in phi2 around 0
sin-cos-mult-revN/A
lift-sin.f64N/A
lift--.f6436.5
Applied rewrites36.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 -1.25e+74) (atan2 (- (sin lambda2)) phi2) (atan2 (sin (- lambda1 lambda2)) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -1.25e+74) {
tmp = atan2(-sin(lambda2), phi2);
} else {
tmp = atan2(sin((lambda1 - lambda2)), 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 <= (-1.25d+74)) then
tmp = atan2(-sin(lambda2), phi2)
else
tmp = atan2(sin((lambda1 - lambda2)), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -1.25e+74) {
tmp = Math.atan2(-Math.sin(lambda2), phi2);
} else {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= -1.25e+74: tmp = math.atan2(-math.sin(lambda2), phi2) else: tmp = math.atan2(math.sin((lambda1 - lambda2)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -1.25e+74) tmp = atan(Float64(-sin(lambda2)), phi2); else tmp = atan(sin(Float64(lambda1 - lambda2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= -1.25e+74) tmp = atan2(-sin(lambda2), phi2); else tmp = atan2(sin((lambda1 - lambda2)), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -1.25e+74], N[ArcTan[(-N[Sin[lambda2], $MachinePrecision]) / phi2], $MachinePrecision], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -1.25 \cdot 10^{+74}:\\
\;\;\;\;\tan^{-1}_* \frac{-\sin \lambda_2}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < -1.24999999999999991e74Initial program 72.2%
Taylor expanded in phi1 around 0
lift-sin.f6448.4
Applied rewrites48.4%
Taylor expanded in phi2 around 0
sin-cos-mult-revN/A
lift-sin.f64N/A
lift--.f6411.4
Applied rewrites11.4%
Taylor expanded in phi2 around 0
Applied rewrites11.8%
Taylor expanded in lambda1 around 0
sin-neg-revN/A
lift-sin.f64N/A
lift-neg.f6420.7
Applied rewrites20.7%
if -1.24999999999999991e74 < phi2 Initial program 80.1%
Taylor expanded in phi1 around 0
lift-sin.f6445.3
Applied rewrites45.3%
Taylor expanded in phi2 around 0
sin-cos-mult-revN/A
lift-sin.f64N/A
lift--.f6434.9
Applied rewrites34.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -0.00092)
(atan2 (- (sin lambda2)) phi2)
(atan2
(sin (- lambda1 lambda2))
(*
phi2
(fma
(* phi2 phi2)
(-
(*
(* phi2 phi2)
(fma -0.0001984126984126984 (* phi2 phi2) 0.008333333333333333))
0.16666666666666666)
1.0)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -0.00092) {
tmp = atan2(-sin(lambda2), phi2);
} else {
tmp = atan2(sin((lambda1 - lambda2)), (phi2 * fma((phi2 * phi2), (((phi2 * phi2) * fma(-0.0001984126984126984, (phi2 * phi2), 0.008333333333333333)) - 0.16666666666666666), 1.0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -0.00092) tmp = atan(Float64(-sin(lambda2)), phi2); else tmp = atan(sin(Float64(lambda1 - lambda2)), Float64(phi2 * fma(Float64(phi2 * phi2), Float64(Float64(Float64(phi2 * phi2) * fma(-0.0001984126984126984, Float64(phi2 * phi2), 0.008333333333333333)) - 0.16666666666666666), 1.0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -0.00092], N[ArcTan[(-N[Sin[lambda2], $MachinePrecision]) / phi2], $MachinePrecision], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(phi2 * N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * N[(-0.0001984126984126984 * N[(phi2 * phi2), $MachinePrecision] + 0.008333333333333333), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -0.00092:\\
\;\;\;\;\tan^{-1}_* \frac{-\sin \lambda_2}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, \left(\phi_2 \cdot \phi_2\right) \cdot \mathsf{fma}\left(-0.0001984126984126984, \phi_2 \cdot \phi_2, 0.008333333333333333\right) - 0.16666666666666666, 1\right)}\\
\end{array}
\end{array}
if phi2 < -9.2000000000000003e-4Initial program 71.4%
Taylor expanded in phi1 around 0
lift-sin.f6446.9
Applied rewrites46.9%
Taylor expanded in phi2 around 0
sin-cos-mult-revN/A
lift-sin.f64N/A
lift--.f6412.5
Applied rewrites12.5%
Taylor expanded in phi2 around 0
Applied rewrites12.3%
Taylor expanded in lambda1 around 0
sin-neg-revN/A
lift-sin.f64N/A
lift-neg.f6418.6
Applied rewrites18.6%
if -9.2000000000000003e-4 < phi2 Initial program 81.0%
Taylor expanded in phi1 around 0
lift-sin.f6445.6
Applied rewrites45.6%
Taylor expanded in phi2 around 0
sin-cos-mult-revN/A
lift-sin.f64N/A
lift--.f6436.4
Applied rewrites36.4%
Taylor expanded in phi2 around 0
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6436.0
Applied rewrites36.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -0.00092)
(atan2 (- (sin lambda2)) phi2)
(atan2
(sin (- lambda1 lambda2))
(* phi2 (fma -0.16666666666666666 (* phi2 phi2) 1.0)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -0.00092) {
tmp = atan2(-sin(lambda2), phi2);
} else {
tmp = atan2(sin((lambda1 - lambda2)), (phi2 * fma(-0.16666666666666666, (phi2 * phi2), 1.0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -0.00092) tmp = atan(Float64(-sin(lambda2)), phi2); else tmp = atan(sin(Float64(lambda1 - lambda2)), Float64(phi2 * fma(-0.16666666666666666, Float64(phi2 * phi2), 1.0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -0.00092], N[ArcTan[(-N[Sin[lambda2], $MachinePrecision]) / phi2], $MachinePrecision], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(phi2 * N[(-0.16666666666666666 * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -0.00092:\\
\;\;\;\;\tan^{-1}_* \frac{-\sin \lambda_2}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2 \cdot \mathsf{fma}\left(-0.16666666666666666, \phi_2 \cdot \phi_2, 1\right)}\\
\end{array}
\end{array}
if phi2 < -9.2000000000000003e-4Initial program 71.4%
Taylor expanded in phi1 around 0
lift-sin.f6446.9
Applied rewrites46.9%
Taylor expanded in phi2 around 0
sin-cos-mult-revN/A
lift-sin.f64N/A
lift--.f6412.5
Applied rewrites12.5%
Taylor expanded in phi2 around 0
Applied rewrites12.3%
Taylor expanded in lambda1 around 0
sin-neg-revN/A
lift-sin.f64N/A
lift-neg.f6418.6
Applied rewrites18.6%
if -9.2000000000000003e-4 < phi2 Initial program 81.0%
Taylor expanded in phi1 around 0
lift-sin.f6445.6
Applied rewrites45.6%
Taylor expanded in phi2 around 0
sin-cos-mult-revN/A
lift-sin.f64N/A
lift--.f6436.4
Applied rewrites36.4%
Taylor expanded in phi2 around 0
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6436.0
Applied rewrites36.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (or (<= lambda1 -7.5e-83) (not (<= lambda1 4.6e-34))) (atan2 (sin lambda1) phi2) (atan2 (- (sin lambda2)) phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -7.5e-83) || !(lambda1 <= 4.6e-34)) {
tmp = atan2(sin(lambda1), phi2);
} else {
tmp = atan2(-sin(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 ((lambda1 <= (-7.5d-83)) .or. (.not. (lambda1 <= 4.6d-34))) then
tmp = atan2(sin(lambda1), phi2)
else
tmp = atan2(-sin(lambda2), phi2)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -7.5e-83) || !(lambda1 <= 4.6e-34)) {
tmp = Math.atan2(Math.sin(lambda1), phi2);
} else {
tmp = Math.atan2(-Math.sin(lambda2), phi2);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda1 <= -7.5e-83) or not (lambda1 <= 4.6e-34): tmp = math.atan2(math.sin(lambda1), phi2) else: tmp = math.atan2(-math.sin(lambda2), phi2) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda1 <= -7.5e-83) || !(lambda1 <= 4.6e-34)) tmp = atan(sin(lambda1), phi2); else tmp = atan(Float64(-sin(lambda2)), phi2); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda1 <= -7.5e-83) || ~((lambda1 <= 4.6e-34))) tmp = atan2(sin(lambda1), phi2); else tmp = atan2(-sin(lambda2), phi2); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda1, -7.5e-83], N[Not[LessEqual[lambda1, 4.6e-34]], $MachinePrecision]], N[ArcTan[N[Sin[lambda1], $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[(-N[Sin[lambda2], $MachinePrecision]) / phi2], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -7.5 \cdot 10^{-83} \lor \neg \left(\lambda_1 \leq 4.6 \cdot 10^{-34}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{-\sin \lambda_2}{\phi_2}\\
\end{array}
\end{array}
if lambda1 < -7.4999999999999997e-83 or 4.60000000000000022e-34 < lambda1 Initial program 65.5%
Taylor expanded in phi1 around 0
lift-sin.f6444.3
Applied rewrites44.3%
Taylor expanded in phi2 around 0
sin-cos-mult-revN/A
lift-sin.f64N/A
lift--.f6429.5
Applied rewrites29.5%
Taylor expanded in phi2 around 0
Applied rewrites27.1%
Taylor expanded in lambda1 around inf
Applied rewrites29.6%
if -7.4999999999999997e-83 < lambda1 < 4.60000000000000022e-34Initial program 99.7%
Taylor expanded in phi1 around 0
lift-sin.f6448.5
Applied rewrites48.5%
Taylor expanded in phi2 around 0
sin-cos-mult-revN/A
lift-sin.f64N/A
lift--.f6430.9
Applied rewrites30.9%
Taylor expanded in phi2 around 0
Applied rewrites29.9%
Taylor expanded in lambda1 around 0
sin-neg-revN/A
lift-sin.f64N/A
lift-neg.f6431.5
Applied rewrites31.5%
Final simplification30.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 -1.25e+77) (atan2 (- (sin lambda2)) phi2) (atan2 (sin (- lambda1 lambda2)) phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -1.25e+77) {
tmp = atan2(-sin(lambda2), 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 <= (-1.25d+77)) then
tmp = atan2(-sin(lambda2), 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 <= -1.25e+77) {
tmp = Math.atan2(-Math.sin(lambda2), phi2);
} else {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), phi2);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= -1.25e+77: tmp = math.atan2(-math.sin(lambda2), phi2) else: tmp = math.atan2(math.sin((lambda1 - lambda2)), phi2) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -1.25e+77) tmp = atan(Float64(-sin(lambda2)), 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 <= -1.25e+77) tmp = atan2(-sin(lambda2), phi2); else tmp = atan2(sin((lambda1 - lambda2)), phi2); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -1.25e+77], N[ArcTan[(-N[Sin[lambda2], $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 -1.25 \cdot 10^{+77}:\\
\;\;\;\;\tan^{-1}_* \frac{-\sin \lambda_2}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2}\\
\end{array}
\end{array}
if phi2 < -1.25000000000000001e77Initial program 71.7%
Taylor expanded in phi1 around 0
lift-sin.f6449.3
Applied rewrites49.3%
Taylor expanded in phi2 around 0
sin-cos-mult-revN/A
lift-sin.f64N/A
lift--.f6411.6
Applied rewrites11.6%
Taylor expanded in phi2 around 0
Applied rewrites10.1%
Taylor expanded in lambda1 around 0
sin-neg-revN/A
lift-sin.f64N/A
lift-neg.f6419.1
Applied rewrites19.1%
if -1.25000000000000001e77 < phi2 Initial program 80.2%
Taylor expanded in phi1 around 0
lift-sin.f6445.1
Applied rewrites45.1%
Taylor expanded in phi2 around 0
sin-cos-mult-revN/A
lift-sin.f64N/A
lift--.f6434.8
Applied rewrites34.8%
Taylor expanded in phi2 around 0
Applied rewrites32.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin lambda1) phi2))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin(lambda1), 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), phi2)
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin(lambda1), phi2);
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin(lambda1), phi2)
function code(lambda1, lambda2, phi1, phi2) return atan(sin(lambda1), phi2) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin(lambda1), phi2); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[lambda1], $MachinePrecision] / phi2], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1}{\phi_2}
\end{array}
Initial program 78.5%
Taylor expanded in phi1 around 0
lift-sin.f6445.9
Applied rewrites45.9%
Taylor expanded in phi2 around 0
sin-cos-mult-revN/A
lift-sin.f64N/A
lift--.f6430.0
Applied rewrites30.0%
Taylor expanded in phi2 around 0
Applied rewrites28.1%
Taylor expanded in lambda1 around inf
Applied rewrites24.5%
herbie shell --seed 2025046
(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))))))