
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 25 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (cos lambda1) (- (sin lambda2))))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (cos phi2) (sin phi1))
(+
(log (exp (* (sin lambda1) (sin lambda2))))
(* (cos lambda2) (cos lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(sin(lambda1), cos(lambda2), (cos(lambda1) * -sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * (log(exp((sin(lambda1) * sin(lambda2)))) + (cos(lambda2) * cos(lambda1))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(cos(lambda1) * Float64(-sin(lambda2)))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * Float64(log(exp(Float64(sin(lambda1) * sin(lambda2)))) + Float64(cos(lambda2) * cos(lambda1)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[Log[N[Exp[N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \cos \lambda_1 \cdot \left(-\sin \lambda_2\right)\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \left(\log \left(e^{\sin \lambda_1 \cdot \sin \lambda_2}\right) + \cos \lambda_2 \cdot \cos \lambda_1\right)}
\end{array}
Initial program 75.5%
cos-diff75.7%
+-commutative75.7%
*-commutative75.7%
Applied egg-rr75.7%
sin-diff99.8%
cancel-sign-sub-inv99.8%
fma-def99.8%
Applied egg-rr99.8%
add-log-exp99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (cos lambda1) (- (sin lambda2))))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (cos phi2) (sin phi1))
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(sin(lambda1), cos(lambda2), (cos(lambda1) * -sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(cos(lambda1) * Float64(-sin(lambda2)))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \cos \lambda_1 \cdot \left(-\sin \lambda_2\right)\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)}
\end{array}
Initial program 75.5%
cos-diff75.7%
+-commutative75.7%
*-commutative75.7%
Applied egg-rr75.7%
sin-diff99.8%
cancel-sign-sub-inv99.8%
fma-def99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(-
(* (cos phi1) (sin phi2))
(*
(* (cos phi2) (sin phi1))
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)}
\end{array}
Initial program 75.5%
sin-diff62.4%
sub-neg62.4%
Applied egg-rr88.9%
sub-neg62.4%
Simplified88.9%
cos-diff75.7%
+-commutative75.7%
*-commutative75.7%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (* (cos phi2) (sin phi1)))
(t_3 (- t_1 (* t_2 (cos (- lambda1 lambda2)))))
(t_4 (* (sin lambda1) (cos lambda2)))
(t_5 (- t_4 t_0)))
(if (<= phi2 -0.00037)
(atan2 (* (cos phi2) t_5) t_3)
(if (<= phi2 1.76e-44)
(atan2
t_5
(-
t_1
(*
t_2
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1))))))
(atan2 (* (cos phi2) (- (expm1 (log1p t_4)) t_0)) t_3)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = cos(phi2) * sin(phi1);
double t_3 = t_1 - (t_2 * cos((lambda1 - lambda2)));
double t_4 = sin(lambda1) * cos(lambda2);
double t_5 = t_4 - t_0;
double tmp;
if (phi2 <= -0.00037) {
tmp = atan2((cos(phi2) * t_5), t_3);
} else if (phi2 <= 1.76e-44) {
tmp = atan2(t_5, (t_1 - (t_2 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
} else {
tmp = atan2((cos(phi2) * (expm1(log1p(t_4)) - t_0)), t_3);
}
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 = Math.cos(phi2) * Math.sin(phi1);
double t_3 = t_1 - (t_2 * Math.cos((lambda1 - lambda2)));
double t_4 = Math.sin(lambda1) * Math.cos(lambda2);
double t_5 = t_4 - t_0;
double tmp;
if (phi2 <= -0.00037) {
tmp = Math.atan2((Math.cos(phi2) * t_5), t_3);
} else if (phi2 <= 1.76e-44) {
tmp = Math.atan2(t_5, (t_1 - (t_2 * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1))))));
} else {
tmp = Math.atan2((Math.cos(phi2) * (Math.expm1(Math.log1p(t_4)) - t_0)), t_3);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda1) * math.sin(lambda2) t_1 = math.cos(phi1) * math.sin(phi2) t_2 = math.cos(phi2) * math.sin(phi1) t_3 = t_1 - (t_2 * math.cos((lambda1 - lambda2))) t_4 = math.sin(lambda1) * math.cos(lambda2) t_5 = t_4 - t_0 tmp = 0 if phi2 <= -0.00037: tmp = math.atan2((math.cos(phi2) * t_5), t_3) elif phi2 <= 1.76e-44: tmp = math.atan2(t_5, (t_1 - (t_2 * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1)))))) else: tmp = math.atan2((math.cos(phi2) * (math.expm1(math.log1p(t_4)) - t_0)), t_3) 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(cos(phi2) * sin(phi1)) t_3 = Float64(t_1 - Float64(t_2 * cos(Float64(lambda1 - lambda2)))) t_4 = Float64(sin(lambda1) * cos(lambda2)) t_5 = Float64(t_4 - t_0) tmp = 0.0 if (phi2 <= -0.00037) tmp = atan(Float64(cos(phi2) * t_5), t_3); elseif (phi2 <= 1.76e-44) tmp = atan(t_5, Float64(t_1 - Float64(t_2 * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))))); else tmp = atan(Float64(cos(phi2) * Float64(expm1(log1p(t_4)) - t_0)), t_3); 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[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 - N[(t$95$2 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 - t$95$0), $MachinePrecision]}, If[LessEqual[phi2, -0.00037], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$5), $MachinePrecision] / t$95$3], $MachinePrecision], If[LessEqual[phi2, 1.76e-44], N[ArcTan[t$95$5 / N[(t$95$1 - N[(t$95$2 * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(Exp[N[Log[1 + t$95$4], $MachinePrecision]] - 1), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] / t$95$3], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \cos \phi_2 \cdot \sin \phi_1\\
t_3 := t_1 - t_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_4 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_5 := t_4 - t_0\\
\mathbf{if}\;\phi_2 \leq -0.00037:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_5}{t_3}\\
\mathbf{elif}\;\phi_2 \leq 1.76 \cdot 10^{-44}:\\
\;\;\;\;\tan^{-1}_* \frac{t_5}{t_1 - t_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\mathsf{expm1}\left(\mathsf{log1p}\left(t_4\right)\right) - t_0\right)}{t_3}\\
\end{array}
\end{array}
if phi2 < -3.6999999999999999e-4Initial program 69.0%
sin-diff64.7%
sub-neg64.7%
Applied egg-rr91.2%
sub-neg64.7%
Simplified91.2%
if -3.6999999999999999e-4 < phi2 < 1.75999999999999995e-44Initial program 76.7%
cos-diff77.0%
+-commutative77.0%
*-commutative77.0%
Applied egg-rr77.0%
sin-diff99.9%
cancel-sign-sub-inv99.9%
fma-def99.9%
Applied egg-rr99.9%
Taylor expanded in phi2 around 0 99.5%
+-commutative99.5%
mul-1-neg99.5%
unsub-neg99.5%
*-commutative99.5%
Simplified99.5%
if 1.75999999999999995e-44 < phi2 Initial program 81.3%
sin-diff65.0%
sub-neg65.0%
Applied egg-rr91.2%
sub-neg65.0%
Simplified91.2%
expm1-log1p-u91.2%
Applied egg-rr91.2%
Final simplification95.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(cos phi2)
(-
(expm1 (log1p (* (sin lambda1) (cos lambda2))))
(* (cos lambda1) (sin lambda2))))
(-
(* (cos phi1) (sin phi2))
(* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * (expm1(log1p((sin(lambda1) * cos(lambda2)))) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * (Math.expm1(Math.log1p((Math.sin(lambda1) * Math.cos(lambda2)))) - (Math.cos(lambda1) * Math.sin(lambda2)))), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * (math.expm1(math.log1p((math.sin(lambda1) * math.cos(lambda2)))) - (math.cos(lambda1) * math.sin(lambda2)))), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * Float64(expm1(log1p(Float64(sin(lambda1) * cos(lambda2)))) - Float64(cos(lambda1) * sin(lambda2)))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(Exp[N[Log[1 + N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \lambda_1 \cdot \cos \lambda_2\right)\right) - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 75.5%
sin-diff62.4%
sub-neg62.4%
Applied egg-rr88.9%
sub-neg62.4%
Simplified88.9%
expm1-log1p-u88.9%
Applied egg-rr88.9%
Final simplification88.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (cos phi2) (sin phi1))))
(if (or (<= lambda1 -0.000102) (not (<= lambda1 5e-5)))
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(- t_0 (* (cos lambda1) t_1)))
(atan2
(* (cos phi2) (- (* lambda1 (cos lambda2)) (sin lambda2)))
(- t_0 (* t_1 (+ (cos lambda2) (* lambda1 (sin lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double tmp;
if ((lambda1 <= -0.000102) || !(lambda1 <= 5e-5)) {
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (cos(lambda1) * t_1)));
} else {
tmp = atan2((cos(phi2) * ((lambda1 * cos(lambda2)) - sin(lambda2))), (t_0 - (t_1 * (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) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
if ((lambda1 <= (-0.000102d0)) .or. (.not. (lambda1 <= 5d-5))) then
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (cos(lambda1) * t_1)))
else
tmp = atan2((cos(phi2) * ((lambda1 * cos(lambda2)) - sin(lambda2))), (t_0 - (t_1 * (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 t_1 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if ((lambda1 <= -0.000102) || !(lambda1 <= 5e-5)) {
tmp = Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (t_0 - (Math.cos(lambda1) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * ((lambda1 * Math.cos(lambda2)) - Math.sin(lambda2))), (t_0 - (t_1 * (Math.cos(lambda2) + (lambda1 * Math.sin(lambda2))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) tmp = 0 if (lambda1 <= -0.000102) or not (lambda1 <= 5e-5): tmp = math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), (t_0 - (math.cos(lambda1) * t_1))) else: tmp = math.atan2((math.cos(phi2) * ((lambda1 * math.cos(lambda2)) - math.sin(lambda2))), (t_0 - (t_1 * (math.cos(lambda2) + (lambda1 * math.sin(lambda2)))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if ((lambda1 <= -0.000102) || !(lambda1 <= 5e-5)) tmp = atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(t_0 - Float64(cos(lambda1) * t_1))); else tmp = atan(Float64(cos(phi2) * Float64(Float64(lambda1 * cos(lambda2)) - sin(lambda2))), Float64(t_0 - Float64(t_1 * 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); t_1 = cos(phi2) * sin(phi1); tmp = 0.0; if ((lambda1 <= -0.000102) || ~((lambda1 <= 5e-5))) tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (cos(lambda1) * t_1))); else tmp = atan2((cos(phi2) * ((lambda1 * cos(lambda2)) - sin(lambda2))), (t_0 - (t_1 * (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]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -0.000102], N[Not[LessEqual[lambda1, 5e-5]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$1), $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[(t$95$1 * N[(N[Cos[lambda2], $MachinePrecision] + N[(lambda1 * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
\mathbf{if}\;\lambda_1 \leq -0.000102 \lor \neg \left(\lambda_1 \leq 5 \cdot 10^{-5}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{t_0 - \cos \lambda_1 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2\right)}{t_0 - t_1 \cdot \left(\cos \lambda_2 + \lambda_1 \cdot \sin \lambda_2\right)}\\
\end{array}
\end{array}
if lambda1 < -1.01999999999999999e-4 or 5.00000000000000024e-5 < lambda1 Initial program 54.3%
sin-diff62.0%
sub-neg62.0%
Applied egg-rr79.7%
sub-neg62.0%
Simplified79.7%
Taylor expanded in lambda2 around 0 79.9%
if -1.01999999999999999e-4 < lambda1 < 5.00000000000000024e-5Initial program 98.9%
Taylor expanded in lambda1 around 0 98.9%
+-commutative98.9%
sin-neg98.9%
unsub-neg98.9%
cos-neg98.9%
*-commutative98.9%
Simplified98.9%
Taylor expanded in lambda1 around 0 99.5%
cos-neg99.5%
+-commutative99.5%
mul-1-neg99.5%
sin-neg99.5%
Simplified99.5%
Final simplification89.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))) (- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 75.5%
sin-diff62.4%
sub-neg62.4%
Applied egg-rr88.9%
sub-neg62.4%
Simplified88.9%
Final simplification88.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -0.00035) (not (<= phi1 2.05e-14)))
(atan2
(* (cos phi2) (- (sin lambda1) t_0))
(- t_1 (* (* (cos phi2) (sin phi1)) t_2)))
(atan2
(* (cos phi2) (- (* (sin lambda1) (cos lambda2)) t_0))
(- t_1 (* phi1 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 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -0.00035) || !(phi1 <= 2.05e-14)) {
tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), (t_1 - ((cos(phi2) * sin(phi1)) * t_2)));
} else {
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - t_0)), (t_1 - (phi1 * t_2)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(lambda1) * sin(lambda2)
t_1 = cos(phi1) * sin(phi2)
t_2 = cos((lambda1 - lambda2))
if ((phi1 <= (-0.00035d0)) .or. (.not. (phi1 <= 2.05d-14))) then
tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), (t_1 - ((cos(phi2) * sin(phi1)) * t_2)))
else
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - t_0)), (t_1 - (phi1 * t_2)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(lambda1) * Math.sin(lambda2);
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double t_2 = Math.cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -0.00035) || !(phi1 <= 2.05e-14)) {
tmp = Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - t_0)), (t_1 - ((Math.cos(phi2) * Math.sin(phi1)) * t_2)));
} else {
tmp = Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - t_0)), (t_1 - (phi1 * 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 = math.cos((lambda1 - lambda2)) tmp = 0 if (phi1 <= -0.00035) or not (phi1 <= 2.05e-14): tmp = math.atan2((math.cos(phi2) * (math.sin(lambda1) - t_0)), (t_1 - ((math.cos(phi2) * math.sin(phi1)) * t_2))) else: tmp = math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - t_0)), (t_1 - (phi1 * 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 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -0.00035) || !(phi1 <= 2.05e-14)) tmp = atan(Float64(cos(phi2) * Float64(sin(lambda1) - t_0)), Float64(t_1 - Float64(Float64(cos(phi2) * sin(phi1)) * t_2))); else tmp = atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - t_0)), Float64(t_1 - Float64(phi1 * t_2))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(lambda1) * sin(lambda2); t_1 = cos(phi1) * sin(phi2); t_2 = cos((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -0.00035) || ~((phi1 <= 2.05e-14))) tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), (t_1 - ((cos(phi2) * sin(phi1)) * t_2))); else tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - t_0)), (t_1 - (phi1 * t_2))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -0.00035], N[Not[LessEqual[phi1, 2.05e-14]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(phi1 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -0.00035 \lor \neg \left(\phi_1 \leq 2.05 \cdot 10^{-14}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - t_0\right)}{t_1 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - t_0\right)}{t_1 - \phi_1 \cdot t_2}\\
\end{array}
\end{array}
if phi1 < -3.49999999999999996e-4 or 2.0500000000000001e-14 < phi1 Initial program 72.9%
sin-diff21.4%
sub-neg21.4%
Applied egg-rr76.9%
sub-neg21.4%
Simplified76.9%
Taylor expanded in lambda2 around 0 74.3%
if -3.49999999999999996e-4 < phi1 < 2.0500000000000001e-14Initial program 77.9%
Taylor expanded in phi2 around 0 77.9%
Taylor expanded in phi1 around 0 77.9%
sin-diff99.7%
sub-neg99.7%
Applied egg-rr99.7%
sub-neg99.7%
Simplified99.7%
Final simplification87.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -0.0043) (not (<= phi1 1.85e+22)))
(atan2
(* (cos phi2) (- (sin lambda1) t_0))
(- t_1 (* (* (cos phi2) (sin phi1)) t_2)))
(atan2
(* (cos phi2) (- (* (sin lambda1) (cos lambda2)) t_0))
(- t_1 (* (sin phi1) 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 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -0.0043) || !(phi1 <= 1.85e+22)) {
tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), (t_1 - ((cos(phi2) * sin(phi1)) * t_2)));
} else {
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - t_0)), (t_1 - (sin(phi1) * t_2)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(lambda1) * sin(lambda2)
t_1 = cos(phi1) * sin(phi2)
t_2 = cos((lambda1 - lambda2))
if ((phi1 <= (-0.0043d0)) .or. (.not. (phi1 <= 1.85d+22))) then
tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), (t_1 - ((cos(phi2) * sin(phi1)) * t_2)))
else
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - t_0)), (t_1 - (sin(phi1) * t_2)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(lambda1) * Math.sin(lambda2);
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double t_2 = Math.cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -0.0043) || !(phi1 <= 1.85e+22)) {
tmp = Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - t_0)), (t_1 - ((Math.cos(phi2) * Math.sin(phi1)) * t_2)));
} else {
tmp = Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - t_0)), (t_1 - (Math.sin(phi1) * 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 = math.cos((lambda1 - lambda2)) tmp = 0 if (phi1 <= -0.0043) or not (phi1 <= 1.85e+22): tmp = math.atan2((math.cos(phi2) * (math.sin(lambda1) - t_0)), (t_1 - ((math.cos(phi2) * math.sin(phi1)) * t_2))) else: tmp = math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - t_0)), (t_1 - (math.sin(phi1) * 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 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -0.0043) || !(phi1 <= 1.85e+22)) tmp = atan(Float64(cos(phi2) * Float64(sin(lambda1) - t_0)), Float64(t_1 - Float64(Float64(cos(phi2) * sin(phi1)) * t_2))); else tmp = atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - t_0)), Float64(t_1 - Float64(sin(phi1) * t_2))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(lambda1) * sin(lambda2); t_1 = cos(phi1) * sin(phi2); t_2 = cos((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -0.0043) || ~((phi1 <= 1.85e+22))) tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), (t_1 - ((cos(phi2) * sin(phi1)) * t_2))); else tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - t_0)), (t_1 - (sin(phi1) * t_2))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -0.0043], N[Not[LessEqual[phi1, 1.85e+22]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -0.0043 \lor \neg \left(\phi_1 \leq 1.85 \cdot 10^{+22}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - t_0\right)}{t_1 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - t_0\right)}{t_1 - \sin \phi_1 \cdot t_2}\\
\end{array}
\end{array}
if phi1 < -0.0043 or 1.8499999999999999e22 < phi1 Initial program 71.5%
sin-diff20.1%
sub-neg20.1%
Applied egg-rr75.8%
sub-neg20.1%
Simplified75.8%
Taylor expanded in lambda2 around 0 72.9%
if -0.0043 < phi1 < 1.8499999999999999e22Initial program 78.7%
sin-diff95.8%
sub-neg95.8%
Applied egg-rr99.2%
sub-neg95.8%
Simplified99.2%
Taylor expanded in phi2 around 0 99.2%
Final simplification87.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -0.00035) (not (<= phi1 2.05e-14)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (* (cos phi2) (sin phi1)) t_1)))
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(- 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 <= -0.00035) || !(phi1 <= 2.05e-14)) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - ((cos(phi2) * sin(phi1)) * t_1)));
} else {
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (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 <= (-0.00035d0)) .or. (.not. (phi1 <= 2.05d-14))) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - ((cos(phi2) * sin(phi1)) * t_1)))
else
tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (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 <= -0.00035) || !(phi1 <= 2.05e-14)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (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 <= -0.00035) or not (phi1 <= 2.05e-14): tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - ((math.cos(phi2) * math.sin(phi1)) * t_1))) else: tmp = math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), (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 <= -0.00035) || !(phi1 <= 2.05e-14)) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * t_1))); else tmp = atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), 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 <= -0.00035) || ~((phi1 <= 2.05e-14))) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - ((cos(phi2) * sin(phi1)) * t_1))); else tmp = atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (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, -0.00035], N[Not[LessEqual[phi1, 2.05e-14]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(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 -0.00035 \lor \neg \left(\phi_1 \leq 2.05 \cdot 10^{-14}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{t_0 - \phi_1 \cdot t_1}\\
\end{array}
\end{array}
if phi1 < -3.49999999999999996e-4 or 2.0500000000000001e-14 < phi1 Initial program 72.9%
if -3.49999999999999996e-4 < phi1 < 2.0500000000000001e-14Initial program 77.9%
Taylor expanded in phi2 around 0 77.9%
Taylor expanded in phi1 around 0 77.9%
sin-diff99.7%
sub-neg99.7%
Applied egg-rr99.7%
sub-neg99.7%
Simplified99.7%
Final simplification86.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin phi1)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_2 (* (cos phi1) (sin phi2)))
(t_3
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_2 (* (cos lambda2) t_0)))))
(if (<= lambda2 -0.0185)
t_3
(if (<= lambda2 9.5e-299)
(atan2 t_1 (- t_2 t_0))
(if (<= lambda2 2.3e+58)
(atan2 t_1 (- t_2 (* (sin phi1) (cos (- lambda1 lambda2)))))
t_3)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin(phi1);
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double t_2 = cos(phi1) * sin(phi2);
double t_3 = atan2((cos(phi2) * sin(-lambda2)), (t_2 - (cos(lambda2) * t_0)));
double tmp;
if (lambda2 <= -0.0185) {
tmp = t_3;
} else if (lambda2 <= 9.5e-299) {
tmp = atan2(t_1, (t_2 - t_0));
} else if (lambda2 <= 2.3e+58) {
tmp = atan2(t_1, (t_2 - (sin(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = t_3;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi2) * sin(phi1)
t_1 = cos(phi2) * sin((lambda1 - lambda2))
t_2 = cos(phi1) * sin(phi2)
t_3 = atan2((cos(phi2) * sin(-lambda2)), (t_2 - (cos(lambda2) * t_0)))
if (lambda2 <= (-0.0185d0)) then
tmp = t_3
else if (lambda2 <= 9.5d-299) then
tmp = atan2(t_1, (t_2 - t_0))
else if (lambda2 <= 2.3d+58) then
tmp = atan2(t_1, (t_2 - (sin(phi1) * cos((lambda1 - lambda2)))))
else
tmp = t_3
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin(phi1);
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double t_2 = Math.cos(phi1) * Math.sin(phi2);
double t_3 = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_2 - (Math.cos(lambda2) * t_0)));
double tmp;
if (lambda2 <= -0.0185) {
tmp = t_3;
} else if (lambda2 <= 9.5e-299) {
tmp = Math.atan2(t_1, (t_2 - t_0));
} else if (lambda2 <= 2.3e+58) {
tmp = Math.atan2(t_1, (t_2 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = t_3;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin(phi1) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) t_2 = math.cos(phi1) * math.sin(phi2) t_3 = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_2 - (math.cos(lambda2) * t_0))) tmp = 0 if lambda2 <= -0.0185: tmp = t_3 elif lambda2 <= 9.5e-299: tmp = math.atan2(t_1, (t_2 - t_0)) elif lambda2 <= 2.3e+58: tmp = math.atan2(t_1, (t_2 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) else: tmp = t_3 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(phi1)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) t_2 = Float64(cos(phi1) * sin(phi2)) t_3 = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_2 - Float64(cos(lambda2) * t_0))) tmp = 0.0 if (lambda2 <= -0.0185) tmp = t_3; elseif (lambda2 <= 9.5e-299) tmp = atan(t_1, Float64(t_2 - t_0)); elseif (lambda2 <= 2.3e+58) tmp = atan(t_1, Float64(t_2 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = t_3; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin(phi1); t_1 = cos(phi2) * sin((lambda1 - lambda2)); t_2 = cos(phi1) * sin(phi2); t_3 = atan2((cos(phi2) * sin(-lambda2)), (t_2 - (cos(lambda2) * t_0))); tmp = 0.0; if (lambda2 <= -0.0185) tmp = t_3; elseif (lambda2 <= 9.5e-299) tmp = atan2(t_1, (t_2 - t_0)); elseif (lambda2 <= 2.3e+58) tmp = atan2(t_1, (t_2 - (sin(phi1) * cos((lambda1 - lambda2))))); else tmp = t_3; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -0.0185], t$95$3, If[LessEqual[lambda2, 9.5e-299], N[ArcTan[t$95$1 / N[(t$95$2 - t$95$0), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 2.3e+58], N[ArcTan[t$95$1 / N[(t$95$2 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$3]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \phi_1\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_1 \cdot \sin \phi_2\\
t_3 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_2 - \cos \lambda_2 \cdot t_0}\\
\mathbf{if}\;\lambda_2 \leq -0.0185:\\
\;\;\;\;t_3\\
\mathbf{elif}\;\lambda_2 \leq 9.5 \cdot 10^{-299}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_2 - t_0}\\
\mathbf{elif}\;\lambda_2 \leq 2.3 \cdot 10^{+58}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}
\end{array}
if lambda2 < -0.0184999999999999991 or 2.30000000000000002e58 < lambda2 Initial program 55.4%
Taylor expanded in lambda1 around 0 55.5%
cos-neg15.2%
Simplified55.5%
Taylor expanded in lambda1 around 0 56.8%
if -0.0184999999999999991 < lambda2 < 9.5000000000000001e-299Initial program 98.5%
Taylor expanded in lambda1 around 0 88.3%
cos-neg54.6%
Simplified88.3%
Taylor expanded in lambda2 around 0 88.3%
if 9.5000000000000001e-299 < lambda2 < 2.30000000000000002e58Initial program 89.6%
Taylor expanded in phi2 around 0 81.0%
Final simplification71.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -0.041) (not (<= lambda2 0.0038)))
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_0 (* (cos lambda2) (* (cos phi2) (sin phi1)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (cos phi2) (* (cos lambda1) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda2 <= -0.041) || !(lambda2 <= 0.0038)) {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(lambda2) * (cos(phi2) * sin(phi1)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda2 <= (-0.041d0)) .or. (.not. (lambda2 <= 0.0038d0))) then
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(lambda2) * (cos(phi2) * sin(phi1)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda2 <= -0.041) || !(lambda2 <= 0.0038)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_0 - (Math.cos(lambda2) * (Math.cos(phi2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.cos(phi2) * (Math.cos(lambda1) * Math.sin(phi1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda2 <= -0.041) or not (lambda2 <= 0.0038): tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_0 - (math.cos(lambda2) * (math.cos(phi2) * math.sin(phi1))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.cos(phi2) * (math.cos(lambda1) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda2 <= -0.041) || !(lambda2 <= 0.0038)) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_0 - Float64(cos(lambda2) * Float64(cos(phi2) * sin(phi1))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda1) * sin(phi1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda2 <= -0.041) || ~((lambda2 <= 0.0038))) tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(lambda2) * (cos(phi2) * sin(phi1))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -0.041], N[Not[LessEqual[lambda2, 0.0038]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $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.041 \lor \neg \left(\lambda_2 \leq 0.0038\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_0 - \cos \lambda_2 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if lambda2 < -0.0410000000000000017 or 0.00379999999999999999 < lambda2 Initial program 54.5%
Taylor expanded in lambda1 around 0 54.6%
cos-neg15.4%
Simplified54.6%
Taylor expanded in lambda1 around 0 55.1%
if -0.0410000000000000017 < lambda2 < 0.00379999999999999999Initial program 98.6%
Taylor expanded in lambda2 around 0 98.6%
Final simplification75.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (- t_1 (* (cos lambda2) (* (cos phi2) (sin phi1))))))
(if (<= lambda2 -0.017)
(atan2 (* (cos phi2) (sin (- lambda2))) t_2)
(if (<= lambda2 0.12)
(atan2 t_0 (- t_1 (* (cos phi2) (* (cos lambda1) (sin phi1)))))
(atan2 t_0 t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double t_1 = cos(phi1) * sin(phi2);
double t_2 = t_1 - (cos(lambda2) * (cos(phi2) * sin(phi1)));
double tmp;
if (lambda2 <= -0.017) {
tmp = atan2((cos(phi2) * sin(-lambda2)), t_2);
} else if (lambda2 <= 0.12) {
tmp = atan2(t_0, (t_1 - (cos(phi2) * (cos(lambda1) * sin(phi1)))));
} else {
tmp = atan2(t_0, t_2);
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi2) * sin((lambda1 - lambda2))
t_1 = cos(phi1) * sin(phi2)
t_2 = t_1 - (cos(lambda2) * (cos(phi2) * sin(phi1)))
if (lambda2 <= (-0.017d0)) then
tmp = atan2((cos(phi2) * sin(-lambda2)), t_2)
else if (lambda2 <= 0.12d0) then
tmp = atan2(t_0, (t_1 - (cos(phi2) * (cos(lambda1) * sin(phi1)))))
else
tmp = atan2(t_0, t_2)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double t_2 = t_1 - (Math.cos(lambda2) * (Math.cos(phi2) * Math.sin(phi1)));
double tmp;
if (lambda2 <= -0.017) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), t_2);
} else if (lambda2 <= 0.12) {
tmp = Math.atan2(t_0, (t_1 - (Math.cos(phi2) * (Math.cos(lambda1) * Math.sin(phi1)))));
} else {
tmp = Math.atan2(t_0, t_2);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) t_1 = math.cos(phi1) * math.sin(phi2) t_2 = t_1 - (math.cos(lambda2) * (math.cos(phi2) * math.sin(phi1))) tmp = 0 if lambda2 <= -0.017: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), t_2) elif lambda2 <= 0.12: tmp = math.atan2(t_0, (t_1 - (math.cos(phi2) * (math.cos(lambda1) * math.sin(phi1))))) else: tmp = math.atan2(t_0, t_2) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = Float64(t_1 - Float64(cos(lambda2) * Float64(cos(phi2) * sin(phi1)))) tmp = 0.0 if (lambda2 <= -0.017) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), t_2); elseif (lambda2 <= 0.12) tmp = atan(t_0, Float64(t_1 - Float64(cos(phi2) * Float64(cos(lambda1) * sin(phi1))))); else tmp = atan(t_0, t_2); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); t_1 = cos(phi1) * sin(phi2); t_2 = t_1 - (cos(lambda2) * (cos(phi2) * sin(phi1))); tmp = 0.0; if (lambda2 <= -0.017) tmp = atan2((cos(phi2) * sin(-lambda2)), t_2); elseif (lambda2 <= 0.12) tmp = atan2(t_0, (t_1 - (cos(phi2) * (cos(lambda1) * sin(phi1))))); else tmp = atan2(t_0, t_2); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - N[(N[Cos[lambda2], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -0.017], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[lambda2, 0.12], N[ArcTan[t$95$0 / N[(t$95$1 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / t$95$2], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := t_1 - \cos \lambda_2 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)\\
\mathbf{if}\;\lambda_2 \leq -0.017:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_2}\\
\mathbf{elif}\;\lambda_2 \leq 0.12:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{t_1 - \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{t_2}\\
\end{array}
\end{array}
if lambda2 < -0.017000000000000001Initial program 52.0%
Taylor expanded in lambda1 around 0 52.2%
cos-neg16.8%
Simplified52.2%
Taylor expanded in lambda1 around 0 53.6%
if -0.017000000000000001 < lambda2 < 0.12Initial program 97.8%
Taylor expanded in lambda2 around 0 97.8%
if 0.12 < lambda2 Initial program 58.1%
Taylor expanded in lambda1 around 0 58.1%
cos-neg14.0%
Simplified58.1%
Final simplification75.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin phi1)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_2 (* (cos phi1) (sin phi2))))
(if (<= lambda2 -0.048)
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_2 (* t_0 (cos (- lambda1 lambda2)))))
(if (<= lambda2 0.12)
(atan2 t_1 (- t_2 (* (cos phi2) (* (cos lambda1) (sin phi1)))))
(atan2 t_1 (- t_2 (* (cos lambda2) t_0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin(phi1);
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double t_2 = cos(phi1) * sin(phi2);
double tmp;
if (lambda2 <= -0.048) {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_2 - (t_0 * cos((lambda1 - lambda2)))));
} else if (lambda2 <= 0.12) {
tmp = atan2(t_1, (t_2 - (cos(phi2) * (cos(lambda1) * sin(phi1)))));
} else {
tmp = atan2(t_1, (t_2 - (cos(lambda2) * t_0)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi2) * sin(phi1)
t_1 = cos(phi2) * sin((lambda1 - lambda2))
t_2 = cos(phi1) * sin(phi2)
if (lambda2 <= (-0.048d0)) then
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_2 - (t_0 * cos((lambda1 - lambda2)))))
else if (lambda2 <= 0.12d0) then
tmp = atan2(t_1, (t_2 - (cos(phi2) * (cos(lambda1) * sin(phi1)))))
else
tmp = atan2(t_1, (t_2 - (cos(lambda2) * t_0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin(phi1);
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double t_2 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (lambda2 <= -0.048) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_2 - (t_0 * Math.cos((lambda1 - lambda2)))));
} else if (lambda2 <= 0.12) {
tmp = Math.atan2(t_1, (t_2 - (Math.cos(phi2) * (Math.cos(lambda1) * Math.sin(phi1)))));
} else {
tmp = Math.atan2(t_1, (t_2 - (Math.cos(lambda2) * t_0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin(phi1) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) t_2 = math.cos(phi1) * math.sin(phi2) tmp = 0 if lambda2 <= -0.048: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_2 - (t_0 * math.cos((lambda1 - lambda2))))) elif lambda2 <= 0.12: tmp = math.atan2(t_1, (t_2 - (math.cos(phi2) * (math.cos(lambda1) * math.sin(phi1))))) else: tmp = math.atan2(t_1, (t_2 - (math.cos(lambda2) * t_0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(phi1)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) t_2 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda2 <= -0.048) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_2 - Float64(t_0 * cos(Float64(lambda1 - lambda2))))); elseif (lambda2 <= 0.12) tmp = atan(t_1, Float64(t_2 - Float64(cos(phi2) * Float64(cos(lambda1) * sin(phi1))))); else tmp = atan(t_1, Float64(t_2 - Float64(cos(lambda2) * t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin(phi1); t_1 = cos(phi2) * sin((lambda1 - lambda2)); t_2 = cos(phi1) * sin(phi2); tmp = 0.0; if (lambda2 <= -0.048) tmp = atan2((cos(phi2) * sin(-lambda2)), (t_2 - (t_0 * cos((lambda1 - lambda2))))); elseif (lambda2 <= 0.12) tmp = atan2(t_1, (t_2 - (cos(phi2) * (cos(lambda1) * sin(phi1))))); else tmp = atan2(t_1, (t_2 - (cos(lambda2) * t_0))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -0.048], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 0.12], N[ArcTan[t$95$1 / N[(t$95$2 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$2 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \phi_1\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -0.048:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_2 - t_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{elif}\;\lambda_2 \leq 0.12:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_2 - \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_2 - \cos \lambda_2 \cdot t_0}\\
\end{array}
\end{array}
if lambda2 < -0.048000000000000001Initial program 52.0%
Taylor expanded in lambda1 around 0 53.6%
if -0.048000000000000001 < lambda2 < 0.12Initial program 97.8%
Taylor expanded in lambda2 around 0 97.8%
if 0.12 < lambda2 Initial program 58.1%
Taylor expanded in lambda1 around 0 58.1%
cos-neg14.0%
Simplified58.1%
Final simplification75.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 75.5%
Final simplification75.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (or (<= (- lambda1 lambda2) -50000.0)
(not (<= (- lambda1 lambda2) 1e-29)))
(atan2 t_1 (- t_0 (* (sin phi1) (cos (- lambda1 lambda2)))))
(atan2 t_1 (- t_0 (* (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(phi2) * sin((lambda1 - lambda2));
double tmp;
if (((lambda1 - lambda2) <= -50000.0) || !((lambda1 - lambda2) <= 1e-29)) {
tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_1, (t_0 - (cos(phi2) * sin(phi1))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin((lambda1 - lambda2))
if (((lambda1 - lambda2) <= (-50000.0d0)) .or. (.not. ((lambda1 - lambda2) <= 1d-29))) then
tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))))
else
tmp = atan2(t_1, (t_0 - (cos(phi2) * 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 t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (((lambda1 - lambda2) <= -50000.0) || !((lambda1 - lambda2) <= 1e-29)) {
tmp = Math.atan2(t_1, (t_0 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2(t_1, (t_0 - (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(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if ((lambda1 - lambda2) <= -50000.0) or not ((lambda1 - lambda2) <= 1e-29): tmp = math.atan2(t_1, (t_0 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if ((Float64(lambda1 - lambda2) <= -50000.0) || !(Float64(lambda1 - lambda2) <= 1e-29)) tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (((lambda1 - lambda2) <= -50000.0) || ~(((lambda1 - lambda2) <= 1e-29))) tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda1 - lambda2))))); else tmp = atan2(t_1, (t_0 - (cos(phi2) * 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]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -50000.0], N[Not[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 1e-29]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -50000 \lor \neg \left(\lambda_1 - \lambda_2 \leq 10^{-29}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \phi_2 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -5e4 or 9.99999999999999943e-30 < (-.f64 lambda1 lambda2) Initial program 67.4%
Taylor expanded in phi2 around 0 59.2%
if -5e4 < (-.f64 lambda1 lambda2) < 9.99999999999999943e-30Initial program 99.9%
Taylor expanded in lambda1 around 0 99.9%
cos-neg40.2%
Simplified99.9%
Taylor expanded in lambda2 around 0 99.9%
Final simplification69.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_1 (* (cos phi1) (sin phi2)))
(t_2
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_1 (* (sin phi1) (cos (- lambda1 lambda2)))))))
(if (<= lambda2 -0.44)
t_2
(if (<= lambda2 5e-298)
(atan2 t_0 (- t_1 (* (cos phi2) (sin phi1))))
(if (<= lambda2 7.5e+73)
(atan2 t_0 (- t_1 (* (cos lambda1) (sin phi1))))
t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double t_1 = cos(phi1) * sin(phi2);
double t_2 = atan2((cos(phi2) * sin(-lambda2)), (t_1 - (sin(phi1) * cos((lambda1 - lambda2)))));
double tmp;
if (lambda2 <= -0.44) {
tmp = t_2;
} else if (lambda2 <= 5e-298) {
tmp = atan2(t_0, (t_1 - (cos(phi2) * sin(phi1))));
} else if (lambda2 <= 7.5e+73) {
tmp = atan2(t_0, (t_1 - (cos(lambda1) * sin(phi1))));
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi2) * sin((lambda1 - lambda2))
t_1 = cos(phi1) * sin(phi2)
t_2 = atan2((cos(phi2) * sin(-lambda2)), (t_1 - (sin(phi1) * cos((lambda1 - lambda2)))))
if (lambda2 <= (-0.44d0)) then
tmp = t_2
else if (lambda2 <= 5d-298) then
tmp = atan2(t_0, (t_1 - (cos(phi2) * sin(phi1))))
else if (lambda2 <= 7.5d+73) then
tmp = atan2(t_0, (t_1 - (cos(lambda1) * sin(phi1))))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double t_2 = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_1 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
double tmp;
if (lambda2 <= -0.44) {
tmp = t_2;
} else if (lambda2 <= 5e-298) {
tmp = Math.atan2(t_0, (t_1 - (Math.cos(phi2) * Math.sin(phi1))));
} else if (lambda2 <= 7.5e+73) {
tmp = Math.atan2(t_0, (t_1 - (Math.cos(lambda1) * Math.sin(phi1))));
} else {
tmp = t_2;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) t_1 = math.cos(phi1) * math.sin(phi2) t_2 = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_1 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) tmp = 0 if lambda2 <= -0.44: tmp = t_2 elif lambda2 <= 5e-298: tmp = math.atan2(t_0, (t_1 - (math.cos(phi2) * math.sin(phi1)))) elif lambda2 <= 7.5e+73: tmp = math.atan2(t_0, (t_1 - (math.cos(lambda1) * math.sin(phi1)))) else: tmp = t_2 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_1 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (lambda2 <= -0.44) tmp = t_2; elseif (lambda2 <= 5e-298) tmp = atan(t_0, Float64(t_1 - Float64(cos(phi2) * sin(phi1)))); elseif (lambda2 <= 7.5e+73) tmp = atan(t_0, Float64(t_1 - Float64(cos(lambda1) * sin(phi1)))); else tmp = t_2; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); t_1 = cos(phi1) * sin(phi2); t_2 = atan2((cos(phi2) * sin(-lambda2)), (t_1 - (sin(phi1) * cos((lambda1 - lambda2))))); tmp = 0.0; if (lambda2 <= -0.44) tmp = t_2; elseif (lambda2 <= 5e-298) tmp = atan2(t_0, (t_1 - (cos(phi2) * sin(phi1)))); elseif (lambda2 <= 7.5e+73) tmp = atan2(t_0, (t_1 - (cos(lambda1) * sin(phi1)))); else tmp = t_2; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -0.44], t$95$2, If[LessEqual[lambda2, 5e-298], N[ArcTan[t$95$0 / N[(t$95$1 - N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 7.5e+73], N[ArcTan[t$95$0 / N[(t$95$1 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_1 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;\lambda_2 \leq -0.44:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\lambda_2 \leq 5 \cdot 10^{-298}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{t_1 - \cos \phi_2 \cdot \sin \phi_1}\\
\mathbf{elif}\;\lambda_2 \leq 7.5 \cdot 10^{+73}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{t_1 - \cos \lambda_1 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if lambda2 < -0.440000000000000002 or 7.5e73 < lambda2 Initial program 54.1%
Taylor expanded in phi2 around 0 48.1%
Taylor expanded in lambda1 around 0 50.4%
if -0.440000000000000002 < lambda2 < 5.0000000000000002e-298Initial program 98.5%
Taylor expanded in lambda1 around 0 88.3%
cos-neg54.6%
Simplified88.3%
Taylor expanded in lambda2 around 0 88.3%
if 5.0000000000000002e-298 < lambda2 < 7.5e73Initial program 89.4%
Taylor expanded in phi2 around 0 79.6%
Taylor expanded in lambda2 around 0 78.6%
Final simplification68.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_1 (* (cos phi1) (sin phi2)))
(t_2
(atan2
(* (sin lambda1) (cos phi2))
(- t_1 (* (sin phi1) (cos (- lambda1 lambda2)))))))
(if (<= phi1 -2.0)
t_2
(if (<= phi1 0.15)
(atan2 t_0 (- t_1 (* (cos lambda2) phi1)))
(if (<= phi1 5e+100) t_2 (atan2 t_0 (- t_1 (* (cos lambda1) phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double t_1 = cos(phi1) * sin(phi2);
double t_2 = atan2((sin(lambda1) * cos(phi2)), (t_1 - (sin(phi1) * cos((lambda1 - lambda2)))));
double tmp;
if (phi1 <= -2.0) {
tmp = t_2;
} else if (phi1 <= 0.15) {
tmp = atan2(t_0, (t_1 - (cos(lambda2) * phi1)));
} else if (phi1 <= 5e+100) {
tmp = t_2;
} else {
tmp = atan2(t_0, (t_1 - (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) :: t_2
real(8) :: tmp
t_0 = cos(phi2) * sin((lambda1 - lambda2))
t_1 = cos(phi1) * sin(phi2)
t_2 = atan2((sin(lambda1) * cos(phi2)), (t_1 - (sin(phi1) * cos((lambda1 - lambda2)))))
if (phi1 <= (-2.0d0)) then
tmp = t_2
else if (phi1 <= 0.15d0) then
tmp = atan2(t_0, (t_1 - (cos(lambda2) * phi1)))
else if (phi1 <= 5d+100) then
tmp = t_2
else
tmp = atan2(t_0, (t_1 - (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(phi2) * Math.sin((lambda1 - lambda2));
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double t_2 = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_1 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
double tmp;
if (phi1 <= -2.0) {
tmp = t_2;
} else if (phi1 <= 0.15) {
tmp = Math.atan2(t_0, (t_1 - (Math.cos(lambda2) * phi1)));
} else if (phi1 <= 5e+100) {
tmp = t_2;
} else {
tmp = Math.atan2(t_0, (t_1 - (Math.cos(lambda1) * phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) t_1 = math.cos(phi1) * math.sin(phi2) t_2 = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_1 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) tmp = 0 if phi1 <= -2.0: tmp = t_2 elif phi1 <= 0.15: tmp = math.atan2(t_0, (t_1 - (math.cos(lambda2) * phi1))) elif phi1 <= 5e+100: tmp = t_2 else: tmp = math.atan2(t_0, (t_1 - (math.cos(lambda1) * phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_1 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (phi1 <= -2.0) tmp = t_2; elseif (phi1 <= 0.15) tmp = atan(t_0, Float64(t_1 - Float64(cos(lambda2) * phi1))); elseif (phi1 <= 5e+100) tmp = t_2; else tmp = atan(t_0, Float64(t_1 - Float64(cos(lambda1) * phi1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); t_1 = cos(phi1) * sin(phi2); t_2 = atan2((sin(lambda1) * cos(phi2)), (t_1 - (sin(phi1) * cos((lambda1 - lambda2))))); tmp = 0.0; if (phi1 <= -2.0) tmp = t_2; elseif (phi1 <= 0.15) tmp = atan2(t_0, (t_1 - (cos(lambda2) * phi1))); elseif (phi1 <= 5e+100) tmp = t_2; else tmp = atan2(t_0, (t_1 - (cos(lambda1) * phi1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -2.0], t$95$2, If[LessEqual[phi1, 0.15], N[ArcTan[t$95$0 / N[(t$95$1 - N[(N[Cos[lambda2], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 5e+100], t$95$2, N[ArcTan[t$95$0 / N[(t$95$1 - N[(N[Cos[lambda1], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_1 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;\phi_1 \leq -2:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\phi_1 \leq 0.15:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{t_1 - \cos \lambda_2 \cdot \phi_1}\\
\mathbf{elif}\;\phi_1 \leq 5 \cdot 10^{+100}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{t_1 - \cos \lambda_1 \cdot \phi_1}\\
\end{array}
\end{array}
if phi1 < -2 or 0.149999999999999994 < phi1 < 4.9999999999999999e100Initial program 75.9%
Taylor expanded in phi2 around 0 55.4%
Taylor expanded in lambda2 around 0 36.0%
if -2 < phi1 < 0.149999999999999994Initial program 78.5%
Taylor expanded in phi2 around 0 78.0%
Taylor expanded in phi1 around 0 77.1%
Taylor expanded in lambda1 around 0 77.1%
cos-neg77.1%
*-commutative77.1%
Simplified77.1%
if 4.9999999999999999e100 < phi1 Initial program 66.1%
Taylor expanded in phi2 around 0 39.0%
Taylor expanded in phi1 around 0 31.8%
Taylor expanded in lambda2 around 0 34.3%
*-commutative34.3%
Simplified34.3%
Final simplification57.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (or (<= lambda1 -0.0024) (not (<= lambda1 1.35e-5)))
(atan2 t_0 (- (* (cos phi1) (sin phi2)) (* (cos lambda1) (sin phi1))))
(atan2 t_0 (- (sin phi2) (* (cos lambda2) (* (cos phi2) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if ((lambda1 <= -0.0024) || !(lambda1 <= 1.35e-5)) {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(lambda1) * sin(phi1))));
} else {
tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * (cos(phi2) * 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(phi2) * sin((lambda1 - lambda2))
if ((lambda1 <= (-0.0024d0)) .or. (.not. (lambda1 <= 1.35d-5))) then
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(lambda1) * sin(phi1))))
else
tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * (cos(phi2) * sin(phi1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if ((lambda1 <= -0.0024) || !(lambda1 <= 1.35e-5)) {
tmp = Math.atan2(t_0, ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(lambda1) * Math.sin(phi1))));
} else {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.cos(lambda2) * (Math.cos(phi2) * Math.sin(phi1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if (lambda1 <= -0.0024) or not (lambda1 <= 1.35e-5): tmp = math.atan2(t_0, ((math.cos(phi1) * math.sin(phi2)) - (math.cos(lambda1) * math.sin(phi1)))) else: tmp = math.atan2(t_0, (math.sin(phi2) - (math.cos(lambda2) * (math.cos(phi2) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if ((lambda1 <= -0.0024) || !(lambda1 <= 1.35e-5)) tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(lambda1) * sin(phi1)))); else tmp = atan(t_0, Float64(sin(phi2) - Float64(cos(lambda2) * Float64(cos(phi2) * sin(phi1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if ((lambda1 <= -0.0024) || ~((lambda1 <= 1.35e-5))) tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(lambda1) * sin(phi1)))); else tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * (cos(phi2) * sin(phi1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -0.0024], N[Not[LessEqual[lambda1, 1.35e-5]], $MachinePrecision]], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda2], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -0.0024 \lor \neg \left(\lambda_1 \leq 1.35 \cdot 10^{-5}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\cos \phi_1 \cdot \sin \phi_2 - \cos \lambda_1 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\sin \phi_2 - \cos \lambda_2 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if lambda1 < -0.00239999999999999979 or 1.3499999999999999e-5 < lambda1 Initial program 54.2%
Taylor expanded in phi2 around 0 49.1%
Taylor expanded in lambda2 around 0 49.1%
if -0.00239999999999999979 < lambda1 < 1.3499999999999999e-5Initial program 98.9%
Taylor expanded in lambda1 around 0 98.9%
cos-neg26.7%
Simplified98.9%
Taylor expanded in phi1 around 0 85.4%
Final simplification66.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda1 -0.65)
(atan2
(* (sin lambda1) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (sin phi1) (cos (- lambda1 lambda2)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- (sin phi2) (* (cos lambda2) (* (cos phi2) (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -0.65) {
tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda2) * (cos(phi2) * 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) :: tmp
if (lambda1 <= (-0.65d0)) then
tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda2) * (cos(phi2) * sin(phi1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -0.65) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.cos(lambda2) * (Math.cos(phi2) * Math.sin(phi1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -0.65: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.cos(lambda2) * (math.cos(phi2) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -0.65) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(cos(lambda2) * Float64(cos(phi2) * sin(phi1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -0.65) tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda2) * (cos(phi2) * sin(phi1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -0.65], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $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], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda2], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -0.65:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \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)}{\sin \phi_2 - \cos \lambda_2 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if lambda1 < -0.650000000000000022Initial program 55.7%
Taylor expanded in phi2 around 0 50.8%
Taylor expanded in lambda2 around 0 50.3%
if -0.650000000000000022 < lambda1 Initial program 83.9%
Taylor expanded in lambda1 around 0 80.0%
cos-neg29.3%
Simplified80.0%
Taylor expanded in phi1 around 0 70.7%
Final simplification64.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.5%
Taylor expanded in phi2 around 0 64.6%
Taylor expanded in phi1 around 0 49.9%
Taylor expanded in lambda2 around 0 50.1%
*-commutative50.1%
Simplified50.1%
Final simplification50.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin lambda1) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (cos lambda1) phi1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin(lambda1) * cos(phi2)), ((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((sin(lambda1) * cos(phi2)), ((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.sin(lambda1) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(lambda1) * phi1)));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin(lambda1) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(lambda1) * phi1)))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(lambda1) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(lambda1) * phi1))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(lambda1) * phi1))); 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[(N[Cos[lambda1], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \cos \lambda_1 \cdot \phi_1}
\end{array}
Initial program 75.5%
Taylor expanded in phi2 around 0 64.6%
Taylor expanded in phi1 around 0 49.9%
Taylor expanded in lambda2 around 0 32.1%
Taylor expanded in lambda2 around 0 32.1%
Final simplification32.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin lambda1) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (cos lambda2) phi1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(lambda2) * 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((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(lambda2) * phi1)))
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)) - (Math.cos(lambda2) * phi1)));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin(lambda1) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(lambda2) * phi1)))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(lambda1) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(lambda2) * phi1))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(lambda2) * phi1))); 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[(N[Cos[lambda2], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \cos \lambda_2 \cdot \phi_1}
\end{array}
Initial program 75.5%
Taylor expanded in phi2 around 0 64.6%
Taylor expanded in phi1 around 0 49.9%
Taylor expanded in lambda2 around 0 32.1%
Taylor expanded in lambda1 around 0 32.1%
cos-neg32.1%
Simplified32.1%
Final simplification32.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin lambda1) (- (* (cos phi1) (sin phi2)) (* phi1 (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin(lambda1), ((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(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(phi1) * Math.sin(phi2)) - (phi1 * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin(lambda1), ((math.cos(phi1) * math.sin(phi2)) - (phi1 * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(lambda1), 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(phi1) * sin(phi2)) - (phi1 * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[lambda1], $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}{\cos \phi_1 \cdot \sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 75.5%
Taylor expanded in phi2 around 0 64.6%
Taylor expanded in phi1 around 0 49.9%
Taylor expanded in lambda2 around 0 32.1%
Taylor expanded in phi2 around 0 25.4%
Final simplification25.4%
(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.5%
Taylor expanded in phi2 around 0 64.6%
Taylor expanded in phi1 around 0 49.9%
Taylor expanded in lambda2 around 0 32.1%
Taylor expanded in phi1 around 0 32.1%
Final simplification32.1%
herbie shell --seed 2023171
(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))))))