
(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 33 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(fma
(* (sin lambda2) (* (cos phi2) (sin phi1)))
(sin lambda1)
(* (* (* (cos lambda2) (cos lambda1)) (sin phi1)) (cos phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - fma((sin(lambda2) * (cos(phi2) * sin(phi1))), sin(lambda1), (((cos(lambda2) * cos(lambda1)) * sin(phi1)) * cos(phi2)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - fma(Float64(sin(lambda2) * Float64(cos(phi2) * sin(phi1))), sin(lambda1), Float64(Float64(Float64(cos(lambda2) * cos(lambda1)) * sin(phi1)) * cos(phi2))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[lambda2], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\sin \lambda_2\right) \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \mathsf{fma}\left(\sin \lambda_2 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right), \sin \lambda_1, \left(\left(\cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2\right)}
\end{array}
Initial program 76.0%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6487.5
Applied rewrites87.5%
lift-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
distribute-lft-inN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
Applied rewrites99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(cos phi2)
(*
(sin phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(sin(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\sin \lambda_2\right) \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)}
\end{array}
Initial program 76.0%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6487.5
Applied rewrites87.5%
lift-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
distribute-lft-inN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
Applied rewrites99.8%
Taylor expanded in lambda1 around inf
Applied rewrites99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(fma (- (sin lambda2)) (cos lambda1) (* (cos lambda2) (sin lambda1)))
(cos phi2))
(fma
(sin phi2)
(cos phi1)
(*
(- (cos phi2))
(*
(sin phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(-sin(lambda2), cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), fma(sin(phi2), cos(phi1), (-cos(phi2) * (sin(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(Float64(-sin(lambda2)), cos(lambda1), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-cos(phi2)) * Float64(sin(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[phi2], $MachinePrecision]) * N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(-\sin \lambda_2, \cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \phi_2\right) \cdot \left(\sin \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)}
\end{array}
Initial program 76.0%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6487.5
Applied rewrites87.5%
lift-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
distribute-lft-inN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.8
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
Applied rewrites99.8%
Taylor expanded in lambda1 around 0
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1)))
(cos phi2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (- t_1 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
(if (<= phi2 -4.6e-7)
(atan2
(*
(fma (sin lambda2) (- (cos lambda1)) (* (cos lambda2) (sin lambda1)))
(cos phi2))
t_2)
(if (<= phi2 2.6e-30)
(atan2
t_0
(-
t_1
(*
(sin phi1)
(fma (sin lambda1) (sin lambda2) (* (cos lambda2) (cos lambda1))))))
(atan2 t_0 t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = t_1 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)));
double tmp;
if (phi2 <= -4.6e-7) {
tmp = atan2((fma(sin(lambda2), -cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), t_2);
} else if (phi2 <= 2.6e-30) {
tmp = atan2(t_0, (t_1 - (sin(phi1) * fma(sin(lambda1), sin(lambda2), (cos(lambda2) * cos(lambda1))))));
} else {
tmp = atan2(t_0, t_2);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = Float64(t_1 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))) tmp = 0.0 if (phi2 <= -4.6e-7) tmp = atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), t_2); elseif (phi2 <= 2.6e-30) tmp = atan(t_0, Float64(t_1 - Float64(sin(phi1) * fma(sin(lambda1), sin(lambda2), Float64(cos(lambda2) * cos(lambda1)))))); else tmp = atan(t_0, t_2); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[lambda1], $MachinePrecision]), $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[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -4.6e-7], N[ArcTan[N[(N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi2, 2.6e-30], N[ArcTan[t$95$0 / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / t$95$2], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\sin \lambda_2\right) \cdot \cos \lambda_1\right) \cdot \cos \phi_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -4.6 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_2, -\cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2}{t\_2}\\
\mathbf{elif}\;\phi_2 \leq 2.6 \cdot 10^{-30}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{t\_1 - \sin \phi_1 \cdot \mathsf{fma}\left(\sin \lambda_1, \sin \lambda_2, \cos \lambda_2 \cdot \cos \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{t\_2}\\
\end{array}
\end{array}
if phi2 < -4.5999999999999999e-7Initial program 82.9%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6493.8
Applied rewrites93.8%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6493.8
Applied rewrites93.8%
if -4.5999999999999999e-7 < phi2 < 2.59999999999999987e-30Initial program 75.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6484.2
Applied rewrites84.2%
lift-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
distribute-lft-inN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
Applied rewrites99.9%
if 2.59999999999999987e-30 < phi2 Initial program 69.4%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6488.1
Applied rewrites88.1%
Final simplification95.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1)))
(cos phi2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (- t_1 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
(if (<= phi2 -4.6e-7)
(atan2
(*
(fma (sin lambda2) (- (cos lambda1)) (* (cos lambda2) (sin lambda1)))
(cos phi2))
t_2)
(if (<= phi2 2.6e-30)
(atan2
t_0
(-
t_1
(*
(sin phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2 t_0 t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = t_1 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)));
double tmp;
if (phi2 <= -4.6e-7) {
tmp = atan2((fma(sin(lambda2), -cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), t_2);
} else if (phi2 <= 2.6e-30) {
tmp = atan2(t_0, (t_1 - (sin(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_0, t_2);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = Float64(t_1 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))) tmp = 0.0 if (phi2 <= -4.6e-7) tmp = atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), t_2); elseif (phi2 <= 2.6e-30) tmp = atan(t_0, Float64(t_1 - Float64(sin(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_0, t_2); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[lambda1], $MachinePrecision]), $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[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -4.6e-7], N[ArcTan[N[(N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi2, 2.6e-30], N[ArcTan[t$95$0 / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / t$95$2], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\sin \lambda_2\right) \cdot \cos \lambda_1\right) \cdot \cos \phi_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -4.6 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_2, -\cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2}{t\_2}\\
\mathbf{elif}\;\phi_2 \leq 2.6 \cdot 10^{-30}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{t\_1 - \sin \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{t\_2}\\
\end{array}
\end{array}
if phi2 < -4.5999999999999999e-7Initial program 82.9%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6493.8
Applied rewrites93.8%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6493.8
Applied rewrites93.8%
if -4.5999999999999999e-7 < phi2 < 2.59999999999999987e-30Initial program 75.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6484.2
Applied rewrites84.2%
lift-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
distribute-lft-inN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
Applied rewrites99.9%
Taylor expanded in phi2 around 0
Applied rewrites99.9%
if 2.59999999999999987e-30 < phi2 Initial program 69.4%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6488.1
Applied rewrites88.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (sin phi1) (cos phi2))))
(if (<= lambda2 -1.6e+24)
(atan2
(*
(fma (sin lambda2) (- (cos lambda1)) (* (sin lambda1) (cos lambda2)))
(cos phi2))
(- t_0 (* (cos lambda2) t_1)))
(if (<= lambda2 7.5e-6)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
t_0
(*
t_1
(fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2))))))
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1)))
(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 tmp;
if (lambda2 <= -1.6e+24) {
tmp = atan2((fma(sin(lambda2), -cos(lambda1), (sin(lambda1) * cos(lambda2))) * cos(phi2)), (t_0 - (cos(lambda2) * t_1)));
} else if (lambda2 <= 7.5e-6) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (t_1 * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))))));
} else {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2)), (t_0 - (t_1 * cos(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 (lambda2 <= -1.6e+24) tmp = atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(sin(lambda1) * cos(lambda2))) * cos(phi2)), Float64(t_0 - Float64(cos(lambda2) * t_1))); elseif (lambda2 <= 7.5e-6) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(t_1 * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2)))))); else tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(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[LessEqual[lambda2, -1.6e+24], N[ArcTan[N[(N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 7.5e-6], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $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\\
\mathbf{if}\;\lambda_2 \leq -1.6 \cdot 10^{+24}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_2, -\cos \lambda_1, \sin \lambda_1 \cdot \cos \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \cos \lambda_2 \cdot t\_1}\\
\mathbf{elif}\;\lambda_2 \leq 7.5 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\sin \lambda_2\right) \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\end{array}
\end{array}
if lambda2 < -1.5999999999999999e24Initial program 58.0%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6479.6
Applied rewrites79.6%
Taylor expanded in lambda1 around inf
Applied rewrites62.2%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-*.f6462.3
Applied rewrites62.3%
Taylor expanded in lambda1 around 0
Applied rewrites79.7%
if -1.5999999999999999e24 < lambda2 < 7.50000000000000019e-6Initial program 98.7%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6498.7
Applied rewrites98.7%
if 7.50000000000000019e-6 < lambda2 Initial program 49.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6473.3
Applied rewrites73.3%
Taylor expanded in lambda1 around 0
Applied rewrites73.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (sin phi1) (cos phi2))))
(if (or (<= lambda2 -170000000.0) (not (<= lambda2 6e-6)))
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1)))
(cos phi2))
(- t_0 (* t_1 (cos lambda2))))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* t_1 (fma (sin lambda1) lambda2 (cos lambda1))))))))
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 ((lambda2 <= -170000000.0) || !(lambda2 <= 6e-6)) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (t_1 * fma(sin(lambda1), lambda2, cos(lambda1)))));
}
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 ((lambda2 <= -170000000.0) || !(lambda2 <= 6e-6)) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda2)))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(t_1 * fma(sin(lambda1), lambda2, cos(lambda1))))); 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[lambda2, -170000000.0], N[Not[LessEqual[lambda2, 6e-6]], $MachinePrecision]], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[Sin[lambda1], $MachinePrecision] * lambda2 + N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\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}\;\lambda_2 \leq -170000000 \lor \neg \left(\lambda_2 \leq 6 \cdot 10^{-6}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\sin \lambda_2\right) \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \mathsf{fma}\left(\sin \lambda_1, \lambda_2, \cos \lambda_1\right)}\\
\end{array}
\end{array}
if lambda2 < -1.7e8 or 6.0000000000000002e-6 < lambda2 Initial program 54.1%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6476.3
Applied rewrites76.3%
Taylor expanded in lambda1 around 0
Applied rewrites76.4%
if -1.7e8 < lambda2 < 6.0000000000000002e-6Initial program 99.3%
Taylor expanded in lambda2 around 0
Applied rewrites99.4%
Final simplification87.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (sin phi1) (cos phi2))))
(if (<= lambda2 -170000000.0)
(atan2
(*
(fma (sin lambda2) (- (cos lambda1)) (* (sin lambda1) (cos lambda2)))
(cos phi2))
(- t_0 (* (cos lambda2) t_1)))
(if (<= lambda2 6e-6)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* t_1 (fma (sin lambda1) lambda2 (cos lambda1)))))
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1)))
(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 tmp;
if (lambda2 <= -170000000.0) {
tmp = atan2((fma(sin(lambda2), -cos(lambda1), (sin(lambda1) * cos(lambda2))) * cos(phi2)), (t_0 - (cos(lambda2) * t_1)));
} else if (lambda2 <= 6e-6) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (t_1 * fma(sin(lambda1), lambda2, cos(lambda1)))));
} else {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2)), (t_0 - (t_1 * cos(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 (lambda2 <= -170000000.0) tmp = atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(sin(lambda1) * cos(lambda2))) * cos(phi2)), Float64(t_0 - Float64(cos(lambda2) * t_1))); elseif (lambda2 <= 6e-6) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(t_1 * fma(sin(lambda1), lambda2, cos(lambda1))))); else tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(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[LessEqual[lambda2, -170000000.0], N[ArcTan[N[(N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 6e-6], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[Sin[lambda1], $MachinePrecision] * lambda2 + N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $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\\
\mathbf{if}\;\lambda_2 \leq -170000000:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_2, -\cos \lambda_1, \sin \lambda_1 \cdot \cos \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \cos \lambda_2 \cdot t\_1}\\
\mathbf{elif}\;\lambda_2 \leq 6 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \mathsf{fma}\left(\sin \lambda_1, \lambda_2, \cos \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\sin \lambda_2\right) \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\end{array}
\end{array}
if lambda2 < -1.7e8Initial program 58.0%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6479.0
Applied rewrites79.0%
Taylor expanded in lambda1 around inf
Applied rewrites62.1%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-*.f6462.1
Applied rewrites62.1%
Taylor expanded in lambda1 around 0
Applied rewrites79.1%
if -1.7e8 < lambda2 < 6.0000000000000002e-6Initial program 99.3%
Taylor expanded in lambda2 around 0
Applied rewrites99.4%
if 6.0000000000000002e-6 < lambda2 Initial program 49.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6473.3
Applied rewrites73.3%
Taylor expanded in lambda1 around 0
Applied rewrites73.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1))) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\sin \lambda_2\right) \cdot \cos \lambda_1\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 76.0%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6487.5
Applied rewrites87.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (cos lambda2) (sin lambda1)) (* (sin lambda2) (cos lambda1))) (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((((cos(lambda2) * sin(lambda1)) - (sin(lambda2) * cos(lambda1))) * 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((((cos(lambda2) * sin(lambda1)) - (sin(lambda2) * cos(lambda1))) * 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.cos(lambda2) * Math.sin(lambda1)) - (Math.sin(lambda2) * Math.cos(lambda1))) * 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.cos(lambda2) * math.sin(lambda1)) - (math.sin(lambda2) * math.cos(lambda1))) * 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(cos(lambda2) * sin(lambda1)) - Float64(sin(lambda2) * cos(lambda1))) * 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((((cos(lambda2) * sin(lambda1)) - (sin(lambda2) * cos(lambda1))) * 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[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $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(\cos \lambda_2 \cdot \sin \lambda_1 - \sin \lambda_2 \cdot \cos \lambda_1\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 76.0%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6487.4
Applied rewrites87.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (* (sin phi1) (cos (- lambda1 lambda2)))))
(if (<= phi1 -48000000.0)
(atan2
(* t_0 (cos phi2))
(-
t_1
(*
(* (sin phi1) (cos phi2))
(/
(+
(cos (- (- (- lambda2 lambda1) lambda2) lambda1))
(cos (- lambda2 (- lambda1 (+ lambda2 lambda1)))))
(* 2.0 (cos (+ lambda2 lambda1)))))))
(if (<= phi1 1.08e+15)
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1)))
(cos phi2))
(- t_1 t_2))
(atan2
(* (cos phi2) t_0)
(fma (sin phi2) (cos phi1) (* (- (cos phi2)) t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = cos(phi1) * sin(phi2);
double t_2 = sin(phi1) * cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -48000000.0) {
tmp = atan2((t_0 * cos(phi2)), (t_1 - ((sin(phi1) * cos(phi2)) * ((cos((((lambda2 - lambda1) - lambda2) - lambda1)) + cos((lambda2 - (lambda1 - (lambda2 + lambda1))))) / (2.0 * cos((lambda2 + lambda1)))))));
} else if (phi1 <= 1.08e+15) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2)), (t_1 - t_2));
} else {
tmp = atan2((cos(phi2) * t_0), fma(sin(phi2), cos(phi1), (-cos(phi2) * t_2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -48000000.0) tmp = atan(Float64(t_0 * cos(phi2)), Float64(t_1 - Float64(Float64(sin(phi1) * cos(phi2)) * Float64(Float64(cos(Float64(Float64(Float64(lambda2 - lambda1) - lambda2) - lambda1)) + cos(Float64(lambda2 - Float64(lambda1 - Float64(lambda2 + lambda1))))) / Float64(2.0 * cos(Float64(lambda2 + lambda1))))))); elseif (phi1 <= 1.08e+15) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)), Float64(t_1 - t_2)); else tmp = atan(Float64(cos(phi2) * t_0), fma(sin(phi2), cos(phi1), Float64(Float64(-cos(phi2)) * t_2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -48000000.0], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[N[(N[(N[(lambda2 - lambda1), $MachinePrecision] - lambda2), $MachinePrecision] - lambda1), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(lambda2 - N[(lambda1 - N[(lambda2 + lambda1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * N[Cos[N[(lambda2 + lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.08e+15], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - t$95$2), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[phi2], $MachinePrecision]) * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -48000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \frac{\cos \left(\left(\left(\lambda_2 - \lambda_1\right) - \lambda_2\right) - \lambda_1\right) + \cos \left(\lambda_2 - \left(\lambda_1 - \left(\lambda_2 + \lambda_1\right)\right)\right)}{2 \cdot \cos \left(\lambda_2 + \lambda_1\right)}}\\
\mathbf{elif}\;\phi_1 \leq 1.08 \cdot 10^{+15}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\sin \lambda_2\right) \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{t\_1 - t\_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \phi_2\right) \cdot t\_2\right)}\\
\end{array}
\end{array}
if phi1 < -4.8e7Initial program 71.8%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
flip-+N/A
cos-sum-revN/A
lower-/.f64N/A
Applied rewrites71.8%
lift-/.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
cos-multN/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites71.9%
if -4.8e7 < phi1 < 1.08e15Initial program 78.5%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6496.9
Applied rewrites96.9%
Taylor expanded in phi2 around 0
Applied rewrites97.0%
if 1.08e15 < phi1 Initial program 74.3%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
flip-+N/A
cos-sum-revN/A
lower-/.f64N/A
Applied rewrites74.3%
Taylor expanded in lambda1 around 0
Applied rewrites74.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- (cos phi2)))
(t_1 (* (sin phi1) (cos (- lambda1 lambda2))))
(t_2 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi1 -48000000.0)
(atan2
t_2
(fma
(* (cos (- lambda2 lambda1)) (sin phi1))
t_0
(* (sin phi2) (cos phi1))))
(if (<= phi1 1.08e+15)
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1)))
(cos phi2))
(- (* (cos phi1) (sin phi2)) t_1))
(atan2 t_2 (fma (sin phi2) (cos phi1) (* t_0 t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = -cos(phi2);
double t_1 = sin(phi1) * cos((lambda1 - lambda2));
double t_2 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -48000000.0) {
tmp = atan2(t_2, fma((cos((lambda2 - lambda1)) * sin(phi1)), t_0, (sin(phi2) * cos(phi1))));
} else if (phi1 <= 1.08e+15) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - t_1));
} else {
tmp = atan2(t_2, fma(sin(phi2), cos(phi1), (t_0 * t_1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(-cos(phi2)) t_1 = Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))) t_2 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -48000000.0) tmp = atan(t_2, fma(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)), t_0, Float64(sin(phi2) * cos(phi1)))); elseif (phi1 <= 1.08e+15) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - t_1)); else tmp = atan(t_2, fma(sin(phi2), cos(phi1), Float64(t_0 * t_1))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = (-N[Cos[phi2], $MachinePrecision])}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -48000000.0], N[ArcTan[t$95$2 / N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0 + N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.08e+15], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\cos \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -48000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{\mathsf{fma}\left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1, t\_0, \sin \phi_2 \cdot \cos \phi_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 1.08 \cdot 10^{+15}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\sin \lambda_2\right) \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, t\_0 \cdot t\_1\right)}\\
\end{array}
\end{array}
if phi1 < -4.8e7Initial program 71.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.8
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-lft-neg-outN/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
Applied rewrites71.8%
if -4.8e7 < phi1 < 1.08e15Initial program 78.5%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6496.9
Applied rewrites96.9%
Taylor expanded in phi2 around 0
Applied rewrites97.0%
if 1.08e15 < phi1 Initial program 74.3%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
flip-+N/A
cos-sum-revN/A
lower-/.f64N/A
Applied rewrites74.3%
Taylor expanded in lambda1 around 0
Applied rewrites74.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- (cos phi2))) (t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi1 -8.8e-12)
(atan2
t_1
(fma
(* (cos (- lambda2 lambda1)) (sin phi1))
t_0
(* (sin phi2) (cos phi1))))
(if (<= phi1 36000000.0)
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1)))
(cos phi2))
(- (sin phi2) (* (* (sin phi1) (cos phi2)) (cos lambda1))))
(atan2
t_1
(fma
(sin phi2)
(cos phi1)
(* t_0 (* (sin phi1) (cos (- lambda1 lambda2))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = -cos(phi2);
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -8.8e-12) {
tmp = atan2(t_1, fma((cos((lambda2 - lambda1)) * sin(phi1)), t_0, (sin(phi2) * cos(phi1))));
} else if (phi1 <= 36000000.0) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos(lambda1))));
} else {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), (t_0 * (sin(phi1) * cos((lambda1 - lambda2))))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(-cos(phi2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -8.8e-12) tmp = atan(t_1, fma(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)), t_0, Float64(sin(phi2) * cos(phi1)))); elseif (phi1 <= 36000000.0) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)), Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda1)))); else tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(t_0 * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = (-N[Cos[phi2], $MachinePrecision])}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -8.8e-12], N[ArcTan[t$95$1 / N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0 + N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 36000000.0], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(t$95$0 * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\cos \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -8.8 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1, t\_0, \sin \phi_2 \cdot \cos \phi_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 36000000:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\sin \lambda_2\right) \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, t\_0 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)}\\
\end{array}
\end{array}
if phi1 < -8.79999999999999966e-12Initial program 73.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6473.0
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-lft-neg-outN/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
Applied rewrites73.0%
if -8.79999999999999966e-12 < phi1 < 3.6e7Initial program 78.6%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6498.3
Applied rewrites98.3%
Taylor expanded in lambda1 around inf
Applied rewrites98.3%
Taylor expanded in phi1 around 0
Applied rewrites98.3%
if 3.6e7 < phi1 Initial program 73.8%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
flip-+N/A
cos-sum-revN/A
lower-/.f64N/A
Applied rewrites73.8%
Taylor expanded in lambda1 around 0
Applied rewrites73.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= lambda2 -170000000.0)
(atan2 t_1 (- t_0 (* (* (cos lambda2) (sin phi1)) (cos phi2))))
(if (<= lambda2 3050000.0)
(atan2
t_1
(-
(* (sin phi2) (cos phi1))
(* (* (cos lambda1) (sin phi1)) (cos phi2))))
(atan2
(* (sin (- lambda2)) (cos phi2))
(- t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (lambda2 <= -170000000.0) {
tmp = atan2(t_1, (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))));
} else if (lambda2 <= 3050000.0) {
tmp = atan2(t_1, ((sin(phi2) * cos(phi1)) - ((cos(lambda1) * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin((lambda1 - lambda2)) * cos(phi2)
if (lambda2 <= (-170000000.0d0)) then
tmp = atan2(t_1, (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))))
else if (lambda2 <= 3050000.0d0) then
tmp = atan2(t_1, ((sin(phi2) * cos(phi1)) - ((cos(lambda1) * sin(phi1)) * cos(phi2))))
else
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double tmp;
if (lambda2 <= -170000000.0) {
tmp = Math.atan2(t_1, (t_0 - ((Math.cos(lambda2) * Math.sin(phi1)) * Math.cos(phi2))));
} else if (lambda2 <= 3050000.0) {
tmp = Math.atan2(t_1, ((Math.sin(phi2) * Math.cos(phi1)) - ((Math.cos(lambda1) * Math.sin(phi1)) * Math.cos(phi2))));
} else {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if lambda2 <= -170000000.0: tmp = math.atan2(t_1, (t_0 - ((math.cos(lambda2) * math.sin(phi1)) * math.cos(phi2)))) elif lambda2 <= 3050000.0: tmp = math.atan2(t_1, ((math.sin(phi2) * math.cos(phi1)) - ((math.cos(lambda1) * math.sin(phi1)) * math.cos(phi2)))) else: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_0 - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (lambda2 <= -170000000.0) tmp = atan(t_1, Float64(t_0 - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2)))); elseif (lambda2 <= 3050000.0) tmp = atan(t_1, Float64(Float64(sin(phi2) * cos(phi1)) - Float64(Float64(cos(lambda1) * sin(phi1)) * cos(phi2)))); else tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if (lambda2 <= -170000000.0) tmp = atan2(t_1, (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2)))); elseif (lambda2 <= 3050000.0) tmp = atan2(t_1, ((sin(phi2) * cos(phi1)) - ((cos(lambda1) * sin(phi1)) * cos(phi2)))); else tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -170000000.0], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 3050000.0], N[ArcTan[t$95$1 / N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -170000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{elif}\;\lambda_2 \leq 3050000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 \cdot \cos \phi_1 - \left(\cos \lambda_1 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda2 < -1.7e8Initial program 58.0%
Taylor expanded in lambda1 around 0
Applied rewrites57.9%
if -1.7e8 < lambda2 < 3.05e6Initial program 97.6%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6498.7
Applied rewrites98.7%
Taylor expanded in lambda1 around inf
Applied rewrites98.7%
lift-fma.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
fp-cancel-sub-signN/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-sin.f64N/A
sin-diffN/A
lift--.f64N/A
lift-sin.f6497.6
Applied rewrites97.7%
if 3.05e6 < lambda2 Initial program 47.5%
Taylor expanded in lambda1 around 0
Applied rewrites51.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (sin phi1) (cos phi2))))
(if (or (<= lambda2 -3e-51) (not (<= lambda2 6.4e-16)))
(atan2 (* (sin (- lambda2)) (cos phi2)) (- t_0 (* t_1 (cos lambda2))))
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* t_1 (cos (- lambda1 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 ((lambda2 <= -3e-51) || !(lambda2 <= 6.4e-16)) {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))));
} else {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2)))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin(phi1) * cos(phi2)
if ((lambda2 <= (-3d-51)) .or. (.not. (lambda2 <= 6.4d-16))) then
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))))
else
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin(phi1) * Math.cos(phi2);
double tmp;
if ((lambda2 <= -3e-51) || !(lambda2 <= 6.4e-16)) {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos(lambda2))));
} else {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos((lambda1 - 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) tmp = 0 if (lambda2 <= -3e-51) or not (lambda2 <= 6.4e-16): tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_0 - (t_1 * math.cos(lambda2)))) else: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - (t_1 * math.cos((lambda1 - 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 ((lambda2 <= -3e-51) || !(lambda2 <= 6.4e-16)) tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda2)))); else tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(Float64(lambda1 - 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); tmp = 0.0; if ((lambda2 <= -3e-51) || ~((lambda2 <= 6.4e-16))) tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2)))); else tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -3e-51], N[Not[LessEqual[lambda2, 6.4e-16]], $MachinePrecision]], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -3 \cdot 10^{-51} \lor \neg \left(\lambda_2 \leq 6.4 \cdot 10^{-16}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda2 < -3.00000000000000002e-51 or 6.40000000000000046e-16 < lambda2 Initial program 58.5%
Taylor expanded in lambda1 around 0
Applied rewrites57.6%
Taylor expanded in lambda1 around 0
Applied rewrites57.2%
if -3.00000000000000002e-51 < lambda2 < 6.40000000000000046e-16Initial program 99.7%
Taylor expanded in lambda1 around inf
Applied rewrites86.4%
Final simplification69.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= lambda2 -170000000.0)
(atan2 t_1 (- t_0 (* (* (cos lambda2) (sin phi1)) (cos phi2))))
(if (<= lambda2 3050000.0)
(atan2
t_1
(-
(* (sin phi2) (cos phi1))
(* (* (cos lambda1) (sin phi1)) (cos phi2))))
(atan2
(* (sin (- lambda2)) (cos phi2))
(- t_0 (* (* (sin phi1) (cos phi2)) (cos lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (lambda2 <= -170000000.0) {
tmp = atan2(t_1, (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))));
} else if (lambda2 <= 3050000.0) {
tmp = atan2(t_1, ((sin(phi2) * cos(phi1)) - ((cos(lambda1) * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos(lambda2))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin((lambda1 - lambda2)) * cos(phi2)
if (lambda2 <= (-170000000.0d0)) then
tmp = atan2(t_1, (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))))
else if (lambda2 <= 3050000.0d0) then
tmp = atan2(t_1, ((sin(phi2) * cos(phi1)) - ((cos(lambda1) * sin(phi1)) * cos(phi2))))
else
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos(lambda2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double tmp;
if (lambda2 <= -170000000.0) {
tmp = Math.atan2(t_1, (t_0 - ((Math.cos(lambda2) * Math.sin(phi1)) * Math.cos(phi2))));
} else if (lambda2 <= 3050000.0) {
tmp = Math.atan2(t_1, ((Math.sin(phi2) * Math.cos(phi1)) - ((Math.cos(lambda1) * Math.sin(phi1)) * Math.cos(phi2))));
} else {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos(lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if lambda2 <= -170000000.0: tmp = math.atan2(t_1, (t_0 - ((math.cos(lambda2) * math.sin(phi1)) * math.cos(phi2)))) elif lambda2 <= 3050000.0: tmp = math.atan2(t_1, ((math.sin(phi2) * math.cos(phi1)) - ((math.cos(lambda1) * math.sin(phi1)) * math.cos(phi2)))) else: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_0 - ((math.sin(phi1) * math.cos(phi2)) * math.cos(lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (lambda2 <= -170000000.0) tmp = atan(t_1, Float64(t_0 - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2)))); elseif (lambda2 <= 3050000.0) tmp = atan(t_1, Float64(Float64(sin(phi2) * cos(phi1)) - Float64(Float64(cos(lambda1) * sin(phi1)) * cos(phi2)))); else tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if (lambda2 <= -170000000.0) tmp = atan2(t_1, (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2)))); elseif (lambda2 <= 3050000.0) tmp = atan2(t_1, ((sin(phi2) * cos(phi1)) - ((cos(lambda1) * sin(phi1)) * cos(phi2)))); else tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * 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[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -170000000.0], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 3050000.0], N[ArcTan[t$95$1 / N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -170000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{elif}\;\lambda_2 \leq 3050000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 \cdot \cos \phi_1 - \left(\cos \lambda_1 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2}\\
\end{array}
\end{array}
if lambda2 < -1.7e8Initial program 58.0%
Taylor expanded in lambda1 around 0
Applied rewrites57.9%
if -1.7e8 < lambda2 < 3.05e6Initial program 97.6%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6498.7
Applied rewrites98.7%
Taylor expanded in lambda1 around inf
Applied rewrites98.7%
lift-fma.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
fp-cancel-sub-signN/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-sin.f64N/A
sin-diffN/A
lift--.f64N/A
lift-sin.f6497.6
Applied rewrites97.7%
if 3.05e6 < lambda2 Initial program 47.5%
Taylor expanded in lambda1 around 0
Applied rewrites47.3%
Taylor expanded in lambda1 around 0
Applied rewrites51.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_2 (* (sin phi1) (cos phi2))))
(if (<= lambda2 -170000000.0)
(atan2 t_1 (- t_0 (* (* (cos lambda2) (sin phi1)) (cos phi2))))
(if (<= lambda2 3050000.0)
(atan2 t_1 (- t_0 (* t_2 (cos lambda1))))
(atan2
(* (sin (- lambda2)) (cos phi2))
(- t_0 (* t_2 (cos lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double t_2 = sin(phi1) * cos(phi2);
double tmp;
if (lambda2 <= -170000000.0) {
tmp = atan2(t_1, (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))));
} else if (lambda2 <= 3050000.0) {
tmp = atan2(t_1, (t_0 - (t_2 * cos(lambda1))));
} else {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_2 * 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((lambda1 - lambda2)) * cos(phi2)
t_2 = sin(phi1) * cos(phi2)
if (lambda2 <= (-170000000.0d0)) then
tmp = atan2(t_1, (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))))
else if (lambda2 <= 3050000.0d0) then
tmp = atan2(t_1, (t_0 - (t_2 * cos(lambda1))))
else
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_2 * 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((lambda1 - lambda2)) * Math.cos(phi2);
double t_2 = Math.sin(phi1) * Math.cos(phi2);
double tmp;
if (lambda2 <= -170000000.0) {
tmp = Math.atan2(t_1, (t_0 - ((Math.cos(lambda2) * Math.sin(phi1)) * Math.cos(phi2))));
} else if (lambda2 <= 3050000.0) {
tmp = Math.atan2(t_1, (t_0 - (t_2 * Math.cos(lambda1))));
} else {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - (t_2 * Math.cos(lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin((lambda1 - lambda2)) * math.cos(phi2) t_2 = math.sin(phi1) * math.cos(phi2) tmp = 0 if lambda2 <= -170000000.0: tmp = math.atan2(t_1, (t_0 - ((math.cos(lambda2) * math.sin(phi1)) * math.cos(phi2)))) elif lambda2 <= 3050000.0: tmp = math.atan2(t_1, (t_0 - (t_2 * math.cos(lambda1)))) else: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_0 - (t_2 * math.cos(lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) t_2 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if (lambda2 <= -170000000.0) tmp = atan(t_1, Float64(t_0 - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2)))); elseif (lambda2 <= 3050000.0) tmp = atan(t_1, Float64(t_0 - Float64(t_2 * cos(lambda1)))); else tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(t_2 * cos(lambda2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin((lambda1 - lambda2)) * cos(phi2); t_2 = sin(phi1) * cos(phi2); tmp = 0.0; if (lambda2 <= -170000000.0) tmp = atan2(t_1, (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2)))); elseif (lambda2 <= 3050000.0) tmp = atan2(t_1, (t_0 - (t_2 * cos(lambda1)))); else tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_2 * 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[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -170000000.0], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 3050000.0], N[ArcTan[t$95$1 / N[(t$95$0 - N[(t$95$2 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$2 * 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 \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -170000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{elif}\;\lambda_2 \leq 3050000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - t\_2 \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_2 \cdot \cos \lambda_2}\\
\end{array}
\end{array}
if lambda2 < -1.7e8Initial program 58.0%
Taylor expanded in lambda1 around 0
Applied rewrites57.9%
if -1.7e8 < lambda2 < 3.05e6Initial program 97.6%
Taylor expanded in lambda1 around inf
Applied rewrites97.6%
if 3.05e6 < lambda2 Initial program 47.5%
Taylor expanded in lambda1 around 0
Applied rewrites47.3%
Taylor expanded in lambda1 around 0
Applied rewrites51.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2)))
(t_1 (* (sin lambda1) (cos phi2)))
(t_2 (* (cos phi1) (sin phi2))))
(if (<= lambda1 -2.5)
(atan2 t_1 (- t_2 (* t_0 (cos lambda1))))
(if (<= lambda1 5.3e-5)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_2 (* t_0 (cos lambda2))))
(atan2 t_1 (- t_2 (* t_0 (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
double t_1 = sin(lambda1) * cos(phi2);
double t_2 = cos(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -2.5) {
tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1))));
} else if (lambda1 <= 5.3e-5) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_2 - (t_0 * cos(lambda2))));
} else {
tmp = atan2(t_1, (t_2 - (t_0 * cos((lambda1 - lambda2)))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(phi1) * cos(phi2)
t_1 = sin(lambda1) * cos(phi2)
t_2 = cos(phi1) * sin(phi2)
if (lambda1 <= (-2.5d0)) then
tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1))))
else if (lambda1 <= 5.3d-5) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_2 - (t_0 * cos(lambda2))))
else
tmp = atan2(t_1, (t_2 - (t_0 * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.cos(phi2);
double t_1 = Math.sin(lambda1) * Math.cos(phi2);
double t_2 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (lambda1 <= -2.5) {
tmp = Math.atan2(t_1, (t_2 - (t_0 * Math.cos(lambda1))));
} else if (lambda1 <= 5.3e-5) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_2 - (t_0 * Math.cos(lambda2))));
} else {
tmp = Math.atan2(t_1, (t_2 - (t_0 * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.cos(phi2) t_1 = math.sin(lambda1) * math.cos(phi2) t_2 = math.cos(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -2.5: tmp = math.atan2(t_1, (t_2 - (t_0 * math.cos(lambda1)))) elif lambda1 <= 5.3e-5: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_2 - (t_0 * math.cos(lambda2)))) else: tmp = math.atan2(t_1, (t_2 - (t_0 * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) t_1 = Float64(sin(lambda1) * cos(phi2)) t_2 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -2.5) tmp = atan(t_1, Float64(t_2 - Float64(t_0 * cos(lambda1)))); elseif (lambda1 <= 5.3e-5) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_2 - Float64(t_0 * cos(lambda2)))); else tmp = atan(t_1, Float64(t_2 - Float64(t_0 * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * cos(phi2); t_1 = sin(lambda1) * cos(phi2); t_2 = cos(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -2.5) tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1)))); elseif (lambda1 <= 5.3e-5) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_2 - (t_0 * cos(lambda2)))); else tmp = atan2(t_1, (t_2 - (t_0 * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -2.5], N[ArcTan[t$95$1 / N[(t$95$2 - N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 5.3e-5], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$2 - N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \lambda_1 \cdot \cos \phi_2\\
t_2 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -2.5:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - t\_0 \cdot \cos \lambda_1}\\
\mathbf{elif}\;\lambda_1 \leq 5.3 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_2 - t\_0 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda1 < -2.5Initial program 52.9%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6476.5
Applied rewrites76.5%
Taylor expanded in lambda1 around inf
Applied rewrites76.2%
Taylor expanded in lambda2 around 0
Applied rewrites53.1%
if -2.5 < lambda1 < 5.3000000000000001e-5Initial program 98.1%
Taylor expanded in lambda1 around 0
Applied rewrites98.1%
if 5.3000000000000001e-5 < lambda1 Initial program 60.8%
Taylor expanded in lambda1 around inf
Applied rewrites61.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2)))
(t_1 (* (sin lambda1) (cos phi2)))
(t_2 (* (cos phi1) (sin phi2))))
(if (<= lambda1 -2.5)
(atan2 t_1 (- t_2 (* t_0 (cos lambda1))))
(if (<= lambda1 5.3e-5)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_2 (* (* (cos lambda2) (sin phi1)) (cos phi2))))
(atan2 t_1 (- t_2 (* t_0 (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
double t_1 = sin(lambda1) * cos(phi2);
double t_2 = cos(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -2.5) {
tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1))));
} else if (lambda1 <= 5.3e-5) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_2 - ((cos(lambda2) * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2(t_1, (t_2 - (t_0 * cos((lambda1 - lambda2)))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(phi1) * cos(phi2)
t_1 = sin(lambda1) * cos(phi2)
t_2 = cos(phi1) * sin(phi2)
if (lambda1 <= (-2.5d0)) then
tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1))))
else if (lambda1 <= 5.3d-5) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_2 - ((cos(lambda2) * sin(phi1)) * cos(phi2))))
else
tmp = atan2(t_1, (t_2 - (t_0 * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.cos(phi2);
double t_1 = Math.sin(lambda1) * Math.cos(phi2);
double t_2 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (lambda1 <= -2.5) {
tmp = Math.atan2(t_1, (t_2 - (t_0 * Math.cos(lambda1))));
} else if (lambda1 <= 5.3e-5) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_2 - ((Math.cos(lambda2) * Math.sin(phi1)) * Math.cos(phi2))));
} else {
tmp = Math.atan2(t_1, (t_2 - (t_0 * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.cos(phi2) t_1 = math.sin(lambda1) * math.cos(phi2) t_2 = math.cos(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -2.5: tmp = math.atan2(t_1, (t_2 - (t_0 * math.cos(lambda1)))) elif lambda1 <= 5.3e-5: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_2 - ((math.cos(lambda2) * math.sin(phi1)) * math.cos(phi2)))) else: tmp = math.atan2(t_1, (t_2 - (t_0 * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) t_1 = Float64(sin(lambda1) * cos(phi2)) t_2 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -2.5) tmp = atan(t_1, Float64(t_2 - Float64(t_0 * cos(lambda1)))); elseif (lambda1 <= 5.3e-5) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_2 - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2)))); else tmp = atan(t_1, Float64(t_2 - Float64(t_0 * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * cos(phi2); t_1 = sin(lambda1) * cos(phi2); t_2 = cos(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -2.5) tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1)))); elseif (lambda1 <= 5.3e-5) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_2 - ((cos(lambda2) * sin(phi1)) * cos(phi2)))); else tmp = atan2(t_1, (t_2 - (t_0 * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -2.5], N[ArcTan[t$95$1 / N[(t$95$2 - N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 5.3e-5], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$2 - N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \lambda_1 \cdot \cos \phi_2\\
t_2 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -2.5:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - t\_0 \cdot \cos \lambda_1}\\
\mathbf{elif}\;\lambda_1 \leq 5.3 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda1 < -2.5Initial program 52.9%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6476.5
Applied rewrites76.5%
Taylor expanded in lambda1 around inf
Applied rewrites76.2%
Taylor expanded in lambda2 around 0
Applied rewrites53.1%
if -2.5 < lambda1 < 5.3000000000000001e-5Initial program 98.1%
Taylor expanded in lambda1 around 0
Applied rewrites98.1%
if 5.3000000000000001e-5 < lambda1 Initial program 60.8%
Taylor expanded in lambda1 around inf
Applied rewrites61.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (sin phi1) (cos phi2))))
(if (or (<= lambda2 -3e-51) (not (<= lambda2 6.4e-16)))
(atan2 (* (sin (- lambda2)) (cos phi2)) (- t_0 (* t_1 (cos lambda2))))
(atan2 (* (sin lambda1) (cos phi2)) (- t_0 (* t_1 (cos lambda1)))))))
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 ((lambda2 <= -3e-51) || !(lambda2 <= 6.4e-16)) {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))));
} else {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * cos(lambda1))));
}
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(phi1) * cos(phi2)
if ((lambda2 <= (-3d-51)) .or. (.not. (lambda2 <= 6.4d-16))) then
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))))
else
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * cos(lambda1))))
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 tmp;
if ((lambda2 <= -3e-51) || !(lambda2 <= 6.4e-16)) {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos(lambda2))));
} else {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos(lambda1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin(phi1) * math.cos(phi2) tmp = 0 if (lambda2 <= -3e-51) or not (lambda2 <= 6.4e-16): tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_0 - (t_1 * math.cos(lambda2)))) else: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - (t_1 * math.cos(lambda1)))) 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 ((lambda2 <= -3e-51) || !(lambda2 <= 6.4e-16)) tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda2)))); else tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin(phi1) * cos(phi2); tmp = 0.0; if ((lambda2 <= -3e-51) || ~((lambda2 <= 6.4e-16))) tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2)))); else tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * cos(lambda1)))); 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]}, If[Or[LessEqual[lambda2, -3e-51], N[Not[LessEqual[lambda2, 6.4e-16]], $MachinePrecision]], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda1], $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}\;\lambda_2 \leq -3 \cdot 10^{-51} \lor \neg \left(\lambda_2 \leq 6.4 \cdot 10^{-16}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_1}\\
\end{array}
\end{array}
if lambda2 < -3.00000000000000002e-51 or 6.40000000000000046e-16 < lambda2 Initial program 58.5%
Taylor expanded in lambda1 around 0
Applied rewrites57.6%
Taylor expanded in lambda1 around 0
Applied rewrites57.2%
if -3.00000000000000002e-51 < lambda2 < 6.40000000000000046e-16Initial program 99.7%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6499.7
Applied rewrites99.7%
Taylor expanded in lambda1 around inf
Applied rewrites99.7%
Taylor expanded in lambda2 around 0
Applied rewrites86.4%
Final simplification69.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (<= lambda1 -9.5e-45)
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* (* (sin phi1) (cos phi2)) (cos lambda1))))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (cos (- lambda2 lambda1)) (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -9.5e-45) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos(lambda1))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (cos((lambda2 - lambda1)) * 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 (lambda1 <= (-9.5d-45)) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos(lambda1))))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (cos((lambda2 - lambda1)) * 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 (lambda1 <= -9.5e-45) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos(lambda1))));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -9.5e-45: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - ((math.sin(phi1) * math.cos(phi2)) * math.cos(lambda1)))) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - (math.cos((lambda2 - lambda1)) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -9.5e-45) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda1)))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -9.5e-45) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos(lambda1)))); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (cos((lambda2 - lambda1)) * 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[LessEqual[lambda1, -9.5e-45], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $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[Cos[N[(lambda2 - lambda1), $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_1 \leq -9.5 \cdot 10^{-45}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}\\
\end{array}
\end{array}
if lambda1 < -9.5000000000000002e-45Initial program 56.5%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-cos.f6477.7
Applied rewrites77.7%
Taylor expanded in lambda1 around inf
Applied rewrites75.8%
Taylor expanded in lambda2 around 0
Applied rewrites54.5%
if -9.5000000000000002e-45 < lambda1 Initial program 84.4%
Taylor expanded in phi2 around 0
Applied rewrites72.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (fma (sin phi2) (cos phi1) (* (- (cos phi2)) (* (sin phi1) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(sin(phi2), cos(phi1), (-cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(sin(phi2), cos(phi1), Float64(Float64(-cos(phi2)) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[phi2], $MachinePrecision]) * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \phi_2\right) \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)}
\end{array}
Initial program 76.0%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
flip-+N/A
cos-sum-revN/A
lower-/.f64N/A
Applied rewrites76.0%
Taylor expanded in lambda1 around 0
Applied rewrites76.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2))))
(if (or (<= lambda1 -9.5e+16) (not (<= lambda1 0.047)))
(atan2
(* (sin lambda1) (cos phi2))
(- (sin phi2) (* t_0 (cos (- lambda1 lambda2)))))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (sin phi2) (* t_0 (cos lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
double tmp;
if ((lambda1 <= -9.5e+16) || !(lambda1 <= 0.047)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (t_0 * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (t_0 * 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) :: tmp
t_0 = sin(phi1) * cos(phi2)
if ((lambda1 <= (-9.5d+16)) .or. (.not. (lambda1 <= 0.047d0))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (t_0 * cos((lambda1 - lambda2)))))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (t_0 * cos(lambda2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.cos(phi2);
double tmp;
if ((lambda1 <= -9.5e+16) || !(lambda1 <= 0.047)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (Math.sin(phi2) - (t_0 * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (Math.sin(phi2) - (t_0 * Math.cos(lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.cos(phi2) tmp = 0 if (lambda1 <= -9.5e+16) or not (lambda1 <= 0.047): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (math.sin(phi2) - (t_0 * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - (t_0 * math.cos(lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((lambda1 <= -9.5e+16) || !(lambda1 <= 0.047)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(sin(phi2) - Float64(t_0 * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(t_0 * cos(lambda2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * cos(phi2); tmp = 0.0; if ((lambda1 <= -9.5e+16) || ~((lambda1 <= 0.047))) tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (t_0 * cos((lambda1 - lambda2))))); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - (t_0 * cos(lambda2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -9.5e+16], N[Not[LessEqual[lambda1, 0.047]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$0 * 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[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_1 \leq -9.5 \cdot 10^{+16} \lor \neg \left(\lambda_1 \leq 0.047\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2 - t\_0 \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 - t\_0 \cdot \cos \lambda_2}\\
\end{array}
\end{array}
if lambda1 < -9.5e16 or 0.047 < lambda1 Initial program 57.1%
Taylor expanded in phi2 around 0
Applied rewrites37.7%
Taylor expanded in phi1 around 0
Applied rewrites37.6%
Taylor expanded in lambda2 around 0
Applied rewrites49.1%
if -9.5e16 < lambda1 < 0.047Initial program 95.5%
Taylor expanded in lambda1 around 0
Applied rewrites94.9%
Taylor expanded in phi1 around 0
Applied rewrites79.1%
Final simplification63.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (or (<= lambda1 -9.5e-45) (not (<= lambda1 380000.0)))
(atan2
(* (sin lambda1) (cos phi2))
(- (sin phi2) (* (* (sin phi1) (cos phi2)) t_0)))
(atan2
(sin (- lambda1 lambda2))
(- (* (cos phi1) (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 ((lambda1 <= -9.5e-45) || !(lambda1 <= 380000.0)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0)));
} else {
tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * 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 ((lambda1 <= (-9.5d-45)) .or. (.not. (lambda1 <= 380000.0d0))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0)))
else
tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * 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 ((lambda1 <= -9.5e-45) || !(lambda1 <= 380000.0)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (Math.sin(phi2) - ((Math.sin(phi1) * Math.cos(phi2)) * t_0)));
} else {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), ((Math.cos(phi1) * 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 (lambda1 <= -9.5e-45) or not (lambda1 <= 380000.0): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (math.sin(phi2) - ((math.sin(phi1) * math.cos(phi2)) * t_0))) else: tmp = math.atan2(math.sin((lambda1 - lambda2)), ((math.cos(phi1) * 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 ((lambda1 <= -9.5e-45) || !(lambda1 <= 380000.0)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))); else tmp = atan(sin(Float64(lambda1 - lambda2)), Float64(Float64(cos(phi1) * 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 ((lambda1 <= -9.5e-45) || ~((lambda1 <= 380000.0))) tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0))); else tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * 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[lambda1, -9.5e-45], N[Not[LessEqual[lambda1, 380000.0]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $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}\;\lambda_1 \leq -9.5 \cdot 10^{-45} \lor \neg \left(\lambda_1 \leq 380000\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\end{array}
\end{array}
if lambda1 < -9.5000000000000002e-45 or 3.8e5 < lambda1 Initial program 58.9%
Taylor expanded in phi2 around 0
Applied rewrites37.2%
Taylor expanded in phi1 around 0
Applied rewrites37.1%
Taylor expanded in lambda2 around 0
Applied rewrites49.8%
if -9.5000000000000002e-45 < lambda1 < 3.8e5Initial program 98.0%
Taylor expanded in phi2 around 0
Applied rewrites65.5%
Taylor expanded in phi2 around 0
Applied rewrites65.9%
Final simplification56.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (cos (- lambda2 lambda1)) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos((lambda2 - lambda1)) * sin(phi1))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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)) - (cos((lambda2 - lambda1)) * sin(phi1))))
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.cos((lambda2 - lambda1)) * Math.sin(phi1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.cos((lambda2 - lambda1)) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos((lambda2 - lambda1)) * sin(phi1)))); 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[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $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 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}
\end{array}
Initial program 76.0%
Taylor expanded in phi2 around 0
Applied rewrites64.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (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)), (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)), (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.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.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(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)), (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[Sin[phi2], $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}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 76.0%
Taylor expanded in phi1 around 0
Applied rewrites63.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2))))
(if (or (<= lambda2 -2.7e+24) (not (<= lambda2 820.0)))
(atan2 (sin (- lambda2)) (- (sin phi2) (* t_0 (cos (- lambda1 lambda2)))))
(atan2 (sin (- lambda1 lambda2)) (- (sin phi2) (* t_0 (cos lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
double tmp;
if ((lambda2 <= -2.7e+24) || !(lambda2 <= 820.0)) {
tmp = atan2(sin(-lambda2), (sin(phi2) - (t_0 * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (t_0 * cos(lambda1))));
}
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(phi1) * cos(phi2)
if ((lambda2 <= (-2.7d+24)) .or. (.not. (lambda2 <= 820.0d0))) then
tmp = atan2(sin(-lambda2), (sin(phi2) - (t_0 * cos((lambda1 - lambda2)))))
else
tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (t_0 * cos(lambda1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.cos(phi2);
double tmp;
if ((lambda2 <= -2.7e+24) || !(lambda2 <= 820.0)) {
tmp = Math.atan2(Math.sin(-lambda2), (Math.sin(phi2) - (t_0 * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), (Math.sin(phi2) - (t_0 * Math.cos(lambda1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.cos(phi2) tmp = 0 if (lambda2 <= -2.7e+24) or not (lambda2 <= 820.0): tmp = math.atan2(math.sin(-lambda2), (math.sin(phi2) - (t_0 * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2(math.sin((lambda1 - lambda2)), (math.sin(phi2) - (t_0 * math.cos(lambda1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((lambda2 <= -2.7e+24) || !(lambda2 <= 820.0)) tmp = atan(sin(Float64(-lambda2)), Float64(sin(phi2) - Float64(t_0 * cos(Float64(lambda1 - lambda2))))); else tmp = atan(sin(Float64(lambda1 - lambda2)), Float64(sin(phi2) - Float64(t_0 * cos(lambda1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * cos(phi2); tmp = 0.0; if ((lambda2 <= -2.7e+24) || ~((lambda2 <= 820.0))) tmp = atan2(sin(-lambda2), (sin(phi2) - (t_0 * cos((lambda1 - lambda2))))); else tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (t_0 * cos(lambda1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -2.7e+24], N[Not[LessEqual[lambda2, 820.0]], $MachinePrecision]], N[ArcTan[N[Sin[(-lambda2)], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -2.7 \cdot 10^{+24} \lor \neg \left(\lambda_2 \leq 820\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right)}{\sin \phi_2 - t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - t\_0 \cdot \cos \lambda_1}\\
\end{array}
\end{array}
if lambda2 < -2.7e24 or 820 < lambda2 Initial program 53.6%
Taylor expanded in phi2 around 0
Applied rewrites37.9%
Taylor expanded in phi1 around 0
Applied rewrites37.5%
Taylor expanded in lambda1 around 0
Applied rewrites39.3%
if -2.7e24 < lambda2 < 820Initial program 98.1%
Taylor expanded in phi2 around 0
Applied rewrites61.0%
Taylor expanded in phi1 around 0
Applied rewrites59.2%
Taylor expanded in lambda1 around inf
Applied rewrites59.2%
Final simplification49.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2))))
(if (<= lambda1 -850000.0)
(atan2 (sin lambda1) (- (sin phi2) (* t_0 (cos lambda1))))
(if (<= lambda1 360000.0)
(atan2 (sin (- lambda1 lambda2)) (- (sin phi2) (* t_0 (cos lambda2))))
(atan2
(sin lambda1)
(-
(sin phi2)
(* (* (cos (- lambda2 lambda1)) (sin phi1)) (cos phi2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
double tmp;
if (lambda1 <= -850000.0) {
tmp = atan2(sin(lambda1), (sin(phi2) - (t_0 * cos(lambda1))));
} else if (lambda1 <= 360000.0) {
tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (t_0 * cos(lambda2))));
} else {
tmp = atan2(sin(lambda1), (sin(phi2) - ((cos((lambda2 - lambda1)) * 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 = sin(phi1) * cos(phi2)
if (lambda1 <= (-850000.0d0)) then
tmp = atan2(sin(lambda1), (sin(phi2) - (t_0 * cos(lambda1))))
else if (lambda1 <= 360000.0d0) then
tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (t_0 * cos(lambda2))))
else
tmp = atan2(sin(lambda1), (sin(phi2) - ((cos((lambda2 - lambda1)) * 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.sin(phi1) * Math.cos(phi2);
double tmp;
if (lambda1 <= -850000.0) {
tmp = Math.atan2(Math.sin(lambda1), (Math.sin(phi2) - (t_0 * Math.cos(lambda1))));
} else if (lambda1 <= 360000.0) {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), (Math.sin(phi2) - (t_0 * Math.cos(lambda2))));
} else {
tmp = Math.atan2(Math.sin(lambda1), (Math.sin(phi2) - ((Math.cos((lambda2 - lambda1)) * Math.sin(phi1)) * Math.cos(phi2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.cos(phi2) tmp = 0 if lambda1 <= -850000.0: tmp = math.atan2(math.sin(lambda1), (math.sin(phi2) - (t_0 * math.cos(lambda1)))) elif lambda1 <= 360000.0: tmp = math.atan2(math.sin((lambda1 - lambda2)), (math.sin(phi2) - (t_0 * math.cos(lambda2)))) else: tmp = math.atan2(math.sin(lambda1), (math.sin(phi2) - ((math.cos((lambda2 - lambda1)) * math.sin(phi1)) * math.cos(phi2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if (lambda1 <= -850000.0) tmp = atan(sin(lambda1), Float64(sin(phi2) - Float64(t_0 * cos(lambda1)))); elseif (lambda1 <= 360000.0) tmp = atan(sin(Float64(lambda1 - lambda2)), Float64(sin(phi2) - Float64(t_0 * cos(lambda2)))); else tmp = atan(sin(lambda1), Float64(sin(phi2) - Float64(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)) * cos(phi2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * cos(phi2); tmp = 0.0; if (lambda1 <= -850000.0) tmp = atan2(sin(lambda1), (sin(phi2) - (t_0 * cos(lambda1)))); elseif (lambda1 <= 360000.0) tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (t_0 * cos(lambda2)))); else tmp = atan2(sin(lambda1), (sin(phi2) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -850000.0], N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 360000.0], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_1 \leq -850000:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1}{\sin \phi_2 - t\_0 \cdot \cos \lambda_1}\\
\mathbf{elif}\;\lambda_1 \leq 360000:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - t\_0 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1}{\sin \phi_2 - \left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\end{array}
\end{array}
if lambda1 < -8.5e5Initial program 53.4%
Taylor expanded in phi2 around 0
Applied rewrites31.7%
Taylor expanded in phi1 around 0
Applied rewrites31.5%
Taylor expanded in lambda1 around inf
Applied rewrites29.9%
Taylor expanded in lambda2 around 0
Applied rewrites30.0%
if -8.5e5 < lambda1 < 3.6e5Initial program 96.0%
Taylor expanded in phi2 around 0
Applied rewrites63.0%
Taylor expanded in phi1 around 0
Applied rewrites60.8%
Taylor expanded in lambda1 around 0
Applied rewrites60.8%
if 3.6e5 < lambda1 Initial program 61.7%
Taylor expanded in phi2 around 0
Applied rewrites42.6%
Taylor expanded in phi1 around 0
Applied rewrites42.5%
Taylor expanded in lambda1 around inf
Applied rewrites42.6%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites42.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= lambda2 -2.4e+51)
(atan2 t_1 (- (sin phi2) (* t_0 (cos lambda2))))
(atan2 t_1 (- (sin phi2) (* t_0 (cos lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
double t_1 = sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -2.4e+51) {
tmp = atan2(t_1, (sin(phi2) - (t_0 * cos(lambda2))));
} else {
tmp = atan2(t_1, (sin(phi2) - (t_0 * cos(lambda1))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(phi1) * cos(phi2)
t_1 = sin((lambda1 - lambda2))
if (lambda2 <= (-2.4d+51)) then
tmp = atan2(t_1, (sin(phi2) - (t_0 * cos(lambda2))))
else
tmp = atan2(t_1, (sin(phi2) - (t_0 * cos(lambda1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.cos(phi2);
double t_1 = Math.sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -2.4e+51) {
tmp = Math.atan2(t_1, (Math.sin(phi2) - (t_0 * Math.cos(lambda2))));
} else {
tmp = Math.atan2(t_1, (Math.sin(phi2) - (t_0 * Math.cos(lambda1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.cos(phi2) t_1 = math.sin((lambda1 - lambda2)) tmp = 0 if lambda2 <= -2.4e+51: tmp = math.atan2(t_1, (math.sin(phi2) - (t_0 * math.cos(lambda2)))) else: tmp = math.atan2(t_1, (math.sin(phi2) - (t_0 * math.cos(lambda1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (lambda2 <= -2.4e+51) tmp = atan(t_1, Float64(sin(phi2) - Float64(t_0 * cos(lambda2)))); else tmp = atan(t_1, Float64(sin(phi2) - Float64(t_0 * cos(lambda1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * cos(phi2); t_1 = sin((lambda1 - lambda2)); tmp = 0.0; if (lambda2 <= -2.4e+51) tmp = atan2(t_1, (sin(phi2) - (t_0 * cos(lambda2)))); else tmp = atan2(t_1, (sin(phi2) - (t_0 * cos(lambda1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -2.4e+51], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_2 \leq -2.4 \cdot 10^{+51}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 - t\_0 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 - t\_0 \cdot \cos \lambda_1}\\
\end{array}
\end{array}
if lambda2 < -2.3999999999999999e51Initial program 60.4%
Taylor expanded in phi2 around 0
Applied rewrites45.9%
Taylor expanded in phi1 around 0
Applied rewrites45.3%
Taylor expanded in lambda1 around 0
Applied rewrites45.2%
if -2.3999999999999999e51 < lambda2 Initial program 80.9%
Taylor expanded in phi2 around 0
Applied rewrites50.7%
Taylor expanded in phi1 around 0
Applied rewrites49.4%
Taylor expanded in lambda1 around inf
Applied rewrites47.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (- (* (cos phi1) (sin phi2)) (* (sin phi1) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * 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(phi1) * sin(phi2)) - (sin(phi1) * 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(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $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]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 76.0%
Taylor expanded in phi2 around 0
Applied rewrites49.6%
Taylor expanded in phi2 around 0
Applied rewrites49.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (- (sin phi2) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), (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)), (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.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.sin(phi2) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), Float64(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)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 76.0%
Taylor expanded in phi2 around 0
Applied rewrites49.6%
Taylor expanded in phi1 around 0
Applied rewrites48.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin lambda1) (- (sin phi2) (* (* (cos (- lambda2 lambda1)) (sin phi1)) (cos phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin(lambda1), (sin(phi2) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(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), (sin(phi2) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin(lambda1), (Math.sin(phi2) - ((Math.cos((lambda2 - lambda1)) * Math.sin(phi1)) * Math.cos(phi2))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin(lambda1), (math.sin(phi2) - ((math.cos((lambda2 - lambda1)) * math.sin(phi1)) * math.cos(phi2))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(lambda1), Float64(sin(phi2) - Float64(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)) * cos(phi2)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin(lambda1), (sin(phi2) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1}{\sin \phi_2 - \left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}
\end{array}
Initial program 76.0%
Taylor expanded in phi2 around 0
Applied rewrites49.6%
Taylor expanded in phi1 around 0
Applied rewrites48.5%
Taylor expanded in lambda1 around inf
Applied rewrites34.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites34.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin lambda1) (- (sin phi2) (* (* (sin phi1) (cos phi2)) (cos lambda1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin(lambda1), (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos(lambda1))));
}
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), (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos(lambda1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin(lambda1), (Math.sin(phi2) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos(lambda1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin(lambda1), (math.sin(phi2) - ((math.sin(phi1) * math.cos(phi2)) * math.cos(lambda1))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(lambda1), Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin(lambda1), (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos(lambda1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1}
\end{array}
Initial program 76.0%
Taylor expanded in phi2 around 0
Applied rewrites49.6%
Taylor expanded in phi1 around 0
Applied rewrites48.5%
Taylor expanded in lambda1 around inf
Applied rewrites34.3%
Taylor expanded in lambda2 around 0
Applied rewrites34.1%
herbie shell --seed 2025020
(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))))))