
(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 32 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 lambda2) (- (cos lambda1)) (* (cos lambda2) (sin lambda1)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(fma
(* (* (sin lambda1) (sin lambda2)) (cos phi2))
(sin phi1)
(* (* (* (sin phi1) (cos phi2)) (cos lambda2)) (cos lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(sin(lambda2), -cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - fma(((sin(lambda1) * sin(lambda2)) * cos(phi2)), sin(phi1), (((sin(phi1) * cos(phi2)) * cos(lambda2)) * cos(lambda1)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - fma(Float64(Float64(sin(lambda1) * sin(lambda2)) * cos(phi2)), sin(phi1), Float64(Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda2)) * cos(lambda1))))) 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[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $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}{\cos \phi_1 \cdot \sin \phi_2 - \mathsf{fma}\left(\left(\sin \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2, \sin \phi_1, \left(\left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2\right) \cdot \cos \lambda_1\right)}
\end{array}
Initial program 76.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.7
Applied rewrites88.7%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f6499.8
Applied rewrites99.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-*.f6499.8
Applied rewrites99.8%
lift-*.f64N/A
lift-fma.f64N/A
distribute-rgt-inN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
Applied rewrites99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(fma (sin lambda2) (- (cos lambda1)) (* (cos lambda2) (sin lambda1)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(sin(lambda2), -cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(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[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $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}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)}
\end{array}
Initial program 76.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.7
Applied rewrites88.7%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f6499.8
Applied rewrites99.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-*.f6499.8
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))
(*
(* (sin phi1) (cos phi2))
(fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos 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)) * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(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)) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(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[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $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 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)}
\end{array}
Initial program 76.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.7
Applied rewrites88.7%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)}
\end{array}
Initial program 76.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.7
Applied rewrites88.7%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
lift-fma.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
fp-cancel-sub-signN/A
*-commutativeN/A
lift-cos.f64N/A
lift-sin.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lower-*.f6499.8
Applied rewrites99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda2) (sin lambda1)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (- t_1 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(t_3 (- (cos lambda1))))
(if (<= phi2 -2.25e-6)
(atan2 (* (fma (sin lambda2) t_3 t_0) (cos phi2)) t_2)
(if (<= phi2 3.6e-29)
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1)))
(cos phi2))
(-
t_1
(*
(sin phi1)
(fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2))))))
(atan2
(fma t_0 (cos phi2) (* (* t_3 (sin lambda2)) (cos phi2)))
t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda2) * sin(lambda1);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = t_1 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)));
double t_3 = -cos(lambda1);
double tmp;
if (phi2 <= -2.25e-6) {
tmp = atan2((fma(sin(lambda2), t_3, t_0) * cos(phi2)), t_2);
} else if (phi2 <= 3.6e-29) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2)), (t_1 - (sin(phi1) * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))))));
} else {
tmp = atan2(fma(t_0, cos(phi2), ((t_3 * sin(lambda2)) * cos(phi2))), t_2);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda2) * sin(lambda1)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = Float64(t_1 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))) t_3 = Float64(-cos(lambda1)) tmp = 0.0 if (phi2 <= -2.25e-6) tmp = atan(Float64(fma(sin(lambda2), t_3, t_0) * cos(phi2)), t_2); elseif (phi2 <= 3.6e-29) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)), Float64(t_1 - Float64(sin(phi1) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2)))))); else tmp = atan(fma(t_0, cos(phi2), Float64(Float64(t_3 * sin(lambda2)) * cos(phi2))), t_2); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $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]}, Block[{t$95$3 = (-N[Cos[lambda1], $MachinePrecision])}, If[LessEqual[phi2, -2.25e-6], N[ArcTan[N[(N[(N[Sin[lambda2], $MachinePrecision] * t$95$3 + t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi2, 3.6e-29], 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 - N[(N[Sin[phi1], $MachinePrecision] * 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[(t$95$0 * N[Cos[phi2], $MachinePrecision] + N[(N[(t$95$3 * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_2 \cdot \sin \lambda_1\\
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)\\
t_3 := -\cos \lambda_1\\
\mathbf{if}\;\phi_2 \leq -2.25 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_2, t\_3, t\_0\right) \cdot \cos \phi_2}{t\_2}\\
\mathbf{elif}\;\phi_2 \leq 3.6 \cdot 10^{-29}:\\
\;\;\;\;\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 - \sin \phi_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(t\_0, \cos \phi_2, \left(t\_3 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\right)}{t\_2}\\
\end{array}
\end{array}
if phi2 < -2.25000000000000006e-6Initial program 77.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.f6489.8
Applied rewrites89.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-*.f6489.8
Applied rewrites89.8%
if -2.25000000000000006e-6 < phi2 < 3.59999999999999974e-29Initial program 80.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.f6487.5
Applied rewrites87.5%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
lower-sin.f6499.9
Applied rewrites99.9%
if 3.59999999999999974e-29 < phi2 Initial program 67.9%
lift-*.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
distribute-rgt-inN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6489.4
Applied rewrites89.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= lambda2 -4.8e-7) (not (<= lambda2 6.8e-29)))
(atan2
(*
(- (* (cos lambda2) (sin lambda1)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (cos lambda2) (sin phi1)) (cos phi2))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(fma
(* (cos (- lambda2 lambda1)) (sin phi1))
(- (cos phi2))
(* (sin phi2) (cos phi1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda2 <= -4.8e-7) || !(lambda2 <= 6.8e-29)) {
tmp = atan2((((cos(lambda2) * sin(lambda1)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(lambda2) * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), fma((cos((lambda2 - lambda1)) * sin(phi1)), -cos(phi2), (sin(phi2) * cos(phi1))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda2 <= -4.8e-7) || !(lambda2 <= 6.8e-29)) tmp = atan(Float64(Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2)))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)), Float64(-cos(phi2)), Float64(sin(phi2) * cos(phi1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda2, -4.8e-7], N[Not[LessEqual[lambda2, 6.8e-29]], $MachinePrecision]], 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[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * (-N[Cos[phi2], $MachinePrecision]) + N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -4.8 \cdot 10^{-7} \lor \neg \left(\lambda_2 \leq 6.8 \cdot 10^{-29}\right):\\
\;\;\;\;\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(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1, -\cos \phi_2, \sin \phi_2 \cdot \cos \phi_1\right)}\\
\end{array}
\end{array}
if lambda2 < -4.79999999999999957e-7 or 6.79999999999999945e-29 < lambda2 Initial program 57.5%
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.f6479.7
Applied rewrites79.7%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f6479.2
Applied rewrites79.2%
if -4.79999999999999957e-7 < lambda2 < 6.79999999999999945e-29Initial program 99.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.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 rewrites99.8%
Final simplification88.4%
(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 (* (* (cos lambda2) (sin phi1)) (cos phi2)))))
(if (<= lambda2 -1250000000.0)
(atan2
(*
(fma (sin lambda2) (- (cos lambda1)) (* (cos lambda2) (sin lambda1)))
(cos phi2))
t_2)
(if (<= lambda2 6.8e-29)
(atan2 t_0 (- t_1 (* (* (sin phi1) (cos phi2)) (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 - ((cos(lambda2) * sin(phi1)) * cos(phi2));
double tmp;
if (lambda2 <= -1250000000.0) {
tmp = atan2((fma(sin(lambda2), -cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), t_2);
} else if (lambda2 <= 6.8e-29) {
tmp = atan2(t_0, (t_1 - ((sin(phi1) * cos(phi2)) * 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(cos(lambda2) * sin(phi1)) * cos(phi2))) tmp = 0.0 if (lambda2 <= -1250000000.0) tmp = atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), t_2); elseif (lambda2 <= 6.8e-29) tmp = atan(t_0, Float64(t_1 - Float64(Float64(sin(phi1) * cos(phi2)) * 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[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -1250000000.0], 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[lambda2, 6.8e-29], N[ArcTan[t$95$0 / N[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $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(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -1250000000:\\
\;\;\;\;\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}\;\lambda_2 \leq 6.8 \cdot 10^{-29}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{t\_2}\\
\end{array}
\end{array}
if lambda2 < -1.25e9Initial program 53.3%
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.f6481.1
Applied rewrites81.1%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f6499.8
Applied rewrites99.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-*.f6499.9
Applied rewrites99.9%
Taylor expanded in lambda1 around 0
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
cos-neg-revN/A
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f6481.2
Applied rewrites81.2%
if -1.25e9 < lambda2 < 6.79999999999999945e-29Initial program 96.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.f6498.6
Applied rewrites98.6%
Taylor expanded in lambda2 around 0
lower-cos.f6498.6
Applied rewrites98.6%
if 6.79999999999999945e-29 < lambda2 Initial program 63.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.f6479.2
Applied rewrites79.2%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f6478.3
Applied rewrites78.3%
(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 (* (* (cos lambda2) (sin phi1)) (cos phi2)))))
(if (<= lambda2 -1250000000.0)
(atan2
(*
(- (* (cos lambda2) (sin lambda1)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
t_2)
(if (<= lambda2 6.8e-29)
(atan2 t_0 (- t_1 (* (* (sin phi1) (cos phi2)) (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 - ((cos(lambda2) * sin(phi1)) * cos(phi2));
double tmp;
if (lambda2 <= -1250000000.0) {
tmp = atan2((((cos(lambda2) * sin(lambda1)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), t_2);
} else if (lambda2 <= 6.8e-29) {
tmp = atan2(t_0, (t_1 - ((sin(phi1) * cos(phi2)) * 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(cos(lambda2) * sin(phi1)) * cos(phi2))) tmp = 0.0 if (lambda2 <= -1250000000.0) tmp = atan(Float64(Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), t_2); elseif (lambda2 <= 6.8e-29) tmp = atan(t_0, Float64(t_1 - Float64(Float64(sin(phi1) * cos(phi2)) * 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[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -1250000000.0], 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] / t$95$2], $MachinePrecision], If[LessEqual[lambda2, 6.8e-29], N[ArcTan[t$95$0 / N[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $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(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -1250000000:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\cos \lambda_2 \cdot \sin \lambda_1 - \sin \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{t\_2}\\
\mathbf{elif}\;\lambda_2 \leq 6.8 \cdot 10^{-29}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{t\_2}\\
\end{array}
\end{array}
if lambda2 < -1.25e9Initial program 53.3%
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.f6481.1
Applied rewrites81.1%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f6481.1
Applied rewrites81.1%
if -1.25e9 < lambda2 < 6.79999999999999945e-29Initial program 96.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.f6498.6
Applied rewrites98.6%
Taylor expanded in lambda2 around 0
lower-cos.f6498.6
Applied rewrites98.6%
if 6.79999999999999945e-29 < lambda2 Initial program 63.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.f6479.2
Applied rewrites79.2%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f6478.3
Applied rewrites78.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(-
(* (cos phi1) (sin phi2))
(* (* (cos lambda2) (sin phi1)) (cos phi2)))))
(if (<= lambda2 -4.8e-7)
(atan2
(*
(- (* (cos lambda2) (sin lambda1)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
t_0)
(if (<= lambda2 6.8e-29)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(fma
(* (cos (- lambda2 lambda1)) (sin phi1))
(- (cos phi2))
(* (sin phi2) (cos phi1))))
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1)))
(cos phi2))
t_0)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(phi1) * sin(phi2)) - ((cos(lambda2) * sin(phi1)) * cos(phi2));
double tmp;
if (lambda2 <= -4.8e-7) {
tmp = atan2((((cos(lambda2) * sin(lambda1)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), t_0);
} else if (lambda2 <= 6.8e-29) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), fma((cos((lambda2 - lambda1)) * sin(phi1)), -cos(phi2), (sin(phi2) * cos(phi1))));
} else {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2)), t_0);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2))) tmp = 0.0 if (lambda2 <= -4.8e-7) tmp = atan(Float64(Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), t_0); elseif (lambda2 <= 6.8e-29) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)), Float64(-cos(phi2)), Float64(sin(phi2) * cos(phi1)))); else tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)), t_0); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -4.8e-7], 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] / t$95$0], $MachinePrecision], If[LessEqual[lambda2, 6.8e-29], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * (-N[Cos[phi2], $MachinePrecision]) + N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $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] / t$95$0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -4.8 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\cos \lambda_2 \cdot \sin \lambda_1 - \sin \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{t\_0}\\
\mathbf{elif}\;\lambda_2 \leq 6.8 \cdot 10^{-29}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1, -\cos \phi_2, \sin \phi_2 \cdot \cos \phi_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}\\
\end{array}
\end{array}
if lambda2 < -4.79999999999999957e-7Initial program 50.6%
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.f6480.3
Applied rewrites80.3%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
cos-neg-revN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f6480.2
Applied rewrites80.2%
if -4.79999999999999957e-7 < lambda2 < 6.79999999999999945e-29Initial program 99.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.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 rewrites99.8%
if 6.79999999999999945e-29 < lambda2 Initial program 63.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.f6479.2
Applied rewrites79.2%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-cos.f6478.3
Applied rewrites78.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (fma (sin lambda2) (- (cos lambda1)) (* (cos lambda2) (sin 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(lambda2), -cos(lambda1), (cos(lambda2) * sin(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(lambda2), Float64(-cos(lambda1)), Float64(cos(lambda2) * sin(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[lambda2], $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[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_2, -\cos \lambda_1, \cos \lambda_2 \cdot \sin \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.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.7
Applied rewrites88.7%
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-*.f6488.7
Applied rewrites88.7%
(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.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.7
Applied rewrites88.7%
(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.4%
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.f6488.6
Applied rewrites88.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (+ lambda2 lambda1)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (sin (- lambda1 lambda2)))
(t_3 (cos (- lambda1 lambda2))))
(if (<= phi1 -0.0072)
(atan2
(* (cos phi2) t_2)
(fma
(* (cos (- lambda2 lambda1)) (sin phi1))
(- (cos phi2))
(* (sin phi2) (cos phi1))))
(if (<= phi1 0.85)
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1)))
(cos phi2))
(-
t_1
(*
(* (* (fma -0.16666666666666666 (* phi1 phi1) 1.0) (cos phi2)) phi1)
t_3)))
(atan2
(/ (* (* t_2 t_0) (cos phi2)) t_0)
(- t_1 (* (* (sin phi1) (cos phi2)) t_3)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda2 + lambda1));
double t_1 = cos(phi1) * sin(phi2);
double t_2 = sin((lambda1 - lambda2));
double t_3 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -0.0072) {
tmp = atan2((cos(phi2) * t_2), fma((cos((lambda2 - lambda1)) * sin(phi1)), -cos(phi2), (sin(phi2) * cos(phi1))));
} else if (phi1 <= 0.85) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2)), (t_1 - (((fma(-0.16666666666666666, (phi1 * phi1), 1.0) * cos(phi2)) * phi1) * t_3)));
} else {
tmp = atan2((((t_2 * t_0) * cos(phi2)) / t_0), (t_1 - ((sin(phi1) * cos(phi2)) * t_3)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda2 + lambda1)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = sin(Float64(lambda1 - lambda2)) t_3 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -0.0072) tmp = atan(Float64(cos(phi2) * t_2), fma(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)), Float64(-cos(phi2)), Float64(sin(phi2) * cos(phi1)))); elseif (phi1 <= 0.85) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)), Float64(t_1 - Float64(Float64(Float64(fma(-0.16666666666666666, Float64(phi1 * phi1), 1.0) * cos(phi2)) * phi1) * t_3))); else tmp = atan(Float64(Float64(Float64(t_2 * t_0) * cos(phi2)) / t_0), Float64(t_1 - Float64(Float64(sin(phi1) * cos(phi2)) * t_3))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda2 + lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.0072], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] / N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * (-N[Cos[phi2], $MachinePrecision]) + N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 0.85], 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 - N[(N[(N[(N[(-0.16666666666666666 * N[(phi1 * phi1), $MachinePrecision] + 1.0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * phi1), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(t$95$2 * t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] / N[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_2 + \lambda_1\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_3 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -0.0072:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t\_2}{\mathsf{fma}\left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1, -\cos \phi_2, \sin \phi_2 \cdot \cos \phi_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 0.85:\\
\;\;\;\;\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 - \left(\left(\mathsf{fma}\left(-0.16666666666666666, \phi_1 \cdot \phi_1, 1\right) \cdot \cos \phi_2\right) \cdot \phi_1\right) \cdot t\_3}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\frac{\left(t\_2 \cdot t\_0\right) \cdot \cos \phi_2}{t\_0}}{t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_3}\\
\end{array}
\end{array}
if phi1 < -0.0071999999999999998Initial program 79.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6479.7
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 rewrites79.7%
if -0.0071999999999999998 < phi1 < 0.849999999999999978Initial program 76.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.4
Applied rewrites98.4%
Taylor expanded in phi1 around 0
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-cos.f6498.4
Applied rewrites98.4%
if 0.849999999999999978 < phi1 Initial program 72.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.f6475.4
Applied rewrites75.4%
lift-*.f64N/A
lift-fma.f64N/A
flip-+N/A
associate-*l/N/A
lift-*.f64N/A
lift-neg.f64N/A
fp-cancel-sign-subN/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-sin.f64N/A
Applied rewrites72.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (sin (- lambda1 lambda2)))
(t_3 (sin (+ lambda2 lambda1))))
(if (<= phi1 -1.46e+29)
(atan2
(* (cos phi2) t_2)
(fma
(* (cos (- lambda2 lambda1)) (sin phi1))
(- (cos phi2))
(* (sin phi2) (cos phi1))))
(if (<= phi1 2.5e+20)
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1)))
(cos phi2))
(- t_0 (* (sin phi1) t_1)))
(atan2
(/ (* (* t_2 t_3) (cos phi2)) t_3)
(- t_0 (* (* (sin phi1) (cos phi2)) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin((lambda1 - lambda2));
double t_3 = sin((lambda2 + lambda1));
double tmp;
if (phi1 <= -1.46e+29) {
tmp = atan2((cos(phi2) * t_2), fma((cos((lambda2 - lambda1)) * sin(phi1)), -cos(phi2), (sin(phi2) * cos(phi1))));
} else if (phi1 <= 2.5e+20) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2)), (t_0 - (sin(phi1) * t_1)));
} else {
tmp = atan2((((t_2 * t_3) * cos(phi2)) / t_3), (t_0 - ((sin(phi1) * cos(phi2)) * t_1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = sin(Float64(lambda1 - lambda2)) t_3 = sin(Float64(lambda2 + lambda1)) tmp = 0.0 if (phi1 <= -1.46e+29) tmp = atan(Float64(cos(phi2) * t_2), fma(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)), Float64(-cos(phi2)), Float64(sin(phi2) * cos(phi1)))); elseif (phi1 <= 2.5e+20) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)), Float64(t_0 - Float64(sin(phi1) * t_1))); else tmp = atan(Float64(Float64(Float64(t_2 * t_3) * cos(phi2)) / t_3), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_1))); 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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(lambda2 + lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.46e+29], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] / N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * (-N[Cos[phi2], $MachinePrecision]) + N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 2.5e+20], 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[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(t$95$2 * t$95$3), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$3), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_3 := \sin \left(\lambda_2 + \lambda_1\right)\\
\mathbf{if}\;\phi_1 \leq -1.46 \cdot 10^{+29}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t\_2}{\mathsf{fma}\left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1, -\cos \phi_2, \sin \phi_2 \cdot \cos \phi_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 2.5 \cdot 10^{+20}:\\
\;\;\;\;\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 - \sin \phi_1 \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\frac{\left(t\_2 \cdot t\_3\right) \cdot \cos \phi_2}{t\_3}}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_1}\\
\end{array}
\end{array}
if phi1 < -1.46e29Initial program 80.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6480.5
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 rewrites80.5%
if -1.46e29 < phi1 < 2.5e20Initial program 75.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.f6495.6
Applied rewrites95.6%
Taylor expanded in phi2 around 0
lower-sin.f6495.4
Applied rewrites95.4%
if 2.5e20 < phi1 Initial program 75.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.f6477.7
Applied rewrites77.7%
lift-*.f64N/A
lift-fma.f64N/A
flip-+N/A
associate-*l/N/A
lift-*.f64N/A
lift-neg.f64N/A
fp-cancel-sign-subN/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-sin.f64N/A
Applied rewrites75.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -1.46e+29) (not (<= phi1 2.5e+20)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(fma
(* (cos (- lambda2 lambda1)) (sin phi1))
(- (cos phi2))
(* (sin phi2) (cos phi1))))
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1)))
(cos phi2))
(- (* (cos phi1) (sin phi2)) (* (sin phi1) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -1.46e+29) || !(phi1 <= 2.5e+20)) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), fma((cos((lambda2 - lambda1)) * sin(phi1)), -cos(phi2), (sin(phi2) * cos(phi1))));
} else {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -1.46e+29) || !(phi1 <= 2.5e+20)) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)), Float64(-cos(phi2)), Float64(sin(phi2) * cos(phi1)))); else tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -1.46e+29], N[Not[LessEqual[phi1, 2.5e+20]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * (-N[Cos[phi2], $MachinePrecision]) + N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $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[(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}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -1.46 \cdot 10^{+29} \lor \neg \left(\phi_1 \leq 2.5 \cdot 10^{+20}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1, -\cos \phi_2, \sin \phi_2 \cdot \cos \phi_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}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi1 < -1.46e29 or 2.5e20 < phi1 Initial program 77.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.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 rewrites77.8%
if -1.46e29 < phi1 < 2.5e20Initial program 75.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.f6495.6
Applied rewrites95.6%
Taylor expanded in phi2 around 0
lower-sin.f6495.4
Applied rewrites95.4%
Final simplification87.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -1.46e+29) (not (<= phi1 2.5e+20)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(fma
(* (cos (- lambda2 lambda1)) (sin phi1))
(- (cos phi2))
(* (sin phi2) (cos phi1))))
(atan2
(*
(- (* (cos lambda2) (sin lambda1)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(- (* (cos phi1) (sin phi2)) (* (sin phi1) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -1.46e+29) || !(phi1 <= 2.5e+20)) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), fma((cos((lambda2 - lambda1)) * sin(phi1)), -cos(phi2), (sin(phi2) * cos(phi1))));
} else {
tmp = atan2((((cos(lambda2) * sin(lambda1)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -1.46e+29) || !(phi1 <= 2.5e+20)) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)), Float64(-cos(phi2)), Float64(sin(phi2) * cos(phi1)))); else tmp = atan(Float64(Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -1.46e+29], N[Not[LessEqual[phi1, 2.5e+20]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * (-N[Cos[phi2], $MachinePrecision]) + N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 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[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -1.46 \cdot 10^{+29} \lor \neg \left(\phi_1 \leq 2.5 \cdot 10^{+20}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1, -\cos \phi_2, \sin \phi_2 \cdot \cos \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\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 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi1 < -1.46e29 or 2.5e20 < phi1 Initial program 77.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6477.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 rewrites77.8%
if -1.46e29 < phi1 < 2.5e20Initial program 75.1%
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.f6495.6
Applied rewrites95.6%
Taylor expanded in phi2 around 0
lower-sin.f6495.4
Applied rewrites95.4%
Final simplification87.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -0.02) (not (<= phi1 1.12e-15)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(fma
(* (cos (- lambda2 lambda1)) (sin phi1))
(- (cos phi2))
(* (sin phi2) (cos phi1))))
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1)))
(cos phi2))
(- (* (cos phi1) (sin phi2)) (* (sin phi1) (cos lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -0.02) || !(phi1 <= 1.12e-15)) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), fma((cos((lambda2 - lambda1)) * sin(phi1)), -cos(phi2), (sin(phi2) * cos(phi1))));
} else {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos(lambda1))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -0.02) || !(phi1 <= 1.12e-15)) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)), Float64(-cos(phi2)), Float64(sin(phi2) * cos(phi1)))); else tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(lambda1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -0.02], N[Not[LessEqual[phi1, 1.12e-15]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * (-N[Cos[phi2], $MachinePrecision]) + N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $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[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.02 \lor \neg \left(\phi_1 \leq 1.12 \cdot 10^{-15}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1, -\cos \phi_2, \sin \phi_2 \cdot \cos \phi_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}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \lambda_1}\\
\end{array}
\end{array}
if phi1 < -0.0200000000000000004 or 1.1200000000000001e-15 < phi1 Initial program 76.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6476.1
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 rewrites76.1%
if -0.0200000000000000004 < phi1 < 1.1200000000000001e-15Initial program 76.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.9
Applied rewrites98.9%
Taylor expanded in lambda2 around 0
lower-cos.f6498.9
Applied rewrites98.9%
Taylor expanded in phi2 around 0
lower-sin.f6498.9
Applied rewrites98.9%
Final simplification87.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (sin phi1) (cos phi2))))
(if (or (<= lambda2 -85000000.0) (not (<= lambda2 1.8e+32)))
(atan2 (* (sin (- lambda2)) (cos phi2)) (- t_0 (* t_1 (cos lambda2))))
(atan2
(* (sin (- lambda1 lambda2)) (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 <= -85000000.0) || !(lambda2 <= 1.8e+32)) {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * 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 <= (-85000000.0d0)) .or. (.not. (lambda2 <= 1.8d+32))) then
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))))
else
tmp = atan2((sin((lambda1 - lambda2)) * 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 <= -85000000.0) || !(lambda2 <= 1.8e+32)) {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos(lambda2))));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * 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 <= -85000000.0) or not (lambda2 <= 1.8e+32): tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_0 - (t_1 * math.cos(lambda2)))) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * 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 <= -85000000.0) || !(lambda2 <= 1.8e+32)) tmp = atan(Float64(sin(Float64(-lambda2)) * 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 * 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 <= -85000000.0) || ~((lambda2 <= 1.8e+32))) tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2)))); else tmp = atan2((sin((lambda1 - lambda2)) * 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, -85000000.0], N[Not[LessEqual[lambda2, 1.8e+32]], $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[N[(lambda1 - lambda2), $MachinePrecision]], $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 -85000000 \lor \neg \left(\lambda_2 \leq 1.8 \cdot 10^{+32}\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 \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_1}\\
\end{array}
\end{array}
if lambda2 < -8.5e7 or 1.7999999999999998e32 < lambda2 Initial program 55.4%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6454.1
Applied rewrites54.1%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lower-cos.f6454.1
Applied rewrites54.1%
if -8.5e7 < lambda2 < 1.7999999999999998e32Initial program 96.7%
Taylor expanded in lambda2 around 0
lower-cos.f6496.0
Applied rewrites96.0%
Final simplification75.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 -0.008)
(atan2 t_1 (- t_2 (* t_0 (cos lambda1))))
(if (<= lambda1 0.33)
(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 <= -0.008) {
tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1))));
} else if (lambda1 <= 0.33) {
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 <= (-0.008d0)) then
tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1))))
else if (lambda1 <= 0.33d0) 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 <= -0.008) {
tmp = Math.atan2(t_1, (t_2 - (t_0 * Math.cos(lambda1))));
} else if (lambda1 <= 0.33) {
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 <= -0.008: tmp = math.atan2(t_1, (t_2 - (t_0 * math.cos(lambda1)))) elif lambda1 <= 0.33: 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 <= -0.008) tmp = atan(t_1, Float64(t_2 - Float64(t_0 * cos(lambda1)))); elseif (lambda1 <= 0.33) 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 <= -0.008) tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1)))); elseif (lambda1 <= 0.33) 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, -0.008], N[ArcTan[t$95$1 / N[(t$95$2 - N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 0.33], 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 -0.008:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - t\_0 \cdot \cos \lambda_1}\\
\mathbf{elif}\;\lambda_1 \leq 0.33:\\
\;\;\;\;\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 < -0.0080000000000000002Initial program 52.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.f6473.8
Applied rewrites73.8%
Taylor expanded in lambda2 around 0
lower-cos.f6473.8
Applied rewrites73.8%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6454.4
Applied rewrites54.4%
if -0.0080000000000000002 < lambda1 < 0.330000000000000016Initial program 99.4%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6499.4
Applied rewrites99.4%
if 0.330000000000000016 < lambda1 Initial program 57.3%
Taylor expanded in lambda2 around 0
lower-sin.f6458.8
Applied rewrites58.8%
(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 -5.7e-5)
(atan2 t_1 (- t_2 (* t_0 (cos lambda1))))
(if (<= lambda1 0.0112)
(atan2 (* (sin (- 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 <= -5.7e-5) {
tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1))));
} else if (lambda1 <= 0.0112) {
tmp = atan2((sin(-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 <= (-5.7d-5)) then
tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1))))
else if (lambda1 <= 0.0112d0) then
tmp = atan2((sin(-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 <= -5.7e-5) {
tmp = Math.atan2(t_1, (t_2 - (t_0 * Math.cos(lambda1))));
} else if (lambda1 <= 0.0112) {
tmp = Math.atan2((Math.sin(-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 <= -5.7e-5: tmp = math.atan2(t_1, (t_2 - (t_0 * math.cos(lambda1)))) elif lambda1 <= 0.0112: tmp = math.atan2((math.sin(-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 <= -5.7e-5) tmp = atan(t_1, Float64(t_2 - Float64(t_0 * cos(lambda1)))); elseif (lambda1 <= 0.0112) tmp = atan(Float64(sin(Float64(-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 <= -5.7e-5) tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1)))); elseif (lambda1 <= 0.0112) tmp = atan2((sin(-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, -5.7e-5], N[ArcTan[t$95$1 / N[(t$95$2 - N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 0.0112], N[ArcTan[N[(N[Sin[(-lambda2)], $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 -5.7 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - t\_0 \cdot \cos \lambda_1}\\
\mathbf{elif}\;\lambda_1 \leq 0.0112:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\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 < -5.7000000000000003e-5Initial program 52.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.f6473.8
Applied rewrites73.8%
Taylor expanded in lambda2 around 0
lower-cos.f6473.8
Applied rewrites73.8%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6454.4
Applied rewrites54.4%
if -5.7000000000000003e-5 < lambda1 < 0.0111999999999999999Initial program 99.4%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6488.2
Applied rewrites88.2%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lower-cos.f6488.2
Applied rewrites88.2%
if 0.0111999999999999999 < lambda1 Initial program 57.3%
Taylor expanded in lambda2 around 0
lower-sin.f6458.8
Applied rewrites58.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (sin phi1) (cos phi2))))
(if (or (<= lambda1 -5.7e-5) (not (<= lambda1 0.0112)))
(atan2 (* (sin lambda1) (cos phi2)) (- t_0 (* t_1 (cos lambda1))))
(atan2 (* (sin (- lambda2)) (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 ((lambda1 <= -5.7e-5) || !(lambda1 <= 0.0112)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * cos(lambda1))));
} else {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin(phi1) * cos(phi2)
if ((lambda1 <= (-5.7d-5)) .or. (.not. (lambda1 <= 0.0112d0))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * cos(lambda1))))
else
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin(phi1) * Math.cos(phi2);
double tmp;
if ((lambda1 <= -5.7e-5) || !(lambda1 <= 0.0112)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos(lambda1))));
} else {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos(lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin(phi1) * math.cos(phi2) tmp = 0 if (lambda1 <= -5.7e-5) or not (lambda1 <= 0.0112): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - (t_1 * math.cos(lambda1)))) else: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_0 - (t_1 * math.cos(lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((lambda1 <= -5.7e-5) || !(lambda1 <= 0.0112)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda1)))); else tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin(phi1) * cos(phi2); tmp = 0.0; if ((lambda1 <= -5.7e-5) || ~((lambda1 <= 0.0112))) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * cos(lambda1)))); else tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (t_1 * cos(lambda2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -5.7e-5], N[Not[LessEqual[lambda1, 0.0112]], $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], 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]]]]
\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_1 \leq -5.7 \cdot 10^{-5} \lor \neg \left(\lambda_1 \leq 0.0112\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\end{array}
\end{array}
if lambda1 < -5.7000000000000003e-5 or 0.0111999999999999999 < lambda1 Initial program 55.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.f6478.5
Applied rewrites78.5%
Taylor expanded in lambda2 around 0
lower-cos.f6477.8
Applied rewrites77.8%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6456.6
Applied rewrites56.6%
if -5.7000000000000003e-5 < lambda1 < 0.0111999999999999999Initial program 99.4%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6488.2
Applied rewrites88.2%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lower-cos.f6488.2
Applied rewrites88.2%
Final simplification71.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda1 -2.2e-15) (not (<= lambda1 0.33)))
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* (* (sin phi1) (cos phi2)) (cos lambda1))))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (sin phi1) (cos lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda1 <= -2.2e-15) || !(lambda1 <= 0.33)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos(lambda1))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (sin(phi1) * 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 = cos(phi1) * sin(phi2)
if ((lambda1 <= (-2.2d-15)) .or. (.not. (lambda1 <= 0.33d0))) 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 - (sin(phi1) * 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 tmp;
if ((lambda1 <= -2.2e-15) || !(lambda1 <= 0.33)) {
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.sin(phi1) * Math.cos(lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda1 <= -2.2e-15) or not (lambda1 <= 0.33): 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.sin(phi1) * math.cos(lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda1 <= -2.2e-15) || !(lambda1 <= 0.33)) 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(sin(phi1) * cos(lambda2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda1 <= -2.2e-15) || ~((lambda1 <= 0.33))) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos(lambda1)))); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (sin(phi1) * 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]}, If[Or[LessEqual[lambda1, -2.2e-15], N[Not[LessEqual[lambda1, 0.33]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * 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[Sin[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -2.2 \cdot 10^{-15} \lor \neg \left(\lambda_1 \leq 0.33\right):\\
\;\;\;\;\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 - \sin \phi_1 \cdot \cos \lambda_2}\\
\end{array}
\end{array}
if lambda1 < -2.19999999999999986e-15 or 0.330000000000000016 < lambda1 Initial program 55.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.f6478.9
Applied rewrites78.9%
Taylor expanded in lambda2 around 0
lower-cos.f6477.6
Applied rewrites77.6%
Taylor expanded in lambda2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6456.7
Applied rewrites56.7%
if -2.19999999999999986e-15 < lambda1 < 0.330000000000000016Initial program 99.4%
Taylor expanded in phi2 around 0
lower-sin.f6483.9
Applied rewrites83.9%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lower-cos.f6483.9
Applied rewrites83.9%
Final simplification69.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (fma (* (cos (- lambda2 lambda1)) (sin phi1)) (- (cos phi2)) (* (sin phi2) (cos phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), fma((cos((lambda2 - lambda1)) * sin(phi1)), -cos(phi2), (sin(phi2) * cos(phi1))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)), Float64(-cos(phi2)), Float64(sin(phi2) * cos(phi1)))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * (-N[Cos[phi2], $MachinePrecision]) + N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1, -\cos \phi_2, \sin \phi_2 \cdot \cos \phi_1\right)}
\end{array}
Initial program 76.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6476.4
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 rewrites76.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (fma (sin phi2) (cos phi1) (* (- (cos phi2)) (* (cos (- lambda2 lambda1)) (sin phi1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), (-cos(phi2) * (cos((lambda2 - lambda1)) * sin(phi1)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-cos(phi2)) * Float64(cos(Float64(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[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[phi2], $MachinePrecision]) * N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \phi_2\right) \cdot \left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1\right)\right)}
\end{array}
Initial program 76.4%
Taylor expanded in phi2 around 0
lower-sin.f6462.5
Applied rewrites62.5%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower--.f64N/A
lower-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
Applied rewrites76.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -0.0022) (not (<= phi2 0.24)))
(atan2 (* t_1 (cos phi2)) (- t_0 (* (sin phi1) (cos lambda1))))
(atan2 (* 1.0 t_1) (- t_0 (* (sin phi1) (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));
double tmp;
if ((phi2 <= -0.0022) || !(phi2 <= 0.24)) {
tmp = atan2((t_1 * cos(phi2)), (t_0 - (sin(phi1) * cos(lambda1))));
} else {
tmp = atan2((1.0 * t_1), (t_0 - (sin(phi1) * 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))
if ((phi2 <= (-0.0022d0)) .or. (.not. (phi2 <= 0.24d0))) then
tmp = atan2((t_1 * cos(phi2)), (t_0 - (sin(phi1) * cos(lambda1))))
else
tmp = atan2((1.0d0 * t_1), (t_0 - (sin(phi1) * 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));
double tmp;
if ((phi2 <= -0.0022) || !(phi2 <= 0.24)) {
tmp = Math.atan2((t_1 * Math.cos(phi2)), (t_0 - (Math.sin(phi1) * Math.cos(lambda1))));
} else {
tmp = Math.atan2((1.0 * t_1), (t_0 - (Math.sin(phi1) * 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)) tmp = 0 if (phi2 <= -0.0022) or not (phi2 <= 0.24): tmp = math.atan2((t_1 * math.cos(phi2)), (t_0 - (math.sin(phi1) * math.cos(lambda1)))) else: tmp = math.atan2((1.0 * t_1), (t_0 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -0.0022) || !(phi2 <= 0.24)) tmp = atan(Float64(t_1 * cos(phi2)), Float64(t_0 - Float64(sin(phi1) * cos(lambda1)))); else tmp = atan(Float64(1.0 * t_1), Float64(t_0 - Float64(sin(phi1) * 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)); tmp = 0.0; if ((phi2 <= -0.0022) || ~((phi2 <= 0.24))) tmp = atan2((t_1 * cos(phi2)), (t_0 - (sin(phi1) * cos(lambda1)))); else tmp = atan2((1.0 * t_1), (t_0 - (sin(phi1) * 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[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.0022], N[Not[LessEqual[phi2, 0.24]], $MachinePrecision]], N[ArcTan[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(1.0 * t$95$1), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $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)\\
\mathbf{if}\;\phi_2 \leq -0.0022 \lor \neg \left(\phi_2 \leq 0.24\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot \cos \phi_2}{t\_0 - \sin \phi_1 \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{1 \cdot t\_1}{t\_0 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.00220000000000000013 or 0.23999999999999999 < phi2 Initial program 72.0%
Taylor expanded in phi2 around 0
lower-sin.f6446.7
Applied rewrites46.7%
Taylor expanded in lambda2 around 0
lower-cos.f6446.0
Applied rewrites46.0%
if -0.00220000000000000013 < phi2 < 0.23999999999999999Initial program 81.1%
Taylor expanded in phi2 around 0
lower-sin.f6479.9
Applied rewrites79.9%
Taylor expanded in phi2 around 0
associate-*r*N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f64N/A
lower--.f6479.9
Applied rewrites79.9%
Taylor expanded in phi2 around 0
Applied rewrites80.2%
Final simplification62.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (sin (- lambda1 lambda2)))
(t_2 (* t_1 (cos phi2))))
(if (<= phi2 -0.0022)
(atan2 t_2 (- t_0 (* (sin phi1) (cos lambda2))))
(if (<= phi2 0.24)
(atan2 (* 1.0 t_1) (- t_0 (* (sin phi1) (cos (- lambda1 lambda2)))))
(atan2 t_2 (- t_0 (* (sin phi1) (cos lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin((lambda1 - lambda2));
double t_2 = t_1 * cos(phi2);
double tmp;
if (phi2 <= -0.0022) {
tmp = atan2(t_2, (t_0 - (sin(phi1) * cos(lambda2))));
} else if (phi2 <= 0.24) {
tmp = atan2((1.0 * t_1), (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_2, (t_0 - (sin(phi1) * 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) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin((lambda1 - lambda2))
t_2 = t_1 * cos(phi2)
if (phi2 <= (-0.0022d0)) then
tmp = atan2(t_2, (t_0 - (sin(phi1) * cos(lambda2))))
else if (phi2 <= 0.24d0) then
tmp = atan2((1.0d0 * t_1), (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))))
else
tmp = atan2(t_2, (t_0 - (sin(phi1) * 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((lambda1 - lambda2));
double t_2 = t_1 * Math.cos(phi2);
double tmp;
if (phi2 <= -0.0022) {
tmp = Math.atan2(t_2, (t_0 - (Math.sin(phi1) * Math.cos(lambda2))));
} else if (phi2 <= 0.24) {
tmp = Math.atan2((1.0 * t_1), (t_0 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2(t_2, (t_0 - (Math.sin(phi1) * Math.cos(lambda1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin((lambda1 - lambda2)) t_2 = t_1 * math.cos(phi2) tmp = 0 if phi2 <= -0.0022: tmp = math.atan2(t_2, (t_0 - (math.sin(phi1) * math.cos(lambda2)))) elif phi2 <= 0.24: tmp = math.atan2((1.0 * t_1), (t_0 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2(t_2, (t_0 - (math.sin(phi1) * math.cos(lambda1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = sin(Float64(lambda1 - lambda2)) t_2 = Float64(t_1 * cos(phi2)) tmp = 0.0 if (phi2 <= -0.0022) tmp = atan(t_2, Float64(t_0 - Float64(sin(phi1) * cos(lambda2)))); elseif (phi2 <= 0.24) tmp = atan(Float64(1.0 * t_1), Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_2, Float64(t_0 - Float64(sin(phi1) * cos(lambda1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin((lambda1 - lambda2)); t_2 = t_1 * cos(phi2); tmp = 0.0; if (phi2 <= -0.0022) tmp = atan2(t_2, (t_0 - (sin(phi1) * cos(lambda2)))); elseif (phi2 <= 0.24) tmp = atan2((1.0 * t_1), (t_0 - (sin(phi1) * cos((lambda1 - lambda2))))); else tmp = atan2(t_2, (t_0 - (sin(phi1) * 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[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.0022], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 0.24], N[ArcTan[N[(1.0 * t$95$1), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * 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 \left(\lambda_1 - \lambda_2\right)\\
t_2 := t\_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.0022:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - \sin \phi_1 \cdot \cos \lambda_2}\\
\mathbf{elif}\;\phi_2 \leq 0.24:\\
\;\;\;\;\tan^{-1}_* \frac{1 \cdot t\_1}{t\_0 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - \sin \phi_1 \cdot \cos \lambda_1}\\
\end{array}
\end{array}
if phi2 < -0.00220000000000000013Initial program 77.2%
Taylor expanded in phi2 around 0
lower-sin.f6446.2
Applied rewrites46.2%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lower-cos.f6446.1
Applied rewrites46.1%
if -0.00220000000000000013 < phi2 < 0.23999999999999999Initial program 81.1%
Taylor expanded in phi2 around 0
lower-sin.f6479.9
Applied rewrites79.9%
Taylor expanded in phi2 around 0
associate-*r*N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f64N/A
lower--.f6479.9
Applied rewrites79.9%
Taylor expanded in phi2 around 0
Applied rewrites80.2%
if 0.23999999999999999 < phi2 Initial program 66.4%
Taylor expanded in phi2 around 0
lower-sin.f6447.2
Applied rewrites47.2%
Taylor expanded in lambda2 around 0
lower-cos.f6446.9
Applied rewrites46.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (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(phi2)), ((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(phi2)), ((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(phi2)), ((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(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * 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(sin(phi1) * 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((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[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) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 76.4%
Taylor expanded in phi2 around 0
lower-sin.f6462.5
Applied rewrites62.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -0.0022) (not (<= phi2 0.24)))
(atan2 (* t_0 (cos phi2)) (sin phi2))
(atan2
(* 1.0 t_0)
(-
(* (cos phi1) (sin phi2))
(* (sin phi1) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.0022) || !(phi2 <= 0.24)) {
tmp = atan2((t_0 * cos(phi2)), sin(phi2));
} else {
tmp = atan2((1.0 * t_0), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if ((phi2 <= (-0.0022d0)) .or. (.not. (phi2 <= 0.24d0))) then
tmp = atan2((t_0 * cos(phi2)), sin(phi2))
else
tmp = atan2((1.0d0 * t_0), ((cos(phi1) * sin(phi2)) - (sin(phi1) * 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((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.0022) || !(phi2 <= 0.24)) {
tmp = Math.atan2((t_0 * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2((1.0 * t_0), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi2 <= -0.0022) or not (phi2 <= 0.24): tmp = math.atan2((t_0 * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2((1.0 * t_0), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -0.0022) || !(phi2 <= 0.24)) tmp = atan(Float64(t_0 * cos(phi2)), sin(phi2)); else tmp = atan(Float64(1.0 * t_0), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi2 <= -0.0022) || ~((phi2 <= 0.24))) tmp = atan2((t_0 * cos(phi2)), sin(phi2)); else tmp = atan2((1.0 * t_0), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.0022], N[Not[LessEqual[phi2, 0.24]], $MachinePrecision]], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(1.0 * t$95$0), $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}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.0022 \lor \neg \left(\phi_2 \leq 0.24\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{1 \cdot t\_0}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.00220000000000000013 or 0.23999999999999999 < phi2 Initial program 72.0%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6444.7
Applied rewrites44.7%
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
sin-+PI/2-revN/A
lift-sin.f64N/A
sin-multN/A
lower-/.f64N/A
Applied rewrites31.7%
Taylor expanded in phi1 around 0
lower-sin.f6430.8
Applied rewrites30.8%
Taylor expanded in lambda1 around 0
lower--.f6444.7
Applied rewrites44.7%
if -0.00220000000000000013 < phi2 < 0.23999999999999999Initial program 81.1%
Taylor expanded in phi2 around 0
lower-sin.f6479.9
Applied rewrites79.9%
Taylor expanded in phi2 around 0
associate-*r*N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f64N/A
lower--.f6479.9
Applied rewrites79.9%
Taylor expanded in phi2 around 0
Applied rewrites80.2%
Final simplification61.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -0.0195)
(atan2
(* (fma (* phi2 phi2) -0.5 1.0) (- lambda1 lambda2))
(- (* (cos phi1) (sin phi2)) (* (sin phi1) (cos (- lambda1 lambda2)))))
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.0195) {
tmp = atan2((fma((phi2 * phi2), -0.5, 1.0) * (lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.0195) tmp = atan(Float64(fma(Float64(phi2 * phi2), -0.5, 1.0) * Float64(lambda1 - lambda2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), sin(phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.0195], N[ArcTan[N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * 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], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.0195:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if phi1 < -0.0195Initial program 79.7%
Taylor expanded in phi2 around 0
lower-sin.f6455.1
Applied rewrites55.1%
Taylor expanded in phi2 around 0
associate-*r*N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f64N/A
lower--.f6448.2
Applied rewrites48.2%
Taylor expanded in lambda2 around 0
Applied rewrites36.1%
Taylor expanded in lambda1 around 0
Applied rewrites26.4%
if -0.0195 < phi1 Initial program 75.2%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6448.1
Applied rewrites48.1%
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
sin-+PI/2-revN/A
lift-sin.f64N/A
sin-multN/A
lower-/.f64N/A
Applied rewrites37.7%
Taylor expanded in phi1 around 0
lower-sin.f6436.6
Applied rewrites36.6%
Taylor expanded in lambda1 around 0
lower--.f6455.2
Applied rewrites55.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -0.065) (not (<= phi2 0.086)))
(atan2 (* (sin (- lambda2)) (cos phi2)) (sin phi2))
(atan2
(* (fma (* phi2 phi2) -0.5 1.0) (sin (- lambda1 lambda2)))
(sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -0.065) || !(phi2 <= 0.086)) {
tmp = atan2((sin(-lambda2) * cos(phi2)), sin(phi2));
} else {
tmp = atan2((fma((phi2 * phi2), -0.5, 1.0) * sin((lambda1 - lambda2))), sin(phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -0.065) || !(phi2 <= 0.086)) tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(fma(Float64(phi2 * phi2), -0.5, 1.0) * sin(Float64(lambda1 - lambda2))), sin(phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -0.065], N[Not[LessEqual[phi2, 0.086]], $MachinePrecision]], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -0.065 \lor \neg \left(\phi_2 \leq 0.086\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < -0.065000000000000002 or 0.085999999999999993 < phi2 Initial program 72.2%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6445.1
Applied rewrites45.1%
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
sin-+PI/2-revN/A
lift-sin.f64N/A
sin-multN/A
lower-/.f64N/A
Applied rewrites31.6%
Taylor expanded in phi1 around 0
lower-sin.f6430.8
Applied rewrites30.8%
if -0.065000000000000002 < phi2 < 0.085999999999999993Initial program 81.0%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6452.2
Applied rewrites52.2%
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
sin-+PI/2-revN/A
lift-sin.f64N/A
sin-multN/A
lower-/.f64N/A
Applied rewrites34.0%
Taylor expanded in phi1 around 0
lower-sin.f6431.3
Applied rewrites31.3%
Taylor expanded in phi2 around 0
associate-*r*N/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f64N/A
lower--.f6446.9
Applied rewrites46.9%
Final simplification38.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), Math.sin(phi2));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), math.sin(phi2))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), sin(phi2)) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}
\end{array}
Initial program 76.4%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6448.5
Applied rewrites48.5%
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
sin-+PI/2-revN/A
lift-sin.f64N/A
sin-multN/A
lower-/.f64N/A
Applied rewrites32.7%
Taylor expanded in phi1 around 0
lower-sin.f6431.0
Applied rewrites31.0%
Taylor expanded in lambda1 around 0
lower--.f6445.7
Applied rewrites45.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (fma (* phi2 phi2) -0.5 1.0) (sin (- lambda1 lambda2))) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma((phi2 * phi2), -0.5, 1.0) * sin((lambda1 - lambda2))), sin(phi2));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(Float64(phi2 * phi2), -0.5, 1.0) * sin(Float64(lambda1 - lambda2))), sin(phi2)) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2}
\end{array}
Initial program 76.4%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6448.5
Applied rewrites48.5%
lift-*.f64N/A
*-commutativeN/A
lift-cos.f64N/A
sin-+PI/2-revN/A
lift-sin.f64N/A
sin-multN/A
lower-/.f64N/A
Applied rewrites32.7%
Taylor expanded in phi1 around 0
lower-sin.f6431.0
Applied rewrites31.0%
Taylor expanded in phi2 around 0
associate-*r*N/A
distribute-rgt1-inN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-sin.f64N/A
lower--.f6427.2
Applied rewrites27.2%
herbie shell --seed 2025006
(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))))))