
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 24 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(fma (sin lambda1) (sin lambda2) (* (cos lambda2) (cos lambda1)))
(* (cos phi2) (sin phi1))))))
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)) - (fma(sin(lambda1), sin(lambda2), (cos(lambda2) * cos(lambda1))) * (cos(phi2) * sin(phi1)))));
}
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(fma(sin(lambda1), sin(lambda2), Float64(cos(lambda2) * cos(lambda1))) * Float64(cos(phi2) * sin(phi1))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $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 - \mathsf{fma}\left(\sin \lambda_1, \sin \lambda_2, \cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}
\end{array}
Initial program 76.1%
*-commutative76.1%
associate-*l*76.1%
Simplified76.1%
sin-diff86.5%
sub-neg86.5%
Applied egg-rr86.5%
sub-neg86.5%
Simplified86.5%
associate-*r*86.5%
cos-diff99.8%
distribute-lft-in99.8%
*-commutative99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
distribute-lft-out99.8%
*-commutative99.8%
+-commutative99.8%
fma-define99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(cos phi2)
(*
(sin phi1)
(fma (cos lambda2) (cos lambda1) (* (sin lambda1) (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * 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(cos(phi2) * Float64(sin(phi1) * fma(cos(lambda2), cos(lambda1), Float64(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[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $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 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)}
\end{array}
Initial program 76.1%
*-commutative76.1%
associate-*l*76.1%
Simplified76.1%
sin-diff86.5%
sub-neg86.5%
Applied egg-rr86.5%
sub-neg86.5%
Simplified86.5%
cos-diff99.8%
*-commutative99.8%
fma-define99.8%
Applied egg-rr99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= phi2 -6.1) (not (<= phi2 2.8e-24)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2))))))
(atan2
(*
(cos phi2)
(fma (sin lambda1) (cos lambda2) (* (cos lambda1) (- (sin lambda2)))))
(-
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 tmp;
if ((phi2 <= -6.1) || !(phi2 <= 2.8e-24)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
} else {
tmp = atan2((cos(phi2) * fma(sin(lambda1), cos(lambda2), (cos(lambda1) * -sin(lambda2)))), (t_0 - (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((phi2 <= -6.1) || !(phi2 <= 2.8e-24)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(Float64(cos(phi2) * fma(sin(lambda1), cos(lambda2), Float64(cos(lambda1) * Float64(-sin(lambda2))))), Float64(t_0 - Float64(sin(phi1) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda1) * sin(lambda2)))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -6.1], N[Not[LessEqual[phi2, 2.8e-24]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 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\\
\mathbf{if}\;\phi_2 \leq -6.1 \lor \neg \left(\phi_2 \leq 2.8 \cdot 10^{-24}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \cos \lambda_1 \cdot \left(-\sin \lambda_2\right)\right)}{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.0999999999999996 or 2.8000000000000002e-24 < phi2 Initial program 74.5%
*-commutative74.5%
associate-*l*74.5%
Simplified74.5%
sin-diff88.3%
sub-neg88.3%
Applied egg-rr88.3%
sub-neg88.3%
Simplified88.3%
if -6.0999999999999996 < phi2 < 2.8000000000000002e-24Initial program 77.7%
*-commutative77.7%
associate-*l*77.7%
Simplified77.7%
sin-diff84.6%
cancel-sign-sub-inv84.6%
fma-define84.6%
Applied egg-rr84.6%
cos-diff99.9%
+-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in phi2 around 0 99.9%
Final simplification94.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))))
(if (or (<= phi2 -1.25e-5) (not (<= phi2 2.8e-24)))
(atan2
(* t_1 (cos phi2))
(- t_0 (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2))))))
(atan2
t_1
(-
t_0
(*
(fma (sin lambda1) (sin lambda2) (* (cos lambda2) (cos lambda1)))
(* (cos phi2) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = (sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2));
double tmp;
if ((phi2 <= -1.25e-5) || !(phi2 <= 2.8e-24)) {
tmp = atan2((t_1 * cos(phi2)), (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
} else {
tmp = atan2(t_1, (t_0 - (fma(sin(lambda1), sin(lambda2), (cos(lambda2) * cos(lambda1))) * (cos(phi2) * sin(phi1)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) tmp = 0.0 if ((phi2 <= -1.25e-5) || !(phi2 <= 2.8e-24)) tmp = atan(Float64(t_1 * cos(phi2)), Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(t_1, Float64(t_0 - Float64(fma(sin(lambda1), sin(lambda2), Float64(cos(lambda2) * cos(lambda1))) * Float64(cos(phi2) * sin(phi1))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -1.25e-5], N[Not[LessEqual[phi2, 2.8e-24]], $MachinePrecision]], N[ArcTan[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\\
\mathbf{if}\;\phi_2 \leq -1.25 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 2.8 \cdot 10^{-24}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot \cos \phi_2}{t\_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \mathsf{fma}\left(\sin \lambda_1, \sin \lambda_2, \cos \lambda_2 \cdot \cos \lambda_1\right) \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if phi2 < -1.25000000000000006e-5 or 2.8000000000000002e-24 < phi2 Initial program 73.9%
*-commutative73.9%
associate-*l*73.9%
Simplified73.9%
sin-diff88.4%
sub-neg88.4%
Applied egg-rr88.4%
sub-neg88.4%
Simplified88.4%
if -1.25000000000000006e-5 < phi2 < 2.8000000000000002e-24Initial program 78.3%
*-commutative78.3%
associate-*l*78.3%
Simplified78.3%
sin-diff84.5%
sub-neg84.5%
Applied egg-rr84.5%
sub-neg84.5%
Simplified84.5%
associate-*r*84.5%
cos-diff99.9%
distribute-lft-in99.9%
*-commutative99.9%
*-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
distribute-lft-out99.9%
*-commutative99.9%
+-commutative99.9%
fma-define99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in phi2 around 0 99.9%
Final simplification94.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(cos phi2)
(*
(sin phi1)
(+ (* (cos lambda2) (cos lambda1)) (* (sin lambda1) (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * (Math.sin(phi1) * ((Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda1) * Math.sin(lambda2)))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * (math.sin(phi1) * ((math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda1) * math.sin(lambda2)))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(sin(phi1) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda1) * sin(lambda2))))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * 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]], $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 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)}
\end{array}
Initial program 76.1%
*-commutative76.1%
associate-*l*76.1%
Simplified76.1%
sin-diff86.5%
sub-neg86.5%
Applied egg-rr86.5%
sub-neg86.5%
Simplified86.5%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))))
(if (or (<= phi2 -6.1) (not (<= phi2 1e-24)))
(atan2
t_1
(- t_0 (* (cos phi2) (* (sin phi1) (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.1) || !(phi2 <= 1e-24)) {
tmp = atan2(t_1, (t_0 - (cos(phi2) * (sin(phi1) * 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.1d0)) .or. (.not. (phi2 <= 1d-24))) then
tmp = atan2(t_1, (t_0 - (cos(phi2) * (sin(phi1) * 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.1) || !(phi2 <= 1e-24)) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * 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.1) or not (phi2 <= 1e-24): tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * (math.sin(phi1) * 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.1) || !(phi2 <= 1e-24)) tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * 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.1) || ~((phi2 <= 1e-24))) tmp = atan2(t_1, (t_0 - (cos(phi2) * (sin(phi1) * 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.1], N[Not[LessEqual[phi2, 1e-24]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $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.1 \lor \neg \left(\phi_2 \leq 10^{-24}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \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.0999999999999996 or 9.99999999999999924e-25 < phi2 Initial program 74.5%
*-commutative74.5%
associate-*l*74.5%
Simplified74.5%
sin-diff88.3%
sub-neg88.3%
Applied egg-rr88.3%
sub-neg88.3%
Simplified88.3%
if -6.0999999999999996 < phi2 < 9.99999999999999924e-25Initial program 77.7%
*-commutative77.7%
associate-*l*77.7%
Simplified77.7%
sin-diff84.6%
sub-neg84.6%
Applied egg-rr84.6%
sub-neg84.6%
Simplified84.6%
associate-*r*84.6%
cos-diff99.9%
distribute-lft-in99.9%
*-commutative99.9%
*-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
distribute-lft-out99.9%
*-commutative99.9%
+-commutative99.9%
fma-define99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in phi2 around 0 99.9%
Final simplification94.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (fma (sin lambda1) (cos lambda2) (* (cos lambda1) (- (sin lambda2))))) (- (* (cos phi1) (sin phi2)) (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * fma(sin(lambda1), cos(lambda2), (cos(lambda1) * -sin(lambda2)))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * fma(sin(lambda1), cos(lambda2), Float64(cos(lambda1) * Float64(-sin(lambda2))))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \cos \lambda_1 \cdot \left(-\sin \lambda_2\right)\right)}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}
\end{array}
Initial program 76.1%
*-commutative76.1%
associate-*l*76.1%
Simplified76.1%
sin-diff86.5%
cancel-sign-sub-inv86.5%
fma-define86.5%
Applied egg-rr86.5%
Final simplification86.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda1 -4.4e-8) (not (<= lambda1 0.000125)))
(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
(*
(cos phi2)
(*
(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 tmp;
if ((lambda1 <= -4.4e-8) || !(lambda1 <= 0.000125)) {
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 - (cos(phi2) * (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) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda1 <= (-4.4d-8)) .or. (.not. (lambda1 <= 0.000125d0))) 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 - (cos(phi2) * (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 tmp;
if ((lambda1 <= -4.4e-8) || !(lambda1 <= 0.000125)) {
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.cos(phi2) * (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) tmp = 0 if (lambda1 <= -4.4e-8) or not (lambda1 <= 0.000125): 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.cos(phi2) * (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)) tmp = 0.0 if ((lambda1 <= -4.4e-8) || !(lambda1 <= 0.000125)) 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(cos(phi2) * 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); tmp = 0.0; if ((lambda1 <= -4.4e-8) || ~((lambda1 <= 0.000125))) 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 - (cos(phi2) * (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]}, If[Or[LessEqual[lambda1, -4.4e-8], N[Not[LessEqual[lambda1, 0.000125]], $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[Cos[phi2], $MachinePrecision] * 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]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -4.4 \cdot 10^{-8} \lor \neg \left(\lambda_1 \leq 0.000125\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 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)\right)}\\
\end{array}
\end{array}
if lambda1 < -4.3999999999999997e-8 or 1.25e-4 < lambda1 Initial program 56.0%
*-commutative56.0%
associate-*l*56.0%
Simplified56.0%
sin-diff75.6%
sub-neg75.6%
Applied egg-rr75.6%
sub-neg75.6%
Simplified75.6%
Taylor expanded in lambda2 around 0 75.2%
associate-*r*75.2%
Simplified75.2%
if -4.3999999999999997e-8 < lambda1 < 1.25e-4Initial program 98.8%
*-commutative98.8%
associate-*l*98.8%
Simplified98.8%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr98.9%
Final simplification86.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda1 -3.8e-6) (not (<= lambda1 0.0009)))
(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
(*
(cos phi2)
(* (sin phi1) (+ 1.0 (+ (cos (+ lambda1 lambda2)) -1.0)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda1 <= -3.8e-6) || !(lambda1 <= 0.0009)) {
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 - (cos(phi2) * (sin(phi1) * (1.0 + (cos((lambda1 + lambda2)) + -1.0))))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda1 <= (-3.8d-6)) .or. (.not. (lambda1 <= 0.0009d0))) 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 - (cos(phi2) * (sin(phi1) * (1.0d0 + (cos((lambda1 + lambda2)) + (-1.0d0)))))))
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 <= -3.8e-6) || !(lambda1 <= 0.0009)) {
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.cos(phi2) * (Math.sin(phi1) * (1.0 + (Math.cos((lambda1 + lambda2)) + -1.0))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda1 <= -3.8e-6) or not (lambda1 <= 0.0009): 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.cos(phi2) * (math.sin(phi1) * (1.0 + (math.cos((lambda1 + lambda2)) + -1.0)))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda1 <= -3.8e-6) || !(lambda1 <= 0.0009)) 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(cos(phi2) * Float64(sin(phi1) * Float64(1.0 + Float64(cos(Float64(lambda1 + lambda2)) + -1.0)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda1 <= -3.8e-6) || ~((lambda1 <= 0.0009))) 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 - (cos(phi2) * (sin(phi1) * (1.0 + (cos((lambda1 + lambda2)) + -1.0)))))); 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, -3.8e-6], N[Not[LessEqual[lambda1, 0.0009]], $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[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[(1.0 + N[(N[Cos[N[(lambda1 + lambda2), $MachinePrecision]], $MachinePrecision] + -1.0), $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 -3.8 \cdot 10^{-6} \lor \neg \left(\lambda_1 \leq 0.0009\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 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \left(1 + \left(\cos \left(\lambda_1 + \lambda_2\right) + -1\right)\right)\right)}\\
\end{array}
\end{array}
if lambda1 < -3.8e-6 or 8.9999999999999998e-4 < lambda1 Initial program 56.0%
*-commutative56.0%
associate-*l*56.0%
Simplified56.0%
sin-diff75.6%
sub-neg75.6%
Applied egg-rr75.6%
sub-neg75.6%
Simplified75.6%
Taylor expanded in lambda2 around 0 75.2%
associate-*r*75.2%
Simplified75.2%
if -3.8e-6 < lambda1 < 8.9999999999999998e-4Initial program 98.8%
*-commutative98.8%
associate-*l*98.8%
Simplified98.8%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr98.9%
+-commutative98.9%
*-commutative98.9%
cos-diff98.8%
expm1-log1p-u98.8%
expm1-undefine98.8%
Applied egg-rr98.8%
expm1-define98.8%
cos-neg98.8%
sub-neg98.8%
+-commutative98.8%
distribute-neg-in98.8%
remove-double-neg98.8%
sub-neg98.8%
Simplified98.8%
expm1-undefine98.8%
Applied egg-rr98.8%
associate--l+98.8%
+-commutative98.8%
Simplified98.8%
Final simplification86.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\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 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}
\end{array}
Initial program 76.1%
*-commutative76.1%
associate-*l*76.1%
Simplified76.1%
sin-diff86.5%
sub-neg86.5%
Applied egg-rr86.5%
sub-neg86.5%
Simplified86.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi1 -1.85e-5)
(atan2
t_1
(-
t_0
(*
(cos phi2)
(* (sin phi1) (+ 1.0 (+ (cos (+ lambda1 lambda2)) -1.0))))))
(if (<= phi1 1e-51)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* (cos (- lambda2 lambda1)) (* (cos phi2) phi1))))
(atan2
t_1
(- t_0 (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.85e-5) {
tmp = atan2(t_1, (t_0 - (cos(phi2) * (sin(phi1) * (1.0 + (cos((lambda1 + lambda2)) + -1.0))))));
} else if (phi1 <= 1e-51) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos((lambda2 - lambda1)) * (cos(phi2) * phi1))));
} else {
tmp = atan2(t_1, (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin((lambda1 - lambda2))
if (phi1 <= (-1.85d-5)) then
tmp = atan2(t_1, (t_0 - (cos(phi2) * (sin(phi1) * (1.0d0 + (cos((lambda1 + lambda2)) + (-1.0d0)))))))
else if (phi1 <= 1d-51) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos((lambda2 - lambda1)) * (cos(phi2) * phi1))))
else
tmp = atan2(t_1, (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.85e-5) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * (1.0 + (Math.cos((lambda1 + lambda2)) + -1.0))))));
} else if (phi1 <= 1e-51) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (Math.cos((lambda2 - lambda1)) * (Math.cos(phi2) * phi1))));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -1.85e-5: tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * (math.sin(phi1) * (1.0 + (math.cos((lambda1 + lambda2)) + -1.0)))))) elif phi1 <= 1e-51: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (math.cos((lambda2 - lambda1)) * (math.cos(phi2) * phi1)))) else: tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2)))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -1.85e-5) tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * Float64(1.0 + Float64(cos(Float64(lambda1 + lambda2)) + -1.0)))))); elseif (phi1 <= 1e-51) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(cos(Float64(lambda2 - lambda1)) * Float64(cos(phi2) * phi1)))); else tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -1.85e-5) tmp = atan2(t_1, (t_0 - (cos(phi2) * (sin(phi1) * (1.0 + (cos((lambda1 + lambda2)) + -1.0)))))); elseif (phi1 <= 1e-51) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos((lambda2 - lambda1)) * (cos(phi2) * phi1)))); else tmp = atan2(t_1, (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.85e-5], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[(1.0 + N[(N[Cos[N[(lambda1 + lambda2), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1e-51], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.85 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \left(1 + \left(\cos \left(\lambda_1 + \lambda_2\right) + -1\right)\right)\right)}\\
\mathbf{elif}\;\phi_1 \leq 10^{-51}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \cos \left(\lambda_2 - \lambda_1\right) \cdot \left(\cos \phi_2 \cdot \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\end{array}
\end{array}
if phi1 < -1.84999999999999991e-5Initial program 70.8%
*-commutative70.8%
associate-*l*70.8%
Simplified70.8%
cos-diff99.6%
+-commutative99.6%
*-commutative99.6%
Applied egg-rr71.4%
+-commutative71.4%
*-commutative71.4%
cos-diff70.8%
expm1-log1p-u70.9%
expm1-undefine70.9%
Applied egg-rr70.9%
expm1-define70.9%
cos-neg70.9%
sub-neg70.9%
+-commutative70.9%
distribute-neg-in70.9%
remove-double-neg70.9%
sub-neg70.9%
Simplified70.9%
expm1-undefine70.9%
Applied egg-rr70.8%
associate--l+70.9%
+-commutative70.9%
Simplified70.9%
if -1.84999999999999991e-5 < phi1 < 1e-51Initial program 79.6%
*-commutative79.6%
associate-*l*79.6%
Simplified79.6%
sin-diff99.7%
sub-neg99.7%
Applied egg-rr99.7%
sub-neg99.7%
Simplified99.7%
Taylor expanded in phi1 around 0 99.7%
associate-*r*99.7%
*-commutative99.7%
sub-neg99.7%
remove-double-neg99.7%
mul-1-neg99.7%
distribute-neg-in99.7%
+-commutative99.7%
cos-neg99.7%
mul-1-neg99.7%
unsub-neg99.7%
Simplified99.7%
if 1e-51 < phi1 Initial program 75.2%
*-commutative75.2%
associate-*l*75.2%
Simplified75.2%
Final simplification84.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin phi1) (cos (- lambda1 lambda2))))
(t_2 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi2 -6.1)
(atan2 t_2 (- t_0 (* (cos phi2) (+ (exp (log1p t_1)) -1.0))))
(if (<= phi2 2.8e-24)
(atan2
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(- t_0 (* (cos phi2) t_1)))
(atan2
t_2
(-
t_0
(*
(cos phi2)
(* (sin phi1) (expm1 (log1p (cos (- lambda2 lambda1))))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin(phi1) * cos((lambda1 - lambda2));
double t_2 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -6.1) {
tmp = atan2(t_2, (t_0 - (cos(phi2) * (exp(log1p(t_1)) + -1.0))));
} else if (phi2 <= 2.8e-24) {
tmp = atan2(((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))), (t_0 - (cos(phi2) * t_1)));
} else {
tmp = atan2(t_2, (t_0 - (cos(phi2) * (sin(phi1) * expm1(log1p(cos((lambda2 - lambda1))))))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin(phi1) * Math.cos((lambda1 - lambda2));
double t_2 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -6.1) {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(phi2) * (Math.exp(Math.log1p(t_1)) + -1.0))));
} else if (phi2 <= 2.8e-24) {
tmp = Math.atan2(((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))), (t_0 - (Math.cos(phi2) * t_1)));
} else {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * Math.expm1(Math.log1p(Math.cos((lambda2 - lambda1))))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin(phi1) * math.cos((lambda1 - lambda2)) t_2 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= -6.1: tmp = math.atan2(t_2, (t_0 - (math.cos(phi2) * (math.exp(math.log1p(t_1)) + -1.0)))) elif phi2 <= 2.8e-24: tmp = math.atan2(((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))), (t_0 - (math.cos(phi2) * t_1))) else: tmp = math.atan2(t_2, (t_0 - (math.cos(phi2) * (math.sin(phi1) * math.expm1(math.log1p(math.cos((lambda2 - lambda1)))))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))) t_2 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi2 <= -6.1) tmp = atan(t_2, Float64(t_0 - Float64(cos(phi2) * Float64(exp(log1p(t_1)) + -1.0)))); elseif (phi2 <= 2.8e-24) tmp = atan(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))), Float64(t_0 - Float64(cos(phi2) * t_1))); else tmp = atan(t_2, Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * expm1(log1p(cos(Float64(lambda2 - lambda1)))))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -6.1], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Exp[N[Log[1 + t$95$1], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 2.8e-24], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[(Exp[N[Log[1 + N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -6.1:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - \cos \phi_2 \cdot \left(e^{\mathsf{log1p}\left(t\_1\right)} + -1\right)}\\
\mathbf{elif}\;\phi_2 \leq 2.8 \cdot 10^{-24}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2}{t\_0 - \cos \phi_2 \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(\lambda_2 - \lambda_1\right)\right)\right)\right)}\\
\end{array}
\end{array}
if phi2 < -6.0999999999999996Initial program 63.7%
*-commutative63.7%
associate-*l*63.7%
Simplified63.7%
expm1-log1p-u63.7%
expm1-undefine63.7%
*-commutative63.7%
Applied egg-rr63.7%
if -6.0999999999999996 < phi2 < 2.8000000000000002e-24Initial program 77.7%
*-commutative77.7%
associate-*l*77.7%
Simplified77.7%
sin-diff84.6%
cancel-sign-sub-inv84.6%
fma-define84.6%
Applied egg-rr84.6%
Taylor expanded in phi2 around 0 84.1%
mul-1-neg84.1%
+-commutative84.1%
sub-neg84.1%
*-commutative84.1%
Simplified84.1%
if 2.8000000000000002e-24 < phi2 Initial program 81.5%
*-commutative81.5%
associate-*l*81.5%
Simplified81.5%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr81.6%
+-commutative81.6%
*-commutative81.6%
cos-diff81.5%
expm1-log1p-u81.5%
expm1-undefine81.5%
Applied egg-rr81.5%
expm1-define81.5%
cos-neg81.5%
sub-neg81.5%
+-commutative81.5%
distribute-neg-in81.5%
remove-double-neg81.5%
sub-neg81.5%
Simplified81.5%
Final simplification79.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos (- lambda1 lambda2))))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (atan2 (* (sin lambda1) (cos phi2)) (- t_1 (* (cos phi2) t_0))))
(t_3 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- t_1 t_0))))
(if (<= lambda1 -0.118)
t_2
(if (<= lambda1 -9.5e-161)
t_3
(if (<= lambda1 1.12e-284)
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_1 (* (cos phi2) (* (cos lambda2) (sin phi1)))))
(if (<= lambda1 3.4e-26) t_3 t_2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos((lambda1 - lambda2));
double t_1 = cos(phi1) * sin(phi2);
double t_2 = atan2((sin(lambda1) * cos(phi2)), (t_1 - (cos(phi2) * t_0)));
double t_3 = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_1 - t_0));
double tmp;
if (lambda1 <= -0.118) {
tmp = t_2;
} else if (lambda1 <= -9.5e-161) {
tmp = t_3;
} else if (lambda1 <= 1.12e-284) {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_1 - (cos(phi2) * (cos(lambda2) * sin(phi1)))));
} else if (lambda1 <= 3.4e-26) {
tmp = t_3;
} else {
tmp = 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) :: t_3
real(8) :: tmp
t_0 = sin(phi1) * cos((lambda1 - lambda2))
t_1 = cos(phi1) * sin(phi2)
t_2 = atan2((sin(lambda1) * cos(phi2)), (t_1 - (cos(phi2) * t_0)))
t_3 = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_1 - t_0))
if (lambda1 <= (-0.118d0)) then
tmp = t_2
else if (lambda1 <= (-9.5d-161)) then
tmp = t_3
else if (lambda1 <= 1.12d-284) then
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_1 - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
else if (lambda1 <= 3.4d-26) then
tmp = t_3
else
tmp = t_2
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.cos((lambda1 - lambda2));
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double t_2 = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_1 - (Math.cos(phi2) * t_0)));
double t_3 = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_1 - t_0));
double tmp;
if (lambda1 <= -0.118) {
tmp = t_2;
} else if (lambda1 <= -9.5e-161) {
tmp = t_3;
} else if (lambda1 <= 1.12e-284) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_1 - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
} else if (lambda1 <= 3.4e-26) {
tmp = t_3;
} else {
tmp = t_2;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.cos((lambda1 - lambda2)) t_1 = math.cos(phi1) * math.sin(phi2) t_2 = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_1 - (math.cos(phi2) * t_0))) t_3 = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_1 - t_0)) tmp = 0 if lambda1 <= -0.118: tmp = t_2 elif lambda1 <= -9.5e-161: tmp = t_3 elif lambda1 <= 1.12e-284: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_1 - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) elif lambda1 <= 3.4e-26: tmp = t_3 else: tmp = t_2 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_1 - Float64(cos(phi2) * t_0))) t_3 = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_1 - t_0)) tmp = 0.0 if (lambda1 <= -0.118) tmp = t_2; elseif (lambda1 <= -9.5e-161) tmp = t_3; elseif (lambda1 <= 1.12e-284) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_1 - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))); elseif (lambda1 <= 3.4e-26) tmp = t_3; else tmp = t_2; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * cos((lambda1 - lambda2)); t_1 = cos(phi1) * sin(phi2); t_2 = atan2((sin(lambda1) * cos(phi2)), (t_1 - (cos(phi2) * t_0))); t_3 = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_1 - t_0)); tmp = 0.0; if (lambda1 <= -0.118) tmp = t_2; elseif (lambda1 <= -9.5e-161) tmp = t_3; elseif (lambda1 <= 1.12e-284) tmp = atan2((cos(phi2) * sin(-lambda2)), (t_1 - (cos(phi2) * (cos(lambda2) * sin(phi1))))); elseif (lambda1 <= 3.4e-26) tmp = t_3; else tmp = t_2; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -0.118], t$95$2, If[LessEqual[lambda1, -9.5e-161], t$95$3, If[LessEqual[lambda1, 1.12e-284], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 3.4e-26], t$95$3, t$95$2]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_1 - \cos \phi_2 \cdot t\_0}\\
t_3 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_1 - t\_0}\\
\mathbf{if}\;\lambda_1 \leq -0.118:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_1 \leq -9.5 \cdot 10^{-161}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\lambda_1 \leq 1.12 \cdot 10^{-284}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t\_1 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\mathbf{elif}\;\lambda_1 \leq 3.4 \cdot 10^{-26}:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if lambda1 < -0.11799999999999999 or 3.40000000000000013e-26 < lambda1 Initial program 57.3%
*-commutative57.3%
associate-*l*57.3%
Simplified57.3%
Taylor expanded in lambda2 around 0 60.1%
if -0.11799999999999999 < lambda1 < -9.4999999999999996e-161 or 1.11999999999999996e-284 < lambda1 < 3.40000000000000013e-26Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
log1p-expm1-u99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in phi2 around 0 87.9%
if -9.4999999999999996e-161 < lambda1 < 1.11999999999999996e-284Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in lambda1 around 0 99.8%
Taylor expanded in lambda1 around 0 99.8%
*-commutative99.8%
cos-neg99.8%
*-commutative99.8%
Simplified99.8%
Final simplification73.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (- t_0 (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))))
(if (<= lambda1 -0.0255)
(atan2 (* (sin lambda1) (cos phi2)) t_1)
(if (<= lambda1 0.04)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (cos phi2) (* (cos lambda2) (sin phi1)))))
(atan2 (* (cos phi2) (sin (+ lambda1 lambda2))) t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))));
double tmp;
if (lambda1 <= -0.0255) {
tmp = atan2((sin(lambda1) * cos(phi2)), t_1);
} else if (lambda1 <= 0.04) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 + lambda2))), t_1);
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))
if (lambda1 <= (-0.0255d0)) then
tmp = atan2((sin(lambda1) * cos(phi2)), t_1)
else if (lambda1 <= 0.04d0) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 + lambda2))), t_1)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = t_0 - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))));
double tmp;
if (lambda1 <= -0.0255) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), t_1);
} else if (lambda1 <= 0.04) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 + lambda2))), t_1);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = t_0 - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2)))) tmp = 0 if lambda1 <= -0.0255: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), t_1) elif lambda1 <= 0.04: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 + lambda2))), t_1) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (lambda1 <= -0.0255) tmp = atan(Float64(sin(lambda1) * cos(phi2)), t_1); elseif (lambda1 <= 0.04) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 + lambda2))), t_1); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))); tmp = 0.0; if (lambda1 <= -0.0255) tmp = atan2((sin(lambda1) * cos(phi2)), t_1); elseif (lambda1 <= 0.04) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1))))); else tmp = atan2((cos(phi2) * sin((lambda1 + lambda2))), t_1); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -0.0255], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision], If[LessEqual[lambda1, 0.04], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 + lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := t\_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{if}\;\lambda_1 \leq -0.0255:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_1}\\
\mathbf{elif}\;\lambda_1 \leq 0.04:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 + \lambda_2\right)}{t\_1}\\
\end{array}
\end{array}
if lambda1 < -0.0254999999999999984Initial program 65.7%
*-commutative65.7%
associate-*l*65.7%
Simplified65.7%
Taylor expanded in lambda2 around 0 70.3%
if -0.0254999999999999984 < lambda1 < 0.0400000000000000008Initial program 98.8%
*-commutative98.8%
associate-*l*98.8%
Simplified98.8%
Taylor expanded in lambda1 around 0 98.7%
*-commutative98.7%
cos-neg98.7%
*-commutative98.7%
Simplified98.7%
if 0.0400000000000000008 < lambda1 Initial program 45.5%
*-commutative45.5%
associate-*l*45.5%
Simplified45.5%
add-cbrt-cube45.5%
pow345.5%
Applied egg-rr45.5%
rem-cbrt-cube45.5%
sin-diff71.2%
cancel-sign-sub-inv71.2%
add-sqr-sqrt35.2%
sqrt-unprod63.0%
sqr-neg63.0%
sqrt-unprod27.8%
add-sqr-sqrt47.2%
sin-sum48.8%
Applied egg-rr48.8%
+-commutative48.8%
Simplified48.8%
Final simplification78.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda1 -0.006) (not (<= lambda1 0.0125)))
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2))))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (cos phi2) (* (cos lambda2) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda1 <= -0.006) || !(lambda1 <= 0.0125)) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda1 <= (-0.006d0)) .or. (.not. (lambda1 <= 0.0125d0))) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda1 <= -0.006) || !(lambda1 <= 0.0125)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda1 <= -0.006) or not (lambda1 <= 0.0125): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2)))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda1 <= -0.006) || !(lambda1 <= 0.0125)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda1 <= -0.006) || ~((lambda1 <= 0.0125))) tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda2) * 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[lambda1, -0.006], N[Not[LessEqual[lambda1, 0.0125]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $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[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -0.006 \lor \neg \left(\lambda_1 \leq 0.0125\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \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 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if lambda1 < -0.0060000000000000001 or 0.012500000000000001 < lambda1 Initial program 55.6%
*-commutative55.6%
associate-*l*55.6%
Simplified55.6%
Taylor expanded in lambda2 around 0 59.2%
if -0.0060000000000000001 < lambda1 < 0.012500000000000001Initial program 98.8%
*-commutative98.8%
associate-*l*98.8%
Simplified98.8%
Taylor expanded in lambda1 around 0 98.7%
*-commutative98.7%
cos-neg98.7%
*-commutative98.7%
Simplified98.7%
Final simplification77.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -0.0285) (not (<= lambda2 4.4e-5)))
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_0 (* (cos phi2) (* (cos lambda2) (sin phi1)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (cos lambda1) (* (cos phi2) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda2 <= -0.0285) || !(lambda2 <= 4.4e-5)) {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda2 <= (-0.0285d0)) .or. (.not. (lambda2 <= 4.4d-5))) then
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda2 <= -0.0285) || !(lambda2 <= 4.4e-5)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_0 - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.cos(lambda1) * (Math.cos(phi2) * Math.sin(phi1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda2 <= -0.0285) or not (lambda2 <= 4.4e-5): tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_0 - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.cos(lambda1) * (math.cos(phi2) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda2 <= -0.0285) || !(lambda2 <= 4.4e-5)) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(lambda1) * Float64(cos(phi2) * sin(phi1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda2 <= -0.0285) || ~((lambda2 <= 4.4e-5))) tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -0.0285], N[Not[LessEqual[lambda2, 4.4e-5]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -0.0285 \lor \neg \left(\lambda_2 \leq 4.4 \cdot 10^{-5}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t\_0 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0 - \cos \lambda_1 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if lambda2 < -0.028500000000000001 or 4.3999999999999999e-5 < lambda2 Initial program 54.6%
*-commutative54.6%
associate-*l*54.6%
Simplified54.6%
Taylor expanded in lambda1 around 0 55.0%
Taylor expanded in lambda1 around 0 55.0%
*-commutative54.4%
cos-neg54.4%
*-commutative54.4%
Simplified55.0%
if -0.028500000000000001 < lambda2 < 4.3999999999999999e-5Initial program 98.2%
*-commutative98.2%
associate-*l*98.2%
Simplified98.2%
Taylor expanded in lambda2 around 0 98.2%
*-commutative98.2%
Simplified98.2%
Final simplification76.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -5.5e-5) (not (<= lambda2 4.4e-5)))
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_0 (* (cos phi2) (* (cos lambda2) (sin phi1)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda2 <= -5.5e-5) || !(lambda2 <= 4.4e-5)) {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda2 <= (-5.5d-5)) .or. (.not. (lambda2 <= 4.4d-5))) then
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda2 <= -5.5e-5) || !(lambda2 <= 4.4e-5)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_0 - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda2 <= -5.5e-5) or not (lambda2 <= 4.4e-5): tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_0 - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda2 <= -5.5e-5) || !(lambda2 <= 4.4e-5)) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda2 <= -5.5e-5) || ~((lambda2 <= 4.4e-5))) tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -5.5e-5], N[Not[LessEqual[lambda2, 4.4e-5]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -5.5 \cdot 10^{-5} \lor \neg \left(\lambda_2 \leq 4.4 \cdot 10^{-5}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t\_0 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda2 < -5.5000000000000002e-5 or 4.3999999999999999e-5 < lambda2 Initial program 54.5%
*-commutative54.5%
associate-*l*54.5%
Simplified54.5%
Taylor expanded in lambda1 around 0 54.8%
Taylor expanded in lambda1 around 0 54.8%
*-commutative54.3%
cos-neg54.3%
*-commutative54.3%
Simplified54.8%
if -5.5000000000000002e-5 < lambda2 < 4.3999999999999999e-5Initial program 98.7%
*-commutative98.7%
associate-*l*98.7%
Simplified98.7%
log1p-expm1-u98.7%
*-commutative98.7%
Applied egg-rr98.7%
Taylor expanded in phi2 around 0 84.0%
Final simplification69.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (cos phi2) (* (sin phi1) (+ 1.0 (+ (cos (+ lambda1 lambda2)) -1.0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * (1.0 + (cos((lambda1 + lambda2)) + -1.0))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * (1.0d0 + (cos((lambda1 + lambda2)) + (-1.0d0)))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * (Math.sin(phi1) * (1.0 + (Math.cos((lambda1 + lambda2)) + -1.0))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * (math.sin(phi1) * (1.0 + (math.cos((lambda1 + lambda2)) + -1.0))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(sin(phi1) * Float64(1.0 + Float64(cos(Float64(lambda1 + lambda2)) + -1.0)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * (1.0 + (cos((lambda1 + lambda2)) + -1.0)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[(1.0 + N[(N[Cos[N[(lambda1 + lambda2), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \left(1 + \left(\cos \left(\lambda_1 + \lambda_2\right) + -1\right)\right)\right)}
\end{array}
Initial program 76.1%
*-commutative76.1%
associate-*l*76.1%
Simplified76.1%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr76.4%
+-commutative76.4%
*-commutative76.4%
cos-diff76.1%
expm1-log1p-u76.1%
expm1-undefine76.0%
Applied egg-rr76.0%
expm1-define76.1%
cos-neg76.1%
sub-neg76.1%
+-commutative76.1%
distribute-neg-in76.1%
remove-double-neg76.1%
sub-neg76.1%
Simplified76.1%
expm1-undefine76.0%
Applied egg-rr76.0%
associate--l+76.1%
+-commutative76.1%
Simplified76.1%
Final simplification76.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}
\end{array}
Initial program 76.1%
*-commutative76.1%
associate-*l*76.1%
Simplified76.1%
Final simplification76.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (<= phi1 -24000.0)
(atan2
(sin (- lambda2))
(- t_0 (* (cos phi2) (* (sin phi1) (cos (- lambda1 lambda2))))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* phi1 (cos (- lambda2 lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if (phi1 <= -24000.0) {
tmp = atan2(sin(-lambda2), (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (phi1 * cos((lambda2 - lambda1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if (phi1 <= (-24000.0d0)) then
tmp = atan2(sin(-lambda2), (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2))))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (phi1 * cos((lambda2 - lambda1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -24000.0) {
tmp = Math.atan2(Math.sin(-lambda2), (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * Math.cos((lambda1 - lambda2))))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (phi1 * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if phi1 <= -24000.0: tmp = math.atan2(math.sin(-lambda2), (t_0 - (math.cos(phi2) * (math.sin(phi1) * math.cos((lambda1 - lambda2)))))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (phi1 * math.cos((lambda2 - lambda1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -24000.0) tmp = atan(sin(Float64(-lambda2)), Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if (phi1 <= -24000.0) tmp = atan2(sin(-lambda2), (t_0 - (cos(phi2) * (sin(phi1) * cos((lambda1 - lambda2)))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (phi1 * cos((lambda2 - lambda1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -24000.0], N[ArcTan[N[Sin[(-lambda2)], $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $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[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -24000:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right)}{t\_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \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 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\end{array}
\end{array}
if phi1 < -24000Initial program 69.8%
*-commutative69.8%
associate-*l*69.8%
Simplified69.8%
Taylor expanded in lambda1 around 0 37.4%
Taylor expanded in phi2 around 0 26.8%
if -24000 < phi1 Initial program 77.9%
*-commutative77.9%
associate-*l*77.9%
Simplified77.9%
Taylor expanded in phi1 around 0 59.7%
sub-neg59.7%
neg-mul-159.7%
neg-mul-159.7%
remove-double-neg59.7%
mul-1-neg59.7%
distribute-neg-in59.7%
+-commutative59.7%
*-commutative59.7%
cos-neg59.7%
mul-1-neg59.7%
unsub-neg59.7%
Simplified59.7%
Taylor expanded in phi2 around 0 60.8%
Final simplification53.1%
(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 76.1%
*-commutative76.1%
associate-*l*76.1%
Simplified76.1%
log1p-expm1-u76.0%
*-commutative76.0%
Applied egg-rr76.0%
Taylor expanded in phi2 around 0 65.2%
Final simplification65.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (cos (- lambda2 lambda1))))
(t_1 (sin (- lambda1 lambda2))))
(if (<= phi1 -21.0)
(atan2 t_1 (- (sin phi2) (fabs (* (cos phi2) t_0))))
(atan2 (* (cos phi2) t_1) (- (* (cos phi1) (sin phi2)) t_0)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * cos((lambda2 - lambda1));
double t_1 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -21.0) {
tmp = atan2(t_1, (sin(phi2) - fabs((cos(phi2) * t_0))));
} else {
tmp = atan2((cos(phi2) * t_1), ((cos(phi1) * sin(phi2)) - t_0));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = phi1 * cos((lambda2 - lambda1))
t_1 = sin((lambda1 - lambda2))
if (phi1 <= (-21.0d0)) then
tmp = atan2(t_1, (sin(phi2) - abs((cos(phi2) * t_0))))
else
tmp = atan2((cos(phi2) * t_1), ((cos(phi1) * sin(phi2)) - t_0))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * Math.cos((lambda2 - lambda1));
double t_1 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -21.0) {
tmp = Math.atan2(t_1, (Math.sin(phi2) - Math.abs((Math.cos(phi2) * t_0))));
} else {
tmp = Math.atan2((Math.cos(phi2) * t_1), ((Math.cos(phi1) * Math.sin(phi2)) - t_0));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = phi1 * math.cos((lambda2 - lambda1)) t_1 = math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -21.0: tmp = math.atan2(t_1, (math.sin(phi2) - math.fabs((math.cos(phi2) * t_0)))) else: tmp = math.atan2((math.cos(phi2) * t_1), ((math.cos(phi1) * math.sin(phi2)) - t_0)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(phi1 * cos(Float64(lambda2 - lambda1))) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -21.0) tmp = atan(t_1, Float64(sin(phi2) - abs(Float64(cos(phi2) * t_0)))); else tmp = atan(Float64(cos(phi2) * t_1), Float64(Float64(cos(phi1) * sin(phi2)) - t_0)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = phi1 * cos((lambda2 - lambda1)); t_1 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -21.0) tmp = atan2(t_1, (sin(phi2) - abs((cos(phi2) * t_0)))); else tmp = atan2((cos(phi2) * t_1), ((cos(phi1) * sin(phi2)) - t_0)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -21.0], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] - N[Abs[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -21:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 - \left|\cos \phi_2 \cdot t\_0\right|}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{\cos \phi_1 \cdot \sin \phi_2 - t\_0}\\
\end{array}
\end{array}
if phi1 < -21Initial program 70.3%
*-commutative70.3%
associate-*l*70.3%
Simplified70.3%
Taylor expanded in phi1 around 0 13.7%
sub-neg13.7%
neg-mul-113.7%
neg-mul-113.7%
remove-double-neg13.7%
mul-1-neg13.7%
distribute-neg-in13.7%
+-commutative13.7%
*-commutative13.7%
cos-neg13.7%
mul-1-neg13.7%
unsub-neg13.7%
Simplified13.7%
Taylor expanded in phi2 around 0 8.7%
Taylor expanded in phi1 around 0 8.7%
add-sqr-sqrt6.2%
sqrt-unprod21.5%
pow221.5%
associate-*r*21.5%
Applied egg-rr21.5%
unpow221.5%
rem-sqrt-square21.5%
*-commutative21.5%
Simplified21.5%
if -21 < phi1 Initial program 77.8%
*-commutative77.8%
associate-*l*77.8%
Simplified77.8%
Taylor expanded in phi1 around 0 59.9%
sub-neg59.9%
neg-mul-159.9%
neg-mul-159.9%
remove-double-neg59.9%
mul-1-neg59.9%
distribute-neg-in59.9%
+-commutative59.9%
*-commutative59.9%
cos-neg59.9%
mul-1-neg59.9%
unsub-neg59.9%
Simplified59.9%
Taylor expanded in phi2 around 0 61.1%
Final simplification52.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (- (sin phi2) (fabs (* (cos phi2) (* phi1 (cos (- lambda2 lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), (sin(phi2) - fabs((cos(phi2) * (phi1 * cos((lambda2 - lambda1)))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin((lambda1 - lambda2)), (sin(phi2) - abs((cos(phi2) * (phi1 * cos((lambda2 - lambda1)))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), (Math.sin(phi2) - Math.abs((Math.cos(phi2) * (phi1 * Math.cos((lambda2 - lambda1)))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), (math.sin(phi2) - math.fabs((math.cos(phi2) * (phi1 * math.cos((lambda2 - lambda1)))))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), Float64(sin(phi2) - abs(Float64(cos(phi2) * Float64(phi1 * cos(Float64(lambda2 - lambda1))))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - abs((cos(phi2) * (phi1 * cos((lambda2 - lambda1))))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[Abs[N[(N[Cos[phi2], $MachinePrecision] * N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \left|\cos \phi_2 \cdot \left(\phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\right|}
\end{array}
Initial program 76.1%
*-commutative76.1%
associate-*l*76.1%
Simplified76.1%
Taylor expanded in phi1 around 0 49.3%
sub-neg49.3%
neg-mul-149.3%
neg-mul-149.3%
remove-double-neg49.3%
mul-1-neg49.3%
distribute-neg-in49.3%
+-commutative49.3%
*-commutative49.3%
cos-neg49.3%
mul-1-neg49.3%
unsub-neg49.3%
Simplified49.3%
Taylor expanded in phi2 around 0 32.6%
Taylor expanded in phi1 around 0 32.6%
add-sqr-sqrt24.5%
sqrt-unprod35.9%
pow235.9%
associate-*r*35.9%
Applied egg-rr35.9%
unpow235.9%
rem-sqrt-square35.9%
*-commutative35.9%
Simplified35.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (- (sin phi2) (* phi1 (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 76.1%
*-commutative76.1%
associate-*l*76.1%
Simplified76.1%
Taylor expanded in phi1 around 0 49.3%
sub-neg49.3%
neg-mul-149.3%
neg-mul-149.3%
remove-double-neg49.3%
mul-1-neg49.3%
distribute-neg-in49.3%
+-commutative49.3%
*-commutative49.3%
cos-neg49.3%
mul-1-neg49.3%
unsub-neg49.3%
Simplified49.3%
Taylor expanded in phi2 around 0 32.6%
Taylor expanded in phi1 around 0 32.6%
Taylor expanded in phi2 around 0 32.7%
herbie shell --seed 2024094
(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))))))