
(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 27 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.1%
sin-diff91.1%
Applied egg-rr91.1%
cos-diff99.7%
+-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(t_2 (* (cos phi2) (sin phi1))))
(if (or (<= phi2 -5.5e-6) (not (<= phi2 1e-64)))
(atan2 (* t_1 (cos phi2)) (- t_0 (* t_2 (cos (- lambda1 lambda2)))))
(atan2
t_1
(-
t_0
(*
t_2
(+
(* (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 = (sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2));
double t_2 = cos(phi2) * sin(phi1);
double tmp;
if ((phi2 <= -5.5e-6) || !(phi2 <= 1e-64)) {
tmp = atan2((t_1 * cos(phi2)), (t_0 - (t_2 * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_1, (t_0 - (t_2 * ((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) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = (sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))
t_2 = cos(phi2) * sin(phi1)
if ((phi2 <= (-5.5d-6)) .or. (.not. (phi2 <= 1d-64))) then
tmp = atan2((t_1 * cos(phi2)), (t_0 - (t_2 * cos((lambda1 - lambda2)))))
else
tmp = atan2(t_1, (t_0 - (t_2 * ((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.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2));
double t_2 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if ((phi2 <= -5.5e-6) || !(phi2 <= 1e-64)) {
tmp = Math.atan2((t_1 * Math.cos(phi2)), (t_0 - (t_2 * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2(t_1, (t_0 - (t_2 * ((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.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)) t_2 = math.cos(phi2) * math.sin(phi1) tmp = 0 if (phi2 <= -5.5e-6) or not (phi2 <= 1e-64): tmp = math.atan2((t_1 * math.cos(phi2)), (t_0 - (t_2 * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2(t_1, (t_0 - (t_2 * ((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(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) t_2 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if ((phi2 <= -5.5e-6) || !(phi2 <= 1e-64)) tmp = atan(Float64(t_1 * cos(phi2)), Float64(t_0 - Float64(t_2 * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_1, Float64(t_0 - Float64(t_2 * 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 = (sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)); t_2 = cos(phi2) * sin(phi1); tmp = 0.0; if ((phi2 <= -5.5e-6) || ~((phi2 <= 1e-64))) tmp = atan2((t_1 * cos(phi2)), (t_0 - (t_2 * cos((lambda1 - lambda2))))); else tmp = atan2(t_1, (t_0 - (t_2 * ((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[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -5.5e-6], N[Not[LessEqual[phi2, 1e-64]], $MachinePrecision]], N[ArcTan[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$2 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(t$95$2 * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\\
t_2 := \cos \phi_2 \cdot \sin \phi_1\\
\mathbf{if}\;\phi_2 \leq -5.5 \cdot 10^{-6} \lor \neg \left(\phi_2 \leq 10^{-64}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_1 \cdot \cos \phi_2}{t_0 - t_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - t_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)}\\
\end{array}
\end{array}
if phi2 < -5.4999999999999999e-6 or 9.99999999999999965e-65 < phi2 Initial program 81.1%
sin-diff91.5%
Applied egg-rr91.5%
if -5.4999999999999999e-6 < phi2 < 9.99999999999999965e-65Initial program 83.4%
sin-diff90.5%
Applied egg-rr90.5%
cos-diff99.9%
+-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in phi2 around 0 99.9%
*-commutative99.9%
Simplified99.9%
Final simplification95.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -0.0034) (not (<= lambda2 2e-22)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* (cos phi2) (* (cos lambda2) (sin phi1)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (cos phi2) (* (cos lambda1) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda2 <= -0.0034) || !(lambda2 <= 2e-22)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda2 <= (-0.0034d0)) .or. (.not. (lambda2 <= 2d-22))) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda2 <= -0.0034) || !(lambda2 <= 2e-22)) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.cos(phi2) * (Math.cos(lambda1) * Math.sin(phi1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda2 <= -0.0034) or not (lambda2 <= 2e-22): tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.cos(phi2) * (math.cos(lambda1) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda2 <= -0.0034) || !(lambda2 <= 2e-22)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda1) * sin(phi1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda2 <= -0.0034) || ~((lambda2 <= 2e-22))) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -0.0034], N[Not[LessEqual[lambda2, 2e-22]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -0.0034 \lor \neg \left(\lambda_2 \leq 2 \cdot 10^{-22}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if lambda2 < -0.00339999999999999981 or 2.0000000000000001e-22 < lambda2 Initial program 64.2%
sin-diff82.3%
Applied egg-rr82.3%
Taylor expanded in lambda1 around 0 82.5%
cos-neg82.5%
*-commutative82.5%
Simplified82.5%
if -0.00339999999999999981 < lambda2 < 2.0000000000000001e-22Initial program 99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in lambda2 around 0 99.7%
Final simplification91.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))))
(if (or (<= lambda2 -7e+20) (not (<= lambda2 2e-22)))
(atan2 t_1 (- t_0 (* (cos phi2) (* (cos lambda2) (sin phi1)))))
(atan2 t_1 (- t_0 (* (cos lambda1) (* (cos phi2) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double tmp;
if ((lambda2 <= -7e+20) || !(lambda2 <= 2e-22)) {
tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))));
} else {
tmp = atan2(t_1, (t_0 - (cos(lambda1) * (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 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)
if ((lambda2 <= (-7d+20)) .or. (.not. (lambda2 <= 2d-22))) then
tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
else
tmp = atan2(t_1, (t_0 - (cos(lambda1) * (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.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2);
double tmp;
if ((lambda2 <= -7e+20) || !(lambda2 <= 2e-22)) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(lambda1) * (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.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2) tmp = 0 if (lambda2 <= -7e+20) or not (lambda2 <= 2e-22): tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) else: tmp = math.atan2(t_1, (t_0 - (math.cos(lambda1) * (math.cos(phi2) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) tmp = 0.0 if ((lambda2 <= -7e+20) || !(lambda2 <= 2e-22)) tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))); else tmp = atan(t_1, Float64(t_0 - Float64(cos(lambda1) * 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 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2); tmp = 0.0; if ((lambda2 <= -7e+20) || ~((lambda2 <= 2e-22))) tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1))))); else tmp = atan2(t_1, (t_0 - (cos(lambda1) * (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[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -7e+20], N[Not[LessEqual[lambda2, 2e-22]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -7 \cdot 10^{+20} \lor \neg \left(\lambda_2 \leq 2 \cdot 10^{-22}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \lambda_1 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if lambda2 < -7e20 or 2.0000000000000001e-22 < lambda2 Initial program 64.9%
sin-diff83.0%
Applied egg-rr83.0%
Taylor expanded in lambda1 around 0 83.3%
cos-neg83.3%
*-commutative83.3%
Simplified83.3%
if -7e20 < lambda2 < 2.0000000000000001e-22Initial program 98.2%
sin-diff98.6%
Applied egg-rr98.6%
Taylor expanded in lambda2 around 0 98.6%
Final simplification91.2%
(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.1%
sin-diff91.1%
Applied egg-rr91.1%
Final simplification91.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (sin phi1) t_1))
(t_3 (sin (- lambda1 lambda2))))
(if (<= phi1 -6.4e-10)
(atan2 (* (cos phi2) t_3) (- t_0 (* (cos phi2) t_2)))
(if (<= phi1 1.7e-59)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 t_2))
(atan2
(* (cos phi2) (log1p (expm1 t_3)))
(- t_0 (* (* (cos phi2) (sin phi1)) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin(phi1) * t_1;
double t_3 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -6.4e-10) {
tmp = atan2((cos(phi2) * t_3), (t_0 - (cos(phi2) * t_2)));
} else if (phi1 <= 1.7e-59) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - t_2));
} else {
tmp = atan2((cos(phi2) * log1p(expm1(t_3))), (t_0 - ((cos(phi2) * sin(phi1)) * t_1)));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.sin(phi1) * t_1;
double t_3 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -6.4e-10) {
tmp = Math.atan2((Math.cos(phi2) * t_3), (t_0 - (Math.cos(phi2) * t_2)));
} else if (phi1 <= 1.7e-59) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - t_2));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.log1p(Math.expm1(t_3))), (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.sin(phi1) * t_1 t_3 = math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -6.4e-10: tmp = math.atan2((math.cos(phi2) * t_3), (t_0 - (math.cos(phi2) * t_2))) elif phi1 <= 1.7e-59: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - t_2)) else: tmp = math.atan2((math.cos(phi2) * math.log1p(math.expm1(t_3))), (t_0 - ((math.cos(phi2) * math.sin(phi1)) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(sin(phi1) * t_1) t_3 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -6.4e-10) tmp = atan(Float64(cos(phi2) * t_3), Float64(t_0 - Float64(cos(phi2) * t_2))); elseif (phi1 <= 1.7e-59) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - t_2)); else tmp = atan(Float64(cos(phi2) * log1p(expm1(t_3))), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * 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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -6.4e-10], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.7e-59], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - t$95$2), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Log[1 + N[(Exp[t$95$3] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \phi_1 \cdot t_1\\
t_3 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -6.4 \cdot 10^{-10}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_3}{t_0 - \cos \phi_2 \cdot t_2}\\
\mathbf{elif}\;\phi_1 \leq 1.7 \cdot 10^{-59}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - t_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(t_3\right)\right)}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_1}\\
\end{array}
\end{array}
if phi1 < -6.39999999999999961e-10Initial program 76.8%
*-commutative76.8%
associate-*l*76.8%
Simplified76.8%
if -6.39999999999999961e-10 < phi1 < 1.70000000000000009e-59Initial program 83.3%
sin-diff99.8%
Applied egg-rr99.8%
Taylor expanded in phi2 around 0 99.8%
if 1.70000000000000009e-59 < phi1 Initial program 85.4%
log1p-expm1-u85.4%
Applied egg-rr85.4%
Final simplification89.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (sin (- lambda1 lambda2))))
(if (<= phi1 -3.7e-13)
(atan2 (* (cos phi2) t_2) (- t_0 (* (cos phi2) (* (sin phi1) t_1))))
(if (<= phi1 1.7e-59)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* (cos lambda1) (sin phi1))))
(atan2
(* (cos phi2) (log1p (expm1 t_2)))
(- t_0 (* (* (cos phi2) (sin phi1)) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -3.7e-13) {
tmp = atan2((cos(phi2) * t_2), (t_0 - (cos(phi2) * (sin(phi1) * t_1))));
} else if (phi1 <= 1.7e-59) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * sin(phi1))));
} else {
tmp = atan2((cos(phi2) * log1p(expm1(t_2))), (t_0 - ((cos(phi2) * sin(phi1)) * t_1)));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -3.7e-13) {
tmp = Math.atan2((Math.cos(phi2) * t_2), (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * t_1))));
} else if (phi1 <= 1.7e-59) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (Math.cos(lambda1) * Math.sin(phi1))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.log1p(Math.expm1(t_2))), (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -3.7e-13: tmp = math.atan2((math.cos(phi2) * t_2), (t_0 - (math.cos(phi2) * (math.sin(phi1) * t_1)))) elif phi1 <= 1.7e-59: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (math.cos(lambda1) * math.sin(phi1)))) else: tmp = math.atan2((math.cos(phi2) * math.log1p(math.expm1(t_2))), (t_0 - ((math.cos(phi2) * math.sin(phi1)) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -3.7e-13) tmp = atan(Float64(cos(phi2) * t_2), Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * t_1)))); elseif (phi1 <= 1.7e-59) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(cos(lambda1) * sin(phi1)))); else tmp = atan(Float64(cos(phi2) * log1p(expm1(t_2))), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * 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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -3.7e-13], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.7e-59], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Log[1 + N[(Exp[t$95$2] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -3.7 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_2}{t_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot t_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 1.7 \cdot 10^{-59}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \cos \lambda_1 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(t_2\right)\right)}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_1}\\
\end{array}
\end{array}
if phi1 < -3.69999999999999989e-13Initial program 77.1%
*-commutative77.1%
associate-*l*77.1%
Simplified77.1%
if -3.69999999999999989e-13 < phi1 < 1.70000000000000009e-59Initial program 83.1%
sin-diff99.8%
Applied egg-rr99.8%
Taylor expanded in lambda2 around 0 99.8%
Taylor expanded in phi2 around 0 99.8%
if 1.70000000000000009e-59 < phi1 Initial program 85.4%
log1p-expm1-u85.4%
Applied egg-rr85.4%
Final simplification89.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (cos phi2) (sin phi1)))
(t_3 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi2 -61.0)
(atan2 t_3 (- t_0 (* t_1 (expm1 (log1p t_2)))))
(if (<= phi2 1.35e-7)
(atan2
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(- t_0 (* (sin phi1) t_1)))
(atan2 t_3 (- t_0 (* t_2 t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = cos(phi2) * sin(phi1);
double t_3 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -61.0) {
tmp = atan2(t_3, (t_0 - (t_1 * expm1(log1p(t_2)))));
} else if (phi2 <= 1.35e-7) {
tmp = atan2(((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))), (t_0 - (sin(phi1) * t_1)));
} else {
tmp = atan2(t_3, (t_0 - (t_2 * t_1)));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.cos(phi2) * Math.sin(phi1);
double t_3 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -61.0) {
tmp = Math.atan2(t_3, (t_0 - (t_1 * Math.expm1(Math.log1p(t_2)))));
} else if (phi2 <= 1.35e-7) {
tmp = Math.atan2(((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))), (t_0 - (Math.sin(phi1) * t_1)));
} else {
tmp = Math.atan2(t_3, (t_0 - (t_2 * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.cos(phi2) * math.sin(phi1) t_3 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= -61.0: tmp = math.atan2(t_3, (t_0 - (t_1 * math.expm1(math.log1p(t_2))))) elif phi2 <= 1.35e-7: tmp = math.atan2(((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))), (t_0 - (math.sin(phi1) * t_1))) else: tmp = math.atan2(t_3, (t_0 - (t_2 * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(cos(phi2) * sin(phi1)) t_3 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi2 <= -61.0) tmp = atan(t_3, Float64(t_0 - Float64(t_1 * expm1(log1p(t_2))))); elseif (phi2 <= 1.35e-7) tmp = atan(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))), Float64(t_0 - Float64(sin(phi1) * t_1))); else tmp = atan(t_3, Float64(t_0 - Float64(t_2 * t_1))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -61.0], N[ArcTan[t$95$3 / N[(t$95$0 - N[(t$95$1 * N[(Exp[N[Log[1 + t$95$2], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 1.35e-7], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$3 / N[(t$95$0 - N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_2 \cdot \sin \phi_1\\
t_3 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -61:\\
\;\;\;\;\tan^{-1}_* \frac{t_3}{t_0 - t_1 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(t_2\right)\right)}\\
\mathbf{elif}\;\phi_2 \leq 1.35 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2}{t_0 - \sin \phi_1 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_3}{t_0 - t_2 \cdot t_1}\\
\end{array}
\end{array}
if phi2 < -61Initial program 80.0%
expm1-log1p-u80.1%
Applied egg-rr80.1%
if -61 < phi2 < 1.35000000000000004e-7Initial program 83.8%
Taylor expanded in phi2 around 0 83.8%
Taylor expanded in phi2 around 0 83.9%
sin-diff91.0%
Applied egg-rr90.9%
if 1.35000000000000004e-7 < phi2 Initial program 80.8%
Final simplification85.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (sin phi1) t_1))
(t_3 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi2 -61.0)
(atan2 t_3 (- t_0 (* (cos phi2) t_2)))
(if (<= phi2 1.35e-7)
(atan2
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(- t_0 t_2))
(atan2 t_3 (- t_0 (* (* (cos phi2) (sin phi1)) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin(phi1) * t_1;
double t_3 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -61.0) {
tmp = atan2(t_3, (t_0 - (cos(phi2) * t_2)));
} else if (phi2 <= 1.35e-7) {
tmp = atan2(((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))), (t_0 - t_2));
} else {
tmp = atan2(t_3, (t_0 - ((cos(phi2) * sin(phi1)) * t_1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
t_2 = sin(phi1) * t_1
t_3 = cos(phi2) * sin((lambda1 - lambda2))
if (phi2 <= (-61.0d0)) then
tmp = atan2(t_3, (t_0 - (cos(phi2) * t_2)))
else if (phi2 <= 1.35d-7) then
tmp = atan2(((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))), (t_0 - t_2))
else
tmp = atan2(t_3, (t_0 - ((cos(phi2) * sin(phi1)) * t_1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.sin(phi1) * t_1;
double t_3 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -61.0) {
tmp = Math.atan2(t_3, (t_0 - (Math.cos(phi2) * t_2)));
} else if (phi2 <= 1.35e-7) {
tmp = Math.atan2(((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))), (t_0 - t_2));
} else {
tmp = Math.atan2(t_3, (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.sin(phi1) * t_1 t_3 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= -61.0: tmp = math.atan2(t_3, (t_0 - (math.cos(phi2) * t_2))) elif phi2 <= 1.35e-7: tmp = math.atan2(((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))), (t_0 - t_2)) else: tmp = math.atan2(t_3, (t_0 - ((math.cos(phi2) * math.sin(phi1)) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(sin(phi1) * t_1) t_3 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi2 <= -61.0) tmp = atan(t_3, Float64(t_0 - Float64(cos(phi2) * t_2))); elseif (phi2 <= 1.35e-7) tmp = atan(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))), Float64(t_0 - t_2)); else tmp = atan(t_3, Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); t_2 = sin(phi1) * t_1; t_3 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= -61.0) tmp = atan2(t_3, (t_0 - (cos(phi2) * t_2))); elseif (phi2 <= 1.35e-7) tmp = atan2(((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))), (t_0 - t_2)); else tmp = atan2(t_3, (t_0 - ((cos(phi2) * sin(phi1)) * t_1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -61.0], N[ArcTan[t$95$3 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 1.35e-7], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - t$95$2), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$3 / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \phi_1 \cdot t_1\\
t_3 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -61:\\
\;\;\;\;\tan^{-1}_* \frac{t_3}{t_0 - \cos \phi_2 \cdot t_2}\\
\mathbf{elif}\;\phi_2 \leq 1.35 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2}{t_0 - t_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_3}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_1}\\
\end{array}
\end{array}
if phi2 < -61Initial program 80.0%
*-commutative80.0%
associate-*l*80.0%
Simplified80.0%
if -61 < phi2 < 1.35000000000000004e-7Initial program 83.8%
Taylor expanded in phi2 around 0 83.8%
Taylor expanded in phi2 around 0 83.9%
sin-diff91.0%
Applied egg-rr90.9%
if 1.35000000000000004e-7 < phi2 Initial program 80.8%
Final simplification85.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (cos phi2) (sin phi1))))
(if (or (<= lambda1 -1e+27) (not (<= lambda1 420000.0)))
(atan2
(* (cos phi2) (sin (+ lambda1 lambda2)))
(- t_0 (* (cos lambda1) t_1)))
(atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- t_0 t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double tmp;
if ((lambda1 <= -1e+27) || !(lambda1 <= 420000.0)) {
tmp = atan2((cos(phi2) * sin((lambda1 + lambda2))), (t_0 - (cos(lambda1) * t_1)));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - t_1));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
if ((lambda1 <= (-1d+27)) .or. (.not. (lambda1 <= 420000.0d0))) then
tmp = atan2((cos(phi2) * sin((lambda1 + lambda2))), (t_0 - (cos(lambda1) * t_1)))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - t_1))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if ((lambda1 <= -1e+27) || !(lambda1 <= 420000.0)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 + lambda2))), (t_0 - (Math.cos(lambda1) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - t_1));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) tmp = 0 if (lambda1 <= -1e+27) or not (lambda1 <= 420000.0): tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 + lambda2))), (t_0 - (math.cos(lambda1) * t_1))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - t_1)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if ((lambda1 <= -1e+27) || !(lambda1 <= 420000.0)) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 + lambda2))), Float64(t_0 - Float64(cos(lambda1) * t_1))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - t_1)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin(phi1); tmp = 0.0; if ((lambda1 <= -1e+27) || ~((lambda1 <= 420000.0))) tmp = atan2((cos(phi2) * sin((lambda1 + lambda2))), (t_0 - (cos(lambda1) * t_1))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - t_1)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -1e+27], N[Not[LessEqual[lambda1, 420000.0]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 + lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - t$95$1), $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 -1 \cdot 10^{+27} \lor \neg \left(\lambda_1 \leq 420000\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 + \lambda_2\right)}{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}\\
\end{array}
\end{array}
if lambda1 < -1e27 or 4.2e5 < lambda1 Initial program 63.7%
sin-diff82.1%
Applied egg-rr82.1%
Taylor expanded in lambda2 around 0 82.1%
sin-diff63.7%
expm1-log1p-u63.7%
expm1-udef63.4%
Applied egg-rr63.7%
expm1-def64.0%
expm1-log1p64.0%
Simplified64.0%
if -1e27 < lambda1 < 4.2e5Initial program 98.6%
Taylor expanded in lambda2 around 0 78.3%
Taylor expanded in lambda1 around 0 82.5%
Final simplification73.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_2 (* (cos phi2) (sin phi1))))
(if (<= lambda1 -7600000000000.0)
(atan2 t_1 (- t_0 (* (cos phi2) (* (cos lambda1) (sin phi1)))))
(if (<= lambda1 19000.0)
(atan2 t_1 (- t_0 (* (cos lambda2) t_2)))
(atan2
(* (cos phi2) (sin (+ lambda1 lambda2)))
(- t_0 (* (cos lambda1) t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double t_2 = cos(phi2) * sin(phi1);
double tmp;
if (lambda1 <= -7600000000000.0) {
tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))));
} else if (lambda1 <= 19000.0) {
tmp = atan2(t_1, (t_0 - (cos(lambda2) * t_2)));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 + lambda2))), (t_0 - (cos(lambda1) * t_2)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin((lambda1 - lambda2))
t_2 = cos(phi2) * sin(phi1)
if (lambda1 <= (-7600000000000.0d0)) then
tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))))
else if (lambda1 <= 19000.0d0) then
tmp = atan2(t_1, (t_0 - (cos(lambda2) * t_2)))
else
tmp = atan2((cos(phi2) * sin((lambda1 + lambda2))), (t_0 - (cos(lambda1) * t_2)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double t_2 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if (lambda1 <= -7600000000000.0) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(phi2) * (Math.cos(lambda1) * Math.sin(phi1)))));
} else if (lambda1 <= 19000.0) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(lambda2) * t_2)));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 + lambda2))), (t_0 - (Math.cos(lambda1) * t_2)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) t_2 = math.cos(phi2) * math.sin(phi1) tmp = 0 if lambda1 <= -7600000000000.0: tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * (math.cos(lambda1) * math.sin(phi1))))) elif lambda1 <= 19000.0: tmp = math.atan2(t_1, (t_0 - (math.cos(lambda2) * t_2))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 + lambda2))), (t_0 - (math.cos(lambda1) * t_2))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) t_2 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if (lambda1 <= -7600000000000.0) tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda1) * sin(phi1))))); elseif (lambda1 <= 19000.0) tmp = atan(t_1, Float64(t_0 - Float64(cos(lambda2) * t_2))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 + lambda2))), Float64(t_0 - Float64(cos(lambda1) * t_2))); 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)); t_2 = cos(phi2) * sin(phi1); tmp = 0.0; if (lambda1 <= -7600000000000.0) tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1))))); elseif (lambda1 <= 19000.0) tmp = atan2(t_1, (t_0 - (cos(lambda2) * t_2))); else tmp = atan2((cos(phi2) * sin((lambda1 + lambda2))), (t_0 - (cos(lambda1) * t_2))); 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]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -7600000000000.0], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 19000.0], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 + lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$2), $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)\\
t_2 := \cos \phi_2 \cdot \sin \phi_1\\
\mathbf{if}\;\lambda_1 \leq -7600000000000:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\mathbf{elif}\;\lambda_1 \leq 19000:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \lambda_2 \cdot t_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 + \lambda_2\right)}{t_0 - \cos \lambda_1 \cdot t_2}\\
\end{array}
\end{array}
if lambda1 < -7.6e12Initial program 60.3%
*-commutative60.3%
associate-*l*60.3%
Simplified60.3%
Taylor expanded in lambda2 around 0 60.3%
if -7.6e12 < lambda1 < 19000Initial program 98.5%
Taylor expanded in lambda1 around 0 98.5%
cos-neg98.5%
Simplified98.5%
if 19000 < lambda1 Initial program 68.7%
sin-diff87.9%
Applied egg-rr87.9%
Taylor expanded in lambda2 around 0 87.7%
sin-diff68.7%
expm1-log1p-u68.7%
expm1-udef68.5%
Applied egg-rr68.6%
expm1-def68.8%
expm1-log1p68.8%
Simplified68.8%
Final simplification82.1%
(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.008)
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_2 (* t_0 (cos (- lambda1 lambda2)))))
(if (<= lambda2 1.3e-5)
(atan2 t_1 (- t_2 (* (cos phi2) (* (cos lambda1) (sin phi1)))))
(atan2 t_1 (- t_2 (* (cos lambda2) t_0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin(phi1);
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double t_2 = cos(phi1) * sin(phi2);
double tmp;
if (lambda2 <= -0.008) {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_2 - (t_0 * cos((lambda1 - lambda2)))));
} else if (lambda2 <= 1.3e-5) {
tmp = atan2(t_1, (t_2 - (cos(phi2) * (cos(lambda1) * sin(phi1)))));
} else {
tmp = atan2(t_1, (t_2 - (cos(lambda2) * t_0)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi2) * sin(phi1)
t_1 = cos(phi2) * sin((lambda1 - lambda2))
t_2 = cos(phi1) * sin(phi2)
if (lambda2 <= (-0.008d0)) then
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_2 - (t_0 * cos((lambda1 - lambda2)))))
else if (lambda2 <= 1.3d-5) then
tmp = atan2(t_1, (t_2 - (cos(phi2) * (cos(lambda1) * sin(phi1)))))
else
tmp = atan2(t_1, (t_2 - (cos(lambda2) * t_0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin(phi1);
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double t_2 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (lambda2 <= -0.008) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_2 - (t_0 * Math.cos((lambda1 - lambda2)))));
} else if (lambda2 <= 1.3e-5) {
tmp = Math.atan2(t_1, (t_2 - (Math.cos(phi2) * (Math.cos(lambda1) * Math.sin(phi1)))));
} else {
tmp = Math.atan2(t_1, (t_2 - (Math.cos(lambda2) * t_0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin(phi1) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) t_2 = math.cos(phi1) * math.sin(phi2) tmp = 0 if lambda2 <= -0.008: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_2 - (t_0 * math.cos((lambda1 - lambda2))))) elif lambda2 <= 1.3e-5: tmp = math.atan2(t_1, (t_2 - (math.cos(phi2) * (math.cos(lambda1) * math.sin(phi1))))) else: tmp = math.atan2(t_1, (t_2 - (math.cos(lambda2) * t_0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(phi1)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) t_2 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda2 <= -0.008) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_2 - Float64(t_0 * cos(Float64(lambda1 - lambda2))))); elseif (lambda2 <= 1.3e-5) tmp = atan(t_1, Float64(t_2 - Float64(cos(phi2) * Float64(cos(lambda1) * sin(phi1))))); else tmp = atan(t_1, Float64(t_2 - Float64(cos(lambda2) * t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin(phi1); t_1 = cos(phi2) * sin((lambda1 - lambda2)); t_2 = cos(phi1) * sin(phi2); tmp = 0.0; if (lambda2 <= -0.008) tmp = atan2((cos(phi2) * sin(-lambda2)), (t_2 - (t_0 * cos((lambda1 - lambda2))))); elseif (lambda2 <= 1.3e-5) tmp = atan2(t_1, (t_2 - (cos(phi2) * (cos(lambda1) * sin(phi1))))); else tmp = atan2(t_1, (t_2 - (cos(lambda2) * t_0))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -0.008], 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.3e-5], N[ArcTan[t$95$1 / N[(t$95$2 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$2 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \phi_1\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -0.008:\\
\;\;\;\;\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.3 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_2 - \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_2 - \cos \lambda_2 \cdot t_0}\\
\end{array}
\end{array}
if lambda2 < -0.0080000000000000002Initial program 56.4%
Taylor expanded in lambda1 around 0 59.9%
if -0.0080000000000000002 < lambda2 < 1.29999999999999992e-5Initial program 99.5%
*-commutative99.5%
associate-*l*99.5%
Simplified99.5%
Taylor expanded in lambda2 around 0 99.5%
if 1.29999999999999992e-5 < lambda2 Initial program 67.8%
Taylor expanded in lambda1 around 0 67.7%
cos-neg67.7%
Simplified67.7%
Final simplification82.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (cos phi2) (sin phi1))))
(if (or (<= lambda1 -1.6e+71) (not (<= lambda1 17500.0)))
(atan2 (* (sin lambda1) (cos phi2)) (- t_0 (* (cos lambda1) t_1)))
(atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- t_0 t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double tmp;
if ((lambda1 <= -1.6e+71) || !(lambda1 <= 17500.0)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (cos(lambda1) * t_1)));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - t_1));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
if ((lambda1 <= (-1.6d+71)) .or. (.not. (lambda1 <= 17500.0d0))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (cos(lambda1) * t_1)))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - t_1))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if ((lambda1 <= -1.6e+71) || !(lambda1 <= 17500.0)) {
tmp = Math.atan2((Math.sin(lambda1) * 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));
}
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 <= -1.6e+71) or not (lambda1 <= 17500.0): tmp = math.atan2((math.sin(lambda1) * 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)) 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 <= -1.6e+71) || !(lambda1 <= 17500.0)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(cos(lambda1) * t_1))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - t_1)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin(phi1); tmp = 0.0; if ((lambda1 <= -1.6e+71) || ~((lambda1 <= 17500.0))) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (cos(lambda1) * t_1))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - t_1)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -1.6e+71], N[Not[LessEqual[lambda1, 17500.0]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $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 - t$95$1), $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 -1.6 \cdot 10^{+71} \lor \neg \left(\lambda_1 \leq 17500\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \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}\\
\end{array}
\end{array}
if lambda1 < -1.60000000000000012e71 or 17500 < lambda1 Initial program 63.5%
sin-diff81.5%
Applied egg-rr81.5%
Taylor expanded in lambda2 around 0 81.5%
Taylor expanded in lambda2 around 0 62.8%
if -1.60000000000000012e71 < lambda1 < 17500Initial program 96.8%
Taylor expanded in lambda2 around 0 76.9%
Taylor expanded in lambda1 around 0 81.6%
Final simplification73.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= lambda2 2.8e-9)
(atan2 t_1 (- t_0 (* (cos phi2) (* (cos lambda1) (sin phi1)))))
(atan2 t_1 (- t_0 (* (sin phi1) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= 2.8e-9) {
tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))));
} else {
tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin((lambda1 - lambda2))
if (lambda2 <= 2.8d-9) then
tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))))
else
tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= 2.8e-9) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(phi2) * (Math.cos(lambda1) * Math.sin(phi1)))));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if lambda2 <= 2.8e-9: tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * (math.cos(lambda1) * math.sin(phi1))))) else: tmp = math.atan2(t_1, (t_0 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (lambda2 <= 2.8e-9) tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda1) * sin(phi1))))); else tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (lambda2 <= 2.8e-9) tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1))))); else tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 2.8e-9], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_2 \leq 2.8 \cdot 10^{-9}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda2 < 2.79999999999999984e-9Initial program 87.5%
*-commutative87.5%
associate-*l*87.5%
Simplified87.5%
Taylor expanded in lambda2 around 0 83.6%
if 2.79999999999999984e-9 < lambda2 Initial program 67.9%
Taylor expanded in phi2 around 0 56.0%
Final simplification75.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}
\end{array}
Initial program 82.1%
*-commutative82.1%
associate-*l*82.1%
Simplified82.1%
Final simplification82.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 82.1%
Final simplification82.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -58000.0) (not (<= phi2 1.32e-15)))
(atan2 (* (cos phi2) t_1) (- t_0 (* (cos phi2) (sin phi1))))
(atan2 t_1 (- t_0 (* (sin phi1) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -58000.0) || !(phi2 <= 1.32e-15)) {
tmp = atan2((cos(phi2) * t_1), (t_0 - (cos(phi2) * sin(phi1))));
} else {
tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin((lambda1 - lambda2))
if ((phi2 <= (-58000.0d0)) .or. (.not. (phi2 <= 1.32d-15))) then
tmp = atan2((cos(phi2) * t_1), (t_0 - (cos(phi2) * sin(phi1))))
else
tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -58000.0) || !(phi2 <= 1.32e-15)) {
tmp = Math.atan2((Math.cos(phi2) * t_1), (t_0 - (Math.cos(phi2) * Math.sin(phi1))));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi2 <= -58000.0) or not (phi2 <= 1.32e-15): tmp = math.atan2((math.cos(phi2) * t_1), (t_0 - (math.cos(phi2) * math.sin(phi1)))) else: tmp = math.atan2(t_1, (t_0 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -58000.0) || !(phi2 <= 1.32e-15)) tmp = atan(Float64(cos(phi2) * t_1), Float64(t_0 - Float64(cos(phi2) * sin(phi1)))); else tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi2 <= -58000.0) || ~((phi2 <= 1.32e-15))) tmp = atan2((cos(phi2) * t_1), (t_0 - (cos(phi2) * sin(phi1)))); else tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -58000.0], N[Not[LessEqual[phi2, 1.32e-15]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -58000 \lor \neg \left(\phi_2 \leq 1.32 \cdot 10^{-15}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_1}{t_0 - \cos \phi_2 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -58000 or 1.31999999999999995e-15 < phi2 Initial program 80.3%
Taylor expanded in lambda2 around 0 68.0%
Taylor expanded in lambda1 around 0 63.6%
if -58000 < phi2 < 1.31999999999999995e-15Initial program 84.1%
Taylor expanded in phi2 around 0 83.4%
Taylor expanded in phi2 around 0 83.6%
Final simplification73.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (sin (- lambda1 lambda2))))
(if (or (<= phi1 -0.0095) (not (<= phi1 1.08e+17)))
(atan2 t_1 (- t_0 (* (sin phi1) (cos (- lambda1 lambda2)))))
(atan2 (* (cos phi2) t_1) (- t_0 (* phi1 (cos (- lambda2 lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -0.0095) || !(phi1 <= 1.08e+17)) {
tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((cos(phi2) * t_1), (t_0 - (phi1 * cos((lambda2 - lambda1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin((lambda1 - lambda2))
if ((phi1 <= (-0.0095d0)) .or. (.not. (phi1 <= 1.08d+17))) then
tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))))
else
tmp = atan2((cos(phi2) * t_1), (t_0 - (phi1 * cos((lambda2 - lambda1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -0.0095) || !(phi1 <= 1.08e+17)) {
tmp = Math.atan2(t_1, (t_0 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * t_1), (t_0 - (phi1 * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi1 <= -0.0095) or not (phi1 <= 1.08e+17): tmp = math.atan2(t_1, (t_0 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((math.cos(phi2) * t_1), (t_0 - (phi1 * math.cos((lambda2 - lambda1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -0.0095) || !(phi1 <= 1.08e+17)) tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(cos(phi2) * t_1), Float64(t_0 - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -0.0095) || ~((phi1 <= 1.08e+17))) tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda1 - lambda2))))); else tmp = atan2((cos(phi2) * t_1), (t_0 - (phi1 * cos((lambda2 - lambda1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -0.0095], N[Not[LessEqual[phi1, 1.08e+17]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(t$95$0 - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -0.0095 \lor \neg \left(\phi_1 \leq 1.08 \cdot 10^{+17}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_1}{t_0 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\end{array}
\end{array}
if phi1 < -0.00949999999999999976 or 1.08e17 < phi1 Initial program 79.1%
Taylor expanded in phi2 around 0 49.6%
Taylor expanded in phi2 around 0 46.4%
if -0.00949999999999999976 < phi1 < 1.08e17Initial program 85.0%
Taylor expanded in phi2 around 0 83.4%
Taylor expanded in phi1 around 0 83.4%
sub-neg83.4%
remove-double-neg83.4%
mul-1-neg83.4%
distribute-neg-in83.4%
+-commutative83.4%
cos-neg83.4%
mul-1-neg83.4%
unsub-neg83.4%
Simplified83.4%
Final simplification65.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -1.92e+31) (not (<= phi2 5.5e-8)))
(atan2
(* (cos phi2) (- (sin lambda1) (* lambda2 (cos lambda1))))
(sin phi2))
(atan2
(sin (- lambda1 lambda2))
(- (* (cos phi1) (sin phi2)) (* (sin phi1) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -1.92e+31) || !(phi2 <= 5.5e-8)) {
tmp = atan2((cos(phi2) * (sin(lambda1) - (lambda2 * cos(lambda1)))), sin(phi2));
} else {
tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((phi2 <= (-1.92d+31)) .or. (.not. (phi2 <= 5.5d-8))) then
tmp = atan2((cos(phi2) * (sin(lambda1) - (lambda2 * cos(lambda1)))), sin(phi2))
else
tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -1.92e+31) || !(phi2 <= 5.5e-8)) {
tmp = Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - (lambda2 * Math.cos(lambda1)))), Math.sin(phi2));
} else {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (phi2 <= -1.92e+31) or not (phi2 <= 5.5e-8): tmp = math.atan2((math.cos(phi2) * (math.sin(lambda1) - (lambda2 * math.cos(lambda1)))), math.sin(phi2)) else: tmp = math.atan2(math.sin((lambda1 - lambda2)), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -1.92e+31) || !(phi2 <= 5.5e-8)) tmp = atan(Float64(cos(phi2) * Float64(sin(lambda1) - Float64(lambda2 * cos(lambda1)))), sin(phi2)); else tmp = atan(sin(Float64(lambda1 - lambda2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi2 <= -1.92e+31) || ~((phi2 <= 5.5e-8))) tmp = atan2((cos(phi2) * (sin(lambda1) - (lambda2 * cos(lambda1)))), sin(phi2)); else tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -1.92e+31], N[Not[LessEqual[phi2, 5.5e-8]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - N[(lambda2 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -1.92 \cdot 10^{+31} \lor \neg \left(\phi_2 \leq 5.5 \cdot 10^{-8}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - \lambda_2 \cdot \cos \lambda_1\right)}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -1.9199999999999999e31 or 5.5000000000000003e-8 < phi2 Initial program 79.9%
Taylor expanded in phi2 around 0 50.8%
Taylor expanded in lambda2 around 0 42.3%
mul-1-neg42.3%
unsub-neg42.3%
Simplified42.3%
Taylor expanded in phi1 around 0 42.7%
if -1.9199999999999999e31 < phi2 < 5.5000000000000003e-8Initial program 84.3%
Taylor expanded in phi2 around 0 83.0%
Taylor expanded in phi2 around 0 83.0%
Final simplification62.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= (- lambda1 lambda2) -5e-6) (not (<= (- lambda1 lambda2) 0.001)))
(atan2 t_0 (* (sin phi1) (- (cos (- lambda1 lambda2)))))
(atan2 t_0 (- (* (cos phi1) (sin phi2)) (sin phi1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (((lambda1 - lambda2) <= -5e-6) || !((lambda1 - lambda2) <= 0.001)) {
tmp = atan2(t_0, (sin(phi1) * -cos((lambda1 - lambda2))));
} else {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - sin(phi1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if (((lambda1 - lambda2) <= (-5d-6)) .or. (.not. ((lambda1 - lambda2) <= 0.001d0))) then
tmp = atan2(t_0, (sin(phi1) * -cos((lambda1 - lambda2))))
else
tmp = atan2(t_0, ((cos(phi1) * sin(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.sin((lambda1 - lambda2));
double tmp;
if (((lambda1 - lambda2) <= -5e-6) || !((lambda1 - lambda2) <= 0.001)) {
tmp = Math.atan2(t_0, (Math.sin(phi1) * -Math.cos((lambda1 - lambda2))));
} else {
tmp = Math.atan2(t_0, ((Math.cos(phi1) * Math.sin(phi2)) - Math.sin(phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if ((lambda1 - lambda2) <= -5e-6) or not ((lambda1 - lambda2) <= 0.001): tmp = math.atan2(t_0, (math.sin(phi1) * -math.cos((lambda1 - lambda2)))) else: tmp = math.atan2(t_0, ((math.cos(phi1) * math.sin(phi2)) - math.sin(phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((Float64(lambda1 - lambda2) <= -5e-6) || !(Float64(lambda1 - lambda2) <= 0.001)) tmp = atan(t_0, Float64(sin(phi1) * Float64(-cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - sin(phi1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (((lambda1 - lambda2) <= -5e-6) || ~(((lambda1 - lambda2) <= 0.001))) tmp = atan2(t_0, (sin(phi1) * -cos((lambda1 - lambda2)))); else tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - sin(phi1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -5e-6], N[Not[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 0.001]], $MachinePrecision]], N[ArcTan[t$95$0 / N[(N[Sin[phi1], $MachinePrecision] * (-N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[Sin[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -5 \cdot 10^{-6} \lor \neg \left(\lambda_1 - \lambda_2 \leq 0.001\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\sin \phi_1 \cdot \left(-\cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1}\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -5.00000000000000041e-6 or 1e-3 < (-.f64 lambda1 lambda2) Initial program 75.7%
Taylor expanded in phi2 around 0 62.6%
Taylor expanded in phi2 around 0 47.3%
Taylor expanded in phi2 around 0 45.6%
associate-*r*45.6%
neg-mul-145.6%
*-commutative45.6%
Simplified45.6%
if -5.00000000000000041e-6 < (-.f64 lambda1 lambda2) < 1e-3Initial program 99.6%
Taylor expanded in phi2 around 0 78.3%
Taylor expanded in phi2 around 0 60.6%
Taylor expanded in lambda1 around 0 60.6%
mul-1-neg60.6%
unsub-neg60.6%
sin-neg60.6%
neg-mul-160.6%
associate-*r*60.6%
*-commutative60.6%
mul-1-neg60.6%
cancel-sign-sub60.6%
cos-neg60.6%
Simplified60.6%
Taylor expanded in lambda2 around 0 60.6%
Final simplification49.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -58000.0) (not (<= phi2 5.5e-8)))
(atan2
(* (cos phi2) (- (sin lambda1) (* lambda2 (cos lambda1))))
(sin phi2))
(atan2
(sin (- lambda1 lambda2))
(- (* phi2 (cos phi1)) (* (sin phi1) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -58000.0) || !(phi2 <= 5.5e-8)) {
tmp = atan2((cos(phi2) * (sin(lambda1) - (lambda2 * cos(lambda1)))), sin(phi2));
} else {
tmp = atan2(sin((lambda1 - lambda2)), ((phi2 * cos(phi1)) - (sin(phi1) * cos((lambda1 - lambda2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((phi2 <= (-58000.0d0)) .or. (.not. (phi2 <= 5.5d-8))) then
tmp = atan2((cos(phi2) * (sin(lambda1) - (lambda2 * cos(lambda1)))), sin(phi2))
else
tmp = atan2(sin((lambda1 - lambda2)), ((phi2 * cos(phi1)) - (sin(phi1) * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -58000.0) || !(phi2 <= 5.5e-8)) {
tmp = Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - (lambda2 * Math.cos(lambda1)))), Math.sin(phi2));
} else {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), ((phi2 * Math.cos(phi1)) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (phi2 <= -58000.0) or not (phi2 <= 5.5e-8): tmp = math.atan2((math.cos(phi2) * (math.sin(lambda1) - (lambda2 * math.cos(lambda1)))), math.sin(phi2)) else: tmp = math.atan2(math.sin((lambda1 - lambda2)), ((phi2 * math.cos(phi1)) - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -58000.0) || !(phi2 <= 5.5e-8)) tmp = atan(Float64(cos(phi2) * Float64(sin(lambda1) - Float64(lambda2 * cos(lambda1)))), sin(phi2)); else tmp = atan(sin(Float64(lambda1 - lambda2)), Float64(Float64(phi2 * cos(phi1)) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi2 <= -58000.0) || ~((phi2 <= 5.5e-8))) tmp = atan2((cos(phi2) * (sin(lambda1) - (lambda2 * cos(lambda1)))), sin(phi2)); else tmp = atan2(sin((lambda1 - lambda2)), ((phi2 * cos(phi1)) - (sin(phi1) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -58000.0], N[Not[LessEqual[phi2, 5.5e-8]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - N[(lambda2 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -58000 \lor \neg \left(\phi_2 \leq 5.5 \cdot 10^{-8}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - \lambda_2 \cdot \cos \lambda_1\right)}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2 \cdot \cos \phi_1 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -58000 or 5.5000000000000003e-8 < phi2 Initial program 79.7%
Taylor expanded in phi2 around 0 50.4%
Taylor expanded in lambda2 around 0 41.8%
mul-1-neg41.8%
unsub-neg41.8%
Simplified41.8%
Taylor expanded in phi1 around 0 42.1%
if -58000 < phi2 < 5.5000000000000003e-8Initial program 84.6%
Taylor expanded in phi2 around 0 84.0%
Taylor expanded in phi2 around 0 84.1%
Taylor expanded in phi2 around 0 84.0%
+-commutative84.0%
*-commutative84.0%
neg-mul-184.0%
unsub-neg84.0%
Simplified84.0%
Final simplification62.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -2.8e+14) (not (<= phi2 1.8e-12)))
(atan2
(* (cos phi2) (- (sin lambda1) (* lambda2 (cos lambda1))))
(sin phi2))
(atan2
(sin (- lambda1 lambda2))
(* (sin phi1) (- (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -2.8e+14) || !(phi2 <= 1.8e-12)) {
tmp = atan2((cos(phi2) * (sin(lambda1) - (lambda2 * cos(lambda1)))), sin(phi2));
} else {
tmp = atan2(sin((lambda1 - lambda2)), (sin(phi1) * -cos((lambda1 - lambda2))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((phi2 <= (-2.8d+14)) .or. (.not. (phi2 <= 1.8d-12))) then
tmp = atan2((cos(phi2) * (sin(lambda1) - (lambda2 * cos(lambda1)))), sin(phi2))
else
tmp = atan2(sin((lambda1 - lambda2)), (sin(phi1) * -cos((lambda1 - lambda2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -2.8e+14) || !(phi2 <= 1.8e-12)) {
tmp = Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - (lambda2 * Math.cos(lambda1)))), Math.sin(phi2));
} else {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), (Math.sin(phi1) * -Math.cos((lambda1 - lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (phi2 <= -2.8e+14) or not (phi2 <= 1.8e-12): tmp = math.atan2((math.cos(phi2) * (math.sin(lambda1) - (lambda2 * math.cos(lambda1)))), math.sin(phi2)) else: tmp = math.atan2(math.sin((lambda1 - lambda2)), (math.sin(phi1) * -math.cos((lambda1 - lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -2.8e+14) || !(phi2 <= 1.8e-12)) tmp = atan(Float64(cos(phi2) * Float64(sin(lambda1) - Float64(lambda2 * cos(lambda1)))), sin(phi2)); else tmp = atan(sin(Float64(lambda1 - lambda2)), Float64(sin(phi1) * Float64(-cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi2 <= -2.8e+14) || ~((phi2 <= 1.8e-12))) tmp = atan2((cos(phi2) * (sin(lambda1) - (lambda2 * cos(lambda1)))), sin(phi2)); else tmp = atan2(sin((lambda1 - lambda2)), (sin(phi1) * -cos((lambda1 - lambda2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -2.8e+14], N[Not[LessEqual[phi2, 1.8e-12]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - N[(lambda2 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[phi1], $MachinePrecision] * (-N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -2.8 \cdot 10^{+14} \lor \neg \left(\phi_2 \leq 1.8 \cdot 10^{-12}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - \lambda_2 \cdot \cos \lambda_1\right)}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_1 \cdot \left(-\cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\end{array}
\end{array}
if phi2 < -2.8e14 or 1.8e-12 < phi2 Initial program 80.0%
Taylor expanded in phi2 around 0 51.7%
Taylor expanded in lambda2 around 0 43.0%
mul-1-neg43.0%
unsub-neg43.0%
Simplified43.0%
Taylor expanded in phi1 around 0 42.7%
if -2.8e14 < phi2 < 1.8e-12Initial program 84.3%
Taylor expanded in phi2 around 0 83.0%
Taylor expanded in phi2 around 0 83.2%
Taylor expanded in phi2 around 0 79.2%
associate-*r*79.2%
neg-mul-179.2%
*-commutative79.2%
Simplified79.2%
Final simplification60.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (or (<= phi1 -0.16) (not (<= phi1 3.2e-5)))
(atan2 t_1 (* (sin phi1) (- t_0)))
(atan2 t_1 (- (sin phi2) (* phi1 t_0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -0.16) || !(phi1 <= 3.2e-5)) {
tmp = atan2(t_1, (sin(phi1) * -t_0));
} else {
tmp = atan2(t_1, (sin(phi2) - (phi1 * t_0)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = sin((lambda1 - lambda2))
if ((phi1 <= (-0.16d0)) .or. (.not. (phi1 <= 3.2d-5))) then
tmp = atan2(t_1, (sin(phi1) * -t_0))
else
tmp = atan2(t_1, (sin(phi2) - (phi1 * t_0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -0.16) || !(phi1 <= 3.2e-5)) {
tmp = Math.atan2(t_1, (Math.sin(phi1) * -t_0));
} else {
tmp = Math.atan2(t_1, (Math.sin(phi2) - (phi1 * t_0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi1 <= -0.16) or not (phi1 <= 3.2e-5): tmp = math.atan2(t_1, (math.sin(phi1) * -t_0)) else: tmp = math.atan2(t_1, (math.sin(phi2) - (phi1 * t_0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -0.16) || !(phi1 <= 3.2e-5)) tmp = atan(t_1, Float64(sin(phi1) * Float64(-t_0))); else tmp = atan(t_1, Float64(sin(phi2) - Float64(phi1 * t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -0.16) || ~((phi1 <= 3.2e-5))) tmp = atan2(t_1, (sin(phi1) * -t_0)); else tmp = atan2(t_1, (sin(phi2) - (phi1 * t_0))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -0.16], N[Not[LessEqual[phi1, 3.2e-5]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(N[Sin[phi1], $MachinePrecision] * (-t$95$0)), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -0.16 \lor \neg \left(\phi_1 \leq 3.2 \cdot 10^{-5}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{\sin \phi_1 \cdot \left(-t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{\sin \phi_2 - \phi_1 \cdot t_0}\\
\end{array}
\end{array}
if phi1 < -0.160000000000000003 or 3.19999999999999986e-5 < phi1 Initial program 78.5%
Taylor expanded in phi2 around 0 49.1%
Taylor expanded in phi2 around 0 45.9%
Taylor expanded in phi2 around 0 43.2%
associate-*r*43.2%
neg-mul-143.2%
*-commutative43.2%
Simplified43.2%
if -0.160000000000000003 < phi1 < 3.19999999999999986e-5Initial program 85.6%
Taylor expanded in phi2 around 0 84.1%
Taylor expanded in phi2 around 0 55.7%
Taylor expanded in phi1 around 0 55.7%
mul-1-neg55.7%
unsub-neg55.7%
Simplified55.7%
Final simplification49.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi1 -1.3e-32) (not (<= phi1 2.45e-25)))
(atan2 t_0 (* (sin phi1) (- (cos (- lambda1 lambda2)))))
(atan2 t_0 (sin phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -1.3e-32) || !(phi1 <= 2.45e-25)) {
tmp = atan2(t_0, (sin(phi1) * -cos((lambda1 - lambda2))));
} else {
tmp = atan2(t_0, sin(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 = sin((lambda1 - lambda2))
if ((phi1 <= (-1.3d-32)) .or. (.not. (phi1 <= 2.45d-25))) then
tmp = atan2(t_0, (sin(phi1) * -cos((lambda1 - lambda2))))
else
tmp = atan2(t_0, sin(phi2))
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 ((phi1 <= -1.3e-32) || !(phi1 <= 2.45e-25)) {
tmp = Math.atan2(t_0, (Math.sin(phi1) * -Math.cos((lambda1 - lambda2))));
} else {
tmp = Math.atan2(t_0, Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi1 <= -1.3e-32) or not (phi1 <= 2.45e-25): tmp = math.atan2(t_0, (math.sin(phi1) * -math.cos((lambda1 - lambda2)))) else: tmp = math.atan2(t_0, math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -1.3e-32) || !(phi1 <= 2.45e-25)) tmp = atan(t_0, Float64(sin(phi1) * Float64(-cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_0, sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -1.3e-32) || ~((phi1 <= 2.45e-25))) tmp = atan2(t_0, (sin(phi1) * -cos((lambda1 - lambda2)))); else tmp = atan2(t_0, sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -1.3e-32], N[Not[LessEqual[phi1, 2.45e-25]], $MachinePrecision]], N[ArcTan[t$95$0 / N[(N[Sin[phi1], $MachinePrecision] * (-N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.3 \cdot 10^{-32} \lor \neg \left(\phi_1 \leq 2.45 \cdot 10^{-25}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\sin \phi_1 \cdot \left(-\cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\sin \phi_2}\\
\end{array}
\end{array}
if phi1 < -1.2999999999999999e-32 or 2.44999999999999995e-25 < phi1 Initial program 79.7%
Taylor expanded in phi2 around 0 51.5%
Taylor expanded in phi2 around 0 45.7%
Taylor expanded in phi2 around 0 42.9%
associate-*r*42.9%
neg-mul-142.9%
*-commutative42.9%
Simplified42.9%
if -1.2999999999999999e-32 < phi1 < 2.44999999999999995e-25Initial program 84.9%
Taylor expanded in phi2 around 0 84.9%
Taylor expanded in phi2 around 0 56.9%
Taylor expanded in phi1 around 0 56.5%
Final simplification49.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (or (<= lambda2 -4e-167) (not (<= lambda2 1.1e-37))) (atan2 (sin (- lambda2)) (sin phi2)) (atan2 (sin lambda1) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda2 <= -4e-167) || !(lambda2 <= 1.1e-37)) {
tmp = atan2(sin(-lambda2), sin(phi2));
} else {
tmp = atan2(sin(lambda1), sin(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) :: tmp
if ((lambda2 <= (-4d-167)) .or. (.not. (lambda2 <= 1.1d-37))) then
tmp = atan2(sin(-lambda2), sin(phi2))
else
tmp = atan2(sin(lambda1), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda2 <= -4e-167) || !(lambda2 <= 1.1e-37)) {
tmp = Math.atan2(Math.sin(-lambda2), Math.sin(phi2));
} else {
tmp = Math.atan2(Math.sin(lambda1), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda2 <= -4e-167) or not (lambda2 <= 1.1e-37): tmp = math.atan2(math.sin(-lambda2), math.sin(phi2)) else: tmp = math.atan2(math.sin(lambda1), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda2 <= -4e-167) || !(lambda2 <= 1.1e-37)) tmp = atan(sin(Float64(-lambda2)), sin(phi2)); else tmp = atan(sin(lambda1), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda2 <= -4e-167) || ~((lambda2 <= 1.1e-37))) tmp = atan2(sin(-lambda2), sin(phi2)); else tmp = atan2(sin(lambda1), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda2, -4e-167], N[Not[LessEqual[lambda2, 1.1e-37]], $MachinePrecision]], N[ArcTan[N[Sin[(-lambda2)], $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -4 \cdot 10^{-167} \lor \neg \left(\lambda_2 \leq 1.1 \cdot 10^{-37}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right)}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1}{\sin \phi_2}\\
\end{array}
\end{array}
if lambda2 < -4.00000000000000001e-167 or 1.10000000000000001e-37 < lambda2 Initial program 73.0%
Taylor expanded in phi2 around 0 58.7%
Taylor expanded in phi2 around 0 45.9%
Taylor expanded in phi1 around 0 35.7%
Taylor expanded in lambda1 around 0 32.3%
if -4.00000000000000001e-167 < lambda2 < 1.10000000000000001e-37Initial program 99.7%
Taylor expanded in phi2 around 0 82.5%
Taylor expanded in phi2 around 0 60.4%
Taylor expanded in phi1 around 0 34.1%
Taylor expanded in lambda2 around 0 34.2%
Final simplification32.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), sin(phi2));
}
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)), sin(phi2))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), Math.sin(phi2));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), math.sin(phi2))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), sin(phi2)) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), sin(phi2)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2}
\end{array}
Initial program 82.1%
Taylor expanded in phi2 around 0 66.8%
Taylor expanded in phi2 around 0 50.8%
Taylor expanded in phi1 around 0 35.2%
Final simplification35.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin lambda1) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin(lambda1), sin(phi2));
}
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), sin(phi2))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin(lambda1), Math.sin(phi2));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin(lambda1), math.sin(phi2))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(lambda1), sin(phi2)) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin(lambda1), sin(phi2)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1}{\sin \phi_2}
\end{array}
Initial program 82.1%
Taylor expanded in phi2 around 0 66.8%
Taylor expanded in phi2 around 0 50.8%
Taylor expanded in phi1 around 0 35.2%
Taylor expanded in lambda2 around 0 24.1%
Final simplification24.1%
herbie shell --seed 2023321
(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))))))