#c) Compute the integral ∫05 x^3 + 2*x^2 dx sympy
#import the modul
from sympy import *
#symbole for x
x = symbols('x')
# x^3 + 2x^2
expr = (x**3) + 2*(x**2)
#integrate exp from 0 to 5
value = integrate(expr,(x,0,5))
#out the value
print ('The value of the definate integral = ', float (value))
#d) Compute the matrix product [ [1.0,0.0], [2.0, 5.0] *[1.5,2.0], [2.0, 2.0]]
import numpy as np
a = np.array([[1.0, 0.0], [2.0, 5.0]])
b = np.array( [[1.5,2.0], [2.0, 2.0]])
print (np.dot(a,b))
d result : [[ 1.5 2. ]
[13. 14. ]]
#e) Create a 7 by 7 identity matrix using numpy.
import numpy as np
I = np.identity(7)
print(I)
#result:[[1. 0. 0. 0. 0. 0. 0.]
[0. 1. 0. 0. 0. 0. 0.]
[0. 0. 1. 0. 0. 0. 0.]
[0. 0. 0. 1. 0. 0. 0.]
[0. 0. 0. 0. 1. 0. 0.]
[0. 0. 0. 0. 0. 1. 0.]
[0. 0. 0. 0. 0. 0. 1.]]
#f)Compute the inverse of the matrix [[1.5, 2.0], [2.0, 2.0]]
#Import required package
import numpy as np
#Taking a 2 * 2 matrix
A = np.array([[1.5, 2.0],
[2.0, 2.0]])
#Calculating the inverse of the matrix
print(np.linalg.inv(A))
#result : [[-2. 2. ]