
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 24 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (cos phi2) (sin phi1))
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((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((((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))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[(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{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)}
\end{array}
Initial program 82.5%
sin-diff90.9%
sub-neg90.9%
Applied egg-rr90.9%
sub-neg90.9%
Simplified90.9%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2 (- (* (cos phi1) (sin phi2)) (* t_1 (cos (- lambda1 lambda2))))))
(if (<= phi2 -7.1)
(atan2 t_0 t_2)
(if (<= phi2 8e-43)
(atan2
t_0
(-
(sin phi2)
(*
t_1
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1))))))
(atan2 (log1p (expm1 t_0)) t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_1 = cos(phi2) * sin(phi1);
double t_2 = (cos(phi1) * sin(phi2)) - (t_1 * cos((lambda1 - lambda2)));
double tmp;
if (phi2 <= -7.1) {
tmp = atan2(t_0, t_2);
} else if (phi2 <= 8e-43) {
tmp = atan2(t_0, (sin(phi2) - (t_1 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
} else {
tmp = atan2(log1p(expm1(t_0)), t_2);
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double t_2 = (Math.cos(phi1) * Math.sin(phi2)) - (t_1 * Math.cos((lambda1 - lambda2)));
double tmp;
if (phi2 <= -7.1) {
tmp = Math.atan2(t_0, t_2);
} else if (phi2 <= 8e-43) {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (t_1 * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1))))));
} else {
tmp = Math.atan2(Math.log1p(Math.expm1(t_0)), t_2);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2) t_1 = math.cos(phi2) * math.sin(phi1) t_2 = (math.cos(phi1) * math.sin(phi2)) - (t_1 * math.cos((lambda1 - lambda2))) tmp = 0 if phi2 <= -7.1: tmp = math.atan2(t_0, t_2) elif phi2 <= 8e-43: tmp = math.atan2(t_0, (math.sin(phi2) - (t_1 * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1)))))) else: tmp = math.atan2(math.log1p(math.expm1(t_0)), t_2) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_1 * cos(Float64(lambda1 - lambda2)))) tmp = 0.0 if (phi2 <= -7.1) tmp = atan(t_0, t_2); elseif (phi2 <= 8e-43) tmp = atan(t_0, Float64(sin(phi2) - Float64(t_1 * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))))); else tmp = atan(log1p(expm1(t_0)), t_2); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -7.1], N[ArcTan[t$95$0 / t$95$2], $MachinePrecision], If[LessEqual[phi2, 8e-43], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$1 * 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[Log[1 + N[(Exp[t$95$0] - 1), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
t_2 := \cos \phi_1 \cdot \sin \phi_2 - t_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -7.1:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{t_2}\\
\mathbf{elif}\;\phi_2 \leq 8 \cdot 10^{-43}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\sin \phi_2 - t_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{log1p}\left(\mathsf{expm1}\left(t_0\right)\right)}{t_2}\\
\end{array}
\end{array}
if phi2 < -7.0999999999999996Initial program 82.7%
sin-diff88.5%
sub-neg88.5%
Applied egg-rr88.5%
sub-neg88.5%
Simplified88.5%
if -7.0999999999999996 < phi2 < 8.00000000000000062e-43Initial program 84.8%
sin-diff92.4%
sub-neg92.4%
Applied egg-rr92.4%
sub-neg92.4%
Simplified92.4%
cos-diff99.9%
+-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in phi1 around 0 99.9%
if 8.00000000000000062e-43 < phi2 Initial program 78.9%
sin-diff90.2%
sub-neg90.2%
Applied egg-rr90.2%
sub-neg90.2%
Simplified90.2%
log1p-expm1-u90.2%
*-commutative90.2%
Applied egg-rr90.2%
Final simplification94.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (- t_0 (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))
(t_2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))))
(if (<= phi2 -1700000000000.0)
(atan2 t_2 t_1)
(if (<= phi2 8e-43)
(atan2
t_2
(-
t_0
(*
(sin phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1))))))
(atan2 (log1p (expm1 t_2)) t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)));
double t_2 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double tmp;
if (phi2 <= -1700000000000.0) {
tmp = atan2(t_2, t_1);
} else if (phi2 <= 8e-43) {
tmp = atan2(t_2, (t_0 - (sin(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
} else {
tmp = atan2(log1p(expm1(t_2)), t_1);
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)));
double t_2 = ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2);
double tmp;
if (phi2 <= -1700000000000.0) {
tmp = Math.atan2(t_2, t_1);
} else if (phi2 <= 8e-43) {
tmp = Math.atan2(t_2, (t_0 - (Math.sin(phi1) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1))))));
} else {
tmp = Math.atan2(Math.log1p(Math.expm1(t_2)), t_1);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = t_0 - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))) t_2 = ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2) tmp = 0 if phi2 <= -1700000000000.0: tmp = math.atan2(t_2, t_1) elif phi2 <= 8e-43: tmp = math.atan2(t_2, (t_0 - (math.sin(phi1) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1)))))) else: tmp = math.atan2(math.log1p(math.expm1(t_2)), t_1) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2)))) t_2 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) tmp = 0.0 if (phi2 <= -1700000000000.0) tmp = atan(t_2, t_1); elseif (phi2 <= 8e-43) tmp = atan(t_2, Float64(t_0 - Float64(sin(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))))); else tmp = atan(log1p(expm1(t_2)), t_1); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -1700000000000.0], N[ArcTan[t$95$2 / t$95$1], $MachinePrecision], If[LessEqual[phi2, 8e-43], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Sin[phi1], $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], N[ArcTan[N[Log[1 + N[(Exp[t$95$2] - 1), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -1700000000000:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_1}\\
\mathbf{elif}\;\phi_2 \leq 8 \cdot 10^{-43}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \sin \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{log1p}\left(\mathsf{expm1}\left(t_2\right)\right)}{t_1}\\
\end{array}
\end{array}
if phi2 < -1.7e12Initial program 84.2%
sin-diff89.7%
sub-neg89.7%
Applied egg-rr89.7%
sub-neg89.7%
Simplified89.7%
if -1.7e12 < phi2 < 8.00000000000000062e-43Initial program 84.1%
sin-diff91.8%
sub-neg91.8%
Applied egg-rr91.8%
sub-neg91.8%
Simplified91.8%
cos-diff99.9%
+-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in phi2 around 0 99.3%
if 8.00000000000000062e-43 < phi2 Initial program 78.9%
sin-diff90.2%
sub-neg90.2%
Applied egg-rr90.2%
sub-neg90.2%
Simplified90.2%
log1p-expm1-u90.2%
*-commutative90.2%
Applied egg-rr90.2%
Final simplification94.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (cos phi2) (sin phi1))))
(if (or (<= lambda1 -3.2e+26) (not (<= lambda1 2.1e-46)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* (cos lambda1) t_1)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(-
t_0
(*
t_1
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1)))))))))
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 <= -3.2e+26) || !(lambda1 <= 2.1e-46)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * t_1)));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (t_1 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
if ((lambda1 <= (-3.2d+26)) .or. (.not. (lambda1 <= 2.1d-46))) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * t_1)))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (t_1 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if ((lambda1 <= -3.2e+26) || !(lambda1 <= 2.1e-46)) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (Math.cos(lambda1) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (t_1 * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1))))));
}
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 <= -3.2e+26) or not (lambda1 <= 2.1e-46): tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (math.cos(lambda1) * t_1))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (t_1 * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1)))))) 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 <= -3.2e+26) || !(lambda1 <= 2.1e-46)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(cos(lambda1) * t_1))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(t_1 * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))))); 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 <= -3.2e+26) || ~((lambda1 <= 2.1e-46))) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * t_1))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (t_1 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -3.2e+26], N[Not[LessEqual[lambda1, 2.1e-46]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * 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}
\\
\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 -3.2 \cdot 10^{+26} \lor \neg \left(\lambda_1 \leq 2.1 \cdot 10^{-46}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \cos \lambda_1 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - t_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)}\\
\end{array}
\end{array}
if lambda1 < -3.20000000000000029e26 or 2.09999999999999987e-46 < lambda1 Initial program 64.7%
sin-diff82.4%
sub-neg82.4%
Applied egg-rr82.4%
sub-neg82.4%
Simplified82.4%
Taylor expanded in lambda2 around 0 82.5%
if -3.20000000000000029e26 < lambda1 < 2.09999999999999987e-46Initial program 98.2%
cos-diff99.7%
+-commutative99.7%
*-commutative99.7%
Applied egg-rr98.4%
Final simplification90.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (cos phi2) (sin phi1))))
(if (or (<= lambda1 -5.6e-5) (not (<= lambda1 2.1e-46)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* (cos lambda1) t_1)))
(atan2
(* (cos phi2) (sin (- lambda1 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 <= -5.6e-5) || !(lambda1 <= 2.1e-46)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * t_1)));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - 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 <= (-5.6d-5)) .or. (.not. (lambda1 <= 2.1d-46))) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * t_1)))
else
tmp = atan2((cos(phi2) * sin((lambda1 - 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 <= -5.6e-5) || !(lambda1 <= 2.1e-46)) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (Math.cos(lambda1) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - 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 <= -5.6e-5) or not (lambda1 <= 2.1e-46): tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (math.cos(lambda1) * t_1))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - 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 <= -5.6e-5) || !(lambda1 <= 2.1e-46)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(cos(lambda1) * t_1))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - 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 <= -5.6e-5) || ~((lambda1 <= 2.1e-46))) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * t_1))); else tmp = atan2((cos(phi2) * sin((lambda1 - 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, -5.6e-5], N[Not[LessEqual[lambda1, 2.1e-46]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(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 -5.6 \cdot 10^{-5} \lor \neg \left(\lambda_1 \leq 2.1 \cdot 10^{-46}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \cos \lambda_1 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \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 < -5.59999999999999992e-5 or 2.09999999999999987e-46 < lambda1 Initial program 64.1%
sin-diff81.6%
sub-neg81.6%
Applied egg-rr81.6%
sub-neg81.6%
Simplified81.6%
Taylor expanded in lambda2 around 0 81.7%
if -5.59999999999999992e-5 < lambda1 < 2.09999999999999987e-46Initial program 99.3%
Taylor expanded in lambda1 around 0 99.3%
cos-neg99.3%
+-commutative99.3%
mul-1-neg99.3%
distribute-rgt-neg-in99.3%
sin-neg99.3%
remove-double-neg99.3%
Simplified99.3%
Final simplification90.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 82.5%
sin-diff90.9%
sub-neg90.9%
Applied egg-rr90.9%
sub-neg90.9%
Simplified90.9%
Final simplification90.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (- (* (cos phi1) (sin phi2)) (* (sin phi1) (* (cos phi2) t_0))))
(t_2 (sin (- lambda1 lambda2))))
(if (<= phi1 -1.15e-7)
(atan2 (* (cos phi2) (log1p (expm1 t_2))) t_1)
(if (<= phi1 72.0)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* (* (cos phi2) (sin phi1)) t_0)))
(atan2 (* (cos phi2) t_2) t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = (cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * t_0));
double t_2 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.15e-7) {
tmp = atan2((cos(phi2) * log1p(expm1(t_2))), t_1);
} else if (phi1 <= 72.0) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - ((cos(phi2) * sin(phi1)) * t_0)));
} else {
tmp = atan2((cos(phi2) * t_2), t_1);
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = (Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * (Math.cos(phi2) * t_0));
double t_2 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.15e-7) {
tmp = Math.atan2((Math.cos(phi2) * Math.log1p(Math.expm1(t_2))), t_1);
} else if (phi1 <= 72.0) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - ((Math.cos(phi2) * Math.sin(phi1)) * t_0)));
} else {
tmp = Math.atan2((Math.cos(phi2) * t_2), t_1);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = (math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * (math.cos(phi2) * t_0)) t_2 = math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -1.15e-7: tmp = math.atan2((math.cos(phi2) * math.log1p(math.expm1(t_2))), t_1) elif phi1 <= 72.0: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - ((math.cos(phi2) * math.sin(phi1)) * t_0))) else: tmp = math.atan2((math.cos(phi2) * t_2), t_1) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * Float64(cos(phi2) * t_0))) t_2 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -1.15e-7) tmp = atan(Float64(cos(phi2) * log1p(expm1(t_2))), t_1); elseif (phi1 <= 72.0) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(Float64(cos(phi2) * sin(phi1)) * t_0))); else tmp = atan(Float64(cos(phi2) * t_2), t_1); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.15e-7], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Log[1 + N[(Exp[t$95$2] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision], If[LessEqual[phi1, 72.0], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] / t$95$1], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.15 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(t_2\right)\right)}{t_1}\\
\mathbf{elif}\;\phi_1 \leq 72:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_2}{t_1}\\
\end{array}
\end{array}
if phi1 < -1.14999999999999997e-7Initial program 79.2%
associate-*l*79.2%
Simplified79.2%
log1p-expm1-u79.2%
Applied egg-rr79.2%
if -1.14999999999999997e-7 < phi1 < 72Initial program 84.8%
sin-diff98.7%
sub-neg98.7%
Applied egg-rr98.7%
sub-neg98.7%
Simplified98.7%
Taylor expanded in phi1 around 0 98.7%
if 72 < phi1 Initial program 81.0%
associate-*l*81.0%
Simplified81.0%
Final simplification89.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(-
(* (cos phi1) (sin phi2))
(* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
(t_1 (sin (- lambda1 lambda2))))
(if (<= phi1 -7.5e-8)
(atan2 (* (cos phi2) (log1p (expm1 t_1))) t_0)
(if (<= phi1 7.5e-19)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* phi1 (cos (- lambda2 lambda1)))))
(atan2 (* (cos phi2) t_1) t_0)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))));
double t_1 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -7.5e-8) {
tmp = atan2((cos(phi2) * log1p(expm1(t_1))), t_0);
} else if (phi1 <= 7.5e-19) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))));
} else {
tmp = atan2((cos(phi2) * t_1), t_0);
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))));
double t_1 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -7.5e-8) {
tmp = Math.atan2((Math.cos(phi2) * Math.log1p(Math.expm1(t_1))), t_0);
} else if (phi1 <= 7.5e-19) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * t_1), t_0);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = (math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2)))) t_1 = math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -7.5e-8: tmp = math.atan2((math.cos(phi2) * math.log1p(math.expm1(t_1))), t_0) elif phi1 <= 7.5e-19: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2((math.cos(phi2) * t_1), t_0) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -7.5e-8) tmp = atan(Float64(cos(phi2) * log1p(expm1(t_1))), t_0); elseif (phi1 <= 7.5e-19) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); else tmp = atan(Float64(cos(phi2) * t_1), t_0); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -7.5e-8], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Log[1 + N[(Exp[t$95$1] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision], If[LessEqual[phi1, 7.5e-19], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / t$95$0], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -7.5 \cdot 10^{-8}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(t_1\right)\right)}{t_0}\\
\mathbf{elif}\;\phi_1 \leq 7.5 \cdot 10^{-19}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_1}{t_0}\\
\end{array}
\end{array}
if phi1 < -7.4999999999999997e-8Initial program 79.2%
associate-*l*79.2%
Simplified79.2%
log1p-expm1-u79.2%
Applied egg-rr79.2%
if -7.4999999999999997e-8 < phi1 < 7.49999999999999957e-19Initial program 85.1%
associate-*l*85.1%
Simplified85.1%
Taylor expanded in phi2 around 0 85.0%
sub-neg85.0%
remove-double-neg85.0%
mul-1-neg85.0%
distribute-neg-in85.0%
+-commutative85.0%
cos-neg85.0%
mul-1-neg85.0%
unsub-neg85.0%
Simplified85.0%
Taylor expanded in phi1 around 0 85.0%
Taylor expanded in phi1 around 0 85.0%
sin-diff99.6%
sub-neg99.6%
Applied egg-rr99.5%
sub-neg99.6%
Simplified99.5%
if 7.49999999999999957e-19 < phi1 Initial program 80.8%
associate-*l*80.8%
Simplified80.8%
Final simplification89.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -5.4e-11) (not (<= phi1 5e-23)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(-
(* (cos phi1) (sin phi2))
(* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* phi1 (cos (- lambda2 lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -5.4e-11) || !(phi1 <= 5e-23)) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((phi1 <= (-5.4d-11)) .or. (.not. (phi1 <= 5d-23))) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -5.4e-11) || !(phi1 <= 5e-23)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))))));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (phi1 <= -5.4e-11) or not (phi1 <= 5e-23): tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2)))))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -5.4e-11) || !(phi1 <= 5e-23)) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi1 <= -5.4e-11) || ~((phi1 <= 5e-23))) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2)))))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -5.4e-11], N[Not[LessEqual[phi1, 5e-23]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -5.4 \cdot 10^{-11} \lor \neg \left(\phi_1 \leq 5 \cdot 10^{-23}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\end{array}
\end{array}
if phi1 < -5.40000000000000009e-11 or 5.0000000000000002e-23 < phi1 Initial program 79.9%
associate-*l*79.9%
Simplified79.9%
if -5.40000000000000009e-11 < phi1 < 5.0000000000000002e-23Initial program 85.1%
associate-*l*85.1%
Simplified85.1%
Taylor expanded in phi2 around 0 85.0%
sub-neg85.0%
remove-double-neg85.0%
mul-1-neg85.0%
distribute-neg-in85.0%
+-commutative85.0%
cos-neg85.0%
mul-1-neg85.0%
unsub-neg85.0%
Simplified85.0%
Taylor expanded in phi1 around 0 85.0%
Taylor expanded in phi1 around 0 85.0%
sin-diff99.6%
sub-neg99.6%
Applied egg-rr99.5%
sub-neg99.6%
Simplified99.5%
Final simplification89.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda1 -2.1e+15) (not (<= lambda1 1.85e-16)))
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) (* (cos lambda2) (cos phi2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda1 <= -2.1e+15) || !(lambda1 <= 1.85e-16)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda1 <= (-2.1d+15)) .or. (.not. (lambda1 <= 1.85d-16))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda1 <= -2.1e+15) || !(lambda1 <= 1.85e-16)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * (Math.cos(lambda2) * Math.cos(phi2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda1 <= -2.1e+15) or not (lambda1 <= 1.85e-16): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * (math.cos(lambda2) * math.cos(phi2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda1 <= -2.1e+15) || !(lambda1 <= 1.85e-16)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(lambda2) * cos(phi2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda1 <= -2.1e+15) || ~((lambda1 <= 1.85e-16))) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -2.1e+15], N[Not[LessEqual[lambda1, 1.85e-16]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -2.1 \cdot 10^{+15} \lor \neg \left(\lambda_1 \leq 1.85 \cdot 10^{-16}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \phi_2\right)}\\
\end{array}
\end{array}
if lambda1 < -2.1e15 or 1.85e-16 < lambda1 Initial program 62.3%
Taylor expanded in lambda2 around 0 62.2%
if -2.1e15 < lambda1 < 1.85e-16Initial program 98.7%
associate-*l*98.7%
Simplified98.7%
Taylor expanded in lambda1 around 0 98.7%
cos-neg98.7%
associate-*r*98.7%
Simplified98.7%
Final simplification82.5%
(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 (<= lambda1 -2.6e+15)
(atan2
(* (sin lambda1) (cos phi2))
(- t_2 (* t_0 (cos (- lambda1 lambda2)))))
(if (<= lambda1 2.1e-46)
(atan2 t_1 (- t_2 (* (sin phi1) (* (cos lambda2) (cos phi2)))))
(atan2 t_1 (- t_2 (* (cos lambda1) 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 (lambda1 <= -2.6e+15) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_2 - (t_0 * cos((lambda1 - lambda2)))));
} else if (lambda1 <= 2.1e-46) {
tmp = atan2(t_1, (t_2 - (sin(phi1) * (cos(lambda2) * cos(phi2)))));
} else {
tmp = atan2(t_1, (t_2 - (cos(lambda1) * 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 (lambda1 <= (-2.6d+15)) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_2 - (t_0 * cos((lambda1 - lambda2)))))
else if (lambda1 <= 2.1d-46) then
tmp = atan2(t_1, (t_2 - (sin(phi1) * (cos(lambda2) * cos(phi2)))))
else
tmp = atan2(t_1, (t_2 - (cos(lambda1) * 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 (lambda1 <= -2.6e+15) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_2 - (t_0 * Math.cos((lambda1 - lambda2)))));
} else if (lambda1 <= 2.1e-46) {
tmp = Math.atan2(t_1, (t_2 - (Math.sin(phi1) * (Math.cos(lambda2) * Math.cos(phi2)))));
} else {
tmp = Math.atan2(t_1, (t_2 - (Math.cos(lambda1) * 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 lambda1 <= -2.6e+15: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_2 - (t_0 * math.cos((lambda1 - lambda2))))) elif lambda1 <= 2.1e-46: tmp = math.atan2(t_1, (t_2 - (math.sin(phi1) * (math.cos(lambda2) * math.cos(phi2))))) else: tmp = math.atan2(t_1, (t_2 - (math.cos(lambda1) * 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 (lambda1 <= -2.6e+15) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_2 - Float64(t_0 * cos(Float64(lambda1 - lambda2))))); elseif (lambda1 <= 2.1e-46) tmp = atan(t_1, Float64(t_2 - Float64(sin(phi1) * Float64(cos(lambda2) * cos(phi2))))); else tmp = atan(t_1, Float64(t_2 - Float64(cos(lambda1) * 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 (lambda1 <= -2.6e+15) tmp = atan2((sin(lambda1) * cos(phi2)), (t_2 - (t_0 * cos((lambda1 - lambda2))))); elseif (lambda1 <= 2.1e-46) tmp = atan2(t_1, (t_2 - (sin(phi1) * (cos(lambda2) * cos(phi2))))); else tmp = atan2(t_1, (t_2 - (cos(lambda1) * 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[lambda1, -2.6e+15], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 2.1e-46], N[ArcTan[t$95$1 / N[(t$95$2 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$2 - N[(N[Cos[lambda1], $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_1 \leq -2.6 \cdot 10^{+15}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_2 - t_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{elif}\;\lambda_1 \leq 2.1 \cdot 10^{-46}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_2 - \sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_2 - \cos \lambda_1 \cdot t_0}\\
\end{array}
\end{array}
if lambda1 < -2.6e15Initial program 60.8%
Taylor expanded in lambda2 around 0 61.0%
if -2.6e15 < lambda1 < 2.09999999999999987e-46Initial program 98.7%
associate-*l*98.7%
Simplified98.7%
Taylor expanded in lambda1 around 0 98.6%
cos-neg98.6%
associate-*r*98.7%
Simplified98.7%
if 2.09999999999999987e-46 < lambda1 Initial program 67.0%
Taylor expanded in lambda2 around 0 67.0%
Final simplification82.5%
(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.082)
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_2 (* t_0 (cos (- lambda1 lambda2)))))
(if (<= lambda2 1.08e-17)
(atan2 t_1 (- t_2 (* (cos lambda1) t_0)))
(atan2 t_1 (- t_2 (* (sin phi1) (* (cos lambda2) (cos phi2)))))))))
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.082) {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_2 - (t_0 * cos((lambda1 - lambda2)))));
} else if (lambda2 <= 1.08e-17) {
tmp = atan2(t_1, (t_2 - (cos(lambda1) * t_0)));
} else {
tmp = atan2(t_1, (t_2 - (sin(phi1) * (cos(lambda2) * cos(phi2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: 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.082d0)) then
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_2 - (t_0 * cos((lambda1 - lambda2)))))
else if (lambda2 <= 1.08d-17) then
tmp = atan2(t_1, (t_2 - (cos(lambda1) * t_0)))
else
tmp = atan2(t_1, (t_2 - (sin(phi1) * (cos(lambda2) * cos(phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(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.082) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_2 - (t_0 * Math.cos((lambda1 - lambda2)))));
} else if (lambda2 <= 1.08e-17) {
tmp = Math.atan2(t_1, (t_2 - (Math.cos(lambda1) * t_0)));
} else {
tmp = Math.atan2(t_1, (t_2 - (Math.sin(phi1) * (Math.cos(lambda2) * Math.cos(phi2)))));
}
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.082: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_2 - (t_0 * math.cos((lambda1 - lambda2))))) elif lambda2 <= 1.08e-17: tmp = math.atan2(t_1, (t_2 - (math.cos(lambda1) * t_0))) else: tmp = math.atan2(t_1, (t_2 - (math.sin(phi1) * (math.cos(lambda2) * math.cos(phi2))))) 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.082) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_2 - Float64(t_0 * cos(Float64(lambda1 - lambda2))))); elseif (lambda2 <= 1.08e-17) tmp = atan(t_1, Float64(t_2 - Float64(cos(lambda1) * t_0))); else tmp = atan(t_1, Float64(t_2 - Float64(sin(phi1) * Float64(cos(lambda2) * cos(phi2))))); 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.082) tmp = atan2((cos(phi2) * sin(-lambda2)), (t_2 - (t_0 * cos((lambda1 - lambda2))))); elseif (lambda2 <= 1.08e-17) tmp = atan2(t_1, (t_2 - (cos(lambda1) * t_0))); else tmp = atan2(t_1, (t_2 - (sin(phi1) * (cos(lambda2) * cos(phi2))))); 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.082], 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, 1.08e-17], N[ArcTan[t$95$1 / N[(t$95$2 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$2 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_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.082:\\
\;\;\;\;\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 1.08 \cdot 10^{-17}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_2 - \cos \lambda_1 \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_2 - \sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \phi_2\right)}\\
\end{array}
\end{array}
if lambda2 < -0.0820000000000000034Initial program 69.4%
Taylor expanded in lambda1 around 0 71.7%
if -0.0820000000000000034 < lambda2 < 1.07999999999999995e-17Initial program 98.8%
Taylor expanded in lambda2 around 0 98.8%
if 1.07999999999999995e-17 < lambda2 Initial program 63.7%
associate-*l*63.7%
Simplified63.7%
Taylor expanded in lambda1 around 0 63.6%
cos-neg63.6%
associate-*r*63.6%
Simplified63.6%
Final simplification83.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}
\end{array}
Initial program 82.5%
associate-*l*82.5%
Simplified82.5%
Final simplification82.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (or (<= phi2 -0.0008) (not (<= phi2 2.85e-5)))
(atan2 t_0 (- (* (cos phi1) (sin phi2)) (* (cos phi2) (sin phi1))))
(atan2
t_0
(- (* phi2 (cos phi1)) (* (sin phi1) (cos (- lambda2 lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.0008) || !(phi2 <= 2.85e-5)) {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1))));
} else {
tmp = atan2(t_0, ((phi2 * cos(phi1)) - (sin(phi1) * cos((lambda2 - lambda1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi2) * sin((lambda1 - lambda2))
if ((phi2 <= (-0.0008d0)) .or. (.not. (phi2 <= 2.85d-5))) then
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1))))
else
tmp = atan2(t_0, ((phi2 * cos(phi1)) - (sin(phi1) * cos((lambda2 - lambda1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.0008) || !(phi2 <= 2.85e-5)) {
tmp = Math.atan2(t_0, ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * Math.sin(phi1))));
} else {
tmp = Math.atan2(t_0, ((phi2 * Math.cos(phi1)) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if (phi2 <= -0.0008) or not (phi2 <= 2.85e-5): tmp = math.atan2(t_0, ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * math.sin(phi1)))) else: tmp = math.atan2(t_0, ((phi2 * math.cos(phi1)) - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if ((phi2 <= -0.0008) || !(phi2 <= 2.85e-5)) tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * sin(phi1)))); else tmp = atan(t_0, Float64(Float64(phi2 * cos(phi1)) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if ((phi2 <= -0.0008) || ~((phi2 <= 2.85e-5))) tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1)))); else tmp = atan2(t_0, ((phi2 * cos(phi1)) - (sin(phi1) * cos((lambda2 - lambda1))))); 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[phi2, -0.0008], N[Not[LessEqual[phi2, 2.85e-5]], $MachinePrecision]], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.0008 \lor \neg \left(\phi_2 \leq 2.85 \cdot 10^{-5}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\phi_2 \cdot \cos \phi_1 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\end{array}
\end{array}
if phi2 < -8.00000000000000038e-4 or 2.8500000000000002e-5 < phi2 Initial program 79.1%
associate-*l*79.1%
Simplified79.1%
associate-*r*79.1%
add-exp-log36.9%
*-commutative36.9%
Applied egg-rr36.9%
Taylor expanded in lambda1 around 0 35.0%
cos-neg35.0%
*-commutative35.0%
Simplified35.0%
Taylor expanded in lambda2 around 0 61.2%
if -8.00000000000000038e-4 < phi2 < 2.8500000000000002e-5Initial program 85.9%
associate-*l*85.9%
Simplified85.9%
Taylor expanded in phi2 around 0 85.9%
sub-neg85.9%
remove-double-neg85.9%
mul-1-neg85.9%
distribute-neg-in85.9%
+-commutative85.9%
cos-neg85.9%
mul-1-neg85.9%
unsub-neg85.9%
Simplified85.9%
Taylor expanded in phi2 around 0 85.9%
Final simplification73.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi2 2600000.0)
(atan2 t_1 (- t_0 (* (sin phi1) (cos (- lambda2 lambda1)))))
(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 (phi2 <= 2600000.0) {
tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda2 - lambda1)))));
} 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 (phi2 <= 2600000.0d0) then
tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda2 - lambda1)))))
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 (phi2 <= 2600000.0) {
tmp = Math.atan2(t_1, (t_0 - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} 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 phi2 <= 2600000.0: tmp = math.atan2(t_1, (t_0 - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) 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 (phi2 <= 2600000.0) tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); 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 (phi2 <= 2600000.0) tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda2 - lambda1))))); 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[LessEqual[phi2, 2600000.0], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(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}\;\phi_2 \leq 2600000:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \phi_2 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if phi2 < 2.6e6Initial program 84.5%
associate-*l*84.5%
Simplified84.5%
Taylor expanded in phi2 around 0 76.4%
sub-neg76.4%
remove-double-neg76.4%
mul-1-neg76.4%
distribute-neg-in76.4%
+-commutative76.4%
cos-neg76.4%
mul-1-neg76.4%
unsub-neg76.4%
Simplified76.4%
if 2.6e6 < phi2 Initial program 77.2%
associate-*l*77.2%
Simplified77.2%
associate-*r*77.2%
add-exp-log35.4%
*-commutative35.4%
Applied egg-rr35.4%
Taylor expanded in lambda1 around 0 33.9%
cos-neg33.9%
*-commutative33.9%
Simplified33.9%
Taylor expanded in lambda2 around 0 61.5%
Final simplification72.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -0.0022) (not (<= phi2 2600000.0)))
(atan2 (* (cos phi2) t_0) (- (sin phi2) (* (cos lambda1) (sin phi1))))
(atan2
(* t_0 (+ 1.0 (* -0.5 (* phi2 phi2))))
(- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.0022) || !(phi2 <= 2600000.0)) {
tmp = atan2((cos(phi2) * t_0), (sin(phi2) - (cos(lambda1) * sin(phi1))));
} else {
tmp = atan2((t_0 * (1.0 + (-0.5 * (phi2 * phi2)))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if ((phi2 <= (-0.0022d0)) .or. (.not. (phi2 <= 2600000.0d0))) then
tmp = atan2((cos(phi2) * t_0), (sin(phi2) - (cos(lambda1) * sin(phi1))))
else
tmp = atan2((t_0 * (1.0d0 + ((-0.5d0) * (phi2 * phi2)))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.0022) || !(phi2 <= 2600000.0)) {
tmp = Math.atan2((Math.cos(phi2) * t_0), (Math.sin(phi2) - (Math.cos(lambda1) * Math.sin(phi1))));
} else {
tmp = Math.atan2((t_0 * (1.0 + (-0.5 * (phi2 * phi2)))), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi2 <= -0.0022) or not (phi2 <= 2600000.0): tmp = math.atan2((math.cos(phi2) * t_0), (math.sin(phi2) - (math.cos(lambda1) * math.sin(phi1)))) else: tmp = math.atan2((t_0 * (1.0 + (-0.5 * (phi2 * phi2)))), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -0.0022) || !(phi2 <= 2600000.0)) tmp = atan(Float64(cos(phi2) * t_0), Float64(sin(phi2) - Float64(cos(lambda1) * sin(phi1)))); else tmp = atan(Float64(t_0 * Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2)))), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi2 <= -0.0022) || ~((phi2 <= 2600000.0))) tmp = atan2((cos(phi2) * t_0), (sin(phi2) - (cos(lambda1) * sin(phi1)))); else tmp = atan2((t_0 * (1.0 + (-0.5 * (phi2 * phi2)))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.0022], N[Not[LessEqual[phi2, 2600000.0]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$0 * N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.0022 \lor \neg \left(\phi_2 \leq 2600000\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_0}{\sin \phi_2 - \cos \lambda_1 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0 \cdot \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right)}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\end{array}
\end{array}
if phi2 < -0.00220000000000000013 or 2.6e6 < phi2 Initial program 79.2%
associate-*l*79.2%
Simplified79.2%
Taylor expanded in phi2 around 0 53.6%
sub-neg53.6%
remove-double-neg53.6%
mul-1-neg53.6%
distribute-neg-in53.6%
+-commutative53.6%
cos-neg53.6%
mul-1-neg53.6%
unsub-neg53.6%
Simplified53.6%
Taylor expanded in phi1 around 0 50.9%
Taylor expanded in lambda2 around 0 50.7%
cos-neg50.7%
*-commutative50.7%
Simplified50.7%
if -0.00220000000000000013 < phi2 < 2.6e6Initial program 85.7%
associate-*l*85.7%
Simplified85.7%
Taylor expanded in phi2 around 0 85.6%
sub-neg85.6%
remove-double-neg85.6%
mul-1-neg85.6%
distribute-neg-in85.6%
+-commutative85.6%
cos-neg85.6%
mul-1-neg85.6%
unsub-neg85.6%
Simplified85.6%
Taylor expanded in phi1 around 0 85.4%
Taylor expanded in phi2 around 0 85.5%
*-lft-identity53.0%
associate-*r*53.0%
distribute-rgt-out53.0%
unpow253.0%
Simplified85.5%
Final simplification68.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= lambda2 -0.094)
(atan2
(* (cos phi2) (sin (- lambda2)))
(- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1)))))
(if (<= lambda2 1.08e-17)
(atan2 t_0 (- (sin phi2) (* (cos lambda1) (sin phi1))))
(atan2 t_0 (- (sin phi2) (* (cos lambda2) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -0.094) {
tmp = atan2((cos(phi2) * sin(-lambda2)), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
} else if (lambda2 <= 1.08e-17) {
tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1))));
} else {
tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * sin(phi1))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi2) * sin((lambda1 - lambda2))
if (lambda2 <= (-0.094d0)) then
tmp = atan2((cos(phi2) * sin(-lambda2)), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
else if (lambda2 <= 1.08d-17) then
tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1))))
else
tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * sin(phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -0.094) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else if (lambda2 <= 1.08e-17) {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.cos(lambda1) * Math.sin(phi1))));
} else {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.cos(lambda2) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if lambda2 <= -0.094: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) elif lambda2 <= 1.08e-17: tmp = math.atan2(t_0, (math.sin(phi2) - (math.cos(lambda1) * math.sin(phi1)))) else: tmp = math.atan2(t_0, (math.sin(phi2) - (math.cos(lambda2) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (lambda2 <= -0.094) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); elseif (lambda2 <= 1.08e-17) tmp = atan(t_0, Float64(sin(phi2) - Float64(cos(lambda1) * sin(phi1)))); else tmp = atan(t_0, Float64(sin(phi2) - Float64(cos(lambda2) * 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 (lambda2 <= -0.094) tmp = atan2((cos(phi2) * sin(-lambda2)), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); elseif (lambda2 <= 1.08e-17) tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1)))); else tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * 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[LessEqual[lambda2, -0.094], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 1.08e-17], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $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[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_2 \leq -0.094:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{elif}\;\lambda_2 \leq 1.08 \cdot 10^{-17}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\sin \phi_2 - \cos \lambda_1 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\sin \phi_2 - \cos \lambda_2 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if lambda2 < -0.094Initial program 69.4%
associate-*l*69.4%
Simplified69.4%
Taylor expanded in phi2 around 0 56.0%
sub-neg56.0%
remove-double-neg56.0%
mul-1-neg56.0%
distribute-neg-in56.0%
+-commutative56.0%
cos-neg56.0%
mul-1-neg56.0%
unsub-neg56.0%
Simplified56.0%
Taylor expanded in phi1 around 0 54.9%
Taylor expanded in lambda1 around 0 57.3%
if -0.094 < lambda2 < 1.07999999999999995e-17Initial program 98.8%
associate-*l*98.8%
Simplified98.8%
Taylor expanded in phi2 around 0 85.6%
sub-neg85.6%
remove-double-neg85.6%
mul-1-neg85.6%
distribute-neg-in85.6%
+-commutative85.6%
cos-neg85.6%
mul-1-neg85.6%
unsub-neg85.6%
Simplified85.6%
Taylor expanded in phi1 around 0 83.7%
Taylor expanded in lambda2 around 0 83.7%
cos-neg83.7%
*-commutative83.7%
Simplified83.7%
if 1.07999999999999995e-17 < lambda2 Initial program 63.7%
associate-*l*63.7%
Simplified63.7%
Taylor expanded in phi2 around 0 52.7%
sub-neg52.7%
remove-double-neg52.7%
mul-1-neg52.7%
distribute-neg-in52.7%
+-commutative52.7%
cos-neg52.7%
mul-1-neg52.7%
unsub-neg52.7%
Simplified52.7%
Taylor expanded in phi1 around 0 52.0%
Taylor expanded in lambda1 around 0 51.9%
*-commutative51.9%
Simplified51.9%
Final simplification69.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda1 -7e+26)
(atan2
(* (sin lambda1) (cos phi2))
(- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- (sin phi2) (* (cos lambda2) (sin phi1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -7e+26) {
tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda2) * sin(phi1))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda1 <= (-7d+26)) then
tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda2) * sin(phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -7e+26) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.cos(lambda2) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -7e+26: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.cos(lambda2) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -7e+26) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(cos(lambda2) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -7e+26) tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda2) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -7e+26], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $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[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -7 \cdot 10^{+26}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \lambda_2 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if lambda1 < -6.9999999999999998e26Initial program 61.2%
associate-*l*61.2%
Simplified61.2%
Taylor expanded in phi2 around 0 52.0%
sub-neg52.0%
remove-double-neg52.0%
mul-1-neg52.0%
distribute-neg-in52.0%
+-commutative52.0%
cos-neg52.0%
mul-1-neg52.0%
unsub-neg52.0%
Simplified52.0%
Taylor expanded in phi1 around 0 51.7%
Taylor expanded in lambda2 around 0 51.8%
if -6.9999999999999998e26 < lambda1 Initial program 87.5%
associate-*l*87.6%
Simplified87.6%
Taylor expanded in phi2 around 0 74.0%
sub-neg74.0%
remove-double-neg74.0%
mul-1-neg74.0%
distribute-neg-in74.0%
+-commutative74.0%
cos-neg74.0%
mul-1-neg74.0%
unsub-neg74.0%
Simplified74.0%
Taylor expanded in phi1 around 0 72.4%
Taylor expanded in lambda1 around 0 71.1%
*-commutative71.1%
Simplified71.1%
Final simplification67.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 82.5%
associate-*l*82.5%
Simplified82.5%
Taylor expanded in phi2 around 0 69.8%
sub-neg69.8%
remove-double-neg69.8%
mul-1-neg69.8%
distribute-neg-in69.8%
+-commutative69.8%
cos-neg69.8%
mul-1-neg69.8%
unsub-neg69.8%
Simplified69.8%
Taylor expanded in phi1 around 0 68.4%
Final simplification68.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))) (t_1 (* (cos phi2) t_0)))
(if (<= phi2 -0.0046)
(atan2 t_1 (- (sin phi2) (* (cos lambda2) phi1)))
(if (<= phi2 2600000.0)
(atan2
(* t_0 (+ 1.0 (* -0.5 (* phi2 phi2))))
(- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1)))))
(atan2 t_1 (- (sin phi2) (* (cos lambda1) phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = cos(phi2) * t_0;
double tmp;
if (phi2 <= -0.0046) {
tmp = atan2(t_1, (sin(phi2) - (cos(lambda2) * phi1)));
} else if (phi2 <= 2600000.0) {
tmp = atan2((t_0 * (1.0 + (-0.5 * (phi2 * phi2)))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = atan2(t_1, (sin(phi2) - (cos(lambda1) * phi1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
t_1 = cos(phi2) * t_0
if (phi2 <= (-0.0046d0)) then
tmp = atan2(t_1, (sin(phi2) - (cos(lambda2) * phi1)))
else if (phi2 <= 2600000.0d0) then
tmp = atan2((t_0 * (1.0d0 + ((-0.5d0) * (phi2 * phi2)))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
else
tmp = atan2(t_1, (sin(phi2) - (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.sin((lambda1 - lambda2));
double t_1 = Math.cos(phi2) * t_0;
double tmp;
if (phi2 <= -0.0046) {
tmp = Math.atan2(t_1, (Math.sin(phi2) - (Math.cos(lambda2) * phi1)));
} else if (phi2 <= 2600000.0) {
tmp = Math.atan2((t_0 * (1.0 + (-0.5 * (phi2 * phi2)))), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2(t_1, (Math.sin(phi2) - (Math.cos(lambda1) * phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = math.cos(phi2) * t_0 tmp = 0 if phi2 <= -0.0046: tmp = math.atan2(t_1, (math.sin(phi2) - (math.cos(lambda2) * phi1))) elif phi2 <= 2600000.0: tmp = math.atan2((t_0 * (1.0 + (-0.5 * (phi2 * phi2)))), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2(t_1, (math.sin(phi2) - (math.cos(lambda1) * phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi2) * t_0) tmp = 0.0 if (phi2 <= -0.0046) tmp = atan(t_1, Float64(sin(phi2) - Float64(cos(lambda2) * phi1))); elseif (phi2 <= 2600000.0) tmp = atan(Float64(t_0 * Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2)))), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = atan(t_1, Float64(sin(phi2) - Float64(cos(lambda1) * phi1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = cos(phi2) * t_0; tmp = 0.0; if (phi2 <= -0.0046) tmp = atan2(t_1, (sin(phi2) - (cos(lambda2) * phi1))); elseif (phi2 <= 2600000.0) tmp = atan2((t_0 * (1.0 + (-0.5 * (phi2 * phi2)))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); else tmp = atan2(t_1, (sin(phi2) - (cos(lambda1) * phi1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[phi2, -0.0046], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda2], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 2600000.0], N[ArcTan[N[(t$95$0 * N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_2 \cdot t_0\\
\mathbf{if}\;\phi_2 \leq -0.0046:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{\sin \phi_2 - \cos \lambda_2 \cdot \phi_1}\\
\mathbf{elif}\;\phi_2 \leq 2600000:\\
\;\;\;\;\tan^{-1}_* \frac{t_0 \cdot \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right)}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{\sin \phi_2 - \cos \lambda_1 \cdot \phi_1}\\
\end{array}
\end{array}
if phi2 < -0.0045999999999999999Initial program 81.7%
associate-*l*81.7%
Simplified81.7%
Taylor expanded in phi2 around 0 55.0%
sub-neg55.0%
remove-double-neg55.0%
mul-1-neg55.0%
distribute-neg-in55.0%
+-commutative55.0%
cos-neg55.0%
mul-1-neg55.0%
unsub-neg55.0%
Simplified55.0%
Taylor expanded in phi1 around 0 53.3%
Taylor expanded in phi1 around 0 47.9%
Taylor expanded in lambda1 around 0 48.4%
if -0.0045999999999999999 < phi2 < 2.6e6Initial program 85.7%
associate-*l*85.7%
Simplified85.7%
Taylor expanded in phi2 around 0 85.6%
sub-neg85.6%
remove-double-neg85.6%
mul-1-neg85.6%
distribute-neg-in85.6%
+-commutative85.6%
cos-neg85.6%
mul-1-neg85.6%
unsub-neg85.6%
Simplified85.6%
Taylor expanded in phi1 around 0 85.4%
Taylor expanded in phi2 around 0 85.5%
*-lft-identity53.0%
associate-*r*53.0%
distribute-rgt-out53.0%
unpow253.0%
Simplified85.5%
if 2.6e6 < phi2 Initial program 77.2%
associate-*l*77.2%
Simplified77.2%
Taylor expanded in phi2 around 0 52.5%
sub-neg52.5%
remove-double-neg52.5%
mul-1-neg52.5%
distribute-neg-in52.5%
+-commutative52.5%
cos-neg52.5%
mul-1-neg52.5%
unsub-neg52.5%
Simplified52.5%
Taylor expanded in phi1 around 0 48.9%
Taylor expanded in phi1 around 0 44.3%
Taylor expanded in lambda2 around 0 44.7%
cos-neg44.7%
Simplified44.7%
Final simplification66.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (or (<= phi1 -1750.0) (not (<= phi1 33000000000.0)))
(atan2
t_0
(- (sin phi2) (* (sin phi1) (+ 1.0 (* -0.5 (* lambda1 lambda1))))))
(atan2 t_0 (- (sin phi2) (* phi1 (cos (- lambda2 lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -1750.0) || !(phi1 <= 33000000000.0)) {
tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * (1.0 + (-0.5 * (lambda1 * lambda1))))));
} else {
tmp = atan2(t_0, (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi2) * sin((lambda1 - lambda2))
if ((phi1 <= (-1750.0d0)) .or. (.not. (phi1 <= 33000000000.0d0))) then
tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * (1.0d0 + ((-0.5d0) * (lambda1 * lambda1))))))
else
tmp = atan2(t_0, (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -1750.0) || !(phi1 <= 33000000000.0)) {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.sin(phi1) * (1.0 + (-0.5 * (lambda1 * lambda1))))));
} else {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if (phi1 <= -1750.0) or not (phi1 <= 33000000000.0): tmp = math.atan2(t_0, (math.sin(phi2) - (math.sin(phi1) * (1.0 + (-0.5 * (lambda1 * lambda1)))))) else: tmp = math.atan2(t_0, (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if ((phi1 <= -1750.0) || !(phi1 <= 33000000000.0)) tmp = atan(t_0, Float64(sin(phi2) - Float64(sin(phi1) * Float64(1.0 + Float64(-0.5 * Float64(lambda1 * lambda1)))))); else tmp = atan(t_0, Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -1750.0) || ~((phi1 <= 33000000000.0))) tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * (1.0 + (-0.5 * (lambda1 * lambda1)))))); else tmp = atan2(t_0, (sin(phi2) - (phi1 * cos((lambda2 - lambda1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -1750.0], N[Not[LessEqual[phi1, 33000000000.0]], $MachinePrecision]], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(lambda1 * lambda1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1750 \lor \neg \left(\phi_1 \leq 33000000000\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\sin \phi_2 - \sin \phi_1 \cdot \left(1 + -0.5 \cdot \left(\lambda_1 \cdot \lambda_1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\end{array}
\end{array}
if phi1 < -1750 or 3.3e10 < phi1 Initial program 79.2%
associate-*l*79.2%
Simplified79.2%
Taylor expanded in phi2 around 0 53.7%
sub-neg53.7%
remove-double-neg53.7%
mul-1-neg53.7%
distribute-neg-in53.7%
+-commutative53.7%
cos-neg53.7%
mul-1-neg53.7%
unsub-neg53.7%
Simplified53.7%
Taylor expanded in phi1 around 0 51.5%
Taylor expanded in lambda1 around 0 43.7%
fma-def43.7%
unpow243.7%
Simplified43.7%
Taylor expanded in lambda2 around 0 30.8%
unpow230.8%
Simplified30.8%
if -1750 < phi1 < 3.3e10Initial program 85.3%
associate-*l*85.3%
Simplified85.3%
Taylor expanded in phi2 around 0 83.2%
sub-neg83.2%
remove-double-neg83.2%
mul-1-neg83.2%
distribute-neg-in83.2%
+-commutative83.2%
cos-neg83.2%
mul-1-neg83.2%
unsub-neg83.2%
Simplified83.2%
Taylor expanded in phi1 around 0 82.5%
Taylor expanded in phi1 around 0 82.6%
Final simplification59.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- (sin phi2) (* phi1 (cos (- lambda2 lambda1))))))
(if (or (<= phi2 -0.21) (not (<= phi2 0.0245)))
(atan2 (* (sin lambda1) (cos phi2)) t_0)
(atan2
(* (sin (- lambda1 lambda2)) (+ 1.0 (* -0.5 (* phi2 phi2))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) - (phi1 * cos((lambda2 - lambda1)));
double tmp;
if ((phi2 <= -0.21) || !(phi2 <= 0.0245)) {
tmp = atan2((sin(lambda1) * cos(phi2)), t_0);
} else {
tmp = atan2((sin((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi2 * phi2)))), t_0);
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin(phi2) - (phi1 * cos((lambda2 - lambda1)))
if ((phi2 <= (-0.21d0)) .or. (.not. (phi2 <= 0.0245d0))) then
tmp = atan2((sin(lambda1) * cos(phi2)), t_0)
else
tmp = atan2((sin((lambda1 - lambda2)) * (1.0d0 + ((-0.5d0) * (phi2 * phi2)))), t_0)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)));
double tmp;
if ((phi2 <= -0.21) || !(phi2 <= 0.0245)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), t_0);
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi2 * phi2)))), t_0);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1))) tmp = 0 if (phi2 <= -0.21) or not (phi2 <= 0.0245): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), t_0) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi2 * phi2)))), t_0) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1)))) tmp = 0.0 if ((phi2 <= -0.21) || !(phi2 <= 0.0245)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), t_0); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2)))), t_0); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi2) - (phi1 * cos((lambda2 - lambda1))); tmp = 0.0; if ((phi2 <= -0.21) || ~((phi2 <= 0.0245))) tmp = atan2((sin(lambda1) * cos(phi2)), t_0); else tmp = atan2((sin((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi2 * phi2)))), t_0); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -0.21], N[Not[LessEqual[phi2, 0.0245]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_2 \leq -0.21 \lor \neg \left(\phi_2 \leq 0.0245\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right)}{t_0}\\
\end{array}
\end{array}
if phi2 < -0.209999999999999992 or 0.024500000000000001 < phi2 Initial program 78.9%
associate-*l*78.9%
Simplified78.9%
Taylor expanded in phi2 around 0 53.3%
sub-neg53.3%
remove-double-neg53.3%
mul-1-neg53.3%
distribute-neg-in53.3%
+-commutative53.3%
cos-neg53.3%
mul-1-neg53.3%
unsub-neg53.3%
Simplified53.3%
Taylor expanded in phi1 around 0 50.6%
Taylor expanded in phi1 around 0 45.7%
Taylor expanded in lambda2 around 0 28.6%
if -0.209999999999999992 < phi2 < 0.024500000000000001Initial program 86.1%
associate-*l*86.1%
Simplified86.1%
Taylor expanded in phi2 around 0 86.1%
sub-neg86.1%
remove-double-neg86.1%
mul-1-neg86.1%
distribute-neg-in86.1%
+-commutative86.1%
cos-neg86.1%
mul-1-neg86.1%
unsub-neg86.1%
Simplified86.1%
Taylor expanded in phi1 around 0 85.9%
Taylor expanded in phi1 around 0 53.3%
Taylor expanded in phi2 around 0 53.3%
*-lft-identity53.3%
associate-*r*53.3%
distribute-rgt-out53.3%
unpow253.3%
Simplified53.3%
Final simplification41.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) (* (cos lambda1) phi1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda1) * phi1)));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda1) * phi1)))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.cos(lambda1) * phi1)));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.cos(lambda1) * phi1)))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(cos(lambda1) * phi1))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda1) * phi1))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \lambda_1 \cdot \phi_1}
\end{array}
Initial program 82.5%
associate-*l*82.5%
Simplified82.5%
Taylor expanded in phi2 around 0 69.8%
sub-neg69.8%
remove-double-neg69.8%
mul-1-neg69.8%
distribute-neg-in69.8%
+-commutative69.8%
cos-neg69.8%
mul-1-neg69.8%
unsub-neg69.8%
Simplified69.8%
Taylor expanded in phi1 around 0 68.4%
Taylor expanded in phi1 around 0 49.5%
Taylor expanded in lambda2 around 0 49.5%
cos-neg49.5%
Simplified49.5%
Final simplification49.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (+ 1.0 (* -0.5 (* phi2 phi2)))) (- (sin phi2) (* phi1 (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi2 * phi2)))), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * (1.0d0 + ((-0.5d0) * (phi2 * phi2)))), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi2 * phi2)))), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi2 * phi2)))), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2)))), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi2 * phi2)))), (sin(phi2) - (phi1 * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right)}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 82.5%
associate-*l*82.5%
Simplified82.5%
Taylor expanded in phi2 around 0 69.8%
sub-neg69.8%
remove-double-neg69.8%
mul-1-neg69.8%
distribute-neg-in69.8%
+-commutative69.8%
cos-neg69.8%
mul-1-neg69.8%
unsub-neg69.8%
Simplified69.8%
Taylor expanded in phi1 around 0 68.4%
Taylor expanded in phi1 around 0 49.5%
Taylor expanded in phi2 around 0 31.8%
*-lft-identity31.8%
associate-*r*31.8%
distribute-rgt-out31.8%
unpow231.8%
Simplified31.8%
Final simplification31.8%
herbie shell --seed 2023271
(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))))))