
(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 29 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))
(+
(log (exp (* (sin lambda1) (sin lambda2))))
(* (cos lambda2) (cos lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * (log(exp((sin(lambda1) * sin(lambda2)))) + (cos(lambda2) * cos(lambda1))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * (log(exp((sin(lambda1) * sin(lambda2)))) + (cos(lambda2) * cos(lambda1))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * (Math.log(Math.exp((Math.sin(lambda1) * Math.sin(lambda2)))) + (Math.cos(lambda2) * Math.cos(lambda1))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * (math.log(math.exp((math.sin(lambda1) * math.sin(lambda2)))) + (math.cos(lambda2) * math.cos(lambda1))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * Float64(log(exp(Float64(sin(lambda1) * sin(lambda2)))) + Float64(cos(lambda2) * cos(lambda1)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * (log(exp((sin(lambda1) * sin(lambda2)))) + (cos(lambda2) * cos(lambda1)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[Log[N[Exp[N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \left(\log \left(e^{\sin \lambda_1 \cdot \sin \lambda_2}\right) + \cos \lambda_2 \cdot \cos \lambda_1\right)}
\end{array}
Initial program 81.1%
sin-diff89.6%
sub-neg89.6%
Applied egg-rr89.6%
sub-neg89.6%
Simplified89.6%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
add-cbrt-cube99.8%
pow399.8%
Applied egg-rr99.8%
rem-cbrt-cube99.8%
add-log-exp99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (cos phi2) (sin phi1))
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1))))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1))))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)}
\end{array}
Initial program 81.1%
sin-diff89.6%
sub-neg89.6%
Applied egg-rr89.6%
sub-neg89.6%
Simplified89.6%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_2 (* (cos phi2) (sin phi1)))
(t_3 (cos (- lambda1 lambda2))))
(if (<= phi2 -1.85)
(atan2 t_1 (- t_0 (* t_2 t_3)))
(if (<= phi2 3.6e-13)
(atan2
t_1
(-
(sin phi2)
(*
t_2
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1))))))
(atan2 t_1 (- t_0 (* t_3 (* (cos phi2) (log (exp (sin phi1)))))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_2 = cos(phi2) * sin(phi1);
double t_3 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -1.85) {
tmp = atan2(t_1, (t_0 - (t_2 * t_3)));
} else if (phi2 <= 3.6e-13) {
tmp = atan2(t_1, (sin(phi2) - (t_2 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
} else {
tmp = atan2(t_1, (t_0 - (t_3 * (cos(phi2) * log(exp(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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)
t_2 = cos(phi2) * sin(phi1)
t_3 = cos((lambda1 - lambda2))
if (phi2 <= (-1.85d0)) then
tmp = atan2(t_1, (t_0 - (t_2 * t_3)))
else if (phi2 <= 3.6d-13) then
tmp = atan2(t_1, (sin(phi2) - (t_2 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))))
else
tmp = atan2(t_1, (t_0 - (t_3 * (cos(phi2) * log(exp(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.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2);
double t_2 = Math.cos(phi2) * Math.sin(phi1);
double t_3 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -1.85) {
tmp = Math.atan2(t_1, (t_0 - (t_2 * t_3)));
} else if (phi2 <= 3.6e-13) {
tmp = Math.atan2(t_1, (Math.sin(phi2) - (t_2 * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1))))));
} else {
tmp = Math.atan2(t_1, (t_0 - (t_3 * (Math.cos(phi2) * Math.log(Math.exp(Math.sin(phi1)))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2) t_2 = math.cos(phi2) * math.sin(phi1) t_3 = math.cos((lambda1 - lambda2)) tmp = 0 if phi2 <= -1.85: tmp = math.atan2(t_1, (t_0 - (t_2 * t_3))) elif phi2 <= 3.6e-13: tmp = math.atan2(t_1, (math.sin(phi2) - (t_2 * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1)))))) else: tmp = math.atan2(t_1, (t_0 - (t_3 * (math.cos(phi2) * math.log(math.exp(math.sin(phi1))))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_2 = Float64(cos(phi2) * sin(phi1)) t_3 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -1.85) tmp = atan(t_1, Float64(t_0 - Float64(t_2 * t_3))); elseif (phi2 <= 3.6e-13) tmp = atan(t_1, Float64(sin(phi2) - Float64(t_2 * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))))); else tmp = atan(t_1, Float64(t_0 - Float64(t_3 * Float64(cos(phi2) * log(exp(sin(phi1))))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2); t_2 = cos(phi2) * sin(phi1); t_3 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= -1.85) tmp = atan2(t_1, (t_0 - (t_2 * t_3))); elseif (phi2 <= 3.6e-13) tmp = atan2(t_1, (sin(phi2) - (t_2 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))); else tmp = atan2(t_1, (t_0 - (t_3 * (cos(phi2) * log(exp(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[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -1.85], N[ArcTan[t$95$1 / N[(t$95$0 - N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 3.6e-13], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$2 * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(t$95$3 * N[(N[Cos[phi2], $MachinePrecision] * N[Log[N[Exp[N[Sin[phi1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \cos \phi_2 \cdot \sin \phi_1\\
t_3 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -1.85:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - t_2 \cdot t_3}\\
\mathbf{elif}\;\phi_2 \leq 3.6 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{\sin \phi_2 - t_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - t_3 \cdot \left(\cos \phi_2 \cdot \log \left(e^{\sin \phi_1}\right)\right)}\\
\end{array}
\end{array}
if phi2 < -1.8500000000000001Initial program 84.6%
sin-diff89.9%
sub-neg89.9%
Applied egg-rr89.9%
sub-neg89.9%
Simplified89.9%
if -1.8500000000000001 < phi2 < 3.5999999999999998e-13Initial program 78.5%
sin-diff87.7%
sub-neg87.7%
Applied egg-rr87.7%
sub-neg87.7%
Simplified87.7%
cos-diff99.9%
+-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in phi1 around 0 99.9%
if 3.5999999999999998e-13 < phi2 Initial program 84.2%
sin-diff93.7%
sub-neg93.7%
Applied egg-rr93.7%
sub-neg93.7%
Simplified93.7%
cos-diff99.7%
+-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
associate-*l*99.7%
+-commutative99.7%
*-commutative99.7%
cos-diff93.7%
add-log-exp93.7%
associate-*r*93.7%
exp-prod93.7%
exp-prod93.5%
Applied egg-rr93.5%
log-pow93.6%
log-pow93.7%
Simplified93.7%
Final simplification96.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (cos phi2) (sin phi1))))
(if (or (<= lambda1 -2250000000000.0) (not (<= lambda1 26500000.0)))
(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
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1)))))))))
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 <= -2250000000000.0) || !(lambda1 <= 26500000.0)) {
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 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
if ((lambda1 <= (-2250000000000.0d0)) .or. (.not. (lambda1 <= 26500000.0d0))) 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 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if ((lambda1 <= -2250000000000.0) || !(lambda1 <= 26500000.0)) {
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.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1))))));
}
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 <= -2250000000000.0) or not (lambda1 <= 26500000.0): 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.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1)))))) 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 <= -2250000000000.0) || !(lambda1 <= 26500000.0)) 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 * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))))); 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 <= -2250000000000.0) || ~((lambda1 <= 26500000.0))) 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 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -2250000000000.0], N[Not[LessEqual[lambda1, 26500000.0]], $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[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\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 -2250000000000 \lor \neg \left(\lambda_1 \leq 26500000\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 \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)}\\
\end{array}
\end{array}
if lambda1 < -2.25e12 or 2.65e7 < lambda1 Initial program 61.6%
sin-diff79.7%
sub-neg79.7%
Applied egg-rr79.7%
sub-neg79.7%
Simplified79.7%
Taylor expanded in lambda2 around 0 79.8%
if -2.25e12 < lambda1 < 2.65e7Initial program 98.5%
cos-diff99.7%
+-commutative99.7%
*-commutative99.7%
Applied egg-rr98.6%
Final simplification89.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (cos phi2) (sin phi1))))
(if (or (<= lambda1 -2500000000000.0) (not (<= lambda1 26500000.0)))
(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 (cbrt (pow (cos (- lambda1 lambda2)) 3.0))))))))
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 <= -2500000000000.0) || !(lambda1 <= 26500000.0)) {
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 * cbrt(pow(cos((lambda1 - lambda2)), 3.0)))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if ((lambda1 <= -2500000000000.0) || !(lambda1 <= 26500000.0)) {
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.cbrt(Math.pow(Math.cos((lambda1 - lambda2)), 3.0)))));
}
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 <= -2500000000000.0) || !(lambda1 <= 26500000.0)) 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 * cbrt((cos(Float64(lambda1 - lambda2)) ^ 3.0))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -2500000000000.0], N[Not[LessEqual[lambda1, 26500000.0]], $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[Power[N[Power[N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision], 1/3], $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 -2500000000000 \lor \neg \left(\lambda_1 \leq 26500000\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 \sqrt[3]{{\cos \left(\lambda_1 - \lambda_2\right)}^{3}}}\\
\end{array}
\end{array}
if lambda1 < -2.5e12 or 2.65e7 < lambda1 Initial program 61.6%
sin-diff79.7%
sub-neg79.7%
Applied egg-rr79.7%
sub-neg79.7%
Simplified79.7%
Taylor expanded in lambda2 around 0 79.8%
if -2.5e12 < lambda1 < 2.65e7Initial program 98.5%
add-cbrt-cube98.6%
pow398.6%
Applied egg-rr98.6%
Final simplification89.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_2 (* (cos phi2) (sin phi1))))
(if (or (<= lambda2 -1100000000.0) (not (<= lambda2 48.0)))
(atan2 t_1 (- t_0 (* (cos lambda2) t_2)))
(atan2 t_1 (- t_0 (* (cos lambda1) t_2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_2 = cos(phi2) * sin(phi1);
double tmp;
if ((lambda2 <= -1100000000.0) || !(lambda2 <= 48.0)) {
tmp = atan2(t_1, (t_0 - (cos(lambda2) * t_2)));
} else {
tmp = atan2(t_1, (t_0 - (cos(lambda1) * 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 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)
t_2 = cos(phi2) * sin(phi1)
if ((lambda2 <= (-1100000000.0d0)) .or. (.not. (lambda2 <= 48.0d0))) then
tmp = atan2(t_1, (t_0 - (cos(lambda2) * t_2)))
else
tmp = atan2(t_1, (t_0 - (cos(lambda1) * 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.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2);
double t_2 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if ((lambda2 <= -1100000000.0) || !(lambda2 <= 48.0)) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(lambda2) * t_2)));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(lambda1) * t_2)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2) t_2 = math.cos(phi2) * math.sin(phi1) tmp = 0 if (lambda2 <= -1100000000.0) or not (lambda2 <= 48.0): tmp = math.atan2(t_1, (t_0 - (math.cos(lambda2) * t_2))) else: tmp = math.atan2(t_1, (t_0 - (math.cos(lambda1) * t_2))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_2 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if ((lambda2 <= -1100000000.0) || !(lambda2 <= 48.0)) tmp = atan(t_1, Float64(t_0 - Float64(cos(lambda2) * t_2))); else tmp = atan(t_1, Float64(t_0 - Float64(cos(lambda1) * t_2))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2); t_2 = cos(phi2) * sin(phi1); tmp = 0.0; if ((lambda2 <= -1100000000.0) || ~((lambda2 <= 48.0))) tmp = atan2(t_1, (t_0 - (cos(lambda2) * t_2))); else tmp = atan2(t_1, (t_0 - (cos(lambda1) * 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[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -1100000000.0], N[Not[LessEqual[lambda2, 48.0]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \cos \phi_2 \cdot \sin \phi_1\\
\mathbf{if}\;\lambda_2 \leq -1100000000 \lor \neg \left(\lambda_2 \leq 48\right):\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \lambda_2 \cdot t_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_1}{t_0 - \cos \lambda_1 \cdot t_2}\\
\end{array}
\end{array}
if lambda2 < -1.1e9 or 48 < lambda2 Initial program 61.0%
sin-diff79.0%
sub-neg79.0%
Applied egg-rr79.0%
sub-neg79.0%
Simplified79.0%
Taylor expanded in lambda1 around 0 79.1%
cos-neg61.0%
Simplified79.1%
if -1.1e9 < lambda2 < 48Initial program 98.8%
sin-diff99.1%
sub-neg99.1%
Applied egg-rr99.1%
sub-neg99.1%
Simplified99.1%
Taylor expanded in lambda2 around 0 99.1%
Final simplification89.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 81.1%
sin-diff89.6%
sub-neg89.6%
Applied egg-rr89.6%
sub-neg89.6%
Simplified89.6%
Final simplification89.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2 (cos (- lambda1 lambda2)))
(t_3 (* t_1 t_2))
(t_4 (* (sin lambda1) (cos lambda2))))
(if (<= phi1 -0.0008)
(atan2 (* (cos phi2) (- t_4 (sin lambda2))) (- t_0 t_3))
(if (<= phi1 0.057)
(atan2
(* (- t_4 (* (cos lambda1) (sin lambda2))) (cos phi2))
(- (* (sin phi2) (+ (* -0.5 (* phi1 phi1)) 1.0)) t_3))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* t_1 (cbrt (pow t_2 3.0)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double t_2 = cos((lambda1 - lambda2));
double t_3 = t_1 * t_2;
double t_4 = sin(lambda1) * cos(lambda2);
double tmp;
if (phi1 <= -0.0008) {
tmp = atan2((cos(phi2) * (t_4 - sin(lambda2))), (t_0 - t_3));
} else if (phi1 <= 0.057) {
tmp = atan2(((t_4 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((sin(phi2) * ((-0.5 * (phi1 * phi1)) + 1.0)) - t_3));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (t_1 * cbrt(pow(t_2, 3.0)))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double t_2 = Math.cos((lambda1 - lambda2));
double t_3 = t_1 * t_2;
double t_4 = Math.sin(lambda1) * Math.cos(lambda2);
double tmp;
if (phi1 <= -0.0008) {
tmp = Math.atan2((Math.cos(phi2) * (t_4 - Math.sin(lambda2))), (t_0 - t_3));
} else if (phi1 <= 0.057) {
tmp = Math.atan2(((t_4 - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.sin(phi2) * ((-0.5 * (phi1 * phi1)) + 1.0)) - t_3));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (t_1 * Math.cbrt(Math.pow(t_2, 3.0)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = cos(Float64(lambda1 - lambda2)) t_3 = Float64(t_1 * t_2) t_4 = Float64(sin(lambda1) * cos(lambda2)) tmp = 0.0 if (phi1 <= -0.0008) tmp = atan(Float64(cos(phi2) * Float64(t_4 - sin(lambda2))), Float64(t_0 - t_3)); elseif (phi1 <= 0.057) tmp = atan(Float64(Float64(t_4 - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(sin(phi2) * Float64(Float64(-0.5 * Float64(phi1 * phi1)) + 1.0)) - t_3)); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(t_1 * cbrt((t_2 ^ 3.0))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.0008], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$4 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - t$95$3), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 0.057], N[ArcTan[N[(N[(t$95$4 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sin[phi2], $MachinePrecision] * N[(N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] - t$95$3), $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[Power[N[Power[t$95$2, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_3 := t_1 \cdot t_2\\
t_4 := \sin \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -0.0008:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(t_4 - \sin \lambda_2\right)}{t_0 - t_3}\\
\mathbf{elif}\;\phi_1 \leq 0.057:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t_4 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 \cdot \left(-0.5 \cdot \left(\phi_1 \cdot \phi_1\right) + 1\right) - t_3}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - t_1 \cdot \sqrt[3]{{t_2}^{3}}}\\
\end{array}
\end{array}
if phi1 < -8.00000000000000038e-4Initial program 72.3%
sin-diff76.9%
sub-neg76.9%
Applied egg-rr76.9%
sub-neg76.9%
Simplified76.9%
Taylor expanded in lambda1 around 0 74.5%
if -8.00000000000000038e-4 < phi1 < 0.0570000000000000021Initial program 84.5%
sin-diff99.1%
sub-neg99.1%
Applied egg-rr99.1%
sub-neg99.1%
Simplified99.1%
Taylor expanded in phi1 around 0 99.0%
associate-*r*99.0%
distribute-lft1-in99.1%
unpow299.1%
Simplified99.1%
if 0.0570000000000000021 < phi1 Initial program 84.4%
add-cbrt-cube84.4%
pow384.4%
Applied egg-rr84.4%
Final simplification88.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) t_0)))
(t_2 (* (sin lambda1) (cos lambda2))))
(if (<= phi2 -2.1e-6)
(atan2 (* (cos phi2) (expm1 (log1p (sin (- lambda1 lambda2))))) t_1)
(if (<= phi2 9e-12)
(atan2
(- t_2 (* (cos lambda1) (sin lambda2)))
(- (sin phi2) (* (sin phi1) (* (cos phi2) t_0))))
(atan2 (* (cos phi2) (- t_2 (sin lambda2))) t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = (cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * t_0);
double t_2 = sin(lambda1) * cos(lambda2);
double tmp;
if (phi2 <= -2.1e-6) {
tmp = atan2((cos(phi2) * expm1(log1p(sin((lambda1 - lambda2))))), t_1);
} else if (phi2 <= 9e-12) {
tmp = atan2((t_2 - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * (cos(phi2) * t_0))));
} else {
tmp = atan2((cos(phi2) * (t_2 - sin(lambda2))), t_1);
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = (Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * t_0);
double t_2 = Math.sin(lambda1) * Math.cos(lambda2);
double tmp;
if (phi2 <= -2.1e-6) {
tmp = Math.atan2((Math.cos(phi2) * Math.expm1(Math.log1p(Math.sin((lambda1 - lambda2))))), t_1);
} else if (phi2 <= 9e-12) {
tmp = Math.atan2((t_2 - (Math.cos(lambda1) * Math.sin(lambda2))), (Math.sin(phi2) - (Math.sin(phi1) * (Math.cos(phi2) * t_0))));
} else {
tmp = Math.atan2((Math.cos(phi2) * (t_2 - Math.sin(lambda2))), t_1);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = (math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * t_0) t_2 = math.sin(lambda1) * math.cos(lambda2) tmp = 0 if phi2 <= -2.1e-6: tmp = math.atan2((math.cos(phi2) * math.expm1(math.log1p(math.sin((lambda1 - lambda2))))), t_1) elif phi2 <= 9e-12: tmp = math.atan2((t_2 - (math.cos(lambda1) * math.sin(lambda2))), (math.sin(phi2) - (math.sin(phi1) * (math.cos(phi2) * t_0)))) else: tmp = math.atan2((math.cos(phi2) * (t_2 - math.sin(lambda2))), t_1) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * t_0)) t_2 = Float64(sin(lambda1) * cos(lambda2)) tmp = 0.0 if (phi2 <= -2.1e-6) tmp = atan(Float64(cos(phi2) * expm1(log1p(sin(Float64(lambda1 - lambda2))))), t_1); elseif (phi2 <= 9e-12) tmp = atan(Float64(t_2 - Float64(cos(lambda1) * sin(lambda2))), Float64(sin(phi2) - Float64(sin(phi1) * Float64(cos(phi2) * t_0)))); else tmp = atan(Float64(cos(phi2) * Float64(t_2 - sin(lambda2))), t_1); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -2.1e-6], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(Exp[N[Log[1 + N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision], If[LessEqual[phi2, 9e-12], N[ArcTan[N[(t$95$2 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$2 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_0\\
t_2 := \sin \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_2 \leq -2.1 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(\lambda_1 - \lambda_2\right)\right)\right)}{t_1}\\
\mathbf{elif}\;\phi_2 \leq 9 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2 - \cos \lambda_1 \cdot \sin \lambda_2}{\sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(t_2 - \sin \lambda_2\right)}{t_1}\\
\end{array}
\end{array}
if phi2 < -2.0999999999999998e-6Initial program 84.9%
expm1-log1p-u85.0%
Applied egg-rr85.0%
if -2.0999999999999998e-6 < phi2 < 8.99999999999999962e-12Initial program 78.4%
associate-*l*78.4%
Simplified78.4%
Taylor expanded in phi1 around 0 78.4%
Taylor expanded in phi2 around 0 78.4%
sin-diff87.6%
sub-neg87.6%
Applied egg-rr87.6%
sub-neg87.6%
Simplified87.6%
if 8.99999999999999962e-12 < phi2 Initial program 84.2%
sin-diff93.7%
sub-neg93.7%
Applied egg-rr93.7%
sub-neg93.7%
Simplified93.7%
Taylor expanded in lambda1 around 0 85.3%
Final simplification86.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2 (cos (- lambda1 lambda2)))
(t_3 (* t_1 t_2))
(t_4 (* (sin lambda1) (cos lambda2))))
(if (<= phi1 -1.85e-7)
(atan2 (* (cos phi2) (- t_4 (sin lambda2))) (- t_0 t_3))
(if (<= phi1 5.2e-6)
(atan2
(* (- t_4 (* (cos lambda1) (sin lambda2))) (cos phi2))
(- (sin phi2) t_3))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* t_1 (cbrt (pow t_2 3.0)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double t_2 = cos((lambda1 - lambda2));
double t_3 = t_1 * t_2;
double t_4 = sin(lambda1) * cos(lambda2);
double tmp;
if (phi1 <= -1.85e-7) {
tmp = atan2((cos(phi2) * (t_4 - sin(lambda2))), (t_0 - t_3));
} else if (phi1 <= 5.2e-6) {
tmp = atan2(((t_4 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - t_3));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (t_1 * cbrt(pow(t_2, 3.0)))));
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double t_2 = Math.cos((lambda1 - lambda2));
double t_3 = t_1 * t_2;
double t_4 = Math.sin(lambda1) * Math.cos(lambda2);
double tmp;
if (phi1 <= -1.85e-7) {
tmp = Math.atan2((Math.cos(phi2) * (t_4 - Math.sin(lambda2))), (t_0 - t_3));
} else if (phi1 <= 5.2e-6) {
tmp = Math.atan2(((t_4 - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - t_3));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (t_1 * Math.cbrt(Math.pow(t_2, 3.0)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = cos(Float64(lambda1 - lambda2)) t_3 = Float64(t_1 * t_2) t_4 = Float64(sin(lambda1) * cos(lambda2)) tmp = 0.0 if (phi1 <= -1.85e-7) tmp = atan(Float64(cos(phi2) * Float64(t_4 - sin(lambda2))), Float64(t_0 - t_3)); elseif (phi1 <= 5.2e-6) tmp = atan(Float64(Float64(t_4 - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - t_3)); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(t_1 * cbrt((t_2 ^ 3.0))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.85e-7], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$4 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - t$95$3), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 5.2e-6], N[ArcTan[N[(N[(t$95$4 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - t$95$3), $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[Power[N[Power[t$95$2, 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_3 := t_1 \cdot t_2\\
t_4 := \sin \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -1.85 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(t_4 - \sin \lambda_2\right)}{t_0 - t_3}\\
\mathbf{elif}\;\phi_1 \leq 5.2 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t_4 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - t_3}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - t_1 \cdot \sqrt[3]{{t_2}^{3}}}\\
\end{array}
\end{array}
if phi1 < -1.85000000000000002e-7Initial program 72.7%
sin-diff77.2%
sub-neg77.2%
Applied egg-rr77.2%
sub-neg77.2%
Simplified77.2%
Taylor expanded in lambda1 around 0 74.9%
if -1.85000000000000002e-7 < phi1 < 5.20000000000000019e-6Initial program 84.4%
sin-diff99.1%
sub-neg99.1%
Applied egg-rr99.1%
sub-neg99.1%
Simplified99.1%
Taylor expanded in phi1 around 0 99.1%
if 5.20000000000000019e-6 < phi1 Initial program 84.4%
add-cbrt-cube84.4%
pow384.4%
Applied egg-rr84.4%
Final simplification88.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) t_0)))
(t_2 (sin (- lambda1 lambda2))))
(if (<= phi2 -5.4e-6)
(atan2 (* (cos phi2) (expm1 (log1p t_2))) t_1)
(if (<= phi2 2e-12)
(atan2
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(- (sin phi2) (* (sin phi1) (* (cos phi2) t_0))))
(atan2 (* (cos phi2) (log1p (expm1 t_2))) t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = (cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * t_0);
double t_2 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -5.4e-6) {
tmp = atan2((cos(phi2) * expm1(log1p(t_2))), t_1);
} else if (phi2 <= 2e-12) {
tmp = atan2(((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * (cos(phi2) * t_0))));
} else {
tmp = atan2((cos(phi2) * log1p(expm1(t_2))), t_1);
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = (Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * t_0);
double t_2 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -5.4e-6) {
tmp = Math.atan2((Math.cos(phi2) * Math.expm1(Math.log1p(t_2))), t_1);
} else if (phi2 <= 2e-12) {
tmp = Math.atan2(((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))), (Math.sin(phi2) - (Math.sin(phi1) * (Math.cos(phi2) * t_0))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.log1p(Math.expm1(t_2))), t_1);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = (math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * t_0) t_2 = math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= -5.4e-6: tmp = math.atan2((math.cos(phi2) * math.expm1(math.log1p(t_2))), t_1) elif phi2 <= 2e-12: tmp = math.atan2(((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))), (math.sin(phi2) - (math.sin(phi1) * (math.cos(phi2) * t_0)))) else: tmp = math.atan2((math.cos(phi2) * math.log1p(math.expm1(t_2))), t_1) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * t_0)) t_2 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -5.4e-6) tmp = atan(Float64(cos(phi2) * expm1(log1p(t_2))), t_1); elseif (phi2 <= 2e-12) tmp = atan(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))), Float64(sin(phi2) - Float64(sin(phi1) * Float64(cos(phi2) * t_0)))); else tmp = atan(Float64(cos(phi2) * log1p(expm1(t_2))), t_1); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -5.4e-6], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(Exp[N[Log[1 + t$95$2], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision], If[LessEqual[phi2, 2e-12], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Log[1 + N[(Exp[t$95$2] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_0\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -5.4 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(t_2\right)\right)}{t_1}\\
\mathbf{elif}\;\phi_2 \leq 2 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2}{\sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(t_2\right)\right)}{t_1}\\
\end{array}
\end{array}
if phi2 < -5.39999999999999997e-6Initial program 84.9%
expm1-log1p-u85.0%
Applied egg-rr85.0%
if -5.39999999999999997e-6 < phi2 < 1.99999999999999996e-12Initial program 78.4%
associate-*l*78.4%
Simplified78.4%
Taylor expanded in phi1 around 0 78.4%
Taylor expanded in phi2 around 0 78.4%
sin-diff87.6%
sub-neg87.6%
Applied egg-rr87.6%
sub-neg87.6%
Simplified87.6%
if 1.99999999999999996e-12 < phi2 Initial program 84.2%
log1p-expm1-u84.3%
Applied egg-rr84.3%
Final simplification86.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) t_0)))
(t_2 (sin (- lambda1 lambda2))))
(if (<= phi2 -2.7e-6)
(atan2 (* (cos phi2) (expm1 (log1p t_2))) t_1)
(if (<= phi2 2.2e-12)
(atan2
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(- (sin phi2) (* (sin phi1) (* (cos phi2) t_0))))
(atan2 (* (cos phi2) t_2) t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = (cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * t_0);
double t_2 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -2.7e-6) {
tmp = atan2((cos(phi2) * expm1(log1p(t_2))), t_1);
} else if (phi2 <= 2.2e-12) {
tmp = atan2(((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * (cos(phi2) * t_0))));
} else {
tmp = atan2((cos(phi2) * t_2), t_1);
}
return tmp;
}
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = (Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * t_0);
double t_2 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -2.7e-6) {
tmp = Math.atan2((Math.cos(phi2) * Math.expm1(Math.log1p(t_2))), t_1);
} else if (phi2 <= 2.2e-12) {
tmp = Math.atan2(((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))), (Math.sin(phi2) - (Math.sin(phi1) * (Math.cos(phi2) * t_0))));
} else {
tmp = Math.atan2((Math.cos(phi2) * t_2), t_1);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = (math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * t_0) t_2 = math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= -2.7e-6: tmp = math.atan2((math.cos(phi2) * math.expm1(math.log1p(t_2))), t_1) elif phi2 <= 2.2e-12: tmp = math.atan2(((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))), (math.sin(phi2) - (math.sin(phi1) * (math.cos(phi2) * t_0)))) else: tmp = math.atan2((math.cos(phi2) * t_2), t_1) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * t_0)) t_2 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -2.7e-6) tmp = atan(Float64(cos(phi2) * expm1(log1p(t_2))), t_1); elseif (phi2 <= 2.2e-12) tmp = atan(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))), Float64(sin(phi2) - Float64(sin(phi1) * Float64(cos(phi2) * t_0)))); else tmp = atan(Float64(cos(phi2) * t_2), t_1); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -2.7e-6], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(Exp[N[Log[1 + t$95$2], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision], If[LessEqual[phi2, 2.2e-12], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] / t$95$1], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_0\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -2.7 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(t_2\right)\right)}{t_1}\\
\mathbf{elif}\;\phi_2 \leq 2.2 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2}{\sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t_2}{t_1}\\
\end{array}
\end{array}
if phi2 < -2.69999999999999998e-6Initial program 84.9%
expm1-log1p-u85.0%
Applied egg-rr85.0%
if -2.69999999999999998e-6 < phi2 < 2.19999999999999992e-12Initial program 78.4%
associate-*l*78.4%
Simplified78.4%
Taylor expanded in phi1 around 0 78.4%
Taylor expanded in phi2 around 0 78.4%
sin-diff87.6%
sub-neg87.6%
Applied egg-rr87.6%
sub-neg87.6%
Simplified87.6%
if 2.19999999999999992e-12 < phi2 Initial program 84.2%
Final simplification86.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (sin phi1) (* (cos phi2) t_1)))
(t_3 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi2 -5.8e-6)
(atan2 t_3 (- t_0 t_2))
(if (<= phi2 2.9e-12)
(atan2
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(- (sin phi2) t_2))
(atan2 t_3 (- t_0 (* (* (cos phi2) (sin phi1)) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin(phi1) * (cos(phi2) * t_1);
double t_3 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -5.8e-6) {
tmp = atan2(t_3, (t_0 - t_2));
} else if (phi2 <= 2.9e-12) {
tmp = atan2(((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - t_2));
} else {
tmp = atan2(t_3, (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) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
t_2 = sin(phi1) * (cos(phi2) * t_1)
t_3 = cos(phi2) * sin((lambda1 - lambda2))
if (phi2 <= (-5.8d-6)) then
tmp = atan2(t_3, (t_0 - t_2))
else if (phi2 <= 2.9d-12) then
tmp = atan2(((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - t_2))
else
tmp = atan2(t_3, (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.sin(phi1) * (Math.cos(phi2) * t_1);
double t_3 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -5.8e-6) {
tmp = Math.atan2(t_3, (t_0 - t_2));
} else if (phi2 <= 2.9e-12) {
tmp = Math.atan2(((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))), (Math.sin(phi2) - t_2));
} else {
tmp = Math.atan2(t_3, (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.sin(phi1) * (math.cos(phi2) * t_1) t_3 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= -5.8e-6: tmp = math.atan2(t_3, (t_0 - t_2)) elif phi2 <= 2.9e-12: tmp = math.atan2(((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))), (math.sin(phi2) - t_2)) else: tmp = math.atan2(t_3, (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(sin(phi1) * Float64(cos(phi2) * t_1)) t_3 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi2 <= -5.8e-6) tmp = atan(t_3, Float64(t_0 - t_2)); elseif (phi2 <= 2.9e-12) tmp = atan(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))), Float64(sin(phi2) - t_2)); else tmp = atan(t_3, Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); t_2 = sin(phi1) * (cos(phi2) * t_1); t_3 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= -5.8e-6) tmp = atan2(t_3, (t_0 - t_2)); elseif (phi2 <= 2.9e-12) tmp = atan2(((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - t_2)); else tmp = atan2(t_3, (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[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -5.8e-6], N[ArcTan[t$95$3 / N[(t$95$0 - t$95$2), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 2.9e-12], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$3 / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_1\right)\\
t_3 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -5.8 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{t_3}{t_0 - t_2}\\
\mathbf{elif}\;\phi_2 \leq 2.9 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2}{\sin \phi_2 - t_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_3}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_1}\\
\end{array}
\end{array}
if phi2 < -5.8000000000000004e-6Initial program 84.9%
associate-*l*84.9%
Simplified84.9%
if -5.8000000000000004e-6 < phi2 < 2.9000000000000002e-12Initial program 78.4%
associate-*l*78.4%
Simplified78.4%
Taylor expanded in phi1 around 0 78.4%
Taylor expanded in phi2 around 0 78.4%
sin-diff87.6%
sub-neg87.6%
Applied egg-rr87.6%
sub-neg87.6%
Simplified87.6%
if 2.9000000000000002e-12 < phi2 Initial program 84.2%
Final simplification86.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2 (* (cos phi1) (sin phi2)))
(t_3
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_2 (* (cos lambda2) t_1)))))
(if (<= lambda2 -20000000.0)
t_3
(if (<= lambda2 2.35e-131)
(atan2 (* (sin lambda1) (cos phi2)) (- t_2 (* t_1 t_0)))
(if (<= lambda2 2.3e+44)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- (sin phi2) (* (sin phi1) (* (cos phi2) t_0))))
t_3)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = cos(phi2) * sin(phi1);
double t_2 = cos(phi1) * sin(phi2);
double t_3 = atan2((cos(phi2) * sin(-lambda2)), (t_2 - (cos(lambda2) * t_1)));
double tmp;
if (lambda2 <= -20000000.0) {
tmp = t_3;
} else if (lambda2 <= 2.35e-131) {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_2 - (t_1 * t_0)));
} else if (lambda2 <= 2.3e+44) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * (cos(phi2) * t_0))));
} else {
tmp = t_3;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = cos(phi2) * sin(phi1)
t_2 = cos(phi1) * sin(phi2)
t_3 = atan2((cos(phi2) * sin(-lambda2)), (t_2 - (cos(lambda2) * t_1)))
if (lambda2 <= (-20000000.0d0)) then
tmp = t_3
else if (lambda2 <= 2.35d-131) then
tmp = atan2((sin(lambda1) * cos(phi2)), (t_2 - (t_1 * t_0)))
else if (lambda2 <= 2.3d+44) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * (cos(phi2) * t_0))))
else
tmp = t_3
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double t_2 = Math.cos(phi1) * Math.sin(phi2);
double t_3 = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_2 - (Math.cos(lambda2) * t_1)));
double tmp;
if (lambda2 <= -20000000.0) {
tmp = t_3;
} else if (lambda2 <= 2.35e-131) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_2 - (t_1 * t_0)));
} else if (lambda2 <= 2.3e+44) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.sin(phi1) * (Math.cos(phi2) * t_0))));
} else {
tmp = t_3;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.cos(phi2) * math.sin(phi1) t_2 = math.cos(phi1) * math.sin(phi2) t_3 = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_2 - (math.cos(lambda2) * t_1))) tmp = 0 if lambda2 <= -20000000.0: tmp = t_3 elif lambda2 <= 2.35e-131: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_2 - (t_1 * t_0))) elif lambda2 <= 2.3e+44: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.sin(phi1) * (math.cos(phi2) * t_0)))) else: tmp = t_3 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = Float64(cos(phi1) * sin(phi2)) t_3 = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_2 - Float64(cos(lambda2) * t_1))) tmp = 0.0 if (lambda2 <= -20000000.0) tmp = t_3; elseif (lambda2 <= 2.35e-131) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_2 - Float64(t_1 * t_0))); elseif (lambda2 <= 2.3e+44) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(sin(phi1) * Float64(cos(phi2) * t_0)))); else tmp = t_3; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = cos(phi2) * sin(phi1); t_2 = cos(phi1) * sin(phi2); t_3 = atan2((cos(phi2) * sin(-lambda2)), (t_2 - (cos(lambda2) * t_1))); tmp = 0.0; if (lambda2 <= -20000000.0) tmp = t_3; elseif (lambda2 <= 2.35e-131) tmp = atan2((sin(lambda1) * cos(phi2)), (t_2 - (t_1 * t_0))); elseif (lambda2 <= 2.3e+44) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * (cos(phi2) * t_0)))); else tmp = t_3; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -20000000.0], t$95$3, If[LessEqual[lambda2, 2.35e-131], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 - N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 2.3e+44], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$3]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
t_2 := \cos \phi_1 \cdot \sin \phi_2\\
t_3 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_2 - \cos \lambda_2 \cdot t_1}\\
\mathbf{if}\;\lambda_2 \leq -20000000:\\
\;\;\;\;t_3\\
\mathbf{elif}\;\lambda_2 \leq 2.35 \cdot 10^{-131}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_2 - t_1 \cdot t_0}\\
\mathbf{elif}\;\lambda_2 \leq 2.3 \cdot 10^{+44}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)}\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}
\end{array}
if lambda2 < -2e7 or 2.30000000000000004e44 < lambda2 Initial program 62.3%
Taylor expanded in lambda1 around 0 60.6%
Taylor expanded in lambda1 around 0 60.7%
*-commutative60.7%
associate-*r*60.7%
*-commutative60.7%
cos-neg60.7%
Simplified60.7%
if -2e7 < lambda2 < 2.3499999999999998e-131Initial program 99.5%
Taylor expanded in lambda2 around 0 89.0%
if 2.3499999999999998e-131 < lambda2 < 2.30000000000000004e44Initial program 86.4%
associate-*l*86.4%
Simplified86.4%
Taylor expanded in phi1 around 0 79.5%
Final simplification75.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (cos phi2) (sin phi1))))
(if (or (<= lambda2 -1200000000.0) (not (<= lambda2 2.06e-16)))
(atan2 (* (cos phi2) (sin (- lambda2))) (- t_0 (* (cos lambda2) t_1)))
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (cos lambda1) t_1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double tmp;
if ((lambda2 <= -1200000000.0) || !(lambda2 <= 2.06e-16)) {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(lambda2) * t_1)));
} else {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * t_1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
if ((lambda2 <= (-1200000000.0d0)) .or. (.not. (lambda2 <= 2.06d-16))) then
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(lambda2) * t_1)))
else
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * t_1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if ((lambda2 <= -1200000000.0) || !(lambda2 <= 2.06e-16)) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_0 - (Math.cos(lambda2) * t_1)));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.cos(lambda1) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) tmp = 0 if (lambda2 <= -1200000000.0) or not (lambda2 <= 2.06e-16): tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_0 - (math.cos(lambda2) * t_1))) else: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.cos(lambda1) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if ((lambda2 <= -1200000000.0) || !(lambda2 <= 2.06e-16)) tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_0 - Float64(cos(lambda2) * t_1))); else tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(cos(lambda1) * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin(phi1); tmp = 0.0; if ((lambda2 <= -1200000000.0) || ~((lambda2 <= 2.06e-16))) tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (cos(lambda2) * t_1))); else tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (cos(lambda1) * t_1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -1200000000.0], N[Not[LessEqual[lambda2, 2.06e-16]], $MachinePrecision]], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
\mathbf{if}\;\lambda_2 \leq -1200000000 \lor \neg \left(\lambda_2 \leq 2.06 \cdot 10^{-16}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t_0 - \cos \lambda_2 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \cos \lambda_1 \cdot t_1}\\
\end{array}
\end{array}
if lambda2 < -1.2e9 or 2.0599999999999999e-16 < lambda2 Initial program 61.8%
Taylor expanded in lambda1 around 0 59.8%
Taylor expanded in lambda1 around 0 59.9%
*-commutative59.9%
associate-*r*59.9%
*-commutative59.9%
cos-neg59.9%
Simplified59.9%
if -1.2e9 < lambda2 < 2.0599999999999999e-16Initial program 99.5%
Taylor expanded in lambda2 around 0 99.5%
Final simplification80.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= lambda1 -0.085)
(atan2 t_2 (- t_0 (* (cos lambda1) t_1)))
(if (<= lambda1 4.8e+18)
(atan2 t_2 (- t_0 (* (cos lambda2) t_1)))
(atan2
(* (sin lambda1) (cos phi2))
(- t_0 (* t_1 (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double t_2 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (lambda1 <= -0.085) {
tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1)));
} else if (lambda1 <= 4.8e+18) {
tmp = atan2(t_2, (t_0 - (cos(lambda2) * t_1)));
} else {
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
t_2 = cos(phi2) * sin((lambda1 - lambda2))
if (lambda1 <= (-0.085d0)) then
tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1)))
else if (lambda1 <= 4.8d+18) then
tmp = atan2(t_2, (t_0 - (cos(lambda2) * t_1)))
else
tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double t_2 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (lambda1 <= -0.085) {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(lambda1) * t_1)));
} else if (lambda1 <= 4.8e+18) {
tmp = Math.atan2(t_2, (t_0 - (Math.cos(lambda2) * t_1)));
} else {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) t_2 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if lambda1 <= -0.085: tmp = math.atan2(t_2, (t_0 - (math.cos(lambda1) * t_1))) elif lambda1 <= 4.8e+18: tmp = math.atan2(t_2, (t_0 - (math.cos(lambda2) * t_1))) else: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - (t_1 * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (lambda1 <= -0.085) tmp = atan(t_2, Float64(t_0 - Float64(cos(lambda1) * t_1))); elseif (lambda1 <= 4.8e+18) tmp = atan(t_2, Float64(t_0 - Float64(cos(lambda2) * t_1))); else tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin(phi1); t_2 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (lambda1 <= -0.085) tmp = atan2(t_2, (t_0 - (cos(lambda1) * t_1))); elseif (lambda1 <= 4.8e+18) tmp = atan2(t_2, (t_0 - (cos(lambda2) * t_1))); else tmp = atan2((sin(lambda1) * cos(phi2)), (t_0 - (t_1 * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -0.085], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 4.8e+18], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[Cos[lambda2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
t_2 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -0.085:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \lambda_1 \cdot t_1}\\
\mathbf{elif}\;\lambda_1 \leq 4.8 \cdot 10^{+18}:\\
\;\;\;\;\tan^{-1}_* \frac{t_2}{t_0 - \cos \lambda_2 \cdot t_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_0 - t_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda1 < -0.0850000000000000061Initial program 65.2%
Taylor expanded in lambda2 around 0 65.2%
if -0.0850000000000000061 < lambda1 < 4.8e18Initial program 98.5%
Taylor expanded in lambda1 around 0 98.5%
cos-neg98.5%
Simplified98.5%
if 4.8e18 < lambda1 Initial program 58.7%
Taylor expanded in lambda2 around 0 66.8%
Final simplification82.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= lambda1 7.6e+18)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) (* (cos phi2) t_1))))
(atan2
(* (sin lambda1) (cos phi2))
(- 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 tmp;
if (lambda1 <= 7.6e+18) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * t_1))));
} else {
tmp = atan2((sin(lambda1) * cos(phi2)), (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) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
if (lambda1 <= 7.6d+18) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * t_1))))
else
tmp = atan2((sin(lambda1) * cos(phi2)), (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 tmp;
if (lambda1 <= 7.6e+18) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * (Math.cos(phi2) * t_1))));
} else {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (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)) tmp = 0 if lambda1 <= 7.6e+18: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * (math.cos(phi2) * t_1)))) else: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (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)) tmp = 0.0 if (lambda1 <= 7.6e+18) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * Float64(cos(phi2) * t_1)))); else tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); tmp = 0.0; if (lambda1 <= 7.6e+18) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * (cos(phi2) * t_1)))); else tmp = atan2((sin(lambda1) * cos(phi2)), (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]}, If[LessEqual[lambda1, 7.6e+18], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq 7.6 \cdot 10^{+18}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot t_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot t_1}\\
\end{array}
\end{array}
if lambda1 < 7.6e18Initial program 87.2%
associate-*l*87.2%
Simplified87.2%
if 7.6e18 < lambda1 Initial program 58.7%
Taylor expanded in lambda2 around 0 66.8%
Final simplification82.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(-
(* (cos phi1) (sin phi2))
(* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2))))))
(if (<= lambda1 6.2e+18)
(atan2 (* (cos phi2) (sin (- lambda1 lambda2))) t_0)
(atan2 (* (sin lambda1) (cos phi2)) t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)));
double tmp;
if (lambda1 <= 6.2e+18) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), t_0);
} else {
tmp = atan2((sin(lambda1) * cos(phi2)), t_0);
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = (cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))
if (lambda1 <= 6.2d+18) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), t_0)
else
tmp = atan2((sin(lambda1) * cos(phi2)), t_0)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)));
double tmp;
if (lambda1 <= 6.2e+18) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), t_0);
} else {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), t_0);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = (math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))) tmp = 0 if lambda1 <= 6.2e+18: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), t_0) else: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), t_0) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2)))) tmp = 0.0 if (lambda1 <= 6.2e+18) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), t_0); else tmp = atan(Float64(sin(lambda1) * cos(phi2)), t_0); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = (cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))); tmp = 0.0; if (lambda1 <= 6.2e+18) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), t_0); else tmp = atan2((sin(lambda1) * cos(phi2)), t_0); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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]}, If[LessEqual[lambda1, 6.2e+18], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq 6.2 \cdot 10^{+18}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_0}\\
\end{array}
\end{array}
if lambda1 < 6.2e18Initial program 87.2%
if 6.2e18 < lambda1 Initial program 58.7%
Taylor expanded in lambda2 around 0 66.8%
Final simplification82.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda2 2.15e+44)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- (sin phi2) (* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
(atan2
(* (cos phi2) (sin (- lambda2)))
(-
(* (cos phi1) (sin phi2))
(* (cos lambda2) (* (cos phi2) (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 2.15e+44) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
} else {
tmp = atan2((cos(phi2) * sin(-lambda2)), ((cos(phi1) * sin(phi2)) - (cos(lambda2) * (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) :: tmp
if (lambda2 <= 2.15d+44) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))))
else
tmp = atan2((cos(phi2) * sin(-lambda2)), ((cos(phi1) * sin(phi2)) - (cos(lambda2) * (cos(phi2) * sin(phi1)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 2.15e+44) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(lambda2) * (Math.cos(phi2) * Math.sin(phi1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 2.15e+44: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2)))))) else: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(lambda2) * (math.cos(phi2) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 2.15e+44) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(lambda2) * Float64(cos(phi2) * sin(phi1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 2.15e+44) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2)))))); else tmp = atan2((cos(phi2) * sin(-lambda2)), ((cos(phi1) * sin(phi2)) - (cos(lambda2) * (cos(phi2) * sin(phi1))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 2.15e+44], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda2], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 2.15 \cdot 10^{+44}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \cos \lambda_2 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\end{array}
\end{array}
if lambda2 < 2.14999999999999991e44Initial program 85.2%
associate-*l*85.2%
Simplified85.2%
Taylor expanded in phi1 around 0 70.9%
if 2.14999999999999991e44 < lambda2 Initial program 63.2%
Taylor expanded in lambda1 around 0 64.8%
Taylor expanded in lambda1 around 0 65.0%
*-commutative65.0%
associate-*r*65.0%
*-commutative65.0%
cos-neg65.0%
Simplified65.0%
Final simplification69.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(-
(sin phi2)
(* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
(if (<= lambda1 7.6e+18)
(atan2 (* (cos phi2) (sin (- lambda1 lambda2))) t_0)
(atan2 (* (sin lambda1) (cos phi2)) t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))));
double tmp;
if (lambda1 <= 7.6e+18) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), t_0);
} else {
tmp = atan2((sin(lambda1) * cos(phi2)), t_0);
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin(phi2) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))
if (lambda1 <= 7.6d+18) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), t_0)
else
tmp = atan2((sin(lambda1) * cos(phi2)), t_0)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi2) - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))));
double tmp;
if (lambda1 <= 7.6e+18) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), t_0);
} else {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), t_0);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi2) - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2)))) tmp = 0 if lambda1 <= 7.6e+18: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), t_0) else: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), t_0) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (lambda1 <= 7.6e+18) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), t_0); else tmp = atan(Float64(sin(lambda1) * cos(phi2)), t_0); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi2) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2)))); tmp = 0.0; if (lambda1 <= 7.6e+18) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), t_0); else tmp = atan2((sin(lambda1) * cos(phi2)), t_0); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, 7.6e+18], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{if}\;\lambda_1 \leq 7.6 \cdot 10^{+18}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t_0}\\
\end{array}
\end{array}
if lambda1 < 7.6e18Initial program 87.2%
associate-*l*87.2%
Simplified87.2%
Taylor expanded in phi1 around 0 71.5%
if 7.6e18 < lambda1 Initial program 58.7%
associate-*l*58.7%
Simplified58.7%
Taylor expanded in phi1 around 0 48.3%
Taylor expanded in lambda2 around 0 56.6%
Final simplification68.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda1 5e+18)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1)))))
(atan2
(* (sin lambda1) (cos phi2))
(- (sin phi2) (* (sin phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= 5e+18) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (sin(phi1) * (cos(phi2) * 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) :: tmp
if (lambda1 <= 5d+18) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
else
tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= 5e+18) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (Math.sin(phi2) - (Math.sin(phi1) * (Math.cos(phi2) * Math.cos((lambda1 - lambda2))))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= 5e+18: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), (math.sin(phi2) - (math.sin(phi1) * (math.cos(phi2) * math.cos((lambda1 - lambda2)))))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= 5e+18) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= 5e+18) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); else tmp = atan2((sin(lambda1) * cos(phi2)), (sin(phi2) - (sin(phi1) * (cos(phi2) * cos((lambda1 - lambda2)))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, 5e+18], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq 5 \cdot 10^{+18}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\end{array}
\end{array}
if lambda1 < 5e18Initial program 87.2%
associate-*l*87.2%
Simplified87.2%
Taylor expanded in phi1 around 0 71.5%
Taylor expanded in phi2 around 0 70.6%
sub-neg55.4%
+-commutative55.4%
neg-mul-155.4%
neg-mul-155.4%
remove-double-neg55.4%
mul-1-neg55.4%
distribute-neg-in55.4%
+-commutative55.4%
cos-neg55.4%
+-commutative55.4%
mul-1-neg55.4%
unsub-neg55.4%
Simplified70.6%
if 5e18 < lambda1 Initial program 58.7%
associate-*l*58.7%
Simplified58.7%
Taylor expanded in phi1 around 0 48.3%
Taylor expanded in lambda2 around 0 56.6%
Final simplification67.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 81.1%
associate-*l*81.1%
Simplified81.1%
Taylor expanded in phi1 around 0 66.6%
Taylor expanded in phi2 around 0 65.7%
sub-neg51.8%
+-commutative51.8%
neg-mul-151.8%
neg-mul-151.8%
remove-double-neg51.8%
mul-1-neg51.8%
distribute-neg-in51.8%
+-commutative51.8%
cos-neg51.8%
+-commutative51.8%
mul-1-neg51.8%
unsub-neg51.8%
Simplified65.7%
Final simplification65.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2 33000000000000.0)
(atan2 t_0 (- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1)))))
(atan2 (* (cos phi2) (pow (sqrt t_0) 2.0)) (sin phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 33000000000000.0) {
tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = atan2((cos(phi2) * pow(sqrt(t_0), 2.0)), sin(phi2));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if (phi2 <= 33000000000000.0d0) then
tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
else
tmp = atan2((cos(phi2) * (sqrt(t_0) ** 2.0d0)), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 33000000000000.0) {
tmp = Math.atan2(t_0, (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.pow(Math.sqrt(t_0), 2.0)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= 33000000000000.0: tmp = math.atan2(t_0, (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2((math.cos(phi2) * math.pow(math.sqrt(t_0), 2.0)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 33000000000000.0) tmp = atan(t_0, Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = atan(Float64(cos(phi2) * (sqrt(t_0) ^ 2.0)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 33000000000000.0) tmp = atan2(t_0, (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); else tmp = atan2((cos(phi2) * (sqrt(t_0) ^ 2.0)), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 33000000000000.0], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sqrt[t$95$0], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 33000000000000:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot {\left(\sqrt{t_0}\right)}^{2}}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < 3.3e13Initial program 80.1%
associate-*l*80.1%
Simplified80.1%
Taylor expanded in phi1 around 0 70.6%
Taylor expanded in phi2 around 0 62.2%
Taylor expanded in phi2 around 0 62.3%
sub-neg62.3%
+-commutative62.3%
neg-mul-162.3%
neg-mul-162.3%
remove-double-neg62.3%
mul-1-neg62.3%
distribute-neg-in62.3%
+-commutative62.3%
cos-neg62.3%
+-commutative62.3%
mul-1-neg62.3%
unsub-neg62.3%
Simplified62.3%
if 3.3e13 < phi2 Initial program 84.3%
associate-*l*84.3%
Simplified84.3%
Taylor expanded in phi1 around 0 53.3%
add-sqr-sqrt29.9%
pow229.9%
Applied egg-rr29.9%
Taylor expanded in phi1 around 0 29.6%
Final simplification54.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 81.1%
associate-*l*81.1%
Simplified81.1%
Taylor expanded in phi1 around 0 66.6%
Taylor expanded in phi2 around 0 51.6%
Taylor expanded in phi2 around 0 51.8%
sub-neg51.8%
+-commutative51.8%
neg-mul-151.8%
neg-mul-151.8%
remove-double-neg51.8%
mul-1-neg51.8%
distribute-neg-in51.8%
+-commutative51.8%
cos-neg51.8%
+-commutative51.8%
mul-1-neg51.8%
unsub-neg51.8%
Simplified51.8%
Final simplification51.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2 6800000000000.0)
(atan2 t_0 (- phi2 (* (sin phi1) (cos (- lambda1 lambda2)))))
(atan2 t_0 (sin phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 6800000000000.0) {
tmp = atan2(t_0, (phi2 - (sin(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_0, sin(phi2));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if (phi2 <= 6800000000000.0d0) then
tmp = atan2(t_0, (phi2 - (sin(phi1) * cos((lambda1 - lambda2)))))
else
tmp = atan2(t_0, sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 6800000000000.0) {
tmp = Math.atan2(t_0, (phi2 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2(t_0, Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= 6800000000000.0: tmp = math.atan2(t_0, (phi2 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2(t_0, math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 6800000000000.0) tmp = atan(t_0, Float64(phi2 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_0, sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 6800000000000.0) tmp = atan2(t_0, (phi2 - (sin(phi1) * cos((lambda1 - lambda2))))); else tmp = atan2(t_0, sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 6800000000000.0], N[ArcTan[t$95$0 / N[(phi2 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 6800000000000:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t_0}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < 6.8e12Initial program 80.1%
associate-*l*80.1%
Simplified80.1%
Taylor expanded in phi1 around 0 70.6%
Taylor expanded in phi2 around 0 62.2%
Taylor expanded in phi2 around 0 62.2%
+-commutative62.2%
mul-1-neg62.2%
unsub-neg62.2%
*-commutative62.2%
Simplified62.2%
if 6.8e12 < phi2 Initial program 84.3%
associate-*l*84.3%
Simplified84.3%
Taylor expanded in phi1 around 0 53.3%
Taylor expanded in phi2 around 0 17.1%
Taylor expanded in phi1 around 0 16.9%
Final simplification51.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (* (sin phi1) (- (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), (sin(phi1) * -cos((lambda1 - lambda2))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin((lambda1 - lambda2)), (sin(phi1) * -cos((lambda1 - lambda2))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), (Math.sin(phi1) * -Math.cos((lambda1 - lambda2))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), (math.sin(phi1) * -math.cos((lambda1 - lambda2))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), Float64(sin(phi1) * Float64(-cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), (sin(phi1) * -cos((lambda1 - lambda2)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[phi1], $MachinePrecision] * (-N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_1 \cdot \left(-\cos \left(\lambda_1 - \lambda_2\right)\right)}
\end{array}
Initial program 81.1%
associate-*l*81.1%
Simplified81.1%
Taylor expanded in phi1 around 0 66.6%
Taylor expanded in phi2 around 0 51.6%
Taylor expanded in phi2 around 0 48.1%
mul-1-neg48.1%
distribute-rgt-neg-in48.1%
Simplified48.1%
Final simplification48.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (or (<= lambda1 -7.2e-22) (not (<= lambda1 1.35e+19))) (atan2 (sin lambda1) (sin phi2)) (atan2 (sin (- lambda2)) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -7.2e-22) || !(lambda1 <= 1.35e+19)) {
tmp = atan2(sin(lambda1), sin(phi2));
} else {
tmp = atan2(sin(-lambda2), sin(phi2));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((lambda1 <= (-7.2d-22)) .or. (.not. (lambda1 <= 1.35d+19))) then
tmp = atan2(sin(lambda1), sin(phi2))
else
tmp = atan2(sin(-lambda2), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 <= -7.2e-22) || !(lambda1 <= 1.35e+19)) {
tmp = Math.atan2(Math.sin(lambda1), Math.sin(phi2));
} else {
tmp = Math.atan2(Math.sin(-lambda2), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda1 <= -7.2e-22) or not (lambda1 <= 1.35e+19): tmp = math.atan2(math.sin(lambda1), math.sin(phi2)) else: tmp = math.atan2(math.sin(-lambda2), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda1 <= -7.2e-22) || !(lambda1 <= 1.35e+19)) tmp = atan(sin(lambda1), sin(phi2)); else tmp = atan(sin(Float64(-lambda2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda1 <= -7.2e-22) || ~((lambda1 <= 1.35e+19))) tmp = atan2(sin(lambda1), sin(phi2)); else tmp = atan2(sin(-lambda2), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda1, -7.2e-22], N[Not[LessEqual[lambda1, 1.35e+19]], $MachinePrecision]], N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[Sin[(-lambda2)], $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -7.2 \cdot 10^{-22} \lor \neg \left(\lambda_1 \leq 1.35 \cdot 10^{+19}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right)}{\sin \phi_2}\\
\end{array}
\end{array}
if lambda1 < -7.1999999999999996e-22 or 1.35e19 < lambda1 Initial program 64.0%
associate-*l*64.0%
Simplified64.0%
Taylor expanded in phi1 around 0 54.1%
Taylor expanded in phi2 around 0 46.9%
Taylor expanded in phi1 around 0 33.2%
Taylor expanded in lambda2 around 0 34.3%
if -7.1999999999999996e-22 < lambda1 < 1.35e19Initial program 98.5%
associate-*l*98.5%
Simplified98.5%
Taylor expanded in phi1 around 0 79.2%
Taylor expanded in phi2 around 0 56.4%
Taylor expanded in phi1 around 0 34.9%
Taylor expanded in lambda1 around 0 34.3%
Final simplification34.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 6e+18) (atan2 (sin (- lambda1 lambda2)) (sin phi2)) (atan2 (sin lambda1) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= 6e+18) {
tmp = atan2(sin((lambda1 - lambda2)), sin(phi2));
} else {
tmp = atan2(sin(lambda1), sin(phi2));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda1 <= 6d+18) then
tmp = atan2(sin((lambda1 - lambda2)), sin(phi2))
else
tmp = atan2(sin(lambda1), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= 6e+18) {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), Math.sin(phi2));
} else {
tmp = Math.atan2(Math.sin(lambda1), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= 6e+18: tmp = math.atan2(math.sin((lambda1 - lambda2)), math.sin(phi2)) else: tmp = math.atan2(math.sin(lambda1), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= 6e+18) tmp = atan(sin(Float64(lambda1 - lambda2)), sin(phi2)); else tmp = atan(sin(lambda1), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= 6e+18) tmp = atan2(sin((lambda1 - lambda2)), sin(phi2)); else tmp = atan2(sin(lambda1), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, 6e+18], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq 6 \cdot 10^{+18}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1}{\sin \phi_2}\\
\end{array}
\end{array}
if lambda1 < 6e18Initial program 87.2%
associate-*l*87.2%
Simplified87.2%
Taylor expanded in phi1 around 0 71.5%
Taylor expanded in phi2 around 0 55.3%
Taylor expanded in phi1 around 0 35.6%
if 6e18 < lambda1 Initial program 58.7%
associate-*l*58.7%
Simplified58.7%
Taylor expanded in phi1 around 0 48.3%
Taylor expanded in phi2 around 0 38.3%
Taylor expanded in phi1 around 0 28.4%
Taylor expanded in lambda2 around 0 37.2%
Final simplification36.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin lambda1) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin(lambda1), sin(phi2));
}
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), sin(phi2))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin(lambda1), Math.sin(phi2));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin(lambda1), math.sin(phi2))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(lambda1), sin(phi2)) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin(lambda1), sin(phi2)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1}{\sin \phi_2}
\end{array}
Initial program 81.1%
associate-*l*81.1%
Simplified81.1%
Taylor expanded in phi1 around 0 66.6%
Taylor expanded in phi2 around 0 51.6%
Taylor expanded in phi1 around 0 34.1%
Taylor expanded in lambda2 around 0 24.7%
Final simplification24.7%
herbie shell --seed 2023252
(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))))))