0% found this document useful (0 votes)
16 views4 pages

NUM-BSMATH-2023-15 Lab Report 5 660670245d59c

The document outlines a lab report by Amanat Ullah Khan on symbolic variables and expressions using the Sympy library in Python. It includes tasks such as defining symbolic variables, solving algebraic equations, performing differentiation and integration, executing linear algebra operations, and calculating limits of functions. The conclusion highlights the utility of Sympy for solving various mathematical problems.

Uploaded by

kamanat623
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views4 pages

NUM-BSMATH-2023-15 Lab Report 5 660670245d59c

The document outlines a lab report by Amanat Ullah Khan on symbolic variables and expressions using the Sympy library in Python. It includes tasks such as defining symbolic variables, solving algebraic equations, performing differentiation and integration, executing linear algebra operations, and calculating limits of functions. The conclusion highlights the utility of Sympy for solving various mathematical problems.

Uploaded by

kamanat623
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Name: Amanat Ullah khan

Roll no: NUM-BSMTH-23-15


Department: Mathematics
Course: QCR II
Submitted to: Sir Shazad Arif
Lab: 05
Task 1: Symbolic Variables and Expressions 1. Define symbolic variables 'x' and 'y'. 2. Create a Sympy
expression representing the following mathematical expression: 3x2 +2xy−5y2 . 3. Expand the
expression obtained in step 2. 4. Factorize the expanded expression back to its original form.

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.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy