
(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)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
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 22 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)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
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))
(*
(cos phi2)
(*
(sin phi1)
(+ (* (cos lambda2) (cos lambda1)) (* (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)) - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
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)) - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (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.cos(phi2) * (Math.sin(phi1) * ((Math.cos(lambda2) * Math.cos(lambda1)) + (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.cos(phi2) * (math.sin(phi1) * ((math.cos(lambda2) * math.cos(lambda1)) + (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(cos(phi2) * Float64(sin(phi1) * Float64(Float64(cos(lambda2) * cos(lambda1)) + 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)) - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (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[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $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 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)}
\end{array}
Initial program 77.4%
sin-diff88.3%
Applied egg-rr88.3%
cos-diff99.7%
distribute-lft-in99.7%
*-commutative99.7%
Applied egg-rr99.7%
distribute-lft-out99.7%
*-commutative99.7%
associate-*l*99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in phi1 around inf 99.7%
Final simplification99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))))
(if (or (<= phi2 -0.00055) (not (<= phi2 9e-39)))
(atan2
t_0
(-
(* (cos phi1) (sin phi2))
(* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))
(atan2
t_0
(-
(* phi2 (cos phi1))
(*
(cos phi2)
(*
(sin phi1)
(+
(* (cos lambda2) (cos lambda1))
(* (sin lambda1) (sin lambda2))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double tmp;
if ((phi2 <= -0.00055) || !(phi2 <= 9e-39)) {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_0, ((phi2 * cos(phi1)) - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
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) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)
if ((phi2 <= (-0.00055d0)) .or. (.not. (phi2 <= 9d-39))) then
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
else
tmp = atan2(t_0, ((phi2 * cos(phi1)) - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2);
double tmp;
if ((phi2 <= -0.00055) || !(phi2 <= 9e-39)) {
tmp = Math.atan2(t_0, ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2(t_0, ((phi2 * Math.cos(phi1)) - (Math.cos(phi2) * (Math.sin(phi1) * ((Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda1) * Math.sin(lambda2)))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2) tmp = 0 if (phi2 <= -0.00055) or not (phi2 <= 9e-39): tmp = math.atan2(t_0, ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2(t_0, ((phi2 * math.cos(phi1)) - (math.cos(phi2) * (math.sin(phi1) * ((math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda1) * math.sin(lambda2))))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) tmp = 0.0 if ((phi2 <= -0.00055) || !(phi2 <= 9e-39)) tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_0, Float64(Float64(phi2 * cos(phi1)) - Float64(cos(phi2) * Float64(sin(phi1) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda1) * sin(lambda2))))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2); tmp = 0.0; if ((phi2 <= -0.00055) || ~((phi2 <= 9e-39))) tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); else tmp = atan2(t_0, ((phi2 * cos(phi1)) - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))))); end tmp_2 = 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]}, If[Or[LessEqual[phi2, -0.00055], N[Not[LessEqual[phi2, 9e-39]], $MachinePrecision]], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.00055 \lor \neg \left(\phi_2 \leq 9 \cdot 10^{-39}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\phi_2 \cdot \cos \phi_1 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)}\\
\end{array}
\end{array}
if phi2 < -5.50000000000000033e-4 or 9.0000000000000002e-39 < phi2 Initial program 74.3%
sin-diff86.7%
Applied egg-rr86.7%
if -5.50000000000000033e-4 < phi2 < 9.0000000000000002e-39Initial program 81.5%
sin-diff90.3%
Applied egg-rr90.3%
cos-diff99.9%
distribute-lft-in99.9%
*-commutative99.9%
Applied egg-rr99.9%
distribute-lft-out99.9%
*-commutative99.9%
associate-*l*99.9%
fma-def99.8%
Simplified99.8%
Taylor expanded in phi1 around inf 99.9%
Taylor expanded in phi2 around 0 99.6%
Final simplification92.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))))
(if (or (<= phi2 -1.1e-8) (not (<= phi2 9e-39)))
(atan2
t_0
(-
(* (cos phi1) (sin phi2))
(* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))
(atan2
t_0
(-
(sin phi2)
(*
(cos phi2)
(*
(sin phi1)
(+
(* (cos lambda2) (cos lambda1))
(* (sin lambda1) (sin lambda2))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double tmp;
if ((phi2 <= -1.1e-8) || !(phi2 <= 9e-39)) {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_0, (sin(phi2) - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
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) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)
if ((phi2 <= (-1.1d-8)) .or. (.not. (phi2 <= 9d-39))) then
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
else
tmp = atan2(t_0, (sin(phi2) - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2);
double tmp;
if ((phi2 <= -1.1e-8) || !(phi2 <= 9e-39)) {
tmp = Math.atan2(t_0, ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.cos(phi2) * (Math.sin(phi1) * ((Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda1) * Math.sin(lambda2)))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2) tmp = 0 if (phi2 <= -1.1e-8) or not (phi2 <= 9e-39): tmp = math.atan2(t_0, ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2(t_0, (math.sin(phi2) - (math.cos(phi2) * (math.sin(phi1) * ((math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda1) * math.sin(lambda2))))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) tmp = 0.0 if ((phi2 <= -1.1e-8) || !(phi2 <= 9e-39)) tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_0, Float64(sin(phi2) - Float64(cos(phi2) * Float64(sin(phi1) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda1) * sin(lambda2))))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2); tmp = 0.0; if ((phi2 <= -1.1e-8) || ~((phi2 <= 9e-39))) tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); else tmp = atan2(t_0, (sin(phi2) - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))))); end tmp_2 = 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]}, If[Or[LessEqual[phi2, -1.1e-8], N[Not[LessEqual[phi2, 9e-39]], $MachinePrecision]], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -1.1 \cdot 10^{-8} \lor \neg \left(\phi_2 \leq 9 \cdot 10^{-39}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\sin \phi_2 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)}\\
\end{array}
\end{array}
if phi2 < -1.0999999999999999e-8 or 9.0000000000000002e-39 < phi2 Initial program 74.0%
sin-diff86.4%
Applied egg-rr86.4%
if -1.0999999999999999e-8 < phi2 < 9.0000000000000002e-39Initial program 82.0%
sin-diff90.9%
Applied egg-rr90.9%
cos-diff99.9%
distribute-lft-in99.9%
*-commutative99.9%
Applied egg-rr99.9%
distribute-lft-out99.9%
*-commutative99.9%
associate-*l*99.9%
fma-def99.8%
Simplified99.8%
Taylor expanded in phi1 around inf 99.9%
Taylor expanded in phi1 around 0 99.9%
Final simplification92.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))))
(if (or (<= phi2 -0.0017) (not (<= phi2 9e-39)))
(atan2
t_1
(- t_0 (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))
(atan2
t_1
(-
t_0
(*
(sin phi1)
(+
(* (cos lambda2) (cos lambda1))
(* (sin lambda1) (sin lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double tmp;
if ((phi2 <= -0.0017) || !(phi2 <= 9e-39)) {
tmp = atan2(t_1, (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_1, (t_0 - (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)
if ((phi2 <= (-0.0017d0)) .or. (.not. (phi2 <= 9d-39))) then
tmp = atan2(t_1, (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
else
tmp = atan2(t_1, (t_0 - (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2);
double tmp;
if ((phi2 <= -0.0017) || !(phi2 <= 9e-39)) {
tmp = Math.atan2(t_1, (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.sin(phi1) * ((Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda1) * Math.sin(lambda2))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2) tmp = 0 if (phi2 <= -0.0017) or not (phi2 <= 9e-39): tmp = math.atan2(t_1, (t_0 - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2(t_1, (t_0 - (math.sin(phi1) * ((math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda1) * math.sin(lambda2)))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) tmp = 0.0 if ((phi2 <= -0.0017) || !(phi2 <= 9e-39)) tmp = atan(t_1, Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda1) * sin(lambda2)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2); tmp = 0.0; if ((phi2 <= -0.0017) || ~((phi2 <= 9e-39))) tmp = atan2(t_1, (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); else tmp = atan2(t_1, (t_0 - (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -0.0017], N[Not[LessEqual[phi2, 9e-39]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.0017 \lor \neg \left(\phi_2 \leq 9 \cdot 10^{-39}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -0.00169999999999999991 or 9.0000000000000002e-39 < phi2 Initial program 74.3%
sin-diff86.7%
Applied egg-rr86.7%
if -0.00169999999999999991 < phi2 < 9.0000000000000002e-39Initial program 81.5%
sin-diff90.3%
Applied egg-rr90.3%
cos-diff99.9%
distribute-lft-in99.9%
*-commutative99.9%
Applied egg-rr99.9%
distribute-lft-out99.9%
*-commutative99.9%
associate-*l*99.9%
fma-def99.8%
Simplified99.8%
Taylor expanded in phi1 around inf 99.9%
Taylor expanded in phi2 around 0 99.5%
Final simplification92.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)))))
(if (or (<= phi2 -0.00045) (not (<= phi2 9e-39)))
(atan2
(* t_1 (cos phi2))
(- t_0 (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))
(atan2
t_1
(-
t_0
(*
(cos phi2)
(*
(sin phi1)
(+
(* (cos lambda2) (cos lambda1))
(* (sin lambda1) (sin lambda2))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = (sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2));
double tmp;
if ((phi2 <= -0.00045) || !(phi2 <= 9e-39)) {
tmp = atan2((t_1 * cos(phi2)), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_1, (t_0 - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = (sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))
if ((phi2 <= (-0.00045d0)) .or. (.not. (phi2 <= 9d-39))) then
tmp = atan2((t_1 * cos(phi2)), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
else
tmp = atan2(t_1, (t_0 - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = (Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2));
double tmp;
if ((phi2 <= -0.00045) || !(phi2 <= 9e-39)) {
tmp = Math.atan2((t_1 * Math.cos(phi2)), (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * ((Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda1) * Math.sin(lambda2)))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = (math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)) tmp = 0 if (phi2 <= -0.00045) or not (phi2 <= 9e-39): tmp = math.atan2((t_1 * math.cos(phi2)), (t_0 - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * (math.sin(phi1) * ((math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda1) * math.sin(lambda2))))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) tmp = 0.0 if ((phi2 <= -0.00045) || !(phi2 <= 9e-39)) tmp = atan(Float64(t_1 * cos(phi2)), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda1) * sin(lambda2))))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = (sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)); tmp = 0.0; if ((phi2 <= -0.00045) || ~((phi2 <= 9e-39))) tmp = atan2((t_1 * cos(phi2)), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); else tmp = atan2(t_1, (t_0 - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -0.00045], N[Not[LessEqual[phi2, 9e-39]], $MachinePrecision]], N[ArcTan[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\\
\mathbf{if}\;\phi_2 \leq -0.00045 \lor \neg \left(\phi_2 \leq 9 \cdot 10^{-39}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_1 \cdot \cos \phi_2}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)}\\
\end{array}
\end{array}
if phi2 < -4.4999999999999999e-4 or 9.0000000000000002e-39 < phi2 Initial program 74.3%
sin-diff86.7%
Applied egg-rr86.7%
if -4.4999999999999999e-4 < phi2 < 9.0000000000000002e-39Initial program 81.5%
sin-diff90.3%
Applied egg-rr90.3%
cos-diff99.9%
distribute-lft-in99.9%
*-commutative99.9%
Applied egg-rr99.9%
distribute-lft-out99.9%
*-commutative99.9%
associate-*l*99.9%
fma-def99.8%
Simplified99.8%
Taylor expanded in phi1 around inf 99.9%
Taylor expanded in phi2 around 0 99.5%
*-commutative99.5%
Simplified99.5%
Final simplification92.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -5.6e-5) (not (<= lambda2 3.7e-9)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* (cos phi2) (* (cos lambda2) (sin phi1)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(-
t_0
(*
(* (cos phi2) (sin phi1))
(+ (cos lambda1) (* (sin lambda1) lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda2 <= -5.6e-5) || !(lambda2 <= 3.7e-9)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - ((cos(phi2) * sin(phi1)) * (cos(lambda1) + (sin(lambda1) * lambda2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda2 <= (-5.6d-5)) .or. (.not. (lambda2 <= 3.7d-9))) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - ((cos(phi2) * sin(phi1)) * (cos(lambda1) + (sin(lambda1) * lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda2 <= -5.6e-5) || !(lambda2 <= 3.7e-9)) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * (Math.cos(lambda1) + (Math.sin(lambda1) * lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda2 <= -5.6e-5) or not (lambda2 <= 3.7e-9): tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - ((math.cos(phi2) * math.sin(phi1)) * (math.cos(lambda1) + (math.sin(lambda1) * lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda2 <= -5.6e-5) || !(lambda2 <= 3.7e-9)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * Float64(cos(lambda1) + Float64(sin(lambda1) * lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda2 <= -5.6e-5) || ~((lambda2 <= 3.7e-9))) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - ((cos(phi2) * sin(phi1)) * (cos(lambda1) + (sin(lambda1) * lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -5.6e-5], N[Not[LessEqual[lambda2, 3.7e-9]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -5.6 \cdot 10^{-5} \lor \neg \left(\lambda_2 \leq 3.7 \cdot 10^{-9}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \left(\cos \lambda_1 + \sin \lambda_1 \cdot \lambda_2\right)}\\
\end{array}
\end{array}
if lambda2 < -5.59999999999999992e-5 or 3.7e-9 < lambda2 Initial program 56.2%
sin-diff77.6%
Applied egg-rr77.6%
Taylor expanded in lambda1 around 0 77.6%
*-commutative77.6%
cos-neg77.6%
Simplified77.6%
if -5.59999999999999992e-5 < lambda2 < 3.7e-9Initial program 99.3%
Taylor expanded in lambda2 around 0 99.3%
Final simplification88.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (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)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
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)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.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.cos(phi2) * math.sin(phi1)) * 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(cos(phi2) * sin(phi1)) * 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)) - ((cos(phi2) * sin(phi1)) * 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[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}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 77.4%
sin-diff88.3%
Applied egg-rr88.3%
Final simplification88.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (sin phi1) t_1))
(t_3 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi1 -3.6e-5)
(atan2 t_3 (- t_0 (* (cos phi2) t_2)))
(if (<= phi1 2.1e-59)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* t_1 (* (cos phi2) phi1))))
(atan2 t_3 (- t_0 (* (cos phi2) (cbrt (pow t_2 3.0)))))))))
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(phi1) * t_1;
double t_3 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -3.6e-5) {
tmp = atan2(t_3, (t_0 - (cos(phi2) * t_2)));
} else if (phi1 <= 2.1e-59) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (t_1 * (cos(phi2) * phi1))));
} else {
tmp = atan2(t_3, (t_0 - (cos(phi2) * cbrt(pow(t_2, 3.0)))));
}
return tmp;
}
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(phi1) * t_1;
double t_3 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -3.6e-5) {
tmp = Math.atan2(t_3, (t_0 - (Math.cos(phi2) * t_2)));
} else if (phi1 <= 2.1e-59) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (t_1 * (Math.cos(phi2) * phi1))));
} else {
tmp = Math.atan2(t_3, (t_0 - (Math.cos(phi2) * Math.cbrt(Math.pow(t_2, 3.0)))));
}
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(phi1) * t_1) t_3 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -3.6e-5) tmp = atan(t_3, Float64(t_0 - Float64(cos(phi2) * t_2))); elseif (phi1 <= 2.1e-59) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(t_1 * Float64(cos(phi2) * phi1)))); else tmp = atan(t_3, Float64(t_0 - Float64(cos(phi2) * cbrt((t_2 ^ 3.0))))); 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[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -3.6e-5], N[ArcTan[t$95$3 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 2.1e-59], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[Cos[phi2], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$3 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Power[t$95$2, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $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 \phi_1 \cdot t_1\\
t_3 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -3.6 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{t_3}{t_0 - \cos \phi_2 \cdot t_2}\\
\mathbf{elif}\;\phi_1 \leq 2.1 \cdot 10^{-59}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - t_1 \cdot \left(\cos \phi_2 \cdot \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_3}{t_0 - \cos \phi_2 \cdot \sqrt[3]{{t_2}^{3}}}\\
\end{array}
\end{array}
if phi1 < -3.60000000000000009e-5Initial program 72.9%
*-commutative72.9%
associate-*l*72.9%
Simplified72.9%
if -3.60000000000000009e-5 < phi1 < 2.09999999999999997e-59Initial program 78.5%
sin-diff99.4%
Applied egg-rr99.4%
Taylor expanded in phi1 around 0 99.4%
*-commutative99.4%
Simplified99.4%
if 2.09999999999999997e-59 < phi1 Initial program 80.7%
*-commutative80.7%
associate-*l*80.7%
Simplified80.7%
add-cbrt-cube80.7%
pow380.7%
*-commutative80.7%
Applied egg-rr80.7%
Final simplification86.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin phi1) (cos (- lambda1 lambda2))))
(t_2 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi1 -215.0)
(atan2 t_2 (- t_0 (* (cos phi2) t_1)))
(if (<= phi1 2.1e-59)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 t_1))
(atan2 t_2 (- t_0 (* (cos phi2) (cbrt (pow t_1 3.0)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin(phi1) * cos((lambda1 - lambda2));
double t_2 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -215.0) {
tmp = atan2(t_2, (t_0 - (cos(phi2) * t_1)));
} else if (phi1 <= 2.1e-59) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - t_1));
} else {
tmp = atan2(t_2, (t_0 - (cos(phi2) * cbrt(pow(t_1, 3.0)))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin(phi1) * Math.cos((lambda1 - lambda2));
double t_2 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -215.0) {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(phi2) * t_1)));
} else if (phi1 <= 2.1e-59) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - t_1));
} else {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(phi2) * Math.cbrt(Math.pow(t_1, 3.0)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))) t_2 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -215.0) tmp = atan(t_2, Float64(t_0 - Float64(cos(phi2) * t_1))); elseif (phi1 <= 2.1e-59) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - t_1)); else tmp = atan(t_2, Float64(t_0 - Float64(cos(phi2) * cbrt((t_1 ^ 3.0))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -215.0], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 2.1e-59], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - t$95$1), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Power[t$95$1, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -215:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \phi_2 \cdot t_1}\\
\mathbf{elif}\;\phi_1 \leq 2.1 \cdot 10^{-59}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \phi_2 \cdot \sqrt[3]{{t_1}^{3}}}\\
\end{array}
\end{array}
if phi1 < -215Initial program 72.6%
*-commutative72.6%
associate-*l*72.6%
Simplified72.6%
if -215 < phi1 < 2.09999999999999997e-59Initial program 78.7%
sin-diff99.4%
Applied egg-rr99.4%
Taylor expanded in phi2 around 0 99.3%
if 2.09999999999999997e-59 < phi1 Initial program 80.7%
*-commutative80.7%
associate-*l*80.7%
Simplified80.7%
add-cbrt-cube80.7%
pow380.7%
*-commutative80.7%
Applied egg-rr80.7%
Final simplification86.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin phi1) (cos (- lambda1 lambda2))))
(t_2 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi1 -6.8e-6)
(atan2 t_2 (- t_0 (* (cos phi2) t_1)))
(if (<= phi1 2.1e-59)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* phi1 (cos (- lambda2 lambda1)))))
(atan2 t_2 (- t_0 (* (cos phi2) (cbrt (pow t_1 3.0)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin(phi1) * cos((lambda1 - lambda2));
double t_2 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -6.8e-6) {
tmp = atan2(t_2, (t_0 - (cos(phi2) * t_1)));
} else if (phi1 <= 2.1e-59) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (phi1 * cos((lambda2 - lambda1)))));
} else {
tmp = atan2(t_2, (t_0 - (cos(phi2) * cbrt(pow(t_1, 3.0)))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin(phi1) * Math.cos((lambda1 - lambda2));
double t_2 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -6.8e-6) {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(phi2) * t_1)));
} else if (phi1 <= 2.1e-59) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (phi1 * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(phi2) * Math.cbrt(Math.pow(t_1, 3.0)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))) t_2 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -6.8e-6) tmp = atan(t_2, Float64(t_0 - Float64(cos(phi2) * t_1))); elseif (phi1 <= 2.1e-59) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); else tmp = atan(t_2, Float64(t_0 - Float64(cos(phi2) * cbrt((t_1 ^ 3.0))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -6.8e-6], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 2.1e-59], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Power[t$95$1, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -6.8 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \phi_2 \cdot t_1}\\
\mathbf{elif}\;\phi_1 \leq 2.1 \cdot 10^{-59}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \phi_2 \cdot \sqrt[3]{{t_1}^{3}}}\\
\end{array}
\end{array}
if phi1 < -6.80000000000000012e-6Initial program 72.9%
*-commutative72.9%
associate-*l*72.9%
Simplified72.9%
if -6.80000000000000012e-6 < phi1 < 2.09999999999999997e-59Initial program 78.5%
Taylor expanded in phi1 around 0 78.5%
*-commutative78.5%
sub-neg78.5%
remove-double-neg78.5%
mul-1-neg78.5%
distribute-neg-in78.5%
+-commutative78.5%
cos-neg78.5%
mul-1-neg78.5%
unsub-neg78.5%
Simplified78.5%
Taylor expanded in phi2 around 0 78.5%
sin-diff99.4%
Applied egg-rr99.4%
if 2.09999999999999997e-59 < phi1 Initial program 80.7%
*-commutative80.7%
associate-*l*80.7%
Simplified80.7%
add-cbrt-cube80.7%
pow380.7%
*-commutative80.7%
Applied egg-rr80.7%
Final simplification86.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= phi1 -6.8e-6) (not (<= phi1 2.1e-59)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2))))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* phi1 (cos (- lambda2 lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((phi1 <= -6.8e-6) || !(phi1 <= 2.1e-59)) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (phi1 * cos((lambda2 - lambda1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((phi1 <= (-6.8d-6)) .or. (.not. (phi1 <= 2.1d-59))) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (phi1 * cos((lambda2 - lambda1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((phi1 <= -6.8e-6) || !(phi1 <= 2.1e-59)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (phi1 * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (phi1 <= -6.8e-6) or not (phi1 <= 2.1e-59): tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2)))))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (phi1 * math.cos((lambda2 - lambda1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((phi1 <= -6.8e-6) || !(phi1 <= 2.1e-59)) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((phi1 <= -6.8e-6) || ~((phi1 <= 2.1e-59))) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (phi1 * cos((lambda2 - lambda1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -6.8e-6], N[Not[LessEqual[phi1, 2.1e-59]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -6.8 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 2.1 \cdot 10^{-59}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\end{array}
\end{array}
if phi1 < -6.80000000000000012e-6 or 2.09999999999999997e-59 < phi1 Initial program 76.5%
*-commutative76.5%
associate-*l*76.5%
Simplified76.5%
if -6.80000000000000012e-6 < phi1 < 2.09999999999999997e-59Initial program 78.5%
Taylor expanded in phi1 around 0 78.5%
*-commutative78.5%
sub-neg78.5%
remove-double-neg78.5%
mul-1-neg78.5%
distribute-neg-in78.5%
+-commutative78.5%
cos-neg78.5%
mul-1-neg78.5%
unsub-neg78.5%
Simplified78.5%
Taylor expanded in phi2 around 0 78.5%
sin-diff99.4%
Applied egg-rr99.4%
Final simplification86.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin phi1)))
(t_1 (* (cos lambda2) t_0))
(t_2 (* (cos phi1) (sin phi2)))
(t_3
(atan2
(* (sin lambda1) (cos phi2))
(- t_2 (* t_0 (cos (- lambda1 lambda2)))))))
(if (<= lambda1 -4.2e-80)
t_3
(if (<= lambda1 1.65e-183)
(atan2 (* (cos phi2) (sin (- lambda2))) (- t_2 t_1))
(if (<= lambda1 4.3e-21)
(atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) t_1))
t_3)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin(phi1);
double t_1 = cos(lambda2) * t_0;
double t_2 = cos(phi1) * sin(phi2);
double t_3 = atan2((sin(lambda1) * cos(phi2)), (t_2 - (t_0 * cos((lambda1 - lambda2)))));
double tmp;
if (lambda1 <= -4.2e-80) {
tmp = t_3;
} else if (lambda1 <= 1.65e-183) {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_2 - t_1));
} else if (lambda1 <= 4.3e-21) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - t_1));
} else {
tmp = t_3;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi2) * sin(phi1)
t_1 = cos(lambda2) * t_0
t_2 = cos(phi1) * sin(phi2)
t_3 = atan2((sin(lambda1) * cos(phi2)), (t_2 - (t_0 * cos((lambda1 - lambda2)))))
if (lambda1 <= (-4.2d-80)) then
tmp = t_3
else if (lambda1 <= 1.65d-183) then
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_2 - t_1))
else if (lambda1 <= 4.3d-21) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - t_1))
else
tmp = t_3
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin(phi1);
double t_1 = Math.cos(lambda2) * t_0;
double t_2 = Math.cos(phi1) * Math.sin(phi2);
double t_3 = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_2 - (t_0 * Math.cos((lambda1 - lambda2)))));
double tmp;
if (lambda1 <= -4.2e-80) {
tmp = t_3;
} else if (lambda1 <= 1.65e-183) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_2 - t_1));
} else if (lambda1 <= 4.3e-21) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - t_1));
} else {
tmp = t_3;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin(phi1) t_1 = math.cos(lambda2) * t_0 t_2 = math.cos(phi1) * math.sin(phi2) t_3 = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_2 - (t_0 * math.cos((lambda1 - lambda2))))) tmp = 0 if lambda1 <= -4.2e-80: tmp = t_3 elif lambda1 <= 1.65e-183: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_2 - t_1)) elif lambda1 <= 4.3e-21: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - t_1)) else: tmp = t_3 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(phi1)) t_1 = Float64(cos(lambda2) * t_0) t_2 = Float64(cos(phi1) * sin(phi2)) t_3 = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_2 - Float64(t_0 * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (lambda1 <= -4.2e-80) tmp = t_3; elseif (lambda1 <= 1.65e-183) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_2 - t_1)); elseif (lambda1 <= 4.3e-21) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - t_1)); else tmp = t_3; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin(phi1); t_1 = cos(lambda2) * t_0; t_2 = cos(phi1) * sin(phi2); t_3 = atan2((sin(lambda1) * cos(phi2)), (t_2 - (t_0 * cos((lambda1 - lambda2))))); tmp = 0.0; if (lambda1 <= -4.2e-80) tmp = t_3; elseif (lambda1 <= 1.65e-183) tmp = atan2((cos(phi2) * sin(-lambda2)), (t_2 - t_1)); elseif (lambda1 <= 4.3e-21) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - t_1)); else tmp = t_3; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[lambda2], $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -4.2e-80], t$95$3, If[LessEqual[lambda1, 1.65e-183], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - t$95$1), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 4.3e-21], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision], t$95$3]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \phi_1\\
t_1 := \cos \lambda_2 \cdot t_0\\
t_2 := \cos \phi_1 \cdot \sin \phi_2\\
t_3 := \tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_2 - t_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;\lambda_1 \leq -4.2 \cdot 10^{-80}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;\lambda_1 \leq 1.65 \cdot 10^{-183}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_2 - t_1}\\
\mathbf{elif}\;\lambda_1 \leq 4.3 \cdot 10^{-21}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - t_1}\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}
\end{array}
if lambda1 < -4.20000000000000003e-80 or 4.2999999999999998e-21 < lambda1 Initial program 62.4%
Taylor expanded in lambda2 around 0 57.1%
if -4.20000000000000003e-80 < lambda1 < 1.65e-183Initial program 99.7%
Taylor expanded in lambda1 around 0 99.7%
cos-neg99.7%
Simplified99.7%
Taylor expanded in lambda1 around 0 90.1%
if 1.65e-183 < lambda1 < 4.2999999999999998e-21Initial program 99.8%
Taylor expanded in lambda1 around 0 99.8%
cos-neg99.8%
Simplified99.8%
Taylor expanded in phi1 around 0 90.9%
Final simplification70.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -8e-6) (not (<= phi1 2.1e-59)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(-
(* (cos phi1) (sin phi2))
(* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2))))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* phi1 (cos (- lambda2 lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -8e-6) || !(phi1 <= 2.1e-59)) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((phi1 <= (-8d-6)) .or. (.not. (phi1 <= 2.1d-59))) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -8e-6) || !(phi1 <= 2.1e-59)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (phi1 <= -8e-6) or not (phi1 <= 2.1e-59): tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2)))))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -8e-6) || !(phi1 <= 2.1e-59)) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi1 <= -8e-6) || ~((phi1 <= 2.1e-59))) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -8e-6], N[Not[LessEqual[phi1, 2.1e-59]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(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[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -8 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 2.1 \cdot 10^{-59}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\end{array}
\end{array}
if phi1 < -7.99999999999999964e-6 or 2.09999999999999997e-59 < phi1 Initial program 76.5%
*-commutative76.5%
associate-*l*76.5%
Simplified76.5%
if -7.99999999999999964e-6 < phi1 < 2.09999999999999997e-59Initial program 78.5%
Taylor expanded in phi1 around 0 78.5%
*-commutative78.5%
sub-neg78.5%
remove-double-neg78.5%
mul-1-neg78.5%
distribute-neg-in78.5%
+-commutative78.5%
cos-neg78.5%
mul-1-neg78.5%
unsub-neg78.5%
Simplified78.5%
Taylor expanded in phi2 around 0 78.5%
Taylor expanded in phi1 around 0 78.5%
sin-diff99.4%
Applied egg-rr99.4%
Final simplification86.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (cos phi2) (sin phi1))))
(if (or (<= lambda2 -0.102) (not (<= lambda2 7.6e+31)))
(atan2 (* (cos phi2) (sin (- lambda2))) (- t_0 (* (cos lambda2) t_1)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (cos lambda1) t_1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double tmp;
if ((lambda2 <= -0.102) || !(lambda2 <= 7.6e+31)) {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(lambda2) * t_1)));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * t_1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
if ((lambda2 <= (-0.102d0)) .or. (.not. (lambda2 <= 7.6d+31))) then
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(lambda2) * t_1)))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * 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(phi2) * Math.sin(phi1);
double tmp;
if ((lambda2 <= -0.102) || !(lambda2 <= 7.6e+31)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_0 - (Math.cos(lambda2) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.cos(lambda1) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) tmp = 0 if (lambda2 <= -0.102) or not (lambda2 <= 7.6e+31): tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_0 - (math.cos(lambda2) * t_1))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.cos(lambda1) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if ((lambda2 <= -0.102) || !(lambda2 <= 7.6e+31)) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_0 - Float64(cos(lambda2) * t_1))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(lambda1) * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin(phi1); tmp = 0.0; if ((lambda2 <= -0.102) || ~((lambda2 <= 7.6e+31))) tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(lambda2) * t_1))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * 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[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -0.102], N[Not[LessEqual[lambda2, 7.6e+31]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $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 \phi_2 \cdot \sin \phi_1\\
\mathbf{if}\;\lambda_2 \leq -0.102 \lor \neg \left(\lambda_2 \leq 7.6 \cdot 10^{+31}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_0 - \cos \lambda_2 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \cos \lambda_1 \cdot t_1}\\
\end{array}
\end{array}
if lambda2 < -0.101999999999999993 or 7.6000000000000003e31 < lambda2 Initial program 56.2%
Taylor expanded in lambda1 around 0 56.2%
cos-neg56.2%
Simplified56.2%
Taylor expanded in lambda1 around 0 57.1%
if -0.101999999999999993 < lambda2 < 7.6000000000000003e31Initial program 98.0%
Taylor expanded in lambda2 around 0 98.0%
Final simplification77.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -0.0295) (not (<= lambda2 7.6e+31)))
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_0 (* (cos lambda2) (* (cos phi2) (sin phi1)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (cos phi2) (/ (* (sin phi1) 2.0) 2.0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda2 <= -0.0295) || !(lambda2 <= 7.6e+31)) {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(lambda2) * (cos(phi2) * sin(phi1)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * ((sin(phi1) * 2.0) / 2.0))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda2 <= (-0.0295d0)) .or. (.not. (lambda2 <= 7.6d+31))) then
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(lambda2) * (cos(phi2) * sin(phi1)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * ((sin(phi1) * 2.0d0) / 2.0d0))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda2 <= -0.0295) || !(lambda2 <= 7.6e+31)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_0 - (Math.cos(lambda2) * (Math.cos(phi2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.cos(phi2) * ((Math.sin(phi1) * 2.0) / 2.0))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda2 <= -0.0295) or not (lambda2 <= 7.6e+31): tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_0 - (math.cos(lambda2) * (math.cos(phi2) * math.sin(phi1))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.cos(phi2) * ((math.sin(phi1) * 2.0) / 2.0)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda2 <= -0.0295) || !(lambda2 <= 7.6e+31)) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_0 - Float64(cos(lambda2) * Float64(cos(phi2) * sin(phi1))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(phi2) * Float64(Float64(sin(phi1) * 2.0) / 2.0)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda2 <= -0.0295) || ~((lambda2 <= 7.6e+31))) tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(lambda2) * (cos(phi2) * sin(phi1))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * ((sin(phi1) * 2.0) / 2.0)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -0.0295], N[Not[LessEqual[lambda2, 7.6e+31]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[phi1], $MachinePrecision] * 2.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -0.0295 \lor \neg \left(\lambda_2 \leq 7.6 \cdot 10^{+31}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_0 - \cos \lambda_2 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \cos \phi_2 \cdot \frac{\sin \phi_1 \cdot 2}{2}}\\
\end{array}
\end{array}
if lambda2 < -0.029499999999999998 or 7.6000000000000003e31 < lambda2 Initial program 56.2%
Taylor expanded in lambda1 around 0 56.2%
cos-neg56.2%
Simplified56.2%
Taylor expanded in lambda1 around 0 57.1%
if -0.029499999999999998 < lambda2 < 7.6000000000000003e31Initial program 98.0%
*-commutative98.0%
associate-*l*98.0%
Simplified98.0%
sin-cos-mult75.5%
+-commutative75.5%
Applied egg-rr75.5%
Taylor expanded in lambda2 around 0 75.5%
+-commutative75.5%
Simplified75.5%
Taylor expanded in lambda1 around 0 75.7%
*-commutative75.7%
Simplified75.7%
Final simplification66.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}
\end{array}
Initial program 77.4%
*-commutative77.4%
associate-*l*77.4%
Simplified77.4%
Final simplification77.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (or (<= lambda2 -1.52e+113) (not (<= lambda2 8.2e+31)))
(atan2 t_1 (- t_0 (* (cos lambda2) (sin phi1))))
(atan2 t_1 (- t_0 (* (cos phi2) (/ (* (sin phi1) 2.0) 2.0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if ((lambda2 <= -1.52e+113) || !(lambda2 <= 8.2e+31)) {
tmp = atan2(t_1, (t_0 - (cos(lambda2) * sin(phi1))));
} else {
tmp = atan2(t_1, (t_0 - (cos(phi2) * ((sin(phi1) * 2.0) / 2.0))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin((lambda1 - lambda2))
if ((lambda2 <= (-1.52d+113)) .or. (.not. (lambda2 <= 8.2d+31))) then
tmp = atan2(t_1, (t_0 - (cos(lambda2) * sin(phi1))))
else
tmp = atan2(t_1, (t_0 - (cos(phi2) * ((sin(phi1) * 2.0d0) / 2.0d0))))
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(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if ((lambda2 <= -1.52e+113) || !(lambda2 <= 8.2e+31)) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(lambda2) * Math.sin(phi1))));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(phi2) * ((Math.sin(phi1) * 2.0) / 2.0))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if (lambda2 <= -1.52e+113) or not (lambda2 <= 8.2e+31): tmp = math.atan2(t_1, (t_0 - (math.cos(lambda2) * math.sin(phi1)))) else: tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * ((math.sin(phi1) * 2.0) / 2.0)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if ((lambda2 <= -1.52e+113) || !(lambda2 <= 8.2e+31)) tmp = atan(t_1, Float64(t_0 - Float64(cos(lambda2) * sin(phi1)))); else tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * Float64(Float64(sin(phi1) * 2.0) / 2.0)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if ((lambda2 <= -1.52e+113) || ~((lambda2 <= 8.2e+31))) tmp = atan2(t_1, (t_0 - (cos(lambda2) * sin(phi1)))); else tmp = atan2(t_1, (t_0 - (cos(phi2) * ((sin(phi1) * 2.0) / 2.0)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -1.52e+113], N[Not[LessEqual[lambda2, 8.2e+31]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[phi1], $MachinePrecision] * 2.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_2 \leq -1.52 \cdot 10^{+113} \lor \neg \left(\lambda_2 \leq 8.2 \cdot 10^{+31}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \lambda_2 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \phi_2 \cdot \frac{\sin \phi_1 \cdot 2}{2}}\\
\end{array}
\end{array}
if lambda2 < -1.52000000000000003e113 or 8.2000000000000003e31 < lambda2 Initial program 57.3%
Taylor expanded in lambda1 around 0 57.3%
cos-neg57.3%
Simplified57.3%
Taylor expanded in phi2 around 0 46.6%
if -1.52000000000000003e113 < lambda2 < 8.2000000000000003e31Initial program 93.0%
*-commutative93.0%
associate-*l*93.0%
Simplified93.0%
sin-cos-mult72.3%
+-commutative72.3%
Applied egg-rr72.3%
Taylor expanded in lambda2 around 0 72.3%
+-commutative72.3%
Simplified72.3%
Taylor expanded in lambda1 around 0 72.4%
*-commutative72.4%
Simplified72.4%
Final simplification61.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) (* (cos lambda2) (* (cos phi2) (sin phi1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda2) * (cos(phi2) * sin(phi1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda2) * (cos(phi2) * sin(phi1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.cos(lambda2) * (Math.cos(phi2) * Math.sin(phi1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.cos(lambda2) * (math.cos(phi2) * math.sin(phi1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(cos(lambda2) * Float64(cos(phi2) * sin(phi1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda2) * (cos(phi2) * sin(phi1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda2], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \lambda_2 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}
\end{array}
Initial program 77.4%
Taylor expanded in lambda1 around 0 66.1%
cos-neg66.1%
Simplified66.1%
Taylor expanded in phi1 around 0 57.8%
Final simplification57.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) (fabs (* phi1 (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - fabs((phi1 * cos((lambda1 - lambda2))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - abs((phi1 * cos((lambda1 - lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - Math.abs((phi1 * Math.cos((lambda1 - lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - math.fabs((phi1 * math.cos((lambda1 - lambda2))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - abs(Float64(phi1 * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - abs((phi1 * cos((lambda1 - lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[Abs[N[(phi1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \left|\phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right|}
\end{array}
Initial program 77.4%
Taylor expanded in phi1 around 0 47.4%
*-commutative47.4%
sub-neg47.4%
remove-double-neg47.4%
mul-1-neg47.4%
distribute-neg-in47.4%
+-commutative47.4%
cos-neg47.4%
mul-1-neg47.4%
unsub-neg47.4%
Simplified47.4%
Taylor expanded in phi2 around 0 46.7%
Taylor expanded in phi1 around 0 46.7%
add-sqr-sqrt26.5%
sqrt-unprod49.0%
pow249.0%
Applied egg-rr49.0%
unpow249.0%
rem-sqrt-square49.0%
sub-neg49.0%
neg-mul-149.0%
neg-mul-149.0%
remove-double-neg49.0%
mul-1-neg49.0%
distribute-neg-in49.0%
+-commutative49.0%
cos-neg49.0%
mul-1-neg49.0%
unsub-neg49.0%
Simplified49.0%
Final simplification49.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) (* phi1 (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (phi1 * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 77.4%
Taylor expanded in phi1 around 0 47.4%
*-commutative47.4%
sub-neg47.4%
remove-double-neg47.4%
mul-1-neg47.4%
distribute-neg-in47.4%
+-commutative47.4%
cos-neg47.4%
mul-1-neg47.4%
unsub-neg47.4%
Simplified47.4%
Taylor expanded in phi2 around 0 46.7%
Taylor expanded in phi1 around 0 46.7%
Final simplification46.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin lambda1) (cos phi2)) (- (sin phi2) (* phi1 (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
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(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin(lambda1) * math.cos(phi2)), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(lambda1) * cos(phi2)), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 77.4%
Taylor expanded in phi1 around 0 47.4%
*-commutative47.4%
sub-neg47.4%
remove-double-neg47.4%
mul-1-neg47.4%
distribute-neg-in47.4%
+-commutative47.4%
cos-neg47.4%
mul-1-neg47.4%
unsub-neg47.4%
Simplified47.4%
Taylor expanded in phi2 around 0 46.7%
Taylor expanded in phi1 around 0 46.7%
Taylor expanded in lambda2 around 0 30.5%
Final simplification30.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) (* (cos lambda1) phi1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda1) * phi1)));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda1) * phi1)))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.cos(lambda1) * phi1)));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.cos(lambda1) * phi1)))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(cos(lambda1) * phi1))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda1) * phi1))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \lambda_1 \cdot \phi_1}
\end{array}
Initial program 77.4%
Taylor expanded in phi1 around 0 47.4%
*-commutative47.4%
sub-neg47.4%
remove-double-neg47.4%
mul-1-neg47.4%
distribute-neg-in47.4%
+-commutative47.4%
cos-neg47.4%
mul-1-neg47.4%
unsub-neg47.4%
Simplified47.4%
Taylor expanded in phi2 around 0 46.7%
Taylor expanded in phi1 around 0 46.7%
Taylor expanded in lambda2 around 0 46.7%
cos-neg46.7%
Simplified46.7%
Final simplification46.7%
herbie shell --seed 2024013
(FPCore (lambda1 lambda2 phi1 phi2)
:name "Bearing on a great circle"
:precision binary64
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))