
(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 24 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(sin phi1)
(*
(cos phi2)
(+ (* (cos lambda2) (cos lambda1)) (* (sin lambda1) (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * (Math.cos(phi2) * ((Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda1) * Math.sin(lambda2)))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * (math.cos(phi2) * ((math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda1) * math.sin(lambda2)))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * Float64(cos(phi2) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda1) * sin(lambda2))))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)}
\end{array}
Initial program 75.9%
associate-*l*75.9%
Simplified75.9%
sin-diff88.4%
sub-neg88.4%
Applied egg-rr88.4%
sub-neg88.4%
Simplified88.4%
cos-diff99.7%
+-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
Final simplification99.7%
(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))))
(if (<= phi2 -3.6e-6)
(atan2 (* (cos phi2) (- t_3 (expm1 (log1p t_0)))) t_2)
(if (<= phi2 3.2e-13)
(atan2
(fma (cos lambda2) (sin lambda1) (* (cos lambda1) (- (sin lambda2))))
(-
t_1
(*
(sin phi1)
(*
(cos phi2)
(+
(* (cos lambda2) (cos lambda1))
(* (sin lambda1) (sin lambda2)))))))
(atan2 (* (- t_3 t_0) (cos phi2)) 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 tmp;
if (phi2 <= -3.6e-6) {
tmp = atan2((cos(phi2) * (t_3 - expm1(log1p(t_0)))), t_2);
} else if (phi2 <= 3.2e-13) {
tmp = atan2(fma(cos(lambda2), sin(lambda1), (cos(lambda1) * -sin(lambda2))), (t_1 - (sin(phi1) * (cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))));
} else {
tmp = atan2(((t_3 - t_0) * cos(phi2)), 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)) tmp = 0.0 if (phi2 <= -3.6e-6) tmp = atan(Float64(cos(phi2) * Float64(t_3 - expm1(log1p(t_0)))), t_2); elseif (phi2 <= 3.2e-13) tmp = atan(fma(cos(lambda2), sin(lambda1), Float64(cos(lambda1) * Float64(-sin(lambda2)))), Float64(t_1 - Float64(sin(phi1) * Float64(cos(phi2) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda1) * sin(lambda2))))))); else tmp = atan(Float64(Float64(t_3 - t_0) * cos(phi2)), 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]}, If[LessEqual[phi2, -3.6e-6], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$3 - N[(Exp[N[Log[1 + t$95$0], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi2, 3.2e-13], N[ArcTan[N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(t$95$3 - t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $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\\
\mathbf{if}\;\phi_2 \leq -3.6 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(t_3 - \mathsf{expm1}\left(\mathsf{log1p}\left(t_0\right)\right)\right)}{t_2}\\
\mathbf{elif}\;\phi_2 \leq 3.2 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\cos \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \left(-\sin \lambda_2\right)\right)}{t_1 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t_3 - t_0\right) \cdot \cos \phi_2}{t_2}\\
\end{array}
\end{array}
if phi2 < -3.59999999999999984e-6Initial program 77.0%
associate-*l*77.1%
Simplified77.1%
sin-diff90.4%
sub-neg90.4%
Applied egg-rr90.4%
sub-neg90.4%
Simplified90.4%
expm1-log1p-u90.4%
Applied egg-rr90.4%
if -3.59999999999999984e-6 < phi2 < 3.2e-13Initial program 72.4%
associate-*l*72.4%
Simplified72.4%
sin-diff85.3%
sub-neg85.3%
Applied egg-rr85.3%
sub-neg85.3%
Simplified85.3%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in phi2 around 0 99.8%
*-commutative99.8%
cancel-sign-sub-inv99.8%
*-commutative99.8%
fma-udef99.9%
*-commutative99.9%
Simplified99.9%
if 3.2e-13 < phi2 Initial program 82.3%
associate-*l*82.3%
Simplified82.3%
sin-diff93.2%
sub-neg93.2%
Applied egg-rr93.2%
sub-neg93.2%
Simplified93.2%
Final simplification95.9%
(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) (cos phi2))))
(if (<= phi2 -1.65e-6)
(atan2 (* (cos phi2) (- t_3 (expm1 (log1p t_0)))) t_2)
(if (<= phi2 2e-20)
(atan2
t_4
(-
t_1
(*
(sin phi1)
(+
(* (cos lambda2) (cos lambda1))
(* (sin lambda1) (sin lambda2))))))
(atan2 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) * cos(phi2);
double tmp;
if (phi2 <= -1.65e-6) {
tmp = atan2((cos(phi2) * (t_3 - expm1(log1p(t_0)))), t_2);
} else if (phi2 <= 2e-20) {
tmp = atan2(t_4, (t_1 - (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(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) * Math.cos(phi2);
double tmp;
if (phi2 <= -1.65e-6) {
tmp = Math.atan2((Math.cos(phi2) * (t_3 - Math.expm1(Math.log1p(t_0)))), t_2);
} else if (phi2 <= 2e-20) {
tmp = Math.atan2(t_4, (t_1 - (Math.sin(phi1) * ((Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda1) * Math.sin(lambda2))))));
} else {
tmp = Math.atan2(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) * math.cos(phi2) tmp = 0 if phi2 <= -1.65e-6: tmp = math.atan2((math.cos(phi2) * (t_3 - math.expm1(math.log1p(t_0)))), t_2) elif phi2 <= 2e-20: tmp = math.atan2(t_4, (t_1 - (math.sin(phi1) * ((math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda1) * math.sin(lambda2)))))) else: tmp = math.atan2(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(Float64(t_3 - t_0) * cos(phi2)) tmp = 0.0 if (phi2 <= -1.65e-6) tmp = atan(Float64(cos(phi2) * Float64(t_3 - expm1(log1p(t_0)))), t_2); elseif (phi2 <= 2e-20) tmp = atan(t_4, Float64(t_1 - Float64(sin(phi1) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(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[(N[(t$95$3 - t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -1.65e-6], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$3 - N[(Exp[N[Log[1 + t$95$0], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi2, 2e-20], N[ArcTan[t$95$4 / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$4 / 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 := \left(t_3 - t_0\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -1.65 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(t_3 - \mathsf{expm1}\left(\mathsf{log1p}\left(t_0\right)\right)\right)}{t_2}\\
\mathbf{elif}\;\phi_2 \leq 2 \cdot 10^{-20}:\\
\;\;\;\;\tan^{-1}_* \frac{t_4}{t_1 - \sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_4}{t_2}\\
\end{array}
\end{array}
if phi2 < -1.65000000000000008e-6Initial program 77.0%
associate-*l*77.1%
Simplified77.1%
sin-diff90.4%
sub-neg90.4%
Applied egg-rr90.4%
sub-neg90.4%
Simplified90.4%
expm1-log1p-u90.4%
Applied egg-rr90.4%
if -1.65000000000000008e-6 < phi2 < 1.99999999999999989e-20Initial program 72.4%
associate-*l*72.4%
Simplified72.4%
sin-diff85.3%
sub-neg85.3%
Applied egg-rr85.3%
sub-neg85.3%
Simplified85.3%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in phi2 around 0 99.8%
if 1.99999999999999989e-20 < phi2 Initial program 82.3%
associate-*l*82.3%
Simplified82.3%
sin-diff93.2%
sub-neg93.2%
Applied egg-rr93.2%
sub-neg93.2%
Simplified93.2%
Final simplification95.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(cos phi2)
(-
(* (sin lambda1) (cos lambda2))
(expm1 (log1p (* (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)) - expm1(log1p((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.sin(lambda1) * Math.cos(lambda2)) - Math.expm1(Math.log1p((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.expm1(math.log1p((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)) - expm1(log1p(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[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(Exp[N[Log[1 + N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $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 - \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \lambda_1 \cdot \sin \lambda_2\right)\right)\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 75.9%
associate-*l*75.9%
Simplified75.9%
sin-diff88.4%
sub-neg88.4%
Applied egg-rr88.4%
sub-neg88.4%
Simplified88.4%
expm1-log1p-u88.4%
Applied egg-rr88.4%
Final simplification88.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda1 -0.00225) (not (<= lambda1 0.00018)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* (sin phi1) (* (cos lambda1) (cos phi2)))))
(atan2
(* (cos phi2) (- (* lambda1 (cos lambda2)) (sin lambda2)))
(-
t_0
(*
(sin phi1)
(* (cos phi2) (+ (cos lambda2) (* lambda1 (sin lambda2))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda1 <= -0.00225) || !(lambda1 <= 0.00018)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))));
} else {
tmp = atan2((cos(phi2) * ((lambda1 * cos(lambda2)) - sin(lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * (cos(lambda2) + (lambda1 * sin(lambda2)))))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda1 <= (-0.00225d0)) .or. (.not. (lambda1 <= 0.00018d0))) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))))
else
tmp = atan2((cos(phi2) * ((lambda1 * cos(lambda2)) - sin(lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * (cos(lambda2) + (lambda1 * sin(lambda2)))))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda1 <= -0.00225) || !(lambda1 <= 0.00018)) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (Math.sin(phi1) * (Math.cos(lambda1) * Math.cos(phi2)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * ((lambda1 * Math.cos(lambda2)) - Math.sin(lambda2))), (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * (Math.cos(lambda2) + (lambda1 * Math.sin(lambda2)))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda1 <= -0.00225) or not (lambda1 <= 0.00018): tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (math.sin(phi1) * (math.cos(lambda1) * math.cos(phi2))))) else: tmp = math.atan2((math.cos(phi2) * ((lambda1 * math.cos(lambda2)) - math.sin(lambda2))), (t_0 - (math.sin(phi1) * (math.cos(phi2) * (math.cos(lambda2) + (lambda1 * math.sin(lambda2))))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda1 <= -0.00225) || !(lambda1 <= 0.00018)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(sin(phi1) * Float64(cos(lambda1) * cos(phi2))))); else tmp = atan(Float64(cos(phi2) * Float64(Float64(lambda1 * cos(lambda2)) - sin(lambda2))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * Float64(cos(lambda2) + Float64(lambda1 * sin(lambda2))))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda1 <= -0.00225) || ~((lambda1 <= 0.00018))) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2))))); else tmp = atan2((cos(phi2) * ((lambda1 * cos(lambda2)) - sin(lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * (cos(lambda2) + (lambda1 * sin(lambda2))))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -0.00225], N[Not[LessEqual[lambda1, 0.00018]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(lambda1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] + N[(lambda1 * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -0.00225 \lor \neg \left(\lambda_1 \leq 0.00018\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \sin \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \lambda_2 + \lambda_1 \cdot \sin \lambda_2\right)\right)}\\
\end{array}
\end{array}
if lambda1 < -0.00224999999999999983 or 1.80000000000000011e-4 < lambda1 Initial program 55.5%
associate-*l*55.5%
Simplified55.5%
sin-diff79.0%
sub-neg79.0%
Applied egg-rr79.0%
sub-neg79.0%
Simplified79.0%
Taylor expanded in lambda2 around 0 78.6%
if -0.00224999999999999983 < lambda1 < 1.80000000000000011e-4Initial program 98.9%
associate-*l*98.9%
Simplified98.9%
Taylor expanded in lambda1 around 0 99.1%
sin-neg99.1%
cos-neg99.1%
*-commutative99.1%
Simplified99.1%
Taylor expanded in lambda1 around 0 99.6%
cos-neg99.6%
+-commutative99.6%
mul-1-neg99.6%
sin-neg99.6%
Simplified99.6%
Final simplification88.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[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{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}
\end{array}
Initial program 75.9%
associate-*l*75.9%
Simplified75.9%
sin-diff88.4%
sub-neg88.4%
Applied egg-rr88.4%
sub-neg88.4%
Simplified88.4%
Final simplification88.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi1 -1.85e-8)
(atan2 t_2 (- t_0 (* (sin phi1) (* (cos phi2) t_1))))
(if (<= phi1 2.8e-8)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* phi1 t_1)))
(atan2
t_2
(- t_0 (expm1 (log1p (* t_1 (* (cos phi2) (sin phi1)))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.85e-8) {
tmp = atan2(t_2, (t_0 - (sin(phi1) * (cos(phi2) * t_1))));
} else if (phi1 <= 2.8e-8) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (phi1 * t_1)));
} else {
tmp = atan2(t_2, (t_0 - expm1(log1p((t_1 * (cos(phi2) * sin(phi1)))))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.85e-8) {
tmp = Math.atan2(t_2, (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * t_1))));
} else if (phi1 <= 2.8e-8) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (phi1 * t_1)));
} else {
tmp = Math.atan2(t_2, (t_0 - Math.expm1(Math.log1p((t_1 * (Math.cos(phi2) * Math.sin(phi1)))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -1.85e-8: tmp = math.atan2(t_2, (t_0 - (math.sin(phi1) * (math.cos(phi2) * t_1)))) elif phi1 <= 2.8e-8: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (phi1 * t_1))) else: tmp = math.atan2(t_2, (t_0 - math.expm1(math.log1p((t_1 * (math.cos(phi2) * math.sin(phi1))))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -1.85e-8) tmp = atan(t_2, Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * t_1)))); elseif (phi1 <= 2.8e-8) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(phi1 * t_1))); else tmp = atan(t_2, Float64(t_0 - expm1(log1p(Float64(t_1 * Float64(cos(phi2) * sin(phi1))))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.85e-8], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 2.8e-8], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(phi1 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$0 - N[(Exp[N[Log[1 + N[(t$95$1 * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.85 \cdot 10^{-8}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 2.8 \cdot 10^{-8}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \phi_1 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \mathsf{expm1}\left(\mathsf{log1p}\left(t_1 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)\right)\right)}\\
\end{array}
\end{array}
if phi1 < -1.85e-8Initial program 74.9%
associate-*l*74.9%
Simplified74.9%
if -1.85e-8 < phi1 < 2.7999999999999999e-8Initial program 76.1%
associate-*l*76.1%
Simplified76.1%
Taylor expanded in phi2 around 0 76.1%
Taylor expanded in phi1 around 0 76.1%
sin-diff99.9%
sub-neg99.9%
Applied egg-rr99.9%
sub-neg99.9%
Simplified99.9%
if 2.7999999999999999e-8 < phi1 Initial program 76.6%
associate-*l*76.6%
Simplified76.6%
expm1-log1p-u76.6%
associate-*r*76.6%
*-commutative76.6%
Applied egg-rr76.6%
Final simplification87.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* t_1 (* (cos phi2) (sin phi1))))
(t_3 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi1 -1.3e-9)
(atan2 t_3 (- t_0 (log1p (expm1 t_2))))
(if (<= phi1 6.5e-12)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* phi1 t_1)))
(atan2 t_3 (- t_0 (expm1 (log1p t_2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = t_1 * (cos(phi2) * sin(phi1));
double t_3 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.3e-9) {
tmp = atan2(t_3, (t_0 - log1p(expm1(t_2))));
} else if (phi1 <= 6.5e-12) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (phi1 * t_1)));
} else {
tmp = atan2(t_3, (t_0 - expm1(log1p(t_2))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = t_1 * (Math.cos(phi2) * Math.sin(phi1));
double t_3 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.3e-9) {
tmp = Math.atan2(t_3, (t_0 - Math.log1p(Math.expm1(t_2))));
} else if (phi1 <= 6.5e-12) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (phi1 * t_1)));
} else {
tmp = Math.atan2(t_3, (t_0 - Math.expm1(Math.log1p(t_2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = t_1 * (math.cos(phi2) * math.sin(phi1)) t_3 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -1.3e-9: tmp = math.atan2(t_3, (t_0 - math.log1p(math.expm1(t_2)))) elif phi1 <= 6.5e-12: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (phi1 * t_1))) else: tmp = math.atan2(t_3, (t_0 - math.expm1(math.log1p(t_2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(t_1 * Float64(cos(phi2) * sin(phi1))) t_3 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -1.3e-9) tmp = atan(t_3, Float64(t_0 - log1p(expm1(t_2)))); elseif (phi1 <= 6.5e-12) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(phi1 * t_1))); else tmp = atan(t_3, Float64(t_0 - expm1(log1p(t_2)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.3e-9], N[ArcTan[t$95$3 / N[(t$95$0 - N[Log[1 + N[(Exp[t$95$2] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 6.5e-12], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(phi1 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$3 / N[(t$95$0 - N[(Exp[N[Log[1 + t$95$2], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := t_1 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)\\
t_3 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.3 \cdot 10^{-9}:\\
\;\;\;\;\tan^{-1}_* \frac{t_3}{t_0 - \mathsf{log1p}\left(\mathsf{expm1}\left(t_2\right)\right)}\\
\mathbf{elif}\;\phi_1 \leq 6.5 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \phi_1 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_3}{t_0 - \mathsf{expm1}\left(\mathsf{log1p}\left(t_2\right)\right)}\\
\end{array}
\end{array}
if phi1 < -1.3000000000000001e-9Initial program 74.9%
associate-*l*74.9%
Simplified74.9%
log1p-expm1-u74.9%
associate-*r*74.9%
*-commutative74.9%
Applied egg-rr74.9%
if -1.3000000000000001e-9 < phi1 < 6.5000000000000002e-12Initial program 76.1%
associate-*l*76.1%
Simplified76.1%
Taylor expanded in phi2 around 0 76.1%
Taylor expanded in phi1 around 0 76.1%
sin-diff99.9%
sub-neg99.9%
Applied egg-rr99.9%
sub-neg99.9%
Simplified99.9%
if 6.5000000000000002e-12 < phi1 Initial program 76.6%
associate-*l*76.6%
Simplified76.6%
expm1-log1p-u76.6%
associate-*r*76.6%
*-commutative76.6%
Applied egg-rr76.6%
Final simplification87.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2 (* (cos (- lambda1 lambda2)) t_1))
(t_3 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi1 -3.6e-16)
(atan2 t_3 (- t_0 (log1p (expm1 t_2))))
(if (<= phi1 0.0004)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 t_1))
(atan2 t_3 (- t_0 (expm1 (log1p t_2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double t_2 = cos((lambda1 - lambda2)) * t_1;
double t_3 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -3.6e-16) {
tmp = atan2(t_3, (t_0 - log1p(expm1(t_2))));
} else if (phi1 <= 0.0004) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - t_1));
} else {
tmp = atan2(t_3, (t_0 - expm1(log1p(t_2))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double t_2 = Math.cos((lambda1 - lambda2)) * t_1;
double t_3 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -3.6e-16) {
tmp = Math.atan2(t_3, (t_0 - Math.log1p(Math.expm1(t_2))));
} else if (phi1 <= 0.0004) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - t_1));
} else {
tmp = Math.atan2(t_3, (t_0 - Math.expm1(Math.log1p(t_2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) t_2 = math.cos((lambda1 - lambda2)) * t_1 t_3 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -3.6e-16: tmp = math.atan2(t_3, (t_0 - math.log1p(math.expm1(t_2)))) elif phi1 <= 0.0004: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - t_1)) else: tmp = math.atan2(t_3, (t_0 - math.expm1(math.log1p(t_2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = Float64(cos(Float64(lambda1 - lambda2)) * t_1) t_3 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -3.6e-16) tmp = atan(t_3, Float64(t_0 - log1p(expm1(t_2)))); elseif (phi1 <= 0.0004) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - t_1)); else tmp = atan(t_3, Float64(t_0 - expm1(log1p(t_2)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -3.6e-16], N[ArcTan[t$95$3 / N[(t$95$0 - N[Log[1 + N[(Exp[t$95$2] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 0.0004], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - t$95$1), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$3 / N[(t$95$0 - N[(Exp[N[Log[1 + t$95$2], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right) \cdot t_1\\
t_3 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -3.6 \cdot 10^{-16}:\\
\;\;\;\;\tan^{-1}_* \frac{t_3}{t_0 - \mathsf{log1p}\left(\mathsf{expm1}\left(t_2\right)\right)}\\
\mathbf{elif}\;\phi_1 \leq 0.0004:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_3}{t_0 - \mathsf{expm1}\left(\mathsf{log1p}\left(t_2\right)\right)}\\
\end{array}
\end{array}
if phi1 < -3.59999999999999983e-16Initial program 75.6%
associate-*l*75.6%
Simplified75.6%
log1p-expm1-u75.6%
associate-*r*75.6%
*-commutative75.6%
Applied egg-rr75.6%
if -3.59999999999999983e-16 < phi1 < 4.00000000000000019e-4Initial program 75.4%
associate-*l*75.4%
Simplified75.4%
sin-diff99.3%
sub-neg99.3%
Applied egg-rr99.3%
sub-neg99.3%
Simplified99.3%
Taylor expanded in lambda1 around 0 99.3%
cos-neg99.3%
Simplified99.3%
Taylor expanded in lambda2 around 0 99.4%
if 4.00000000000000019e-4 < phi1 Initial program 77.3%
associate-*l*77.3%
Simplified77.3%
expm1-log1p-u77.3%
associate-*r*77.3%
*-commutative77.3%
Applied egg-rr77.3%
Final simplification87.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2 (cos (- lambda1 lambda2)))
(t_3 (* (sin lambda1) (cos lambda2))))
(if (<= phi1 -7e-16)
(atan2
(* (cos phi2) (- t_3 (sin lambda2)))
(- t_0 (* (sin phi1) (* (cos phi2) t_2))))
(if (<= phi1 0.0004)
(atan2
(* (- t_3 (* (cos lambda1) (sin lambda2))) (cos phi2))
(- t_0 t_1))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (expm1 (log1p (* t_2 t_1)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double t_2 = cos((lambda1 - lambda2));
double t_3 = sin(lambda1) * cos(lambda2);
double tmp;
if (phi1 <= -7e-16) {
tmp = atan2((cos(phi2) * (t_3 - sin(lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * t_2))));
} else if (phi1 <= 0.0004) {
tmp = atan2(((t_3 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - t_1));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - expm1(log1p((t_2 * t_1)))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double t_2 = Math.cos((lambda1 - lambda2));
double t_3 = Math.sin(lambda1) * Math.cos(lambda2);
double tmp;
if (phi1 <= -7e-16) {
tmp = Math.atan2((Math.cos(phi2) * (t_3 - Math.sin(lambda2))), (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * t_2))));
} else if (phi1 <= 0.0004) {
tmp = Math.atan2(((t_3 - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - t_1));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - Math.expm1(Math.log1p((t_2 * t_1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) t_2 = math.cos((lambda1 - lambda2)) t_3 = math.sin(lambda1) * math.cos(lambda2) tmp = 0 if phi1 <= -7e-16: tmp = math.atan2((math.cos(phi2) * (t_3 - math.sin(lambda2))), (t_0 - (math.sin(phi1) * (math.cos(phi2) * t_2)))) elif phi1 <= 0.0004: tmp = math.atan2(((t_3 - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - t_1)) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - math.expm1(math.log1p((t_2 * t_1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = cos(Float64(lambda1 - lambda2)) t_3 = Float64(sin(lambda1) * cos(lambda2)) tmp = 0.0 if (phi1 <= -7e-16) tmp = atan(Float64(cos(phi2) * Float64(t_3 - sin(lambda2))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * t_2)))); elseif (phi1 <= 0.0004) tmp = atan(Float64(Float64(t_3 - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - t_1)); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - expm1(log1p(Float64(t_2 * t_1))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -7e-16], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$3 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 0.0004], N[ArcTan[N[(N[(t$95$3 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - t$95$1), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(Exp[N[Log[1 + N[(t$95$2 * t$95$1), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_3 := \sin \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -7 \cdot 10^{-16}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(t_3 - \sin \lambda_2\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_2\right)}\\
\mathbf{elif}\;\phi_1 \leq 0.0004:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t_3 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \mathsf{expm1}\left(\mathsf{log1p}\left(t_2 \cdot t_1\right)\right)}\\
\end{array}
\end{array}
if phi1 < -7.00000000000000035e-16Initial program 75.6%
associate-*l*75.6%
Simplified75.6%
sin-diff77.8%
sub-neg77.8%
Applied egg-rr77.8%
sub-neg77.8%
Simplified77.8%
Taylor expanded in lambda1 around 0 76.2%
if -7.00000000000000035e-16 < phi1 < 4.00000000000000019e-4Initial program 75.4%
associate-*l*75.4%
Simplified75.4%
sin-diff99.3%
sub-neg99.3%
Applied egg-rr99.3%
sub-neg99.3%
Simplified99.3%
Taylor expanded in lambda1 around 0 99.3%
cos-neg99.3%
Simplified99.3%
Taylor expanded in lambda2 around 0 99.4%
if 4.00000000000000019e-4 < phi1 Initial program 77.3%
associate-*l*77.3%
Simplified77.3%
expm1-log1p-u77.3%
associate-*r*77.3%
*-commutative77.3%
Applied egg-rr77.3%
Final simplification87.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -3e-8) (not (<= phi1 2.95e-12)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) (* (cos phi2) t_1))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* phi1 t_1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -3e-8) || !(phi1 <= 2.95e-12)) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * t_1))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (phi1 * t_1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
if ((phi1 <= (-3d-8)) .or. (.not. (phi1 <= 2.95d-12))) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * t_1))))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (phi1 * t_1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -3e-8) || !(phi1 <= 2.95e-12)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * t_1))));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (phi1 * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) tmp = 0 if (phi1 <= -3e-8) or not (phi1 <= 2.95e-12): tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * (math.cos(phi2) * t_1)))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (phi1 * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -3e-8) || !(phi1 <= 2.95e-12)) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * t_1)))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(phi1 * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -3e-8) || ~((phi1 <= 2.95e-12))) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * t_1)))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (phi1 * t_1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -3e-8], N[Not[LessEqual[phi1, 2.95e-12]], $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] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(phi1 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -3 \cdot 10^{-8} \lor \neg \left(\phi_1 \leq 2.95 \cdot 10^{-12}\right):\\
\;\;\;\;\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 t_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \phi_1 \cdot t_1}\\
\end{array}
\end{array}
if phi1 < -2.99999999999999973e-8 or 2.95e-12 < phi1 Initial program 75.6%
associate-*l*75.6%
Simplified75.6%
if -2.99999999999999973e-8 < phi1 < 2.95e-12Initial program 76.1%
associate-*l*76.1%
Simplified76.1%
Taylor expanded in phi2 around 0 76.1%
Taylor expanded in phi1 around 0 76.1%
sin-diff99.9%
sub-neg99.9%
Applied egg-rr99.9%
sub-neg99.9%
Simplified99.9%
Final simplification87.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (or (<= lambda1 -1050000000.0) (not (<= lambda1 1.65e-35)))
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* (sin phi1) (* (cos phi2) t_1))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) t_1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if ((lambda1 <= -1050000000.0) || !(lambda1 <= 1.65e-35)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (sin(phi1) * (cos(phi2) * t_1))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * t_1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
if ((lambda1 <= (-1050000000.0d0)) .or. (.not. (lambda1 <= 1.65d-35))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (sin(phi1) * (cos(phi2) * t_1))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * t_1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double tmp;
if ((lambda1 <= -1050000000.0) || !(lambda1 <= 1.65e-35)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * t_1))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) tmp = 0 if (lambda1 <= -1050000000.0) or not (lambda1 <= 1.65e-35): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - (math.sin(phi1) * (math.cos(phi2) * t_1)))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((lambda1 <= -1050000000.0) || !(lambda1 <= 1.65e-35)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * t_1)))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); tmp = 0.0; if ((lambda1 <= -1050000000.0) || ~((lambda1 <= 1.65e-35))) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (sin(phi1) * (cos(phi2) * t_1)))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * t_1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda1, -1050000000.0], N[Not[LessEqual[lambda1, 1.65e-35]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $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] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -1050000000 \lor \neg \left(\lambda_1 \leq 1.65 \cdot 10^{-35}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \sin \phi_1 \cdot t_1}\\
\end{array}
\end{array}
if lambda1 < -1.05e9 or 1.65e-35 < lambda1 Initial program 56.5%
associate-*l*56.5%
Simplified56.5%
Taylor expanded in lambda2 around 0 57.3%
if -1.05e9 < lambda1 < 1.65e-35Initial program 98.9%
associate-*l*98.9%
Simplified98.9%
Taylor expanded in phi2 around 0 84.6%
Final simplification69.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -0.23) (not (<= lambda2 8e-7)))
(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.23) || !(lambda2 <= 8e-7)) {
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.23d0)) .or. (.not. (lambda2 <= 8d-7))) 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.23) || !(lambda2 <= 8e-7)) {
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.23) or not (lambda2 <= 8e-7): 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.23) || !(lambda2 <= 8e-7)) tmp = atan(Float64(cos(phi2) * Float64(-sin(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.23) || ~((lambda2 <= 8e-7))) 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.23], N[Not[LessEqual[lambda2, 8e-7]], $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.23 \lor \neg \left(\lambda_2 \leq 8 \cdot 10^{-7}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(-\sin \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.23000000000000001 or 7.9999999999999996e-7 < lambda2 Initial program 54.8%
associate-*l*54.8%
Simplified54.8%
sin-diff78.8%
sub-neg78.8%
Applied egg-rr78.8%
sub-neg78.8%
Simplified78.8%
Taylor expanded in lambda1 around 0 78.4%
cos-neg78.4%
Simplified78.4%
Taylor expanded in lambda1 around 0 54.0%
mul-1-neg54.0%
*-commutative54.0%
distribute-rgt-neg-in54.0%
Simplified54.0%
if -0.23000000000000001 < lambda2 < 7.9999999999999996e-7Initial program 99.0%
associate-*l*99.0%
Simplified99.0%
Taylor expanded in lambda2 around 0 98.9%
Final simplification75.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda1 -500.0) (not (<= lambda1 10500000000000.0)))
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) (* (cos lambda2) (cos phi2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda1 <= -500.0) || !(lambda1 <= 10500000000000.0)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (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) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda1 <= (-500.0d0)) .or. (.not. (lambda1 <= 10500000000000.0d0))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda1 <= -500.0) || !(lambda1 <= 10500000000000.0)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * (Math.cos(lambda2) * Math.cos(phi2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda1 <= -500.0) or not (lambda1 <= 10500000000000.0): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2)))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * (math.cos(lambda2) * math.cos(phi2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda1 <= -500.0) || !(lambda1 <= 10500000000000.0)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), 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); tmp = 0.0; if ((lambda1 <= -500.0) || ~((lambda1 <= 10500000000000.0))) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2)))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -500.0], N[Not[LessEqual[lambda1, 10500000000000.0]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $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], 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[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\\
\mathbf{if}\;\lambda_1 \leq -500 \lor \neg \left(\lambda_1 \leq 10500000000000\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_0 - \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 \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \phi_2\right)}\\
\end{array}
\end{array}
if lambda1 < -500 or 1.05e13 < lambda1 Initial program 54.9%
associate-*l*54.9%
Simplified54.9%
Taylor expanded in lambda2 around 0 56.9%
if -500 < lambda1 < 1.05e13Initial program 96.9%
associate-*l*96.9%
Simplified96.9%
Taylor expanded in lambda1 around 0 96.4%
cos-neg96.4%
Simplified96.4%
Final simplification76.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -1.3e+105) (not (<= lambda2 1.8e-15)))
(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 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda2 <= -1.3e+105) || !(lambda2 <= 1.8e-15)) {
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 - lambda2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda2 <= (-1.3d+105)) .or. (.not. (lambda2 <= 1.8d-15))) 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 - lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda2 <= -1.3e+105) || !(lambda2 <= 1.8e-15)) {
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 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda2 <= -1.3e+105) or not (lambda2 <= 1.8e-15): 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 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda2 <= -1.3e+105) || !(lambda2 <= 1.8e-15)) tmp = atan(Float64(cos(phi2) * Float64(-sin(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) * 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 ((lambda2 <= -1.3e+105) || ~((lambda2 <= 1.8e-15))) 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 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -1.3e+105], N[Not[LessEqual[lambda2, 1.8e-15]], $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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -1.3 \cdot 10^{+105} \lor \neg \left(\lambda_2 \leq 1.8 \cdot 10^{-15}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(-\sin \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 \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda2 < -1.3000000000000001e105 or 1.8000000000000001e-15 < lambda2 Initial program 56.9%
associate-*l*56.9%
Simplified56.9%
sin-diff79.8%
sub-neg79.8%
Applied egg-rr79.8%
sub-neg79.8%
Simplified79.8%
Taylor expanded in lambda1 around 0 78.9%
cos-neg78.9%
Simplified78.9%
Taylor expanded in lambda1 around 0 55.6%
mul-1-neg55.6%
*-commutative55.6%
distribute-rgt-neg-in55.6%
Simplified55.6%
if -1.3000000000000001e105 < lambda2 < 1.8000000000000001e-15Initial program 92.1%
associate-*l*92.1%
Simplified92.1%
Taylor expanded in phi2 around 0 76.7%
Final simplification67.0%
(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 75.9%
associate-*l*75.9%
Simplified75.9%
Final simplification75.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (or (<= (- lambda1 lambda2) -1e-6) (not (<= (- lambda1 lambda2) 1e-20)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) t_1)))
(atan2
(* (cos phi2) (- lambda1 lambda2))
(- t_0 (* (sin phi1) (* (cos phi2) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (((lambda1 - lambda2) <= -1e-6) || !((lambda1 - lambda2) <= 1e-20)) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * t_1)));
} else {
tmp = atan2((cos(phi2) * (lambda1 - lambda2)), (t_0 - (sin(phi1) * (cos(phi2) * t_1))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
if (((lambda1 - lambda2) <= (-1d-6)) .or. (.not. ((lambda1 - lambda2) <= 1d-20))) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * t_1)))
else
tmp = atan2((cos(phi2) * (lambda1 - lambda2)), (t_0 - (sin(phi1) * (cos(phi2) * t_1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double tmp;
if (((lambda1 - lambda2) <= -1e-6) || !((lambda1 - lambda2) <= 1e-20)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * (lambda1 - lambda2)), (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * t_1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) tmp = 0 if ((lambda1 - lambda2) <= -1e-6) or not ((lambda1 - lambda2) <= 1e-20): tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * t_1))) else: tmp = math.atan2((math.cos(phi2) * (lambda1 - lambda2)), (t_0 - (math.sin(phi1) * (math.cos(phi2) * t_1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((Float64(lambda1 - lambda2) <= -1e-6) || !(Float64(lambda1 - lambda2) <= 1e-20)) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * t_1))); else tmp = atan(Float64(cos(phi2) * Float64(lambda1 - lambda2)), Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * t_1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); tmp = 0.0; if (((lambda1 - lambda2) <= -1e-6) || ~(((lambda1 - lambda2) <= 1e-20))) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * t_1))); else tmp = atan2((cos(phi2) * (lambda1 - lambda2)), (t_0 - (sin(phi1) * (cos(phi2) * t_1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1e-6], N[Not[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 1e-20]], $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] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1 \cdot 10^{-6} \lor \neg \left(\lambda_1 - \lambda_2 \leq 10^{-20}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \sin \phi_1 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\lambda_1 - \lambda_2\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_1\right)}\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -9.99999999999999955e-7 or 9.99999999999999945e-21 < (-.f64 lambda1 lambda2) Initial program 68.6%
associate-*l*68.6%
Simplified68.6%
Taylor expanded in phi2 around 0 56.3%
if -9.99999999999999955e-7 < (-.f64 lambda1 lambda2) < 9.99999999999999945e-21Initial program 99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in lambda1 around 0 99.7%
sin-neg99.7%
cos-neg99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in lambda2 around 0 99.7%
*-commutative99.7%
associate-*r*99.7%
neg-mul-199.7%
distribute-rgt-out99.7%
sub-neg99.7%
Simplified99.7%
Final simplification66.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (sin (- lambda1 lambda2))))
(if (or (<= phi1 -0.00058) (not (<= phi1 1.55e+20)))
(atan2 t_1 (- t_0 (* (sin phi1) (* (cos lambda2) (cos phi2)))))
(atan2 (* (cos phi2) t_1) (- t_0 (* (cos lambda1) phi1))))))
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 ((phi1 <= -0.00058) || !(phi1 <= 1.55e+20)) {
tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2)))));
} else {
tmp = atan2((cos(phi2) * t_1), (t_0 - (cos(lambda1) * 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(phi1) * sin(phi2)
t_1 = sin((lambda1 - lambda2))
if ((phi1 <= (-0.00058d0)) .or. (.not. (phi1 <= 1.55d+20))) then
tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2)))))
else
tmp = atan2((cos(phi2) * t_1), (t_0 - (cos(lambda1) * phi1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -0.00058) || !(phi1 <= 1.55e+20)) {
tmp = Math.atan2(t_1, (t_0 - (Math.sin(phi1) * (Math.cos(lambda2) * Math.cos(phi2)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * t_1), (t_0 - (Math.cos(lambda1) * phi1)));
}
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 (phi1 <= -0.00058) or not (phi1 <= 1.55e+20): tmp = math.atan2(t_1, (t_0 - (math.sin(phi1) * (math.cos(lambda2) * math.cos(phi2))))) else: tmp = math.atan2((math.cos(phi2) * t_1), (t_0 - (math.cos(lambda1) * phi1))) 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 ((phi1 <= -0.00058) || !(phi1 <= 1.55e+20)) tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * Float64(cos(lambda2) * cos(phi2))))); else tmp = atan(Float64(cos(phi2) * t_1), Float64(t_0 - Float64(cos(lambda1) * phi1))); 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 ((phi1 <= -0.00058) || ~((phi1 <= 1.55e+20))) tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2))))); else tmp = atan2((cos(phi2) * t_1), (t_0 - (cos(lambda1) * phi1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -0.00058], N[Not[LessEqual[phi1, 1.55e+20]], $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[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * phi1), $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_1 \leq -0.00058 \lor \neg \left(\phi_1 \leq 1.55 \cdot 10^{+20}\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{\cos \phi_2 \cdot t_1}{t_0 - \cos \lambda_1 \cdot \phi_1}\\
\end{array}
\end{array}
if phi1 < -5.8e-4 or 1.55e20 < phi1 Initial program 75.0%
associate-*l*75.0%
Simplified75.0%
sin-diff77.7%
sub-neg77.7%
Applied egg-rr77.7%
sub-neg77.7%
Simplified77.7%
Taylor expanded in lambda1 around 0 57.9%
cos-neg57.9%
Simplified57.9%
add-log-exp40.4%
sin-diff37.8%
*-commutative37.8%
Applied egg-rr37.8%
Taylor expanded in phi2 around 0 40.1%
if -5.8e-4 < phi1 < 1.55e20Initial program 76.7%
associate-*l*76.7%
Simplified76.7%
Taylor expanded in phi2 around 0 75.2%
Taylor expanded in phi1 around 0 74.6%
Taylor expanded in lambda2 around 0 74.6%
Final simplification57.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda1 -1.2e+18) (not (<= lambda1 14000000000000.0)))
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* (sin phi1) (cos (- lambda1 lambda2)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (cos lambda2) (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda1 <= -1.2e+18) || !(lambda1 <= 14000000000000.0)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda2) * 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) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda1 <= (-1.2d+18)) .or. (.not. (lambda1 <= 14000000000000.0d0))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda2) * sin(phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda1 <= -1.2e+18) || !(lambda1 <= 14000000000000.0)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.cos(lambda2) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda1 <= -1.2e+18) or not (lambda1 <= 14000000000000.0): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.cos(lambda2) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda1 <= -1.2e+18) || !(lambda1 <= 14000000000000.0)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(lambda2) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda1 <= -1.2e+18) || ~((lambda1 <= 14000000000000.0))) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (sin(phi1) * cos((lambda1 - lambda2))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda2) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -1.2e+18], N[Not[LessEqual[lambda1, 14000000000000.0]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -1.2 \cdot 10^{+18} \lor \neg \left(\lambda_1 \leq 14000000000000\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_0 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \cos \lambda_2 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if lambda1 < -1.2e18 or 1.4e13 < lambda1 Initial program 54.4%
associate-*l*54.4%
Simplified54.4%
Taylor expanded in phi2 around 0 43.5%
Taylor expanded in lambda2 around 0 46.1%
if -1.2e18 < lambda1 < 1.4e13Initial program 95.7%
associate-*l*95.7%
Simplified95.7%
Taylor expanded in phi2 around 0 81.2%
Taylor expanded in lambda1 around 0 80.4%
cos-neg80.4%
*-commutative80.4%
Simplified80.4%
Final simplification63.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (sin phi1) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $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_1 - \lambda_2\right)}
\end{array}
Initial program 75.9%
associate-*l*75.9%
Simplified75.9%
Taylor expanded in phi2 around 0 63.1%
Final simplification63.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* phi1 (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (phi1 * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (phi1 * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (phi1 * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (phi1 * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(phi1 * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (phi1 * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda1 - lambda2), $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 - \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 75.9%
associate-*l*75.9%
Simplified75.9%
Taylor expanded in phi2 around 0 63.1%
Taylor expanded in phi1 around 0 45.4%
Final simplification45.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin lambda1) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* phi1 (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (phi1 * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (phi1 * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (phi1 * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin(lambda1) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (phi1 * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(lambda1) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(phi1 * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (phi1 * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 75.9%
associate-*l*75.9%
Simplified75.9%
Taylor expanded in phi2 around 0 63.1%
Taylor expanded in phi1 around 0 45.4%
Taylor expanded in lambda2 around 0 32.6%
Final simplification32.6%
(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 75.9%
associate-*l*75.9%
Simplified75.9%
Taylor expanded in phi2 around 0 63.1%
Taylor expanded in phi1 around 0 45.4%
Taylor expanded in lambda2 around 0 45.3%
Final simplification45.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin lambda1) (cos phi2)) (- (sin phi2) (* phi1 (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (Math.sin(phi2) - (phi1 * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin(lambda1) * math.cos(phi2)), (math.sin(phi2) - (phi1 * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(lambda1) * cos(phi2)), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 75.9%
associate-*l*75.9%
Simplified75.9%
Taylor expanded in phi2 around 0 63.1%
Taylor expanded in phi1 around 0 45.4%
Taylor expanded in lambda2 around 0 32.6%
Taylor expanded in phi1 around 0 32.6%
Final simplification32.6%
herbie shell --seed 2023178
(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))))))