Matlab
Matlab
Syntax
Example 2:
Syntax
Example 3:
Syntax
Department of Mathematics 1
Department of Mathematics 2
𝒅𝒚
Example 4: Solve 𝒅𝒙 = 𝒍𝒐𝒈𝒆 (𝒙 + 𝒚), 𝒚 𝟏 = 𝟐 by Modified Euler’s method for 𝒚 𝟏. 𝟒
taking h=0.1. Display output for each value of x upto 1.4. Perform 3 modifications
at every step.
Syntax
Department of Mathematics 3
𝒅𝒚 𝒚
Example 5: Solve = 𝟏 + , 𝒚 𝟏 = 𝟐 by Modified Euler’s method for 𝒚 𝟏. 𝟒 taking h=0.1.
𝒅𝒙 𝒙
Display output for each value of x up to 1.4. Perform 3 modifications at every
step.
Syntax
Department of Mathematics 4
𝒅𝒚 𝒚
Example 6: Solve 𝒅𝒙 = 𝟑𝒙 + 𝟐 , 𝒚 𝟏 = 𝟐 by Modified Euler’s method for 𝒚 𝟏. 𝟒 taking h=0.1.
Display output for each value of x upto 1.4. Perform 3 modifications at every step.
Syntax
Department of Mathematics 5
Example 7: By using 4th order R-K method, solve dy/dx=xy1/3, y(1)=1 at x=1.5 by taking step
size as 0.1.
Syntax
𝑦
Example 8: By using 4th order R-K method, solve dy/dx = 3x + , y(0) = 1 at x = 0.2 by taking
2
step size as 0.1.
Syntax
Department of Mathematics 6
Example 9: Write the MATLAB code that uses Newton's forward interpolation formula and
find the approximate value of f(9) given the following data points (x,y) = (8,10),
(10,19), (12,32.5), (14,54), (16,89.5) & (18,154).
Syntax
Department of Mathematics 7
Example 10:Write the MATLAB code that uses Newton's backward interpolation formula and
find the approximate value of f(17) given the following data points (x,y) = (8,10),
(10,19), (12,32.5), (14,54), (16,89.5) & (18,154).
Syntax
Department of Mathematics 8
3
Example 11: Evaluate 0
(4 + 𝑥 3 ) dx by using Trapezoidal Rule by taking no. of subintervals
as 6.
Syntax
Department of Mathematics 9
Example 14: Find the real root of y = cos(x)
lying between 0 and 𝝅 using N-R method
10
Example 16:
Syntax
Example 17 :
Syntax
Example 18:
Syntax
Department of Mathematics 11
Example 19: Compute the area of the circle lying in the first quadrant with radius a.
Syntax
Example 20: Compute the area bounded by the line x + y = 5 and the x axis.
Syntax
Example 21: Compute the volume of the sphere lying in the positive octant with
radius a.
Syntax
Department of Mathematics 12
Example 22: Find the dimension and basis of subspace spanned by the vectors (1, 2, 3),
(2, 3, 1) and (3, 1, 2).
Syntax
Example 23 : Find the dimension and basis of subspace spanned by the vectors
(1, 2, 1,-1), (3,1,0,5) and (0,5,3,-8).
Syntax
Department of Mathematics 13
Example 24: Verify the rank-nullity theorem for the linear transformation
T : R3 → R3 defined by T (x, y, z) = (x + 4y + 7z, 2x + 5y + 8z, 3x + 6y + 9z).
Syntax
Department of Mathematics 14
Example 25: Compute the inner product of the vectors [1 2 3] and [4 5 6].
Syntax
Example 26: Compute the inner product of the vectors [2 -1 3] and [5 4 -2].
Syntax
Example 27 : Check the orthogonality of the vectors [1, 2, 3] and [-2, 1, 0].
Syntax
Department of Mathematics 15