diff --git a/tests/test_utils.py b/tests/test_utils.py index d5faed3..f839793 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -7,8 +7,8 @@ def test_quadroots_1(): b = -5.0 c = 2.0 roots = qr.quadroots(a, b, c) - x1_exact = 2.0 - x2_exact = 0.5 + x1_exact = 8.0 + x2_exact = 2.0 assert (np.abs(roots[0] - x1_exact) < 1e-14) and (np.abs(roots[1] - x2_exact)) < 1e-14 def test_chebD_1(): diff --git a/utils/chebutils.py b/utils/chebutils.py index 0d7e38a..80efe9e 100644 --- a/utils/chebutils.py +++ b/utils/chebutils.py @@ -2,8 +2,19 @@ def chebD(n): """ - Hint: https://people.maths.ox.ac.uk/trefethen/book.pdf, Chapter 6, pages - 51-55. + Computes the Chebyshev differentiation matrix and grid points in [-1, 1]. + + Parameters + ---------- + n: int + Specify n + 1 dimension of the chebyshev differentiation matrix. + + Returns + ------- + D: n+1 x n+1 ndarray + Chebyshev differentiation matrix. + x: n+1 ndarray + Chebyshev grid points in [-1, 1]. """ if n == 0: x = 1; D = 0; w = 0 diff --git a/utils/quadroots.py b/utils/quadroots.py index 460f2b1..8b1e0ee 100644 --- a/utils/quadroots.py +++ b/utils/quadroots.py @@ -24,4 +24,4 @@ def quadroots(a, b, c): x1 = (-b + np.sqrt(b**2 - 4*a*c))/2*a x2 = (-b - np.sqrt(b**2 - 4*a*c))/2*a - return (x1, x2) + return (x1, x2) \ No newline at end of file