
(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 21 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (cos phi2) (sin phi1))
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)}
\end{array}
Initial program 82.5%
sin-diff92.6%
sub-neg92.6%
Applied egg-rr92.6%
sub-neg92.6%
Simplified92.6%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (cos phi2) (sin phi1))))
(if (or (<= lambda1 -1.85e-6) (not (<= lambda1 1.2e-5)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* (cos lambda1) t_1)))
(atan2
(* (cos phi2) (- (* lambda1 (cos lambda2)) (sin lambda2)))
(- t_0 (* t_1 (+ (cos lambda2) (* lambda1 (sin lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double tmp;
if ((lambda1 <= -1.85e-6) || !(lambda1 <= 1.2e-5)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * t_1)));
} else {
tmp = atan2((cos(phi2) * ((lambda1 * cos(lambda2)) - sin(lambda2))), (t_0 - (t_1 * (cos(lambda2) + (lambda1 * sin(lambda2))))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
if ((lambda1 <= (-1.85d-6)) .or. (.not. (lambda1 <= 1.2d-5))) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * t_1)))
else
tmp = atan2((cos(phi2) * ((lambda1 * cos(lambda2)) - sin(lambda2))), (t_0 - (t_1 * (cos(lambda2) + (lambda1 * sin(lambda2))))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if ((lambda1 <= -1.85e-6) || !(lambda1 <= 1.2e-5)) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (Math.cos(lambda1) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * ((lambda1 * Math.cos(lambda2)) - Math.sin(lambda2))), (t_0 - (t_1 * (Math.cos(lambda2) + (lambda1 * Math.sin(lambda2))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) tmp = 0 if (lambda1 <= -1.85e-6) or not (lambda1 <= 1.2e-5): tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (math.cos(lambda1) * t_1))) else: tmp = math.atan2((math.cos(phi2) * ((lambda1 * math.cos(lambda2)) - math.sin(lambda2))), (t_0 - (t_1 * (math.cos(lambda2) + (lambda1 * math.sin(lambda2)))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if ((lambda1 <= -1.85e-6) || !(lambda1 <= 1.2e-5)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(cos(lambda1) * t_1))); else tmp = atan(Float64(cos(phi2) * Float64(Float64(lambda1 * cos(lambda2)) - sin(lambda2))), Float64(t_0 - Float64(t_1 * Float64(cos(lambda2) + Float64(lambda1 * sin(lambda2)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin(phi1); tmp = 0.0; if ((lambda1 <= -1.85e-6) || ~((lambda1 <= 1.2e-5))) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * t_1))); else tmp = atan2((cos(phi2) * ((lambda1 * cos(lambda2)) - sin(lambda2))), (t_0 - (t_1 * (cos(lambda2) + (lambda1 * sin(lambda2)))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -1.85e-6], N[Not[LessEqual[lambda1, 1.2e-5]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(lambda1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[Cos[lambda2], $MachinePrecision] + N[(lambda1 * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
\mathbf{if}\;\lambda_1 \leq -1.85 \cdot 10^{-6} \lor \neg \left(\lambda_1 \leq 1.2 \cdot 10^{-5}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \cos \lambda_1 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2\right)}{t_0 - t_1 \cdot \left(\cos \lambda_2 + \lambda_1 \cdot \sin \lambda_2\right)}\\
\end{array}
\end{array}
if lambda1 < -1.8500000000000001e-6 or 1.2e-5 < lambda1 Initial program 66.9%
sin-diff86.4%
sub-neg86.4%
Applied egg-rr86.4%
sub-neg86.4%
Simplified86.4%
Taylor expanded in lambda2 around 0 86.5%
if -1.8500000000000001e-6 < lambda1 < 1.2e-5Initial program 98.8%
Taylor expanded in lambda1 around 0 99.1%
+-commutative99.1%
sin-neg99.1%
unsub-neg99.1%
cos-neg99.1%
*-commutative99.1%
Simplified99.1%
Taylor expanded in lambda1 around 0 99.7%
cos-neg99.7%
+-commutative99.7%
mul-1-neg99.7%
sin-neg99.7%
Simplified99.7%
Final simplification92.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 82.5%
sin-diff92.6%
sub-neg92.6%
Applied egg-rr92.6%
sub-neg92.6%
Simplified92.6%
Final simplification92.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_2 (cos (- lambda1 lambda2)))
(t_3 (* (* (cos phi2) (sin phi1)) t_2)))
(if (<= phi1 -4.6e-11)
(atan2 t_1 (- t_0 (expm1 (log1p t_3))))
(if (<= phi1 2.4e-21)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* (sin phi1) t_2)))
(atan2 t_1 (- t_0 t_3))))))
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((lambda1 - lambda2));
double t_3 = (cos(phi2) * sin(phi1)) * t_2;
double tmp;
if (phi1 <= -4.6e-11) {
tmp = atan2(t_1, (t_0 - expm1(log1p(t_3))));
} else if (phi1 <= 2.4e-21) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_2)));
} else {
tmp = atan2(t_1, (t_0 - t_3));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double t_2 = Math.cos((lambda1 - lambda2));
double t_3 = (Math.cos(phi2) * Math.sin(phi1)) * t_2;
double tmp;
if (phi1 <= -4.6e-11) {
tmp = Math.atan2(t_1, (t_0 - Math.expm1(Math.log1p(t_3))));
} else if (phi1 <= 2.4e-21) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (Math.sin(phi1) * t_2)));
} else {
tmp = Math.atan2(t_1, (t_0 - t_3));
}
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((lambda1 - lambda2)) t_3 = (math.cos(phi2) * math.sin(phi1)) * t_2 tmp = 0 if phi1 <= -4.6e-11: tmp = math.atan2(t_1, (t_0 - math.expm1(math.log1p(t_3)))) elif phi1 <= 2.4e-21: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (math.sin(phi1) * t_2))) else: tmp = math.atan2(t_1, (t_0 - t_3)) 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 = cos(Float64(lambda1 - lambda2)) t_3 = Float64(Float64(cos(phi2) * sin(phi1)) * t_2) tmp = 0.0 if (phi1 <= -4.6e-11) tmp = atan(t_1, Float64(t_0 - expm1(log1p(t_3)))); elseif (phi1 <= 2.4e-21) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * t_2))); else tmp = atan(t_1, Float64(t_0 - t_3)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]}, If[LessEqual[phi1, -4.6e-11], N[ArcTan[t$95$1 / N[(t$95$0 - N[(Exp[N[Log[1 + t$95$3], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 2.4e-21], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - t$95$3), $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 \left(\lambda_1 - \lambda_2\right)\\
t_3 := \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_2\\
\mathbf{if}\;\phi_1 \leq -4.6 \cdot 10^{-11}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \mathsf{expm1}\left(\mathsf{log1p}\left(t_3\right)\right)}\\
\mathbf{elif}\;\phi_1 \leq 2.4 \cdot 10^{-21}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot t_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - t_3}\\
\end{array}
\end{array}
if phi1 < -4.60000000000000027e-11Initial program 84.6%
expm1-log1p-u84.6%
*-commutative84.6%
Applied egg-rr84.6%
if -4.60000000000000027e-11 < phi1 < 2.3999999999999999e-21Initial program 81.2%
sin-diff99.9%
sub-neg99.9%
Applied egg-rr99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in phi2 around 0 99.9%
Taylor expanded in phi1 around 0 99.9%
if 2.3999999999999999e-21 < phi1 Initial program 82.8%
Final simplification91.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -5.2e-9) (not (<= phi1 2.4e-21)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) t_0)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* (sin phi1) t_0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -5.2e-9) || !(phi1 <= 2.4e-21)) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * t_0)));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
if ((phi1 <= (-5.2d-9)) .or. (.not. (phi1 <= 2.4d-21))) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * t_0)))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -5.2e-9) || !(phi1 <= 2.4e-21)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * t_0)));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (Math.sin(phi1) * t_0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if (phi1 <= -5.2e-9) or not (phi1 <= 2.4e-21): tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * t_0))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (math.sin(phi1) * t_0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -5.2e-9) || !(phi1 <= 2.4e-21)) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * t_0))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -5.2e-9) || ~((phi1 <= 2.4e-21))) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * t_0))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -5.2e-9], N[Not[LessEqual[phi1, 2.4e-21]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -5.2 \cdot 10^{-9} \lor \neg \left(\phi_1 \leq 2.4 \cdot 10^{-21}\right):\\
\;\;\;\;\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 t_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot t_0}\\
\end{array}
\end{array}
if phi1 < -5.2000000000000002e-9 or 2.3999999999999999e-21 < phi1 Initial program 83.7%
if -5.2000000000000002e-9 < phi1 < 2.3999999999999999e-21Initial program 81.2%
sin-diff99.9%
sub-neg99.9%
Applied egg-rr99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in phi2 around 0 99.9%
Taylor expanded in phi1 around 0 99.9%
Final simplification91.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -1.1e-10) (not (<= phi1 2.4e-21)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(-
(* (cos phi1) (sin phi2))
(* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* phi1 (cos (- lambda2 lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -1.1e-10) || !(phi1 <= 2.4e-21)) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((phi1 <= (-1.1d-10)) .or. (.not. (phi1 <= 2.4d-21))) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -1.1e-10) || !(phi1 <= 2.4e-21)) {
tmp = 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)))));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (phi1 <= -1.1e-10) or not (phi1 <= 2.4e-21): tmp = 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))))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -1.1e-10) || !(phi1 <= 2.4e-21)) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi1 <= -1.1e-10) || ~((phi1 <= 2.4e-21))) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -1.1e-10], N[Not[LessEqual[phi1, 2.4e-21]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -1.1 \cdot 10^{-10} \lor \neg \left(\phi_1 \leq 2.4 \cdot 10^{-21}\right):\\
\;\;\;\;\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)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\end{array}
\end{array}
if phi1 < -1.09999999999999995e-10 or 2.3999999999999999e-21 < phi1 Initial program 83.7%
if -1.09999999999999995e-10 < phi1 < 2.3999999999999999e-21Initial program 81.2%
Taylor expanded in phi2 around 0 81.2%
sub-neg81.2%
+-commutative81.2%
neg-mul-181.2%
neg-mul-181.2%
remove-double-neg81.2%
mul-1-neg81.2%
distribute-neg-in81.2%
+-commutative81.2%
cos-neg81.2%
+-commutative81.2%
mul-1-neg81.2%
unsub-neg81.2%
Simplified81.2%
Taylor expanded in phi1 around 0 81.2%
Taylor expanded in phi1 around 0 81.2%
sin-diff99.9%
sub-neg99.9%
Applied egg-rr99.9%
sub-neg99.9%
Simplified99.9%
Final simplification91.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= lambda2 -0.000135)
(atan2 t_2 (- t_0 (* (cos lambda2) t_1)))
(if (<= lambda2 0.00043)
(atan2 t_2 (- t_0 (* (cos lambda1) t_1)))
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_0 (* t_1 (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(phi1);
double t_2 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -0.000135) {
tmp = atan2(t_2, (t_0 - (cos(lambda2) * t_1)));
} else if (lambda2 <= 0.00043) {
tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1)));
} else {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (t_1 * 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) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
t_2 = cos(phi2) * sin((lambda1 - lambda2))
if (lambda2 <= (-0.000135d0)) then
tmp = atan2(t_2, (t_0 - (cos(lambda2) * t_1)))
else if (lambda2 <= 0.00043d0) then
tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1)))
else
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (t_1 * 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(phi1);
double t_2 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -0.000135) {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(lambda2) * t_1)));
} else if (lambda2 <= 0.00043) {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(lambda1) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_0 - (t_1 * 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(phi1) t_2 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if lambda2 <= -0.000135: tmp = math.atan2(t_2, (t_0 - (math.cos(lambda2) * t_1))) elif lambda2 <= 0.00043: tmp = math.atan2(t_2, (t_0 - (math.cos(lambda1) * t_1))) else: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_0 - (t_1 * 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(phi1)) t_2 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (lambda2 <= -0.000135) tmp = atan(t_2, Float64(t_0 - Float64(cos(lambda2) * t_1))); elseif (lambda2 <= 0.00043) tmp = atan(t_2, Float64(t_0 - Float64(cos(lambda1) * t_1))); else tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_0 - Float64(t_1 * 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(phi1); t_2 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (lambda2 <= -0.000135) tmp = atan2(t_2, (t_0 - (cos(lambda2) * t_1))); elseif (lambda2 <= 0.00043) tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1))); else tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (t_1 * 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[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -0.000135], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 0.00043], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * 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 \phi_1\\
t_2 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_2 \leq -0.000135:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \lambda_2 \cdot t_1}\\
\mathbf{elif}\;\lambda_2 \leq 0.00043:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \lambda_1 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_0 - t_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda2 < -1.35000000000000002e-4Initial program 67.3%
Taylor expanded in lambda1 around 0 67.1%
cos-neg67.1%
Simplified67.1%
if -1.35000000000000002e-4 < lambda2 < 4.29999999999999989e-4Initial program 98.5%
Taylor expanded in lambda2 around 0 98.5%
if 4.29999999999999989e-4 < lambda2 Initial program 63.1%
Taylor expanded in lambda1 around 0 65.2%
Final simplification82.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (or (<= lambda1 -1.35) (not (<= lambda1 2.5e-5)))
(atan2 t_2 (- t_0 (* (cos lambda1) t_1)))
(atan2 t_2 (- t_0 (* (cos lambda2) t_1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double t_2 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if ((lambda1 <= -1.35) || !(lambda1 <= 2.5e-5)) {
tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1)));
} else {
tmp = atan2(t_2, (t_0 - (cos(lambda2) * 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) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
t_2 = cos(phi2) * sin((lambda1 - lambda2))
if ((lambda1 <= (-1.35d0)) .or. (.not. (lambda1 <= 2.5d-5))) then
tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1)))
else
tmp = atan2(t_2, (t_0 - (cos(lambda2) * 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 t_2 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if ((lambda1 <= -1.35) || !(lambda1 <= 2.5e-5)) {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(lambda1) * t_1)));
} else {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(lambda2) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) t_2 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if (lambda1 <= -1.35) or not (lambda1 <= 2.5e-5): tmp = math.atan2(t_2, (t_0 - (math.cos(lambda1) * t_1))) else: tmp = math.atan2(t_2, (t_0 - (math.cos(lambda2) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if ((lambda1 <= -1.35) || !(lambda1 <= 2.5e-5)) tmp = atan(t_2, Float64(t_0 - Float64(cos(lambda1) * t_1))); else tmp = atan(t_2, Float64(t_0 - Float64(cos(lambda2) * 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); t_2 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if ((lambda1 <= -1.35) || ~((lambda1 <= 2.5e-5))) tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1))); else tmp = atan2(t_2, (t_0 - (cos(lambda2) * 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]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -1.35], N[Not[LessEqual[lambda1, 2.5e-5]], $MachinePrecision]], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[lambda2], $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 \phi_2 \cdot \sin \phi_1\\
t_2 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -1.35 \lor \neg \left(\lambda_1 \leq 2.5 \cdot 10^{-5}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \lambda_1 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \lambda_2 \cdot t_1}\\
\end{array}
\end{array}
if lambda1 < -1.3500000000000001 or 2.50000000000000012e-5 < lambda1 Initial program 66.4%
Taylor expanded in lambda2 around 0 66.5%
if -1.3500000000000001 < lambda1 < 2.50000000000000012e-5Initial program 98.5%
Taylor expanded in lambda1 around 0 98.5%
cos-neg98.5%
Simplified98.5%
Final simplification82.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (- t_0 (* (sin phi1) (cos (- lambda2 lambda1))))))
(if (<= lambda2 -5.7e-55)
(atan2 (* (cos phi2) (sin (- lambda1 lambda2))) t_1)
(if (<= lambda2 2.85e-5)
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))
(atan2 (* (cos phi2) (sin (- lambda2))) t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = t_0 - (sin(phi1) * cos((lambda2 - lambda1)));
double tmp;
if (lambda2 <= -5.7e-55) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), t_1);
} else if (lambda2 <= 2.85e-5) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((cos(phi2) * sin(-lambda2)), 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 = t_0 - (sin(phi1) * cos((lambda2 - lambda1)))
if (lambda2 <= (-5.7d-55)) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), t_1)
else if (lambda2 <= 2.85d-5) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
else
tmp = atan2((cos(phi2) * sin(-lambda2)), 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 = t_0 - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)));
double tmp;
if (lambda2 <= -5.7e-55) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), t_1);
} else if (lambda2 <= 2.85e-5) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), t_1);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = t_0 - (math.sin(phi1) * math.cos((lambda2 - lambda1))) tmp = 0 if lambda2 <= -5.7e-55: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), t_1) elif lambda2 <= 2.85e-5: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), t_1) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1)))) tmp = 0.0 if (lambda2 <= -5.7e-55) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), t_1); elseif (lambda2 <= 2.85e-5) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), t_1); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = t_0 - (sin(phi1) * cos((lambda2 - lambda1))); tmp = 0.0; if (lambda2 <= -5.7e-55) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), t_1); elseif (lambda2 <= 2.85e-5) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); else tmp = atan2((cos(phi2) * sin(-lambda2)), 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[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -5.7e-55], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision], If[LessEqual[lambda2, 2.85e-5], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := t_0 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\lambda_2 \leq -5.7 \cdot 10^{-55}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_1}\\
\mathbf{elif}\;\lambda_2 \leq 2.85 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_1}\\
\end{array}
\end{array}
if lambda2 < -5.7000000000000002e-55Initial program 69.3%
Taylor expanded in phi2 around 0 58.5%
sub-neg58.5%
+-commutative58.5%
neg-mul-158.5%
neg-mul-158.5%
remove-double-neg58.5%
mul-1-neg58.5%
distribute-neg-in58.5%
+-commutative58.5%
cos-neg58.5%
+-commutative58.5%
mul-1-neg58.5%
unsub-neg58.5%
Simplified58.5%
if -5.7000000000000002e-55 < lambda2 < 2.8500000000000002e-5Initial program 99.3%
Taylor expanded in lambda2 around 0 87.0%
if 2.8500000000000002e-5 < lambda2 Initial program 63.1%
Taylor expanded in phi2 around 0 55.3%
sub-neg55.3%
+-commutative55.3%
neg-mul-155.3%
neg-mul-155.3%
remove-double-neg55.3%
mul-1-neg55.3%
distribute-neg-in55.3%
+-commutative55.3%
cos-neg55.3%
+-commutative55.3%
mul-1-neg55.3%
unsub-neg55.3%
Simplified55.3%
Taylor expanded in lambda1 around 0 57.3%
Final simplification72.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_2 (- t_0 (* (sin phi1) (cos (- lambda2 lambda1))))))
(if (<= lambda2 -145000000.0)
(atan2 t_1 t_2)
(if (<= lambda2 0.075)
(atan2 t_1 (- t_0 (* (cos lambda1) (* (cos phi2) (sin phi1)))))
(atan2 (* (cos phi2) (sin (- lambda2))) 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 = t_0 - (sin(phi1) * cos((lambda2 - lambda1)));
double tmp;
if (lambda2 <= -145000000.0) {
tmp = atan2(t_1, t_2);
} else if (lambda2 <= 0.075) {
tmp = atan2(t_1, (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1)))));
} else {
tmp = atan2((cos(phi2) * sin(-lambda2)), 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 = t_0 - (sin(phi1) * cos((lambda2 - lambda1)))
if (lambda2 <= (-145000000.0d0)) then
tmp = atan2(t_1, t_2)
else if (lambda2 <= 0.075d0) then
tmp = atan2(t_1, (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1)))))
else
tmp = atan2((cos(phi2) * sin(-lambda2)), 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 = t_0 - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)));
double tmp;
if (lambda2 <= -145000000.0) {
tmp = Math.atan2(t_1, t_2);
} else if (lambda2 <= 0.075) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(lambda1) * (Math.cos(phi2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), 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 = t_0 - (math.sin(phi1) * math.cos((lambda2 - lambda1))) tmp = 0 if lambda2 <= -145000000.0: tmp = math.atan2(t_1, t_2) elif lambda2 <= 0.075: tmp = math.atan2(t_1, (t_0 - (math.cos(lambda1) * (math.cos(phi2) * math.sin(phi1))))) else: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), 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(t_0 - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1)))) tmp = 0.0 if (lambda2 <= -145000000.0) tmp = atan(t_1, t_2); elseif (lambda2 <= 0.075) tmp = atan(t_1, Float64(t_0 - Float64(cos(lambda1) * Float64(cos(phi2) * sin(phi1))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), 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 = t_0 - (sin(phi1) * cos((lambda2 - lambda1))); tmp = 0.0; if (lambda2 <= -145000000.0) tmp = atan2(t_1, t_2); elseif (lambda2 <= 0.075) tmp = atan2(t_1, (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1))))); else tmp = atan2((cos(phi2) * sin(-lambda2)), 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[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -145000000.0], N[ArcTan[t$95$1 / t$95$2], $MachinePrecision], If[LessEqual[lambda2, 0.075], 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], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / t$95$2], $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 := t_0 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\lambda_2 \leq -145000000:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_2}\\
\mathbf{elif}\;\lambda_2 \leq 0.075:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \lambda_1 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_2}\\
\end{array}
\end{array}
if lambda2 < -1.45e8Initial program 68.0%
Taylor expanded in phi2 around 0 55.7%
sub-neg55.7%
+-commutative55.7%
neg-mul-155.7%
neg-mul-155.7%
remove-double-neg55.7%
mul-1-neg55.7%
distribute-neg-in55.7%
+-commutative55.7%
cos-neg55.7%
+-commutative55.7%
mul-1-neg55.7%
unsub-neg55.7%
Simplified55.7%
if -1.45e8 < lambda2 < 0.0749999999999999972Initial program 98.0%
Taylor expanded in lambda2 around 0 97.6%
if 0.0749999999999999972 < lambda2 Initial program 62.5%
Taylor expanded in phi2 around 0 56.1%
sub-neg56.1%
+-commutative56.1%
neg-mul-156.1%
neg-mul-156.1%
remove-double-neg56.1%
mul-1-neg56.1%
distribute-neg-in56.1%
+-commutative56.1%
cos-neg56.1%
+-commutative56.1%
mul-1-neg56.1%
unsub-neg56.1%
Simplified56.1%
Taylor expanded in lambda1 around 0 58.1%
Final simplification78.2%
(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.5%
Final simplification82.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= (- lambda1 lambda2) -0.05) (not (<= (- lambda1 lambda2) 2e-33)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) (cos (- lambda2 lambda1)))))
(atan2
(* (cos phi2) (- lambda1 lambda2))
(- t_0 (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if (((lambda1 - lambda2) <= -0.05) || !((lambda1 - lambda2) <= 2e-33)) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = atan2((cos(phi2) * (lambda1 - lambda2)), (t_0 - ((cos(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) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if (((lambda1 - lambda2) <= (-0.05d0)) .or. (.not. ((lambda1 - lambda2) <= 2d-33))) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * cos((lambda2 - lambda1)))))
else
tmp = atan2((cos(phi2) * (lambda1 - lambda2)), (t_0 - ((cos(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 t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (((lambda1 - lambda2) <= -0.05) || !((lambda1 - lambda2) <= 2e-33)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * (lambda1 - lambda2)), (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if ((lambda1 - lambda2) <= -0.05) or not ((lambda1 - lambda2) <= 2e-33): tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2((math.cos(phi2) * (lambda1 - lambda2)), (t_0 - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((Float64(lambda1 - lambda2) <= -0.05) || !(Float64(lambda1 - lambda2) <= 2e-33)) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = atan(Float64(cos(phi2) * Float64(lambda1 - lambda2)), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if (((lambda1 - lambda2) <= -0.05) || ~(((lambda1 - lambda2) <= 2e-33))) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * cos((lambda2 - lambda1))))); else tmp = atan2((cos(phi2) * (lambda1 - lambda2)), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -0.05], N[Not[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 2e-33]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -0.05 \lor \neg \left(\lambda_1 - \lambda_2 \leq 2 \cdot 10^{-33}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\lambda_1 - \lambda_2\right)}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -0.050000000000000003 or 2.0000000000000001e-33 < (-.f64 lambda1 lambda2) Initial program 77.6%
Taylor expanded in phi2 around 0 64.1%
sub-neg64.1%
+-commutative64.1%
neg-mul-164.1%
neg-mul-164.1%
remove-double-neg64.1%
mul-1-neg64.1%
distribute-neg-in64.1%
+-commutative64.1%
cos-neg64.1%
+-commutative64.1%
mul-1-neg64.1%
unsub-neg64.1%
Simplified64.1%
if -0.050000000000000003 < (-.f64 lambda1 lambda2) < 2.0000000000000001e-33Initial program 99.8%
Taylor expanded in lambda1 around 0 99.8%
+-commutative99.8%
sin-neg99.8%
unsub-neg99.8%
cos-neg99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in lambda2 around 0 99.0%
*-commutative99.0%
associate-*r*99.0%
neg-mul-199.0%
distribute-rgt-out99.0%
sub-neg99.0%
Simplified99.0%
Final simplification71.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= lambda2 -145000000.0)
(atan2 t_1 (- t_0 (* (cos lambda2) (sin phi1))))
(if (<= lambda2 0.00049)
(atan2 t_1 (- t_0 (* (cos lambda1) (sin phi1))))
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_0 (* (sin phi1) (cos (- lambda2 lambda1)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -145000000.0) {
tmp = atan2(t_1, (t_0 - (cos(lambda2) * sin(phi1))));
} else if (lambda2 <= 0.00049) {
tmp = atan2(t_1, (t_0 - (cos(lambda1) * sin(phi1))));
} else {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (sin(phi1) * cos((lambda2 - lambda1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin((lambda1 - lambda2))
if (lambda2 <= (-145000000.0d0)) then
tmp = atan2(t_1, (t_0 - (cos(lambda2) * sin(phi1))))
else if (lambda2 <= 0.00049d0) then
tmp = atan2(t_1, (t_0 - (cos(lambda1) * sin(phi1))))
else
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (sin(phi1) * cos((lambda2 - lambda1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -145000000.0) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(lambda2) * Math.sin(phi1))));
} else if (lambda2 <= 0.00049) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(lambda1) * Math.sin(phi1))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_0 - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if lambda2 <= -145000000.0: tmp = math.atan2(t_1, (t_0 - (math.cos(lambda2) * math.sin(phi1)))) elif lambda2 <= 0.00049: tmp = math.atan2(t_1, (t_0 - (math.cos(lambda1) * math.sin(phi1)))) else: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_0 - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (lambda2 <= -145000000.0) tmp = atan(t_1, Float64(t_0 - Float64(cos(lambda2) * sin(phi1)))); elseif (lambda2 <= 0.00049) tmp = atan(t_1, Float64(t_0 - Float64(cos(lambda1) * sin(phi1)))); else tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (lambda2 <= -145000000.0) tmp = atan2(t_1, (t_0 - (cos(lambda2) * sin(phi1)))); elseif (lambda2 <= 0.00049) tmp = atan2(t_1, (t_0 - (cos(lambda1) * sin(phi1)))); else tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (sin(phi1) * cos((lambda2 - lambda1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -145000000.0], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 0.00049], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_2 \leq -145000000:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \lambda_2 \cdot \sin \phi_1}\\
\mathbf{elif}\;\lambda_2 \leq 0.00049:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \lambda_1 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_0 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\end{array}
\end{array}
if lambda2 < -1.45e8Initial program 68.0%
Taylor expanded in phi2 around 0 55.7%
sub-neg55.7%
+-commutative55.7%
neg-mul-155.7%
neg-mul-155.7%
remove-double-neg55.7%
mul-1-neg55.7%
distribute-neg-in55.7%
+-commutative55.7%
cos-neg55.7%
+-commutative55.7%
mul-1-neg55.7%
unsub-neg55.7%
Simplified55.7%
Taylor expanded in lambda1 around 0 55.5%
if -1.45e8 < lambda2 < 4.8999999999999998e-4Initial program 98.0%
Taylor expanded in phi2 around 0 78.1%
sub-neg78.1%
+-commutative78.1%
neg-mul-178.1%
neg-mul-178.1%
remove-double-neg78.1%
mul-1-neg78.1%
distribute-neg-in78.1%
+-commutative78.1%
cos-neg78.1%
+-commutative78.1%
mul-1-neg78.1%
unsub-neg78.1%
Simplified78.1%
Taylor expanded in lambda2 around 0 78.1%
cos-neg54.7%
Simplified78.1%
if 4.8999999999999998e-4 < lambda2 Initial program 63.1%
Taylor expanded in phi2 around 0 55.3%
sub-neg55.3%
+-commutative55.3%
neg-mul-155.3%
neg-mul-155.3%
remove-double-neg55.3%
mul-1-neg55.3%
distribute-neg-in55.3%
+-commutative55.3%
cos-neg55.3%
+-commutative55.3%
mul-1-neg55.3%
unsub-neg55.3%
Simplified55.3%
Taylor expanded in lambda1 around 0 57.3%
Final simplification67.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -0.000195) (not (<= phi2 0.0001)))
(atan2 (* (cos phi2) t_1) (- t_0 (* (cos lambda1) (sin phi1))))
(atan2
(/ (* t_1 2.0) 2.0)
(- t_0 (* (sin phi1) (cos (- lambda2 lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.000195) || !(phi2 <= 0.0001)) {
tmp = atan2((cos(phi2) * t_1), (t_0 - (cos(lambda1) * sin(phi1))));
} else {
tmp = atan2(((t_1 * 2.0) / 2.0), (t_0 - (sin(phi1) * cos((lambda2 - lambda1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin((lambda1 - lambda2))
if ((phi2 <= (-0.000195d0)) .or. (.not. (phi2 <= 0.0001d0))) then
tmp = atan2((cos(phi2) * t_1), (t_0 - (cos(lambda1) * sin(phi1))))
else
tmp = atan2(((t_1 * 2.0d0) / 2.0d0), (t_0 - (sin(phi1) * cos((lambda2 - lambda1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.000195) || !(phi2 <= 0.0001)) {
tmp = Math.atan2((Math.cos(phi2) * t_1), (t_0 - (Math.cos(lambda1) * Math.sin(phi1))));
} else {
tmp = Math.atan2(((t_1 * 2.0) / 2.0), (t_0 - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi2 <= -0.000195) or not (phi2 <= 0.0001): tmp = math.atan2((math.cos(phi2) * t_1), (t_0 - (math.cos(lambda1) * math.sin(phi1)))) else: tmp = math.atan2(((t_1 * 2.0) / 2.0), (t_0 - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -0.000195) || !(phi2 <= 0.0001)) tmp = atan(Float64(cos(phi2) * t_1), Float64(t_0 - Float64(cos(lambda1) * sin(phi1)))); else tmp = atan(Float64(Float64(t_1 * 2.0) / 2.0), Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi2 <= -0.000195) || ~((phi2 <= 0.0001))) tmp = atan2((cos(phi2) * t_1), (t_0 - (cos(lambda1) * sin(phi1)))); else tmp = atan2(((t_1 * 2.0) / 2.0), (t_0 - (sin(phi1) * cos((lambda2 - lambda1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.000195], N[Not[LessEqual[phi2, 0.0001]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(t$95$1 * 2.0), $MachinePrecision] / 2.0), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.000195 \lor \neg \left(\phi_2 \leq 0.0001\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_1}{t_0 - \cos \lambda_1 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\frac{t_1 \cdot 2}{2}}{t_0 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\end{array}
\end{array}
if phi2 < -1.94999999999999996e-4 or 1.00000000000000005e-4 < phi2 Initial program 77.4%
Taylor expanded in phi2 around 0 50.2%
sub-neg50.2%
+-commutative50.2%
neg-mul-150.2%
neg-mul-150.2%
remove-double-neg50.2%
mul-1-neg50.2%
distribute-neg-in50.2%
+-commutative50.2%
cos-neg50.2%
+-commutative50.2%
mul-1-neg50.2%
unsub-neg50.2%
Simplified50.2%
Taylor expanded in lambda2 around 0 49.8%
cos-neg46.0%
Simplified49.8%
if -1.94999999999999996e-4 < phi2 < 1.00000000000000005e-4Initial program 88.8%
Taylor expanded in phi2 around 0 88.8%
sub-neg88.8%
+-commutative88.8%
neg-mul-188.8%
neg-mul-188.8%
remove-double-neg88.8%
mul-1-neg88.8%
distribute-neg-in88.8%
+-commutative88.8%
cos-neg88.8%
+-commutative88.8%
mul-1-neg88.8%
unsub-neg88.8%
Simplified88.8%
sin-cos-mult85.4%
associate--l-85.4%
Applied egg-rr85.4%
associate--r+85.4%
Simplified85.4%
Taylor expanded in phi2 around 0 88.8%
Final simplification67.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= lambda2 -145000000.0)
(atan2 t_1 (- t_0 (* (cos lambda2) (sin phi1))))
(atan2 t_1 (- t_0 (* (cos lambda1) (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -145000000.0) {
tmp = atan2(t_1, (t_0 - (cos(lambda2) * sin(phi1))));
} else {
tmp = atan2(t_1, (t_0 - (cos(lambda1) * sin(phi1))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin((lambda1 - lambda2))
if (lambda2 <= (-145000000.0d0)) then
tmp = atan2(t_1, (t_0 - (cos(lambda2) * sin(phi1))))
else
tmp = atan2(t_1, (t_0 - (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 t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -145000000.0) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(lambda2) * Math.sin(phi1))));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(lambda1) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if lambda2 <= -145000000.0: tmp = math.atan2(t_1, (t_0 - (math.cos(lambda2) * math.sin(phi1)))) else: tmp = math.atan2(t_1, (t_0 - (math.cos(lambda1) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (lambda2 <= -145000000.0) tmp = atan(t_1, Float64(t_0 - Float64(cos(lambda2) * sin(phi1)))); else tmp = atan(t_1, Float64(t_0 - Float64(cos(lambda1) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (lambda2 <= -145000000.0) tmp = atan2(t_1, (t_0 - (cos(lambda2) * sin(phi1)))); else tmp = atan2(t_1, (t_0 - (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]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -145000000.0], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_2 \leq -145000000:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \lambda_2 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \lambda_1 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if lambda2 < -1.45e8Initial program 68.0%
Taylor expanded in phi2 around 0 55.7%
sub-neg55.7%
+-commutative55.7%
neg-mul-155.7%
neg-mul-155.7%
remove-double-neg55.7%
mul-1-neg55.7%
distribute-neg-in55.7%
+-commutative55.7%
cos-neg55.7%
+-commutative55.7%
mul-1-neg55.7%
unsub-neg55.7%
Simplified55.7%
Taylor expanded in lambda1 around 0 55.5%
if -1.45e8 < lambda2 Initial program 87.4%
Taylor expanded in phi2 around 0 71.2%
sub-neg71.2%
+-commutative71.2%
neg-mul-171.2%
neg-mul-171.2%
remove-double-neg71.2%
mul-1-neg71.2%
distribute-neg-in71.2%
+-commutative71.2%
cos-neg71.2%
+-commutative71.2%
mul-1-neg71.2%
unsub-neg71.2%
Simplified71.2%
Taylor expanded in lambda2 around 0 69.6%
cos-neg52.7%
Simplified69.6%
Final simplification66.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (sin phi1) (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda2 - lambda1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda2 - lambda1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 82.5%
Taylor expanded in phi2 around 0 67.3%
sub-neg67.3%
+-commutative67.3%
neg-mul-167.3%
neg-mul-167.3%
remove-double-neg67.3%
mul-1-neg67.3%
distribute-neg-in67.3%
+-commutative67.3%
cos-neg67.3%
+-commutative67.3%
mul-1-neg67.3%
unsub-neg67.3%
Simplified67.3%
Final simplification67.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (* (cos phi2) t_0))
(t_2 (* (cos phi1) (sin phi2)))
(t_3 (cos (- lambda2 lambda1))))
(if (<= phi2 -52.0)
(atan2 t_1 (- t_2 (* (cos lambda2) phi1)))
(if (<= phi2 0.00037)
(atan2 (/ (* t_0 2.0) 2.0) (- t_2 (* (sin phi1) t_3)))
(atan2
t_1
(- (* (sin phi2) (+ (* -0.5 (* phi1 phi1)) 1.0)) (* phi1 t_3)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = cos(phi2) * t_0;
double t_2 = cos(phi1) * sin(phi2);
double t_3 = cos((lambda2 - lambda1));
double tmp;
if (phi2 <= -52.0) {
tmp = atan2(t_1, (t_2 - (cos(lambda2) * phi1)));
} else if (phi2 <= 0.00037) {
tmp = atan2(((t_0 * 2.0) / 2.0), (t_2 - (sin(phi1) * t_3)));
} else {
tmp = atan2(t_1, ((sin(phi2) * ((-0.5 * (phi1 * phi1)) + 1.0)) - (phi1 * t_3)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
t_1 = cos(phi2) * t_0
t_2 = cos(phi1) * sin(phi2)
t_3 = cos((lambda2 - lambda1))
if (phi2 <= (-52.0d0)) then
tmp = atan2(t_1, (t_2 - (cos(lambda2) * phi1)))
else if (phi2 <= 0.00037d0) then
tmp = atan2(((t_0 * 2.0d0) / 2.0d0), (t_2 - (sin(phi1) * t_3)))
else
tmp = atan2(t_1, ((sin(phi2) * (((-0.5d0) * (phi1 * phi1)) + 1.0d0)) - (phi1 * t_3)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double t_1 = Math.cos(phi2) * t_0;
double t_2 = Math.cos(phi1) * Math.sin(phi2);
double t_3 = Math.cos((lambda2 - lambda1));
double tmp;
if (phi2 <= -52.0) {
tmp = Math.atan2(t_1, (t_2 - (Math.cos(lambda2) * phi1)));
} else if (phi2 <= 0.00037) {
tmp = Math.atan2(((t_0 * 2.0) / 2.0), (t_2 - (Math.sin(phi1) * t_3)));
} else {
tmp = Math.atan2(t_1, ((Math.sin(phi2) * ((-0.5 * (phi1 * phi1)) + 1.0)) - (phi1 * t_3)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = math.cos(phi2) * t_0 t_2 = math.cos(phi1) * math.sin(phi2) t_3 = math.cos((lambda2 - lambda1)) tmp = 0 if phi2 <= -52.0: tmp = math.atan2(t_1, (t_2 - (math.cos(lambda2) * phi1))) elif phi2 <= 0.00037: tmp = math.atan2(((t_0 * 2.0) / 2.0), (t_2 - (math.sin(phi1) * t_3))) else: tmp = math.atan2(t_1, ((math.sin(phi2) * ((-0.5 * (phi1 * phi1)) + 1.0)) - (phi1 * t_3))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi2) * t_0) t_2 = Float64(cos(phi1) * sin(phi2)) t_3 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi2 <= -52.0) tmp = atan(t_1, Float64(t_2 - Float64(cos(lambda2) * phi1))); elseif (phi2 <= 0.00037) tmp = atan(Float64(Float64(t_0 * 2.0) / 2.0), Float64(t_2 - Float64(sin(phi1) * t_3))); else tmp = atan(t_1, Float64(Float64(sin(phi2) * Float64(Float64(-0.5 * Float64(phi1 * phi1)) + 1.0)) - Float64(phi1 * t_3))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = cos(phi2) * t_0; t_2 = cos(phi1) * sin(phi2); t_3 = cos((lambda2 - lambda1)); tmp = 0.0; if (phi2 <= -52.0) tmp = atan2(t_1, (t_2 - (cos(lambda2) * phi1))); elseif (phi2 <= 0.00037) tmp = atan2(((t_0 * 2.0) / 2.0), (t_2 - (sin(phi1) * t_3))); else tmp = atan2(t_1, ((sin(phi2) * ((-0.5 * (phi1 * phi1)) + 1.0)) - (phi1 * t_3))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -52.0], N[ArcTan[t$95$1 / N[(t$95$2 - N[(N[Cos[lambda2], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 0.00037], N[ArcTan[N[(N[(t$95$0 * 2.0), $MachinePrecision] / 2.0), $MachinePrecision] / N[(t$95$2 - N[(N[Sin[phi1], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[(N[Sin[phi2], $MachinePrecision] * N[(N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(phi1 * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_2 \cdot t_0\\
t_2 := \cos \phi_1 \cdot \sin \phi_2\\
t_3 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_2 \leq -52:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_2 - \cos \lambda_2 \cdot \phi_1}\\
\mathbf{elif}\;\phi_2 \leq 0.00037:\\
\;\;\;\;\tan^{-1}_* \frac{\frac{t_0 \cdot 2}{2}}{t_2 - \sin \phi_1 \cdot t_3}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{\sin \phi_2 \cdot \left(-0.5 \cdot \left(\phi_1 \cdot \phi_1\right) + 1\right) - \phi_1 \cdot t_3}\\
\end{array}
\end{array}
if phi2 < -52Initial program 74.6%
Taylor expanded in phi2 around 0 45.9%
sub-neg45.9%
+-commutative45.9%
neg-mul-145.9%
neg-mul-145.9%
remove-double-neg45.9%
mul-1-neg45.9%
distribute-neg-in45.9%
+-commutative45.9%
cos-neg45.9%
+-commutative45.9%
mul-1-neg45.9%
unsub-neg45.9%
Simplified45.9%
Taylor expanded in phi1 around 0 44.0%
Taylor expanded in lambda1 around 0 45.0%
if -52 < phi2 < 3.6999999999999999e-4Initial program 88.3%
Taylor expanded in phi2 around 0 88.3%
sub-neg88.3%
+-commutative88.3%
neg-mul-188.3%
neg-mul-188.3%
remove-double-neg88.3%
mul-1-neg88.3%
distribute-neg-in88.3%
+-commutative88.3%
cos-neg88.3%
+-commutative88.3%
mul-1-neg88.3%
unsub-neg88.3%
Simplified88.3%
sin-cos-mult84.9%
associate--l-84.9%
Applied egg-rr84.9%
associate--r+84.9%
Simplified84.9%
Taylor expanded in phi2 around 0 88.2%
if 3.6999999999999999e-4 < phi2 Initial program 80.7%
Taylor expanded in phi2 around 0 54.4%
sub-neg54.4%
+-commutative54.4%
neg-mul-154.4%
neg-mul-154.4%
remove-double-neg54.4%
mul-1-neg54.4%
distribute-neg-in54.4%
+-commutative54.4%
cos-neg54.4%
+-commutative54.4%
mul-1-neg54.4%
unsub-neg54.4%
Simplified54.4%
Taylor expanded in phi1 around 0 48.3%
Taylor expanded in phi1 around 0 48.7%
associate-*r*48.7%
distribute-lft1-in48.7%
unpow248.7%
Simplified48.7%
Final simplification65.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (sin phi2) (+ (* -0.5 (* phi1 phi1)) 1.0)) (* phi1 (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((sin(phi2) * ((-0.5 * (phi1 * phi1)) + 1.0)) - (phi1 * cos((lambda2 - lambda1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((sin(phi2) * (((-0.5d0) * (phi1 * phi1)) + 1.0d0)) - (phi1 * cos((lambda2 - lambda1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.sin(phi2) * ((-0.5 * (phi1 * phi1)) + 1.0)) - (phi1 * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.sin(phi2) * ((-0.5 * (phi1 * phi1)) + 1.0)) - (phi1 * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(sin(phi2) * Float64(Float64(-0.5 * Float64(phi1 * phi1)) + 1.0)) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((sin(phi2) * ((-0.5 * (phi1 * phi1)) + 1.0)) - (phi1 * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sin[phi2], $MachinePrecision] * N[(N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 \cdot \left(-0.5 \cdot \left(\phi_1 \cdot \phi_1\right) + 1\right) - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 82.5%
Taylor expanded in phi2 around 0 67.3%
sub-neg67.3%
+-commutative67.3%
neg-mul-167.3%
neg-mul-167.3%
remove-double-neg67.3%
mul-1-neg67.3%
distribute-neg-in67.3%
+-commutative67.3%
cos-neg67.3%
+-commutative67.3%
mul-1-neg67.3%
unsub-neg67.3%
Simplified67.3%
Taylor expanded in phi1 around 0 49.0%
Taylor expanded in phi1 around 0 49.7%
associate-*r*49.7%
distribute-lft1-in49.7%
unpow249.7%
Simplified49.7%
Final simplification49.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin lambda1) (cos phi2)) (- (sin phi2) (* phi1 (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin(lambda1) * math.cos(phi2)), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(lambda1) * cos(phi2)), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 82.5%
Taylor expanded in phi2 around 0 67.3%
sub-neg67.3%
+-commutative67.3%
neg-mul-167.3%
neg-mul-167.3%
remove-double-neg67.3%
mul-1-neg67.3%
distribute-neg-in67.3%
+-commutative67.3%
cos-neg67.3%
+-commutative67.3%
mul-1-neg67.3%
unsub-neg67.3%
Simplified67.3%
Taylor expanded in phi1 around 0 49.0%
Taylor expanded in phi1 around 0 49.0%
Taylor expanded in lambda2 around 0 33.4%
Final simplification33.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) (* (cos lambda1) phi1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda1) * phi1)));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda1) * phi1)))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.cos(lambda1) * phi1)));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.cos(lambda1) * phi1)))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(cos(lambda1) * phi1))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda1) * phi1))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \lambda_1 \cdot \phi_1}
\end{array}
Initial program 82.5%
Taylor expanded in phi2 around 0 67.3%
sub-neg67.3%
+-commutative67.3%
neg-mul-167.3%
neg-mul-167.3%
remove-double-neg67.3%
mul-1-neg67.3%
distribute-neg-in67.3%
+-commutative67.3%
cos-neg67.3%
+-commutative67.3%
mul-1-neg67.3%
unsub-neg67.3%
Simplified67.3%
Taylor expanded in phi1 around 0 49.0%
Taylor expanded in phi1 around 0 49.0%
Taylor expanded in lambda2 around 0 49.0%
cos-neg49.0%
Simplified49.0%
Final simplification49.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) (* (cos lambda2) phi1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda2) * phi1)));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda2) * phi1)))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.cos(lambda2) * phi1)));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.cos(lambda2) * phi1)))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(cos(lambda2) * phi1))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda2) * phi1))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda2], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \lambda_2 \cdot \phi_1}
\end{array}
Initial program 82.5%
Taylor expanded in phi2 around 0 67.3%
sub-neg67.3%
+-commutative67.3%
neg-mul-167.3%
neg-mul-167.3%
remove-double-neg67.3%
mul-1-neg67.3%
distribute-neg-in67.3%
+-commutative67.3%
cos-neg67.3%
+-commutative67.3%
mul-1-neg67.3%
unsub-neg67.3%
Simplified67.3%
Taylor expanded in phi1 around 0 49.0%
Taylor expanded in phi1 around 0 49.0%
Taylor expanded in lambda1 around 0 49.2%
Final simplification49.2%
herbie shell --seed 2023174
(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))))))