得到R中的正交Gegenbauer多项式基

gijlo24d  于 9个月前  发布在  其他
关注(0)|答案(1)|浏览(91)

我一直在尝试几个软件包来计算正交格根鲍尔多项式的基础,它似乎是正交的[-1,1]。使用软件包midasml,但我得到了不同的结果:

library(midasml)

x <- seq(-1, 1, length.out = 100)
matplot(B <- gb(degree = 3, alpha = 1, a = -1, b = 1, jmax = NULL, X = x), type="l")

round(t(B) %*% B, 3) #not orthonormal

字符串
有什么原因吗?有什么建议吗?谢谢!

du7egjpx

du7egjpx1#

正交性并不意味着这个矩阵是正交的。它意味着如果i != j,则P_i(x)P_j(x)w(x)从-1到1的积分为0,如果i = j,则为1,其中w是权重函数。参数为alpha的Gegenbauer多项式的权重函数为(1 - x^2)^(alpha - 1/2)
你可以用orthopolynom包得到这些多项式。

library(orthopolynom)
alpha <- 1
gp.list <- gegenbauer.polynomials(3, alpha, normalized = FALSE)
print(gp.list)
# [[1]]
# 1 
# 
# [[2]]
# 2*x 
# 
# [[3]]
# -1 + 4*x^2 
# 
# [[4]]
# -4*x + 8*x^3 

w <- function(x) { # the weight function
  (1 - x^2)^(alpha - 1/2)
}
GP2 <- function(x) {
  -1 + 4*x^2
}
GP3 <- function(x) {
  -4*x + 8*x^3
}

f <- function(x) {
  GP2(x) * GP3(x) * w(x)
}
integrate(f, lower = -1, upper = 1) # should be zero
# 0 with absolute error < 1.4e-14

f <- function(x) {
  GP3(x) * GP3(x) * w(x)
}
integrate(f, lower = -1, upper = 1) # should be pi/2
# 1.570796 with absolute error < 6e-07

字符串
这里P_i(x)²w(x)的积分不是1,因为我取了normalized = FALSE

相关问题