
(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 26 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))
(+ (* (cos lambda2) (cos lambda1)) (* (sin lambda1) (sin lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * ((Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda1) * Math.sin(lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * ((math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda1) * math.sin(lambda2))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda1) * sin(lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\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(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 82.3%
sin-diff89.5%
sub-neg89.5%
Applied egg-rr89.5%
sub-neg89.5%
Simplified89.5%
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 lambda2) (cos lambda1)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_2 (* (cos phi2) (sin phi1))))
(if (or (<= phi2 -4e-15) (not (<= phi2 1e-34)))
(atan2 t_1 (- (* (cos phi1) (sin phi2)) (* t_2 t_0)))
(atan2
t_1
(- (sin phi2) (* t_2 (+ t_0 (* (sin lambda1) (sin lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda2) * cos(lambda1);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_2 = cos(phi2) * sin(phi1);
double tmp;
if ((phi2 <= -4e-15) || !(phi2 <= 1e-34)) {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (t_2 * t_0)));
} else {
tmp = atan2(t_1, (sin(phi2) - (t_2 * (t_0 + (sin(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) :: t_2
real(8) :: tmp
t_0 = cos(lambda2) * cos(lambda1)
t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)
t_2 = cos(phi2) * sin(phi1)
if ((phi2 <= (-4d-15)) .or. (.not. (phi2 <= 1d-34))) then
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (t_2 * t_0)))
else
tmp = atan2(t_1, (sin(phi2) - (t_2 * (t_0 + (sin(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(lambda2) * Math.cos(lambda1);
double t_1 = ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2);
double t_2 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if ((phi2 <= -4e-15) || !(phi2 <= 1e-34)) {
tmp = Math.atan2(t_1, ((Math.cos(phi1) * Math.sin(phi2)) - (t_2 * t_0)));
} else {
tmp = Math.atan2(t_1, (Math.sin(phi2) - (t_2 * (t_0 + (Math.sin(lambda1) * Math.sin(lambda2))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda2) * math.cos(lambda1) t_1 = ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2) t_2 = math.cos(phi2) * math.sin(phi1) tmp = 0 if (phi2 <= -4e-15) or not (phi2 <= 1e-34): tmp = math.atan2(t_1, ((math.cos(phi1) * math.sin(phi2)) - (t_2 * t_0))) else: tmp = math.atan2(t_1, (math.sin(phi2) - (t_2 * (t_0 + (math.sin(lambda1) * math.sin(lambda2)))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda2) * cos(lambda1)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_2 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if ((phi2 <= -4e-15) || !(phi2 <= 1e-34)) tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_2 * t_0))); else tmp = atan(t_1, Float64(sin(phi2) - Float64(t_2 * Float64(t_0 + Float64(sin(lambda1) * sin(lambda2)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(lambda2) * cos(lambda1); t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2); t_2 = cos(phi2) * sin(phi1); tmp = 0.0; if ((phi2 <= -4e-15) || ~((phi2 <= 1e-34))) tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (t_2 * t_0))); else tmp = atan2(t_1, (sin(phi2) - (t_2 * (t_0 + (sin(lambda1) * sin(lambda2)))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -4e-15], N[Not[LessEqual[phi2, 1e-34]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$2 * N[(t$95$0 + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_2 \cdot \cos \lambda_1\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \cos \phi_2 \cdot \sin \phi_1\\
\mathbf{if}\;\phi_2 \leq -4 \cdot 10^{-15} \lor \neg \left(\phi_2 \leq 10^{-34}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{\cos \phi_1 \cdot \sin \phi_2 - t_2 \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{\sin \phi_2 - t_2 \cdot \left(t_0 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -4.0000000000000003e-15 or 9.99999999999999928e-35 < phi2 Initial program 83.7%
sin-diff92.4%
sub-neg92.4%
Applied egg-rr92.4%
sub-neg92.4%
Simplified92.4%
cos-diff99.7%
+-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
sin-mult92.7%
cos-diff92.7%
*-commutative92.7%
+-commutative92.7%
cos-sum99.7%
*-commutative99.7%
*-commutative99.7%
cos-sum92.7%
div-sub92.7%
Applied egg-rr92.7%
+-inverses92.7%
Simplified92.7%
if -4.0000000000000003e-15 < phi2 < 9.99999999999999928e-35Initial program 80.5%
sin-diff85.3%
sub-neg85.3%
Applied egg-rr85.3%
sub-neg85.3%
Simplified85.3%
cos-diff99.9%
+-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in phi1 around 0 99.9%
Final simplification95.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda2) (cos lambda1)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))))
(if (or (<= phi2 -8.8e-7) (not (<= phi2 1e-31)))
(atan2 t_2 (- t_1 (* (* (cos phi2) (sin phi1)) t_0)))
(atan2
t_2
(- t_1 (* (sin phi1) (+ t_0 (* (sin lambda1) (sin lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda2) * cos(lambda1);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double tmp;
if ((phi2 <= -8.8e-7) || !(phi2 <= 1e-31)) {
tmp = atan2(t_2, (t_1 - ((cos(phi2) * sin(phi1)) * t_0)));
} else {
tmp = atan2(t_2, (t_1 - (sin(phi1) * (t_0 + (sin(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) :: t_2
real(8) :: tmp
t_0 = cos(lambda2) * cos(lambda1)
t_1 = cos(phi1) * sin(phi2)
t_2 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)
if ((phi2 <= (-8.8d-7)) .or. (.not. (phi2 <= 1d-31))) then
tmp = atan2(t_2, (t_1 - ((cos(phi2) * sin(phi1)) * t_0)))
else
tmp = atan2(t_2, (t_1 - (sin(phi1) * (t_0 + (sin(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(lambda2) * Math.cos(lambda1);
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double t_2 = ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2);
double tmp;
if ((phi2 <= -8.8e-7) || !(phi2 <= 1e-31)) {
tmp = Math.atan2(t_2, (t_1 - ((Math.cos(phi2) * Math.sin(phi1)) * t_0)));
} else {
tmp = Math.atan2(t_2, (t_1 - (Math.sin(phi1) * (t_0 + (Math.sin(lambda1) * Math.sin(lambda2))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda2) * math.cos(lambda1) t_1 = math.cos(phi1) * math.sin(phi2) t_2 = ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2) tmp = 0 if (phi2 <= -8.8e-7) or not (phi2 <= 1e-31): tmp = math.atan2(t_2, (t_1 - ((math.cos(phi2) * math.sin(phi1)) * t_0))) else: tmp = math.atan2(t_2, (t_1 - (math.sin(phi1) * (t_0 + (math.sin(lambda1) * math.sin(lambda2)))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda2) * cos(lambda1)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) tmp = 0.0 if ((phi2 <= -8.8e-7) || !(phi2 <= 1e-31)) tmp = atan(t_2, Float64(t_1 - Float64(Float64(cos(phi2) * sin(phi1)) * t_0))); else tmp = atan(t_2, Float64(t_1 - Float64(sin(phi1) * Float64(t_0 + Float64(sin(lambda1) * sin(lambda2)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(lambda2) * cos(lambda1); t_1 = cos(phi1) * sin(phi2); t_2 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2); tmp = 0.0; if ((phi2 <= -8.8e-7) || ~((phi2 <= 1e-31))) tmp = atan2(t_2, (t_1 - ((cos(phi2) * sin(phi1)) * t_0))); else tmp = atan2(t_2, (t_1 - (sin(phi1) * (t_0 + (sin(lambda1) * sin(lambda2)))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -8.8e-7], N[Not[LessEqual[phi2, 1e-31]], $MachinePrecision]], N[ArcTan[t$95$2 / N[(t$95$1 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[(t$95$0 + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_2 \cdot \cos \lambda_1\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -8.8 \cdot 10^{-7} \lor \neg \left(\phi_2 \leq 10^{-31}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_1 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_1 - \sin \phi_1 \cdot \left(t_0 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -8.8000000000000004e-7 or 1e-31 < phi2 Initial program 83.5%
sin-diff92.2%
sub-neg92.2%
Applied egg-rr92.2%
sub-neg92.2%
Simplified92.2%
cos-diff99.7%
+-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
sin-mult92.5%
cos-diff92.5%
*-commutative92.5%
+-commutative92.5%
cos-sum99.7%
*-commutative99.7%
*-commutative99.7%
cos-sum92.5%
div-sub92.5%
Applied egg-rr92.5%
+-inverses92.5%
Simplified92.5%
if -8.8000000000000004e-7 < phi2 < 1e-31Initial program 80.9%
sin-diff85.9%
sub-neg85.9%
Applied egg-rr85.9%
sub-neg85.9%
Simplified85.9%
cos-diff99.9%
+-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in phi2 around 0 99.9%
Final simplification95.7%
(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 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)) * (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)) * (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.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.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(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)) * (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[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $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(\cos \lambda_2 \cdot \cos \lambda_1\right)}
\end{array}
Initial program 82.3%
sin-diff89.5%
sub-neg89.5%
Applied egg-rr89.5%
sub-neg89.5%
Simplified89.5%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
sin-mult89.7%
cos-diff89.7%
*-commutative89.7%
+-commutative89.7%
cos-sum99.8%
*-commutative99.8%
*-commutative99.8%
cos-sum89.7%
div-sub89.7%
Applied egg-rr89.7%
+-inverses89.7%
Simplified89.7%
Final simplification89.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (cos phi2) (sin phi1))))
(if (or (<= lambda1 -0.53) (not (<= lambda1 6e-21)))
(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 (- 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 tmp;
if ((lambda1 <= -0.53) || !(lambda1 <= 6e-21)) {
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((lambda1 - lambda2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
if ((lambda1 <= (-0.53d0)) .or. (.not. (lambda1 <= 6d-21))) 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((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 tmp;
if ((lambda1 <= -0.53) || !(lambda1 <= 6e-21)) {
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((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) tmp = 0 if (lambda1 <= -0.53) or not (lambda1 <= 6e-21): 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((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if ((lambda1 <= -0.53) || !(lambda1 <= 6e-21)) 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 * 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); tmp = 0.0; if ((lambda1 <= -0.53) || ~((lambda1 <= 6e-21))) 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((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]}, If[Or[LessEqual[lambda1, -0.53], N[Not[LessEqual[lambda1, 6e-21]], $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[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\\
\mathbf{if}\;\lambda_1 \leq -0.53 \lor \neg \left(\lambda_1 \leq 6 \cdot 10^{-21}\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 \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda1 < -0.53000000000000003 or 5.99999999999999982e-21 < lambda1 Initial program 65.2%
sin-diff79.6%
sub-neg79.6%
Applied egg-rr79.6%
sub-neg79.6%
Simplified79.6%
Taylor expanded in lambda2 around 0 79.5%
if -0.53000000000000003 < lambda1 < 5.99999999999999982e-21Initial program 99.0%
Taylor expanded in lambda1 around 0 99.0%
sin-neg99.0%
cos-neg99.0%
*-commutative99.0%
Simplified99.0%
Final simplification89.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (cos phi2) (sin phi1))))
(if (or (<= lambda2 -3.9e-7) (not (<= lambda2 1e-48)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* (cos lambda2) t_1)))
(atan2
(* (cos phi2) (log1p (expm1 (sin (- lambda1 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 tmp;
if ((lambda2 <= -3.9e-7) || !(lambda2 <= 1e-48)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda2) * t_1)));
} else {
tmp = atan2((cos(phi2) * log1p(expm1(sin((lambda1 - lambda2))))), (t_0 - (t_1 * cos((lambda1 - lambda2)))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if ((lambda2 <= -3.9e-7) || !(lambda2 <= 1e-48)) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (Math.cos(lambda2) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.log1p(Math.expm1(Math.sin((lambda1 - 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) tmp = 0 if (lambda2 <= -3.9e-7) or not (lambda2 <= 1e-48): tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (math.cos(lambda2) * t_1))) else: tmp = math.atan2((math.cos(phi2) * math.log1p(math.expm1(math.sin((lambda1 - 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)) tmp = 0.0 if ((lambda2 <= -3.9e-7) || !(lambda2 <= 1e-48)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(cos(lambda2) * t_1))); else tmp = atan(Float64(cos(phi2) * log1p(expm1(sin(Float64(lambda1 - lambda2))))), Float64(t_0 - Float64(t_1 * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -3.9e-7], N[Not[LessEqual[lambda2, 1e-48]], $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[lambda2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Log[1 + N[(Exp[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $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\\
\mathbf{if}\;\lambda_2 \leq -3.9 \cdot 10^{-7} \lor \neg \left(\lambda_2 \leq 10^{-48}\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_2 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin \left(\lambda_1 - \lambda_2\right)\right)\right)}{t_0 - t_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda2 < -3.90000000000000025e-7 or 9.9999999999999997e-49 < lambda2 Initial program 67.4%
sin-diff80.6%
sub-neg80.6%
Applied egg-rr80.6%
sub-neg80.6%
Simplified80.6%
Taylor expanded in lambda1 around 0 80.7%
cos-neg80.7%
Simplified80.7%
if -3.90000000000000025e-7 < lambda2 < 9.9999999999999997e-49Initial program 99.8%
log1p-expm1-u99.8%
Applied egg-rr99.8%
Final simplification89.5%
(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.3%
sin-diff89.5%
sub-neg89.5%
Applied egg-rr89.5%
sub-neg89.5%
Simplified89.5%
Final simplification89.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (sin (- lambda1 lambda2))))
(if (<= phi1 -1.88)
(atan2 (* (cos phi2) t_2) (- t_0 (* (sin phi1) (* (cos phi2) t_1))))
(if (<= phi1 4.9e-55)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* phi1 (cos (- lambda2 lambda1)))))
(atan2
(* (cos phi2) (expm1 (log1p t_2)))
(- t_0 (* (* (cos phi2) (sin phi1)) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.88) {
tmp = atan2((cos(phi2) * t_2), (t_0 - (sin(phi1) * (cos(phi2) * t_1))));
} else if (phi1 <= 4.9e-55) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))));
} else {
tmp = atan2((cos(phi2) * expm1(log1p(t_2))), (t_0 - ((cos(phi2) * sin(phi1)) * t_1)));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.88) {
tmp = Math.atan2((Math.cos(phi2) * t_2), (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * t_1))));
} else if (phi1 <= 4.9e-55) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.expm1(Math.log1p(t_2))), (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -1.88: tmp = math.atan2((math.cos(phi2) * t_2), (t_0 - (math.sin(phi1) * (math.cos(phi2) * t_1)))) elif phi1 <= 4.9e-55: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2((math.cos(phi2) * math.expm1(math.log1p(t_2))), (t_0 - ((math.cos(phi2) * math.sin(phi1)) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -1.88) tmp = atan(Float64(cos(phi2) * t_2), Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * t_1)))); elseif (phi1 <= 4.9e-55) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); else tmp = atan(Float64(cos(phi2) * expm1(log1p(t_2))), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * t_1))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.88], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 4.9e-55], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(Exp[N[Log[1 + t$95$2], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.88:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_2}{t_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 4.9 \cdot 10^{-55}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(t_2\right)\right)}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_1}\\
\end{array}
\end{array}
if phi1 < -1.8799999999999999Initial program 76.4%
associate-*l*76.4%
Simplified76.4%
if -1.8799999999999999 < phi1 < 4.90000000000000035e-55Initial program 85.8%
associate-*l*85.8%
Simplified85.8%
Taylor expanded in phi2 around 0 85.8%
sub-neg85.8%
+-commutative85.8%
neg-mul-185.8%
neg-mul-185.8%
remove-double-neg85.8%
mul-1-neg85.8%
distribute-neg-in85.8%
+-commutative85.8%
cos-neg85.8%
+-commutative85.8%
mul-1-neg85.8%
unsub-neg85.8%
Simplified85.8%
Taylor expanded in phi1 around 0 85.8%
Taylor expanded in phi1 around 0 85.8%
sin-diff98.7%
sub-neg98.7%
Applied egg-rr98.7%
sub-neg98.7%
Simplified98.7%
if 4.90000000000000035e-55 < phi1 Initial program 82.0%
expm1-log1p-u82.0%
Applied egg-rr82.0%
Final simplification88.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (sin (- lambda1 lambda2))))
(if (<= phi1 -1.88)
(atan2 (* (cos phi2) t_2) (- t_0 (* (sin phi1) (* (cos phi2) t_1))))
(if (<= phi1 4.9e-55)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* phi1 (cos (- lambda2 lambda1)))))
(atan2
(* (cos phi2) (log1p (expm1 t_2)))
(- t_0 (* (* (cos phi2) (sin phi1)) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.88) {
tmp = atan2((cos(phi2) * t_2), (t_0 - (sin(phi1) * (cos(phi2) * t_1))));
} else if (phi1 <= 4.9e-55) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))));
} else {
tmp = atan2((cos(phi2) * log1p(expm1(t_2))), (t_0 - ((cos(phi2) * sin(phi1)) * t_1)));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.88) {
tmp = Math.atan2((Math.cos(phi2) * t_2), (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * t_1))));
} else if (phi1 <= 4.9e-55) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.log1p(Math.expm1(t_2))), (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -1.88: tmp = math.atan2((math.cos(phi2) * t_2), (t_0 - (math.sin(phi1) * (math.cos(phi2) * t_1)))) elif phi1 <= 4.9e-55: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2((math.cos(phi2) * math.log1p(math.expm1(t_2))), (t_0 - ((math.cos(phi2) * math.sin(phi1)) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -1.88) tmp = atan(Float64(cos(phi2) * t_2), Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * t_1)))); elseif (phi1 <= 4.9e-55) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); else tmp = atan(Float64(cos(phi2) * log1p(expm1(t_2))), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * t_1))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.88], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 4.9e-55], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Log[1 + N[(Exp[t$95$2] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.88:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_2}{t_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 4.9 \cdot 10^{-55}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(t_2\right)\right)}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_1}\\
\end{array}
\end{array}
if phi1 < -1.8799999999999999Initial program 76.4%
associate-*l*76.4%
Simplified76.4%
if -1.8799999999999999 < phi1 < 4.90000000000000035e-55Initial program 85.8%
associate-*l*85.8%
Simplified85.8%
Taylor expanded in phi2 around 0 85.8%
sub-neg85.8%
+-commutative85.8%
neg-mul-185.8%
neg-mul-185.8%
remove-double-neg85.8%
mul-1-neg85.8%
distribute-neg-in85.8%
+-commutative85.8%
cos-neg85.8%
+-commutative85.8%
mul-1-neg85.8%
unsub-neg85.8%
Simplified85.8%
Taylor expanded in phi1 around 0 85.8%
Taylor expanded in phi1 around 0 85.8%
sin-diff98.7%
sub-neg98.7%
Applied egg-rr98.7%
sub-neg98.7%
Simplified98.7%
if 4.90000000000000035e-55 < phi1 Initial program 82.0%
log1p-expm1-u82.0%
Applied egg-rr82.0%
Final simplification88.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2 (cos (- lambda1 lambda2)))
(t_3 (sin (- lambda1 lambda2))))
(if (<= phi1 -1.88)
(atan2 (* (cos phi2) t_3) (- t_0 (* t_1 (log1p (expm1 t_2)))))
(if (<= phi1 4.9e-55)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* phi1 (cos (- lambda2 lambda1)))))
(atan2 (* (cos phi2) (log1p (expm1 t_3))) (- t_0 (* t_1 t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double t_2 = cos((lambda1 - lambda2));
double t_3 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.88) {
tmp = atan2((cos(phi2) * t_3), (t_0 - (t_1 * log1p(expm1(t_2)))));
} else if (phi1 <= 4.9e-55) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))));
} else {
tmp = atan2((cos(phi2) * log1p(expm1(t_3))), (t_0 - (t_1 * t_2)));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double t_2 = Math.cos((lambda1 - lambda2));
double t_3 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.88) {
tmp = Math.atan2((Math.cos(phi2) * t_3), (t_0 - (t_1 * Math.log1p(Math.expm1(t_2)))));
} else if (phi1 <= 4.9e-55) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.log1p(Math.expm1(t_3))), (t_0 - (t_1 * t_2)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) t_2 = math.cos((lambda1 - lambda2)) t_3 = math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -1.88: tmp = math.atan2((math.cos(phi2) * t_3), (t_0 - (t_1 * math.log1p(math.expm1(t_2))))) elif phi1 <= 4.9e-55: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2((math.cos(phi2) * math.log1p(math.expm1(t_3))), (t_0 - (t_1 * t_2))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = cos(Float64(lambda1 - lambda2)) t_3 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -1.88) tmp = atan(Float64(cos(phi2) * t_3), Float64(t_0 - Float64(t_1 * log1p(expm1(t_2))))); elseif (phi1 <= 4.9e-55) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); else tmp = atan(Float64(cos(phi2) * log1p(expm1(t_3))), Float64(t_0 - Float64(t_1 * t_2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.88], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Log[1 + N[(Exp[t$95$2] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 4.9e-55], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Log[1 + N[(Exp[t$95$3] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_3 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.88:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_3}{t_0 - t_1 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(t_2\right)\right)}\\
\mathbf{elif}\;\phi_1 \leq 4.9 \cdot 10^{-55}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(t_3\right)\right)}{t_0 - t_1 \cdot t_2}\\
\end{array}
\end{array}
if phi1 < -1.8799999999999999Initial program 76.4%
log1p-expm1-u76.5%
Applied egg-rr76.5%
if -1.8799999999999999 < phi1 < 4.90000000000000035e-55Initial program 85.8%
associate-*l*85.8%
Simplified85.8%
Taylor expanded in phi2 around 0 85.8%
sub-neg85.8%
+-commutative85.8%
neg-mul-185.8%
neg-mul-185.8%
remove-double-neg85.8%
mul-1-neg85.8%
distribute-neg-in85.8%
+-commutative85.8%
cos-neg85.8%
+-commutative85.8%
mul-1-neg85.8%
unsub-neg85.8%
Simplified85.8%
Taylor expanded in phi1 around 0 85.8%
Taylor expanded in phi1 around 0 85.8%
sin-diff98.7%
sub-neg98.7%
Applied egg-rr98.7%
sub-neg98.7%
Simplified98.7%
if 4.90000000000000035e-55 < phi1 Initial program 82.0%
log1p-expm1-u82.0%
Applied egg-rr82.0%
Final simplification88.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2 (cos (- lambda1 lambda2)))
(t_3 (sin (- lambda1 lambda2))))
(if (<= phi1 -2.8e+16)
(atan2 (* (cos phi2) t_3) (- t_0 (* t_1 (log1p (expm1 t_2)))))
(if (<= phi1 4.6e-55)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* (cos lambda2) t_1)))
(atan2 (* (cos phi2) (log1p (expm1 t_3))) (- t_0 (* t_1 t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double t_2 = cos((lambda1 - lambda2));
double t_3 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -2.8e+16) {
tmp = atan2((cos(phi2) * t_3), (t_0 - (t_1 * log1p(expm1(t_2)))));
} else if (phi1 <= 4.6e-55) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (cos(lambda2) * t_1)));
} else {
tmp = atan2((cos(phi2) * log1p(expm1(t_3))), (t_0 - (t_1 * t_2)));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double t_2 = Math.cos((lambda1 - lambda2));
double t_3 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -2.8e+16) {
tmp = Math.atan2((Math.cos(phi2) * t_3), (t_0 - (t_1 * Math.log1p(Math.expm1(t_2)))));
} else if (phi1 <= 4.6e-55) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (Math.cos(lambda2) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.log1p(Math.expm1(t_3))), (t_0 - (t_1 * t_2)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) t_2 = math.cos((lambda1 - lambda2)) t_3 = math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -2.8e+16: tmp = math.atan2((math.cos(phi2) * t_3), (t_0 - (t_1 * math.log1p(math.expm1(t_2))))) elif phi1 <= 4.6e-55: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (math.cos(lambda2) * t_1))) else: tmp = math.atan2((math.cos(phi2) * math.log1p(math.expm1(t_3))), (t_0 - (t_1 * t_2))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = cos(Float64(lambda1 - lambda2)) t_3 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -2.8e+16) tmp = atan(Float64(cos(phi2) * t_3), Float64(t_0 - Float64(t_1 * log1p(expm1(t_2))))); elseif (phi1 <= 4.6e-55) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(cos(lambda2) * t_1))); else tmp = atan(Float64(cos(phi2) * log1p(expm1(t_3))), Float64(t_0 - Float64(t_1 * t_2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -2.8e+16], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Log[1 + N[(Exp[t$95$2] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 4.6e-55], 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[Cos[lambda2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Log[1 + N[(Exp[t$95$3] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_3 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -2.8 \cdot 10^{+16}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_3}{t_0 - t_1 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(t_2\right)\right)}\\
\mathbf{elif}\;\phi_1 \leq 4.6 \cdot 10^{-55}:\\
\;\;\;\;\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 - \cos \lambda_2 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(t_3\right)\right)}{t_0 - t_1 \cdot t_2}\\
\end{array}
\end{array}
if phi1 < -2.8e16Initial program 75.7%
log1p-expm1-u75.7%
Applied egg-rr75.7%
if -2.8e16 < phi1 < 4.60000000000000023e-55Initial program 86.1%
sin-diff98.7%
sub-neg98.7%
Applied egg-rr98.7%
sub-neg98.7%
Simplified98.7%
Taylor expanded in lambda1 around 0 98.8%
cos-neg98.8%
Simplified98.8%
Taylor expanded in phi1 around 0 98.8%
if 4.60000000000000023e-55 < phi1 Initial program 82.0%
log1p-expm1-u82.0%
Applied egg-rr82.0%
Final simplification88.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi1 -1.88)
(atan2 t_2 (- t_0 (* (sin phi1) (* (cos phi2) t_1))))
(if (<= phi1 4.9e-55)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* phi1 (cos (- lambda2 lambda1)))))
(atan2 t_2 (- t_0 (* (* (cos phi2) (sin phi1)) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.88) {
tmp = atan2(t_2, (t_0 - (sin(phi1) * (cos(phi2) * t_1))));
} else if (phi1 <= 4.9e-55) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))));
} else {
tmp = atan2(t_2, (t_0 - ((cos(phi2) * sin(phi1)) * t_1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
t_2 = cos(phi2) * sin((lambda1 - lambda2))
if (phi1 <= (-1.88d0)) then
tmp = atan2(t_2, (t_0 - (sin(phi1) * (cos(phi2) * t_1))))
else if (phi1 <= 4.9d-55) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))))
else
tmp = atan2(t_2, (t_0 - ((cos(phi2) * sin(phi1)) * t_1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.88) {
tmp = Math.atan2(t_2, (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * t_1))));
} else if (phi1 <= 4.9e-55) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2(t_2, (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -1.88: tmp = math.atan2(t_2, (t_0 - (math.sin(phi1) * (math.cos(phi2) * t_1)))) elif phi1 <= 4.9e-55: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2(t_2, (t_0 - ((math.cos(phi2) * math.sin(phi1)) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -1.88) tmp = atan(t_2, Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * t_1)))); elseif (phi1 <= 4.9e-55) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); else tmp = atan(t_2, Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); t_2 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -1.88) tmp = atan2(t_2, (t_0 - (sin(phi1) * (cos(phi2) * t_1)))); elseif (phi1 <= 4.9e-55) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1))))); else tmp = atan2(t_2, (t_0 - ((cos(phi2) * sin(phi1)) * t_1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.88], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 4.9e-55], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.88:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 4.9 \cdot 10^{-55}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_1}\\
\end{array}
\end{array}
if phi1 < -1.8799999999999999Initial program 76.4%
associate-*l*76.4%
Simplified76.4%
if -1.8799999999999999 < phi1 < 4.90000000000000035e-55Initial program 85.8%
associate-*l*85.8%
Simplified85.8%
Taylor expanded in phi2 around 0 85.8%
sub-neg85.8%
+-commutative85.8%
neg-mul-185.8%
neg-mul-185.8%
remove-double-neg85.8%
mul-1-neg85.8%
distribute-neg-in85.8%
+-commutative85.8%
cos-neg85.8%
+-commutative85.8%
mul-1-neg85.8%
unsub-neg85.8%
Simplified85.8%
Taylor expanded in phi1 around 0 85.8%
Taylor expanded in phi1 around 0 85.8%
sin-diff98.7%
sub-neg98.7%
Applied egg-rr98.7%
sub-neg98.7%
Simplified98.7%
if 4.90000000000000035e-55 < phi1 Initial program 82.0%
Final simplification88.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (cos phi2) (sin phi1))))
(if (or (<= lambda2 -3.45e+15) (not (<= lambda2 5e-40)))
(atan2 (* (sin lambda2) (- (cos phi2))) (- t_0 (* (cos lambda2) t_1)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (cos lambda1) t_1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double tmp;
if ((lambda2 <= -3.45e+15) || !(lambda2 <= 5e-40)) {
tmp = atan2((sin(lambda2) * -cos(phi2)), (t_0 - (cos(lambda2) * t_1)));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * t_1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
if ((lambda2 <= (-3.45d+15)) .or. (.not. (lambda2 <= 5d-40))) then
tmp = atan2((sin(lambda2) * -cos(phi2)), (t_0 - (cos(lambda2) * t_1)))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * t_1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if ((lambda2 <= -3.45e+15) || !(lambda2 <= 5e-40)) {
tmp = Math.atan2((Math.sin(lambda2) * -Math.cos(phi2)), (t_0 - (Math.cos(lambda2) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.cos(lambda1) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) tmp = 0 if (lambda2 <= -3.45e+15) or not (lambda2 <= 5e-40): tmp = math.atan2((math.sin(lambda2) * -math.cos(phi2)), (t_0 - (math.cos(lambda2) * t_1))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.cos(lambda1) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if ((lambda2 <= -3.45e+15) || !(lambda2 <= 5e-40)) tmp = atan(Float64(sin(lambda2) * Float64(-cos(phi2))), Float64(t_0 - Float64(cos(lambda2) * t_1))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(lambda1) * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin(phi1); tmp = 0.0; if ((lambda2 <= -3.45e+15) || ~((lambda2 <= 5e-40))) tmp = atan2((sin(lambda2) * -cos(phi2)), (t_0 - (cos(lambda2) * t_1))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * t_1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -3.45e+15], N[Not[LessEqual[lambda2, 5e-40]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[phi2], $MachinePrecision])), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $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\\
\mathbf{if}\;\lambda_2 \leq -3.45 \cdot 10^{+15} \lor \neg \left(\lambda_2 \leq 5 \cdot 10^{-40}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_2 \cdot \left(-\cos \phi_2\right)}{t_0 - \cos \lambda_2 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \cos \lambda_1 \cdot t_1}\\
\end{array}
\end{array}
if lambda2 < -3.45e15 or 4.99999999999999965e-40 < lambda2 Initial program 66.2%
sin-diff79.7%
sub-neg79.7%
Applied egg-rr79.7%
sub-neg79.7%
Simplified79.7%
Taylor expanded in lambda1 around 0 79.8%
cos-neg79.8%
Simplified79.8%
Taylor expanded in lambda1 around 0 64.8%
mul-1-neg64.8%
distribute-rgt-neg-in64.8%
Simplified64.8%
if -3.45e15 < lambda2 < 4.99999999999999965e-40Initial program 99.5%
Taylor expanded in lambda2 around 0 99.5%
Final simplification81.6%
(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 (<= lambda2 -1e-5) (not (<= lambda2 1e-48)))
(atan2 t_2 (- t_0 (* (cos lambda2) t_1)))
(atan2 t_2 (- t_0 (* (cos lambda1) 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 ((lambda2 <= -1e-5) || !(lambda2 <= 1e-48)) {
tmp = atan2(t_2, (t_0 - (cos(lambda2) * t_1)));
} else {
tmp = atan2(t_2, (t_0 - (cos(lambda1) * 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 ((lambda2 <= (-1d-5)) .or. (.not. (lambda2 <= 1d-48))) then
tmp = atan2(t_2, (t_0 - (cos(lambda2) * t_1)))
else
tmp = atan2(t_2, (t_0 - (cos(lambda1) * 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 ((lambda2 <= -1e-5) || !(lambda2 <= 1e-48)) {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(lambda2) * t_1)));
} else {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(lambda1) * 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 (lambda2 <= -1e-5) or not (lambda2 <= 1e-48): tmp = math.atan2(t_2, (t_0 - (math.cos(lambda2) * t_1))) else: tmp = math.atan2(t_2, (t_0 - (math.cos(lambda1) * 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 ((lambda2 <= -1e-5) || !(lambda2 <= 1e-48)) tmp = atan(t_2, Float64(t_0 - Float64(cos(lambda2) * t_1))); else tmp = atan(t_2, Float64(t_0 - Float64(cos(lambda1) * 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 ((lambda2 <= -1e-5) || ~((lambda2 <= 1e-48))) tmp = atan2(t_2, (t_0 - (cos(lambda2) * t_1))); else tmp = atan2(t_2, (t_0 - (cos(lambda1) * 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[lambda2, -1e-5], N[Not[LessEqual[lambda2, 1e-48]], $MachinePrecision]], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[lambda1], $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_2 \leq -1 \cdot 10^{-5} \lor \neg \left(\lambda_2 \leq 10^{-48}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \lambda_2 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \lambda_1 \cdot t_1}\\
\end{array}
\end{array}
if lambda2 < -1.00000000000000008e-5 or 9.9999999999999997e-49 < lambda2 Initial program 67.4%
Taylor expanded in lambda1 around 0 67.4%
cos-neg80.7%
Simplified67.4%
if -1.00000000000000008e-5 < lambda2 < 9.9999999999999997e-49Initial program 99.8%
Taylor expanded in lambda2 around 0 99.8%
Final simplification82.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -3.45e+15) (not (<= lambda2 5e-40)))
(atan2
(* (sin lambda2) (- (cos phi2)))
(- t_0 (* (cos lambda2) (* (cos phi2) (sin phi1)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (cos lambda1) (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda2 <= -3.45e+15) || !(lambda2 <= 5e-40)) {
tmp = atan2((sin(lambda2) * -cos(phi2)), (t_0 - (cos(lambda2) * (cos(phi2) * sin(phi1)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (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) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda2 <= (-3.45d+15)) .or. (.not. (lambda2 <= 5d-40))) then
tmp = atan2((sin(lambda2) * -cos(phi2)), (t_0 - (cos(lambda2) * (cos(phi2) * sin(phi1)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (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 tmp;
if ((lambda2 <= -3.45e+15) || !(lambda2 <= 5e-40)) {
tmp = Math.atan2((Math.sin(lambda2) * -Math.cos(phi2)), (t_0 - (Math.cos(lambda2) * (Math.cos(phi2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.cos(lambda1) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda2 <= -3.45e+15) or not (lambda2 <= 5e-40): tmp = math.atan2((math.sin(lambda2) * -math.cos(phi2)), (t_0 - (math.cos(lambda2) * (math.cos(phi2) * math.sin(phi1))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.cos(lambda1) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda2 <= -3.45e+15) || !(lambda2 <= 5e-40)) tmp = atan(Float64(sin(lambda2) * Float64(-cos(phi2))), Float64(t_0 - Float64(cos(lambda2) * Float64(cos(phi2) * sin(phi1))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(lambda1) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda2 <= -3.45e+15) || ~((lambda2 <= 5e-40))) tmp = atan2((sin(lambda2) * -cos(phi2)), (t_0 - (cos(lambda2) * (cos(phi2) * sin(phi1))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (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]}, If[Or[LessEqual[lambda2, -3.45e+15], N[Not[LessEqual[lambda2, 5e-40]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[phi2], $MachinePrecision])), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -3.45 \cdot 10^{+15} \lor \neg \left(\lambda_2 \leq 5 \cdot 10^{-40}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_2 \cdot \left(-\cos \phi_2\right)}{t_0 - \cos \lambda_2 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \cos \lambda_1 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if lambda2 < -3.45e15 or 4.99999999999999965e-40 < lambda2 Initial program 66.2%
sin-diff79.7%
sub-neg79.7%
Applied egg-rr79.7%
sub-neg79.7%
Simplified79.7%
Taylor expanded in lambda1 around 0 79.8%
cos-neg79.8%
Simplified79.8%
Taylor expanded in lambda1 around 0 64.8%
mul-1-neg64.8%
distribute-rgt-neg-in64.8%
Simplified64.8%
if -3.45e15 < lambda2 < 4.99999999999999965e-40Initial program 99.5%
associate-*l*99.5%
Simplified99.5%
Taylor expanded in phi2 around 0 85.9%
sub-neg85.9%
+-commutative85.9%
neg-mul-185.9%
neg-mul-185.9%
remove-double-neg85.9%
mul-1-neg85.9%
distribute-neg-in85.9%
+-commutative85.9%
cos-neg85.9%
+-commutative85.9%
mul-1-neg85.9%
unsub-neg85.9%
Simplified85.9%
Taylor expanded in lambda2 around 0 85.9%
cos-neg85.4%
Simplified85.9%
Final simplification75.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin phi1))) (t_1 (* (cos phi1) (sin phi2))))
(if (<= lambda1 -0.56)
(atan2
(* (sin lambda1) (cos phi2))
(- t_1 (* t_0 (cos (- lambda1 lambda2)))))
(if (<= lambda1 2.2e-106)
(atan2 (* (sin lambda2) (- (cos phi2))) (- t_1 (* (cos lambda2) t_0)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_1 (* (sin phi1) (cos (- lambda2 lambda1)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin(phi1);
double t_1 = cos(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -0.56) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - (t_0 * cos((lambda1 - lambda2)))));
} else if (lambda1 <= 2.2e-106) {
tmp = atan2((sin(lambda2) * -cos(phi2)), (t_1 - (cos(lambda2) * t_0)));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_1 - (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(phi2) * sin(phi1)
t_1 = cos(phi1) * sin(phi2)
if (lambda1 <= (-0.56d0)) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - (t_0 * cos((lambda1 - lambda2)))))
else if (lambda1 <= 2.2d-106) then
tmp = atan2((sin(lambda2) * -cos(phi2)), (t_1 - (cos(lambda2) * t_0)))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_1 - (sin(phi1) * cos((lambda2 - lambda1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin(phi1);
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (lambda1 <= -0.56) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_1 - (t_0 * Math.cos((lambda1 - lambda2)))));
} else if (lambda1 <= 2.2e-106) {
tmp = Math.atan2((Math.sin(lambda2) * -Math.cos(phi2)), (t_1 - (Math.cos(lambda2) * t_0)));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_1 - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin(phi1) t_1 = math.cos(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -0.56: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_1 - (t_0 * math.cos((lambda1 - lambda2))))) elif lambda1 <= 2.2e-106: tmp = math.atan2((math.sin(lambda2) * -math.cos(phi2)), (t_1 - (math.cos(lambda2) * t_0))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_1 - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(phi1)) t_1 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -0.56) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_1 - Float64(t_0 * cos(Float64(lambda1 - lambda2))))); elseif (lambda1 <= 2.2e-106) tmp = atan(Float64(sin(lambda2) * Float64(-cos(phi2))), Float64(t_1 - Float64(cos(lambda2) * t_0))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_1 - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin(phi1); t_1 = cos(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -0.56) tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - (t_0 * cos((lambda1 - lambda2))))); elseif (lambda1 <= 2.2e-106) tmp = atan2((sin(lambda2) * -cos(phi2)), (t_1 - (cos(lambda2) * t_0))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_1 - (sin(phi1) * cos((lambda2 - lambda1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -0.56], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 2.2e-106], N[ArcTan[N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[phi2], $MachinePrecision])), $MachinePrecision] / N[(t$95$1 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \phi_1\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -0.56:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_1 - t_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{elif}\;\lambda_1 \leq 2.2 \cdot 10^{-106}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_2 \cdot \left(-\cos \phi_2\right)}{t_1 - \cos \lambda_2 \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_1 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\end{array}
\end{array}
if lambda1 < -0.56000000000000005Initial program 66.4%
sin-diff82.4%
sub-neg82.4%
Applied egg-rr82.4%
sub-neg82.4%
Simplified82.4%
Taylor expanded in lambda2 around 0 65.7%
if -0.56000000000000005 < lambda1 < 2.19999999999999994e-106Initial program 98.8%
sin-diff98.9%
sub-neg98.9%
Applied egg-rr98.9%
sub-neg98.9%
Simplified98.9%
Taylor expanded in lambda1 around 0 98.9%
cos-neg98.9%
Simplified98.9%
Taylor expanded in lambda1 around 0 91.8%
mul-1-neg91.8%
distribute-rgt-neg-in91.8%
Simplified91.8%
if 2.19999999999999994e-106 < lambda1 Initial program 72.8%
associate-*l*72.8%
Simplified72.8%
Taylor expanded in phi2 around 0 65.3%
sub-neg65.3%
+-commutative65.3%
neg-mul-165.3%
neg-mul-165.3%
remove-double-neg65.3%
mul-1-neg65.3%
distribute-neg-in65.3%
+-commutative65.3%
cos-neg65.3%
+-commutative65.3%
mul-1-neg65.3%
unsub-neg65.3%
Simplified65.3%
Final simplification76.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}
\end{array}
Initial program 82.3%
associate-*l*82.3%
Simplified82.3%
Final simplification82.3%
(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.3%
Final simplification82.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -0.00095) (not (<= phi2 0.31)))
(atan2 (* (cos phi2) t_1) (- t_0 (* (cos phi2) (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.00095) || !(phi2 <= 0.31)) {
tmp = atan2((cos(phi2) * t_1), (t_0 - (cos(phi2) * 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.00095d0)) .or. (.not. (phi2 <= 0.31d0))) then
tmp = atan2((cos(phi2) * t_1), (t_0 - (cos(phi2) * 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.00095) || !(phi2 <= 0.31)) {
tmp = Math.atan2((Math.cos(phi2) * t_1), (t_0 - (Math.cos(phi2) * 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.00095) or not (phi2 <= 0.31): tmp = math.atan2((math.cos(phi2) * t_1), (t_0 - (math.cos(phi2) * 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.00095) || !(phi2 <= 0.31)) tmp = atan(Float64(cos(phi2) * t_1), Float64(t_0 - Float64(cos(phi2) * 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.00095) || ~((phi2 <= 0.31))) tmp = atan2((cos(phi2) * t_1), (t_0 - (cos(phi2) * 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.00095], N[Not[LessEqual[phi2, 0.31]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[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.00095 \lor \neg \left(\phi_2 \leq 0.31\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_1}{t_0 - \cos \phi_2 \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 < -9.49999999999999998e-4 or 0.309999999999999998 < phi2 Initial program 82.4%
Taylor expanded in lambda2 around 0 66.8%
Taylor expanded in lambda1 around 0 61.1%
if -9.49999999999999998e-4 < phi2 < 0.309999999999999998Initial program 82.3%
associate-*l*82.3%
Simplified82.3%
Taylor expanded in phi2 around 0 81.6%
sub-neg81.6%
+-commutative81.6%
neg-mul-181.6%
neg-mul-181.6%
remove-double-neg81.6%
mul-1-neg81.6%
distribute-neg-in81.6%
+-commutative81.6%
cos-neg81.6%
+-commutative81.6%
mul-1-neg81.6%
unsub-neg81.6%
Simplified81.6%
sin-cos-mult77.1%
associate--l-77.1%
Applied egg-rr77.1%
associate--r+77.1%
Simplified77.1%
Taylor expanded in phi2 around 0 81.7%
Final simplification70.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi2 1.1)
(atan2 t_1 (- t_0 (* (sin phi1) (cos (- lambda2 lambda1)))))
(atan2 t_1 (- t_0 (* (cos phi2) (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 1.1) {
tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = atan2(t_1, (t_0 - (cos(phi2) * sin(phi1))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin((lambda1 - lambda2))
if (phi2 <= 1.1d0) then
tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda2 - lambda1)))))
else
tmp = atan2(t_1, (t_0 - (cos(phi2) * sin(phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 1.1) {
tmp = Math.atan2(t_1, (t_0 - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(phi2) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= 1.1: tmp = math.atan2(t_1, (t_0 - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi2 <= 1.1) tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 1.1) tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda2 - lambda1))))); else tmp = atan2(t_1, (t_0 - (cos(phi2) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 1.1], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 1.1:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \phi_2 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if phi2 < 1.1000000000000001Initial program 81.5%
associate-*l*81.5%
Simplified81.5%
Taylor expanded in phi2 around 0 70.6%
sub-neg70.6%
+-commutative70.6%
neg-mul-170.6%
neg-mul-170.6%
remove-double-neg70.6%
mul-1-neg70.6%
distribute-neg-in70.6%
+-commutative70.6%
cos-neg70.6%
+-commutative70.6%
mul-1-neg70.6%
unsub-neg70.6%
Simplified70.6%
if 1.1000000000000001 < phi2 Initial program 84.5%
Taylor expanded in lambda2 around 0 73.6%
Taylor expanded in lambda1 around 0 67.9%
Final simplification69.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -1800000.0) (not (<= phi1 6.8e+137)))
(atan2
(* (sin lambda1) (cos phi2))
(- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- (sin phi2) (* (cos lambda1) phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -1800000.0) || !(phi1 <= 6.8e+137)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda1) * phi1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((phi1 <= (-1800000.0d0)) .or. (.not. (phi1 <= 6.8d+137))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda1) * phi1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -1800000.0) || !(phi1 <= 6.8e+137)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.cos(lambda1) * phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (phi1 <= -1800000.0) or not (phi1 <= 6.8e+137): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.cos(lambda1) * phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -1800000.0) || !(phi1 <= 6.8e+137)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(cos(lambda1) * phi1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi1 <= -1800000.0) || ~((phi1 <= 6.8e+137))) tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda1) * phi1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -1800000.0], N[Not[LessEqual[phi1, 6.8e+137]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -1800000 \lor \neg \left(\phi_1 \leq 6.8 \cdot 10^{+137}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \lambda_1 \cdot \phi_1}\\
\end{array}
\end{array}
if phi1 < -1.8e6 or 6.79999999999999973e137 < phi1 Initial program 75.8%
associate-*l*75.8%
Simplified75.8%
Taylor expanded in phi2 around 0 50.6%
sub-neg50.6%
+-commutative50.6%
neg-mul-150.6%
neg-mul-150.6%
remove-double-neg50.6%
mul-1-neg50.6%
distribute-neg-in50.6%
+-commutative50.6%
cos-neg50.6%
+-commutative50.6%
mul-1-neg50.6%
unsub-neg50.6%
Simplified50.6%
Taylor expanded in phi1 around 0 48.8%
Taylor expanded in lambda2 around 0 33.9%
if -1.8e6 < phi1 < 6.79999999999999973e137Initial program 86.5%
associate-*l*86.5%
Simplified86.5%
Taylor expanded in phi2 around 0 79.1%
sub-neg79.1%
+-commutative79.1%
neg-mul-179.1%
neg-mul-179.1%
remove-double-neg79.1%
mul-1-neg79.1%
distribute-neg-in79.1%
+-commutative79.1%
cos-neg79.1%
+-commutative79.1%
mul-1-neg79.1%
unsub-neg79.1%
Simplified79.1%
Taylor expanded in phi1 around 0 78.8%
Taylor expanded in phi1 around 0 73.3%
Taylor expanded in lambda2 around 0 73.9%
cos-neg73.9%
Simplified73.9%
Final simplification58.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= lambda2 -2.6e+17)
(atan2 t_0 (- (sin phi2) (* (cos lambda2) (sin phi1))))
(atan2 t_0 (- (sin phi2) (* (cos lambda1) (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -2.6e+17) {
tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * sin(phi1))));
} else {
tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi2) * sin((lambda1 - lambda2))
if (lambda2 <= (-2.6d+17)) then
tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * sin(phi1))))
else
tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (lambda2 <= -2.6e+17) {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.cos(lambda2) * Math.sin(phi1))));
} else {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.cos(lambda1) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if lambda2 <= -2.6e+17: tmp = math.atan2(t_0, (math.sin(phi2) - (math.cos(lambda2) * math.sin(phi1)))) else: tmp = math.atan2(t_0, (math.sin(phi2) - (math.cos(lambda1) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (lambda2 <= -2.6e+17) tmp = atan(t_0, Float64(sin(phi2) - Float64(cos(lambda2) * sin(phi1)))); else tmp = atan(t_0, Float64(sin(phi2) - Float64(cos(lambda1) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (lambda2 <= -2.6e+17) tmp = atan2(t_0, (sin(phi2) - (cos(lambda2) * sin(phi1)))); else tmp = atan2(t_0, (sin(phi2) - (cos(lambda1) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -2.6e+17], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_2 \leq -2.6 \cdot 10^{+17}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\sin \phi_2 - \cos \lambda_2 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\sin \phi_2 - \cos \lambda_1 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if lambda2 < -2.6e17Initial program 62.1%
associate-*l*62.1%
Simplified62.1%
Taylor expanded in phi2 around 0 51.3%
sub-neg51.3%
+-commutative51.3%
neg-mul-151.3%
neg-mul-151.3%
remove-double-neg51.3%
mul-1-neg51.3%
distribute-neg-in51.3%
+-commutative51.3%
cos-neg51.3%
+-commutative51.3%
mul-1-neg51.3%
unsub-neg51.3%
Simplified51.3%
Taylor expanded in phi1 around 0 50.3%
Taylor expanded in lambda1 around 0 50.3%
if -2.6e17 < lambda2 Initial program 90.7%
associate-*l*90.7%
Simplified90.7%
Taylor expanded in phi2 around 0 75.1%
sub-neg75.1%
+-commutative75.1%
neg-mul-175.1%
neg-mul-175.1%
remove-double-neg75.1%
mul-1-neg75.1%
distribute-neg-in75.1%
+-commutative75.1%
cos-neg75.1%
+-commutative75.1%
mul-1-neg75.1%
unsub-neg75.1%
Simplified75.1%
Taylor expanded in phi1 around 0 74.2%
Taylor expanded in lambda2 around 0 72.8%
cos-neg72.8%
Simplified72.8%
Final simplification66.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 82.3%
associate-*l*82.3%
Simplified82.3%
Taylor expanded in phi2 around 0 68.1%
sub-neg68.1%
+-commutative68.1%
neg-mul-168.1%
neg-mul-168.1%
remove-double-neg68.1%
mul-1-neg68.1%
distribute-neg-in68.1%
+-commutative68.1%
cos-neg68.1%
+-commutative68.1%
mul-1-neg68.1%
unsub-neg68.1%
Simplified68.1%
Taylor expanded in phi1 around 0 67.2%
Final simplification67.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) (* (cos lambda1) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda1) * sin(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) * sin(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) * Math.sin(phi1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.cos(lambda1) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(cos(lambda1) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda1) * sin(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] * N[Sin[phi1], $MachinePrecision]), $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 \sin \phi_1}
\end{array}
Initial program 82.3%
associate-*l*82.3%
Simplified82.3%
Taylor expanded in phi2 around 0 68.1%
sub-neg68.1%
+-commutative68.1%
neg-mul-168.1%
neg-mul-168.1%
remove-double-neg68.1%
mul-1-neg68.1%
distribute-neg-in68.1%
+-commutative68.1%
cos-neg68.1%
+-commutative68.1%
mul-1-neg68.1%
unsub-neg68.1%
Simplified68.1%
Taylor expanded in phi1 around 0 67.2%
Taylor expanded in lambda2 around 0 63.0%
cos-neg63.0%
Simplified63.0%
Final simplification63.0%
(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.3%
associate-*l*82.3%
Simplified82.3%
Taylor expanded in phi2 around 0 68.1%
sub-neg68.1%
+-commutative68.1%
neg-mul-168.1%
neg-mul-168.1%
remove-double-neg68.1%
mul-1-neg68.1%
distribute-neg-in68.1%
+-commutative68.1%
cos-neg68.1%
+-commutative68.1%
mul-1-neg68.1%
unsub-neg68.1%
Simplified68.1%
Taylor expanded in phi1 around 0 67.2%
Taylor expanded in phi1 around 0 50.5%
Taylor expanded in lambda2 around 0 31.3%
Final simplification31.3%
(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.3%
associate-*l*82.3%
Simplified82.3%
Taylor expanded in phi2 around 0 68.1%
sub-neg68.1%
+-commutative68.1%
neg-mul-168.1%
neg-mul-168.1%
remove-double-neg68.1%
mul-1-neg68.1%
distribute-neg-in68.1%
+-commutative68.1%
cos-neg68.1%
+-commutative68.1%
mul-1-neg68.1%
unsub-neg68.1%
Simplified68.1%
Taylor expanded in phi1 around 0 67.2%
Taylor expanded in phi1 around 0 50.5%
Taylor expanded in lambda2 around 0 50.6%
cos-neg50.6%
Simplified50.6%
Final simplification50.6%
herbie shell --seed 2023250
(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))))))