Online Homework Help
We provide Online Homework help in Mathematics, Science, Probability and Statistics, Data Science, Programming and Engineering Homework, Assignment, Projects with step by step explanation to learn definitions, formulas and concepts to solve the questions and proofs in a better ways.
OR
Assignment Question & Answers Help Examples
Q : Simpson rule Matlab code to calculates the numerical approximation to integral x^3 from 0 to 1 with 3 sub-intervals?
Answer :
To calculate the numerical approximation of
\[\int_{0}^{1} x^3 dx \]
with 3 sub-intervals
Simpson 1/3 rule :
\[\int_{a}^{b} f(x) dx =\frac{\delta x}{3}\left(f(x_{0})+4f(x_{1})+2f(x_{2})+4f(x_{3})+…..+2f(x_{n-2})+4f(x_{n-1})+f(x_{n})\right)\]
clear all
%Simpson 1/3 rule Matlab code to calculates the numerical approximation to a definite integral
f=@(x) x.^3 % function
a=0 % left point of the interval [a, b]
b=1 % right point of the interval [a, b]
n=3 % step size
A=0
h=(b-a)/n
for i = 1:n
x(i) = a +h* (i-1);
y(i) = f(x(i));
end
%Simpson 1/3 rule
for i = 1:n
if ( i== 1 || i == n)
A = A+y(i);
elseif(rem(i,2)==1)
A = A+4*y(i);
else(rem(i,2)==2)
A = A+2*y(i);
end
end
clear all
%Simpson 1/3 rule Matlab code to calculates the numerical approximation to a definite integral
f=@(x) x.^3 % function
a=0 % left point of the interval [a, b]
b=1 % right point of the interval [a, b]
n=3 % step size
A=0
h=(b-a)/n
for i = 1:n
x(i) = a +h* (i-1);
y(i) = f(x(i));
end
%Simpson 1/3 rule
for i = 1:n
if ( i== 1 || i == n)
A = A+y(i);
elseif(rem(i,2)==1)
A = A+4*y(i);
else(rem(i,2)==2)
A = A+2*y(i);
end
end
Output:
f =
@(x) x .^ 3
a = 0
b = 1
n = 3
A = 0
h = 0.3333
ans = 0
A = 0.041152
A= 0.0411523
Q: What is a Matrix ? Explain addition, subtraction and multiplication of two matrices.
Answer :
Matrix : A matrix is an arrangement of elements into rows and columns.
Examples
- \(\left(\begin{array}{ccc}3 & -2 & 1 \\4 & -5 & 8\\\end{array}\right)\) is a matrix with two rows and three columns.
- \(\left(\begin{array}{ccc}2 & 3 & 4 \\3 & 2 & 1 \\4 & 6 & 8 \\\end{array}\right)\) is a matrix with three rows and three columns
Addition and Subtraction of Two Matrices : If Two matrices have equal number of rows and columns are equal then they can be added element wise.
Let \(A=\left(\begin{array}{ccc}0 & -1 & 2 \\-3 & 2 & 0 \\4 & 2 & 0 \\\end{array}\right) and B=\left(\begin{array}{ccc}9 & 6 & 3 \\-5 & 0 & 2 \\3 & 3 & 2 \\\end{array}\right)\)
Both A and B have equal number of rows and matrices. So we can find their addition and subtraction as follows
Addition of A and B
\[\left(\begin{array}{ccc}0+9 & -1+6 & 2+3 \\-3-5 & 2+0& 0+2\\ 4+3&2+3&0+2\\\end{array}\right)=\left(\begin{array}{ccc}9 & 5 & 5 \\-8 & 2& 2\\ 7&5&2\\\end{array}\right) \]
Subtraction of A and B
\[\left(\begin{array}{ccc}0-9 & -1-6 & 2-3 \\-3-(-5) & 2-0& 0-2\\ 4-3&2-3&0-2\\\end{array}\right)=\left(\begin{array}{ccc}-9 & -7 & -1 \\2 & 2& -2\\ 1&-1&-2\\\end{array}\right) \]
Scalar Multiplication : When we want to multiply by a number \(k\) to a matrix then it is multiplied with each entry \( a(i, j) \) of matrix \(A\) and it is called scalar multiplication of k with A.
Example : Suppose \(k = 5\) and \(A=\left(\begin{array}{ccc}2 & -1 & 1 \\0 & 4 & 2 \\0 & -3 & -5 \\\end{array}\right)\) then scalar multiplication of k with A is
\[kA=5A = \left(\begin{array}{ccc}2*5 & -1*5 & 1*5 \\0*5 & 4*5 & 2*5 \\0*5 & -3*5 & -5*5 \\\end{array}\right) = \left(\begin{array}{ccc}10 & -5 & 5 \\0 & 20 & 10\\0 & -15 & -25 \\\end{array}\right)\]
Multiplication of Two Matrices :
If number of rows of a matrix A are equal to number of columns of a matrix B then the product AB is find as follows
Let \(A =\left(\begin{array}{cc}2 & 8 \\3 & 4 \end{array}\right), B =\left(\begin{array}{cc}-3 & 1 \\0 & -1 \end{array}\right)\)
Clearly number of rows in A are two equal to number of columns of B equal to 2.
\[AB =\left(\begin{array}{cc}2 & 8 \\3 & 4 \end{array}\right)\left(\begin{array}{cc}-3 & 1 \\0 & -1 \end{array}\right)\]
\[=\left(\begin{array}{cc}2*(-3)+8*0 & 2*1+8*(-1) \\3*(-3)+4*0 & 3*1+4*(-1) \end{array}\right) \]
\[AB=\left(\begin{array}{cc}-6 & -6 \\-9 & -1 \end{array}\right)\]
Post Your Study Question
Homework and Assignment Subjects
Mathematics : Mathematics , Trigonometry , Geometry
Science: Chemistry , Physics , Biology , Mathematical Biology , Economics , General Aptitude
Advanced Mathematics : Advanced Math , Linear Algebra , Abstract Algebra , Multivariable Calculus , Real Analysis , ODEs , PDEs , Numerical Analysis , Complex Analysis , Integral Equations
Probability and Statistics: Probability & Statistics , Operation Research
Computer Science: Computer science , Discrete Mathematics , Number Theory , Graph Theory
Programming : MATLAB , Python , Excel
Engineering : Laplace Transforms , Fourier Transform , Electrical Engineering , Mechanical Engineering , Electronics Engineering
Management : Research Methodology , Operation Research , Financial Mathematics , Management ,
Recently Answered Questions and Their Answers
- What is zeros command MATLAB?
- How to find the coefficient of x^6y^8 in the Binomial Expansion of (2x^3-y^2)^6 ?
- Math 10th Grade Quiz
- Python subsequence of string
- How to write python program to print first recurring character in given string else none ?