
(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 23 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))
(*
(sin phi1)
(*
(cos phi2)
(+ (* (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)) - (sin(phi1) * (cos(phi2) * ((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)) - (sin(phi1) * (cos(phi2) * ((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.sin(phi1) * (Math.cos(phi2) * ((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.sin(phi1) * (math.cos(phi2) * ((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(sin(phi1) * Float64(cos(phi2) * 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)) - (sin(phi1) * (cos(phi2) * ((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[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $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]], $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 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)}
\end{array}
Initial program 81.2%
associate-*l*81.2%
Simplified81.2%
sin-diff91.4%
sub-neg91.4%
Applied egg-rr91.4%
sub-neg91.4%
Simplified91.4%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))))
(if (or (<= phi2 -6.2e-5) (not (<= phi2 4e-21)))
(atan2
t_1
(- t_0 (* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
(atan2
t_1
(-
t_0
(*
(sin phi1)
(+
(* (cos lambda2) (cos lambda1))
(* (sin lambda1) (sin lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double tmp;
if ((phi2 <= -6.2e-5) || !(phi2 <= 4e-21)) {
tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
} else {
tmp = atan2(t_1, (t_0 - (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (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) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)
if ((phi2 <= (-6.2d-5)) .or. (.not. (phi2 <= 4d-21))) then
tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))))
else
tmp = atan2(t_1, (t_0 - (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (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(phi1) * Math.sin(phi2);
double t_1 = ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2);
double tmp;
if ((phi2 <= -6.2e-5) || !(phi2 <= 4e-21)) {
tmp = Math.atan2(t_1, (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))))));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.sin(phi1) * ((Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda1) * Math.sin(lambda2))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2) tmp = 0 if (phi2 <= -6.2e-5) or not (phi2 <= 4e-21): tmp = math.atan2(t_1, (t_0 - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2)))))) else: tmp = math.atan2(t_1, (t_0 - (math.sin(phi1) * ((math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda1) * math.sin(lambda2)))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) tmp = 0.0 if ((phi2 <= -6.2e-5) || !(phi2 <= 4e-21)) tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda1) * sin(lambda2)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2); tmp = 0.0; if ((phi2 <= -6.2e-5) || ~((phi2 <= 4e-21))) tmp = atan2(t_1, (t_0 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2)))))); else tmp = atan2(t_1, (t_0 - (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(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, -6.2e-5], N[Not[LessEqual[phi2, 4e-21]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $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}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -6.2 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 4 \cdot 10^{-21}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -6.20000000000000027e-5 or 3.99999999999999963e-21 < phi2 Initial program 76.8%
associate-*l*76.8%
Simplified76.8%
sin-diff90.7%
sub-neg90.7%
Applied egg-rr90.7%
sub-neg90.7%
Simplified90.7%
if -6.20000000000000027e-5 < phi2 < 3.99999999999999963e-21Initial program 86.7%
associate-*l*86.7%
Simplified86.7%
sin-diff92.3%
sub-neg92.3%
Applied egg-rr92.3%
sub-neg92.3%
Simplified92.3%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in phi2 around 0 99.8%
Final simplification94.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda1 -9.6e-6) (not (<= lambda1 2.6e-6)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* (sin phi1) (* (cos lambda1) (cos phi2)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(-
t_0
(* (sin phi1) (* (cos phi2) (log (exp (cos (- lambda1 lambda2)))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda1 <= -9.6e-6) || !(lambda1 <= 2.6e-6)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * log(exp(cos((lambda1 - lambda2))))))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda1 <= (-9.6d-6)) .or. (.not. (lambda1 <= 2.6d-6))) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * log(exp(cos((lambda1 - lambda2))))))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda1 <= -9.6e-6) || !(lambda1 <= 2.6e-6)) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (Math.sin(phi1) * (Math.cos(lambda1) * Math.cos(phi2)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * Math.log(Math.exp(Math.cos((lambda1 - lambda2))))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda1 <= -9.6e-6) or not (lambda1 <= 2.6e-6): tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (math.sin(phi1) * (math.cos(lambda1) * math.cos(phi2))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * (math.cos(phi2) * math.log(math.exp(math.cos((lambda1 - lambda2)))))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda1 <= -9.6e-6) || !(lambda1 <= 2.6e-6)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(sin(phi1) * Float64(cos(lambda1) * cos(phi2))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * log(exp(cos(Float64(lambda1 - lambda2)))))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda1 <= -9.6e-6) || ~((lambda1 <= 2.6e-6))) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * log(exp(cos((lambda1 - lambda2)))))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -9.6e-6], N[Not[LessEqual[lambda1, 2.6e-6]], $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[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Log[N[Exp[N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -9.6 \cdot 10^{-6} \lor \neg \left(\lambda_1 \leq 2.6 \cdot 10^{-6}\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 - \sin \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \log \left(e^{\cos \left(\lambda_1 - \lambda_2\right)}\right)\right)}\\
\end{array}
\end{array}
if lambda1 < -9.5999999999999996e-6 or 2.60000000000000009e-6 < lambda1 Initial program 66.1%
associate-*l*66.1%
Simplified66.1%
sin-diff84.8%
sub-neg84.8%
Applied egg-rr84.8%
sub-neg84.8%
Simplified84.8%
Taylor expanded in lambda2 around 0 85.1%
if -9.5999999999999996e-6 < lambda1 < 2.60000000000000009e-6Initial program 99.5%
associate-*l*99.5%
Simplified99.5%
add-log-exp99.5%
Applied egg-rr99.5%
Final simplification91.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -6.1e-6) (not (<= lambda2 1.1e-5)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* (sin phi1) (* (cos lambda2) (cos phi2)))))
(atan2
(* (cos phi2) (- (sin lambda1) (* lambda2 (cos lambda1))))
(-
t_0
(*
(sin phi1)
(* (cos phi2) (+ (cos lambda1) (* (sin lambda1) lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda2 <= -6.1e-6) || !(lambda2 <= 1.1e-5)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2)))));
} else {
tmp = atan2((cos(phi2) * (sin(lambda1) - (lambda2 * cos(lambda1)))), (t_0 - (sin(phi1) * (cos(phi2) * (cos(lambda1) + (sin(lambda1) * lambda2))))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda2 <= (-6.1d-6)) .or. (.not. (lambda2 <= 1.1d-5))) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2)))))
else
tmp = atan2((cos(phi2) * (sin(lambda1) - (lambda2 * cos(lambda1)))), (t_0 - (sin(phi1) * (cos(phi2) * (cos(lambda1) + (sin(lambda1) * lambda2))))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda2 <= -6.1e-6) || !(lambda2 <= 1.1e-5)) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (Math.sin(phi1) * (Math.cos(lambda2) * Math.cos(phi2)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - (lambda2 * Math.cos(lambda1)))), (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * (Math.cos(lambda1) + (Math.sin(lambda1) * lambda2))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda2 <= -6.1e-6) or not (lambda2 <= 1.1e-5): tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (math.sin(phi1) * (math.cos(lambda2) * math.cos(phi2))))) else: tmp = math.atan2((math.cos(phi2) * (math.sin(lambda1) - (lambda2 * math.cos(lambda1)))), (t_0 - (math.sin(phi1) * (math.cos(phi2) * (math.cos(lambda1) + (math.sin(lambda1) * lambda2)))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda2 <= -6.1e-6) || !(lambda2 <= 1.1e-5)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(sin(phi1) * Float64(cos(lambda2) * cos(phi2))))); else tmp = atan(Float64(cos(phi2) * Float64(sin(lambda1) - Float64(lambda2 * cos(lambda1)))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * Float64(cos(lambda1) + Float64(sin(lambda1) * lambda2)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda2 <= -6.1e-6) || ~((lambda2 <= 1.1e-5))) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (sin(phi1) * (cos(lambda2) * cos(phi2))))); else tmp = atan2((cos(phi2) * (sin(lambda1) - (lambda2 * cos(lambda1)))), (t_0 - (sin(phi1) * (cos(phi2) * (cos(lambda1) + (sin(lambda1) * lambda2)))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -6.1e-6], N[Not[LessEqual[lambda2, 1.1e-5]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - N[(lambda2 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -6.1 \cdot 10^{-6} \lor \neg \left(\lambda_2 \leq 1.1 \cdot 10^{-5}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - \lambda_2 \cdot \cos \lambda_1\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \lambda_1 + \sin \lambda_1 \cdot \lambda_2\right)\right)}\\
\end{array}
\end{array}
if lambda2 < -6.10000000000000004e-6 or 1.1e-5 < lambda2 Initial program 63.1%
associate-*l*63.1%
Simplified63.1%
sin-diff83.6%
sub-neg83.6%
Applied egg-rr83.6%
sub-neg83.6%
Simplified83.6%
Taylor expanded in lambda1 around 0 83.5%
cos-neg63.1%
Simplified83.5%
if -6.10000000000000004e-6 < lambda2 < 1.1e-5Initial program 99.1%
associate-*l*99.1%
Simplified99.1%
Taylor expanded in lambda2 around 0 99.2%
+-commutative99.2%
mul-1-neg99.2%
unsub-neg99.2%
Simplified99.2%
Taylor expanded in lambda2 around 0 99.7%
Final simplification91.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin 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) * cos(lambda2)) - (cos(lambda1) * sin(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) * cos(lambda2)) - (cos(lambda1) * sin(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) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(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) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(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(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), 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((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * 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[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{\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 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}
\end{array}
Initial program 81.2%
associate-*l*81.2%
Simplified81.2%
sin-diff91.4%
sub-neg91.4%
Applied egg-rr91.4%
sub-neg91.4%
Simplified91.4%
Final simplification91.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -3.1e-7) (not (<= phi1 3.55e-6)))
(atan2
(* (cos phi2) (- (sin lambda1) t_0))
(- t_1 (* (sin phi1) (* (cos phi2) t_2))))
(atan2
(* (- (* (sin lambda1) (cos lambda2)) t_0) (cos phi2))
(- t_1 (* t_2 (* (cos phi2) phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -3.1e-7) || !(phi1 <= 3.55e-6)) {
tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), (t_1 - (sin(phi1) * (cos(phi2) * t_2))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), (t_1 - (t_2 * (cos(phi2) * phi1))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(lambda1) * sin(lambda2)
t_1 = cos(phi1) * sin(phi2)
t_2 = cos((lambda1 - lambda2))
if ((phi1 <= (-3.1d-7)) .or. (.not. (phi1 <= 3.55d-6))) then
tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), (t_1 - (sin(phi1) * (cos(phi2) * t_2))))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), (t_1 - (t_2 * (cos(phi2) * phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(lambda1) * Math.sin(lambda2);
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double t_2 = Math.cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -3.1e-7) || !(phi1 <= 3.55e-6)) {
tmp = Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - t_0)), (t_1 - (Math.sin(phi1) * (Math.cos(phi2) * t_2))));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - t_0) * Math.cos(phi2)), (t_1 - (t_2 * (Math.cos(phi2) * phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda1) * math.sin(lambda2) t_1 = math.cos(phi1) * math.sin(phi2) t_2 = math.cos((lambda1 - lambda2)) tmp = 0 if (phi1 <= -3.1e-7) or not (phi1 <= 3.55e-6): tmp = math.atan2((math.cos(phi2) * (math.sin(lambda1) - t_0)), (t_1 - (math.sin(phi1) * (math.cos(phi2) * t_2)))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - t_0) * math.cos(phi2)), (t_1 - (t_2 * (math.cos(phi2) * phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -3.1e-7) || !(phi1 <= 3.55e-6)) tmp = atan(Float64(cos(phi2) * Float64(sin(lambda1) - t_0)), Float64(t_1 - Float64(sin(phi1) * Float64(cos(phi2) * t_2)))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), Float64(t_1 - Float64(t_2 * Float64(cos(phi2) * phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(lambda1) * sin(lambda2); t_1 = cos(phi1) * sin(phi2); t_2 = cos((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -3.1e-7) || ~((phi1 <= 3.55e-6))) tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), (t_1 - (sin(phi1) * (cos(phi2) * t_2)))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), (t_1 - (t_2 * (cos(phi2) * phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -3.1e-7], N[Not[LessEqual[phi1, 3.55e-6]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(t$95$2 * N[(N[Cos[phi2], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -3.1 \cdot 10^{-7} \lor \neg \left(\phi_1 \leq 3.55 \cdot 10^{-6}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - t_0\right)}{t_1 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t_0\right) \cdot \cos \phi_2}{t_1 - t_2 \cdot \left(\cos \phi_2 \cdot \phi_1\right)}\\
\end{array}
\end{array}
if phi1 < -3.1e-7 or 3.5499999999999999e-6 < phi1 Initial program 79.8%
associate-*l*79.8%
Simplified79.8%
sin-diff82.5%
sub-neg82.5%
Applied egg-rr82.5%
sub-neg82.5%
Simplified82.5%
Taylor expanded in lambda2 around 0 81.0%
if -3.1e-7 < phi1 < 3.5499999999999999e-6Initial program 82.6%
associate-*l*82.6%
Simplified82.6%
sin-diff99.8%
sub-neg99.8%
Applied egg-rr99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in phi1 around 0 99.8%
Final simplification90.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -3.1e-13) (not (<= phi1 4.1e-11)))
(atan2
(* (cos phi2) (- (sin lambda1) t_0))
(- t_1 (* (sin phi1) (* (cos phi2) t_2))))
(atan2
(* (- (* (sin lambda1) (cos lambda2)) t_0) (cos phi2))
(- t_1 (* phi1 t_2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -3.1e-13) || !(phi1 <= 4.1e-11)) {
tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), (t_1 - (sin(phi1) * (cos(phi2) * t_2))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), (t_1 - (phi1 * t_2)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(lambda1) * sin(lambda2)
t_1 = cos(phi1) * sin(phi2)
t_2 = cos((lambda1 - lambda2))
if ((phi1 <= (-3.1d-13)) .or. (.not. (phi1 <= 4.1d-11))) then
tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), (t_1 - (sin(phi1) * (cos(phi2) * t_2))))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), (t_1 - (phi1 * t_2)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(lambda1) * Math.sin(lambda2);
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double t_2 = Math.cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -3.1e-13) || !(phi1 <= 4.1e-11)) {
tmp = Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - t_0)), (t_1 - (Math.sin(phi1) * (Math.cos(phi2) * t_2))));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - t_0) * Math.cos(phi2)), (t_1 - (phi1 * t_2)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda1) * math.sin(lambda2) t_1 = math.cos(phi1) * math.sin(phi2) t_2 = math.cos((lambda1 - lambda2)) tmp = 0 if (phi1 <= -3.1e-13) or not (phi1 <= 4.1e-11): tmp = math.atan2((math.cos(phi2) * (math.sin(lambda1) - t_0)), (t_1 - (math.sin(phi1) * (math.cos(phi2) * t_2)))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - t_0) * math.cos(phi2)), (t_1 - (phi1 * t_2))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -3.1e-13) || !(phi1 <= 4.1e-11)) tmp = atan(Float64(cos(phi2) * Float64(sin(lambda1) - t_0)), Float64(t_1 - Float64(sin(phi1) * Float64(cos(phi2) * t_2)))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), Float64(t_1 - Float64(phi1 * t_2))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(lambda1) * sin(lambda2); t_1 = cos(phi1) * sin(phi2); t_2 = cos((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -3.1e-13) || ~((phi1 <= 4.1e-11))) tmp = atan2((cos(phi2) * (sin(lambda1) - t_0)), (t_1 - (sin(phi1) * (cos(phi2) * t_2)))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), (t_1 - (phi1 * t_2))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -3.1e-13], N[Not[LessEqual[phi1, 4.1e-11]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(phi1 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -3.1 \cdot 10^{-13} \lor \neg \left(\phi_1 \leq 4.1 \cdot 10^{-11}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - t_0\right)}{t_1 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t_0\right) \cdot \cos \phi_2}{t_1 - \phi_1 \cdot t_2}\\
\end{array}
\end{array}
if phi1 < -3.0999999999999999e-13 or 4.1000000000000001e-11 < phi1 Initial program 80.3%
associate-*l*80.3%
Simplified80.3%
sin-diff82.9%
sub-neg82.9%
Applied egg-rr82.9%
sub-neg82.9%
Simplified82.9%
Taylor expanded in lambda2 around 0 81.5%
if -3.0999999999999999e-13 < phi1 < 4.1000000000000001e-11Initial program 82.2%
associate-*l*82.2%
Simplified82.2%
sin-diff99.8%
sub-neg99.8%
Applied egg-rr99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in phi1 around 0 99.8%
Taylor expanded in phi2 around 0 99.8%
Final simplification90.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -6.2e-14) (not (<= phi1 3.05e-10)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) (* (cos phi2) (log (exp t_1))))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* phi1 t_1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -6.2e-14) || !(phi1 <= 3.05e-10)) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * log(exp(t_1))))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (phi1 * t_1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
if ((phi1 <= (-6.2d-14)) .or. (.not. (phi1 <= 3.05d-10))) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * log(exp(t_1))))))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (phi1 * t_1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -6.2e-14) || !(phi1 <= 3.05e-10)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * Math.log(Math.exp(t_1))))));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (phi1 * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) tmp = 0 if (phi1 <= -6.2e-14) or not (phi1 <= 3.05e-10): tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * (math.cos(phi2) * math.log(math.exp(t_1)))))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (phi1 * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -6.2e-14) || !(phi1 <= 3.05e-10)) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * log(exp(t_1)))))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(phi1 * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -6.2e-14) || ~((phi1 <= 3.05e-10))) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * log(exp(t_1)))))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (phi1 * t_1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -6.2e-14], N[Not[LessEqual[phi1, 3.05e-10]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Log[N[Exp[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(phi1 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -6.2 \cdot 10^{-14} \lor \neg \left(\phi_1 \leq 3.05 \cdot 10^{-10}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \log \left(e^{t_1}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \phi_1 \cdot t_1}\\
\end{array}
\end{array}
if phi1 < -6.20000000000000009e-14 or 3.0499999999999998e-10 < phi1 Initial program 80.3%
associate-*l*80.3%
Simplified80.3%
add-log-exp80.3%
Applied egg-rr80.3%
if -6.20000000000000009e-14 < phi1 < 3.0499999999999998e-10Initial program 82.2%
associate-*l*82.2%
Simplified82.2%
sin-diff99.8%
sub-neg99.8%
Applied egg-rr99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in phi1 around 0 99.8%
Taylor expanded in phi2 around 0 99.8%
Final simplification90.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -2.15e-16) (not (<= phi1 1.25e-8)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) (* (cos phi2) t_1))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* phi1 t_1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -2.15e-16) || !(phi1 <= 1.25e-8)) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * t_1))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (phi1 * t_1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
if ((phi1 <= (-2.15d-16)) .or. (.not. (phi1 <= 1.25d-8))) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * t_1))))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (phi1 * t_1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -2.15e-16) || !(phi1 <= 1.25e-8)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * t_1))));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (phi1 * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) tmp = 0 if (phi1 <= -2.15e-16) or not (phi1 <= 1.25e-8): tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * (math.cos(phi2) * t_1)))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (phi1 * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -2.15e-16) || !(phi1 <= 1.25e-8)) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * t_1)))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(phi1 * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -2.15e-16) || ~((phi1 <= 1.25e-8))) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * t_1)))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (phi1 * t_1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -2.15e-16], N[Not[LessEqual[phi1, 1.25e-8]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(phi1 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -2.15 \cdot 10^{-16} \lor \neg \left(\phi_1 \leq 1.25 \cdot 10^{-8}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \phi_1 \cdot t_1}\\
\end{array}
\end{array}
if phi1 < -2.1499999999999999e-16 or 1.2499999999999999e-8 < phi1 Initial program 80.3%
associate-*l*80.3%
Simplified80.3%
if -2.1499999999999999e-16 < phi1 < 1.2499999999999999e-8Initial program 82.2%
associate-*l*82.2%
Simplified82.2%
sin-diff99.8%
sub-neg99.8%
Applied egg-rr99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in phi1 around 0 99.8%
Taylor expanded in phi2 around 0 99.8%
Final simplification90.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -0.96) (not (<= lambda2 2.05e-5)))
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_0 (* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) (* (cos lambda1) (cos phi2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda2 <= -0.96) || !(lambda2 <= 2.05e-5)) {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda2 <= (-0.96d0)) .or. (.not. (lambda2 <= 2.05d-5))) then
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda2 <= -0.96) || !(lambda2 <= 2.05e-5)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * (Math.cos(lambda1) * Math.cos(phi2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda2 <= -0.96) or not (lambda2 <= 2.05e-5): tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_0 - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2)))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * (math.cos(lambda1) * math.cos(phi2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda2 <= -0.96) || !(lambda2 <= 2.05e-5)) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(lambda1) * cos(phi2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda2 <= -0.96) || ~((lambda2 <= 2.05e-5))) tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2)))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -0.96], N[Not[LessEqual[lambda2, 2.05e-5]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -0.96 \lor \neg \left(\lambda_2 \leq 2.05 \cdot 10^{-5}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \phi_2\right)}\\
\end{array}
\end{array}
if lambda2 < -0.95999999999999996 or 2.05000000000000002e-5 < lambda2 Initial program 62.2%
associate-*l*62.2%
Simplified62.2%
Taylor expanded in lambda1 around 0 64.3%
if -0.95999999999999996 < lambda2 < 2.05000000000000002e-5Initial program 99.1%
associate-*l*99.1%
Simplified99.1%
Taylor expanded in lambda2 around 0 99.1%
Final simplification82.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (or (<= lambda1 -3.4e-5) (not (<= lambda1 2.1e+71)))
(atan2
(* (sin lambda1) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (sin phi1) (* (cos phi2) t_0))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- (sin phi2) (log1p (expm1 (* (sin phi1) t_0))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if ((lambda1 <= -3.4e-5) || !(lambda1 <= 2.1e+71)) {
tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (sin(phi1) * (cos(phi2) * t_0))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - log1p(expm1((sin(phi1) * t_0)))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if ((lambda1 <= -3.4e-5) || !(lambda1 <= 2.1e+71)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * (Math.cos(phi2) * t_0))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - Math.log1p(Math.expm1((Math.sin(phi1) * t_0)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if (lambda1 <= -3.4e-5) or not (lambda1 <= 2.1e+71): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * (math.cos(phi2) * t_0)))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - math.log1p(math.expm1((math.sin(phi1) * t_0))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((lambda1 <= -3.4e-5) || !(lambda1 <= 2.1e+71)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * Float64(cos(phi2) * t_0)))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - log1p(expm1(Float64(sin(phi1) * t_0))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda1, -3.4e-5], N[Not[LessEqual[lambda1, 2.1e+71]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $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[Log[1 + N[(Exp[N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -3.4 \cdot 10^{-5} \lor \neg \left(\lambda_1 \leq 2.1 \cdot 10^{+71}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \mathsf{log1p}\left(\mathsf{expm1}\left(\sin \phi_1 \cdot t_0\right)\right)}\\
\end{array}
\end{array}
if lambda1 < -3.4e-5 or 2.09999999999999989e71 < lambda1 Initial program 68.9%
associate-*l*69.0%
Simplified69.0%
Taylor expanded in lambda2 around 0 69.2%
if -3.4e-5 < lambda1 < 2.09999999999999989e71Initial program 92.4%
associate-*l*92.4%
Simplified92.4%
Taylor expanded in phi2 around 0 79.1%
log1p-expm1-u79.1%
Applied egg-rr79.1%
Taylor expanded in phi1 around 0 79.4%
Final simplification74.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -6.8) (not (<= lambda2 4.2e-5)))
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_0 (* (sin phi1) (cos (- lambda1 lambda2)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) (* (cos lambda1) (cos phi2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda2 <= -6.8) || !(lambda2 <= 4.2e-5)) {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda2 <= (-6.8d0)) .or. (.not. (lambda2 <= 4.2d-5))) then
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda2 <= -6.8) || !(lambda2 <= 4.2e-5)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_0 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * (Math.cos(lambda1) * Math.cos(phi2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda2 <= -6.8) or not (lambda2 <= 4.2e-5): tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_0 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * (math.cos(lambda1) * math.cos(phi2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda2 <= -6.8) || !(lambda2 <= 4.2e-5)) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(lambda1) * cos(phi2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda2 <= -6.8) || ~((lambda2 <= 4.2e-5))) tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (sin(phi1) * cos((lambda1 - lambda2))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(lambda1) * cos(phi2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -6.8], N[Not[LessEqual[lambda2, 4.2e-5]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -6.8 \lor \neg \left(\lambda_2 \leq 4.2 \cdot 10^{-5}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_0 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \phi_2\right)}\\
\end{array}
\end{array}
if lambda2 < -6.79999999999999982 or 4.19999999999999977e-5 < lambda2 Initial program 61.9%
associate-*l*61.9%
Simplified61.9%
Taylor expanded in phi2 around 0 55.1%
Taylor expanded in lambda1 around 0 57.2%
if -6.79999999999999982 < lambda2 < 4.19999999999999977e-5Initial program 99.1%
associate-*l*99.1%
Simplified99.1%
Taylor expanded in lambda2 around 0 99.1%
Final simplification78.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_1 (* (cos phi1) (sin phi2))))
(if (<= lambda1 -3.4e-5)
(atan2
(* (sin lambda1) (cos phi2))
(- t_1 (* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
(if (<= lambda1 1.22e-6)
(atan2 t_0 (- t_1 (* (sin phi1) (* (cos lambda2) (cos phi2)))))
(atan2 t_0 (- t_1 (* (sin phi1) (* (cos lambda1) (cos phi2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double t_1 = cos(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -3.4e-5) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
} else if (lambda1 <= 1.22e-6) {
tmp = atan2(t_0, (t_1 - (sin(phi1) * (cos(lambda2) * cos(phi2)))));
} else {
tmp = atan2(t_0, (t_1 - (sin(phi1) * (cos(lambda1) * cos(phi2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi2) * sin((lambda1 - lambda2))
t_1 = cos(phi1) * sin(phi2)
if (lambda1 <= (-3.4d-5)) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))))
else if (lambda1 <= 1.22d-6) then
tmp = atan2(t_0, (t_1 - (sin(phi1) * (cos(lambda2) * cos(phi2)))))
else
tmp = atan2(t_0, (t_1 - (sin(phi1) * (cos(lambda1) * cos(phi2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (lambda1 <= -3.4e-5) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_1 - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))))));
} else if (lambda1 <= 1.22e-6) {
tmp = Math.atan2(t_0, (t_1 - (Math.sin(phi1) * (Math.cos(lambda2) * Math.cos(phi2)))));
} else {
tmp = Math.atan2(t_0, (t_1 - (Math.sin(phi1) * (Math.cos(lambda1) * Math.cos(phi2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) t_1 = math.cos(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -3.4e-5: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_1 - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2)))))) elif lambda1 <= 1.22e-6: tmp = math.atan2(t_0, (t_1 - (math.sin(phi1) * (math.cos(lambda2) * math.cos(phi2))))) else: tmp = math.atan2(t_0, (t_1 - (math.sin(phi1) * (math.cos(lambda1) * math.cos(phi2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) t_1 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -3.4e-5) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_1 - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); elseif (lambda1 <= 1.22e-6) tmp = atan(t_0, Float64(t_1 - Float64(sin(phi1) * Float64(cos(lambda2) * cos(phi2))))); else tmp = atan(t_0, Float64(t_1 - Float64(sin(phi1) * Float64(cos(lambda1) * cos(phi2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); t_1 = cos(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -3.4e-5) tmp = atan2((sin(lambda1) * cos(phi2)), (t_1 - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2)))))); elseif (lambda1 <= 1.22e-6) tmp = atan2(t_0, (t_1 - (sin(phi1) * (cos(lambda2) * cos(phi2))))); else tmp = atan2(t_0, (t_1 - (sin(phi1) * (cos(lambda1) * cos(phi2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -3.4e-5], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 1.22e-6], N[ArcTan[t$95$0 / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -3.4 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_1 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{elif}\;\lambda_1 \leq 1.22 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{t_1 - \sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{t_1 - \sin \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \phi_2\right)}\\
\end{array}
\end{array}
if lambda1 < -3.4e-5Initial program 70.0%
associate-*l*70.0%
Simplified70.0%
Taylor expanded in lambda2 around 0 70.2%
if -3.4e-5 < lambda1 < 1.21999999999999997e-6Initial program 99.0%
associate-*l*99.0%
Simplified99.0%
Taylor expanded in lambda1 around 0 99.0%
cos-neg99.0%
Simplified99.0%
if 1.21999999999999997e-6 < lambda1 Initial program 63.2%
associate-*l*63.2%
Simplified63.2%
Taylor expanded in lambda2 around 0 63.3%
Final simplification81.3%
(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 81.2%
associate-*l*81.2%
Simplified81.2%
Final simplification81.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -1.48) (not (<= lambda2 2.05e-5)))
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_0 (* (sin phi1) (cos (- lambda1 lambda2)))))
(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 <= -1.48) || !(lambda2 <= 2.05e-5)) {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))));
} 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 <= (-1.48d0)) .or. (.not. (lambda2 <= 2.05d-5))) then
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))))
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 <= -1.48) || !(lambda2 <= 2.05e-5)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_0 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} 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 <= -1.48) or not (lambda2 <= 2.05e-5): tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_0 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) 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 <= -1.48) || !(lambda2 <= 2.05e-5)) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); 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 <= -1.48) || ~((lambda2 <= 2.05e-5))) tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (sin(phi1) * cos((lambda1 - lambda2))))); 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, -1.48], N[Not[LessEqual[lambda2, 2.05e-5]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[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 -1.48 \lor \neg \left(\lambda_2 \leq 2.05 \cdot 10^{-5}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_0 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \cos \lambda_1 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if lambda2 < -1.48 or 2.05000000000000002e-5 < lambda2 Initial program 62.2%
associate-*l*62.2%
Simplified62.2%
Taylor expanded in phi2 around 0 55.0%
Taylor expanded in lambda1 around 0 57.1%
if -1.48 < lambda2 < 2.05000000000000002e-5Initial program 99.1%
associate-*l*99.1%
Simplified99.1%
Taylor expanded in phi2 around 0 81.5%
Taylor expanded in lambda2 around 0 81.5%
Final simplification69.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (sin (- lambda1 lambda2)))
(t_2 (* (cos phi2) t_1)))
(if (<= phi2 -13.8)
(atan2 t_2 (- t_0 (* (cos lambda2) (sin phi1))))
(if (<= phi2 9.8e-15)
(atan2
t_1
(- (* phi2 (cos phi1)) (* (sin phi1) (cos (- lambda1 lambda2)))))
(atan2 t_2 (- t_0 (* (cos lambda1) phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin((lambda1 - lambda2));
double t_2 = cos(phi2) * t_1;
double tmp;
if (phi2 <= -13.8) {
tmp = atan2(t_2, (t_0 - (cos(lambda2) * sin(phi1))));
} else if (phi2 <= 9.8e-15) {
tmp = atan2(t_1, ((phi2 * cos(phi1)) - (sin(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_2, (t_0 - (cos(lambda1) * phi1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin((lambda1 - lambda2))
t_2 = cos(phi2) * t_1
if (phi2 <= (-13.8d0)) then
tmp = atan2(t_2, (t_0 - (cos(lambda2) * sin(phi1))))
else if (phi2 <= 9.8d-15) then
tmp = atan2(t_1, ((phi2 * cos(phi1)) - (sin(phi1) * cos((lambda1 - lambda2)))))
else
tmp = atan2(t_2, (t_0 - (cos(lambda1) * phi1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin((lambda1 - lambda2));
double t_2 = Math.cos(phi2) * t_1;
double tmp;
if (phi2 <= -13.8) {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(lambda2) * Math.sin(phi1))));
} else if (phi2 <= 9.8e-15) {
tmp = Math.atan2(t_1, ((phi2 * Math.cos(phi1)) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(lambda1) * phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin((lambda1 - lambda2)) t_2 = math.cos(phi2) * t_1 tmp = 0 if phi2 <= -13.8: tmp = math.atan2(t_2, (t_0 - (math.cos(lambda2) * math.sin(phi1)))) elif phi2 <= 9.8e-15: tmp = math.atan2(t_1, ((phi2 * math.cos(phi1)) - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2(t_2, (t_0 - (math.cos(lambda1) * phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = sin(Float64(lambda1 - lambda2)) t_2 = Float64(cos(phi2) * t_1) tmp = 0.0 if (phi2 <= -13.8) tmp = atan(t_2, Float64(t_0 - Float64(cos(lambda2) * sin(phi1)))); elseif (phi2 <= 9.8e-15) tmp = atan(t_1, Float64(Float64(phi2 * cos(phi1)) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_2, Float64(t_0 - Float64(cos(lambda1) * phi1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin((lambda1 - lambda2)); t_2 = cos(phi2) * t_1; tmp = 0.0; if (phi2 <= -13.8) tmp = atan2(t_2, (t_0 - (cos(lambda2) * sin(phi1)))); elseif (phi2 <= 9.8e-15) tmp = atan2(t_1, ((phi2 * cos(phi1)) - (sin(phi1) * cos((lambda1 - lambda2))))); else tmp = atan2(t_2, (t_0 - (cos(lambda1) * 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[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[phi2, -13.8], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 9.8e-15], N[ArcTan[t$95$1 / N[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * phi1), $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)\\
t_2 := \cos \phi_2 \cdot t_1\\
\mathbf{if}\;\phi_2 \leq -13.8:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \lambda_2 \cdot \sin \phi_1}\\
\mathbf{elif}\;\phi_2 \leq 9.8 \cdot 10^{-15}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{\phi_2 \cdot \cos \phi_1 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \lambda_1 \cdot \phi_1}\\
\end{array}
\end{array}
if phi2 < -13.800000000000001Initial program 80.9%
associate-*l*80.9%
Simplified80.9%
Taylor expanded in phi2 around 0 57.9%
Taylor expanded in lambda1 around 0 57.0%
cos-neg57.0%
*-commutative57.0%
Simplified57.0%
if -13.800000000000001 < phi2 < 9.7999999999999999e-15Initial program 87.0%
associate-*l*87.0%
Simplified87.0%
Taylor expanded in phi2 around 0 86.2%
log1p-expm1-u86.2%
log1p-udef69.8%
Applied egg-rr69.8%
Taylor expanded in phi2 around 0 86.2%
Taylor expanded in phi2 around 0 87.0%
if 9.7999999999999999e-15 < phi2 Initial program 71.4%
associate-*l*71.4%
Simplified71.4%
Taylor expanded in phi2 around 0 49.5%
Taylor expanded in phi1 around 0 49.6%
Taylor expanded in lambda2 around 0 49.8%
Final simplification68.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (sin (- lambda1 lambda2)))
(t_2 (* (cos phi2) t_1)))
(if (<= phi2 -13.8)
(atan2 t_2 (- t_0 (* (cos lambda1) (sin phi1))))
(if (<= phi2 9.8e-15)
(atan2
t_1
(- (* phi2 (cos phi1)) (* (sin phi1) (cos (- lambda1 lambda2)))))
(atan2 t_2 (- t_0 (* (cos lambda1) phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin((lambda1 - lambda2));
double t_2 = cos(phi2) * t_1;
double tmp;
if (phi2 <= -13.8) {
tmp = atan2(t_2, (t_0 - (cos(lambda1) * sin(phi1))));
} else if (phi2 <= 9.8e-15) {
tmp = atan2(t_1, ((phi2 * cos(phi1)) - (sin(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_2, (t_0 - (cos(lambda1) * phi1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin((lambda1 - lambda2))
t_2 = cos(phi2) * t_1
if (phi2 <= (-13.8d0)) then
tmp = atan2(t_2, (t_0 - (cos(lambda1) * sin(phi1))))
else if (phi2 <= 9.8d-15) then
tmp = atan2(t_1, ((phi2 * cos(phi1)) - (sin(phi1) * cos((lambda1 - lambda2)))))
else
tmp = atan2(t_2, (t_0 - (cos(lambda1) * phi1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin((lambda1 - lambda2));
double t_2 = Math.cos(phi2) * t_1;
double tmp;
if (phi2 <= -13.8) {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(lambda1) * Math.sin(phi1))));
} else if (phi2 <= 9.8e-15) {
tmp = Math.atan2(t_1, ((phi2 * Math.cos(phi1)) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(lambda1) * phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin((lambda1 - lambda2)) t_2 = math.cos(phi2) * t_1 tmp = 0 if phi2 <= -13.8: tmp = math.atan2(t_2, (t_0 - (math.cos(lambda1) * math.sin(phi1)))) elif phi2 <= 9.8e-15: tmp = math.atan2(t_1, ((phi2 * math.cos(phi1)) - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2(t_2, (t_0 - (math.cos(lambda1) * phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = sin(Float64(lambda1 - lambda2)) t_2 = Float64(cos(phi2) * t_1) tmp = 0.0 if (phi2 <= -13.8) tmp = atan(t_2, Float64(t_0 - Float64(cos(lambda1) * sin(phi1)))); elseif (phi2 <= 9.8e-15) tmp = atan(t_1, Float64(Float64(phi2 * cos(phi1)) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_2, Float64(t_0 - Float64(cos(lambda1) * phi1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin((lambda1 - lambda2)); t_2 = cos(phi2) * t_1; tmp = 0.0; if (phi2 <= -13.8) tmp = atan2(t_2, (t_0 - (cos(lambda1) * sin(phi1)))); elseif (phi2 <= 9.8e-15) tmp = atan2(t_1, ((phi2 * cos(phi1)) - (sin(phi1) * cos((lambda1 - lambda2))))); else tmp = atan2(t_2, (t_0 - (cos(lambda1) * 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[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[phi2, -13.8], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 9.8e-15], N[ArcTan[t$95$1 / N[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * phi1), $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)\\
t_2 := \cos \phi_2 \cdot t_1\\
\mathbf{if}\;\phi_2 \leq -13.8:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \lambda_1 \cdot \sin \phi_1}\\
\mathbf{elif}\;\phi_2 \leq 9.8 \cdot 10^{-15}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{\phi_2 \cdot \cos \phi_1 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \lambda_1 \cdot \phi_1}\\
\end{array}
\end{array}
if phi2 < -13.800000000000001Initial program 80.9%
associate-*l*80.9%
Simplified80.9%
Taylor expanded in phi2 around 0 57.9%
Taylor expanded in lambda2 around 0 58.1%
if -13.800000000000001 < phi2 < 9.7999999999999999e-15Initial program 87.0%
associate-*l*87.0%
Simplified87.0%
Taylor expanded in phi2 around 0 86.2%
log1p-expm1-u86.2%
log1p-udef69.8%
Applied egg-rr69.8%
Taylor expanded in phi2 around 0 86.2%
Taylor expanded in phi2 around 0 87.0%
if 9.7999999999999999e-15 < phi2 Initial program 71.4%
associate-*l*71.4%
Simplified71.4%
Taylor expanded in phi2 around 0 49.5%
Taylor expanded in phi1 around 0 49.6%
Taylor expanded in lambda2 around 0 49.8%
Final simplification69.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin 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)) - (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)) - (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.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.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(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)) - (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[Sin[phi1], $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 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 81.2%
associate-*l*81.2%
Simplified81.2%
Taylor expanded in phi2 around 0 68.7%
Final simplification68.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (sin (- lambda1 lambda2))))
(if (or (<= phi1 -3.65e-6) (not (<= phi1 780000.0)))
(atan2 t_1 (- t_0 (* (sin phi1) (cos (- lambda1 lambda2)))))
(atan2 (* (cos phi2) t_1) (- t_0 phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -3.65e-6) || !(phi1 <= 780000.0)) {
tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((cos(phi2) * t_1), (t_0 - phi1));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin((lambda1 - lambda2))
if ((phi1 <= (-3.65d-6)) .or. (.not. (phi1 <= 780000.0d0))) then
tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))))
else
tmp = atan2((cos(phi2) * t_1), (t_0 - phi1))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -3.65e-6) || !(phi1 <= 780000.0)) {
tmp = Math.atan2(t_1, (t_0 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * t_1), (t_0 - phi1));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi1 <= -3.65e-6) or not (phi1 <= 780000.0): tmp = math.atan2(t_1, (t_0 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((math.cos(phi2) * t_1), (t_0 - phi1)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -3.65e-6) || !(phi1 <= 780000.0)) tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(cos(phi2) * t_1), Float64(t_0 - phi1)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -3.65e-6) || ~((phi1 <= 780000.0))) tmp = atan2(t_1, (t_0 - (sin(phi1) * cos((lambda1 - lambda2))))); else tmp = atan2((cos(phi2) * t_1), (t_0 - 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[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -3.65e-6], N[Not[LessEqual[phi1, 780000.0]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(t$95$0 - phi1), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -3.65 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 780000\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_1}{t_0 - \phi_1}\\
\end{array}
\end{array}
if phi1 < -3.65000000000000021e-6 or 7.8e5 < phi1 Initial program 79.3%
associate-*l*79.3%
Simplified79.3%
Taylor expanded in phi2 around 0 54.0%
log1p-expm1-u53.9%
log1p-udef44.4%
Applied egg-rr44.4%
Taylor expanded in phi2 around 0 51.7%
if -3.65000000000000021e-6 < phi1 < 7.8e5Initial program 82.9%
associate-*l*82.9%
Simplified82.9%
Taylor expanded in phi2 around 0 81.8%
Taylor expanded in phi1 around 0 81.7%
Taylor expanded in lambda1 around 0 73.2%
cos-neg73.2%
+-commutative73.2%
mul-1-neg73.2%
sin-neg73.2%
Simplified73.2%
Taylor expanded in lambda2 around 0 81.7%
Final simplification67.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -4.4e+16) (not (<= phi2 9.8e-15)))
(atan2
(* (cos phi2) t_0)
(- (* (cos phi1) (sin phi2)) (* (cos lambda1) phi1)))
(atan2
t_0
(- (* phi2 (cos phi1)) (* (sin phi1) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -4.4e+16) || !(phi2 <= 9.8e-15)) {
tmp = atan2((cos(phi2) * t_0), ((cos(phi1) * sin(phi2)) - (cos(lambda1) * phi1)));
} else {
tmp = atan2(t_0, ((phi2 * cos(phi1)) - (sin(phi1) * cos((lambda1 - lambda2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if ((phi2 <= (-4.4d+16)) .or. (.not. (phi2 <= 9.8d-15))) then
tmp = atan2((cos(phi2) * t_0), ((cos(phi1) * sin(phi2)) - (cos(lambda1) * phi1)))
else
tmp = atan2(t_0, ((phi2 * cos(phi1)) - (sin(phi1) * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -4.4e+16) || !(phi2 <= 9.8e-15)) {
tmp = Math.atan2((Math.cos(phi2) * t_0), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(lambda1) * phi1)));
} else {
tmp = Math.atan2(t_0, ((phi2 * Math.cos(phi1)) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi2 <= -4.4e+16) or not (phi2 <= 9.8e-15): tmp = math.atan2((math.cos(phi2) * t_0), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(lambda1) * phi1))) else: tmp = math.atan2(t_0, ((phi2 * math.cos(phi1)) - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -4.4e+16) || !(phi2 <= 9.8e-15)) tmp = atan(Float64(cos(phi2) * t_0), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(lambda1) * phi1))); else tmp = atan(t_0, Float64(Float64(phi2 * cos(phi1)) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi2 <= -4.4e+16) || ~((phi2 <= 9.8e-15))) tmp = atan2((cos(phi2) * t_0), ((cos(phi1) * sin(phi2)) - (cos(lambda1) * phi1))); else tmp = atan2(t_0, ((phi2 * cos(phi1)) - (sin(phi1) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -4.4e+16], N[Not[LessEqual[phi2, 9.8e-15]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -4.4 \cdot 10^{+16} \lor \neg \left(\phi_2 \leq 9.8 \cdot 10^{-15}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_0}{\cos \phi_1 \cdot \sin \phi_2 - \cos \lambda_1 \cdot \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\phi_2 \cdot \cos \phi_1 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -4.4e16 or 9.7999999999999999e-15 < phi2 Initial program 76.9%
associate-*l*77.0%
Simplified77.0%
Taylor expanded in phi2 around 0 54.4%
Taylor expanded in phi1 around 0 52.3%
Taylor expanded in lambda2 around 0 52.3%
if -4.4e16 < phi2 < 9.7999999999999999e-15Initial program 86.1%
associate-*l*86.1%
Simplified86.1%
Taylor expanded in phi2 around 0 84.8%
log1p-expm1-u84.8%
log1p-udef68.8%
Applied egg-rr68.8%
Taylor expanded in phi2 around 0 84.5%
Taylor expanded in phi2 around 0 85.2%
Final simplification67.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (sin (- lambda1 lambda2)))
(t_3 (* (cos phi2) t_2)))
(if (<= phi2 -4.4e+16)
(atan2 t_3 (- t_0 (* phi1 t_1)))
(if (<= phi2 9.8e-15)
(atan2 t_2 (- (* phi2 (cos phi1)) (* (sin phi1) t_1)))
(atan2 t_3 (- t_0 (* (cos lambda1) phi1)))))))
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 t_3 = cos(phi2) * t_2;
double tmp;
if (phi2 <= -4.4e+16) {
tmp = atan2(t_3, (t_0 - (phi1 * t_1)));
} else if (phi2 <= 9.8e-15) {
tmp = atan2(t_2, ((phi2 * cos(phi1)) - (sin(phi1) * t_1)));
} else {
tmp = atan2(t_3, (t_0 - (cos(lambda1) * phi1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
t_2 = sin((lambda1 - lambda2))
t_3 = cos(phi2) * t_2
if (phi2 <= (-4.4d+16)) then
tmp = atan2(t_3, (t_0 - (phi1 * t_1)))
else if (phi2 <= 9.8d-15) then
tmp = atan2(t_2, ((phi2 * cos(phi1)) - (sin(phi1) * t_1)))
else
tmp = atan2(t_3, (t_0 - (cos(lambda1) * phi1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.sin((lambda1 - lambda2));
double t_3 = Math.cos(phi2) * t_2;
double tmp;
if (phi2 <= -4.4e+16) {
tmp = Math.atan2(t_3, (t_0 - (phi1 * t_1)));
} else if (phi2 <= 9.8e-15) {
tmp = Math.atan2(t_2, ((phi2 * Math.cos(phi1)) - (Math.sin(phi1) * t_1)));
} else {
tmp = Math.atan2(t_3, (t_0 - (Math.cos(lambda1) * phi1)));
}
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)) t_3 = math.cos(phi2) * t_2 tmp = 0 if phi2 <= -4.4e+16: tmp = math.atan2(t_3, (t_0 - (phi1 * t_1))) elif phi2 <= 9.8e-15: tmp = math.atan2(t_2, ((phi2 * math.cos(phi1)) - (math.sin(phi1) * t_1))) else: tmp = math.atan2(t_3, (t_0 - (math.cos(lambda1) * phi1))) 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)) t_3 = Float64(cos(phi2) * t_2) tmp = 0.0 if (phi2 <= -4.4e+16) tmp = atan(t_3, Float64(t_0 - Float64(phi1 * t_1))); elseif (phi2 <= 9.8e-15) tmp = atan(t_2, Float64(Float64(phi2 * cos(phi1)) - Float64(sin(phi1) * t_1))); else tmp = atan(t_3, Float64(t_0 - Float64(cos(lambda1) * phi1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); t_2 = sin((lambda1 - lambda2)); t_3 = cos(phi2) * t_2; tmp = 0.0; if (phi2 <= -4.4e+16) tmp = atan2(t_3, (t_0 - (phi1 * t_1))); elseif (phi2 <= 9.8e-15) tmp = atan2(t_2, ((phi2 * cos(phi1)) - (sin(phi1) * t_1))); else tmp = atan2(t_3, (t_0 - (cos(lambda1) * 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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]}, If[LessEqual[phi2, -4.4e+16], N[ArcTan[t$95$3 / N[(t$95$0 - N[(phi1 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 9.8e-15], N[ArcTan[t$95$2 / N[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$3 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * phi1), $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)\\
t_3 := \cos \phi_2 \cdot t_2\\
\mathbf{if}\;\phi_2 \leq -4.4 \cdot 10^{+16}:\\
\;\;\;\;\tan^{-1}_* \frac{t_3}{t_0 - \phi_1 \cdot t_1}\\
\mathbf{elif}\;\phi_2 \leq 9.8 \cdot 10^{-15}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{\phi_2 \cdot \cos \phi_1 - \sin \phi_1 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_3}{t_0 - \cos \lambda_1 \cdot \phi_1}\\
\end{array}
\end{array}
if phi2 < -4.4e16Initial program 82.3%
associate-*l*82.3%
Simplified82.3%
Taylor expanded in phi2 around 0 59.1%
Taylor expanded in phi1 around 0 54.8%
if -4.4e16 < phi2 < 9.7999999999999999e-15Initial program 86.1%
associate-*l*86.1%
Simplified86.1%
Taylor expanded in phi2 around 0 84.8%
log1p-expm1-u84.8%
log1p-udef68.8%
Applied egg-rr68.8%
Taylor expanded in phi2 around 0 84.5%
Taylor expanded in phi2 around 0 85.2%
if 9.7999999999999999e-15 < phi2 Initial program 71.4%
associate-*l*71.4%
Simplified71.4%
Taylor expanded in phi2 around 0 49.5%
Taylor expanded in phi1 around 0 49.6%
Taylor expanded in lambda2 around 0 49.8%
Final simplification67.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi1 -1.45e-6) (not (<= phi1 780000.0)))
(atan2 t_0 (- (sin phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))
(atan2 (* (cos phi2) t_0) (- (* (cos phi1) (sin phi2)) phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -1.45e-6) || !(phi1 <= 780000.0)) {
tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((cos(phi2) * t_0), ((cos(phi1) * sin(phi2)) - phi1));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if ((phi1 <= (-1.45d-6)) .or. (.not. (phi1 <= 780000.0d0))) then
tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2)))))
else
tmp = atan2((cos(phi2) * t_0), ((cos(phi1) * sin(phi2)) - phi1))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if ((phi1 <= -1.45e-6) || !(phi1 <= 780000.0)) {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * t_0), ((Math.cos(phi1) * Math.sin(phi2)) - phi1));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi1 <= -1.45e-6) or not (phi1 <= 780000.0): tmp = math.atan2(t_0, (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((math.cos(phi2) * t_0), ((math.cos(phi1) * math.sin(phi2)) - phi1)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -1.45e-6) || !(phi1 <= 780000.0)) tmp = atan(t_0, Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(cos(phi2) * t_0), Float64(Float64(cos(phi1) * sin(phi2)) - phi1)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -1.45e-6) || ~((phi1 <= 780000.0))) tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2))))); else tmp = atan2((cos(phi2) * t_0), ((cos(phi1) * sin(phi2)) - phi1)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -1.45e-6], N[Not[LessEqual[phi1, 780000.0]], $MachinePrecision]], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - phi1), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.45 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 780000\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_0}{\cos \phi_1 \cdot \sin \phi_2 - \phi_1}\\
\end{array}
\end{array}
if phi1 < -1.4500000000000001e-6 or 7.8e5 < phi1 Initial program 79.3%
associate-*l*79.3%
Simplified79.3%
Taylor expanded in phi2 around 0 54.0%
log1p-expm1-u53.9%
log1p-udef44.4%
Applied egg-rr44.4%
Taylor expanded in phi2 around 0 51.7%
Taylor expanded in phi1 around 0 51.4%
if -1.4500000000000001e-6 < phi1 < 7.8e5Initial program 82.9%
associate-*l*82.9%
Simplified82.9%
Taylor expanded in phi2 around 0 81.8%
Taylor expanded in phi1 around 0 81.7%
Taylor expanded in lambda1 around 0 73.2%
cos-neg73.2%
+-commutative73.2%
mul-1-neg73.2%
sin-neg73.2%
Simplified73.2%
Taylor expanded in lambda2 around 0 81.7%
Final simplification67.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (- (sin phi2) (* (sin phi1) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), (sin(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 - lambda2)), (sin(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 - lambda2)), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (sin(phi1) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 81.2%
associate-*l*81.2%
Simplified81.2%
Taylor expanded in phi2 around 0 68.7%
log1p-expm1-u68.7%
log1p-udef56.0%
Applied egg-rr56.0%
Taylor expanded in phi2 around 0 47.9%
Taylor expanded in phi1 around 0 47.7%
Final simplification47.7%
herbie shell --seed 2023256
(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))))))