diff --git a/differentiation/derivative_backward_difference.m b/differentiation/derivative_backward_difference.m index 4d47890..1502e30 100644 --- a/differentiation/derivative_backward_difference.m +++ b/differentiation/derivative_backward_difference.m @@ -4,11 +4,11 @@ % All values in 'x' must be equally spaced. % % Args: - % x: array containing x values. - % y: array containing y values. + % x: an array containing x values. + % y: an array containing y values. % % Returns: - % dy: array containing the first derivative values. + % dy: an array containing the first derivative values. x_size = size(x, 2); y_size = size(y, 2); diff --git a/differentiation/derivative_five_point.m b/differentiation/derivative_five_point.m index 2791864..a49f98c 100644 --- a/differentiation/derivative_five_point.m +++ b/differentiation/derivative_five_point.m @@ -4,11 +4,11 @@ % All values in 'x' must be equally spaced. % % Args: - % x: array containing x values. - % y: array containing y values. + % x: an array containing x values. + % y: an array containing y values. % % Returns: - % dy: array containing the first derivative values. + % dy: an array containing the first derivative values. x_size = size(x, 2); y_size = size(y, 2); diff --git a/differentiation/derivative_three_point.m b/differentiation/derivative_three_point.m index 976691f..ef2de48 100644 --- a/differentiation/derivative_three_point.m +++ b/differentiation/derivative_three_point.m @@ -4,11 +4,11 @@ % All values in 'x' must be equally spaced. % % Args: - % x: array containing x values. - % y: array containing y values. + % x: an array containing x values. + % y: an array containing y values. % % Returns: - % dy: array containing the first derivative values. + % dy: an array containing the first derivative values. x_size = size(x, 2); y_size = size(y, 2); diff --git a/integration/composite2_simpson.m b/integration/composite2_simpson.m index 4d506b7..a265839 100644 --- a/integration/composite2_simpson.m +++ b/integration/composite2_simpson.m @@ -2,8 +2,8 @@ % Calculate the integral from 1/3 Simpson's Rule. % % Args: - % x: array containing x values. - % y: array containing y values. + % x: an array containing x values. + % y: an array containing y values. % % Returns: % xi: integral value. diff --git a/integration/composite2_trapezoidal.m b/integration/composite2_trapezoidal.m index 9d50b48..9a981d7 100644 --- a/integration/composite2_trapezoidal.m +++ b/integration/composite2_trapezoidal.m @@ -1,9 +1,9 @@ function [xi] = composite2_trapezoidal(x, y) - % Calculate the integral from Trapezoidal Rule. + % Calculate the integral from the Trapezoidal Rule. % % Args: - % x: array containing x values. - % y: array containing y values. + % x: an array containing x values. + % y: an array containing y values. % % Returns: % xi: integral value. diff --git a/integration/composite_simpson.m b/integration/composite_simpson.m index 5b93f99..244d722 100644 --- a/integration/composite_simpson.m +++ b/integration/composite_simpson.m @@ -3,8 +3,8 @@ % % Args: % f: function f(x). - % a: initial point. - % b: end point. + % a: the initial point. + % b: the final point. % n: number of intervals. % % Returns: diff --git a/integration/composite_trapezoidal.m b/integration/composite_trapezoidal.m index b3446d8..287e772 100644 --- a/integration/composite_trapezoidal.m +++ b/integration/composite_trapezoidal.m @@ -1,10 +1,10 @@ function [xi] = composite_trapezoidal(f, b, a, n) - % Calculate the integral from Trapezoidal Rule. + % Calculate the integral from the Trapezoidal Rule. % % Args: % f: function f(x). - % a: initial point. - % b: end point. + % a: the initial point. + % b: the final point. % n: number of intervals. % % Returns: diff --git a/interpolation/lagrange.m b/interpolation/lagrange.m index 69ae71f..814123c 100644 --- a/interpolation/lagrange.m +++ b/interpolation/lagrange.m @@ -1,9 +1,9 @@ function [y_int] = lagrange(x, y, x_int) - % Interpolates a value using Lagrange polynomial. + % Interpolates a value using the 'Lagrange polynomial'. % % Args: - % x: array containing x values. - % y: array containing y values. + % x: an array containing x values. + % y: an array containing y values. % x_int: value to interpolate. % % Returns: diff --git a/interpolation/neville.m b/interpolation/neville.m index ee1bee2..bccd012 100644 --- a/interpolation/neville.m +++ b/interpolation/neville.m @@ -1,9 +1,9 @@ function [y_int, q] = neville(x, y, x_int) - % Interpolates a value using Neville polynomial. + % Interpolates a value using the 'Neville polynomial'. % % Args: - % x: array containing x values. - % y: array containing y values. + % x: an array containing x values. + % y: an array containing y values. % x_int: value to interpolate. % % Returns: diff --git a/linear_systems/backward_substitution.m b/linear_systems/backward_substitution.m index c1597b1..c8fcd04 100644 --- a/linear_systems/backward_substitution.m +++ b/linear_systems/backward_substitution.m @@ -3,10 +3,10 @@ % % Args: % upper: upper triangular matrix. - % d: array containing d values. + % d: an array containing d values. % % Returns: - % x: solution of linear system. + % x: solution of linear the system. [n, m] = size(u); diff --git a/linear_systems/forward_substitution.m b/linear_systems/forward_substitution.m index 6105651..e51c300 100644 --- a/linear_systems/forward_substitution.m +++ b/linear_systems/forward_substitution.m @@ -3,10 +3,10 @@ % % Args: % lower: lower triangular matrix. - % c: array containing c values. + % c: an array containing c values. % % Returns: - % x: solution of linear system. + % x: solution of linear the system. [n, m] = size(l); diff --git a/linear_systems/gauss_elimination_pp.m b/linear_systems/gauss_elimination_pp.m index 48decef..61b671d 100644 --- a/linear_systems/gauss_elimination_pp.m +++ b/linear_systems/gauss_elimination_pp.m @@ -1,12 +1,12 @@ function [a] = gauss_elimination_pp(a, b) % Gaussian Elimination with Partial Pivoting. % - % Calculate the upper triangular matrix from linear system Ax=b (do a row + % Calculate the upper triangular matrix from linear system Ax=b (make a row % reduction). % % Args: % a: matrix A from system Ax=b. - % b: array containing b values. + % b: an array containing b values. % % Returns: % a: augmented upper triangular matrix. @@ -33,7 +33,7 @@ end - % Cheking for nullity of the pivots + % Checking for nullity of the pivots while p <= n && a(p, i) == 0 p = p + 1; end diff --git a/linear_systems_iterative/gauss_seidel.m b/linear_systems_iterative/gauss_seidel.m index 38ad44a..04caaa7 100644 --- a/linear_systems_iterative/gauss_seidel.m +++ b/linear_systems_iterative/gauss_seidel.m @@ -3,13 +3,13 @@ % % Args: % a: matrix A from system Ax=b. - % b: array containing b values. - % x0: initial approximation of solution. + % b: an array containing b values. + % x0: initial approximation of the solution. % tol: tolerance. % iter_max: maximum number of iterations. % % Returns: - % x: solution of linear system. + % x: solution of linear the system. % iter: used iterations. % L and U matrices diff --git a/linear_systems_iterative/jacobi.m b/linear_systems_iterative/jacobi.m index 0bc0388..5dfa9b7 100644 --- a/linear_systems_iterative/jacobi.m +++ b/linear_systems_iterative/jacobi.m @@ -3,13 +3,13 @@ % % Args: % a: matrix A from system Ax=b. - % b: array containing b values. - % x0: initial approximation of solution. + % b: an array containing b values. + % x0: initial approximation of the solution. % tol: tolerance. % iter_max: maximum number of iterations. % % Returns: - % x: solution of linear system. + % x: solution of linear the system. % iter: used iterations. % D and M matrices diff --git a/main.m b/main.m index 2b8f44e..b8e1451 100644 --- a/main.m +++ b/main.m @@ -19,7 +19,7 @@ % Bisection method (find roots of an equation) % Pros: % It is a reliable method with guaranteed convergence; -% It is a simple method that searches for the root employing a +% It is a simple method that searches for the root by employing a % binary search; % There is no need to calculate the derivative of the function. % Cons: @@ -58,7 +58,7 @@ % Cons: % It may diverge if the function is not approximately linear in the % range containing the root; -% It is necessary to give two points 'a' and 'b' where +% It is necessary to give two points, 'a' and 'b' where % f(a)-f(b) must be nonzero. disp('> Run an example "Solutions: Secant method".') f = @(x) (4 * x^3 + x + cos(x) - 10); diff --git a/ode/euler.m b/ode/euler.m index 8b25ceb..4d3d8ed 100644 --- a/ode/euler.m +++ b/ode/euler.m @@ -1,18 +1,18 @@ function [vx, vy] = euler(f, a, b, n, ya) % Calculate the solution of the initial-value problem (IVP). % - % Solve the IVP from Euler method. + % Solve the IVP from the Euler method. % % Args: % f: function f(x). - % a: initial point. - % b: end point. + % a: the initial point. + % b: the final point. % n: number of intervals. % ya: initial value. % % Returns: - % vx: array containing x values. - % vy: array containing y values (solution of IVP). + % vx: an array containing x values. + % vy: an array containing y values (solution of IVP). vx = zeros(1, n + 1); vy = zeros(1, n + 1); diff --git a/ode/rk4.m b/ode/rk4.m index 47417ca..ccca3be 100644 --- a/ode/rk4.m +++ b/ode/rk4.m @@ -1,18 +1,18 @@ function [vx, vy] = rk4(f, a, b, n, ya) % Calculate the solution of the initial-value problem (IVP). % - % Solve the IVP from Runge-Kutta (Order Four) method. + % Solve the IVP from the Runge-Kutta (Order Four) method. % % Args: % f: function f(x). - % a: initial point. - % b: end point. + % a: the initial point. + % b: the final point. % n: number of intervals. % ya: initial value. % % Returns: - % vx: array containing x values. - % vy: array containing y values (solution of IVP). + % vx: an array containing x values. + % vy: an array containing y values (solution of IVP). vx = zeros(1, n + 1); vy = zeros(1, n + 1); diff --git a/ode/rk4_system.m b/ode/rk4_system.m index ea29598..9ed2c9a 100644 --- a/ode/rk4_system.m +++ b/ode/rk4_system.m @@ -4,15 +4,15 @@ % Solve from Runge-Kutta (Order Four) method. % % Args: - % f: array of functions f(x). - % a: initial point. - % b: end point. + % f: an array of functions f(x). + % a: the initial point. + % b: the final point. % n: number of intervals. - % ya: array of initial values. + % ya: an array of initial values. % % Returns: - % vx: array containing x values. - % vy: array containing y values (solution of IVP). + % vx: an array containing x values. + % vy: an array containing y values (solution of IVP). m = size(f, 1); diff --git a/ode/taylor2.m b/ode/taylor2.m index b529665..d5eea8a 100644 --- a/ode/taylor2.m +++ b/ode/taylor2.m @@ -1,19 +1,19 @@ function [vx, vy] = taylor2(f, df1, a, b, n, ya) % Calculate the solution of the initial-value problem (IVP). % - % Solve the IVP from Taylor (Order Two) method. + % Solve the IVP from the Taylor (Order Two) method. % % Args: % f: function f(x). % df1: 1's derivative of function f(x). - % a: initial point. - % b: end point. + % a: the initial point. + % b: the final point. % n: number of intervals. % ya: initial value. % % Returns: - % vx: array containing x values. - % vy: array containing y values (solution of IVP). + % vx: an array containing x values. + % vy: an array containing y values (solution of IVP). vx = zeros(1, n + 1); vy = zeros(1, n + 1); diff --git a/ode/taylor4.m b/ode/taylor4.m index 8ea87e8..6de59a1 100644 --- a/ode/taylor4.m +++ b/ode/taylor4.m @@ -1,21 +1,21 @@ function [vx, vy] = taylor4(f, df1, df2, df3, a, b, n, ya) % Calculate the solution of the initial-value problem (IVP). % - % Solve the IVP from Taylor (Order Four) method. + % Solve the IVP from the Taylor (Order Four) method. % % Args: % f: function f(x). % df1: 1's derivative of function f(x). % df2: 2's derivative of function f(x). % df3: 3's derivative of function f(x). - % a: initial point. - % b: end point. + % a: the initial point. + % b: the final point. % n: number of intervals. % ya: initial value. % % Returns: - % vx: array containing x values. - % vy: array containing y values (solution of IVP). + % vx: an array containing x values. + % vy: an array containing y values (solution of IVP). vx = zeros(1, n + 1); vy = zeros(1, n + 1); diff --git a/polynomials/briot_ruffini.m b/polynomials/briot_ruffini.m index 19fc39a..7cb5671 100644 --- a/polynomials/briot_ruffini.m +++ b/polynomials/briot_ruffini.m @@ -1,14 +1,14 @@ function [b, rest] = briot_ruffini(root, a) - % Divides a polynomial by another polynomial. + % Divide a polynomial by another polynomial. % % The format is: P(x) = Q(x) * (x-root) + rest. % % Args: - % a: array containing the coefficients of the input polynomial. + % a: an array containing the coefficients of the input polynomial. % root: one of the polynomial roots. % % Returns: - % b: array containing the coefficients of the output polynomial. + % b: an array containing the coefficients of the output polynomial. % rest: polynomial division Rest. n = size(a, 2) - 1; diff --git a/polynomials/newton_divided_difference.m b/polynomials/newton_divided_difference.m index d0a30d3..bcd63f0 100644 --- a/polynomials/newton_divided_difference.m +++ b/polynomials/newton_divided_difference.m @@ -1,14 +1,14 @@ function [f] = newton_divided_difference(x, y) % Find the coefficients of Newton's divided difference. % - % Also findthe Newton's polynomial. + % Also, find Newton's polynomial. % % Args: - % x: array containing x values. - % y: array containing y values. + % x: an array containing x values. + % y: an array containing y values. % % Returns: - % f: array containing Newton's divided difference coefficients. + % f: an array containing Newton's divided difference coefficients. n = size(x, 2); q = zeros(n, n - 1); diff --git a/solutions/bisection.m b/solutions/bisection.m index 6f02667..4add2ef 100644 --- a/solutions/bisection.m +++ b/solutions/bisection.m @@ -1,5 +1,5 @@ function [root, iter, converged] = bisection(f, a, b, tol, iter_max) - % Calculate the root of an equation by Bisection method. + % Calculate the root of an equation by the Bisection method. % % Args: % f: function f(x). diff --git a/solutions/newton.m b/solutions/newton.m index 0474899..1969c84 100644 --- a/solutions/newton.m +++ b/solutions/newton.m @@ -1,5 +1,5 @@ function [root, iter, converged] = newton(f, df, x0, tol, iter_max) - % Calculate the root of an equation by Newton method. + % Calculate the root of an equation by the Newton method. % % Args: % f: function f(x). diff --git a/solutions/secant.m b/solutions/secant.m index 1c3ec11..af3f50c 100644 --- a/solutions/secant.m +++ b/solutions/secant.m @@ -1,5 +1,5 @@ function [root, iter, converged] = secant(f, a, b, tol, iter_max) - % Calculate the root of an equation by Secant method. + % Calculate the root of an equation by the Secant method. % % Args: % f: function f(x).