
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 23 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(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 80.1%
sin-diff87.7%
Applied egg-rr87.7%
cos-diff99.7%
+-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in phi1 around inf 99.7%
Final simplification99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (- t_1 (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))
(t_3 (* (sin lambda1) (cos lambda2)))
(t_4 (* (- t_3 t_0) (cos phi2))))
(if (<= phi2 -2.6e-7)
(atan2 (- (* t_3 (cos phi2)) (* t_0 (cos phi2))) t_2)
(if (<= phi2 6.2e-21)
(atan2
t_4
(-
t_1
(*
(sin phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2 t_4 t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = t_1 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)));
double t_3 = sin(lambda1) * cos(lambda2);
double t_4 = (t_3 - t_0) * cos(phi2);
double tmp;
if (phi2 <= -2.6e-7) {
tmp = atan2(((t_3 * cos(phi2)) - (t_0 * cos(phi2))), t_2);
} else if (phi2 <= 6.2e-21) {
tmp = atan2(t_4, (t_1 - (sin(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_4, t_2);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = Float64(t_1 - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2)))) t_3 = Float64(sin(lambda1) * cos(lambda2)) t_4 = Float64(Float64(t_3 - t_0) * cos(phi2)) tmp = 0.0 if (phi2 <= -2.6e-7) tmp = atan(Float64(Float64(t_3 * cos(phi2)) - Float64(t_0 * cos(phi2))), t_2); elseif (phi2 <= 6.2e-21) tmp = atan(t_4, Float64(t_1 - Float64(sin(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_4, t_2); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(t$95$3 - t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -2.6e-7], N[ArcTan[N[(N[(t$95$3 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi2, 6.2e-21], N[ArcTan[t$95$4 / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$4 / t$95$2], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := t_1 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_3 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_4 := \left(t_3 - t_0\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -2.6 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{t_3 \cdot \cos \phi_2 - t_0 \cdot \cos \phi_2}{t_2}\\
\mathbf{elif}\;\phi_2 \leq 6.2 \cdot 10^{-21}:\\
\;\;\;\;\tan^{-1}_* \frac{t_4}{t_1 - \sin \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_4}{t_2}\\
\end{array}
\end{array}
if phi2 < -2.59999999999999999e-7Initial program 75.5%
sin-diff85.8%
Applied egg-rr85.8%
sin-diff75.5%
*-commutative75.5%
sin-diff85.8%
sub-neg85.8%
distribute-rgt-in85.8%
distribute-rgt-neg-in85.8%
Applied egg-rr85.8%
if -2.59999999999999999e-7 < phi2 < 6.1999999999999997e-21Initial program 81.5%
sin-diff88.2%
Applied egg-rr88.2%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in phi2 around 0 99.8%
*-commutative99.8%
fma-def99.8%
Simplified99.8%
if 6.1999999999999997e-21 < phi2 Initial program 81.9%
sin-diff88.6%
Applied egg-rr88.6%
Final simplification93.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2)))
(t_1 (* (sin lambda1) (cos lambda2)))
(t_2 (* (- t_1 t_0) (cos phi2)))
(t_3 (* (cos phi2) (sin phi1)))
(t_4 (- (* (cos phi1) (sin phi2)) (* t_3 (cos (- lambda1 lambda2))))))
(if (<= phi2 -1.42e-8)
(atan2 (- (* t_1 (cos phi2)) (* t_0 (cos phi2))) t_4)
(if (<= phi2 6.2e-21)
(atan2
t_2
(-
(sin phi2)
(*
t_3
(+
(* (cos lambda2) (cos lambda1))
(* (sin lambda1) (sin lambda2))))))
(atan2 t_2 t_4)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = sin(lambda1) * cos(lambda2);
double t_2 = (t_1 - t_0) * cos(phi2);
double t_3 = cos(phi2) * sin(phi1);
double t_4 = (cos(phi1) * sin(phi2)) - (t_3 * cos((lambda1 - lambda2)));
double tmp;
if (phi2 <= -1.42e-8) {
tmp = atan2(((t_1 * cos(phi2)) - (t_0 * cos(phi2))), t_4);
} else if (phi2 <= 6.2e-21) {
tmp = atan2(t_2, (sin(phi2) - (t_3 * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_2, t_4);
}
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) :: t_4
real(8) :: tmp
t_0 = cos(lambda1) * sin(lambda2)
t_1 = sin(lambda1) * cos(lambda2)
t_2 = (t_1 - t_0) * cos(phi2)
t_3 = cos(phi2) * sin(phi1)
t_4 = (cos(phi1) * sin(phi2)) - (t_3 * cos((lambda1 - lambda2)))
if (phi2 <= (-1.42d-8)) then
tmp = atan2(((t_1 * cos(phi2)) - (t_0 * cos(phi2))), t_4)
else if (phi2 <= 6.2d-21) then
tmp = atan2(t_2, (sin(phi2) - (t_3 * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2))))))
else
tmp = atan2(t_2, t_4)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(lambda1) * Math.sin(lambda2);
double t_1 = Math.sin(lambda1) * Math.cos(lambda2);
double t_2 = (t_1 - t_0) * Math.cos(phi2);
double t_3 = Math.cos(phi2) * Math.sin(phi1);
double t_4 = (Math.cos(phi1) * Math.sin(phi2)) - (t_3 * Math.cos((lambda1 - lambda2)));
double tmp;
if (phi2 <= -1.42e-8) {
tmp = Math.atan2(((t_1 * Math.cos(phi2)) - (t_0 * Math.cos(phi2))), t_4);
} else if (phi2 <= 6.2e-21) {
tmp = Math.atan2(t_2, (Math.sin(phi2) - (t_3 * ((Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda1) * Math.sin(lambda2))))));
} else {
tmp = Math.atan2(t_2, t_4);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda1) * math.sin(lambda2) t_1 = math.sin(lambda1) * math.cos(lambda2) t_2 = (t_1 - t_0) * math.cos(phi2) t_3 = math.cos(phi2) * math.sin(phi1) t_4 = (math.cos(phi1) * math.sin(phi2)) - (t_3 * math.cos((lambda1 - lambda2))) tmp = 0 if phi2 <= -1.42e-8: tmp = math.atan2(((t_1 * math.cos(phi2)) - (t_0 * math.cos(phi2))), t_4) elif phi2 <= 6.2e-21: tmp = math.atan2(t_2, (math.sin(phi2) - (t_3 * ((math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda1) * math.sin(lambda2)))))) else: tmp = math.atan2(t_2, t_4) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) t_1 = Float64(sin(lambda1) * cos(lambda2)) t_2 = Float64(Float64(t_1 - t_0) * cos(phi2)) t_3 = Float64(cos(phi2) * sin(phi1)) t_4 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_3 * cos(Float64(lambda1 - lambda2)))) tmp = 0.0 if (phi2 <= -1.42e-8) tmp = atan(Float64(Float64(t_1 * cos(phi2)) - Float64(t_0 * cos(phi2))), t_4); elseif (phi2 <= 6.2e-21) tmp = atan(t_2, Float64(sin(phi2) - Float64(t_3 * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_2, t_4); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(lambda1) * sin(lambda2); t_1 = sin(lambda1) * cos(lambda2); t_2 = (t_1 - t_0) * cos(phi2); t_3 = cos(phi2) * sin(phi1); t_4 = (cos(phi1) * sin(phi2)) - (t_3 * cos((lambda1 - lambda2))); tmp = 0.0; if (phi2 <= -1.42e-8) tmp = atan2(((t_1 * cos(phi2)) - (t_0 * cos(phi2))), t_4); elseif (phi2 <= 6.2e-21) tmp = atan2(t_2, (sin(phi2) - (t_3 * ((cos(lambda2) * cos(lambda1)) + (sin(lambda1) * sin(lambda2)))))); else tmp = atan2(t_2, t_4); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 - t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$3 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -1.42e-8], N[ArcTan[N[(N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$4], $MachinePrecision], If[LessEqual[phi2, 6.2e-21], N[ArcTan[t$95$2 / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$3 * 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], N[ArcTan[t$95$2 / t$95$4], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_2 := \left(t_1 - t_0\right) \cdot \cos \phi_2\\
t_3 := \cos \phi_2 \cdot \sin \phi_1\\
t_4 := \cos \phi_1 \cdot \sin \phi_2 - t_3 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -1.42 \cdot 10^{-8}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1 \cdot \cos \phi_2 - t_0 \cdot \cos \phi_2}{t_4}\\
\mathbf{elif}\;\phi_2 \leq 6.2 \cdot 10^{-21}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{\sin \phi_2 - t_3 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_4}\\
\end{array}
\end{array}
if phi2 < -1.41999999999999998e-8Initial program 75.5%
sin-diff85.8%
Applied egg-rr85.8%
sin-diff75.5%
*-commutative75.5%
sin-diff85.8%
sub-neg85.8%
distribute-rgt-in85.8%
distribute-rgt-neg-in85.8%
Applied egg-rr85.8%
if -1.41999999999999998e-8 < phi2 < 6.1999999999999997e-21Initial program 81.5%
sin-diff88.2%
Applied egg-rr88.2%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in phi1 around 0 99.8%
if 6.1999999999999997e-21 < phi2 Initial program 81.9%
sin-diff88.6%
Applied egg-rr88.6%
Final simplification93.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (- (* (* (sin lambda1) (cos lambda2)) (cos phi2)) (* (* (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(phi2)) - ((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(phi2)) - ((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(phi2)) - ((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(phi2)) - ((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)) * cos(phi2)) - Float64(Float64(cos(lambda1) * sin(lambda2)) * cos(phi2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) * cos(phi2)) - ((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[Cos[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2\right) \cdot \cos \phi_2 - \left(\cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 80.1%
sin-diff87.7%
Applied egg-rr87.7%
sin-diff80.1%
*-commutative80.1%
sin-diff87.7%
sub-neg87.7%
distribute-rgt-in87.7%
distribute-rgt-neg-in87.7%
Applied egg-rr87.7%
Final simplification87.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -2.4e-8) (not (<= lambda2 3.1e-5)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* (cos phi2) (* (cos lambda2) (sin phi1)))))
(atan2
(* (cos phi2) (- (sin lambda1) (* lambda2 (cos lambda1))))
(- t_0 (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda2 <= -2.4e-8) || !(lambda2 <= 3.1e-5)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))));
} else {
tmp = atan2((cos(phi2) * (sin(lambda1) - (lambda2 * cos(lambda1)))), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda2 <= (-2.4d-8)) .or. (.not. (lambda2 <= 3.1d-5))) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1)))))
else
tmp = atan2((cos(phi2) * (sin(lambda1) - (lambda2 * cos(lambda1)))), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda2 <= -2.4e-8) || !(lambda2 <= 3.1e-5)) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (Math.cos(phi2) * (Math.cos(lambda2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - (lambda2 * Math.cos(lambda1)))), (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda2 <= -2.4e-8) or not (lambda2 <= 3.1e-5): tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (math.cos(phi2) * (math.cos(lambda2) * math.sin(phi1))))) else: tmp = math.atan2((math.cos(phi2) * (math.sin(lambda1) - (lambda2 * math.cos(lambda1)))), (t_0 - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda2 <= -2.4e-8) || !(lambda2 <= 3.1e-5)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda2) * sin(phi1))))); else tmp = atan(Float64(cos(phi2) * Float64(sin(lambda1) - Float64(lambda2 * cos(lambda1)))), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda2 <= -2.4e-8) || ~((lambda2 <= 3.1e-5))) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(phi2) * (cos(lambda2) * sin(phi1))))); else tmp = atan2((cos(phi2) * (sin(lambda1) - (lambda2 * cos(lambda1)))), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -2.4e-8], N[Not[LessEqual[lambda2, 3.1e-5]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - N[(lambda2 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -2.4 \cdot 10^{-8} \lor \neg \left(\lambda_2 \leq 3.1 \cdot 10^{-5}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - \lambda_2 \cdot \cos \lambda_1\right)}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda2 < -2.39999999999999998e-8 or 3.10000000000000014e-5 < lambda2 Initial program 62.3%
sin-diff76.9%
Applied egg-rr76.9%
Taylor expanded in lambda1 around 0 76.8%
*-commutative76.8%
cos-neg76.8%
Simplified76.8%
if -2.39999999999999998e-8 < lambda2 < 3.10000000000000014e-5Initial program 99.3%
Taylor expanded in lambda2 around 0 99.4%
mul-1-neg99.4%
unsub-neg99.4%
Simplified99.4%
Final simplification87.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (cos phi2) (sin phi1))))
(if (or (<= lambda1 -1.55) (not (<= lambda1 1.6e-17)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* (cos lambda1) t_1)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* t_1 (log (exp (cos (- lambda1 lambda2))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double tmp;
if ((lambda1 <= -1.55) || !(lambda1 <= 1.6e-17)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * t_1)));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (t_1 * log(exp(cos((lambda1 - lambda2)))))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
if ((lambda1 <= (-1.55d0)) .or. (.not. (lambda1 <= 1.6d-17))) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * t_1)))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (t_1 * log(exp(cos((lambda1 - lambda2)))))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if ((lambda1 <= -1.55) || !(lambda1 <= 1.6e-17)) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (Math.cos(lambda1) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (t_1 * Math.log(Math.exp(Math.cos((lambda1 - lambda2)))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) tmp = 0 if (lambda1 <= -1.55) or not (lambda1 <= 1.6e-17): tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (math.cos(lambda1) * t_1))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (t_1 * math.log(math.exp(math.cos((lambda1 - lambda2))))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if ((lambda1 <= -1.55) || !(lambda1 <= 1.6e-17)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(cos(lambda1) * t_1))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(t_1 * log(exp(cos(Float64(lambda1 - lambda2))))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin(phi1); tmp = 0.0; if ((lambda1 <= -1.55) || ~((lambda1 <= 1.6e-17))) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * t_1))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (t_1 * log(exp(cos((lambda1 - lambda2))))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -1.55], N[Not[LessEqual[lambda1, 1.6e-17]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Log[N[Exp[N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
\mathbf{if}\;\lambda_1 \leq -1.55 \lor \neg \left(\lambda_1 \leq 1.6 \cdot 10^{-17}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \cos \lambda_1 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - t_1 \cdot \log \left(e^{\cos \left(\lambda_1 - \lambda_2\right)}\right)}\\
\end{array}
\end{array}
if lambda1 < -1.55000000000000004 or 1.6000000000000001e-17 < lambda1 Initial program 58.4%
sin-diff74.4%
Applied egg-rr74.4%
Taylor expanded in lambda2 around 0 74.4%
if -1.55000000000000004 < lambda1 < 1.6000000000000001e-17Initial program 99.8%
add-log-exp99.8%
Applied egg-rr99.8%
Final simplification87.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 80.1%
sin-diff87.7%
Applied egg-rr87.7%
Final simplification87.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin lambda1) (cos lambda2))) (t_1 (* (cos phi1) (sin phi2))))
(if (or (<= phi1 -66.0) (not (<= phi1 1.6e-43)))
(atan2
(* (cos phi2) (- t_0 (sin lambda2)))
(- t_1 (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))
(atan2
(* (- t_0 (* (cos lambda1) (sin lambda2))) (cos phi2))
(- t_1 (* phi1 (* (cos phi2) (cos (- lambda2 lambda1)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(lambda1) * cos(lambda2);
double t_1 = cos(phi1) * sin(phi2);
double tmp;
if ((phi1 <= -66.0) || !(phi1 <= 1.6e-43)) {
tmp = atan2((cos(phi2) * (t_0 - sin(lambda2))), (t_1 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(((t_0 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_1 - (phi1 * (cos(phi2) * cos((lambda2 - lambda1))))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(lambda1) * cos(lambda2)
t_1 = cos(phi1) * sin(phi2)
if ((phi1 <= (-66.0d0)) .or. (.not. (phi1 <= 1.6d-43))) then
tmp = atan2((cos(phi2) * (t_0 - sin(lambda2))), (t_1 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
else
tmp = atan2(((t_0 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_1 - (phi1 * (cos(phi2) * 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.sin(lambda1) * Math.cos(lambda2);
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((phi1 <= -66.0) || !(phi1 <= 1.6e-43)) {
tmp = Math.atan2((Math.cos(phi2) * (t_0 - Math.sin(lambda2))), (t_1 - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2(((t_0 - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_1 - (phi1 * (Math.cos(phi2) * Math.cos((lambda2 - lambda1))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(lambda1) * math.cos(lambda2) t_1 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (phi1 <= -66.0) or not (phi1 <= 1.6e-43): tmp = math.atan2((math.cos(phi2) * (t_0 - math.sin(lambda2))), (t_1 - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2(((t_0 - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_1 - (phi1 * (math.cos(phi2) * math.cos((lambda2 - lambda1)))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(lambda1) * cos(lambda2)) t_1 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((phi1 <= -66.0) || !(phi1 <= 1.6e-43)) tmp = atan(Float64(cos(phi2) * Float64(t_0 - sin(lambda2))), Float64(t_1 - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(Float64(t_0 - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_1 - Float64(phi1 * Float64(cos(phi2) * cos(Float64(lambda2 - lambda1)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(lambda1) * cos(lambda2); t_1 = cos(phi1) * sin(phi2); tmp = 0.0; if ((phi1 <= -66.0) || ~((phi1 <= 1.6e-43))) tmp = atan2((cos(phi2) * (t_0 - sin(lambda2))), (t_1 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); else tmp = atan2(((t_0 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_1 - (phi1 * (cos(phi2) * cos((lambda2 - lambda1)))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -66.0], N[Not[LessEqual[phi1, 1.6e-43]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(phi1 * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -66 \lor \neg \left(\phi_1 \leq 1.6 \cdot 10^{-43}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(t_0 - \sin \lambda_2\right)}{t_1 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t_0 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_1 - \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)}\\
\end{array}
\end{array}
if phi1 < -66 or 1.59999999999999992e-43 < phi1 Initial program 75.8%
sin-diff78.7%
Applied egg-rr78.7%
Taylor expanded in lambda1 around 0 76.8%
if -66 < phi1 < 1.59999999999999992e-43Initial program 85.0%
sin-diff98.1%
Applied egg-rr98.1%
Taylor expanded in phi1 around 0 98.1%
*-commutative85.0%
sub-neg85.0%
remove-double-neg85.0%
mul-1-neg85.0%
distribute-neg-in85.0%
+-commutative85.0%
cos-neg85.0%
mul-1-neg85.0%
unsub-neg85.0%
Simplified98.1%
Final simplification86.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin lambda1) (cos lambda2))) (t_1 (* (cos phi1) (sin phi2))))
(if (or (<= phi1 -66.0) (not (<= phi1 1.6e-43)))
(atan2
(* (cos phi2) (- t_0 (sin lambda2)))
(- t_1 (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))
(atan2
(* (- t_0 (* (cos lambda1) (sin lambda2))) (cos phi2))
(- t_1 (* (cos lambda1) phi1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(lambda1) * cos(lambda2);
double t_1 = cos(phi1) * sin(phi2);
double tmp;
if ((phi1 <= -66.0) || !(phi1 <= 1.6e-43)) {
tmp = atan2((cos(phi2) * (t_0 - sin(lambda2))), (t_1 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(((t_0 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_1 - (cos(lambda1) * phi1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(lambda1) * cos(lambda2)
t_1 = cos(phi1) * sin(phi2)
if ((phi1 <= (-66.0d0)) .or. (.not. (phi1 <= 1.6d-43))) then
tmp = atan2((cos(phi2) * (t_0 - sin(lambda2))), (t_1 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
else
tmp = atan2(((t_0 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_1 - (cos(lambda1) * phi1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(lambda1) * Math.cos(lambda2);
double t_1 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((phi1 <= -66.0) || !(phi1 <= 1.6e-43)) {
tmp = Math.atan2((Math.cos(phi2) * (t_0 - Math.sin(lambda2))), (t_1 - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2(((t_0 - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_1 - (Math.cos(lambda1) * phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(lambda1) * math.cos(lambda2) t_1 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (phi1 <= -66.0) or not (phi1 <= 1.6e-43): tmp = math.atan2((math.cos(phi2) * (t_0 - math.sin(lambda2))), (t_1 - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2(((t_0 - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_1 - (math.cos(lambda1) * phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(lambda1) * cos(lambda2)) t_1 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((phi1 <= -66.0) || !(phi1 <= 1.6e-43)) tmp = atan(Float64(cos(phi2) * Float64(t_0 - sin(lambda2))), Float64(t_1 - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(Float64(t_0 - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_1 - Float64(cos(lambda1) * phi1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(lambda1) * cos(lambda2); t_1 = cos(phi1) * sin(phi2); tmp = 0.0; if ((phi1 <= -66.0) || ~((phi1 <= 1.6e-43))) tmp = atan2((cos(phi2) * (t_0 - sin(lambda2))), (t_1 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); else tmp = atan2(((t_0 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_1 - (cos(lambda1) * phi1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -66.0], N[Not[LessEqual[phi1, 1.6e-43]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Cos[lambda1], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -66 \lor \neg \left(\phi_1 \leq 1.6 \cdot 10^{-43}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(t_0 - \sin \lambda_2\right)}{t_1 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t_0 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_1 - \cos \lambda_1 \cdot \phi_1}\\
\end{array}
\end{array}
if phi1 < -66 or 1.59999999999999992e-43 < phi1 Initial program 75.8%
sin-diff78.7%
Applied egg-rr78.7%
Taylor expanded in lambda1 around 0 76.8%
if -66 < phi1 < 1.59999999999999992e-43Initial program 85.0%
Taylor expanded in phi1 around 0 85.0%
*-commutative85.0%
sub-neg85.0%
remove-double-neg85.0%
mul-1-neg85.0%
distribute-neg-in85.0%
+-commutative85.0%
cos-neg85.0%
mul-1-neg85.0%
unsub-neg85.0%
Simplified85.0%
Taylor expanded in phi2 around 0 85.0%
sin-diff98.1%
Applied egg-rr98.1%
Taylor expanded in lambda2 around 0 98.1%
cos-neg85.0%
Simplified98.1%
Final simplification86.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi1 -66.0)
(atan2 t_1 (- t_0 (* (* (cos phi2) (sin phi1)) (log (exp t_2)))))
(if (<= phi1 1.6e-43)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* (cos lambda1) phi1)))
(atan2 t_1 (- t_0 (* (cos phi2) (* (sin phi1) t_2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -66.0) {
tmp = atan2(t_1, (t_0 - ((cos(phi2) * sin(phi1)) * log(exp(t_2)))));
} else if (phi1 <= 1.6e-43) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * phi1)));
} else {
tmp = atan2(t_1, (t_0 - (cos(phi2) * (sin(phi1) * t_2))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin((lambda1 - lambda2))
t_2 = cos((lambda1 - lambda2))
if (phi1 <= (-66.0d0)) then
tmp = atan2(t_1, (t_0 - ((cos(phi2) * sin(phi1)) * log(exp(t_2)))))
else if (phi1 <= 1.6d-43) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * phi1)))
else
tmp = atan2(t_1, (t_0 - (cos(phi2) * (sin(phi1) * t_2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double t_2 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -66.0) {
tmp = Math.atan2(t_1, (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * Math.log(Math.exp(t_2)))));
} else if (phi1 <= 1.6e-43) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (Math.cos(lambda1) * phi1)));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * t_2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) t_2 = math.cos((lambda1 - lambda2)) tmp = 0 if phi1 <= -66.0: tmp = math.atan2(t_1, (t_0 - ((math.cos(phi2) * math.sin(phi1)) * math.log(math.exp(t_2))))) elif phi1 <= 1.6e-43: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (math.cos(lambda1) * phi1))) else: tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * (math.sin(phi1) * t_2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -66.0) tmp = atan(t_1, Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * log(exp(t_2))))); elseif (phi1 <= 1.6e-43) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(cos(lambda1) * phi1))); else tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * t_2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin((lambda1 - lambda2)); t_2 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -66.0) tmp = atan2(t_1, (t_0 - ((cos(phi2) * sin(phi1)) * log(exp(t_2))))); elseif (phi1 <= 1.6e-43) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * phi1))); else tmp = atan2(t_1, (t_0 - (cos(phi2) * (sin(phi1) * t_2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -66.0], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Log[N[Exp[t$95$2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.6e-43], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * t$95$2), $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)\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -66:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \log \left(e^{t_2}\right)}\\
\mathbf{elif}\;\phi_1 \leq 1.6 \cdot 10^{-43}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \cos \lambda_1 \cdot \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot t_2\right)}\\
\end{array}
\end{array}
if phi1 < -66Initial program 73.8%
add-log-exp73.8%
Applied egg-rr73.8%
if -66 < phi1 < 1.59999999999999992e-43Initial program 85.0%
Taylor expanded in phi1 around 0 85.0%
*-commutative85.0%
sub-neg85.0%
remove-double-neg85.0%
mul-1-neg85.0%
distribute-neg-in85.0%
+-commutative85.0%
cos-neg85.0%
mul-1-neg85.0%
unsub-neg85.0%
Simplified85.0%
Taylor expanded in phi2 around 0 85.0%
sin-diff98.1%
Applied egg-rr98.1%
Taylor expanded in lambda2 around 0 98.1%
cos-neg85.0%
Simplified98.1%
if 1.59999999999999992e-43 < phi1 Initial program 77.3%
*-commutative77.3%
associate-*l*77.4%
Simplified77.4%
Final simplification86.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi1 -66.0)
(atan2 t_2 (- t_0 (* (* (cos phi2) (sin phi1)) t_1)))
(if (<= phi1 1.6e-43)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* (cos lambda1) phi1)))
(atan2 t_2 (- t_0 (* (cos phi2) (* (sin phi1) t_1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -66.0) {
tmp = atan2(t_2, (t_0 - ((cos(phi2) * sin(phi1)) * t_1)));
} else if (phi1 <= 1.6e-43) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * phi1)));
} else {
tmp = atan2(t_2, (t_0 - (cos(phi2) * (sin(phi1) * t_1))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
t_2 = cos(phi2) * sin((lambda1 - lambda2))
if (phi1 <= (-66.0d0)) then
tmp = atan2(t_2, (t_0 - ((cos(phi2) * sin(phi1)) * t_1)))
else if (phi1 <= 1.6d-43) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * phi1)))
else
tmp = atan2(t_2, (t_0 - (cos(phi2) * (sin(phi1) * t_1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -66.0) {
tmp = Math.atan2(t_2, (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * t_1)));
} else if (phi1 <= 1.6e-43) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (Math.cos(lambda1) * phi1)));
} else {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * t_1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -66.0: tmp = math.atan2(t_2, (t_0 - ((math.cos(phi2) * math.sin(phi1)) * t_1))) elif phi1 <= 1.6e-43: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (math.cos(lambda1) * phi1))) else: tmp = math.atan2(t_2, (t_0 - (math.cos(phi2) * (math.sin(phi1) * t_1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -66.0) tmp = atan(t_2, Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * t_1))); elseif (phi1 <= 1.6e-43) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(cos(lambda1) * phi1))); else tmp = atan(t_2, Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * t_1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); t_2 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -66.0) tmp = atan2(t_2, (t_0 - ((cos(phi2) * sin(phi1)) * t_1))); elseif (phi1 <= 1.6e-43) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * phi1))); else tmp = atan2(t_2, (t_0 - (cos(phi2) * (sin(phi1) * t_1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -66.0], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.6e-43], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -66:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_1}\\
\mathbf{elif}\;\phi_1 \leq 1.6 \cdot 10^{-43}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t_0 - \cos \lambda_1 \cdot \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot t_1\right)}\\
\end{array}
\end{array}
if phi1 < -66Initial program 73.8%
if -66 < phi1 < 1.59999999999999992e-43Initial program 85.0%
Taylor expanded in phi1 around 0 85.0%
*-commutative85.0%
sub-neg85.0%
remove-double-neg85.0%
mul-1-neg85.0%
distribute-neg-in85.0%
+-commutative85.0%
cos-neg85.0%
mul-1-neg85.0%
unsub-neg85.0%
Simplified85.0%
Taylor expanded in phi2 around 0 85.0%
sin-diff98.1%
Applied egg-rr98.1%
Taylor expanded in lambda2 around 0 98.1%
cos-neg85.0%
Simplified98.1%
if 1.59999999999999992e-43 < phi1 Initial program 77.3%
*-commutative77.3%
associate-*l*77.4%
Simplified77.4%
Final simplification86.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi1 -66.0)
(atan2 t_2 (- t_0 (* (* (cos phi2) (sin phi1)) t_1)))
(if (<= phi1 1.6e-43)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* phi1 (cos (- lambda2 lambda1)))))
(atan2 t_2 (- t_0 (* (cos phi2) (* (sin phi1) t_1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -66.0) {
tmp = atan2(t_2, (t_0 - ((cos(phi2) * sin(phi1)) * t_1)));
} else if (phi1 <= 1.6e-43) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))));
} else {
tmp = atan2(t_2, (t_0 - (cos(phi2) * (sin(phi1) * t_1))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
t_2 = cos(phi2) * sin((lambda1 - lambda2))
if (phi1 <= (-66.0d0)) then
tmp = atan2(t_2, (t_0 - ((cos(phi2) * sin(phi1)) * t_1)))
else if (phi1 <= 1.6d-43) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))))
else
tmp = atan2(t_2, (t_0 - (cos(phi2) * (sin(phi1) * t_1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -66.0) {
tmp = Math.atan2(t_2, (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * t_1)));
} else if (phi1 <= 1.6e-43) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(phi2) * (Math.sin(phi1) * t_1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -66.0: tmp = math.atan2(t_2, (t_0 - ((math.cos(phi2) * math.sin(phi1)) * t_1))) elif phi1 <= 1.6e-43: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2(t_2, (t_0 - (math.cos(phi2) * (math.sin(phi1) * t_1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -66.0) tmp = atan(t_2, Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * t_1))); elseif (phi1 <= 1.6e-43) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))); else tmp = atan(t_2, Float64(t_0 - Float64(cos(phi2) * Float64(sin(phi1) * t_1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); t_2 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -66.0) tmp = atan2(t_2, (t_0 - ((cos(phi2) * sin(phi1)) * t_1))); elseif (phi1 <= 1.6e-43) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1))))); else tmp = atan2(t_2, (t_0 - (cos(phi2) * (sin(phi1) * t_1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -66.0], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.6e-43], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -66:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_1}\\
\mathbf{elif}\;\phi_1 \leq 1.6 \cdot 10^{-43}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot t_1\right)}\\
\end{array}
\end{array}
if phi1 < -66Initial program 73.8%
if -66 < phi1 < 1.59999999999999992e-43Initial program 85.0%
Taylor expanded in phi1 around 0 85.0%
*-commutative85.0%
sub-neg85.0%
remove-double-neg85.0%
mul-1-neg85.0%
distribute-neg-in85.0%
+-commutative85.0%
cos-neg85.0%
mul-1-neg85.0%
unsub-neg85.0%
Simplified85.0%
Taylor expanded in phi2 around 0 85.0%
Taylor expanded in phi1 around 0 85.0%
sin-diff98.1%
Applied egg-rr98.1%
if 1.59999999999999992e-43 < phi1 Initial program 77.3%
*-commutative77.3%
associate-*l*77.4%
Simplified77.4%
Final simplification86.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (or (<= lambda2 -0.0095) (not (<= lambda2 0.0009)))
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_0 (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (cos phi2) (* (cos lambda1) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if ((lambda2 <= -0.0095) || !(lambda2 <= 0.0009)) {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
if ((lambda2 <= (-0.0095d0)) .or. (.not. (lambda2 <= 0.0009d0))) then
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if ((lambda2 <= -0.0095) || !(lambda2 <= 0.0009)) {
tmp = Math.atan2((Math.cos(phi2) * 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 - (Math.cos(phi2) * (Math.cos(lambda1) * Math.sin(phi1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if (lambda2 <= -0.0095) or not (lambda2 <= 0.0009): tmp = math.atan2((math.cos(phi2) * 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 - (math.cos(phi2) * (math.cos(lambda1) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if ((lambda2 <= -0.0095) || !(lambda2 <= 0.0009)) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda1) * sin(phi1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if ((lambda2 <= -0.0095) || ~((lambda2 <= 0.0009))) tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -0.0095], N[Not[LessEqual[lambda2, 0.0009]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -0.0095 \lor \neg \left(\lambda_2 \leq 0.0009\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if lambda2 < -0.00949999999999999976 or 8.9999999999999998e-4 < lambda2 Initial program 61.7%
Taylor expanded in lambda1 around 0 63.8%
if -0.00949999999999999976 < lambda2 < 8.9999999999999998e-4Initial program 99.3%
*-commutative99.3%
associate-*l*99.3%
Simplified99.3%
Taylor expanded in lambda2 around 0 99.2%
Final simplification81.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (or (<= lambda2 -1.25e-13) (not (<= lambda2 0.122)))
(atan2
t_1
(- t_0 (/ (cos (- lambda1 lambda2)) (/ 2.0 (* (sin phi1) 2.0)))))
(atan2 t_1 (- t_0 (* (cos phi2) (* (cos lambda1) (sin phi1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if ((lambda2 <= -1.25e-13) || !(lambda2 <= 0.122)) {
tmp = atan2(t_1, (t_0 - (cos((lambda1 - lambda2)) / (2.0 / (sin(phi1) * 2.0)))));
} else {
tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin((lambda1 - lambda2))
if ((lambda2 <= (-1.25d-13)) .or. (.not. (lambda2 <= 0.122d0))) then
tmp = atan2(t_1, (t_0 - (cos((lambda1 - lambda2)) / (2.0d0 / (sin(phi1) * 2.0d0)))))
else
tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if ((lambda2 <= -1.25e-13) || !(lambda2 <= 0.122)) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos((lambda1 - lambda2)) / (2.0 / (Math.sin(phi1) * 2.0)))));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(phi2) * (Math.cos(lambda1) * Math.sin(phi1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if (lambda2 <= -1.25e-13) or not (lambda2 <= 0.122): tmp = math.atan2(t_1, (t_0 - (math.cos((lambda1 - lambda2)) / (2.0 / (math.sin(phi1) * 2.0))))) else: tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * (math.cos(lambda1) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if ((lambda2 <= -1.25e-13) || !(lambda2 <= 0.122)) tmp = atan(t_1, Float64(t_0 - Float64(cos(Float64(lambda1 - lambda2)) / Float64(2.0 / Float64(sin(phi1) * 2.0))))); else tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda1) * sin(phi1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if ((lambda2 <= -1.25e-13) || ~((lambda2 <= 0.122))) tmp = atan2(t_1, (t_0 - (cos((lambda1 - lambda2)) / (2.0 / (sin(phi1) * 2.0))))); else tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -1.25e-13], N[Not[LessEqual[lambda2, 0.122]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(2.0 / N[(N[Sin[phi1], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_2 \leq -1.25 \cdot 10^{-13} \lor \neg \left(\lambda_2 \leq 0.122\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{\frac{2}{\sin \phi_1 \cdot 2}}}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if lambda2 < -1.24999999999999997e-13 or 0.122 < lambda2 Initial program 62.6%
*-commutative62.6%
sin-cos-mult54.9%
associate-*r/54.9%
Applied egg-rr54.9%
associate-/l*54.9%
Simplified54.9%
Taylor expanded in phi2 around 0 54.9%
if -1.24999999999999997e-13 < lambda2 < 0.122Initial program 99.3%
*-commutative99.3%
associate-*l*99.3%
Simplified99.3%
Taylor expanded in lambda2 around 0 98.8%
Final simplification75.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_2 (* (cos phi2) (sin phi1))))
(if (<= lambda1 -3.6e-6)
(atan2 t_1 (- t_0 (* (cos phi2) (* (cos lambda1) (sin phi1)))))
(if (<= lambda1 0.56)
(atan2 t_1 (- t_0 (* (cos lambda2) t_2)))
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* t_2 (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 t_2 = cos(phi2) * sin(phi1);
double tmp;
if (lambda1 <= -3.6e-6) {
tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))));
} else if (lambda1 <= 0.56) {
tmp = atan2(t_1, (t_0 - (cos(lambda2) * t_2)));
} else {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_2 * cos((lambda1 - lambda2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin((lambda1 - lambda2))
t_2 = cos(phi2) * sin(phi1)
if (lambda1 <= (-3.6d-6)) then
tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1)))))
else if (lambda1 <= 0.56d0) then
tmp = atan2(t_1, (t_0 - (cos(lambda2) * t_2)))
else
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_2 * 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 t_2 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if (lambda1 <= -3.6e-6) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(phi2) * (Math.cos(lambda1) * Math.sin(phi1)))));
} else if (lambda1 <= 0.56) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(lambda2) * t_2)));
} else {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - (t_2 * 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)) t_2 = math.cos(phi2) * math.sin(phi1) tmp = 0 if lambda1 <= -3.6e-6: tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * (math.cos(lambda1) * math.sin(phi1))))) elif lambda1 <= 0.56: tmp = math.atan2(t_1, (t_0 - (math.cos(lambda2) * t_2))) else: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - (t_2 * 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))) t_2 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if (lambda1 <= -3.6e-6) tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * Float64(cos(lambda1) * sin(phi1))))); elseif (lambda1 <= 0.56) tmp = atan(t_1, Float64(t_0 - Float64(cos(lambda2) * t_2))); else tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(t_2 * 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)); t_2 = cos(phi2) * sin(phi1); tmp = 0.0; if (lambda1 <= -3.6e-6) tmp = atan2(t_1, (t_0 - (cos(phi2) * (cos(lambda1) * sin(phi1))))); elseif (lambda1 <= 0.56) tmp = atan2(t_1, (t_0 - (cos(lambda2) * t_2))); else tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_2 * 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]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -3.6e-6], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 0.56], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$2 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_2 \cdot \sin \phi_1\\
\mathbf{if}\;\lambda_1 \leq -3.6 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\mathbf{elif}\;\lambda_1 \leq 0.56:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \lambda_2 \cdot t_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_0 - t_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda1 < -3.59999999999999984e-6Initial program 58.7%
*-commutative58.7%
associate-*l*58.7%
Simplified58.7%
Taylor expanded in lambda2 around 0 58.4%
if -3.59999999999999984e-6 < lambda1 < 0.56000000000000005Initial program 99.3%
Taylor expanded in lambda1 around 0 99.3%
cos-neg99.3%
Simplified99.3%
if 0.56000000000000005 < lambda1 Initial program 56.7%
Taylor expanded in lambda2 around 0 57.0%
Final simplification80.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 80.1%
*-commutative80.1%
associate-*l*80.1%
Simplified80.1%
Final simplification80.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi2 1e-7)
(atan2
t_1
(- t_0 (/ (cos (- lambda1 lambda2)) (/ 2.0 (* (sin phi1) 2.0)))))
(atan2 t_1 (- t_0 (* (cos phi2) (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 1e-7) {
tmp = atan2(t_1, (t_0 - (cos((lambda1 - lambda2)) / (2.0 / (sin(phi1) * 2.0)))));
} else {
tmp = atan2(t_1, (t_0 - (cos(phi2) * sin(phi1))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin((lambda1 - lambda2))
if (phi2 <= 1d-7) then
tmp = atan2(t_1, (t_0 - (cos((lambda1 - lambda2)) / (2.0d0 / (sin(phi1) * 2.0d0)))))
else
tmp = atan2(t_1, (t_0 - (cos(phi2) * sin(phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 1e-7) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos((lambda1 - lambda2)) / (2.0 / (Math.sin(phi1) * 2.0)))));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(phi2) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= 1e-7: tmp = math.atan2(t_1, (t_0 - (math.cos((lambda1 - lambda2)) / (2.0 / (math.sin(phi1) * 2.0))))) else: tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi2 <= 1e-7) tmp = atan(t_1, Float64(t_0 - Float64(cos(Float64(lambda1 - lambda2)) / Float64(2.0 / Float64(sin(phi1) * 2.0))))); else tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 1e-7) tmp = atan2(t_1, (t_0 - (cos((lambda1 - lambda2)) / (2.0 / (sin(phi1) * 2.0))))); else tmp = atan2(t_1, (t_0 - (cos(phi2) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 1e-7], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(2.0 / N[(N[Sin[phi1], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{\frac{2}{\sin \phi_1 \cdot 2}}}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \phi_2 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if phi2 < 9.9999999999999995e-8Initial program 80.1%
*-commutative80.1%
sin-cos-mult71.6%
associate-*r/71.6%
Applied egg-rr71.6%
associate-/l*71.6%
Simplified71.6%
Taylor expanded in phi2 around 0 71.6%
if 9.9999999999999995e-8 < phi2 Initial program 80.0%
*-commutative80.0%
associate-*l*80.0%
Simplified80.0%
Taylor expanded in lambda2 around 0 73.6%
Taylor expanded in lambda1 around 0 68.5%
Final simplification70.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi2 5.1e-37)
(atan2 t_0 (- (sin phi2) (* (cos phi2) (* (cos lambda1) (sin phi1)))))
(atan2 t_0 (- (* (cos phi1) (sin phi2)) (* (cos phi2) (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 5.1e-37) {
tmp = atan2(t_0, (sin(phi2) - (cos(phi2) * (cos(lambda1) * sin(phi1)))));
} else {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (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(phi2) * sin((lambda1 - lambda2))
if (phi2 <= 5.1d-37) then
tmp = atan2(t_0, (sin(phi2) - (cos(phi2) * (cos(lambda1) * sin(phi1)))))
else
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (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(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 5.1e-37) {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.cos(phi2) * (Math.cos(lambda1) * Math.sin(phi1)))));
} else {
tmp = Math.atan2(t_0, ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= 5.1e-37: tmp = math.atan2(t_0, (math.sin(phi2) - (math.cos(phi2) * (math.cos(lambda1) * math.sin(phi1))))) else: tmp = math.atan2(t_0, ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi2 <= 5.1e-37) tmp = atan(t_0, Float64(sin(phi2) - Float64(cos(phi2) * Float64(cos(lambda1) * sin(phi1))))); else tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 5.1e-37) tmp = atan2(t_0, (sin(phi2) - (cos(phi2) * (cos(lambda1) * sin(phi1))))); else tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 5.1e-37], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 5.1 \cdot 10^{-37}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\sin \phi_2 - \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \sin \phi_1}\\
\end{array}
\end{array}
if phi2 < 5.1000000000000001e-37Initial program 79.5%
*-commutative79.5%
associate-*l*79.5%
Simplified79.5%
Taylor expanded in lambda2 around 0 68.6%
Taylor expanded in phi1 around 0 64.1%
if 5.1000000000000001e-37 < phi2 Initial program 81.5%
*-commutative81.5%
associate-*l*81.5%
Simplified81.5%
Taylor expanded in lambda2 around 0 74.9%
Taylor expanded in lambda1 around 0 70.5%
Final simplification65.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) (* (cos phi2) (* (cos lambda1) (sin phi1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(phi2) * (cos(lambda1) * sin(phi1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(phi2) * (cos(lambda1) * sin(phi1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.cos(phi2) * (Math.cos(lambda1) * Math.sin(phi1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.cos(phi2) * (math.cos(lambda1) * math.sin(phi1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(cos(phi2) * Float64(cos(lambda1) * sin(phi1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(phi2) * (cos(lambda1) * sin(phi1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}
\end{array}
Initial program 80.1%
*-commutative80.1%
associate-*l*80.1%
Simplified80.1%
Taylor expanded in lambda2 around 0 70.3%
Taylor expanded in phi1 around 0 63.3%
Final simplification63.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) (fabs (* phi1 (cos (- lambda2 lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - fabs((phi1 * cos((lambda2 - lambda1))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - abs((phi1 * cos((lambda2 - lambda1))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - Math.abs((phi1 * Math.cos((lambda2 - lambda1))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - math.fabs((phi1 * math.cos((lambda2 - lambda1))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - abs(Float64(phi1 * cos(Float64(lambda2 - lambda1)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - abs((phi1 * cos((lambda2 - lambda1)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[Abs[N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \left|\phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right|}
\end{array}
Initial program 80.1%
Taylor expanded in phi1 around 0 50.0%
*-commutative50.0%
sub-neg50.0%
remove-double-neg50.0%
mul-1-neg50.0%
distribute-neg-in50.0%
+-commutative50.0%
cos-neg50.0%
mul-1-neg50.0%
unsub-neg50.0%
Simplified50.0%
Taylor expanded in phi2 around 0 49.3%
Taylor expanded in phi1 around 0 49.3%
add-sqr-sqrt29.9%
sqrt-unprod54.8%
pow254.8%
Applied egg-rr54.8%
unpow254.8%
rem-sqrt-square54.8%
Simplified54.8%
Final simplification54.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin lambda1) (cos phi2)) (- (sin phi2) (* phi1 (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (Math.sin(phi2) - (phi1 * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin(lambda1) * math.cos(phi2)), (math.sin(phi2) - (phi1 * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(lambda1) * cos(phi2)), Float64(sin(phi2) - Float64(phi1 * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (phi1 * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(phi1 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2 - \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 80.1%
Taylor expanded in phi1 around 0 50.0%
*-commutative50.0%
sub-neg50.0%
remove-double-neg50.0%
mul-1-neg50.0%
distribute-neg-in50.0%
+-commutative50.0%
cos-neg50.0%
mul-1-neg50.0%
unsub-neg50.0%
Simplified50.0%
Taylor expanded in phi2 around 0 49.3%
Taylor expanded in phi1 around 0 49.3%
Taylor expanded in lambda2 around 0 30.8%
Final simplification30.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) (* (cos lambda1) phi1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda1) * phi1)));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda1) * phi1)))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.cos(lambda1) * phi1)));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.cos(lambda1) * phi1)))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(cos(lambda1) * phi1))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda1) * phi1))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \lambda_1 \cdot \phi_1}
\end{array}
Initial program 80.1%
Taylor expanded in phi1 around 0 50.0%
*-commutative50.0%
sub-neg50.0%
remove-double-neg50.0%
mul-1-neg50.0%
distribute-neg-in50.0%
+-commutative50.0%
cos-neg50.0%
mul-1-neg50.0%
unsub-neg50.0%
Simplified50.0%
Taylor expanded in phi2 around 0 49.3%
Taylor expanded in phi1 around 0 49.3%
Taylor expanded in lambda2 around 0 48.8%
cos-neg48.8%
Simplified48.8%
Final simplification48.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) (* (cos lambda2) phi1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda2) * phi1)));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda2) * phi1)))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.cos(lambda2) * phi1)));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.cos(lambda2) * phi1)))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(cos(lambda2) * phi1))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (cos(lambda2) * phi1))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Cos[lambda2], $MachinePrecision] * phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \cos \lambda_2 \cdot \phi_1}
\end{array}
Initial program 80.1%
Taylor expanded in phi1 around 0 50.0%
*-commutative50.0%
sub-neg50.0%
remove-double-neg50.0%
mul-1-neg50.0%
distribute-neg-in50.0%
+-commutative50.0%
cos-neg50.0%
mul-1-neg50.0%
unsub-neg50.0%
Simplified50.0%
Taylor expanded in phi2 around 0 49.3%
Taylor expanded in phi1 around 0 49.3%
Taylor expanded in lambda1 around 0 49.6%
Final simplification49.6%
herbie shell --seed 2024014
(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))))))