0 ratings0% found this document useful (0 votes) 42 views13 pagesPython
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
k 16 lim gsBitrary constant
Example 2 : Investigate for what values of 2,11 the simultaneous equations
xty+c26, xt2y+32=10, x+2y+dc=p have
(i) no solution, (ii) a unique solution (iii) an infinite number of solutions.
Solution : The matrix form of the given system of equations is
J.R. INSTITUTE OF MATHEMATICS
189/35 BEHIND RAILWAY STATION, VAISH COLLEGE ROAD, ROHTAK PIN-124001 (HARYANA)
E-mail us on - jrinstituterohtak@ gmail.com, balwanmudgilS4@ gmail.com Mob, 607383607, 9802177766
Page 5
x) [6
= 10|"B
z] La
The augmented matrix is
[A: B] =
Operating R,—>R,—R,, Ry-R,-R,
| 6
~|oO1 4
oOo. u-6
Operating R,—» R,-R,
frag 6
~|01 2 a4
[o 0 2-3):
(@) The system will have no solution if pA: B] # AA) which is possible only if A=3 and ju #10.
(ii) The system will have a unique soltition if, p[A: B] = p(A) = number of unknowns =3, which is
possible only if 4 # 3 and ge is arbitrary.
(iii) The system will have an infinite number of solutions if p[A : B] = p(A) RR, RRR,
4
yaa
[aca}- jon 2
036
Operating R,—+ R,—3R;
friace
-jo12:8
[ooo:o
which isthe row echelon form ofthe matrix [4:8].
We have rank of [4:d] = the umber af oo-zeo rows in echelon form = 2.
‘Alo by the same cl mentary transformations, we et
it ef
a-|o12
000
rankot A=2.
Since rank A= rask{A:B]=2- mumber of unknowns therefore’ We given equations me consist and
will have an infinite mumber of sohtions
‘We see that the given system of equations
ea)
AB)
=2, yo8-2k, c= i the general solution ofthe given system, where
aw a tas eatinba
Exercise 1
1. ( Solve t
xt pyres
+ Bes3y-r-Dwe? , dre Sy43e=7
‘whether the following system equations is consistent or mot
dey s Uroytre6 de-ys2ee7 , rey.
2. Check the consistency ofthe following system of equations and find the solstion if itis consistent:
(@ dee3y4220-7 , Pee y—dz
(i xe2ys3c44e=0, 2e+3y eared, Sxsdysr,
43. Check the consistency of the following system of equations and solve if it is consistent:
9
.xe2yes
drec43e3
wx Des Tyslteeds, dx yo6r=16 , Sx-Sys3e=0
iy 2x-y432=3 , 2429 Tw=5
4. For what values of «and b do the system of equations
AtyeSeeQ, x42y+3aab, xe3ysacet he
@ m0 solution (8) unique sohtion (a) mingely many solutions,
‘5. Investigate the values of 2 and j1 so that the equations
Was3y+Sea9, Tes3y-2ee8, Qesdyedzey ne
(20 solution (i) unique solution (i) an infinite umber,
jy 3 =
Swed, 43yH
6, For what value of 2, the equations x+y+2=1, 442) 44204, x64y-4)02=
solution and solve them completely in each case
17. Show that the equations -2r+y+z=a, x-2y+r=b, x+y-2rwe unless
a+b+e=0 in which case they have infinitely many
arhb=he=-2.
fi -2-1
8, For what value of 2, docs the system | 3. —
ot
() m solation (i) enique soltion
) Solve the system of equations: Ax ¥2y—
specially the case when = 2.
10, Determine whether each systems is linear
(a) Bendy 2yce® () exs3yen (0) 2x-3yskend
Axe dy-2=2, 6x46y+A2 = Sconsidering
11, Consider each of sytem i unknowns «and
(@) x-ayat () ant 3y=2 (© xtaye3
ar W2esayad desSyab
For, of a does cach system have a unique soltion, and fr which paits of values, b)
system have more than oae sokstion ?
(a) xt yeteed (©) x42y43203
2x4 3y 462-10 Des3y48ead
3rs6y+10c=17 Se48ys19c011
13. Consider cach of the following systems in unknowns xy,
@) x-2y=t (by r42ye2cet (© xtysare!
x atay+3e)
tare?https://www.halvorsen.blog -
Mathematics in
Python
Hans-Petter HalvorsenMathematics in Python
Python is a powerful tool for mathematical
calculations
Python Standard Library
— math Module
— statistics Module
NumPy Library
Contents
* Python Standard Library and Basic Math
Functions
* NumPy Library
* Statistics
* Trigonometric Functions
* Polynomials
* Complex NumbersCalculations in Python
We can use variables in a calculation like this:
y(x) = 2x +4
>a=2
>b=4
y(3) =? >x=3
>y = atx +b y(x) =ax+b
> print(y)
(5)=? |>x=5
* > y= atx +b)
> print(y)
Python Standard Library
* Python allows you to split your program into modules
that can be reused in other Python programs. It comes
with a large collection of standard modules that you
can use as the basis of your programs.
* The Python Standard Library consists of different
modules for handling file 1/O, basic mathematics, etc.
* You don't need to install the modules in the Python
Standard Library separately, but you need to important
them when you want to use some of these modules or
some of the functions within these modules.Basic Math Functions
Some basic math functions in Some basic Examples: import math as mt
Python Standard Library:
+ math.exp(x)
+ math. log(x)
+ math.10g10(x)
+ math.pow(x,y)
+ math. sqrt(x)
7 -pythi library/math.htm!
Mathematical Expressions
Let's create the following mathematical expression in Python:
SQey) = 3x2 + fae Hy? + ete
f(2,2) =?
‘The answer becomes f(2,2) = 16.83
Mathematical Expressions
Let's create a function that calculates the following mathematical expression:
f(xy) = 3x? + fxF $y? + eh
Python Code:
import math as mt
def func_ex(x,y)+
a goes Pom a2) + mt.sqrt(mt.pow(x,2) + mt.pow(y,2)) + mt.exp(mt.1og(x))Python Code:
Amport math as mt
ef fune_ox(x,y) +
rmt.pow(x,2) + mt.aqrt (mt pow(x,2) + mt.pow(y/2)) + mt.exp(at.log (x))
return £
xe2
y=2
f= fune_ex(x,y)
print (#)
NumPy
* The Python Standard Library consists basic Math
functions, for fore advanced Math functions, you
typically want to use the NumPy Library
* If you don’t have Python yet and want the
simplest way to get started, you can use the
Anaconda Distribution - it includes Python,
NumPy, and other commonly used packages for
scientific computing and data science.
* Oruse “pip install numpy” https://numpy.orj
NumPy
In this example we use both the math module in the
Python Standard Library and the NumPy library:
Basic NumPy Example:
import numpy as np
x=3 {import math as mt
import numpy as np
y = np.sin(x)
print(y)
y = mt. sin(x)
print(y)
‘As you see, NumPy also have also similar functions | y = !
n(x)
(ee. sim), cost), etc.) as those whois part of the | primecy)
‘math library, but they are more powerful
Mathematical Expressions
{Let's create the following mathematical expression in Python using NumPy:
P(xy) = 3x? + LaF y? + cme F(22) =?
Python Code:
Previously we used math in the Python Standard Library
‘import nuapy a= mp
et fune_ex(x.y)¢
£5 JeMp-Power (x2) ¢ mp.sart(np.power(x,2) + np.poverty.2)) + npvexpinp-og(x))
ial
f= tune exix.y)
peine(e)
—— ie aremer become ye Tee |Mathematical Expressions
FL.) = 3x? + xt + y% + etme) | MPOFE nemPy 08 np
def func_ex(x,y):
f£ = 3+np.power(x,2) + np.sqrt(np.power(x,2) +
-power(y,2)) + np-exp(ap.1og (x
Let's find the values of f(x, y) for ey as iene oe
Ox =?
p(2) =?
———— 30-32/41 88
import numpy.polynomial.polynomial as poly Poly :
Given the following
pl = [1, 1, -1)
p2 = [2, 0, 0, 1] polynomials:
pi(x) = 14x—x?
= e
P = poly.polymul(pl, p2) pax) = 2423
Let's find the polynomial p(x) =
Px(X) + p2(x) using Python
And let's find the roots of the
polynomial
p(x) =0
Polynomial Fitting |