
(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 25 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
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
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(-
(* (cos phi1) (sin phi2))
(*
(sin phi1)
(*
(cos phi2)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(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) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * (Math.cos(phi2) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1)))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * (math.cos(phi2) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1)))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1))))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)}
\end{array}
Initial program 76.8%
associate-*l*76.8%
Simplified76.8%
sin-diff88.5%
sub-neg88.5%
Applied egg-rr88.5%
sub-neg88.5%
Simplified88.5%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (- t_1 (* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
(t_3 (* (sin lambda1) (cos lambda2)))
(t_4 (- t_3 t_0)))
(if (<= phi2 -0.0027)
(atan2 (* (cos phi2) (- (expm1 (log1p t_3)) t_0)) t_2)
(if (<= phi2 0.68)
(atan2
(* (+ (* -0.5 (* phi2 phi2)) 1.0) t_4)
(-
t_1
(*
(sin phi1)
(*
(cos phi2)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1)))))))
(atan2 (* (cos phi2) t_4) t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = t_1 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))));
double t_3 = sin(lambda1) * cos(lambda2);
double t_4 = t_3 - t_0;
double tmp;
if (phi2 <= -0.0027) {
tmp = atan2((cos(phi2) * (expm1(log1p(t_3)) - t_0)), t_2);
} else if (phi2 <= 0.68) {
tmp = atan2((((-0.5 * (phi2 * phi2)) + 1.0) * t_4), (t_1 - (sin(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))));
} else {
tmp = atan2((cos(phi2) * t_4), t_2);
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(lambda1) * Math.sin(lambda2);
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double t_2 = t_1 - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))));
double t_3 = Math.sin(lambda1) * Math.cos(lambda2);
double t_4 = t_3 - t_0;
double tmp;
if (phi2 <= -0.0027) {
tmp = Math.atan2((Math.cos(phi2) * (Math.expm1(Math.log1p(t_3)) - t_0)), t_2);
} else if (phi2 <= 0.68) {
tmp = Math.atan2((((-0.5 * (phi2 * phi2)) + 1.0) * t_4), (t_1 - (Math.sin(phi1) * (Math.cos(phi2) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1)))))));
} else {
tmp = Math.atan2((Math.cos(phi2) * t_4), t_2);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda1) * math.sin(lambda2) t_1 = math.cos(phi1) * math.sin(phi2) t_2 = t_1 - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2)))) t_3 = math.sin(lambda1) * math.cos(lambda2) t_4 = t_3 - t_0 tmp = 0 if phi2 <= -0.0027: tmp = math.atan2((math.cos(phi2) * (math.expm1(math.log1p(t_3)) - t_0)), t_2) elif phi2 <= 0.68: tmp = math.atan2((((-0.5 * (phi2 * phi2)) + 1.0) * t_4), (t_1 - (math.sin(phi1) * (math.cos(phi2) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1))))))) else: tmp = math.atan2((math.cos(phi2) * t_4), t_2) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = Float64(t_1 - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))) t_3 = Float64(sin(lambda1) * cos(lambda2)) t_4 = Float64(t_3 - t_0) tmp = 0.0 if (phi2 <= -0.0027) tmp = atan(Float64(cos(phi2) * Float64(expm1(log1p(t_3)) - t_0)), t_2); elseif (phi2 <= 0.68) tmp = atan(Float64(Float64(Float64(-0.5 * Float64(phi2 * phi2)) + 1.0) * t_4), Float64(t_1 - Float64(sin(phi1) * Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1))))))); else tmp = atan(Float64(cos(phi2) * t_4), t_2); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 - t$95$0), $MachinePrecision]}, If[LessEqual[phi2, -0.0027], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(Exp[N[Log[1 + t$95$3], $MachinePrecision]] - 1), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi2, 0.68], N[ArcTan[N[(N[(N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$4), $MachinePrecision] / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$4), $MachinePrecision] / t$95$2], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := t_1 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
t_3 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_4 := t_3 - t_0\\
\mathbf{if}\;\phi_2 \leq -0.0027:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\mathsf{expm1}\left(\mathsf{log1p}\left(t_3\right)\right) - t_0\right)}{t_2}\\
\mathbf{elif}\;\phi_2 \leq 0.68:\\
\;\;\;\;\tan^{-1}_* \frac{\left(-0.5 \cdot \left(\phi_2 \cdot \phi_2\right) + 1\right) \cdot t_4}{t_1 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_4}{t_2}\\
\end{array}
\end{array}
if phi2 < -0.0027000000000000001Initial program 73.2%
associate-*l*73.2%
Simplified73.2%
sin-diff91.1%
sub-neg91.1%
Applied egg-rr91.1%
sub-neg91.1%
Simplified91.1%
expm1-log1p-u91.1%
Applied egg-rr91.1%
if -0.0027000000000000001 < phi2 < 0.680000000000000049Initial program 82.1%
associate-*l*82.1%
Simplified82.1%
sin-diff86.8%
sub-neg86.8%
Applied egg-rr86.8%
sub-neg86.8%
Simplified86.8%
cos-diff99.9%
+-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in phi2 around 0 99.4%
associate--l+99.4%
associate-*r*99.4%
distribute-lft1-in99.4%
unpow299.4%
*-commutative99.4%
Simplified99.4%
if 0.680000000000000049 < phi2 Initial program 68.3%
associate-*l*68.3%
Simplified68.3%
sin-diff90.0%
sub-neg90.0%
Applied egg-rr90.0%
sub-neg90.0%
Simplified90.0%
Final simplification95.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2)))
(t_1
(-
(* (cos phi1) (sin phi2))
(* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
(t_2 (* (sin lambda1) (cos lambda2)))
(t_3 (* (cos phi2) (- t_2 t_0))))
(if (<= phi2 -0.00014)
(atan2 (* (cos phi2) (- (expm1 (log1p t_2)) t_0)) t_1)
(if (<= phi2 0.68)
(atan2
t_3
(-
(* phi2 (cos phi1))
(*
(sin phi1)
(*
(cos phi2)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1)))))))
(atan2 t_3 t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = (cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))));
double t_2 = sin(lambda1) * cos(lambda2);
double t_3 = cos(phi2) * (t_2 - t_0);
double tmp;
if (phi2 <= -0.00014) {
tmp = atan2((cos(phi2) * (expm1(log1p(t_2)) - t_0)), t_1);
} else if (phi2 <= 0.68) {
tmp = atan2(t_3, ((phi2 * cos(phi1)) - (sin(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))));
} else {
tmp = atan2(t_3, t_1);
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(lambda1) * Math.sin(lambda2);
double t_1 = (Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))));
double t_2 = Math.sin(lambda1) * Math.cos(lambda2);
double t_3 = Math.cos(phi2) * (t_2 - t_0);
double tmp;
if (phi2 <= -0.00014) {
tmp = Math.atan2((Math.cos(phi2) * (Math.expm1(Math.log1p(t_2)) - t_0)), t_1);
} else if (phi2 <= 0.68) {
tmp = Math.atan2(t_3, ((phi2 * Math.cos(phi1)) - (Math.sin(phi1) * (Math.cos(phi2) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1)))))));
} else {
tmp = Math.atan2(t_3, t_1);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda1) * math.sin(lambda2) t_1 = (math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2)))) t_2 = math.sin(lambda1) * math.cos(lambda2) t_3 = math.cos(phi2) * (t_2 - t_0) tmp = 0 if phi2 <= -0.00014: tmp = math.atan2((math.cos(phi2) * (math.expm1(math.log1p(t_2)) - t_0)), t_1) elif phi2 <= 0.68: tmp = math.atan2(t_3, ((phi2 * math.cos(phi1)) - (math.sin(phi1) * (math.cos(phi2) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1))))))) else: tmp = math.atan2(t_3, t_1) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) t_1 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))) t_2 = Float64(sin(lambda1) * cos(lambda2)) t_3 = Float64(cos(phi2) * Float64(t_2 - t_0)) tmp = 0.0 if (phi2 <= -0.00014) tmp = atan(Float64(cos(phi2) * Float64(expm1(log1p(t_2)) - t_0)), t_1); elseif (phi2 <= 0.68) tmp = atan(t_3, Float64(Float64(phi2 * cos(phi1)) - Float64(sin(phi1) * Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1))))))); else tmp = atan(t_3, t_1); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$2 - t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.00014], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(Exp[N[Log[1 + t$95$2], $MachinePrecision]] - 1), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision], If[LessEqual[phi2, 0.68], N[ArcTan[t$95$3 / N[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$3 / t$95$1], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
t_2 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_3 := \cos \phi_2 \cdot \left(t_2 - t_0\right)\\
\mathbf{if}\;\phi_2 \leq -0.00014:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\mathsf{expm1}\left(\mathsf{log1p}\left(t_2\right)\right) - t_0\right)}{t_1}\\
\mathbf{elif}\;\phi_2 \leq 0.68:\\
\;\;\;\;\tan^{-1}_* \frac{t_3}{\phi_2 \cdot \cos \phi_1 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_3}{t_1}\\
\end{array}
\end{array}
if phi2 < -1.3999999999999999e-4Initial program 72.4%
associate-*l*72.4%
Simplified72.4%
sin-diff91.4%
sub-neg91.4%
Applied egg-rr91.4%
sub-neg91.4%
Simplified91.4%
expm1-log1p-u91.4%
Applied egg-rr91.4%
if -1.3999999999999999e-4 < phi2 < 0.680000000000000049Initial program 82.6%
associate-*l*82.6%
Simplified82.6%
sin-diff86.6%
sub-neg86.6%
Applied egg-rr86.6%
sub-neg86.6%
Simplified86.6%
cos-diff99.9%
+-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in phi2 around 0 99.4%
if 0.680000000000000049 < phi2 Initial program 68.3%
associate-*l*68.3%
Simplified68.3%
sin-diff90.0%
sub-neg90.0%
Applied egg-rr90.0%
sub-neg90.0%
Simplified90.0%
Final simplification95.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (- t_1 (* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
(t_3 (* (sin lambda1) (cos lambda2)))
(t_4 (- t_3 t_0)))
(if (<= phi2 -2.1e-5)
(atan2 (* (cos phi2) (- (expm1 (log1p t_3)) t_0)) t_2)
(if (<= phi2 0.68)
(atan2
t_4
(-
t_1
(*
(sin phi1)
(*
(cos phi2)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1)))))))
(atan2 (* (cos phi2) t_4) t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = t_1 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))));
double t_3 = sin(lambda1) * cos(lambda2);
double t_4 = t_3 - t_0;
double tmp;
if (phi2 <= -2.1e-5) {
tmp = atan2((cos(phi2) * (expm1(log1p(t_3)) - t_0)), t_2);
} else if (phi2 <= 0.68) {
tmp = atan2(t_4, (t_1 - (sin(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))));
} else {
tmp = atan2((cos(phi2) * t_4), t_2);
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(lambda1) * Math.sin(lambda2);
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double t_2 = t_1 - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))));
double t_3 = Math.sin(lambda1) * Math.cos(lambda2);
double t_4 = t_3 - t_0;
double tmp;
if (phi2 <= -2.1e-5) {
tmp = Math.atan2((Math.cos(phi2) * (Math.expm1(Math.log1p(t_3)) - t_0)), t_2);
} else if (phi2 <= 0.68) {
tmp = Math.atan2(t_4, (t_1 - (Math.sin(phi1) * (Math.cos(phi2) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1)))))));
} else {
tmp = Math.atan2((Math.cos(phi2) * t_4), t_2);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda1) * math.sin(lambda2) t_1 = math.cos(phi1) * math.sin(phi2) t_2 = t_1 - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2)))) t_3 = math.sin(lambda1) * math.cos(lambda2) t_4 = t_3 - t_0 tmp = 0 if phi2 <= -2.1e-5: tmp = math.atan2((math.cos(phi2) * (math.expm1(math.log1p(t_3)) - t_0)), t_2) elif phi2 <= 0.68: tmp = math.atan2(t_4, (t_1 - (math.sin(phi1) * (math.cos(phi2) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1))))))) else: tmp = math.atan2((math.cos(phi2) * t_4), t_2) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = Float64(t_1 - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))) t_3 = Float64(sin(lambda1) * cos(lambda2)) t_4 = Float64(t_3 - t_0) tmp = 0.0 if (phi2 <= -2.1e-5) tmp = atan(Float64(cos(phi2) * Float64(expm1(log1p(t_3)) - t_0)), t_2); elseif (phi2 <= 0.68) tmp = atan(t_4, Float64(t_1 - Float64(sin(phi1) * Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1))))))); else tmp = atan(Float64(cos(phi2) * t_4), t_2); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 - t$95$0), $MachinePrecision]}, If[LessEqual[phi2, -2.1e-5], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(Exp[N[Log[1 + t$95$3], $MachinePrecision]] - 1), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi2, 0.68], N[ArcTan[t$95$4 / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$4), $MachinePrecision] / t$95$2], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := t_1 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
t_3 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_4 := t_3 - t_0\\
\mathbf{if}\;\phi_2 \leq -2.1 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\mathsf{expm1}\left(\mathsf{log1p}\left(t_3\right)\right) - t_0\right)}{t_2}\\
\mathbf{elif}\;\phi_2 \leq 0.68:\\
\;\;\;\;\tan^{-1}_* \frac{t_4}{t_1 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_4}{t_2}\\
\end{array}
\end{array}
if phi2 < -2.09999999999999988e-5Initial program 72.4%
associate-*l*72.4%
Simplified72.4%
sin-diff91.4%
sub-neg91.4%
Applied egg-rr91.4%
sub-neg91.4%
Simplified91.4%
expm1-log1p-u91.4%
Applied egg-rr91.4%
if -2.09999999999999988e-5 < phi2 < 0.680000000000000049Initial program 82.6%
associate-*l*82.6%
Simplified82.6%
sin-diff86.6%
sub-neg86.6%
Applied egg-rr86.6%
sub-neg86.6%
Simplified86.6%
cos-diff99.9%
+-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in phi2 around 0 99.4%
*-commutative99.4%
Simplified99.4%
if 0.680000000000000049 < phi2 Initial program 68.3%
associate-*l*68.3%
Simplified68.3%
sin-diff90.0%
sub-neg90.0%
Applied egg-rr90.0%
sub-neg90.0%
Simplified90.0%
Final simplification95.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(cos phi2)
(-
(expm1 (log1p (* (sin lambda1) (cos lambda2))))
(* (cos lambda1) (sin lambda2))))
(-
(* (cos phi1) (sin phi2))
(* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * (expm1(log1p((sin(lambda1) * cos(lambda2)))) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * (Math.expm1(Math.log1p((Math.sin(lambda1) * Math.cos(lambda2)))) - (Math.cos(lambda1) * Math.sin(lambda2)))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * (math.expm1(math.log1p((math.sin(lambda1) * math.cos(lambda2)))) - (math.cos(lambda1) * math.sin(lambda2)))), ((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(cos(phi2) * Float64(expm1(log1p(Float64(sin(lambda1) * cos(lambda2)))) - Float64(cos(lambda1) * sin(lambda2)))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(Exp[N[Log[1 + N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \lambda_1 \cdot \cos \lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}
\end{array}
Initial program 76.8%
associate-*l*76.8%
Simplified76.8%
sin-diff88.5%
sub-neg88.5%
Applied egg-rr88.5%
sub-neg88.5%
Simplified88.5%
expm1-log1p-u88.5%
Applied egg-rr88.5%
Final simplification88.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda1 -3.8e-11) (not (<= lambda1 5.2e-29)))
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(- t_0 (* (sin phi1) (* (cos lambda1) (cos phi2)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda1 <= -3.8e-11) || !(lambda1 <= 5.2e-29)) {
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * cos((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 ((lambda1 <= (-3.8d-11)) .or. (.not. (lambda1 <= 5.2d-29))) then
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda1 <= -3.8e-11) || !(lambda1 <= 5.2e-29)) {
tmp = Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (t_0 - (Math.sin(phi1) * (Math.cos(lambda1) * Math.cos(phi2)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda1 <= -3.8e-11) or not (lambda1 <= 5.2e-29): tmp = math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), (t_0 - (math.sin(phi1) * (math.cos(lambda1) * math.cos(phi2))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2)))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda1 <= -3.8e-11) || !(lambda1 <= 5.2e-29)) tmp = atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(lambda1) * cos(phi2))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda1 <= -3.8e-11) || ~((lambda1 <= 5.2e-29))) tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2)))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -3.8e-11], N[Not[LessEqual[lambda1, 5.2e-29]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $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[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -3.8 \cdot 10^{-11} \lor \neg \left(\lambda_1 \leq 5.2 \cdot 10^{-29}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\end{array}
\end{array}
if lambda1 < -3.7999999999999998e-11 or 5.2000000000000004e-29 < lambda1 Initial program 55.1%
associate-*l*55.1%
Simplified55.1%
sin-diff77.9%
sub-neg77.9%
Applied egg-rr77.9%
sub-neg77.9%
Simplified77.9%
Taylor expanded in lambda2 around 0 78.0%
if -3.7999999999999998e-11 < lambda1 < 5.2000000000000004e-29Initial program 99.8%
associate-*l*99.8%
Simplified99.8%
Final simplification88.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(cos phi2)
(-
(* (sin lambda1) (cos lambda2))
(* (cos lambda1) (sin lambda2))))))
(if (or (<= lambda1 -5.0) (not (<= lambda1 5.2e-29)))
(atan2 t_1 (- t_0 (* (sin phi1) (* (cos lambda1) (cos phi2)))))
(atan2 t_1 (- t_0 (* (sin phi1) (* (cos lambda2) (cos phi2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)));
double tmp;
if ((lambda1 <= -5.0) || !(lambda1 <= 5.2e-29)) {
tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))));
} else {
tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2)))));
}
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) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))
if ((lambda1 <= (-5.0d0)) .or. (.not. (lambda1 <= 5.2d-29))) then
tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))))
else
tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)));
double tmp;
if ((lambda1 <= -5.0) || !(lambda1 <= 5.2e-29)) {
tmp = Math.atan2(t_1, (t_0 - (Math.sin(phi1) * (Math.cos(lambda1) * Math.cos(phi2)))));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.sin(phi1) * (Math.cos(lambda2) * Math.cos(phi2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) tmp = 0 if (lambda1 <= -5.0) or not (lambda1 <= 5.2e-29): tmp = math.atan2(t_1, (t_0 - (math.sin(phi1) * (math.cos(lambda1) * math.cos(phi2))))) else: tmp = math.atan2(t_1, (t_0 - (math.sin(phi1) * (math.cos(lambda2) * math.cos(phi2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))) tmp = 0.0 if ((lambda1 <= -5.0) || !(lambda1 <= 5.2e-29)) tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * Float64(cos(lambda1) * cos(phi2))))); else tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * Float64(cos(lambda2) * cos(phi2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))); tmp = 0.0; if ((lambda1 <= -5.0) || ~((lambda1 <= 5.2e-29))) tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2))))); else tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -5.0], N[Not[LessEqual[lambda1, 5.2e-29]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $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 \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -5 \lor \neg \left(\lambda_1 \leq 5.2 \cdot 10^{-29}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \sin \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \phi_2\right)}\\
\end{array}
\end{array}
if lambda1 < -5 or 5.2000000000000004e-29 < lambda1 Initial program 55.1%
associate-*l*55.1%
Simplified55.1%
sin-diff77.4%
sub-neg77.4%
Applied egg-rr77.4%
sub-neg77.4%
Simplified77.4%
Taylor expanded in lambda2 around 0 77.5%
if -5 < lambda1 < 5.2000000000000004e-29Initial program 98.7%
associate-*l*98.7%
Simplified98.7%
sin-diff99.8%
sub-neg99.8%
Applied egg-rr99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in lambda1 around 0 99.8%
cos-neg78.3%
associate-*r*78.3%
Simplified99.8%
Final simplification88.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))) (- (* (cos phi1) (sin phi2)) (* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((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((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), ((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(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}
\end{array}
Initial program 76.8%
associate-*l*76.8%
Simplified76.8%
sin-diff88.5%
sub-neg88.5%
Applied egg-rr88.5%
sub-neg88.5%
Simplified88.5%
Final simplification88.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -120.0) (not (<= phi1 0.000415)))
(atan2
(* (cos phi2) (- (sin lambda1) t_0))
(- t_1 (* (sin phi1) (* (cos phi2) t_2))))
(atan2
(* (cos phi2) (- (* (sin lambda1) (cos lambda2)) t_0))
(- t_1 (* t_2 (* (cos phi2) phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -120.0) || !(phi1 <= 0.000415)) {
tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), (t_1 - (sin(phi1) * (cos(phi2) * t_2))));
} else {
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - t_0)), (t_1 - (t_2 * (cos(phi2) * phi1))));
}
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) :: tmp
t_0 = cos(lambda1) * sin(lambda2)
t_1 = cos(phi1) * sin(phi2)
t_2 = cos((lambda1 - lambda2))
if ((phi1 <= (-120.0d0)) .or. (.not. (phi1 <= 0.000415d0))) then
tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), (t_1 - (sin(phi1) * (cos(phi2) * t_2))))
else
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - t_0)), (t_1 - (t_2 * (cos(phi2) * phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(lambda1) * Math.sin(lambda2);
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double t_2 = Math.cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -120.0) || !(phi1 <= 0.000415)) {
tmp = Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - t_0)), (t_1 - (Math.sin(phi1) * (Math.cos(phi2) * t_2))));
} else {
tmp = Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - t_0)), (t_1 - (t_2 * (Math.cos(phi2) * phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda1) * math.sin(lambda2) t_1 = math.cos(phi1) * math.sin(phi2) t_2 = math.cos((lambda1 - lambda2)) tmp = 0 if (phi1 <= -120.0) or not (phi1 <= 0.000415): tmp = math.atan2((math.cos(phi2) * (math.sin(lambda1) - t_0)), (t_1 - (math.sin(phi1) * (math.cos(phi2) * t_2)))) else: tmp = math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - t_0)), (t_1 - (t_2 * (math.cos(phi2) * phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -120.0) || !(phi1 <= 0.000415)) tmp = atan(Float64(cos(phi2) * Float64(sin(lambda1) - t_0)), Float64(t_1 - Float64(sin(phi1) * Float64(cos(phi2) * t_2)))); else tmp = atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - t_0)), Float64(t_1 - Float64(t_2 * Float64(cos(phi2) * phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(lambda1) * sin(lambda2); t_1 = cos(phi1) * sin(phi2); t_2 = cos((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -120.0) || ~((phi1 <= 0.000415))) tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), (t_1 - (sin(phi1) * (cos(phi2) * t_2)))); else tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - t_0)), (t_1 - (t_2 * (cos(phi2) * phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -120.0], N[Not[LessEqual[phi1, 0.000415]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(t$95$2 * N[(N[Cos[phi2], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -120 \lor \neg \left(\phi_1 \leq 0.000415\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - t_0\right)}{t_1 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - t_0\right)}{t_1 - t_2 \cdot \left(\cos \phi_2 \cdot \phi_1\right)}\\
\end{array}
\end{array}
if phi1 < -120 or 4.15e-4 < phi1 Initial program 72.8%
associate-*l*72.8%
Simplified72.8%
sin-diff76.1%
sub-neg76.1%
Applied egg-rr76.1%
sub-neg76.1%
Simplified76.1%
Taylor expanded in lambda2 around 0 73.9%
if -120 < phi1 < 4.15e-4Initial program 80.0%
associate-*l*80.0%
Simplified80.0%
sin-diff98.8%
sub-neg98.8%
Applied egg-rr98.8%
sub-neg98.8%
Simplified98.8%
Taylor expanded in phi1 around 0 98.8%
associate-*r*98.8%
Simplified98.8%
Final simplification87.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2))))
(if (or (<= phi1 -5.2e-9) (not (<= phi1 7e-6)))
(atan2
(* (cos phi2) (- (sin lambda1) t_0))
(-
(* (cos phi1) (sin phi2))
(* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
(atan2
(* (cos phi2) (- (* (sin lambda1) (cos lambda2)) t_0))
(- (sin phi2) (* phi1 (cos (- lambda2 lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double tmp;
if ((phi1 <= -5.2e-9) || !(phi1 <= 7e-6)) {
tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
} else {
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - t_0)), (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) :: t_0
real(8) :: tmp
t_0 = cos(lambda1) * sin(lambda2)
if ((phi1 <= (-5.2d-9)) .or. (.not. (phi1 <= 7d-6))) then
tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))))
else
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - t_0)), (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 t_0 = Math.cos(lambda1) * Math.sin(lambda2);
double tmp;
if ((phi1 <= -5.2e-9) || !(phi1 <= 7e-6)) {
tmp = Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - t_0)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))))));
} else {
tmp = Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - t_0)), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda1) * math.sin(lambda2) tmp = 0 if (phi1 <= -5.2e-9) or not (phi1 <= 7e-6): tmp = math.atan2((math.cos(phi2) * (math.sin(lambda1) - t_0)), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2)))))) else: tmp = math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - t_0)), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) tmp = 0.0 if ((phi1 <= -5.2e-9) || !(phi1 <= 7e-6)) tmp = atan(Float64(cos(phi2) * Float64(sin(lambda1) - t_0)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - t_0)), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(lambda1) * sin(lambda2); tmp = 0.0; if ((phi1 <= -5.2e-9) || ~((phi1 <= 7e-6))) tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2)))))); else tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - t_0)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -5.2e-9], N[Not[LessEqual[phi1, 7e-6]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$0), $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}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
\mathbf{if}\;\phi_1 \leq -5.2 \cdot 10^{-9} \lor \neg \left(\phi_1 \leq 7 \cdot 10^{-6}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - t_0\right)}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - t_0\right)}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\end{array}
\end{array}
if phi1 < -5.2000000000000002e-9 or 6.99999999999999989e-6 < phi1 Initial program 72.4%
associate-*l*72.4%
Simplified72.4%
sin-diff75.8%
sub-neg75.8%
Applied egg-rr75.8%
sub-neg75.8%
Simplified75.8%
Taylor expanded in lambda2 around 0 73.6%
if -5.2000000000000002e-9 < phi1 < 6.99999999999999989e-6Initial program 80.5%
associate-*l*80.5%
Simplified80.5%
Taylor expanded in phi2 around 0 80.5%
sub-neg80.5%
remove-double-neg80.5%
mul-1-neg80.5%
distribute-neg-in80.5%
+-commutative80.5%
cos-neg80.5%
mul-1-neg80.5%
unsub-neg80.5%
Simplified80.5%
Taylor expanded in phi1 around 0 80.5%
Taylor expanded in phi1 around 0 80.5%
sin-diff99.4%
sub-neg99.4%
Applied egg-rr99.4%
sub-neg99.4%
Simplified99.4%
Final simplification87.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -4.6e-9) (not (<= phi1 1.6e-5)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(-
(* (cos phi1) (sin phi2))
(* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(- (sin phi2) (* phi1 (cos (- lambda2 lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -4.6e-9) || !(phi1 <= 1.6e-5)) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
} else {
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (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 <= (-4.6d-9)) .or. (.not. (phi1 <= 1.6d-5))) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))))
else
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (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 <= -4.6e-9) || !(phi1 <= 1.6e-5)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))))));
} else {
tmp = Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (phi1 <= -4.6e-9) or not (phi1 <= 1.6e-5): tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2)))))) else: tmp = math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -4.6e-9) || !(phi1 <= 1.6e-5)) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), 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 <= -4.6e-9) || ~((phi1 <= 1.6e-5))) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2)))))); else tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (sin(phi2) - (phi1 * cos((lambda2 - lambda1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -4.6e-9], N[Not[LessEqual[phi1, 1.6e-5]], $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[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $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 -4.6 \cdot 10^{-9} \lor \neg \left(\phi_1 \leq 1.6 \cdot 10^{-5}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\end{array}
\end{array}
if phi1 < -4.5999999999999998e-9 or 1.59999999999999993e-5 < phi1 Initial program 72.4%
associate-*l*72.4%
Simplified72.4%
if -4.5999999999999998e-9 < phi1 < 1.59999999999999993e-5Initial program 80.5%
associate-*l*80.5%
Simplified80.5%
Taylor expanded in phi2 around 0 80.5%
sub-neg80.5%
remove-double-neg80.5%
mul-1-neg80.5%
distribute-neg-in80.5%
+-commutative80.5%
cos-neg80.5%
mul-1-neg80.5%
unsub-neg80.5%
Simplified80.5%
Taylor expanded in phi1 around 0 80.5%
Taylor expanded in phi1 around 0 80.5%
sin-diff99.4%
sub-neg99.4%
Applied egg-rr99.4%
sub-neg99.4%
Simplified99.4%
Final simplification87.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -0.76) (not (<= lambda2 4.5e-14)))
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_0 (* (sin phi1) (* (cos lambda2) (cos phi2)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) (* (cos lambda1) (cos phi2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda2 <= -0.76) || !(lambda2 <= 4.5e-14)) {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))));
}
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.76d0)) .or. (.not. (lambda2 <= 4.5d-14))) then
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda2 <= -0.76) || !(lambda2 <= 4.5e-14)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_0 - (Math.sin(phi1) * (Math.cos(lambda2) * Math.cos(phi2)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * (Math.cos(lambda1) * Math.cos(phi2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda2 <= -0.76) or not (lambda2 <= 4.5e-14): tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_0 - (math.sin(phi1) * (math.cos(lambda2) * math.cos(phi2))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * (math.cos(lambda1) * math.cos(phi2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda2 <= -0.76) || !(lambda2 <= 4.5e-14)) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(lambda2) * cos(phi2))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(lambda1) * cos(phi2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda2 <= -0.76) || ~((lambda2 <= 4.5e-14))) tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -0.76], N[Not[LessEqual[lambda2, 4.5e-14]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $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[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $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 -0.76 \lor \neg \left(\lambda_2 \leq 4.5 \cdot 10^{-14}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \phi_2\right)}\\
\end{array}
\end{array}
if lambda2 < -0.76000000000000001 or 4.4999999999999998e-14 < lambda2 Initial program 56.6%
associate-*l*56.6%
Simplified56.6%
Taylor expanded in lambda1 around 0 55.5%
Taylor expanded in lambda1 around 0 55.5%
cos-neg55.5%
associate-*r*55.5%
Simplified55.5%
if -0.76000000000000001 < lambda2 < 4.4999999999999998e-14Initial program 99.2%
associate-*l*99.2%
Simplified99.2%
Taylor expanded in lambda2 around 0 99.2%
Final simplification76.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (or (<= lambda2 -4200000000000.0) (not (<= lambda2 4.5e-14)))
(atan2 t_1 (- t_0 (* (sin phi1) (* (cos lambda2) (cos phi2)))))
(atan2 t_1 (- t_0 (* (sin phi1) (* (cos lambda1) (cos phi2))))))))
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 <= -4200000000000.0) || !(lambda2 <= 4.5e-14)) {
tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2)))));
} else {
tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))));
}
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 <= (-4200000000000.0d0)) .or. (.not. (lambda2 <= 4.5d-14))) then
tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2)))))
else
tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if ((lambda2 <= -4200000000000.0) || !(lambda2 <= 4.5e-14)) {
tmp = Math.atan2(t_1, (t_0 - (Math.sin(phi1) * (Math.cos(lambda2) * Math.cos(phi2)))));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.sin(phi1) * (Math.cos(lambda1) * Math.cos(phi2)))));
}
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 <= -4200000000000.0) or not (lambda2 <= 4.5e-14): tmp = math.atan2(t_1, (t_0 - (math.sin(phi1) * (math.cos(lambda2) * math.cos(phi2))))) else: tmp = math.atan2(t_1, (t_0 - (math.sin(phi1) * (math.cos(lambda1) * math.cos(phi2))))) 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 <= -4200000000000.0) || !(lambda2 <= 4.5e-14)) tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * Float64(cos(lambda2) * cos(phi2))))); else tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * Float64(cos(lambda1) * cos(phi2))))); 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 <= -4200000000000.0) || ~((lambda2 <= 4.5e-14))) tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2))))); else tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -4200000000000.0], N[Not[LessEqual[lambda2, 4.5e-14]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $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 -4200000000000 \lor \neg \left(\lambda_2 \leq 4.5 \cdot 10^{-14}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \sin \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \phi_2\right)}\\
\end{array}
\end{array}
if lambda2 < -4.2e12 or 4.4999999999999998e-14 < lambda2 Initial program 57.6%
associate-*l*57.6%
Simplified57.6%
Taylor expanded in lambda1 around 0 57.6%
cos-neg56.1%
associate-*r*56.1%
Simplified57.6%
if -4.2e12 < lambda2 < 4.4999999999999998e-14Initial program 96.9%
associate-*l*96.9%
Simplified96.9%
Taylor expanded in lambda2 around 0 96.9%
Final simplification76.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= lambda1 -8e+56)
(atan2
(* (cos phi2) (sin (+ lambda1 lambda2)))
(- t_0 (* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
(if (<= lambda1 5.2e-29)
(atan2 t_1 (- t_0 (* (sin phi1) (* (cos lambda2) (cos phi2)))))
(atan2 t_1 (- t_0 (* (sin phi1) (* (cos lambda1) (cos phi2)))))))))
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 (lambda1 <= -8e+56) {
tmp = atan2((cos(phi2) * sin((lambda1 + lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
} else if (lambda1 <= 5.2e-29) {
tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2)))));
} else {
tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))));
}
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 (lambda1 <= (-8d+56)) then
tmp = atan2((cos(phi2) * sin((lambda1 + lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))))
else if (lambda1 <= 5.2d-29) then
tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2)))))
else
tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (lambda1 <= -8e+56) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 + lambda2))), (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))))));
} else if (lambda1 <= 5.2e-29) {
tmp = Math.atan2(t_1, (t_0 - (Math.sin(phi1) * (Math.cos(lambda2) * Math.cos(phi2)))));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.sin(phi1) * (Math.cos(lambda1) * Math.cos(phi2)))));
}
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 lambda1 <= -8e+56: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 + lambda2))), (t_0 - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2)))))) elif lambda1 <= 5.2e-29: tmp = math.atan2(t_1, (t_0 - (math.sin(phi1) * (math.cos(lambda2) * math.cos(phi2))))) else: tmp = math.atan2(t_1, (t_0 - (math.sin(phi1) * (math.cos(lambda1) * math.cos(phi2))))) 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 (lambda1 <= -8e+56) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 + lambda2))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); elseif (lambda1 <= 5.2e-29) tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * Float64(cos(lambda2) * cos(phi2))))); else tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * Float64(cos(lambda1) * cos(phi2))))); 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 (lambda1 <= -8e+56) tmp = atan2((cos(phi2) * sin((lambda1 + lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2)))))); elseif (lambda1 <= 5.2e-29) tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2))))); else tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -8e+56], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 + lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 5.2e-29], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $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_1 \leq -8 \cdot 10^{+56}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 + \lambda_2\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{elif}\;\lambda_1 \leq 5.2 \cdot 10^{-29}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \sin \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \phi_2\right)}\\
\end{array}
\end{array}
if lambda1 < -8.00000000000000074e56Initial program 44.7%
associate-*l*44.7%
Simplified44.7%
sin-diff77.7%
sub-neg77.7%
Applied egg-rr77.7%
fma-def77.7%
*-commutative77.7%
distribute-lft-neg-out77.7%
Simplified77.7%
add-sqr-sqrt27.6%
sqrt-unprod58.9%
sqr-neg58.9%
sqrt-unprod31.3%
add-sqr-sqrt49.0%
*-commutative49.0%
fma-def49.0%
sin-sum49.1%
Applied egg-rr49.1%
if -8.00000000000000074e56 < lambda1 < 5.2000000000000004e-29Initial program 96.9%
associate-*l*96.9%
Simplified96.9%
Taylor expanded in lambda1 around 0 95.8%
cos-neg74.5%
associate-*r*74.5%
Simplified95.8%
if 5.2000000000000004e-29 < lambda1 Initial program 59.6%
associate-*l*59.6%
Simplified59.6%
Taylor expanded in lambda2 around 0 59.6%
Final simplification76.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((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((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((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(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * 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[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $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 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}
\end{array}
Initial program 76.8%
associate-*l*76.8%
Simplified76.8%
Final simplification76.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi2 2.2e-19)
(atan2 t_1 (- t_0 (* (sin phi1) (cos (- lambda2 lambda1)))))
(atan2 t_1 (fma (cos phi2) (- (sin phi1)) t_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 (phi2 <= 2.2e-19) {
tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = atan2(t_1, fma(cos(phi2), -sin(phi1), t_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 (phi2 <= 2.2e-19) tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = atan(t_1, fma(cos(phi2), Float64(-sin(phi1)), t_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[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 2.2e-19], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Cos[phi2], $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision]) + t$95$0), $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}\;\phi_2 \leq 2.2 \cdot 10^{-19}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{\mathsf{fma}\left(\cos \phi_2, -\sin \phi_1, t_0\right)}\\
\end{array}
\end{array}
if phi2 < 2.1999999999999998e-19Initial program 79.8%
associate-*l*79.8%
Simplified79.8%
Taylor expanded in phi2 around 0 74.0%
sub-neg74.0%
remove-double-neg74.0%
mul-1-neg74.0%
distribute-neg-in74.0%
+-commutative74.0%
cos-neg74.0%
mul-1-neg74.0%
unsub-neg74.0%
Simplified74.0%
if 2.1999999999999998e-19 < phi2 Initial program 68.7%
sub-neg68.7%
+-commutative68.7%
distribute-rgt-neg-in68.7%
*-commutative68.7%
associate-*l*68.7%
fma-def68.6%
distribute-rgt-neg-in68.6%
*-commutative68.6%
distribute-rgt-neg-out68.6%
Simplified68.6%
Taylor expanded in lambda1 around 0 65.4%
mul-1-neg65.4%
cos-neg65.4%
*-commutative65.4%
distribute-rgt-neg-in65.4%
Simplified65.4%
Taylor expanded in lambda2 around 0 61.9%
mul-1-neg61.9%
Simplified61.9%
Final simplification70.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -0.0034) (not (<= phi2 0.68)))
(atan2 (* (cos phi2) t_1) (- t_0 (* (cos lambda1) (sin phi1))))
(atan2
(* (+ (* -0.5 (* phi2 phi2)) 1.0) t_1)
(- t_0 (* (sin phi1) (cos (- lambda2 lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.0034) || !(phi2 <= 0.68)) {
tmp = atan2((cos(phi2) * t_1), (t_0 - (cos(lambda1) * sin(phi1))));
} else {
tmp = atan2((((-0.5 * (phi2 * phi2)) + 1.0) * t_1), (t_0 - (sin(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) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin((lambda1 - lambda2))
if ((phi2 <= (-0.0034d0)) .or. (.not. (phi2 <= 0.68d0))) then
tmp = atan2((cos(phi2) * t_1), (t_0 - (cos(lambda1) * sin(phi1))))
else
tmp = atan2(((((-0.5d0) * (phi2 * phi2)) + 1.0d0) * t_1), (t_0 - (sin(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 t_1 = Math.sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.0034) || !(phi2 <= 0.68)) {
tmp = Math.atan2((Math.cos(phi2) * t_1), (t_0 - (Math.cos(lambda1) * Math.sin(phi1))));
} else {
tmp = Math.atan2((((-0.5 * (phi2 * phi2)) + 1.0) * t_1), (t_0 - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi2 <= -0.0034) or not (phi2 <= 0.68): tmp = math.atan2((math.cos(phi2) * t_1), (t_0 - (math.cos(lambda1) * math.sin(phi1)))) else: tmp = math.atan2((((-0.5 * (phi2 * phi2)) + 1.0) * t_1), (t_0 - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -0.0034) || !(phi2 <= 0.68)) tmp = atan(Float64(cos(phi2) * t_1), Float64(t_0 - Float64(cos(lambda1) * sin(phi1)))); else tmp = atan(Float64(Float64(Float64(-0.5 * Float64(phi2 * phi2)) + 1.0) * t_1), Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi2 <= -0.0034) || ~((phi2 <= 0.68))) tmp = atan2((cos(phi2) * t_1), (t_0 - (cos(lambda1) * sin(phi1)))); else tmp = atan2((((-0.5 * (phi2 * phi2)) + 1.0) * t_1), (t_0 - (sin(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]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.0034], N[Not[LessEqual[phi2, 0.68]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * 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\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.0034 \lor \neg \left(\phi_2 \leq 0.68\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_1}{t_0 - \cos \lambda_1 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(-0.5 \cdot \left(\phi_2 \cdot \phi_2\right) + 1\right) \cdot t_1}{t_0 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\end{array}
\end{array}
if phi2 < -0.00339999999999999981 or 0.680000000000000049 < phi2 Initial program 70.6%
associate-*l*70.6%
Simplified70.6%
Taylor expanded in phi2 around 0 51.0%
sub-neg51.0%
remove-double-neg51.0%
mul-1-neg51.0%
distribute-neg-in51.0%
+-commutative51.0%
cos-neg51.0%
mul-1-neg51.0%
unsub-neg51.0%
Simplified51.0%
Taylor expanded in lambda2 around 0 50.8%
cos-neg45.1%
Simplified50.8%
if -0.00339999999999999981 < phi2 < 0.680000000000000049Initial program 82.1%
associate-*l*82.1%
Simplified82.1%
Taylor expanded in phi2 around 0 81.8%
sub-neg81.8%
remove-double-neg81.8%
mul-1-neg81.8%
distribute-neg-in81.8%
+-commutative81.8%
cos-neg81.8%
mul-1-neg81.8%
unsub-neg81.8%
Simplified81.8%
Taylor expanded in phi2 around 0 81.8%
*-lft-identity53.2%
associate-*r*53.2%
distribute-rgt-out53.2%
unpow253.2%
Simplified81.8%
Final simplification67.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_1 (* (cos phi1) (sin phi2))))
(if (<= lambda1 -8e+56)
(atan2
(* (sin lambda1) (cos phi2))
(- t_1 (* (sin phi1) (cos (- lambda2 lambda1)))))
(if (<= lambda1 5.2e-29)
(atan2 t_0 (- t_1 (* (cos lambda2) (sin phi1))))
(atan2 t_0 (- t_1 (* (cos lambda1) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double t_1 = cos(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -8e+56) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - (sin(phi1) * cos((lambda2 - lambda1)))));
} else if (lambda1 <= 5.2e-29) {
tmp = atan2(t_0, (t_1 - (cos(lambda2) * sin(phi1))));
} else {
tmp = atan2(t_0, (t_1 - (cos(lambda1) * sin(phi1))));
}
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(phi2) * sin((lambda1 - lambda2))
t_1 = cos(phi1) * sin(phi2)
if (lambda1 <= (-8d+56)) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - (sin(phi1) * cos((lambda2 - lambda1)))))
else if (lambda1 <= 5.2d-29) then
tmp = atan2(t_0, (t_1 - (cos(lambda2) * sin(phi1))))
else
tmp = atan2(t_0, (t_1 - (cos(lambda1) * sin(phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (lambda1 <= -8e+56) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_1 - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else if (lambda1 <= 5.2e-29) {
tmp = Math.atan2(t_0, (t_1 - (Math.cos(lambda2) * Math.sin(phi1))));
} else {
tmp = Math.atan2(t_0, (t_1 - (Math.cos(lambda1) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) t_1 = math.cos(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -8e+56: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_1 - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) elif lambda1 <= 5.2e-29: tmp = math.atan2(t_0, (t_1 - (math.cos(lambda2) * math.sin(phi1)))) else: tmp = math.atan2(t_0, (t_1 - (math.cos(lambda1) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) t_1 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -8e+56) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_1 - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); elseif (lambda1 <= 5.2e-29) tmp = atan(t_0, Float64(t_1 - Float64(cos(lambda2) * sin(phi1)))); else tmp = atan(t_0, Float64(t_1 - Float64(cos(lambda1) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); t_1 = cos(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -8e+56) tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - (sin(phi1) * cos((lambda2 - lambda1))))); elseif (lambda1 <= 5.2e-29) tmp = atan2(t_0, (t_1 - (cos(lambda2) * sin(phi1)))); else tmp = atan2(t_0, (t_1 - (cos(lambda1) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -8e+56], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 5.2e-29], N[ArcTan[t$95$0 / N[(t$95$1 - N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(t$95$1 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -8 \cdot 10^{+56}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_1 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{elif}\;\lambda_1 \leq 5.2 \cdot 10^{-29}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{t_1 - \cos \lambda_2 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{t_1 - \cos \lambda_1 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if lambda1 < -8.00000000000000074e56Initial program 44.7%
associate-*l*44.7%
Simplified44.7%
Taylor expanded in phi2 around 0 38.9%
sub-neg38.9%
remove-double-neg38.9%
mul-1-neg38.9%
distribute-neg-in38.9%
+-commutative38.9%
cos-neg38.9%
mul-1-neg38.9%
unsub-neg38.9%
Simplified38.9%
Taylor expanded in lambda2 around 0 41.2%
if -8.00000000000000074e56 < lambda1 < 5.2000000000000004e-29Initial program 96.9%
associate-*l*96.9%
Simplified96.9%
Taylor expanded in phi2 around 0 84.5%
sub-neg84.5%
remove-double-neg84.5%
mul-1-neg84.5%
distribute-neg-in84.5%
+-commutative84.5%
cos-neg84.5%
mul-1-neg84.5%
unsub-neg84.5%
Simplified84.5%
Taylor expanded in lambda1 around 0 84.4%
if 5.2000000000000004e-29 < lambda1 Initial program 59.6%
associate-*l*59.6%
Simplified59.6%
Taylor expanded in phi2 around 0 54.1%
sub-neg54.1%
remove-double-neg54.1%
mul-1-neg54.1%
distribute-neg-in54.1%
+-commutative54.1%
cos-neg54.1%
mul-1-neg54.1%
unsub-neg54.1%
Simplified54.1%
Taylor expanded in lambda2 around 0 54.1%
cos-neg42.0%
Simplified54.1%
Final simplification67.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (sin phi1) (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(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))), ((cos(phi1) * sin(phi2)) - (sin(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.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(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[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * 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)}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 76.8%
associate-*l*76.8%
Simplified76.8%
Taylor expanded in phi2 around 0 67.5%
sub-neg67.5%
remove-double-neg67.5%
mul-1-neg67.5%
distribute-neg-in67.5%
+-commutative67.5%
cos-neg67.5%
mul-1-neg67.5%
unsub-neg67.5%
Simplified67.5%
Final simplification67.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))) (t_1 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -0.48) (not (<= phi2 0.68)))
(atan2
(* (cos phi2) t_1)
(- (+ (sin phi2) (* -0.5 (* (sin phi2) (* phi1 phi1)))) (* phi1 t_0)))
(atan2
(* (+ (* -0.5 (* phi2 phi2)) 1.0) t_1)
(- (* (cos phi1) (sin phi2)) (* (sin phi1) t_0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double t_1 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.48) || !(phi2 <= 0.68)) {
tmp = atan2((cos(phi2) * t_1), ((sin(phi2) + (-0.5 * (sin(phi2) * (phi1 * phi1)))) - (phi1 * t_0)));
} else {
tmp = atan2((((-0.5 * (phi2 * phi2)) + 1.0) * t_1), ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_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((lambda2 - lambda1))
t_1 = sin((lambda1 - lambda2))
if ((phi2 <= (-0.48d0)) .or. (.not. (phi2 <= 0.68d0))) then
tmp = atan2((cos(phi2) * t_1), ((sin(phi2) + ((-0.5d0) * (sin(phi2) * (phi1 * phi1)))) - (phi1 * t_0)))
else
tmp = atan2(((((-0.5d0) * (phi2 * phi2)) + 1.0d0) * t_1), ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda2 - lambda1));
double t_1 = Math.sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.48) || !(phi2 <= 0.68)) {
tmp = Math.atan2((Math.cos(phi2) * t_1), ((Math.sin(phi2) + (-0.5 * (Math.sin(phi2) * (phi1 * phi1)))) - (phi1 * t_0)));
} else {
tmp = Math.atan2((((-0.5 * (phi2 * phi2)) + 1.0) * t_1), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * t_0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) t_1 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi2 <= -0.48) or not (phi2 <= 0.68): tmp = math.atan2((math.cos(phi2) * t_1), ((math.sin(phi2) + (-0.5 * (math.sin(phi2) * (phi1 * phi1)))) - (phi1 * t_0))) else: tmp = math.atan2((((-0.5 * (phi2 * phi2)) + 1.0) * t_1), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * t_0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -0.48) || !(phi2 <= 0.68)) tmp = atan(Float64(cos(phi2) * t_1), Float64(Float64(sin(phi2) + Float64(-0.5 * Float64(sin(phi2) * Float64(phi1 * phi1)))) - Float64(phi1 * t_0))); else tmp = atan(Float64(Float64(Float64(-0.5 * Float64(phi2 * phi2)) + 1.0) * t_1), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda2 - lambda1)); t_1 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi2 <= -0.48) || ~((phi2 <= 0.68))) tmp = atan2((cos(phi2) * t_1), ((sin(phi2) + (-0.5 * (sin(phi2) * (phi1 * phi1)))) - (phi1 * t_0))); else tmp = atan2((((-0.5 * (phi2 * phi2)) + 1.0) * t_1), ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.48], N[Not[LessEqual[phi2, 0.68]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(N[(N[Sin[phi2], $MachinePrecision] + N[(-0.5 * N[(N[Sin[phi2], $MachinePrecision] * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(phi1 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.48 \lor \neg \left(\phi_2 \leq 0.68\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_1}{\left(\sin \phi_2 + -0.5 \cdot \left(\sin \phi_2 \cdot \left(\phi_1 \cdot \phi_1\right)\right)\right) - \phi_1 \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(-0.5 \cdot \left(\phi_2 \cdot \phi_2\right) + 1\right) \cdot t_1}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot t_0}\\
\end{array}
\end{array}
if phi2 < -0.47999999999999998 or 0.680000000000000049 < phi2 Initial program 70.6%
associate-*l*70.6%
Simplified70.6%
Taylor expanded in phi2 around 0 51.0%
sub-neg51.0%
remove-double-neg51.0%
mul-1-neg51.0%
distribute-neg-in51.0%
+-commutative51.0%
cos-neg51.0%
mul-1-neg51.0%
unsub-neg51.0%
Simplified51.0%
Taylor expanded in phi1 around 0 44.8%
Taylor expanded in phi1 around 0 47.0%
*-commutative47.0%
unpow247.0%
Simplified47.0%
if -0.47999999999999998 < phi2 < 0.680000000000000049Initial program 82.1%
associate-*l*82.1%
Simplified82.1%
Taylor expanded in phi2 around 0 81.8%
sub-neg81.8%
remove-double-neg81.8%
mul-1-neg81.8%
distribute-neg-in81.8%
+-commutative81.8%
cos-neg81.8%
mul-1-neg81.8%
unsub-neg81.8%
Simplified81.8%
Taylor expanded in phi2 around 0 81.8%
*-lft-identity53.2%
associate-*r*53.2%
distribute-rgt-out53.2%
unpow253.2%
Simplified81.8%
Final simplification65.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi1 -125.0)
(atan2
t_1
(- (+ (sin phi2) (* -0.5 (* (sin phi2) (* phi1 phi1)))) (* phi1 t_0)))
(atan2 t_1 (- (sin phi2) (* phi1 (fabs t_0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -125.0) {
tmp = atan2(t_1, ((sin(phi2) + (-0.5 * (sin(phi2) * (phi1 * phi1)))) - (phi1 * t_0)));
} else {
tmp = atan2(t_1, (sin(phi2) - (phi1 * fabs(t_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((lambda2 - lambda1))
t_1 = cos(phi2) * sin((lambda1 - lambda2))
if (phi1 <= (-125.0d0)) then
tmp = atan2(t_1, ((sin(phi2) + ((-0.5d0) * (sin(phi2) * (phi1 * phi1)))) - (phi1 * t_0)))
else
tmp = atan2(t_1, (sin(phi2) - (phi1 * abs(t_0))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda2 - lambda1));
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -125.0) {
tmp = Math.atan2(t_1, ((Math.sin(phi2) + (-0.5 * (Math.sin(phi2) * (phi1 * phi1)))) - (phi1 * t_0)));
} else {
tmp = Math.atan2(t_1, (Math.sin(phi2) - (phi1 * Math.abs(t_0))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -125.0: tmp = math.atan2(t_1, ((math.sin(phi2) + (-0.5 * (math.sin(phi2) * (phi1 * phi1)))) - (phi1 * t_0))) else: tmp = math.atan2(t_1, (math.sin(phi2) - (phi1 * math.fabs(t_0)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -125.0) tmp = atan(t_1, Float64(Float64(sin(phi2) + Float64(-0.5 * Float64(sin(phi2) * Float64(phi1 * phi1)))) - Float64(phi1 * t_0))); else tmp = atan(t_1, Float64(sin(phi2) - Float64(phi1 * abs(t_0)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda2 - lambda1)); t_1 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -125.0) tmp = atan2(t_1, ((sin(phi2) + (-0.5 * (sin(phi2) * (phi1 * phi1)))) - (phi1 * t_0))); else tmp = atan2(t_1, (sin(phi2) - (phi1 * abs(t_0)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -125.0], N[ArcTan[t$95$1 / N[(N[(N[Sin[phi2], $MachinePrecision] + N[(-0.5 * N[(N[Sin[phi2], $MachinePrecision] * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(phi1 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Abs[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -125:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{\left(\sin \phi_2 + -0.5 \cdot \left(\sin \phi_2 \cdot \left(\phi_1 \cdot \phi_1\right)\right)\right) - \phi_1 \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{\sin \phi_2 - \phi_1 \cdot \left|t_0\right|}\\
\end{array}
\end{array}
if phi1 < -125Initial program 72.5%
associate-*l*72.5%
Simplified72.5%
Taylor expanded in phi2 around 0 55.2%
sub-neg55.2%
remove-double-neg55.2%
mul-1-neg55.2%
distribute-neg-in55.2%
+-commutative55.2%
cos-neg55.2%
mul-1-neg55.2%
unsub-neg55.2%
Simplified55.2%
Taylor expanded in phi1 around 0 8.6%
Taylor expanded in phi1 around 0 17.7%
*-commutative17.7%
unpow217.7%
Simplified17.7%
if -125 < phi1 Initial program 78.0%
associate-*l*78.0%
Simplified78.0%
Taylor expanded in phi2 around 0 71.1%
sub-neg71.1%
remove-double-neg71.1%
mul-1-neg71.1%
distribute-neg-in71.1%
+-commutative71.1%
cos-neg71.1%
mul-1-neg71.1%
unsub-neg71.1%
Simplified71.1%
Taylor expanded in phi1 around 0 61.2%
Taylor expanded in phi1 around 0 61.2%
add-sqr-sqrt45.2%
sqrt-unprod62.3%
pow262.3%
Applied egg-rr62.3%
unpow262.3%
rem-sqrt-square62.3%
Simplified62.3%
Final simplification52.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (cos lambda1) phi1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * 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))), ((cos(phi1) * 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.cos(phi1) * Math.sin(phi2)) - (Math.cos(lambda1) * phi1)));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(lambda1) * phi1)))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(lambda1) * phi1))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * 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[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $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)}{\cos \phi_1 \cdot \sin \phi_2 - \cos \lambda_1 \cdot \phi_1}
\end{array}
Initial program 76.8%
associate-*l*76.8%
Simplified76.8%
Taylor expanded in phi2 around 0 67.5%
sub-neg67.5%
remove-double-neg67.5%
mul-1-neg67.5%
distribute-neg-in67.5%
+-commutative67.5%
cos-neg67.5%
mul-1-neg67.5%
unsub-neg67.5%
Simplified67.5%
Taylor expanded in phi1 around 0 49.3%
Taylor expanded in lambda2 around 0 49.5%
cos-neg49.5%
Simplified49.5%
Final simplification49.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- (sin phi2) (* phi1 (cos (- lambda2 lambda1))))))
(if (or (<= phi2 -1.3e+35) (not (<= phi2 3650.0)))
(atan2 (* (sin lambda1) (cos phi2)) t_0)
(atan2
(* (+ (* -0.5 (* phi2 phi2)) 1.0) (sin (- lambda1 lambda2)))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) - (phi1 * cos((lambda2 - lambda1)));
double tmp;
if ((phi2 <= -1.3e+35) || !(phi2 <= 3650.0)) {
tmp = atan2((sin(lambda1) * cos(phi2)), t_0);
} else {
tmp = atan2((((-0.5 * (phi2 * phi2)) + 1.0) * sin((lambda1 - lambda2))), t_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 = sin(phi2) - (phi1 * cos((lambda2 - lambda1)))
if ((phi2 <= (-1.3d+35)) .or. (.not. (phi2 <= 3650.0d0))) then
tmp = atan2((sin(lambda1) * cos(phi2)), t_0)
else
tmp = atan2(((((-0.5d0) * (phi2 * phi2)) + 1.0d0) * sin((lambda1 - lambda2))), t_0)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)));
double tmp;
if ((phi2 <= -1.3e+35) || !(phi2 <= 3650.0)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), t_0);
} else {
tmp = Math.atan2((((-0.5 * (phi2 * phi2)) + 1.0) * Math.sin((lambda1 - lambda2))), t_0);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1))) tmp = 0 if (phi2 <= -1.3e+35) or not (phi2 <= 3650.0): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), t_0) else: tmp = math.atan2((((-0.5 * (phi2 * phi2)) + 1.0) * math.sin((lambda1 - lambda2))), t_0) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1)))) tmp = 0.0 if ((phi2 <= -1.3e+35) || !(phi2 <= 3650.0)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), t_0); else tmp = atan(Float64(Float64(Float64(-0.5 * Float64(phi2 * phi2)) + 1.0) * sin(Float64(lambda1 - lambda2))), t_0); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi2) - (phi1 * cos((lambda2 - lambda1))); tmp = 0.0; if ((phi2 <= -1.3e+35) || ~((phi2 <= 3650.0))) tmp = atan2((sin(lambda1) * cos(phi2)), t_0); else tmp = atan2((((-0.5 * (phi2 * phi2)) + 1.0) * sin((lambda1 - lambda2))), t_0); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -1.3e+35], N[Not[LessEqual[phi2, 3650.0]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision], N[ArcTan[N[(N[(N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_2 \leq -1.3 \cdot 10^{+35} \lor \neg \left(\phi_2 \leq 3650\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(-0.5 \cdot \left(\phi_2 \cdot \phi_2\right) + 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0}\\
\end{array}
\end{array}
if phi2 < -1.30000000000000003e35 or 3650 < phi2 Initial program 70.0%
associate-*l*70.0%
Simplified70.0%
Taylor expanded in phi2 around 0 51.8%
sub-neg51.8%
remove-double-neg51.8%
mul-1-neg51.8%
distribute-neg-in51.8%
+-commutative51.8%
cos-neg51.8%
mul-1-neg51.8%
unsub-neg51.8%
Simplified51.8%
Taylor expanded in phi1 around 0 45.4%
Taylor expanded in phi1 around 0 45.4%
Taylor expanded in lambda2 around 0 30.4%
if -1.30000000000000003e35 < phi2 < 3650Initial program 81.8%
associate-*l*81.8%
Simplified81.8%
Taylor expanded in phi2 around 0 79.3%
sub-neg79.3%
remove-double-neg79.3%
mul-1-neg79.3%
distribute-neg-in79.3%
+-commutative79.3%
cos-neg79.3%
mul-1-neg79.3%
unsub-neg79.3%
Simplified79.3%
Taylor expanded in phi1 around 0 52.2%
Taylor expanded in phi1 around 0 52.2%
Taylor expanded in phi2 around 0 50.7%
*-lft-identity50.7%
associate-*r*50.7%
distribute-rgt-out50.7%
unpow250.7%
Simplified50.7%
Final simplification42.0%
(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 76.8%
associate-*l*76.8%
Simplified76.8%
Taylor expanded in phi2 around 0 67.5%
sub-neg67.5%
remove-double-neg67.5%
mul-1-neg67.5%
distribute-neg-in67.5%
+-commutative67.5%
cos-neg67.5%
mul-1-neg67.5%
unsub-neg67.5%
Simplified67.5%
Taylor expanded in phi1 around 0 49.3%
Taylor expanded in phi1 around 0 49.3%
Taylor expanded in lambda2 around 0 49.5%
cos-neg49.5%
Simplified49.5%
Final simplification49.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (+ (* -0.5 (* phi2 phi2)) 1.0) (sin (- lambda1 lambda2))) (- (sin phi2) (* phi1 (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((-0.5 * (phi2 * phi2)) + 1.0) * 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(((((-0.5d0) * (phi2 * phi2)) + 1.0d0) * 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((((-0.5 * (phi2 * phi2)) + 1.0) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((-0.5 * (phi2 * phi2)) + 1.0) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(-0.5 * Float64(phi2 * phi2)) + 1.0) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((-0.5 * (phi2 * phi2)) + 1.0) * sin((lambda1 - lambda2))), (sin(phi2) - (phi1 * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] + 1.0), $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{\left(-0.5 \cdot \left(\phi_2 \cdot \phi_2\right) + 1\right) \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 76.8%
associate-*l*76.8%
Simplified76.8%
Taylor expanded in phi2 around 0 67.5%
sub-neg67.5%
remove-double-neg67.5%
mul-1-neg67.5%
distribute-neg-in67.5%
+-commutative67.5%
cos-neg67.5%
mul-1-neg67.5%
unsub-neg67.5%
Simplified67.5%
Taylor expanded in phi1 around 0 49.3%
Taylor expanded in phi1 around 0 49.3%
Taylor expanded in phi2 around 0 33.5%
*-lft-identity33.5%
associate-*r*33.5%
distribute-rgt-out33.5%
unpow233.5%
Simplified33.5%
Final simplification33.5%
herbie shell --seed 2023272
(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))))))