# Mastering the Art of Quickly Grasping New Concepts
Written on
Chapter 1: Introduction to Learning New Algorithms
As I embarked on my Ph.D. journey, I encountered numerous algorithms rooted in mathematical principles. A solid understanding of these principles is essential for successfully implementing these algorithms. One particular algorithm that I recently had to master is the Gauß-Lobatto Quadrature. In this post, I aim to share my approach to quickly understanding this concept.
Image by mohammed_hassan on pixabay.
Although it may seem complex, the Gauß-Lobatto method is surprisingly straightforward. This numerical approach allows us to calculate the integral of a function, essentially enabling us to determine the area beneath a curve without the need for calculus. The underlying concepts of the Gauß-Lobatto method derive solely from linear algebra.
Section 1.1: Understanding the Implementation
To implement this algorithm, we strategically place coordinates across the entire area of the graph and compute the corresponding values of our base function—rather than its integral. These values are then multiplied by specific weights. To comprehend what these weights signify, we need to visualize the method.
Gauss-Lobatto-Quadraturen for a Gaussian distribution. Image by author.
The strategically placed coordinates correspond to the midpoints of the red rectangles shown above. Notably, the rectangles vary in width, which is where the weights come into play. Different weights reflect the varying widths of these rectangles. Why are the coordinates carefully chosen, and why do the widths differ?
As the widths of the rectangles increase (for instance, if we use fewer rectangles under our graph), the accuracy of our solution diminishes. Wider rectangles may suffice for flatter sections of our graph, but they can introduce significant errors in steeper regions. Consequently, we position rectangles of varying widths to account for the changing trends in our graph, using narrower rectangles where the function is steep and wider ones where it is flatter.
Section 1.2: My Learning Process
So, how did I navigate this learning curve when I initially had no understanding of the subject? As any programmer would advise—Google is invaluable. For me, YouTube was a key resource. I searched for relevant videos and found an instructor who conveyed the concepts in an easily digestible manner. Thanks to this, I quickly grasped the fundamental ideas and implemented a simplified version in MATLAB.
This led me to develop a script that addressed the specific problem depicted in the image above. As anticipated, the analytical solution and the Gauß-Lobatto solution were nearly identical. Why "nearly"? Because the Gauß-Lobatto method is an approximation rather than an exact solution.
Although my problem was more intricate than a Gaussian distribution, I had established a solid foundation. My next task was to adapt the straightforward equation to fit my more complex scenario and generate the appropriate Gauß-Lobatto coordinates and weights. The final step proved to be more challenging than I had anticipated, but I ultimately succeeded.
Section 1.3: Cementing the Knowledge
To truly internalize this new method, it's essential to teach it to someone else. This blog post serves that purpose for me. More importantly, I noticed a lack of accessible resources explaining the Gauß-Lobatto method in simple terms, and I hope this post can help fill that void. Additionally, I will share my implementation of the Gauß-Lobatto method in case you need to use it in your projects.
Struggling to Learn a New Concept? DO THIS... - This video offers insights on effective strategies for grasping new ideas quickly.
Conclusion
To summarize my approach to learning new concepts:
- Utilize resources like Google, Wikipedia, YouTube, books, and research papers to build a foundational understanding.
- Implement a basic and straightforward example to solidify your grasp of the new concept.
- Adapt your implementation to tackle your specific situation or problem.
- Teach someone else what you've learned to fully internalize the concept.
Appendix: Simple Example for Applying Gauss-Lobatto
% Function to be integrated
ffd = @(k) exp(-((k-40/2-0.5)/2.5)^2);
%% Analytical solution for the borders [-1, 1]:
f_borders = 1;
f = integral(ffd, -f_borders, f_borders);
%% Numerical solution for the borders [-1, 1]:
Nqx = 20; % Order of Gauss-Lobatto quadrature
[x, w] = JacobiGL(0, 0, Nqx-1); % Calculating GL-coordinates and weights
f_gl = zeros(Nqx, 1);
for i = 1 : Nqx
f_gl(i) = ffd(x(i)); % Calculating f-values with GL-coordinates
end
f_gl = f_gl .* w; % Multiplying f-values with weights
f_gl = sum(f_gl); % Calculating the sum of the solution vector
It's important to note that the ‘analytical’ solution provided is not genuinely analytical; rather, it is MATLAB's method for solving function integrals. Thus, the analytical solution is just another form of approximation. Nevertheless, you'll find that f equals f_gl, indicating that our Gauß-Lobatto implementation is accurate.
To run the above code, you will need the following two functions:
function [x, w] = JacobiGL(alpha, beta, N)
% Purpose: Compute the N'th order Gauss Lobatto quadrature points, x, associated with the Jacobi polynomial,
% type (alpha, beta) > -1 ( <> -0.5). Additionally compute corresponding quadrature points w.
% [Insert function code here]
end
function [x, w] = JacobiGQ(alpha, beta, N)
% Purpose: Compute the N'th order Gauss quadrature points, x, and weights, w, associated with the Jacobi polynomial,
% type (alpha, beta) > -1 ( <> -0.5).
% [Insert function code here]
end
Both functions are taken from the book "Nodal Discontinuous Galerkin Methods—Algorithms, Analysis, and Applications" by Jan S. Hesthaven and Tim Warburton. They function seamlessly, so you can use them without additional modifications.
Write For Beyond Productivity
Thank you for taking the time to read this post. If you enjoyed the content, I would greatly appreciate your support. Don't forget to follow me on Medium and Twitter for more insightful blog posts. If you have any feedback, questions, or collaboration ideas, feel free to reach out via Twitter or email at v.ganiu@gmail.com. Alternatively, you can leave a comment below!
If you would like to support my work further, consider buying me a coffee. Your kindness is greatly appreciated!
How I Learn New Content Quickly - This video shares effective techniques for rapidly absorbing new information.