Is there any built-in function in R for computing the legendre function rather than pracma::legendre? The pracma::legendre function is indeed commonly used for computing Legendre polynomials, but it may encounter numerical issues for high degree and order. Using this function for high degree and order, we get NaN, -Inf, +Inf, or a big number of power e+280.
I have the degree l and order m as follows:
l = c(0, 1, 1, 2, 2, 2, 3, 3, 3, 3)
m = c(0, 0, 1, 0, 1, 2, 0, 1, 2, 3)
theta = pi/180 * c(rep(58.5, 5), rep(58.25, 5))
lambda = pi/180 * rep(c(33, 33.25, 33.5, 33.75, 34), 2)
bar_c <- c(1.00e+00, 0.00e+00, 0.00e+00, -4.84e-04, -3.38e-10, 2.44e-06, 9.57e-07, 2.03e-06, 9.05e-07, 7.21e-07)
bar_s <-c(0.00e+00, 0.00e+00, 0.00e+00, 0.00e+00, 1.45e-09, -1.40e-06, 0.00e+00, 2.48e-07, -6.19e-07, 1.41e-06)
N_max = 10
R =6371000
