
(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 42 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
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * ((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * ((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda1) * math.sin(lambda2))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 80.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.6
Applied rewrites89.6%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 80.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.6
Applied rewrites89.6%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_1 (* (sin phi1) (cos phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi2 -0.202)
(atan2 t_0 (- (* (cos phi1) (sin phi2)) (* t_1 t_2)))
(if (<= phi2 1.45)
(atan2
t_0
(-
(*
(cos phi1)
(*
phi2
(+
1.0
(*
(* phi2 phi2)
(-
(*
(* phi2 phi2)
(+
0.008333333333333333
(* -0.0001984126984126984 (* phi2 phi2))))
0.16666666666666666)))))
(*
t_1
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2))))))
(atan2
t_0
(fma (sin phi2) (cos phi1) (* (* (- (cos phi2)) (sin phi1)) t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_1 = sin(phi1) * cos(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -0.202) {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (t_1 * t_2)));
} else if (phi2 <= 1.45) {
tmp = atan2(t_0, ((cos(phi1) * (phi2 * (1.0 + ((phi2 * phi2) * (((phi2 * phi2) * (0.008333333333333333 + (-0.0001984126984126984 * (phi2 * phi2)))) - 0.16666666666666666))))) - (t_1 * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_0, fma(sin(phi2), cos(phi1), ((-cos(phi2) * sin(phi1)) * t_2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -0.202) tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_1 * t_2))); elseif (phi2 <= 1.45) tmp = atan(t_0, Float64(Float64(cos(phi1) * Float64(phi2 * Float64(1.0 + Float64(Float64(phi2 * phi2) * Float64(Float64(Float64(phi2 * phi2) * Float64(0.008333333333333333 + Float64(-0.0001984126984126984 * Float64(phi2 * phi2)))) - 0.16666666666666666))))) - Float64(t_1 * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_0, fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-cos(phi2)) * sin(phi1)) * t_2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.202], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 1.45], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(phi2 * N[(1.0 + N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * N[(0.008333333333333333 + N[(-0.0001984126984126984 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Cos[phi2], $MachinePrecision]) * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.202:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \sin \phi_2 - t\_1 \cdot t\_2}\\
\mathbf{elif}\;\phi_2 \leq 1.45:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \left(\phi_2 \cdot \left(1 + \left(\phi_2 \cdot \phi_2\right) \cdot \left(\left(\phi_2 \cdot \phi_2\right) \cdot \left(0.008333333333333333 + -0.0001984126984126984 \cdot \left(\phi_2 \cdot \phi_2\right)\right) - 0.16666666666666666\right)\right)\right) - t\_1 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\cos \phi_2\right) \cdot \sin \phi_1\right) \cdot t\_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.20200000000000001Initial program 74.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6488.9
Applied rewrites88.9%
if -0.20200000000000001 < phi2 < 1.44999999999999996Initial program 83.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.4
Applied rewrites89.4%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.2
Applied rewrites99.2%
if 1.44999999999999996 < phi2 Initial program 79.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.6
Applied rewrites90.6%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites90.6%
Final simplification94.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_1 (* (sin phi1) (cos phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi2 -0.202)
(atan2 t_0 (- (* (cos phi1) (sin phi2)) (* t_1 t_2)))
(if (<= phi2 1.45)
(atan2
t_0
(-
(*
(cos phi1)
(*
phi2
(+
1.0
(*
(* phi2 phi2)
(-
(*
(* phi2 phi2)
(+
0.008333333333333333
(* -0.0001984126984126984 (* phi2 phi2))))
0.16666666666666666)))))
(*
t_1
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2
t_0
(fma (sin phi2) (cos phi1) (* (* (- (cos phi2)) (sin phi1)) t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_1 = sin(phi1) * cos(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -0.202) {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (t_1 * t_2)));
} else if (phi2 <= 1.45) {
tmp = atan2(t_0, ((cos(phi1) * (phi2 * (1.0 + ((phi2 * phi2) * (((phi2 * phi2) * (0.008333333333333333 + (-0.0001984126984126984 * (phi2 * phi2)))) - 0.16666666666666666))))) - (t_1 * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_0, fma(sin(phi2), cos(phi1), ((-cos(phi2) * sin(phi1)) * t_2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -0.202) tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_1 * t_2))); elseif (phi2 <= 1.45) tmp = atan(t_0, Float64(Float64(cos(phi1) * Float64(phi2 * Float64(1.0 + Float64(Float64(phi2 * phi2) * Float64(Float64(Float64(phi2 * phi2) * Float64(0.008333333333333333 + Float64(-0.0001984126984126984 * Float64(phi2 * phi2)))) - 0.16666666666666666))))) - Float64(t_1 * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_0, fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-cos(phi2)) * sin(phi1)) * t_2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.202], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 1.45], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(phi2 * N[(1.0 + N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * N[(0.008333333333333333 + N[(-0.0001984126984126984 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Cos[phi2], $MachinePrecision]) * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.202:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \sin \phi_2 - t\_1 \cdot t\_2}\\
\mathbf{elif}\;\phi_2 \leq 1.45:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \left(\phi_2 \cdot \left(1 + \left(\phi_2 \cdot \phi_2\right) \cdot \left(\left(\phi_2 \cdot \phi_2\right) \cdot \left(0.008333333333333333 + -0.0001984126984126984 \cdot \left(\phi_2 \cdot \phi_2\right)\right) - 0.16666666666666666\right)\right)\right) - t\_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\cos \phi_2\right) \cdot \sin \phi_1\right) \cdot t\_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.20200000000000001Initial program 74.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6488.9
Applied rewrites88.9%
if -0.20200000000000001 < phi2 < 1.44999999999999996Initial program 83.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.4
Applied rewrites89.4%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.2
Applied rewrites99.2%
if 1.44999999999999996 < phi2 Initial program 79.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.6
Applied rewrites90.6%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites90.6%
Final simplification94.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi2 -0.202)
(atan2 t_1 (- t_0 (* (* (sin phi1) (cos phi2)) t_2)))
(if (<= phi2 1.45)
(atan2
t_1
(-
t_0
(*
(*
(sin phi1)
(+
1.0
(*
(* phi2 phi2)
(-
(*
(* phi2 phi2)
(+
0.041666666666666664
(* -0.001388888888888889 (* phi2 phi2))))
0.5))))
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2))))))
(atan2
t_1
(fma (sin phi2) (cos phi1) (* (* (- (cos phi2)) (sin phi1)) t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -0.202) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * t_2)));
} else if (phi2 <= 1.45) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * (1.0 + ((phi2 * phi2) * (((phi2 * phi2) * (0.041666666666666664 + (-0.001388888888888889 * (phi2 * phi2)))) - 0.5)))) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), ((-cos(phi2) * sin(phi1)) * t_2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -0.202) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_2))); elseif (phi2 <= 1.45) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * Float64(1.0 + Float64(Float64(phi2 * phi2) * Float64(Float64(Float64(phi2 * phi2) * Float64(0.041666666666666664 + Float64(-0.001388888888888889 * Float64(phi2 * phi2)))) - 0.5)))) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-cos(phi2)) * sin(phi1)) * t_2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.202], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 1.45], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[(1.0 + N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * N[(0.041666666666666664 + N[(-0.001388888888888889 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Cos[phi2], $MachinePrecision]) * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.202:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_2}\\
\mathbf{elif}\;\phi_2 \leq 1.45:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \left(1 + \left(\phi_2 \cdot \phi_2\right) \cdot \left(\left(\phi_2 \cdot \phi_2\right) \cdot \left(0.041666666666666664 + -0.001388888888888889 \cdot \left(\phi_2 \cdot \phi_2\right)\right) - 0.5\right)\right)\right) \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\cos \phi_2\right) \cdot \sin \phi_1\right) \cdot t\_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.20200000000000001Initial program 74.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6488.9
Applied rewrites88.9%
if -0.20200000000000001 < phi2 < 1.44999999999999996Initial program 83.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.4
Applied rewrites89.4%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.2
Applied rewrites99.2%
if 1.44999999999999996 < phi2 Initial program 79.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.6
Applied rewrites90.6%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites90.6%
Final simplification94.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi2 -0.202)
(atan2 t_1 (- t_0 (* (* (sin phi1) (cos phi2)) t_2)))
(if (<= phi2 1.45)
(atan2
t_1
(-
t_0
(*
(*
(sin phi1)
(+
1.0
(*
(* phi2 phi2)
(-
(*
(* phi2 phi2)
(+
0.041666666666666664
(* -0.001388888888888889 (* phi2 phi2))))
0.5))))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2
t_1
(fma (sin phi2) (cos phi1) (* (* (- (cos phi2)) (sin phi1)) t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -0.202) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * t_2)));
} else if (phi2 <= 1.45) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * (1.0 + ((phi2 * phi2) * (((phi2 * phi2) * (0.041666666666666664 + (-0.001388888888888889 * (phi2 * phi2)))) - 0.5)))) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), ((-cos(phi2) * sin(phi1)) * t_2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -0.202) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_2))); elseif (phi2 <= 1.45) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * Float64(1.0 + Float64(Float64(phi2 * phi2) * Float64(Float64(Float64(phi2 * phi2) * Float64(0.041666666666666664 + Float64(-0.001388888888888889 * Float64(phi2 * phi2)))) - 0.5)))) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-cos(phi2)) * sin(phi1)) * t_2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.202], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 1.45], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[(1.0 + N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * N[(0.041666666666666664 + N[(-0.001388888888888889 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Cos[phi2], $MachinePrecision]) * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.202:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_2}\\
\mathbf{elif}\;\phi_2 \leq 1.45:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \left(1 + \left(\phi_2 \cdot \phi_2\right) \cdot \left(\left(\phi_2 \cdot \phi_2\right) \cdot \left(0.041666666666666664 + -0.001388888888888889 \cdot \left(\phi_2 \cdot \phi_2\right)\right) - 0.5\right)\right)\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\cos \phi_2\right) \cdot \sin \phi_1\right) \cdot t\_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.20200000000000001Initial program 74.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6488.9
Applied rewrites88.9%
if -0.20200000000000001 < phi2 < 1.44999999999999996Initial program 83.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.4
Applied rewrites89.4%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.2
Applied rewrites99.2%
if 1.44999999999999996 < phi2 Initial program 79.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.6
Applied rewrites90.6%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites90.6%
Final simplification94.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi2 -0.19)
(atan2 t_1 (- t_0 (* (* (sin phi1) (cos phi2)) t_2)))
(if (<= phi2 1.45)
(atan2
t_1
(-
t_0
(*
(*
(sin phi1)
(+
1.0
(* (* phi2 phi2) (- (* 0.041666666666666664 (* phi2 phi2)) 0.5))))
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2))))))
(atan2
t_1
(fma (sin phi2) (cos phi1) (* (* (- (cos phi2)) (sin phi1)) t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -0.19) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * t_2)));
} else if (phi2 <= 1.45) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * (1.0 + ((phi2 * phi2) * ((0.041666666666666664 * (phi2 * phi2)) - 0.5)))) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), ((-cos(phi2) * sin(phi1)) * t_2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -0.19) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_2))); elseif (phi2 <= 1.45) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * Float64(1.0 + Float64(Float64(phi2 * phi2) * Float64(Float64(0.041666666666666664 * Float64(phi2 * phi2)) - 0.5)))) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-cos(phi2)) * sin(phi1)) * t_2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.19], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 1.45], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[(1.0 + N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(0.041666666666666664 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Cos[phi2], $MachinePrecision]) * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.19:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_2}\\
\mathbf{elif}\;\phi_2 \leq 1.45:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \left(1 + \left(\phi_2 \cdot \phi_2\right) \cdot \left(0.041666666666666664 \cdot \left(\phi_2 \cdot \phi_2\right) - 0.5\right)\right)\right) \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\cos \phi_2\right) \cdot \sin \phi_1\right) \cdot t\_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.19Initial program 74.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6488.9
Applied rewrites88.9%
if -0.19 < phi2 < 1.44999999999999996Initial program 83.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.4
Applied rewrites89.4%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.0
Applied rewrites99.0%
if 1.44999999999999996 < phi2 Initial program 79.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.6
Applied rewrites90.6%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites90.6%
Final simplification94.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi2 -0.19)
(atan2 t_1 (- t_0 (* (* (sin phi1) (cos phi2)) t_2)))
(if (<= phi2 1.45)
(atan2
t_1
(-
t_0
(*
(*
(sin phi1)
(+
1.0
(* (* phi2 phi2) (- (* 0.041666666666666664 (* phi2 phi2)) 0.5))))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2
t_1
(fma (sin phi2) (cos phi1) (* (* (- (cos phi2)) (sin phi1)) t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -0.19) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * t_2)));
} else if (phi2 <= 1.45) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * (1.0 + ((phi2 * phi2) * ((0.041666666666666664 * (phi2 * phi2)) - 0.5)))) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), ((-cos(phi2) * sin(phi1)) * t_2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -0.19) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_2))); elseif (phi2 <= 1.45) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * Float64(1.0 + Float64(Float64(phi2 * phi2) * Float64(Float64(0.041666666666666664 * Float64(phi2 * phi2)) - 0.5)))) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-cos(phi2)) * sin(phi1)) * t_2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.19], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 1.45], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[(1.0 + N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(0.041666666666666664 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Cos[phi2], $MachinePrecision]) * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.19:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_2}\\
\mathbf{elif}\;\phi_2 \leq 1.45:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \left(1 + \left(\phi_2 \cdot \phi_2\right) \cdot \left(0.041666666666666664 \cdot \left(\phi_2 \cdot \phi_2\right) - 0.5\right)\right)\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\cos \phi_2\right) \cdot \sin \phi_1\right) \cdot t\_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.19Initial program 74.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6488.9
Applied rewrites88.9%
if -0.19 < phi2 < 1.44999999999999996Initial program 83.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.4
Applied rewrites89.4%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.0
Applied rewrites99.0%
if 1.44999999999999996 < phi2 Initial program 79.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.6
Applied rewrites90.6%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites90.6%
Final simplification94.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi2 -0.185)
(atan2 t_1 (- t_0 (* (* (sin phi1) (cos phi2)) t_2)))
(if (<= phi2 3e-30)
(atan2
t_1
(-
t_0
(*
(* (sin phi1) (+ 1.0 (* -0.5 (* phi2 phi2))))
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2))))))
(atan2
t_1
(fma (sin phi2) (cos phi1) (* (* (- (cos phi2)) (sin phi1)) t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -0.185) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * t_2)));
} else if (phi2 <= 3e-30) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * (1.0 + (-0.5 * (phi2 * phi2)))) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), ((-cos(phi2) * sin(phi1)) * t_2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -0.185) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_2))); elseif (phi2 <= 3e-30) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2)))) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-cos(phi2)) * sin(phi1)) * t_2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.185], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 3e-30], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Cos[phi2], $MachinePrecision]) * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.185:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_2}\\
\mathbf{elif}\;\phi_2 \leq 3 \cdot 10^{-30}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right)\right) \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\cos \phi_2\right) \cdot \sin \phi_1\right) \cdot t\_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.185Initial program 74.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6488.9
Applied rewrites88.9%
if -0.185 < phi2 < 2.9999999999999999e-30Initial program 83.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.4
Applied rewrites89.4%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.4
Applied rewrites99.4%
if 2.9999999999999999e-30 < phi2 Initial program 80.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.5
Applied rewrites90.5%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites90.6%
Final simplification94.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi2 -0.185)
(atan2 t_1 (- t_0 (* (* (sin phi1) (cos phi2)) t_2)))
(if (<= phi2 3e-30)
(atan2
t_1
(-
t_0
(*
(* (sin phi1) (+ 1.0 (* -0.5 (* phi2 phi2))))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2
t_1
(fma (sin phi2) (cos phi1) (* (* (- (cos phi2)) (sin phi1)) t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -0.185) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * t_2)));
} else if (phi2 <= 3e-30) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * (1.0 + (-0.5 * (phi2 * phi2)))) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), ((-cos(phi2) * sin(phi1)) * t_2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -0.185) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_2))); elseif (phi2 <= 3e-30) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2)))) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-cos(phi2)) * sin(phi1)) * t_2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.185], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 3e-30], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Cos[phi2], $MachinePrecision]) * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.185:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_2}\\
\mathbf{elif}\;\phi_2 \leq 3 \cdot 10^{-30}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right)\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\cos \phi_2\right) \cdot \sin \phi_1\right) \cdot t\_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.185Initial program 74.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6488.9
Applied rewrites88.9%
if -0.185 < phi2 < 2.9999999999999999e-30Initial program 83.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.4
Applied rewrites89.4%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6499.4
Applied rewrites99.4%
if 2.9999999999999999e-30 < phi2 Initial program 80.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.5
Applied rewrites90.5%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites90.6%
Final simplification94.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi2 -0.185)
(atan2 t_1 (- t_0 (* (* (sin phi1) (cos phi2)) t_2)))
(if (<= phi2 3e-30)
(atan2
t_1
(-
t_0
(*
(sin phi1)
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2))))))
(atan2
t_1
(fma (sin phi2) (cos phi1) (* (* (- (cos phi2)) (sin phi1)) t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -0.185) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * t_2)));
} else if (phi2 <= 3e-30) {
tmp = atan2(t_1, (t_0 - (sin(phi1) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), ((-cos(phi2) * sin(phi1)) * t_2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -0.185) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_2))); elseif (phi2 <= 3e-30) tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-cos(phi2)) * sin(phi1)) * t_2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.185], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 3e-30], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Cos[phi2], $MachinePrecision]) * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.185:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_2}\\
\mathbf{elif}\;\phi_2 \leq 3 \cdot 10^{-30}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \sin \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\cos \phi_2\right) \cdot \sin \phi_1\right) \cdot t\_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.185Initial program 74.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6488.9
Applied rewrites88.9%
if -0.185 < phi2 < 2.9999999999999999e-30Initial program 83.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.4
Applied rewrites89.4%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
lift-sin.f6499.3
Applied rewrites99.3%
if 2.9999999999999999e-30 < phi2 Initial program 80.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.5
Applied rewrites90.5%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites90.6%
Final simplification94.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi2 -0.185)
(atan2 t_1 (- t_0 (* (* (sin phi1) (cos phi2)) t_2)))
(if (<= phi2 3e-30)
(atan2
t_1
(-
t_0
(*
(sin phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2
t_1
(fma (sin phi2) (cos phi1) (* (* (- (cos phi2)) (sin phi1)) t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -0.185) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * t_2)));
} else if (phi2 <= 3e-30) {
tmp = atan2(t_1, (t_0 - (sin(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), ((-cos(phi2) * sin(phi1)) * t_2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -0.185) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_2))); elseif (phi2 <= 3e-30) tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-cos(phi2)) * sin(phi1)) * t_2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.185], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 3e-30], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Cos[phi2], $MachinePrecision]) * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.185:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_2}\\
\mathbf{elif}\;\phi_2 \leq 3 \cdot 10^{-30}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \sin \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\cos \phi_2\right) \cdot \sin \phi_1\right) \cdot t\_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.185Initial program 74.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6488.9
Applied rewrites88.9%
if -0.185 < phi2 < 2.9999999999999999e-30Initial program 83.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.4
Applied rewrites89.4%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
lift-sin.f6499.3
Applied rewrites99.3%
if 2.9999999999999999e-30 < phi2 Initial program 80.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.5
Applied rewrites90.5%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites90.6%
Final simplification94.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_1 (* (sin phi1) (cos phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi2 -0.185)
(atan2 t_0 (- (* (cos phi1) (sin phi2)) (* t_1 t_2)))
(if (<= phi2 3e-30)
(atan2
t_0
(-
(sin phi2)
(*
t_1
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2
t_0
(fma (sin phi2) (cos phi1) (* (* (- (cos phi2)) (sin phi1)) t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_1 = sin(phi1) * cos(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -0.185) {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (t_1 * t_2)));
} else if (phi2 <= 3e-30) {
tmp = atan2(t_0, (sin(phi2) - (t_1 * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_0, fma(sin(phi2), cos(phi1), ((-cos(phi2) * sin(phi1)) * t_2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -0.185) tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_1 * t_2))); elseif (phi2 <= 3e-30) tmp = atan(t_0, Float64(sin(phi2) - Float64(t_1 * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_0, fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-cos(phi2)) * sin(phi1)) * t_2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.185], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 3e-30], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$1 * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Cos[phi2], $MachinePrecision]) * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.185:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \sin \phi_2 - t\_1 \cdot t\_2}\\
\mathbf{elif}\;\phi_2 \leq 3 \cdot 10^{-30}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 - t\_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\cos \phi_2\right) \cdot \sin \phi_1\right) \cdot t\_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.185Initial program 74.4%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6488.9
Applied rewrites88.9%
if -0.185 < phi2 < 2.9999999999999999e-30Initial program 83.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.4
Applied rewrites89.4%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi1 around 0
lift-sin.f6499.2
Applied rewrites99.2%
if 2.9999999999999999e-30 < phi2 Initial program 80.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.5
Applied rewrites90.5%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites90.6%
Final simplification94.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(fma
(sin phi2)
(cos phi1)
(* (- (cos lambda1)) (* (cos phi2) (sin phi1)))))))
(if (<= lambda1 -0.00034)
t_0
(if (<= lambda1 5.8e+23)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(sin(phi2), cos(phi1), (-cos(lambda1) * (cos(phi2) * sin(phi1)))));
double tmp;
if (lambda1 <= -0.00034) {
tmp = t_0;
} else if (lambda1 <= 5.8e+23) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = t_0;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-cos(lambda1)) * Float64(cos(phi2) * sin(phi1))))) tmp = 0.0 if (lambda1 <= -0.00034) tmp = t_0; elseif (lambda1 <= 5.8e+23) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = t_0; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -0.00034], t$95$0, If[LessEqual[lambda1, 5.8e+23], 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[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \lambda_1\right) \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)\right)}\\
\mathbf{if}\;\lambda_1 \leq -0.00034:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_1 \leq 5.8 \cdot 10^{+23}:\\
\;\;\;\;\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 \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda1 < -3.4e-4 or 5.80000000000000025e23 < lambda1 Initial program 61.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.6
Applied rewrites80.6%
Taylor expanded in lambda2 around 0
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites80.8%
if -3.4e-4 < lambda1 < 5.80000000000000025e23Initial program 98.0%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6498.2
Applied rewrites98.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(fma
(sin phi2)
(cos phi1)
(* (- (cos lambda1)) (* (cos phi2) (sin phi1)))))))
(if (<= lambda1 -0.00034)
t_0
(if (<= lambda1 0.00205)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma
(+ (* (* (cos lambda2) lambda1) -0.5) (sin lambda2))
lambda1
(cos lambda2)))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(sin(phi2), cos(phi1), (-cos(lambda1) * (cos(phi2) * sin(phi1)))));
double tmp;
if (lambda1 <= -0.00034) {
tmp = t_0;
} else if (lambda1 <= 0.00205) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma((((cos(lambda2) * lambda1) * -0.5) + sin(lambda2)), lambda1, cos(lambda2)))));
} else {
tmp = t_0;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-cos(lambda1)) * Float64(cos(phi2) * sin(phi1))))) tmp = 0.0 if (lambda1 <= -0.00034) tmp = t_0; elseif (lambda1 <= 0.00205) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(Float64(Float64(Float64(cos(lambda2) * lambda1) * -0.5) + sin(lambda2)), lambda1, cos(lambda2))))); else tmp = t_0; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -0.00034], t$95$0, If[LessEqual[lambda1, 0.00205], 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[(N[(N[(N[(N[Cos[lambda2], $MachinePrecision] * lambda1), $MachinePrecision] * -0.5), $MachinePrecision] + N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * lambda1 + N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \lambda_1\right) \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)\right)}\\
\mathbf{if}\;\lambda_1 \leq -0.00034:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_1 \leq 0.00205:\\
\;\;\;\;\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 \mathsf{fma}\left(\left(\cos \lambda_2 \cdot \lambda_1\right) \cdot -0.5 + \sin \lambda_2, \lambda_1, \cos \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda1 < -3.4e-4 or 0.00205000000000000017 < lambda1 Initial program 61.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.3
Applied rewrites80.3%
Taylor expanded in lambda2 around 0
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites80.4%
if -3.4e-4 < lambda1 < 0.00205000000000000017Initial program 98.6%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
cos-negN/A
lower-cos.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f6498.7
Applied rewrites98.7%
Final simplification89.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))) (cos phi2)) (fma (sin phi2) (cos phi1) (* (* (- (cos phi2)) (sin phi1)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(sin(phi2), cos(phi1), ((-cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(Float64(-cos(phi2)) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[((-N[Cos[phi2], $MachinePrecision]) * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(\left(-\cos \phi_2\right) \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}
\end{array}
Initial program 80.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.6
Applied rewrites89.6%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
Applied rewrites89.6%
Final simplification89.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 80.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.6
Applied rewrites89.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin lambda1) (cos lambda2)))
(t_1 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))
(t_2 (- (* (cos phi1) (sin phi2)) t_1))
(t_3 (* (cos lambda1) (sin lambda2))))
(if (<= phi1 -2.6e-7)
(atan2 (* (- (sin lambda1) t_3) (cos phi2)) t_2)
(if (<= phi1 4.6e+48)
(atan2 (* (- t_0 t_3) (cos phi2)) (- (sin phi2) t_1))
(atan2 (* (- t_0 (sin lambda2)) (cos phi2)) t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(lambda1) * cos(lambda2);
double t_1 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2));
double t_2 = (cos(phi1) * sin(phi2)) - t_1;
double t_3 = cos(lambda1) * sin(lambda2);
double tmp;
if (phi1 <= -2.6e-7) {
tmp = atan2(((sin(lambda1) - t_3) * cos(phi2)), t_2);
} else if (phi1 <= 4.6e+48) {
tmp = atan2(((t_0 - t_3) * cos(phi2)), (sin(phi2) - t_1));
} 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 = sin(lambda1) * cos(lambda2)
t_1 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))
t_2 = (cos(phi1) * sin(phi2)) - t_1
t_3 = cos(lambda1) * sin(lambda2)
if (phi1 <= (-2.6d-7)) then
tmp = atan2(((sin(lambda1) - t_3) * cos(phi2)), t_2)
else if (phi1 <= 4.6d+48) then
tmp = atan2(((t_0 - t_3) * cos(phi2)), (sin(phi2) - t_1))
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.sin(lambda1) * Math.cos(lambda2);
double t_1 = (Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2));
double t_2 = (Math.cos(phi1) * Math.sin(phi2)) - t_1;
double t_3 = Math.cos(lambda1) * Math.sin(lambda2);
double tmp;
if (phi1 <= -2.6e-7) {
tmp = Math.atan2(((Math.sin(lambda1) - t_3) * Math.cos(phi2)), t_2);
} else if (phi1 <= 4.6e+48) {
tmp = Math.atan2(((t_0 - t_3) * Math.cos(phi2)), (Math.sin(phi2) - t_1));
} 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.sin(lambda1) * math.cos(lambda2) t_1 = (math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)) t_2 = (math.cos(phi1) * math.sin(phi2)) - t_1 t_3 = math.cos(lambda1) * math.sin(lambda2) tmp = 0 if phi1 <= -2.6e-7: tmp = math.atan2(((math.sin(lambda1) - t_3) * math.cos(phi2)), t_2) elif phi1 <= 4.6e+48: tmp = math.atan2(((t_0 - t_3) * math.cos(phi2)), (math.sin(phi2) - t_1)) 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(sin(lambda1) * cos(lambda2)) t_1 = Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) t_2 = Float64(Float64(cos(phi1) * sin(phi2)) - t_1) t_3 = Float64(cos(lambda1) * sin(lambda2)) tmp = 0.0 if (phi1 <= -2.6e-7) tmp = atan(Float64(Float64(sin(lambda1) - t_3) * cos(phi2)), t_2); elseif (phi1 <= 4.6e+48) tmp = atan(Float64(Float64(t_0 - t_3) * cos(phi2)), Float64(sin(phi2) - t_1)); 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 = sin(lambda1) * cos(lambda2); t_1 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)); t_2 = (cos(phi1) * sin(phi2)) - t_1; t_3 = cos(lambda1) * sin(lambda2); tmp = 0.0; if (phi1 <= -2.6e-7) tmp = atan2(((sin(lambda1) - t_3) * cos(phi2)), t_2); elseif (phi1 <= 4.6e+48) tmp = atan2(((t_0 - t_3) * cos(phi2)), (sin(phi2) - t_1)); 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[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -2.6e-7], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$3), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi1, 4.6e+48], N[ArcTan[N[(N[(t$95$0 - t$95$3), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - t$95$1), $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 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_1 := \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_1 \cdot \sin \phi_2 - t\_1\\
t_3 := \cos \lambda_1 \cdot \sin \lambda_2\\
\mathbf{if}\;\phi_1 \leq -2.6 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_3\right) \cdot \cos \phi_2}{t\_2}\\
\mathbf{elif}\;\phi_1 \leq 4.6 \cdot 10^{+48}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_0 - t\_3\right) \cdot \cos \phi_2}{\sin \phi_2 - t\_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 < -2.59999999999999999e-7Initial program 72.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6477.1
Applied rewrites77.1%
Taylor expanded in lambda2 around 0
lift-sin.f6474.6
Applied rewrites74.6%
if -2.59999999999999999e-7 < phi1 < 4.6e48Initial program 84.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.6
Applied rewrites98.6%
Taylor expanded in phi1 around 0
lift-sin.f6498.6
Applied rewrites98.6%
if 4.6e48 < phi1 Initial program 77.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.9
Applied rewrites80.9%
Taylor expanded in lambda1 around 0
lift-sin.f6479.0
Applied rewrites79.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin lambda1) (cos lambda2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_1)))
(t_3 (* (cos lambda1) (sin lambda2))))
(if (<= phi1 -2.6e-7)
(atan2 (* (- (sin lambda1) t_3) (cos phi2)) t_2)
(if (<= phi1 4.6e+48)
(atan2
(* (- t_0 t_3) (cos phi2))
(fma (- phi1) (* t_1 (cos phi2)) (sin phi2)))
(atan2 (* (- t_0 (sin lambda2)) (cos phi2)) t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(lambda1) * cos(lambda2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = (cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_1);
double t_3 = cos(lambda1) * sin(lambda2);
double tmp;
if (phi1 <= -2.6e-7) {
tmp = atan2(((sin(lambda1) - t_3) * cos(phi2)), t_2);
} else if (phi1 <= 4.6e+48) {
tmp = atan2(((t_0 - t_3) * cos(phi2)), fma(-phi1, (t_1 * cos(phi2)), sin(phi2)));
} else {
tmp = atan2(((t_0 - sin(lambda2)) * cos(phi2)), t_2);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(lambda1) * cos(lambda2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_1)) t_3 = Float64(cos(lambda1) * sin(lambda2)) tmp = 0.0 if (phi1 <= -2.6e-7) tmp = atan(Float64(Float64(sin(lambda1) - t_3) * cos(phi2)), t_2); elseif (phi1 <= 4.6e+48) tmp = atan(Float64(Float64(t_0 - t_3) * cos(phi2)), fma(Float64(-phi1), Float64(t_1 * cos(phi2)), sin(phi2))); else tmp = atan(Float64(Float64(t_0 - sin(lambda2)) * cos(phi2)), t_2); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -2.6e-7], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$3), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi1, 4.6e+48], N[ArcTan[N[(N[(t$95$0 - t$95$3), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[((-phi1) * N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Sin[phi2], $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 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\\
t_3 := \cos \lambda_1 \cdot \sin \lambda_2\\
\mathbf{if}\;\phi_1 \leq -2.6 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_3\right) \cdot \cos \phi_2}{t\_2}\\
\mathbf{elif}\;\phi_1 \leq 4.6 \cdot 10^{+48}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_0 - t\_3\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-\phi_1, t\_1 \cdot \cos \phi_2, \sin \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_0 - \sin \lambda_2\right) \cdot \cos \phi_2}{t\_2}\\
\end{array}
\end{array}
if phi1 < -2.59999999999999999e-7Initial program 72.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6477.1
Applied rewrites77.1%
Taylor expanded in lambda2 around 0
lift-sin.f6474.6
Applied rewrites74.6%
if -2.59999999999999999e-7 < phi1 < 4.6e48Initial program 84.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.6
Applied rewrites98.6%
Taylor expanded in phi1 around 0
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites98.5%
if 4.6e48 < phi1 Initial program 77.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.9
Applied rewrites80.9%
Taylor expanded in lambda1 around 0
lift-sin.f6479.0
Applied rewrites79.0%
Final simplification88.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_0)))
(t_2 (* (cos lambda1) (sin lambda2))))
(if (<= phi1 -2.6e-7)
(atan2 (* (- (sin lambda1) t_2) (cos phi2)) t_1)
(if (<= phi1 4.6e+48)
(atan2
(* (- (* (sin lambda1) (cos lambda2)) t_2) (cos phi2))
(fma (- phi1) (* t_0 (cos phi2)) (sin phi2)))
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = (cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0);
double t_2 = cos(lambda1) * sin(lambda2);
double tmp;
if (phi1 <= -2.6e-7) {
tmp = atan2(((sin(lambda1) - t_2) * cos(phi2)), t_1);
} else if (phi1 <= 4.6e+48) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_2) * cos(phi2)), fma(-phi1, (t_0 * cos(phi2)), sin(phi2)));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), t_1);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0)) t_2 = Float64(cos(lambda1) * sin(lambda2)) tmp = 0.0 if (phi1 <= -2.6e-7) tmp = atan(Float64(Float64(sin(lambda1) - t_2) * cos(phi2)), t_1); elseif (phi1 <= 4.6e+48) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - t_2) * cos(phi2)), fma(Float64(-phi1), Float64(t_0 * cos(phi2)), sin(phi2))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), t_1); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -2.6e-7], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$2), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision], If[LessEqual[phi1, 4.6e+48], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[((-phi1) * N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\\
t_2 := \cos \lambda_1 \cdot \sin \lambda_2\\
\mathbf{if}\;\phi_1 \leq -2.6 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_2\right) \cdot \cos \phi_2}{t\_1}\\
\mathbf{elif}\;\phi_1 \leq 4.6 \cdot 10^{+48}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-\phi_1, t\_0 \cdot \cos \phi_2, \sin \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_1}\\
\end{array}
\end{array}
if phi1 < -2.59999999999999999e-7Initial program 72.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6477.1
Applied rewrites77.1%
Taylor expanded in lambda2 around 0
lift-sin.f6474.6
Applied rewrites74.6%
if -2.59999999999999999e-7 < phi1 < 4.6e48Initial program 84.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6498.6
Applied rewrites98.6%
Taylor expanded in phi1 around 0
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites98.5%
if 4.6e48 < phi1 Initial program 77.8%
Final simplification88.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* t_1 (cos phi2)))
(t_3 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -1.95e+14)
(atan2 t_3 (- t_0 (* (sin phi1) t_2)))
(if (<= phi1 4.6e+48)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(fma (- phi1) t_2 (sin phi2)))
(atan2 t_3 (- t_0 (* (* (sin phi1) (cos phi2)) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = t_1 * cos(phi2);
double t_3 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi1 <= -1.95e+14) {
tmp = atan2(t_3, (t_0 - (sin(phi1) * t_2)));
} else if (phi1 <= 4.6e+48) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(-phi1, t_2, sin(phi2)));
} else {
tmp = atan2(t_3, (t_0 - ((sin(phi1) * cos(phi2)) * t_1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(t_1 * cos(phi2)) t_3 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -1.95e+14) tmp = atan(t_3, Float64(t_0 - Float64(sin(phi1) * t_2))); elseif (phi1 <= 4.6e+48) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(Float64(-phi1), t_2, sin(phi2))); else tmp = atan(t_3, Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_1))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.95e+14], N[ArcTan[t$95$3 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 4.6e+48], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[((-phi1) * t$95$2 + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$3 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := t\_1 \cdot \cos \phi_2\\
t_3 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -1.95 \cdot 10^{+14}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_3}{t\_0 - \sin \phi_1 \cdot t\_2}\\
\mathbf{elif}\;\phi_1 \leq 4.6 \cdot 10^{+48}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(-\phi_1, t\_2, \sin \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_3}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_1}\\
\end{array}
\end{array}
if phi1 < -1.95e14Initial program 73.1%
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6473.2
Applied rewrites73.2%
if -1.95e14 < phi1 < 4.6e48Initial program 84.2%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6497.6
Applied rewrites97.6%
Taylor expanded in phi1 around 0
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites97.3%
if 4.6e48 < phi1 Initial program 77.8%
Final simplification87.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -5e-86)
(atan2 t_2 (- t_0 (* (sin phi1) (* t_1 (cos phi2)))))
(if (<= phi1 5.35e-14)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
(atan2 t_2 (- t_0 (* (* (sin phi1) (cos phi2)) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi1 <= -5e-86) {
tmp = atan2(t_2, (t_0 - (sin(phi1) * (t_1 * cos(phi2)))));
} else if (phi1 <= 5.35e-14) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2(t_2, (t_0 - ((sin(phi1) * cos(phi2)) * t_1)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
t_2 = sin((lambda1 - lambda2)) * cos(phi2)
if (phi1 <= (-5d-86)) then
tmp = atan2(t_2, (t_0 - (sin(phi1) * (t_1 * cos(phi2)))))
else if (phi1 <= 5.35d-14) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
else
tmp = atan2(t_2, (t_0 - ((sin(phi1) * cos(phi2)) * t_1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double tmp;
if (phi1 <= -5e-86) {
tmp = Math.atan2(t_2, (t_0 - (Math.sin(phi1) * (t_1 * Math.cos(phi2)))));
} else if (phi1 <= 5.35e-14) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2(t_2, (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if phi1 <= -5e-86: tmp = math.atan2(t_2, (t_0 - (math.sin(phi1) * (t_1 * math.cos(phi2))))) elif phi1 <= 5.35e-14: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2(t_2, (t_0 - ((math.sin(phi1) * math.cos(phi2)) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -5e-86) tmp = atan(t_2, Float64(t_0 - Float64(sin(phi1) * Float64(t_1 * cos(phi2))))); elseif (phi1 <= 5.35e-14) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan(t_2, Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); t_2 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if (phi1 <= -5e-86) tmp = atan2(t_2, (t_0 - (sin(phi1) * (t_1 * cos(phi2))))); elseif (phi1 <= 5.35e-14) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan2(t_2, (t_0 - ((sin(phi1) * cos(phi2)) * t_1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -5e-86], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 5.35e-14], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -5 \cdot 10^{-86}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - \sin \phi_1 \cdot \left(t\_1 \cdot \cos \phi_2\right)}\\
\mathbf{elif}\;\phi_1 \leq 5.35 \cdot 10^{-14}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_1}\\
\end{array}
\end{array}
if phi1 < -4.9999999999999999e-86Initial program 78.9%
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6479.0
Applied rewrites79.0%
if -4.9999999999999999e-86 < phi1 < 5.3499999999999999e-14Initial program 83.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi1 around 0
lift-sin.f6498.4
Applied rewrites98.4%
if 5.3499999999999999e-14 < phi1 Initial program 76.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (sin phi1) (* (cos (- lambda1 lambda2)) (cos phi2)))))))
(if (<= phi1 -5e-86)
t_0
(if (<= phi1 5.35e-14)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos((lambda1 - lambda2)) * cos(phi2)))));
double tmp;
if (phi1 <= -5e-86) {
tmp = t_0;
} else if (phi1 <= 5.35e-14) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos((lambda1 - lambda2)) * cos(phi2)))))
if (phi1 <= (-5d-86)) then
tmp = t_0
else if (phi1 <= 5.35d-14) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * (Math.cos((lambda1 - lambda2)) * Math.cos(phi2)))));
double tmp;
if (phi1 <= -5e-86) {
tmp = t_0;
} else if (phi1 <= 5.35e-14) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * (math.cos((lambda1 - lambda2)) * math.cos(phi2))))) tmp = 0 if phi1 <= -5e-86: tmp = t_0 elif phi1 <= 5.35e-14: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * Float64(cos(Float64(lambda1 - lambda2)) * cos(phi2))))) tmp = 0.0 if (phi1 <= -5e-86) tmp = t_0; elseif (phi1 <= 5.35e-14) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos((lambda1 - lambda2)) * cos(phi2))))); tmp = 0.0; if (phi1 <= -5e-86) tmp = t_0; elseif (phi1 <= 5.35e-14) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -5e-86], t$95$0, If[LessEqual[phi1, 5.35e-14], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\right)}\\
\mathbf{if}\;\phi_1 \leq -5 \cdot 10^{-86}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 5.35 \cdot 10^{-14}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi1 < -4.9999999999999999e-86 or 5.3499999999999999e-14 < phi1 Initial program 77.9%
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6477.9
Applied rewrites77.9%
if -4.9999999999999999e-86 < phi1 < 5.3499999999999999e-14Initial program 83.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi1 around 0
lift-sin.f6498.4
Applied rewrites98.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))))
(if (<= lambda1 -0.027)
t_0
(if (<= lambda1 5.8e+23)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (sin phi1) (* (cos lambda2) (cos phi2)))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
double tmp;
if (lambda1 <= -0.027) {
tmp = t_0;
} else if (lambda1 <= 5.8e+23) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(lambda2) * cos(phi2)))));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
if (lambda1 <= (-0.027d0)) then
tmp = t_0
else if (lambda1 <= 5.8d+23) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(lambda2) * cos(phi2)))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
double tmp;
if (lambda1 <= -0.027) {
tmp = t_0;
} else if (lambda1 <= 5.8e+23) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * (Math.cos(lambda2) * Math.cos(phi2)))));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) tmp = 0 if lambda1 <= -0.027: tmp = t_0 elif lambda1 <= 5.8e+23: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * (math.cos(lambda2) * math.cos(phi2))))) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)) tmp = 0.0 if (lambda1 <= -0.027) tmp = t_0; elseif (lambda1 <= 5.8e+23) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * Float64(cos(lambda2) * cos(phi2))))); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); tmp = 0.0; if (lambda1 <= -0.027) tmp = t_0; elseif (lambda1 <= 5.8e+23) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(lambda2) * cos(phi2))))); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -0.027], t$95$0, If[LessEqual[lambda1, 5.8e+23], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\lambda_1 \leq -0.027:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_1 \leq 5.8 \cdot 10^{+23}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda1 < -0.0269999999999999997 or 5.80000000000000025e23 < lambda1 Initial program 61.3%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.3
Applied rewrites80.3%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.6
Applied rewrites99.6%
Taylor expanded in phi1 around 0
lift-sin.f6466.2
Applied rewrites66.2%
if -0.0269999999999999997 < lambda1 < 5.80000000000000025e23Initial program 98.0%
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6498.0
Applied rewrites98.0%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
lift-cos.f6497.7
Applied rewrites97.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))))
(if (<= lambda2 -0.0041)
t_0
(if (<= lambda2 0.11)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(fma
(sin phi2)
(cos phi1)
(* (- (cos lambda1)) (* (sin phi1) (cos phi2)))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
double tmp;
if (lambda2 <= -0.0041) {
tmp = t_0;
} else if (lambda2 <= 0.11) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), (-cos(lambda1) * (sin(phi1) * cos(phi2)))));
} else {
tmp = t_0;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)) tmp = 0.0 if (lambda2 <= -0.0041) tmp = t_0; elseif (lambda2 <= 0.11) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-cos(lambda1)) * Float64(sin(phi1) * cos(phi2))))); else tmp = t_0; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -0.0041], t$95$0, If[LessEqual[lambda2, 0.11], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\lambda_2 \leq -0.0041:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_2 \leq 0.11:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \lambda_1\right) \cdot \left(\sin \phi_1 \cdot \cos \phi_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda2 < -0.00410000000000000035 or 0.110000000000000001 < lambda2 Initial program 63.2%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.8
Applied rewrites80.8%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.6
Applied rewrites99.6%
Taylor expanded in phi1 around 0
lift-sin.f6462.1
Applied rewrites62.1%
if -0.00410000000000000035 < lambda2 < 0.110000000000000001Initial program 99.2%
Taylor expanded in lambda2 around 0
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-cos.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f6499.2
Applied rewrites99.2%
Final simplification79.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -5e-86)
(atan2 t_1 (- (sin phi2) (* (* (sin phi1) (cos phi2)) t_0)))
(if (<= phi1 5.35e-14)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
(atan2 t_1 (- (* (cos phi1) (sin phi2)) (* (sin phi1) t_0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi1 <= -5e-86) {
tmp = atan2(t_1, (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0)));
} else if (phi1 <= 5.35e-14) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = sin((lambda1 - lambda2)) * cos(phi2)
if (phi1 <= (-5d-86)) then
tmp = atan2(t_1, (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0)))
else if (phi1 <= 5.35d-14) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
else
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double tmp;
if (phi1 <= -5e-86) {
tmp = Math.atan2(t_1, (Math.sin(phi2) - ((Math.sin(phi1) * Math.cos(phi2)) * t_0)));
} else if (phi1 <= 5.35e-14) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2(t_1, ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * t_0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if phi1 <= -5e-86: tmp = math.atan2(t_1, (math.sin(phi2) - ((math.sin(phi1) * math.cos(phi2)) * t_0))) elif phi1 <= 5.35e-14: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2(t_1, ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * t_0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -5e-86) tmp = atan(t_1, Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))); elseif (phi1 <= 5.35e-14) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if (phi1 <= -5e-86) tmp = atan2(t_1, (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0))); elseif (phi1 <= 5.35e-14) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -5e-86], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 5.35e-14], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -5 \cdot 10^{-86}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\
\mathbf{elif}\;\phi_1 \leq 5.35 \cdot 10^{-14}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\end{array}
\end{array}
if phi1 < -4.9999999999999999e-86Initial program 78.9%
Taylor expanded in phi1 around 0
lift-sin.f6461.9
Applied rewrites61.9%
if -4.9999999999999999e-86 < phi1 < 5.3499999999999999e-14Initial program 83.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi1 around 0
lift-sin.f6498.4
Applied rewrites98.4%
if 5.3499999999999999e-14 < phi1 Initial program 76.8%
Taylor expanded in phi2 around 0
lift-sin.f6449.0
Applied rewrites49.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -5e-86)
(atan2 t_1 (- (sin phi2) (* (* (sin phi1) (cos phi2)) t_0)))
(if (<= phi1 1.8e-13)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))
(atan2 t_1 (* t_0 (- (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi1 <= -5e-86) {
tmp = atan2(t_1, (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0)));
} else if (phi1 <= 1.8e-13) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2(t_1, (t_0 * -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) :: t_1
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = sin((lambda1 - lambda2)) * cos(phi2)
if (phi1 <= (-5d-86)) then
tmp = atan2(t_1, (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0)))
else if (phi1 <= 1.8d-13) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
else
tmp = atan2(t_1, (t_0 * -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((lambda1 - lambda2));
double t_1 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double tmp;
if (phi1 <= -5e-86) {
tmp = Math.atan2(t_1, (Math.sin(phi2) - ((Math.sin(phi1) * Math.cos(phi2)) * t_0)));
} else if (phi1 <= 1.8e-13) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2(t_1, (t_0 * -Math.sin(phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if phi1 <= -5e-86: tmp = math.atan2(t_1, (math.sin(phi2) - ((math.sin(phi1) * math.cos(phi2)) * t_0))) elif phi1 <= 1.8e-13: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2(t_1, (t_0 * -math.sin(phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -5e-86) tmp = atan(t_1, Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))); elseif (phi1 <= 1.8e-13) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan(t_1, Float64(t_0 * Float64(-sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if (phi1 <= -5e-86) tmp = atan2(t_1, (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0))); elseif (phi1 <= 1.8e-13) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan2(t_1, (t_0 * -sin(phi1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -5e-86], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.8e-13], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -5 \cdot 10^{-86}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\
\mathbf{elif}\;\phi_1 \leq 1.8 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 \cdot \left(-\sin \phi_1\right)}\\
\end{array}
\end{array}
if phi1 < -4.9999999999999999e-86Initial program 78.9%
Taylor expanded in phi1 around 0
lift-sin.f6461.9
Applied rewrites61.9%
if -4.9999999999999999e-86 < phi1 < 1.7999999999999999e-13Initial program 83.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi1 around 0
lift-sin.f6498.4
Applied rewrites98.4%
if 1.7999999999999999e-13 < phi1 Initial program 76.8%
Taylor expanded in phi2 around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6447.3
Applied rewrites47.3%
Final simplification74.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(sin phi2))))
(if (<= phi2 -0.00019)
t_0
(if (<= phi2 1.45)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (* (cos phi1) phi2) (* (cos (- lambda1 lambda2)) (sin phi1))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
double tmp;
if (phi2 <= -0.00019) {
tmp = t_0;
} else if (phi2 <= 1.45) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * phi2) - (cos((lambda1 - lambda2)) * sin(phi1))));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2))
if (phi2 <= (-0.00019d0)) then
tmp = t_0
else if (phi2 <= 1.45d0) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * phi2) - (cos((lambda1 - lambda2)) * sin(phi1))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), Math.sin(phi2));
double tmp;
if (phi2 <= -0.00019) {
tmp = t_0;
} else if (phi2 <= 1.45) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * phi2) - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), math.sin(phi2)) tmp = 0 if phi2 <= -0.00019: tmp = t_0 elif phi2 <= 1.45: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * phi2) - (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)) tmp = 0.0 if (phi2 <= -0.00019) tmp = t_0; elseif (phi2 <= 1.45) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * phi2) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2)); tmp = 0.0; if (phi2 <= -0.00019) tmp = t_0; elseif (phi2 <= 1.45) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * phi2) - (cos((lambda1 - lambda2)) * sin(phi1)))); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.00019], t$95$0, If[LessEqual[phi2, 1.45], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * phi2), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\phi_2 \leq -0.00019:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_2 \leq 1.45:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \phi_2 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi2 < -1.9000000000000001e-4 or 1.44999999999999996 < phi2 Initial program 76.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6489.5
Applied rewrites89.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.5
Applied rewrites99.5%
Taylor expanded in phi1 around 0
lift-sin.f6462.8
Applied rewrites62.8%
if -1.9000000000000001e-4 < phi2 < 1.44999999999999996Initial program 85.6%
Taylor expanded in phi2 around 0
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6485.6
Applied rewrites85.6%
Final simplification73.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (sin (- lambda1 lambda2)))
(t_2 (* t_1 (cos phi2))))
(if (<= phi1 -1.95e+14)
(atan2 t_1 (- (* (cos phi1) (sin phi2)) (* (sin phi1) t_0)))
(if (<= phi1 1.8e-13)
(atan2 t_2 (fma (- phi1) (* t_0 (cos phi2)) (sin phi2)))
(atan2 t_2 (* t_0 (- (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2));
double t_2 = t_1 * cos(phi2);
double tmp;
if (phi1 <= -1.95e+14) {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)));
} else if (phi1 <= 1.8e-13) {
tmp = atan2(t_2, fma(-phi1, (t_0 * cos(phi2)), sin(phi2)));
} else {
tmp = atan2(t_2, (t_0 * -sin(phi1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) t_2 = Float64(t_1 * cos(phi2)) tmp = 0.0 if (phi1 <= -1.95e+14) tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * t_0))); elseif (phi1 <= 1.8e-13) tmp = atan(t_2, fma(Float64(-phi1), Float64(t_0 * cos(phi2)), sin(phi2))); else tmp = atan(t_2, Float64(t_0 * Float64(-sin(phi1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.95e+14], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.8e-13], N[ArcTan[t$95$2 / N[((-phi1) * N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$0 * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_2 := t\_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -1.95 \cdot 10^{+14}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\mathbf{elif}\;\phi_1 \leq 1.8 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{\mathsf{fma}\left(-\phi_1, t\_0 \cdot \cos \phi_2, \sin \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 \cdot \left(-\sin \phi_1\right)}\\
\end{array}
\end{array}
if phi1 < -1.95e14Initial program 73.1%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6477.4
Applied rewrites77.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
sin-diff-revN/A
lift-sin.f64N/A
lift--.f6447.7
Applied rewrites47.7%
Taylor expanded in phi2 around 0
lift-sin.f6447.9
Applied rewrites47.9%
if -1.95e14 < phi1 < 1.7999999999999999e-13Initial program 84.9%
Taylor expanded in phi1 around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-sin.f6484.7
Applied rewrites84.7%
if 1.7999999999999999e-13 < phi1 Initial program 76.8%
Taylor expanded in phi2 around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6447.3
Applied rewrites47.3%
Final simplification67.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_1 (atan2 t_0 (sin phi2))))
(if (<= phi2 -0.0048)
t_1
(if (<= phi2 1.45)
(atan2
t_0
(- (* (cos phi1) phi2) (* (cos (- lambda1 lambda2)) (sin phi1))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double t_1 = atan2(t_0, sin(phi2));
double tmp;
if (phi2 <= -0.0048) {
tmp = t_1;
} else if (phi2 <= 1.45) {
tmp = atan2(t_0, ((cos(phi1) * phi2) - (cos((lambda1 - lambda2)) * sin(phi1))));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin((lambda1 - lambda2)) * cos(phi2)
t_1 = atan2(t_0, sin(phi2))
if (phi2 <= (-0.0048d0)) then
tmp = t_1
else if (phi2 <= 1.45d0) then
tmp = atan2(t_0, ((cos(phi1) * phi2) - (cos((lambda1 - lambda2)) * sin(phi1))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double t_1 = Math.atan2(t_0, Math.sin(phi2));
double tmp;
if (phi2 <= -0.0048) {
tmp = t_1;
} else if (phi2 <= 1.45) {
tmp = Math.atan2(t_0, ((Math.cos(phi1) * phi2) - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * math.cos(phi2) t_1 = math.atan2(t_0, math.sin(phi2)) tmp = 0 if phi2 <= -0.0048: tmp = t_1 elif phi2 <= 1.45: tmp = math.atan2(t_0, ((math.cos(phi1) * phi2) - (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) t_1 = atan(t_0, sin(phi2)) tmp = 0.0 if (phi2 <= -0.0048) tmp = t_1; elseif (phi2 <= 1.45) tmp = atan(t_0, Float64(Float64(cos(phi1) * phi2) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)) * cos(phi2); t_1 = atan2(t_0, sin(phi2)); tmp = 0.0; if (phi2 <= -0.0048) tmp = t_1; elseif (phi2 <= 1.45) tmp = atan2(t_0, ((cos(phi1) * phi2) - (cos((lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.0048], t$95$1, If[LessEqual[phi2, 1.45], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * phi2), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
t_1 := \tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\mathbf{if}\;\phi_2 \leq -0.0048:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 1.45:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \phi_2 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -0.00479999999999999958 or 1.44999999999999996 < phi2 Initial program 76.5%
Taylor expanded in phi1 around 0
lift-sin.f6450.2
Applied rewrites50.2%
if -0.00479999999999999958 < phi2 < 1.44999999999999996Initial program 84.9%
Taylor expanded in phi2 around 0
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6484.9
Applied rewrites84.9%
Final simplification66.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (atan2 (* t_0 (cos phi2)) (sin phi2))))
(if (<= phi2 -0.122)
t_1
(if (<= phi2 1.45)
(atan2
(* t_0 1.0)
(- (* phi2 (cos phi1)) (* (cos (- lambda1 lambda2)) (sin phi1))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = atan2((t_0 * cos(phi2)), sin(phi2));
double tmp;
if (phi2 <= -0.122) {
tmp = t_1;
} else if (phi2 <= 1.45) {
tmp = atan2((t_0 * 1.0), ((phi2 * cos(phi1)) - (cos((lambda1 - lambda2)) * sin(phi1))));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
t_1 = atan2((t_0 * cos(phi2)), sin(phi2))
if (phi2 <= (-0.122d0)) then
tmp = t_1
else if (phi2 <= 1.45d0) then
tmp = atan2((t_0 * 1.0d0), ((phi2 * cos(phi1)) - (cos((lambda1 - lambda2)) * sin(phi1))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double t_1 = Math.atan2((t_0 * Math.cos(phi2)), Math.sin(phi2));
double tmp;
if (phi2 <= -0.122) {
tmp = t_1;
} else if (phi2 <= 1.45) {
tmp = Math.atan2((t_0 * 1.0), ((phi2 * Math.cos(phi1)) - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = math.atan2((t_0 * math.cos(phi2)), math.sin(phi2)) tmp = 0 if phi2 <= -0.122: tmp = t_1 elif phi2 <= 1.45: tmp = math.atan2((t_0 * 1.0), ((phi2 * math.cos(phi1)) - (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = atan(Float64(t_0 * cos(phi2)), sin(phi2)) tmp = 0.0 if (phi2 <= -0.122) tmp = t_1; elseif (phi2 <= 1.45) tmp = atan(Float64(t_0 * 1.0), Float64(Float64(phi2 * cos(phi1)) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = atan2((t_0 * cos(phi2)), sin(phi2)); tmp = 0.0; if (phi2 <= -0.122) tmp = t_1; elseif (phi2 <= 1.45) tmp = atan2((t_0 * 1.0), ((phi2 * cos(phi1)) - (cos((lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.122], t$95$1, If[LessEqual[phi2, 1.45], N[ArcTan[N[(t$95$0 * 1.0), $MachinePrecision] / N[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\phi_2 \leq -0.122:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 1.45:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot 1}{\phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -0.122 or 1.44999999999999996 < phi2 Initial program 76.8%
Taylor expanded in phi1 around 0
lift-sin.f6450.3
Applied rewrites50.3%
if -0.122 < phi2 < 1.44999999999999996Initial program 84.5%
Taylor expanded in phi1 around 0
lift-sin.f6455.4
Applied rewrites55.4%
Taylor expanded in phi2 around 0
Applied rewrites55.4%
Taylor expanded in phi2 around 0
lower--.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6484.5
Applied rewrites84.5%
Final simplification66.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_1 (atan2 t_0 (* (cos (- lambda1 lambda2)) (- (sin phi1))))))
(if (<= phi1 -1.95e+14)
t_1
(if (<= phi1 1.8e-13) (atan2 t_0 (sin phi2)) t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double t_1 = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1)));
double tmp;
if (phi1 <= -1.95e+14) {
tmp = t_1;
} else if (phi1 <= 1.8e-13) {
tmp = atan2(t_0, sin(phi2));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin((lambda1 - lambda2)) * cos(phi2)
t_1 = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1)))
if (phi1 <= (-1.95d+14)) then
tmp = t_1
else if (phi1 <= 1.8d-13) then
tmp = atan2(t_0, sin(phi2))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double t_1 = Math.atan2(t_0, (Math.cos((lambda1 - lambda2)) * -Math.sin(phi1)));
double tmp;
if (phi1 <= -1.95e+14) {
tmp = t_1;
} else if (phi1 <= 1.8e-13) {
tmp = Math.atan2(t_0, Math.sin(phi2));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * math.cos(phi2) t_1 = math.atan2(t_0, (math.cos((lambda1 - lambda2)) * -math.sin(phi1))) tmp = 0 if phi1 <= -1.95e+14: tmp = t_1 elif phi1 <= 1.8e-13: tmp = math.atan2(t_0, math.sin(phi2)) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) t_1 = atan(t_0, Float64(cos(Float64(lambda1 - lambda2)) * Float64(-sin(phi1)))) tmp = 0.0 if (phi1 <= -1.95e+14) tmp = t_1; elseif (phi1 <= 1.8e-13) tmp = atan(t_0, sin(phi2)); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)) * cos(phi2); t_1 = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1))); tmp = 0.0; if (phi1 <= -1.95e+14) tmp = t_1; elseif (phi1 <= 1.8e-13) tmp = atan2(t_0, sin(phi2)); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[t$95$0 / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.95e+14], t$95$1, If[LessEqual[phi1, 1.8e-13], N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
t_1 := \tan^{-1}_* \frac{t\_0}{\cos \left(\lambda_1 - \lambda_2\right) \cdot \left(-\sin \phi_1\right)}\\
\mathbf{if}\;\phi_1 \leq -1.95 \cdot 10^{+14}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 1.8 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi1 < -1.95e14 or 1.7999999999999999e-13 < phi1 Initial program 75.2%
Taylor expanded in phi2 around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6447.3
Applied rewrites47.3%
if -1.95e14 < phi1 < 1.7999999999999999e-13Initial program 84.9%
Taylor expanded in phi1 around 0
lift-sin.f6481.6
Applied rewrites81.6%
Final simplification65.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (atan2 (* t_0 (cos phi2)) (sin phi2))))
(if (<= phi2 -8e-20)
t_1
(if (<= phi2 1.45)
(atan2 (* t_0 1.0) (* (cos (- lambda1 lambda2)) (- (sin phi1))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = atan2((t_0 * cos(phi2)), sin(phi2));
double tmp;
if (phi2 <= -8e-20) {
tmp = t_1;
} else if (phi2 <= 1.45) {
tmp = atan2((t_0 * 1.0), (cos((lambda1 - lambda2)) * -sin(phi1)));
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
t_1 = atan2((t_0 * cos(phi2)), sin(phi2))
if (phi2 <= (-8d-20)) then
tmp = t_1
else if (phi2 <= 1.45d0) then
tmp = atan2((t_0 * 1.0d0), (cos((lambda1 - lambda2)) * -sin(phi1)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double t_1 = Math.atan2((t_0 * Math.cos(phi2)), Math.sin(phi2));
double tmp;
if (phi2 <= -8e-20) {
tmp = t_1;
} else if (phi2 <= 1.45) {
tmp = Math.atan2((t_0 * 1.0), (Math.cos((lambda1 - lambda2)) * -Math.sin(phi1)));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = math.atan2((t_0 * math.cos(phi2)), math.sin(phi2)) tmp = 0 if phi2 <= -8e-20: tmp = t_1 elif phi2 <= 1.45: tmp = math.atan2((t_0 * 1.0), (math.cos((lambda1 - lambda2)) * -math.sin(phi1))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = atan(Float64(t_0 * cos(phi2)), sin(phi2)) tmp = 0.0 if (phi2 <= -8e-20) tmp = t_1; elseif (phi2 <= 1.45) tmp = atan(Float64(t_0 * 1.0), Float64(cos(Float64(lambda1 - lambda2)) * Float64(-sin(phi1)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = atan2((t_0 * cos(phi2)), sin(phi2)); tmp = 0.0; if (phi2 <= -8e-20) tmp = t_1; elseif (phi2 <= 1.45) tmp = atan2((t_0 * 1.0), (cos((lambda1 - lambda2)) * -sin(phi1))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -8e-20], t$95$1, If[LessEqual[phi2, 1.45], N[ArcTan[N[(t$95$0 * 1.0), $MachinePrecision] / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\phi_2 \leq -8 \cdot 10^{-20}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 1.45:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot 1}{\cos \left(\lambda_1 - \lambda_2\right) \cdot \left(-\sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -7.99999999999999956e-20 or 1.44999999999999996 < phi2 Initial program 76.3%
Taylor expanded in phi1 around 0
lift-sin.f6450.6
Applied rewrites50.6%
if -7.99999999999999956e-20 < phi2 < 1.44999999999999996Initial program 85.4%
Taylor expanded in phi1 around 0
lift-sin.f6455.3
Applied rewrites55.3%
Taylor expanded in phi2 around 0
Applied rewrites55.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6482.1
Applied rewrites82.1%
Final simplification65.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (atan2 (* (sin (- lambda2)) (cos phi2)) (sin phi2))))
(if (<= lambda2 -12000000000000.0)
t_0
(if (<= lambda2 2.5e-13)
(atan2 (* (sin lambda1) (cos phi2)) (sin phi2))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin(-lambda2) * cos(phi2)), sin(phi2));
double tmp;
if (lambda2 <= -12000000000000.0) {
tmp = t_0;
} else if (lambda2 <= 2.5e-13) {
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = atan2((sin(-lambda2) * cos(phi2)), sin(phi2))
if (lambda2 <= (-12000000000000.0d0)) then
tmp = t_0
else if (lambda2 <= 2.5d-13) then
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), Math.sin(phi2));
double tmp;
if (lambda2 <= -12000000000000.0) {
tmp = t_0;
} else if (lambda2 <= 2.5e-13) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((math.sin(-lambda2) * math.cos(phi2)), math.sin(phi2)) tmp = 0 if lambda2 <= -12000000000000.0: tmp = t_0 elif lambda2 <= 2.5e-13: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), math.sin(phi2)) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), sin(phi2)) tmp = 0.0 if (lambda2 <= -12000000000000.0) tmp = t_0; elseif (lambda2 <= 2.5e-13) tmp = atan(Float64(sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((sin(-lambda2) * cos(phi2)), sin(phi2)); tmp = 0.0; if (lambda2 <= -12000000000000.0) tmp = t_0; elseif (lambda2 <= 2.5e-13) tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -12000000000000.0], t$95$0, If[LessEqual[lambda2, 2.5e-13], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\lambda_2 \leq -12000000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_2 \leq 2.5 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda2 < -1.2e13 or 2.49999999999999995e-13 < lambda2 Initial program 63.5%
Taylor expanded in phi1 around 0
lift-sin.f6444.5
Applied rewrites44.5%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6444.3
Applied rewrites44.3%
if -1.2e13 < lambda2 < 2.49999999999999995e-13Initial program 99.2%
Taylor expanded in phi1 around 0
lift-sin.f6461.8
Applied rewrites61.8%
Taylor expanded in lambda1 around inf
Applied rewrites55.7%
Final simplification49.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda2 -2.5e-15)
(atan2 (* (- (sin lambda2)) 1.0) (sin phi2))
(if (<= lambda2 2.95e-87)
(atan2 (* (sin lambda1) (cos phi2)) (sin phi2))
(atan2 (* (sin (- lambda1 lambda2)) 1.0) (sin phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= -2.5e-15) {
tmp = atan2((-sin(lambda2) * 1.0), sin(phi2));
} else if (lambda2 <= 2.95e-87) {
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * 1.0), sin(phi2));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda2 <= (-2.5d-15)) then
tmp = atan2((-sin(lambda2) * 1.0d0), sin(phi2))
else if (lambda2 <= 2.95d-87) then
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2))
else
tmp = atan2((sin((lambda1 - lambda2)) * 1.0d0), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= -2.5e-15) {
tmp = Math.atan2((-Math.sin(lambda2) * 1.0), Math.sin(phi2));
} else if (lambda2 <= 2.95e-87) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * 1.0), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= -2.5e-15: tmp = math.atan2((-math.sin(lambda2) * 1.0), math.sin(phi2)) elif lambda2 <= 2.95e-87: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * 1.0), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= -2.5e-15) tmp = atan(Float64(Float64(-sin(lambda2)) * 1.0), sin(phi2)); elseif (lambda2 <= 2.95e-87) tmp = atan(Float64(sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= -2.5e-15) tmp = atan2((-sin(lambda2) * 1.0), sin(phi2)); elseif (lambda2 <= 2.95e-87) tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2)); else tmp = atan2((sin((lambda1 - lambda2)) * 1.0), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, -2.5e-15], N[ArcTan[N[((-N[Sin[lambda2], $MachinePrecision]) * 1.0), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 2.95e-87], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -2.5 \cdot 10^{-15}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(-\sin \lambda_2\right) \cdot 1}{\sin \phi_2}\\
\mathbf{elif}\;\lambda_2 \leq 2.95 \cdot 10^{-87}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\sin \phi_2}\\
\end{array}
\end{array}
if lambda2 < -2.5e-15Initial program 67.0%
Taylor expanded in phi1 around 0
lift-sin.f6448.0
Applied rewrites48.0%
Taylor expanded in phi2 around 0
Applied rewrites36.5%
Taylor expanded in lambda1 around 0
sin-negN/A
lower-neg.f64N/A
lift-sin.f6438.2
Applied rewrites38.2%
if -2.5e-15 < lambda2 < 2.9499999999999998e-87Initial program 99.8%
Taylor expanded in phi1 around 0
lift-sin.f6461.8
Applied rewrites61.8%
Taylor expanded in lambda1 around inf
Applied rewrites57.3%
if 2.9499999999999998e-87 < lambda2 Initial program 67.5%
Taylor expanded in phi1 around 0
lift-sin.f6445.4
Applied rewrites45.4%
Taylor expanded in phi2 around 0
Applied rewrites35.3%
Final simplification45.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), Math.sin(phi2));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), math.sin(phi2))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), sin(phi2)) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}
\end{array}
Initial program 80.5%
Taylor expanded in phi1 around 0
lift-sin.f6452.7
Applied rewrites52.7%
Final simplification52.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 85000.0)
(atan2 t_0 phi2)
(atan2 t_0 (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi2 <= 85000.0) {
tmp = atan2(t_0, phi2);
} else {
tmp = atan2(t_0, (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi2 <= 85000.0) tmp = atan(t_0, phi2); else tmp = atan(t_0, Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 85000.0], N[ArcTan[t$95$0 / phi2], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq 85000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2}\\
\end{array}
\end{array}
if phi2 < 85000Initial program 80.9%
Taylor expanded in phi1 around 0
lift-sin.f6452.8
Applied rewrites52.8%
Taylor expanded in phi2 around 0
Applied rewrites43.4%
if 85000 < phi2 Initial program 79.3%
Taylor expanded in phi1 around 0
lift-sin.f6452.7
Applied rewrites52.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6427.2
Applied rewrites27.2%
Final simplification38.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2 10200000000.0)
(atan2 (* t_0 (cos phi2)) phi2)
(atan2
(* t_0 1.0)
(*
phi2
(+
1.0
(*
(* phi2 phi2)
(-
(*
(* phi2 phi2)
(+ 0.008333333333333333 (* -0.0001984126984126984 (* phi2 phi2))))
0.16666666666666666))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 10200000000.0) {
tmp = atan2((t_0 * cos(phi2)), phi2);
} else {
tmp = atan2((t_0 * 1.0), (phi2 * (1.0 + ((phi2 * phi2) * (((phi2 * phi2) * (0.008333333333333333 + (-0.0001984126984126984 * (phi2 * phi2)))) - 0.16666666666666666)))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if (phi2 <= 10200000000.0d0) then
tmp = atan2((t_0 * cos(phi2)), phi2)
else
tmp = atan2((t_0 * 1.0d0), (phi2 * (1.0d0 + ((phi2 * phi2) * (((phi2 * phi2) * (0.008333333333333333d0 + ((-0.0001984126984126984d0) * (phi2 * phi2)))) - 0.16666666666666666d0)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 10200000000.0) {
tmp = Math.atan2((t_0 * Math.cos(phi2)), phi2);
} else {
tmp = Math.atan2((t_0 * 1.0), (phi2 * (1.0 + ((phi2 * phi2) * (((phi2 * phi2) * (0.008333333333333333 + (-0.0001984126984126984 * (phi2 * phi2)))) - 0.16666666666666666)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= 10200000000.0: tmp = math.atan2((t_0 * math.cos(phi2)), phi2) else: tmp = math.atan2((t_0 * 1.0), (phi2 * (1.0 + ((phi2 * phi2) * (((phi2 * phi2) * (0.008333333333333333 + (-0.0001984126984126984 * (phi2 * phi2)))) - 0.16666666666666666))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 10200000000.0) tmp = atan(Float64(t_0 * cos(phi2)), phi2); else tmp = atan(Float64(t_0 * 1.0), Float64(phi2 * Float64(1.0 + Float64(Float64(phi2 * phi2) * Float64(Float64(Float64(phi2 * phi2) * Float64(0.008333333333333333 + Float64(-0.0001984126984126984 * Float64(phi2 * phi2)))) - 0.16666666666666666))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 10200000000.0) tmp = atan2((t_0 * cos(phi2)), phi2); else tmp = atan2((t_0 * 1.0), (phi2 * (1.0 + ((phi2 * phi2) * (((phi2 * phi2) * (0.008333333333333333 + (-0.0001984126984126984 * (phi2 * phi2)))) - 0.16666666666666666))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 10200000000.0], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(t$95$0 * 1.0), $MachinePrecision] / N[(phi2 * N[(1.0 + N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(N[(phi2 * phi2), $MachinePrecision] * N[(0.008333333333333333 + N[(-0.0001984126984126984 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 10200000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot 1}{\phi_2 \cdot \left(1 + \left(\phi_2 \cdot \phi_2\right) \cdot \left(\left(\phi_2 \cdot \phi_2\right) \cdot \left(0.008333333333333333 + -0.0001984126984126984 \cdot \left(\phi_2 \cdot \phi_2\right)\right) - 0.16666666666666666\right)\right)}\\
\end{array}
\end{array}
if phi2 < 1.02e10Initial program 80.7%
Taylor expanded in phi1 around 0
lift-sin.f6452.8
Applied rewrites52.8%
Taylor expanded in phi2 around 0
Applied rewrites43.1%
if 1.02e10 < phi2 Initial program 79.8%
Taylor expanded in phi1 around 0
lift-sin.f6452.5
Applied rewrites52.5%
Taylor expanded in phi2 around 0
Applied rewrites14.4%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6415.5
Applied rewrites15.5%
Final simplification35.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -95.0)
(atan2 (* (cos phi2) (- (sin lambda2))) phi2)
(atan2
(* (sin (- lambda1 lambda2)) 1.0)
(* phi2 (+ 1.0 (* -0.16666666666666666 (* phi2 phi2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -95.0) {
tmp = atan2((cos(phi2) * -sin(lambda2)), phi2);
} else {
tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2)))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= (-95.0d0)) then
tmp = atan2((cos(phi2) * -sin(lambda2)), phi2)
else
tmp = atan2((sin((lambda1 - lambda2)) * 1.0d0), (phi2 * (1.0d0 + ((-0.16666666666666666d0) * (phi2 * phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -95.0) {
tmp = Math.atan2((Math.cos(phi2) * -Math.sin(lambda2)), phi2);
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * 1.0), (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= -95.0: tmp = math.atan2((math.cos(phi2) * -math.sin(lambda2)), phi2) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * 1.0), (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -95.0) tmp = atan(Float64(cos(phi2) * Float64(-sin(lambda2))), phi2); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), Float64(phi2 * Float64(1.0 + Float64(-0.16666666666666666 * Float64(phi2 * phi2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= -95.0) tmp = atan2((cos(phi2) * -sin(lambda2)), phi2); else tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -95.0], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[(phi2 * N[(1.0 + N[(-0.16666666666666666 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -95:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(-\sin \lambda_2\right)}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2 \cdot \left(1 + -0.16666666666666666 \cdot \left(\phi_2 \cdot \phi_2\right)\right)}\\
\end{array}
\end{array}
if phi2 < -95Initial program 73.9%
Taylor expanded in phi1 around 0
lift-sin.f6447.0
Applied rewrites47.0%
Taylor expanded in phi2 around 0
Applied rewrites11.7%
Taylor expanded in phi2 around 0
Applied rewrites13.5%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lift-cos.f64N/A
sin-negN/A
lower-neg.f64N/A
lift-sin.f6417.6
Applied rewrites17.6%
if -95 < phi2 Initial program 82.5%
Taylor expanded in phi1 around 0
lift-sin.f6454.5
Applied rewrites54.5%
Taylor expanded in phi2 around 0
Applied rewrites39.7%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6439.8
Applied rewrites39.8%
Final simplification34.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) 1.0) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * 1.0), sin(phi2));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * 1.0d0), sin(phi2))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * 1.0), Math.sin(phi2));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * 1.0), math.sin(phi2))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), sin(phi2)) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * 1.0), sin(phi2)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\sin \phi_2}
\end{array}
Initial program 80.5%
Taylor expanded in phi1 around 0
lift-sin.f6452.7
Applied rewrites52.7%
Taylor expanded in phi2 around 0
Applied rewrites33.2%
Final simplification33.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -0.12)
(atan2 (* (- (sin lambda2)) 1.0) phi2)
(atan2
(* (sin (- lambda1 lambda2)) 1.0)
(* phi2 (+ 1.0 (* -0.16666666666666666 (* phi2 phi2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -0.12) {
tmp = atan2((-sin(lambda2) * 1.0), phi2);
} else {
tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2)))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= (-0.12d0)) then
tmp = atan2((-sin(lambda2) * 1.0d0), phi2)
else
tmp = atan2((sin((lambda1 - lambda2)) * 1.0d0), (phi2 * (1.0d0 + ((-0.16666666666666666d0) * (phi2 * phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -0.12) {
tmp = Math.atan2((-Math.sin(lambda2) * 1.0), phi2);
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * 1.0), (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= -0.12: tmp = math.atan2((-math.sin(lambda2) * 1.0), phi2) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * 1.0), (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -0.12) tmp = atan(Float64(Float64(-sin(lambda2)) * 1.0), phi2); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), Float64(phi2 * Float64(1.0 + Float64(-0.16666666666666666 * Float64(phi2 * phi2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= -0.12) tmp = atan2((-sin(lambda2) * 1.0), phi2); else tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (phi2 * (1.0 + (-0.16666666666666666 * (phi2 * phi2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -0.12], N[ArcTan[N[((-N[Sin[lambda2], $MachinePrecision]) * 1.0), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[(phi2 * N[(1.0 + N[(-0.16666666666666666 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -0.12:\\
\;\;\;\;\tan^{-1}_* \frac{\left(-\sin \lambda_2\right) \cdot 1}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2 \cdot \left(1 + -0.16666666666666666 \cdot \left(\phi_2 \cdot \phi_2\right)\right)}\\
\end{array}
\end{array}
if phi2 < -0.12Initial program 72.6%
Taylor expanded in phi1 around 0
lift-sin.f6445.8
Applied rewrites45.8%
Taylor expanded in phi2 around 0
Applied rewrites11.8%
Taylor expanded in phi2 around 0
Applied rewrites13.5%
Taylor expanded in lambda1 around 0
sin-negN/A
lower-neg.f64N/A
lift-sin.f6414.2
Applied rewrites14.2%
if -0.12 < phi2 Initial program 83.0%
Taylor expanded in phi1 around 0
lift-sin.f6455.0
Applied rewrites55.0%
Taylor expanded in phi2 around 0
Applied rewrites40.1%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6440.2
Applied rewrites40.2%
Final simplification33.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) phi2))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), phi2);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin((lambda1 - lambda2)), phi2)
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), phi2);
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), phi2)
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), phi2) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), phi2); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / phi2], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2}
\end{array}
Initial program 80.5%
Taylor expanded in phi1 around 0
lift-sin.f6452.7
Applied rewrites52.7%
Taylor expanded in phi2 around 0
Applied rewrites33.2%
Taylor expanded in phi2 around 0
Applied rewrites30.7%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6430.7
Applied rewrites30.7%
Final simplification30.7%
herbie shell --seed 2025050
(FPCore (lambda1 lambda2 phi1 phi2)
:name "Bearing on a great circle"
:precision binary64
:pre (TRUE)
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))