NUM-BSMATH-2023-15 Lab Report 5 660670245d59c
NUM-BSMATH-2023-15 Lab Report 5 660670245d59c
Code:
import sympy as sp
x,y= sp.symbols('x y')
equation= 3*x**2+2*x*y-5*y**2
expand_equ= sp.expand(equation,(x,y))
print(expand_equ)
factor_equ= sp.factor(expand_equ)
print(factor_equ)
Output:
Task 2: Solving Algebraic Equations 1. Solve the following algebraic equation for 'x': 2x2 + 5x -3 =0. 2.
Solve the following system of equations for 'x' and 'y
Code:
import sympy as sp
x,y= sp.symbols('x y')
equation= 2*x**2+5*x-3
expand_equ= sp.solve(equation,x)
print(expand_equ)
equation_2= 2*x+3*y-10,4*x-2*y-4
sol_equ_2= sp.solve(equation_2,(x,y))
print(sol_equ_2)
Output:
Task 3: Differentiation and Integration 1. Differentiate the following function with respect to 'x': f(x) =
x3 + 2x2 + 5x + 10 2. Integrate the following function with respect to 'x': g(x) = 3x2 + 4x +1 within the
interval [0,2]
Code:
import sympy as sp
x= sp.Symbol('x')
f= x**3+2*x**2+5*x+10
f1=sp.diff(f,x)
print("derivatice is:", f1)
g=3*x**2+4*x+1
integ= sp.integrate(g,(x,0,2))
print("integration is:",integ)
Output:
Task 4: Linear Algebra Operations 1. Create two matrices 'A' and 'B' representing the following
matrices:
Code:
import sympy as sp
x,y= sp.symbols('x y')
A= sp.Matrix([[2,3],[1,4]])
B= sp.Matrix([[5,1],[2,6]])
determinant= A.det()
print("determinant:",determinant)
inverse= B.inv()
print("inverse:",inverse)
cross_product=A*B
print("cross_product of A*B:",cross_product)
equations= 2*x+3*y-10,x-2*y+1
sol=sp.solve(equations,x,y)
print("solution of equations is:",sol)
Output:
Task 5: Calculating Limit of a Function In this task, you'll learn how to compute the limit of a function
symbolically using Sympy. Consider the function
Code:
import sympy as sp
x= sp.Symbol('x')
f= (x**2-4)/(x-2)
limit_value= sp.limit(f,x,2)
print("limit_value:", limit_value)
Output
Conclusion:
In this lab we learn about Sympy which is the library in python, used for solved
mathematical problems.
We solve many problems about that such as about integration, derivation, and
limit. This library is very useful in math in future.