
(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 25 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 phi2))
(- (cos lambda1))
(* (* (sin lambda1) (cos 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(fma((sin(lambda2) * cos(phi2)), -cos(lambda1), ((sin(lambda1) * cos(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(fma(Float64(sin(lambda2) * cos(phi2)), Float64(-cos(lambda1)), Float64(Float64(sin(lambda1) * cos(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[Sin[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $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 \cdot \cos \phi_2, -\cos \lambda_1, \left(\sin \lambda_1 \cdot \cos \lambda_2\right) \cdot \cos \phi_2\right)}{\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 81.1%
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.f6490.3
Applied rewrites90.3%
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.7
Applied rewrites99.7%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6499.7
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(fma
(* (cos lambda2) (sin lambda1))
(cos phi2)
(* (* (- (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(fma((cos(lambda2) * sin(lambda1)), cos(phi2), ((-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(fma(Float64(cos(lambda2) * sin(lambda1)), cos(phi2), Float64(Float64(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[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[(N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $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(\cos \lambda_2 \cdot \sin \lambda_1, \cos \phi_2, \left(\left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2\right)}{\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 81.1%
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.f6490.3
Applied rewrites90.3%
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.7
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (fma (- (sin lambda2)) (cos lambda1) (* (cos lambda2) (sin lambda1))) (cos phi2)) (fma (* (- (sin phi1)) (cos phi2)) (fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1))) (* (sin phi2) (cos phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(-sin(lambda2), cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), fma((-sin(phi1) * cos(phi2)), fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1))), (sin(phi2) * cos(phi1))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(Float64(-sin(lambda2)), cos(lambda1), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), fma(Float64(Float64(-sin(phi1)) * cos(phi2)), fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1))), Float64(sin(phi2) * cos(phi1)))) 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[Sin[phi1], $MachinePrecision]) * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(-\sin \lambda_2, \cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\left(-\sin \phi_1\right) \cdot \cos \phi_2, \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right), \sin \phi_2 \cdot \cos \phi_1\right)}
\end{array}
Initial program 81.1%
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.f6490.3
Applied rewrites90.3%
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.7
Applied rewrites99.7%
Taylor expanded in lambda1 around 0
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(fma
(- (sin lambda2))
(cos lambda1)
(* (cos lambda2) (sin lambda1)))))
(if (or (<= phi2 -0.00011) (not (<= phi2 5e-10)))
(atan2
(* t_0 (cos phi2))
(fma
(- (cos phi2))
(* (cos (- lambda1 lambda2)) (sin phi1))
(* (sin phi2) (cos phi1))))
(atan2
t_0
(-
(* (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) {
double t_0 = fma(-sin(lambda2), cos(lambda1), (cos(lambda2) * sin(lambda1)));
double tmp;
if ((phi2 <= -0.00011) || !(phi2 <= 5e-10)) {
tmp = atan2((t_0 * cos(phi2)), fma(-cos(phi2), (cos((lambda1 - lambda2)) * sin(phi1)), (sin(phi2) * cos(phi1))));
} else {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = fma(Float64(-sin(lambda2)), cos(lambda1), Float64(cos(lambda2) * sin(lambda1))) tmp = 0.0 if ((phi2 <= -0.00011) || !(phi2 <= 5e-10)) tmp = atan(Float64(t_0 * cos(phi2)), fma(Float64(-cos(phi2)), Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)), Float64(sin(phi2) * cos(phi1)))); else tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2)))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -0.00011], N[Not[LessEqual[phi2, 5e-10]], $MachinePrecision]], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[((-N[Cos[phi2], $MachinePrecision]) * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / 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}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-\sin \lambda_2, \cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\right)\\
\mathbf{if}\;\phi_2 \leq -0.00011 \lor \neg \left(\phi_2 \leq 5 \cdot 10^{-10}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\mathsf{fma}\left(-\cos \phi_2, \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1, \sin \phi_2 \cdot \cos \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\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}
\end{array}
if phi2 < -1.10000000000000004e-4 or 5.00000000000000031e-10 < phi2 Initial program 73.2%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6487.2
Applied rewrites87.2%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lift-neg.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6487.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6487.2
Applied rewrites87.2%
Taylor expanded in lambda1 around 0
Applied rewrites87.3%
if -1.10000000000000004e-4 < phi2 < 5.00000000000000031e-10Initial program 87.4%
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.f6492.7
Applied rewrites92.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.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
Applied rewrites99.8%
Final simplification94.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (sin phi1) (cos phi2))))
(if (or (<= lambda2 -2.2e-5) (not (<= lambda2 0.00011)))
(atan2
(*
(- (* (cos lambda2) (sin lambda1)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(- t_0 (* t_1 (cos lambda2))))
(atan2
(* (fma (cos lambda1) (- lambda2) (sin lambda1)) (cos phi2))
(- t_0 (* t_1 (fma (sin lambda1) lambda2 (cos lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin(phi1) * cos(phi2);
double tmp;
if ((lambda2 <= -2.2e-5) || !(lambda2 <= 0.00011)) {
tmp = atan2((((cos(lambda2) * sin(lambda1)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))));
} else {
tmp = atan2((fma(cos(lambda1), -lambda2, sin(lambda1)) * cos(phi2)), (t_0 - (t_1 * fma(sin(lambda1), lambda2, cos(lambda1)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((lambda2 <= -2.2e-5) || !(lambda2 <= 0.00011)) tmp = atan(Float64(Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda2)))); else tmp = atan(Float64(fma(cos(lambda1), Float64(-lambda2), sin(lambda1)) * cos(phi2)), Float64(t_0 - Float64(t_1 * fma(sin(lambda1), lambda2, cos(lambda1))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -2.2e-5], N[Not[LessEqual[lambda2, 0.00011]], $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[(t$95$0 - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Cos[lambda1], $MachinePrecision] * (-lambda2) + N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[Sin[lambda1], $MachinePrecision] * lambda2 + N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\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 -2.2 \cdot 10^{-5} \lor \neg \left(\lambda_2 \leq 0.00011\right):\\
\;\;\;\;\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 - t\_1 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\cos \lambda_1, -\lambda_2, \sin \lambda_1\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \mathsf{fma}\left(\sin \lambda_1, \lambda_2, \cos \lambda_1\right)}\\
\end{array}
\end{array}
if lambda2 < -2.1999999999999999e-5 or 1.10000000000000004e-4 < lambda2 Initial program 59.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.f6479.3
Applied rewrites79.3%
Taylor expanded in lambda1 around 0
Applied rewrites79.4%
if -2.1999999999999999e-5 < lambda2 < 1.10000000000000004e-4Initial program 99.3%
Taylor expanded in lambda2 around 0
Applied rewrites99.5%
Taylor expanded in lambda2 around 0
Applied rewrites99.7%
Final simplification90.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (fma (- (sin lambda2)) (cos lambda1) (* (cos lambda2) (sin lambda1))) (cos phi2)) (fma (- (cos phi2)) (* (cos (- lambda1 lambda2)) (sin phi1)) (* (sin phi2) (cos phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(-sin(lambda2), cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), fma(-cos(phi2), (cos((lambda1 - lambda2)) * sin(phi1)), (sin(phi2) * cos(phi1))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(Float64(-sin(lambda2)), cos(lambda1), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), fma(Float64(-cos(phi2)), Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)), Float64(sin(phi2) * cos(phi1)))) 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[Cos[phi2], $MachinePrecision]) * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(-\sin \lambda_2, \cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-\cos \phi_2, \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1, \sin \phi_2 \cdot \cos \phi_1\right)}
\end{array}
Initial program 81.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.f6490.3
Applied rewrites90.3%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lift-neg.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6490.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.3
Applied rewrites90.3%
Taylor expanded in lambda1 around 0
Applied rewrites90.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(if (or (<= phi1 -7e+14) (not (<= phi1 1.25e-6)))
(atan2
(* (- (sin lambda1) (* (sin lambda2) (cos lambda1))) (cos phi2))
(- (* (cos phi1) (sin phi2)) t_0))
(atan2
(*
(fma (sin lambda2) (- (cos lambda1)) (* (sin lambda1) (cos lambda2)))
(cos phi2))
(- (sin phi2) t_0)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -7e+14) || !(phi1 <= 1.25e-6)) {
tmp = atan2(((sin(lambda1) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - t_0));
} else {
tmp = atan2((fma(sin(lambda2), -cos(lambda1), (sin(lambda1) * cos(lambda2))) * cos(phi2)), (sin(phi2) - t_0));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) tmp = 0.0 if ((phi1 <= -7e+14) || !(phi1 <= 1.25e-6)) tmp = atan(Float64(Float64(sin(lambda1) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - t_0)); else tmp = atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(sin(lambda1) * cos(lambda2))) * cos(phi2)), Float64(sin(phi2) - t_0)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -7e+14], N[Not[LessEqual[phi1, 1.25e-6]], $MachinePrecision]], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -7 \cdot 10^{+14} \lor \neg \left(\phi_1 \leq 1.25 \cdot 10^{-6}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - \sin \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_2, -\cos \lambda_1, \sin \lambda_1 \cdot \cos \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - t\_0}\\
\end{array}
\end{array}
if phi1 < -7e14 or 1.2500000000000001e-6 < phi1 Initial program 77.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.f6481.2
Applied rewrites81.2%
Taylor expanded in lambda2 around 0
Applied rewrites78.7%
if -7e14 < phi1 < 1.2500000000000001e-6Initial program 84.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.f6499.1
Applied rewrites99.1%
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
lift-neg.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.1
Applied rewrites99.1%
Taylor expanded in phi1 around 0
Applied rewrites99.1%
Final simplification89.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(if (or (<= phi1 -7e+14) (not (<= phi1 1.25e-6)))
(atan2
(* (- (sin lambda1) (* (sin lambda2) (cos lambda1))) (cos phi2))
(- (* (cos phi1) (sin phi2)) t_0))
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (sin lambda2)) (cos lambda1)))
(cos phi2))
(- (sin phi2) t_0)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -7e+14) || !(phi1 <= 1.25e-6)) {
tmp = atan2(((sin(lambda1) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - t_0));
} else {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-sin(lambda2) * cos(lambda1))) * cos(phi2)), (sin(phi2) - t_0));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) tmp = 0.0 if ((phi1 <= -7e+14) || !(phi1 <= 1.25e-6)) tmp = atan(Float64(Float64(sin(lambda1) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - t_0)); else tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-sin(lambda2)) * cos(lambda1))) * cos(phi2)), Float64(sin(phi2) - t_0)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -7e+14], N[Not[LessEqual[phi1, 1.25e-6]], $MachinePrecision]], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$0), $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[Sin[phi2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -7 \cdot 10^{+14} \lor \neg \left(\phi_1 \leq 1.25 \cdot 10^{-6}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - \sin \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0}\\
\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}{\sin \phi_2 - t\_0}\\
\end{array}
\end{array}
if phi1 < -7e14 or 1.2500000000000001e-6 < phi1 Initial program 77.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.f6481.2
Applied rewrites81.2%
Taylor expanded in lambda2 around 0
Applied rewrites78.7%
if -7e14 < phi1 < 1.2500000000000001e-6Initial program 84.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.f6499.1
Applied rewrites99.1%
Taylor expanded in phi1 around 0
Applied rewrites99.1%
Final simplification89.0%
(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 (* (sin lambda2) (cos lambda1))))
(if (<= phi1 -1.7e-15)
(atan2 (* (- (sin lambda1) t_3) (cos phi2)) t_2)
(if (<= phi1 3e-34)
(atan2
(* (- t_0 t_3) (cos phi2))
(- t_1 (* (cos (- lambda2 lambda1)) (sin phi1))))
(atan2 (* (- t_0 (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 = sin(lambda2) * cos(lambda1);
double tmp;
if (phi1 <= -1.7e-15) {
tmp = atan2(((sin(lambda1) - t_3) * cos(phi2)), t_2);
} else if (phi1 <= 3e-34) {
tmp = atan2(((t_0 - t_3) * cos(phi2)), (t_1 - (cos((lambda2 - lambda1)) * sin(phi1))));
} else {
tmp = atan2(((t_0 - sin(lambda2)) * cos(phi2)), t_2);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
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 = sin(lambda2) * cos(lambda1)
if (phi1 <= (-1.7d-15)) then
tmp = atan2(((sin(lambda1) - t_3) * cos(phi2)), t_2)
else if (phi1 <= 3d-34) then
tmp = atan2(((t_0 - t_3) * cos(phi2)), (t_1 - (cos((lambda2 - lambda1)) * sin(phi1))))
else
tmp = atan2(((t_0 - sin(lambda2)) * cos(phi2)), t_2)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(lambda2) * Math.sin(lambda1);
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double t_2 = t_1 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)));
double t_3 = Math.sin(lambda2) * Math.cos(lambda1);
double tmp;
if (phi1 <= -1.7e-15) {
tmp = Math.atan2(((Math.sin(lambda1) - t_3) * Math.cos(phi2)), t_2);
} else if (phi1 <= 3e-34) {
tmp = Math.atan2(((t_0 - t_3) * Math.cos(phi2)), (t_1 - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
} else {
tmp = Math.atan2(((t_0 - Math.sin(lambda2)) * Math.cos(phi2)), t_2);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda2) * math.sin(lambda1) t_1 = math.cos(phi1) * math.sin(phi2) t_2 = t_1 - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))) t_3 = math.sin(lambda2) * math.cos(lambda1) tmp = 0 if phi1 <= -1.7e-15: tmp = math.atan2(((math.sin(lambda1) - t_3) * math.cos(phi2)), t_2) elif phi1 <= 3e-34: tmp = math.atan2(((t_0 - t_3) * math.cos(phi2)), (t_1 - (math.cos((lambda2 - lambda1)) * math.sin(phi1)))) else: tmp = math.atan2(((t_0 - math.sin(lambda2)) * math.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(sin(lambda2) * cos(lambda1)) tmp = 0.0 if (phi1 <= -1.7e-15) tmp = atan(Float64(Float64(sin(lambda1) - t_3) * cos(phi2)), t_2); elseif (phi1 <= 3e-34) tmp = atan(Float64(Float64(t_0 - t_3) * cos(phi2)), Float64(t_1 - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))); else tmp = atan(Float64(Float64(t_0 - sin(lambda2)) * cos(phi2)), t_2); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) 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 = sin(lambda2) * cos(lambda1); tmp = 0.0; if (phi1 <= -1.7e-15) tmp = atan2(((sin(lambda1) - t_3) * cos(phi2)), t_2); elseif (phi1 <= 3e-34) tmp = atan2(((t_0 - t_3) * cos(phi2)), (t_1 - (cos((lambda2 - lambda1)) * sin(phi1)))); else tmp = atan2(((t_0 - sin(lambda2)) * cos(phi2)), t_2); end tmp_2 = 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[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.7e-15], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$3), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi1, 3e-34], N[ArcTan[N[(N[(t$95$0 - t$95$3), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(t$95$0 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $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 := \sin \lambda_2 \cdot \cos \lambda_1\\
\mathbf{if}\;\phi_1 \leq -1.7 \cdot 10^{-15}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_3\right) \cdot \cos \phi_2}{t\_2}\\
\mathbf{elif}\;\phi_1 \leq 3 \cdot 10^{-34}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_0 - t\_3\right) \cdot \cos \phi_2}{t\_1 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_0 - \sin \lambda_2\right) \cdot \cos \phi_2}{t\_2}\\
\end{array}
\end{array}
if phi1 < -1.7e-15Initial program 75.2%
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.f6478.8
Applied rewrites78.8%
Taylor expanded in lambda2 around 0
Applied rewrites76.2%
if -1.7e-15 < phi1 < 3e-34Initial program 84.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.f6499.8
Applied rewrites99.8%
Taylor expanded in phi2 around 0
Applied rewrites99.8%
if 3e-34 < phi1 Initial program 80.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.f6484.9
Applied rewrites84.9%
Taylor expanded in lambda1 around 0
Applied rewrites82.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (cos lambda2) (sin lambda1)) (sin lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((cos(lambda2) * sin(lambda1)) - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((cos(lambda2) * sin(lambda1)) - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.cos(lambda2) * Math.sin(lambda1)) - Math.sin(lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.cos(lambda2) * math.sin(lambda1)) - math.sin(lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(cos(lambda2) * sin(lambda1)) - sin(lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((cos(lambda2) * sin(lambda1)) - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[Sin[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{\left(\cos \lambda_2 \cdot \sin \lambda_1 - \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 81.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.f6490.3
Applied rewrites90.3%
Taylor expanded in lambda1 around 0
Applied rewrites82.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (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(((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(((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.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.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(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(((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[Sin[lambda1], $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(\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 81.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.f6490.3
Applied rewrites90.3%
Taylor expanded in lambda2 around 0
Applied rewrites81.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda1 -0.00105) (not (<= lambda1 19.5)))
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* (cos lambda2) (sin phi1)) (cos phi2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda1 <= -0.00105) || !(lambda1 <= 19.5)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda1 <= (-0.00105d0)) .or. (.not. (lambda1 <= 19.5d0))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda1 <= -0.00105) || !(lambda1 <= 19.5)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - ((Math.cos(lambda2) * Math.sin(phi1)) * Math.cos(phi2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda1 <= -0.00105) or not (lambda1 <= 19.5): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - ((math.cos(lambda2) * math.sin(phi1)) * math.cos(phi2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda1 <= -0.00105) || !(lambda1 <= 19.5)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda1 <= -0.00105) || ~((lambda1 <= 19.5))) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda2) * sin(phi1)) * cos(phi2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -0.00105], N[Not[LessEqual[lambda1, 19.5]], $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[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -0.00105 \lor \neg \left(\lambda_1 \leq 19.5\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\end{array}
\end{array}
if lambda1 < -0.00104999999999999994 or 19.5 < lambda1 Initial program 66.6%
Taylor expanded in lambda1 around inf
Applied rewrites65.6%
if -0.00104999999999999994 < lambda1 < 19.5Initial program 99.1%
Taylor expanded in lambda1 around 0
Applied rewrites99.2%
Final simplification80.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_2 (* (cos phi1) (sin phi2))))
(if (<= lambda1 -0.00105)
(atan2
(* (sin lambda1) (cos phi2))
(- t_2 (* t_0 (cos (- lambda1 lambda2)))))
(if (<= lambda1 4.5e-39)
(atan2 t_1 (- t_2 (* (* (cos lambda2) (sin phi1)) (cos phi2))))
(atan2 t_1 (- t_2 (* t_0 (cos lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double t_2 = cos(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -0.00105) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_2 - (t_0 * cos((lambda1 - lambda2)))));
} else if (lambda1 <= 4.5e-39) {
tmp = atan2(t_1, (t_2 - ((cos(lambda2) * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(phi1) * cos(phi2)
t_1 = sin((lambda1 - lambda2)) * cos(phi2)
t_2 = cos(phi1) * sin(phi2)
if (lambda1 <= (-0.00105d0)) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_2 - (t_0 * cos((lambda1 - lambda2)))))
else if (lambda1 <= 4.5d-39) then
tmp = atan2(t_1, (t_2 - ((cos(lambda2) * sin(phi1)) * cos(phi2))))
else
tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.cos(phi2);
double t_1 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double t_2 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (lambda1 <= -0.00105) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_2 - (t_0 * Math.cos((lambda1 - lambda2)))));
} else if (lambda1 <= 4.5e-39) {
tmp = Math.atan2(t_1, (t_2 - ((Math.cos(lambda2) * Math.sin(phi1)) * Math.cos(phi2))));
} else {
tmp = Math.atan2(t_1, (t_2 - (t_0 * Math.cos(lambda1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.cos(phi2) t_1 = math.sin((lambda1 - lambda2)) * math.cos(phi2) t_2 = math.cos(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -0.00105: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_2 - (t_0 * math.cos((lambda1 - lambda2))))) elif lambda1 <= 4.5e-39: tmp = math.atan2(t_1, (t_2 - ((math.cos(lambda2) * math.sin(phi1)) * math.cos(phi2)))) else: tmp = math.atan2(t_1, (t_2 - (t_0 * math.cos(lambda1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) t_2 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -0.00105) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_2 - Float64(t_0 * cos(Float64(lambda1 - lambda2))))); elseif (lambda1 <= 4.5e-39) tmp = atan(t_1, Float64(t_2 - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2)))); else tmp = atan(t_1, Float64(t_2 - Float64(t_0 * cos(lambda1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * cos(phi2); t_1 = sin((lambda1 - lambda2)) * cos(phi2); t_2 = cos(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -0.00105) tmp = atan2((sin(lambda1) * cos(phi2)), (t_2 - (t_0 * cos((lambda1 - lambda2))))); elseif (lambda1 <= 4.5e-39) tmp = atan2(t_1, (t_2 - ((cos(lambda2) * sin(phi1)) * cos(phi2)))); else tmp = atan2(t_1, (t_2 - (t_0 * cos(lambda1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -0.00105], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 4.5e-39], N[ArcTan[t$95$1 / N[(t$95$2 - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$2 - N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -0.00105:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_2 - t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{elif}\;\lambda_1 \leq 4.5 \cdot 10^{-39}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_2 - t\_0 \cdot \cos \lambda_1}\\
\end{array}
\end{array}
if lambda1 < -0.00104999999999999994Initial program 64.5%
Taylor expanded in lambda1 around inf
Applied rewrites65.0%
if -0.00104999999999999994 < lambda1 < 4.5000000000000001e-39Initial program 99.8%
Taylor expanded in lambda1 around 0
Applied rewrites99.8%
if 4.5000000000000001e-39 < lambda1 Initial program 71.5%
Taylor expanded in lambda1 around inf
Applied rewrites71.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (<= lambda1 -0.235)
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (cos (- lambda2 lambda1)) (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -0.235) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (cos((lambda2 - lambda1)) * sin(phi1))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if (lambda1 <= (-0.235d0)) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (cos((lambda2 - lambda1)) * sin(phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (lambda1 <= -0.235) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -0.235: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - (math.cos((lambda2 - lambda1)) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -0.235) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -0.235) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (cos((lambda2 - lambda1)) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -0.235], 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[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -0.235:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}\\
\end{array}
\end{array}
if lambda1 < -0.23499999999999999Initial program 64.5%
Taylor expanded in lambda1 around inf
Applied rewrites65.0%
if -0.23499999999999999 < lambda1 Initial program 86.7%
Taylor expanded in phi2 around 0
Applied rewrites77.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (<= lambda2 1.25e+94)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (cos (- lambda2 lambda1)) (sin phi1))))
(atan2
(* (sin (- lambda2)) (cos phi2))
(- t_0 (* (* (sin phi1) (cos lambda2)) (cos phi2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if (lambda2 <= 1.25e+94) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (cos((lambda2 - lambda1)) * sin(phi1))));
} else {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(lambda2)) * cos(phi2))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if (lambda2 <= 1.25d+94) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (cos((lambda2 - lambda1)) * sin(phi1))))
else
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(lambda2)) * cos(phi2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (lambda2 <= 1.25e+94) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
} else {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - ((Math.sin(phi1) * Math.cos(lambda2)) * Math.cos(phi2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if lambda2 <= 1.25e+94: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - (math.cos((lambda2 - lambda1)) * math.sin(phi1)))) else: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_0 - ((math.sin(phi1) * math.cos(lambda2)) * math.cos(phi2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda2 <= 1.25e+94) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))); else tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(lambda2)) * cos(phi2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if (lambda2 <= 1.25e+94) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (cos((lambda2 - lambda1)) * sin(phi1)))); else tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((sin(phi1) * cos(lambda2)) * cos(phi2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 1.25e+94], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq 1.25 \cdot 10^{+94}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \lambda_2\right) \cdot \cos \phi_2}\\
\end{array}
\end{array}
if lambda2 < 1.25000000000000003e94Initial program 84.7%
Taylor expanded in phi2 around 0
Applied rewrites74.6%
if 1.25000000000000003e94 < lambda2 Initial program 61.6%
Taylor expanded in lambda1 around 0
Applied rewrites62.5%
Taylor expanded in lambda1 around 0
Applied rewrites62.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 81.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6481.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 rewrites81.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (cos (- lambda2 lambda1)) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos((lambda2 - lambda1)) * sin(phi1))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos((lambda2 - lambda1)) * sin(phi1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.cos((lambda2 - lambda1)) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos((lambda2 - lambda1)) * sin(phi1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}
\end{array}
Initial program 81.1%
Taylor expanded in phi2 around 0
Applied rewrites70.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- (sin phi2) (* (cos (- lambda2 lambda1)) (sin phi1)))))
(if (or (<= lambda1 -4.6e-18) (not (<= lambda1 1.3e-13)))
(atan2 (* (sin lambda1) (cos phi2)) t_0)
(atan2 (* (sin (- lambda2)) (cos phi2)) t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1));
double tmp;
if ((lambda1 <= -4.6e-18) || !(lambda1 <= 1.3e-13)) {
tmp = atan2((sin(lambda1) * cos(phi2)), t_0);
} else {
tmp = atan2((sin(-lambda2) * cos(phi2)), t_0);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))
if ((lambda1 <= (-4.6d-18)) .or. (.not. (lambda1 <= 1.3d-13))) then
tmp = atan2((sin(lambda1) * cos(phi2)), t_0)
else
tmp = atan2((sin(-lambda2) * cos(phi2)), t_0)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi2) - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1));
double tmp;
if ((lambda1 <= -4.6e-18) || !(lambda1 <= 1.3e-13)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), t_0);
} else {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), t_0);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi2) - (math.cos((lambda2 - lambda1)) * math.sin(phi1)) tmp = 0 if (lambda1 <= -4.6e-18) or not (lambda1 <= 1.3e-13): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), t_0) else: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), t_0) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1))) tmp = 0.0 if ((lambda1 <= -4.6e-18) || !(lambda1 <= 1.3e-13)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), t_0); else tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), t_0); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1)); tmp = 0.0; if ((lambda1 <= -4.6e-18) || ~((lambda1 <= 1.3e-13))) tmp = atan2((sin(lambda1) * cos(phi2)), t_0); else tmp = atan2((sin(-lambda2) * cos(phi2)), t_0); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -4.6e-18], N[Not[LessEqual[lambda1, 1.3e-13]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1\\
\mathbf{if}\;\lambda_1 \leq -4.6 \cdot 10^{-18} \lor \neg \left(\lambda_1 \leq 1.3 \cdot 10^{-13}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0}\\
\end{array}
\end{array}
if lambda1 < -4.6000000000000002e-18 or 1.3e-13 < lambda1 Initial program 67.4%
Taylor expanded in phi2 around 0
Applied rewrites49.3%
Taylor expanded in phi2 around 0
Applied rewrites49.4%
Taylor expanded in phi1 around 0
Applied rewrites49.1%
Taylor expanded in lambda2 around 0
Applied rewrites58.2%
if -4.6000000000000002e-18 < lambda1 < 1.3e-13Initial program 99.8%
Taylor expanded in lambda1 around 0
Applied rewrites83.5%
Taylor expanded in phi2 around 0
Applied rewrites73.5%
Taylor expanded in phi1 around 0
Applied rewrites72.1%
Final simplification64.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= lambda1 -1.9e-6) (not (<= lambda1 4.7e-39)))
(atan2
(* (sin lambda1) (cos phi2))
(- (sin phi2) (* (cos (- lambda2 lambda1)) (sin phi1))))
(atan2
(sin (- lambda1 lambda2))
(- (* (cos phi1) (sin phi2)) (* (cos lambda2) (sin phi1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -1.9e-6) || !(lambda1 <= 4.7e-39)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))));
} else {
tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - (cos(lambda2) * sin(phi1))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((lambda1 <= (-1.9d-6)) .or. (.not. (lambda1 <= 4.7d-39))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))))
else
tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - (cos(lambda2) * sin(phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -1.9e-6) || !(lambda1 <= 4.7e-39)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (Math.sin(phi2) - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
} else {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(lambda2) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda1 <= -1.9e-6) or not (lambda1 <= 4.7e-39): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (math.sin(phi2) - (math.cos((lambda2 - lambda1)) * math.sin(phi1)))) else: tmp = math.atan2(math.sin((lambda1 - lambda2)), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(lambda2) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda1 <= -1.9e-6) || !(lambda1 <= 4.7e-39)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(sin(phi2) - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))); else tmp = atan(sin(Float64(lambda1 - lambda2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(lambda2) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda1 <= -1.9e-6) || ~((lambda1 <= 4.7e-39))) tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1)))); else tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - (cos(lambda2) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda1, -1.9e-6], N[Not[LessEqual[lambda1, 4.7e-39]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -1.9 \cdot 10^{-6} \lor \neg \left(\lambda_1 \leq 4.7 \cdot 10^{-39}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \cos \lambda_2 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if lambda1 < -1.9e-6 or 4.7000000000000002e-39 < lambda1 Initial program 68.7%
Taylor expanded in phi2 around 0
Applied rewrites48.8%
Taylor expanded in phi2 around 0
Applied rewrites49.0%
Taylor expanded in phi1 around 0
Applied rewrites48.7%
Taylor expanded in lambda2 around 0
Applied rewrites57.4%
if -1.9e-6 < lambda1 < 4.7000000000000002e-39Initial program 99.8%
Taylor expanded in phi2 around 0
Applied rewrites71.0%
Taylor expanded in phi2 around 0
Applied rewrites71.1%
Taylor expanded in lambda1 around 0
Applied rewrites71.1%
Final simplification62.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) (* (cos (- lambda2 lambda1)) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.cos((lambda2 - lambda1)) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}
\end{array}
Initial program 81.1%
Taylor expanded in phi2 around 0
Applied rewrites57.7%
Taylor expanded in phi2 around 0
Applied rewrites57.8%
Taylor expanded in phi1 around 0
Applied rewrites56.8%
Taylor expanded in lambda1 around inf
Applied rewrites69.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= lambda2 -1.2e-7)
(atan2 t_0 (- (sin phi2) (* (cos lambda2) (sin phi1))))
(if (<= lambda2 0.122)
(atan2 t_0 (- (sin phi2) (* (cos lambda1) (sin phi1))))
(atan2
(sin (- lambda2))
(- (sin phi2) (* (cos (- lambda2 lambda1)) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -1.2e-7) {
tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * sin(phi1))));
} else if (lambda2 <= 0.122) {
tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1))));
} else {
tmp = atan2(sin(-lambda2), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if (lambda2 <= (-1.2d-7)) then
tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * sin(phi1))))
else if (lambda2 <= 0.122d0) then
tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1))))
else
tmp = atan2(sin(-lambda2), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -1.2e-7) {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.cos(lambda2) * Math.sin(phi1))));
} else if (lambda2 <= 0.122) {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.cos(lambda1) * Math.sin(phi1))));
} else {
tmp = Math.atan2(Math.sin(-lambda2), (Math.sin(phi2) - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if lambda2 <= -1.2e-7: tmp = math.atan2(t_0, (math.sin(phi2) - (math.cos(lambda2) * math.sin(phi1)))) elif lambda2 <= 0.122: tmp = math.atan2(t_0, (math.sin(phi2) - (math.cos(lambda1) * math.sin(phi1)))) else: tmp = math.atan2(math.sin(-lambda2), (math.sin(phi2) - (math.cos((lambda2 - lambda1)) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (lambda2 <= -1.2e-7) tmp = atan(t_0, Float64(sin(phi2) - Float64(cos(lambda2) * sin(phi1)))); elseif (lambda2 <= 0.122) tmp = atan(t_0, Float64(sin(phi2) - Float64(cos(lambda1) * sin(phi1)))); else tmp = atan(sin(Float64(-lambda2)), Float64(sin(phi2) - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (lambda2 <= -1.2e-7) tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * sin(phi1)))); elseif (lambda2 <= 0.122) tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1)))); else tmp = atan2(sin(-lambda2), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -1.2e-7], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 0.122], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[Sin[(-lambda2)], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_2 \leq -1.2 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 - \cos \lambda_2 \cdot \sin \phi_1}\\
\mathbf{elif}\;\lambda_2 \leq 0.122:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 - \cos \lambda_1 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right)}{\sin \phi_2 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}\\
\end{array}
\end{array}
if lambda2 < -1.19999999999999989e-7Initial program 54.7%
Taylor expanded in phi2 around 0
Applied rewrites40.8%
Taylor expanded in phi2 around 0
Applied rewrites41.0%
Taylor expanded in phi1 around 0
Applied rewrites40.6%
Taylor expanded in lambda1 around 0
Applied rewrites40.5%
if -1.19999999999999989e-7 < lambda2 < 0.122Initial program 99.3%
Taylor expanded in phi2 around 0
Applied rewrites69.9%
Taylor expanded in phi2 around 0
Applied rewrites70.0%
Taylor expanded in phi1 around 0
Applied rewrites68.9%
Taylor expanded in lambda2 around 0
Applied rewrites68.9%
if 0.122 < lambda2 Initial program 62.6%
Taylor expanded in phi2 around 0
Applied rewrites44.5%
Taylor expanded in phi2 around 0
Applied rewrites44.5%
Taylor expanded in phi1 around 0
Applied rewrites43.4%
Taylor expanded in lambda1 around 0
Applied rewrites44.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= lambda1 -0.00013)
(atan2
(sin lambda1)
(- (sin phi2) (* (cos (- lambda2 lambda1)) (sin phi1))))
(if (<= lambda1 4.5e-39)
(atan2 t_0 (- (sin phi2) (* (cos lambda2) (sin phi1))))
(atan2 t_0 (- (sin phi2) (* (cos lambda1) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (lambda1 <= -0.00013) {
tmp = atan2(sin(lambda1), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))));
} else if (lambda1 <= 4.5e-39) {
tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * sin(phi1))));
} else {
tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if (lambda1 <= (-0.00013d0)) then
tmp = atan2(sin(lambda1), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))))
else if (lambda1 <= 4.5d-39) then
tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * sin(phi1))))
else
tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (lambda1 <= -0.00013) {
tmp = Math.atan2(Math.sin(lambda1), (Math.sin(phi2) - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
} else if (lambda1 <= 4.5e-39) {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.cos(lambda2) * Math.sin(phi1))));
} else {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.cos(lambda1) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if lambda1 <= -0.00013: tmp = math.atan2(math.sin(lambda1), (math.sin(phi2) - (math.cos((lambda2 - lambda1)) * math.sin(phi1)))) elif lambda1 <= 4.5e-39: tmp = math.atan2(t_0, (math.sin(phi2) - (math.cos(lambda2) * math.sin(phi1)))) else: tmp = math.atan2(t_0, (math.sin(phi2) - (math.cos(lambda1) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (lambda1 <= -0.00013) tmp = atan(sin(lambda1), Float64(sin(phi2) - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))); elseif (lambda1 <= 4.5e-39) tmp = atan(t_0, Float64(sin(phi2) - Float64(cos(lambda2) * sin(phi1)))); else tmp = atan(t_0, Float64(sin(phi2) - Float64(cos(lambda1) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (lambda1 <= -0.00013) tmp = atan2(sin(lambda1), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1)))); elseif (lambda1 <= 4.5e-39) tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * sin(phi1)))); else tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -0.00013], N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 4.5e-39], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -0.00013:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1}{\sin \phi_2 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}\\
\mathbf{elif}\;\lambda_1 \leq 4.5 \cdot 10^{-39}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 - \cos \lambda_2 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 - \cos \lambda_1 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if lambda1 < -1.29999999999999989e-4Initial program 65.0%
Taylor expanded in phi2 around 0
Applied rewrites43.0%
Taylor expanded in phi2 around 0
Applied rewrites43.3%
Taylor expanded in phi1 around 0
Applied rewrites43.0%
Taylor expanded in lambda1 around inf
Applied rewrites43.6%
if -1.29999999999999989e-4 < lambda1 < 4.5000000000000001e-39Initial program 99.8%
Taylor expanded in phi2 around 0
Applied rewrites71.0%
Taylor expanded in phi2 around 0
Applied rewrites71.1%
Taylor expanded in phi1 around 0
Applied rewrites69.1%
Taylor expanded in lambda1 around 0
Applied rewrites69.1%
if 4.5000000000000001e-39 < lambda1 Initial program 71.5%
Taylor expanded in phi2 around 0
Applied rewrites53.2%
Taylor expanded in phi2 around 0
Applied rewrites53.2%
Taylor expanded in phi1 around 0
Applied rewrites52.9%
Taylor expanded in lambda2 around 0
Applied rewrites53.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (- (sin phi2) (* (cos (- lambda2 lambda1)) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), (Math.sin(phi2) - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), (math.sin(phi2) - (math.cos((lambda2 - lambda1)) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), Float64(sin(phi2) - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}
\end{array}
Initial program 81.1%
Taylor expanded in phi2 around 0
Applied rewrites57.7%
Taylor expanded in phi2 around 0
Applied rewrites57.8%
Taylor expanded in phi1 around 0
Applied rewrites56.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (- (sin phi2) (* (cos lambda1) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), (sin(phi2) - (cos(lambda1) * sin(phi1))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (cos(lambda1) * sin(phi1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), (Math.sin(phi2) - (Math.cos(lambda1) * Math.sin(phi1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), (math.sin(phi2) - (math.cos(lambda1) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), Float64(sin(phi2) - Float64(cos(lambda1) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (cos(lambda1) * sin(phi1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \lambda_1 \cdot \sin \phi_1}
\end{array}
Initial program 81.1%
Taylor expanded in phi2 around 0
Applied rewrites57.7%
Taylor expanded in phi2 around 0
Applied rewrites57.8%
Taylor expanded in phi1 around 0
Applied rewrites56.8%
Taylor expanded in lambda2 around 0
Applied rewrites52.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin lambda1) (- (sin phi2) (* (cos (- lambda2 lambda1)) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin(lambda1), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin(lambda1), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin(lambda1), (Math.sin(phi2) - (Math.cos((lambda2 - lambda1)) * Math.sin(phi1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin(lambda1), (math.sin(phi2) - (math.cos((lambda2 - lambda1)) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(lambda1), Float64(sin(phi2) - Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin(lambda1), (sin(phi2) - (cos((lambda2 - lambda1)) * sin(phi1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1}{\sin \phi_2 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1}
\end{array}
Initial program 81.1%
Taylor expanded in phi2 around 0
Applied rewrites57.7%
Taylor expanded in phi2 around 0
Applied rewrites57.8%
Taylor expanded in phi1 around 0
Applied rewrites56.8%
Taylor expanded in lambda1 around inf
Applied rewrites40.9%
herbie shell --seed 2025021
(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))))))