Skip to content

Commit 1299c76

Browse files
authored
Add explanation on Gram basis for Chebyshev basis (#266)
1 parent d5f7a57 commit 1299c76

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

docs/src/tutorials/Getting started/univariate.jl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# # Mminimization of a univariate polynomial
1+
# # Minimization of a univariate polynomial
22

33
#md # [![](https://mybinder.org/badge_logo.svg)](@__BINDER_ROOT_URL__/generated/Getting started/univariate.ipynb)
44
#md # [![](https://img.shields.io/badge/show-nbviewer-579ACA.svg)](@__NBVIEWER_ROOT_URL__/generated/Getting started/univariate.ipynb)
@@ -99,3 +99,18 @@ cheby_g.Q
9999

100100
cheby_sos_dec = sos_decomposition(cheby_cref, 1e-4)
101101
@test isapprox(cheby_sos_dec.ps, [expected], rtol=1e-4) || isapprox(cheby_sos_dec.ps, [-expected], rtol=1e-4) #src
102+
103+
# The gram matrix in the Chebyshev basis can be understood as follows.
104+
# To express the polynomial $-x^2 + 2x + 3$ in the Chebyshev basis, we start by
105+
# substituting $x$ into $\cos(\theta)$ to obtain
106+
# $-\cos(\theta)^2 + 2\cos(\theta) + 3$.
107+
# We now express it as a combination of $\cos(n\theta)$ for $n = 0, 1, 2$:
108+
# $-(2\cos(\theta) - 1) /2 + 2 \cos(\theta) + 5/2.$
109+
# Therefore, the coefficients in the Chebyshev basis is:
110+
111+
cheby_coefs = [-1/2, 2, 5/2]
112+
113+
# We can indeed observe that we obtain the same matrix as `cheby_g.Q`
114+
115+
@test cheby_g.Q cheby_coefs * cheby_coefs' rtol=1e-6 #src
116+
cheby_coefs * cheby_coefs'

0 commit comments

Comments
 (0)