Assign 1
Assign 1
Assign 1
Department of Mathematics
Expriment Number 1
Name:Piyush Patel
Roll Number: 39
Section:C
Date: 26/09/2024
In [1]: 564545+73636 #
Out[1]: 638181
In [2]:
6454-8363535
Out[2]: -8357081
In [3]: 565*709
Out[3]: 400585
In [4]: 759^11
Out[4]: 48157012271803961449924277680359
In [5]:
759**11 # Returns 11th power of 759
Out[5]: 48157012271803961449924277680359
In [6]:
81^(1/4)
Out[6]: 3
In [7]:
(79/12)
Out[7]: 79/12
In [9]:
(79/12.0)
Out[9]: 6.58333333333333
In [10]:
(79/12).n()
Out[10]: 6.58333333333333
In [11]: (79/12).n()
Out[11]: 6.58333333333333
Out[12]: 6
Out[13]: 7
In [14]:
17*(68+72)
Out[14]: 2380
In [15]: (sin(81)).n(digits=20)
Out[15]: -0.62988799427445387857
In [16]: sin(81.0)
Out[16]: -0.629887994274454
In [17]: cos(-5.3)
Out[17]: 0.554374336179161
In [18]: tan(1/2.0)
Out[18]: 0.546302489843790
In [19]:
asin(-0.2)
Out[19]: -0.201357920790331
In [20]: exp(1.0)
Out[20]: 2.71828182845905
In [21]:
pi.n(digits=50)
Out[21]: 3.1415926535897932384626433832795028841971693993751
In [22]: F = factorial(575)
In [23]: print(F)
Out[23]: 739044177711914144340163003120913688696220649621834947725038382067263003829165002719927604137960497761382230035613758248367109475446243386206042021342172687553887264311319034417173352830563722961607927
247491455377926232706894408228906373929389914766429633441130417890962892264047803648004312389788980821791450595169682444396373566601199730056372616248829184760330188815674476093815979031329183226235508
112862108311290423305168936214231975260326069408598967329585653717484240200348138286770572945205714711999695761816962916034492974117436630500215341753045903688819594481866023699076493279365981468000818
855698232700003654518792463763404339738107299048799906048841964705471890915918292973484895118626793346555224135808997264431491277987559661335668764150242293545429007510476811236475825803556784159881592
248340578877453492644622428159485520688049139049036099733563005129343517587944213020542348768471260895734606790511189558065199075432432972197291804384765433362484245649135716108532122894777454234895185
238412755220249179457138242922062525378682086557968284244292121989379136729504832762707050058213710066049412773563483064907375850286271364616477909255924092061802563238092546271537438503469056000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
In [24]:
F.ndigits()
Out[24]: 1339
In [27]: w=F.digits()
w
Expand
In [28]:
w[0] ## gives digit presant at unit place of number 575
w[1] ## gives digit presant at tenth place of number 575
Out[28]: 0
Defining Variables
In [29]: a = 7563
b = 87431
In [30]: print(a,b)
Out[31]: 5170037059533902841
In [32]: b.is_prime()
Out[32]: False
In [34]: b.next_prime()
Out[34]: 87433
In [35]: gcd(a,b)
Out[35]: 1
In [36]: lcm(a,b)
Out[36]: 661240653
In [37]: nth_prime(100)
Out[37]: 541
In [38]: list(primes(50,100))
Out[38]: [53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
Defining Functions
f(x) = sin(x^2)e^(− x) + 3x + 1
In [61]: f(2.1)
Out[61]: 7.18309969277139
In [62]: f.diff()
In [64]: f.diff(2)
In [65]: f.diff(3)
In [66]: f.integral(x)
Out[66]: x |--> 3/2*x^2 - 1/16*sqrt(pi)*((-(I + 1)*sqrt(2)*cos(1/4) + (I - 1)*sqrt(2)*sin(1/4))*erf(-1/2*(-1)^(3/4)*(2*I*x + 1)) + (-(I + 1)*sqrt(2)*cos(1/4) + (I - 1)*sqrt(2)*sin(1/4))*erf(-(1/4*I -
1/4)*sqrt(2)*(2*I*x + 1)) + ((I - 1)*sqrt(2)*cos(1/4) - (I + 1)*sqrt(2)*sin(1/4))*erf(-(1/4*I + 1/4)*sqrt(2)*(2*I*x - 1)) + (-(I - 1)*sqrt(2)*cos(1/4) + (I + 1)*sqrt(2)*sin(1/4))*erf(1/2*(2*I*x -
1)/sqrt(-I))) + x
In [67]: var('x,y')
h(x,y) = sin(x^2-y^2)
In [68]: h(1.0,2.0)
Out[68]: -0.141120008059867
In [69]: var('a,b,c')
show((solve(a*x^2+b*x+c==0,x)))
Out[69]:
[x = − ]
b+ b2 − 4 ac b− b2 − 4 ac
,x = −
2a 2a
In [70]: var('x1,x2')
solve([3*x1-2*x2==7,2*x1+3*x2==11],x1,x2)
In [72]: a,b,c=2,3,-2
x1,x2=quad(a,b,c)
show(f'The roots of the quadratic are {x1} and {x2}')
In [75]:
a,b,c=3,7,9
Area=Heron(a,b,c)
print(f'The area of Triangle is {Area.n()}')
In [76]:
k=0
In [77]:
for i in range (1,51):# (1,51) will take all numbers from 1 to 50 only.
k=k+i
k
Out[77]: 1275
Exercise Problem
2.Solve the system of non linear equations x^2 + y^2=4 and y=x^2-2 for x and y
3.Find the number digits in 1050! and how many zeros are there in 1050!
7.Suppose an investment is made to a bank by an indivisual. The bank gives an annual interest at the rate 4%. Return is
Solution1
In [97]:
var('x1,x2,x3')
solve(x**3-2*x**2-5*x+6 ==0,x)
Out[97]: [x == 3, x == -2, x == 1]
Solution2
In [98]: var('x,y')
Out[98]: (x, y)
In [99]: show(solve([x**2+y**2==4,y==x**2-2],x,y))
[[x = − 3, y = 1] , [x = 3, y = 1] , [x = 0, y = (−2)]]
Out[99]:
Solution3
In [100]: a=factorial(1050)
a.ndigits()
print('Number of digits of 1050! is ',{a.ndigits()})
k=0
Solution4
In [119]: b=factorial(1275)
Out[119]: ---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[119], line 1
----> 1 b.factorial(Integer(1275))
TypeError: factorial() takes exactly 0 positional arguments (1 given)
Solution5
In [112]: f(x)=(cos(x))/(sin(x)+1)
f.integral(x)
Solution6
Out[113]: 24
− 32 sin (2 x)
x5
Solution7
In [0]: