Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
22 views
Lab manual
Lab manual
Uploaded by
K C CHANDANA
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
Download now
Download
Save Lab manual For Later
Download
Save
Save Lab manual For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
22 views
Lab manual
Lab manual
Uploaded by
K C CHANDANA
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
Download now
Download
Save Lab manual For Later
Carousel Previous
Carousel Next
Save
Save Lab manual For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 49
Search
Fullscreen
Lab Component Second Semester Engineering Mathematics as presctibed by Visvesvaraya Technological University, Belagavi Compiled by Dr. Ramananda H. §. St Joseph Engineering Callege, Mangaluru, INDIA. Dr. Smita S. Nagouda CHRIST(Deemed to he University’. Central Campus, Bengalura, INDIA, Dr. Chandra Shekara G. BMS College of Engineering, Bull Temple Road, Bengaluru, INDIA. Dr. Madhukar Krishnamurthy BMS College of Engineering, Bull Temple Rowd, Bengalure, INDIA. Mr. Sonain Kumar AMC Engineering college, Bannerghatta Road, Bengalum, INDIA.Instructions and method of evaluation In ead Lab student have to show the record of previous Lab. Each Lab will be evaluated for 15 marks and finally average will be taken for 15 marks. ‘Viva questions shall be asked in labs and attendance also can be considered for everyday Lab evaluation. |. Tests shall be considered for 5 marks and final Lab assessment is for 20 marks. . Student has to score minimum § marks out of 20 to pass Lab component.Contents: Computer Science and Engineering Stream Lab 1 Lab 2. Lab 3. Lab 4 Lab 5. Lab 6, Lab 7. Lab ¥. Lab 9, Lab 10. Programme to compute area, volume and center of gravity. Evaluation of improper integrals , Beta and Gamma functions. Finding gradient, divergent, curl and their geometrical interpretation Computation of basis and dimension for a vector space and graphical representation of linear transformation Computing the inner product and orthogonality Solution of algebraic and transcendental equation by Regula-Faki and Newton- Raphson method Interpolation /Extrapolation using Newton’s forward and backward difference for- mula Computation of area under the curve using Trapezoidal, Simpson's (4)" and Sin sons (2)" rule Solution of ODE of first order and first degree by Taylor's series and Modified Euler's method lution of ODE of first order and first degree by Runge-Kutta th or and Milne's predictor and corrector method nethodLAB 1; Programme to compute area, volume and cen- ter of gravity 1.1 Objectives: Use python 1. to evaluate double integration. 2. to compute area and volume. 3. to calculate center of gravity of 2D object Syntax for the commands used: 1. Data pretty printer in Python: pprint() 2. integrate: integrate(function,(variable, sin lisit, saz_limit)) 1.2. Double and triple integration Example 1: Le Evaluate the integral f f(x + y®)dydr fron aympy isport + symbols(*= y 2°) ntegrate (x +2-y °° 2,(y,0,2) .(z.0,1)) prist (ut) 1/3 Example 2: detey Evaluate the integral [ ff (xyz aa yds trom sympy ispert + x-Symbol ("=") symbol ('y*) ymbol('2") ntegrate((x+y+2) ,(2,0,3-x-y) (0 ,3-2) ,(x,0,3)) rint (w2) yx 2 81/80Example 3: Prove that f [(c2 + p?}dyde = f flo? + y?ydedy v3- integrate (x"2-yo"2,y,x) pprint (3) w4=integrate(x°"2-y-"2.2,y) pprint (wa) 1.3. Area and Volume Area of the region Rin the cartesian form is [J drdy h Example 4: « Wawa Find the area of an ellipse by double integration. A=4 ff dydr fren sympy iaport + x=Symbol(*=!) y=Symbol("y") pa=Syabol (a) soesyaboi (>) 4 be6 weds sntograte (Cy ,0,(b/a) sage t (ass 2-m0°2)) ,(x,0,a)) print 3) 24.0¢pi 1.4 Area of the region R in the polar form is f/f rdrd? ik Example 5: Find the area of the cardioid r= a{1 + cos) by double integration fron ayapy sport» bol ('e") t-Symbol("s') a-Symbol ("2") bans v9-2-integrate(r,Cr,O,as(1-cos(t))),(t,0,pi)) pprint (3)1,5 Volume of a solid is given by ff [ drdyd= i Example 6: Find the volume of the tetrahecon bounded by the planes x: Oand 200, +842 trea sympy isport * x=Symbol ("x") yo Symbol ("5") 2 Symbol ("2") as Symbol (‘a') be Symbo2(*b') e- Symbol ('c') w2-integrate(1,Cz,0,c:(1-x/a-y/b)) (yO, be Ct-x/ a), Cx, 0,0)) prawt (wa) atbtc/6 1.6 Center of Gravity Find the center of gravity of cardioid . Plot the graph of ear of gravity. sport mumpy ae np pert matplotlib.pyplot as pit ioport math feos syspy re Symbol ('r') te Symbol (+t!) a= Symbol(‘a') Ilsintegrate(con(t)+ree2,(r,0,m*(1econ(t)) F(t. -paypid) ID-integrate(r,Cr,0,a-C1=con(t) 2) .(t ps ypt)) Tet /12 print @h) TnI. gubs(a,5) plt-ares(projection - ‘polar') a8 port rad = ap.arange(0, (2 = ap.pi), 0.01) # plotting the cardiosd for 4 ie rad reas (wenp.cov(4)) pit.polar(i.r,‘g.°) plt-potar(o,I,'r.") plt. show () 5420/618 ss 1.7 Exercise: Le Evaluate f f(c + y)dydr Ans: 05 °° tow(2) x =+1ou6y) . Find the of ff (ete \dedydr ao Ans: -0.2627 3. Find the area of positive quadrant of the cincle x7 + y? = 16 Ans: dr 4. Find the volume of the tetrahedron bounded by the planes x=(),y=0 and 2=0, ptEtinl Ans: 4LAB 2: Evaluation of improper Gamma functions tegrals, Beta and 2.1 Objectives: Use python 1. to evaluate improper integrals using Beta function 2. to evaluate improper integraks using Gamma function. Syntax for the commands used: 1. gamma saath. ganma(x) Parameters : x + The number whose gamma value needs to be computed. 2. beta th beta (x.y) Parameters : x,y: The uumbers whose beta value needs to be compute 3. Note: We can evaluate improper integral involving, infinity by using inf Example 1: ate [ete ayapy sport xepymbola('<') wieintegrate(oxp (-x),(x,0, 01001 € 86°99) prise Ceimplity (wt) Eval Gamma function is 2(n) = [O82 Example 2: Evaluate (5) by using definition fren syapy import + x-symbole('s') wl-integrate( exp (-2)-x094, (2.0.0 oar (*int!))) print Caimpdity (wi) 24Example 3: Evaluate [ e*'cos(4#)dt. That is Laplace transform of cos(41) a feos aympy isport ole Ct 3") # for infinity in syspy wis integrate exp(-a+t) *cos (48), (t.0,00)) ddap lay (aiaplity(wt)) ae & J" cas(4ndi otherwise a for 2 arg (s)| < x Example 4: Find Beta(3,5), Gamma(5) wheta and ganna functions fron sympy izport beta, gamma mrinpueC'a 21); npc Ca ss Hoavtm); per ioay (a); betacm,n); teganza(a) print Cgnama Com.) is 23. a6%%e) print (Beta Comyn") te 43,98 ed a3 n 38 gama (5.0) is 24.000 Beta ( 3.05.0) is 0.010 Example 5: Caleulate Beta(s/2,7/2) and Gamma(5/2)- Yheta and gamma functions # If the oumber is a fraction give it im di from aympy ispor’ beta, gamma mefloatGapar(s 2 1225 aefioarGinpar€te s 1995 imale. fg $/2=2.5 aebetatm,n); te gamma (n) print (gamma ('ym,') ie 03. 36t%e) print@ Beta C myn") ae 10.98 ‘haymn: 25 23.5 gama ( 3.5 ) is 3.323 Beta (2.5 3.5 ) is 0.037 Example 6: Verify that Beta(m,n) = Gamma(m)Gamma(n)/Gamma(m + n) for m=5 and n=7 sympy isport beta, gamma at) <=0.00001) t(*beta and gamma are related’) prist (given values are vrong*) 0 ,000432900432900833 0 .000432900432900433 beta and gama are related 2.2 Exercise: 1. Evaluate J eteos(2t)dt 3 Ans: 1/5 2. Find the value of Beta(5/2,9/2) Ans: 0.0214 3. Find the value of Gamma(13) Ans: 479001600 4. Verify that Beta(m, n) = Gamma(m)Gamma(n) /Gamma(m +1) for m=7/2 nell /2 Ans: TrueLAB 3: Finding gradient, divergent, curl and their geometrical interpretation 1.1 Objectives: Use python 1. to find the gradient of « given sealar function 2. to find find divergence and curl of a vector function, 1.2 Method I: Tp find gradient of ¢ = ry + 2r>— 4. #fo find gradient of scalar point function fron sympy. vector ayspy icpor! syabols N-CoordSys3D('N*) #Serting the coordinate systes x,y, zeaymbola('x y 2!) AeNee<2eW ysDeWeeW 2-4 aVarisbles 2,y,2 to be used with coordinate ayatem ¥ delop'Der() #lei operator display (delop(A)) #00! operator appised to A BradA-gradient(k) #Gradiext function is used print(@*\n Gradient of {A} is \n*) display (grada) + 2ayzy -)iv+ (ors + 2ayay —4) Oy (xy? yy + any -4) iy Gradient of Hxt2"Ny 4 2M? — 4 bs (ayy + 22y) fy + (xy?) dn + an) hy ‘To find divergence of F To find divergence of a v fron aympy.vector sport © ison sympy isport syabels N-CoordSys3D('N') x,y. z-aymbole('x y 2") Case ReWyeM eWay oe 2eW ze WeW. SoN caer Qe Woe yall ok delop-Del () di vandelop. dot (A) display (aiva) priut(E\a Divergence of (k} iu \n") display (divergence (A)) ao8 yang? + oo xnve? Dag NINE ta net Divergence of N.x**2*N.y'N.Z*N.i + Nex*N.y**2"N. ZN. jot NOXANLY*NLZT*ZENG K is, OXN NEN To find curl of F = rtyci + ytrj + 22ryk To find curl of a sympy.vector | irom sympy sport syabols M-CoordSye3D("K') mbols('s y 2°) DoW eM. x delop-Del () curlA=delop.cross(A) display(curlA) ctor point function SOM. jW zee Qe ee yee prantt{"\n Cush of (A) as Nut) dimplay curd (4)) (siervrnte! ~ gfeanrn'an int (—jgesnngan’ + sloay'ngtn i + (Goan ~ 5S aye) cur of Moateaenys (rman! sana) fn + (ayy = ats? Diet (ania tan ny 1.3 Method IT: To find gradient of @ = c*y= #To find gradient af 2 scalar point fanction x” 2yz sympy. physics. vector » sympy (sport var,ppriat var ('=,y,2') v-RaferenceFrase('y') Fev(Ol e#2ey (4) ¥v(2) G- gradient (F,v) FOF, sube(((vi0) ,x), (vit) ,y).(vi2),2)1) print (Given scalar fumction P=") display CF) OG, subs (| (viO) .x), Cv 2) ,y) (vi2).2)1) prane@"\a Gradient of Fe") diaplay (2) 60Given scalar function xyz Gradient of Fe Inyzi, + zi, +27 yi, ‘To find divergence of F = rtyi + ys4] +2 To find divergence of Fax" 2yity272j+x"22k fron aympy-physics.vector iaport * fron sympy isport var var('x, 5.2") veReferenceFrame(*y') FeyiO)--2evillev.xew! G-divergence (F,v) FHF. muba(((v (0) .x) Cv. 2] .y) (v2) 42) )) privt(*Given vector point function ia “) ddaptay (FD v2] ++Bev.y-v iO] ++ 2evi2iev.z G=G. subs (i (vy (0) x2, C¥l 4) ,y), (vi2) 291) print (*Divergence of P=") display (G) Given vector point function is yh, tyr hy toch, Divergence of F= play tc To find curl of F = cy4t + 2c4ys} - Sys #To find curl of Fexy~2i+2x”2yz)-3yz 2k iron aympy-physics.vector ‘sport = fron sympy import var var('x, 5.24) w= ReferenceFrame(*y') FoviO)svit)+2ev.x+20¥ (0) s=2evit) Gecurl(F,¥) PoP. mubs( (v0) .x3,¢vi4) ,y), (vf2).2)!) print(*Given vector point function + display (FD [2)ev. y-Sev (1) evi) ee 2evez ” G=C. subs (((v (0) x) Cvi4) ,y), (vid) 291) curl of Fi peint dispiay (6)Given vector point function is xy, + 2x*y2fy — 3926, curl of Fe (-2aPy — 327), + (4xyz — Zeyh, 14 1 . Prove that the vector (y: — 22)i + (4y— |. Find the vector normal to the surface ry?z7 = 4 at the point (—1, Exercise: Muartyt P+yt sw Ans: 745 +6, 2h + yj + 2 c+ ry, find gradu, gradv and gradi, (y+ sit (ste) + (2+ nb . Evaluate divF and curlF at the point (1,2,3), given that F = r?yei+sy*2j+.ry%. 2)5 + 2(y? - 229k 7)) + (22 — 42)h is solenoidal. Ans: Girys, (2? — y+ yl? Ans: ~4i — 19) + 4h. If R= xi+yj + 2h, show that (i) V-# =3, (li) V x R=0.LAB 4: Computation of basis and dimension for a vec- tor space and graphical representation of linear trans- formation 4.1 Objectives: Use python 1. to verify the Rank aullity theorem of given linear transformation 2. to compute the dimension of yector space 3. to represent linear transformations gxaphically 4.2 Rank Nullity Theorem Verify the rank-uullity theorem for the linear transformation T : R* + R* defined by T(x, y,5) = (0 + Ay + 72,2 + Sy + 82, Sr + by +95 sport mumpy as ap acipy.Linalg 4 Define & Linear tramsforaation interss of satrix A mpearray(( (1, 2, 3), (4) 8, 6], (7, 8, 911) 4 Find the rank of the satrix 4 rank © np. 1inalg.satrix rank(A) print ("Rank ef the matrix*, rank) # Find the null space of the satrix A ns» null_apaee(A) print (mul © of the satrax* # Find the dimension of ene null space nullity shape (41 print(*Null space of the aatrix* ,aw2lity) * Verity the rank-nullity theores st rank + aullity == A.chape!t prant ("Rank-aullity theor: holds .*) print (*Rank-mullity theeres does not hald.*) Rank of the matrix 2 Null space of the matrix [[-0.40824829] [ 0.81649658) [-0.40824829]1 Null space of the matrix 1 Rank-nullity theorem holds. a4.3 Dimension of Vector Space Find the dimension of subspace spanned by the vectors (1,2,3), (2,5, 1) and (31,2). Laport mumpy ap # Define the vector space V V = np. array (/ 1,2, 31 2.3.41, 3,1, 211) 4 Find the dimeneion and basis of ¥ basis ~ ep.linalg-aatriz_rank(¥) dimension - V.chape(0) print (Basis of the matrix", basta) print(*Dimension of the aatrix™ Basis of the matrix 3 Dimension of the matrix 3 Extract the linearly independent rows in given matrix : Basis of Row space aumpy sspor! aympy as ep 1,1,11,[2,-8,2,2), (8,-8,5,3 1A. -4,A, Ald S=chape (AY arlen(a) for a is range(a) HABLA, 1] ==0 ab=copy (AB) for k in range (4+4,8[0)) He ab lk, 4) /90 Abid.) °ABLKY able) AB, | ABr copy (ab) for J in range (a +lym) Fact AB}, 3) /ABLS, 31 ek ie rangeCt.a) AB j,k) AB Lj ke) Fact -ABLa, Ke] display ("REF of given satrix: ",sp.Matrix(AB)) tomp = (0, 0, 0,0)? result - [] for 4dx, row in enumerate (sap(eupte. AB)) af row oot in temp result. append (1dx) print (*\n Basis are non-zero rows of A:*) display (sp. Matrix (AB (result |))"REF of given matrix: ' re 0 300 o 0 20 o 0 00 Basis are non-zero rows of A: 1-l bd 0 300 0 0 20 4.4 Graphical representation of a transformation 44,1 Horizontal stretch: Represent the horizontal stretch transformation T : ?8R? geometrically Find the imaxe of vector (10,0) when it is stretched horizontally by 2. units ssport aumpy as ap sport matplotlib.pyplot as plt V = mp.areay (((10,0! 1) origin - ap.array(i (0, 0, 0),(0, ©, 0)}) # origin point Avop matrax( (2,0) ,0.1))) Vienp-matrix(¥) V2-Anap.transpone (V1) V2enp array (V2) plt quiver(-origin, Vi .0), Vi..1), color= scalen50) plt quiver(-origin, V2.0, ), V2.1, ), color=i'r'), acaler50) pit show () 00 | 002 | 000 — ee | ~002 | Another example. fron math isport pi, ein, coe‘epost matplotlib.pyplot as pit leper! muspy ae np coords = ap. array(( (0,0), (0,5,0.5),/0.8,1,8), (0,9) ,/0,0))) evords ~ coords .tranapose() coords x = coords i0,:) y = coords (1,-) A = 'mp-array€l (2,0), Acconrds = A@coords xlLTa coords 0, y.LT1 = A_eoords (1, # create the figure and axes objects fig, ax © pit. aubplotaQ # Plot t pointe. x and y are original vecto ages ax.plotdz,y,'re!') ax.piot Lt, y_LT1, bo) # Connect the poiats by lines ax.plot (x,y, ‘r',La="--") ax. plot GLLT, y-LT1, 0°) 4 Edit come settings ax.axviine(x°O,color="k",1e=":") ax,axhline(y-Q,color=*k",1g=":") ax.gria@s ue) ax.axia(/-2,2,-1,2)) ax. set_aspect (equal) ax.set_title ("Horizontal Stretch"); Horizontal Stretch4.4.2 Reflection: resent the reflection transformation 7: R* — R* yeometrically. Find the image of yeetor (10,0) when it is reflected about y-axis. ieport aumpy as ap suport matplotlib.pyplot as pit V = mpsarray({ (10,0) 1) origin - mp-srray(/(0, 0, 0), (0, 0, 011) # origin point deap matrix (((-1,0), 10,1! 1) Vi-np-matrix(¥) V2-Avap. transpose (V1) V2-ap.array (V2) plt.quiver(-origin, Vi..0), Vi:.1]. color-['b'), seale-50) plt.quiver(-origin, ¥2(0..), V2.1, 1, color-['r‘), seale=BO) pit. show() Another example. # Create the figure and axes objects fig, ax - plt.subplots<) 4 Plot the points. x and y are original vectors, x tT! and y.tTt are aaages ax prot (zy, 'r0") ax plot (x LT2,y_L12, ‘be') # Connect the pointe by lines ax plot(z,y,'r'jlee"--") ax. plot (x LT2,y_LT2, *b') 4 Edit cone settings ax anvline(x-0,color="k" 1 " 7ax .azhLine(y-0,color=*k* 1a=" 2") ae seria Ges) ax sazie(/-2,2,-1,21) ax. set_aspect(‘equal') ax tatathe("Heflection™); Reflection "-2.0 15 10 0.5 oo Os 10 15 20 Represent the rotation transformation T - R* — RB? peometrically. Find the image of vector (10,0) when it is rotated hy /2 radians. ieport aumpy as np sport matplotlib.pyplot as pit V = mp.array({(10,0)1) origin asray(( (0, 0, 01, {0, 0, O11) # origin point Asap . O11. 41) Vi-np.matrix(¥) V2-Asap. transpome(V1) V2-np. are ay (V2) pit. quiver(-origin, Vi 01, Vi..1). color + seale50) plt.quiver(-origin, V2/0, ), V21, 1, color=(‘r'), msenle~50) pit. shou ()oo 802 oo Another example theta = ps /6 A= np. array (( (cos (theta) ,-sinCtheta)), [ein(theta) ,cos (theta) ))) R_coords - coords xLLT3 = Regorde (0, yhT3 - Rleoords it, | 4 Create the figure and axes objects fig, ax = plt.aubplota() # Plot the points. x and y are original vectors, x.LTi and y.LT! are jnages ax.plot (x.y, 'r0") ax. plot (x_LT3, y_LT3, ‘bo") # Connect the points by lines ax plot Ge.y, tr! ,la=*--*) ax plot (x.LT3,y-LT3,"b') 4 Edit some settings ax azviine(x-0, color ax, exhl ine (yO, color~ ax.grid (Tue) ax axis((-2,2,-1,21) ax.set_aspect (‘equal ') e* dee) ery doe"s")‘e--------—‘s -1.0 20 -15 -10 -05 oo 085 10 «15 (20 44.4 Shear Transformation Represent the Shear transformation T : R? —> R? geometrically Find the image of (2,33) under shear transformation. import mumpy as ap Lupost matploelib. pyplot as plt Vo» mp-array(1 (2,311) origin = ap.array(.10, 0. 0), (0. 0, 021) # origin point Aenp matrax(. 1,2) ,10,1)1) Vienp.matrix(¥) V2cAenp. transpose (V1) V2-np. array (V2) print (image ef given vectors se:", V2) plt.quaver(-origin, ¥i-,0), Vi,1), eolor-['b'), seale-20) plt.quiver(-origin, V2(0,.), V2.1, 1, eolor=\‘r'), seale-20) plt. show () 70os ow 00 -092 -008 woe? ato cr oe Another example. S = mp-erray(L (1,2), { |S coords = Stcoords x74 = S_coords (0, -) yolT4 = S.coorde(1,>) |# create the figure and a fig, ax ~ plt.aubplots() objects # Plot the points. x and y are original vector, x LT! and yLT! are taag: ax.piot (xy, 'r0") ax. plot (x_LT4,y_LT4, 'bo') |* Connect the points by lines | ax plot ey, 'r',1=*--") [ax plot GrlLT4 ,y 074, "1D |# Bdit come settings ax axvline(x-O,color-"k",1s-":") ax reolor="k*,1e=":") as 4,-1,2)) ax, get_aspect (‘equal ') ax. set_titie("Shear*); 71Shear 44.5 Composition Represent the composition of two 2D transformations Find the image of veetor (10,00) when it is rotated hy 7/2 radians then stretched hori- zontally 2 units ‘sport aumpy ae ap Lupost matplotiib.pyplot as plt V = ap.array (((2,3)1) origin = mp.array(.(®, 0, 0), (0, 0, OJ1) # origin point Aeup -mateax( (0,91), 1,011) Benp -matrix(2,0),/0,1)1) Virnp matrix (¥) V2-Acnp . transpose (Vi) VaeB-¥2 Vaenp. array (¥2) VBenp.arcay (V3) print ( Inage of gives plt.quiver(sorigin, Vi-,01, Vil, plt.quiver(-origia, V2/0,-), V2i1,") te!) , weale=20) plt.quiver(-origin, ¥3(0, ), YB.1. ‘g') | seale=20) plt.title( Slue=original, Red=Rotated .Groen=Rotated+Streached ") plt.ahow() scale=20)Bive=original, Red=Rotated Green=Rotated+Streached - oo 00S Another example. = aplatray(((-e Gacdbean = ceceords (theta) ,cin(theta)), (sintheta) .coo (theta) J]} KALTB * Clevords (0, ° ylLTS = Cleoords(t.-] 4 create the, figure and azes objects lester phaser (ied oie) » Gi pai Uelfad eck aah cia yee inages | jax.piot(x.y,* 40") Jax. plot (eLTS ,y.LTS,'be") | coeanee one pesste wy tt000 |ax-pietinay tet dest= ae plot GeL78 yy “LTS ,'b*) |e cate some set tings |x. axviine(x-0, calor-"K* 28°72") te sahline(y-0,coler-"k lee"!*) Jax grsacteue) Jaxvenioci-2.2 tet 1.21 pect (' equal’)-1.0 “20-15 -10 -05 00 05 10 45 20 4.5 Exercise: 1. Verify the rank nullity theorem for the following linear transformation a) T= RY + RY defined by T(1,y) = (x +4y,2r + 5y,3e + 6y) Ans: Rank=2, Nullity=1, RNT verified b) T: RY + R defined by T(x, y.2) = (rHy— Aus: Rank=3, Nullity=1, RNT verified Dr thy t8e, drut bats), 2. Find the dimension of the subspace spanned following set of vectors 34). (2 6, 8), (1, LAL) ension of subspace is 2 4), (2,1,6,8), (1, 11, 1) 3, ension of subspace is 3 3. Find the image of (1,3) under following 2. transformations a) Horizontal stretch b) Reflection ¢) Shear dj RotationLAB 5: Computing the inner product and orthogo- nality 5.1 Objectives: Us python 1. to compute the inner product of two vectors. 2. to check whether the given vectors are orthogoual 5.2 Inner Product of two vectors Find the inner product of the vector: isport mumpy as op initialize arrays A= mp-array([2, 1, 8, 41) B= mp.array((3, 4, 7, 8)) fdot produce output mp. diot(A, B) print Coutput) 17 5.3 Checking orthogonality Verify whether the following vectors (2, 1,54) and (3,4,7,8) are orthogonal ‘sport numpy as np # initiation arrays A= mp.array((2, 1, 8, 4) B= ap.array(i3, 4, 7, 8)) fdot produce output = ap.dor(A, B) print@ Inner product is :*,output) Vf output -0 praue€*gaven vectors are orthognal ') pront(*gaven vectors are not orthognal ‘) Inner product is ; 77 given vectors are not orthognal5.4 Exercise: 1. Find the inner product of (1, 2,3) and (3,4,5). Ans: 26 2. Find the inner product of (1,—1,2.1) and (4, 2,1, 0). Ans: 4 3. Check whether the following vectors are orthogonal or not 4) (1,1,=1) and (2,3,LAB 6: Solution of algebraic and transcendental equa- tion by Regula-Falsi and Newton-Raphson method 6.1 Objectives: Use python 1. to solve algebraic and transcendental equation by Regula method. 2. tw solve algebraic and transcendental equation by Newton-Itaplson method. 6.2 Regula-Falsi method to solve a transcendental equation Obtain a root of the e Perform 5 iterat uation 1 — 2 —5 HW between 2 and 3 by regula-falsi method. # Regula Falei method tres sympy izport + ymbol("=') g sinput( Enter the function ‘J #ix3-2ex-5 Function f-lambdify(x.g) jot :nputQ' Enter a valus :')) #2 befioat(input'Enter b value :*}) # 3 Meant¢ (Enter nusber of iterations :'}) #6 for 4 an rango(L,Mea) evar t(b)-bet(a))/ (0b) -£ (49) CC Ca) o£ Ce) 09) bee ‘itvation Yd \t the root %0.3f \t function value “0.31 \nt Gye, tCedd) Enter the function xt*3-2"-5 Enter @ valus :2 Enter b valus = Enter number of iterations :5 itration 2 ‘the rect 2.059 function velue -@, 392 itration 2 ‘the root 2.881 function value -@. 147 itration 3 the root 2.080 function value -@. 655 itration 4 the root 2.093, function value -@,¢2@ itration 5 the root 2.054 function value -@. 007 Using tolerance value we can write the same program as follows: Obtain a root of the equation 4 —2r — 5 = W between 2 aml 3 by regula-falsi method. Correct to 3 decimal paces.# Regula Faiei method while loop? fron aympy ispert + x= Symbol ('x') § tinput('Enter the function function f>lambdity Cx, g) arfloat (input (Enter a walus befloat(input (‘Enter b valus loatCinput ("Enter tolarence :')) # 0. © (abe Gre) 6) c= (Car £(b) be tad) CEC) -£Cad) : 1 (ta) te) 09) bee -e deat printC*iteation Jd \t the root /0.3f \t function value /0.3f \n! (6.605 print(*fimal value of the root is %0.8f'he) Enter the function x**3+2*x-5 Enter a valus :2 Enter b valus :3 Enter tolarence :@.001 itration 1 ‘the root 2.059 function value -2.391 itration 2 the root 2.08% function value -0.147 itration 3 ‘the root 2.098 function value -0.@55 itration 4 ‘the root 2.093 Function value
[email protected]
itration 5 ‘the root 2.094 Function value -.007 itration 6 ‘the root 2.094 function value -0.003 final value of the root is 2.09432 6.3 Newton-Raphson method to solve a transcendental equa- tion Find a root of the equation 3. = cos r+ 1, near 1, by Newton Raphson method. Perform 5 iterations ircs sympy xe symbol ("x") gS cinpulC'Enter the fusction ") #i3x-cos(x)-i f-lambdity(x.g) ag = ite(g):df= Lasbdi ty (x, dg) Gaput( Enter the intial approsimation *)) ut(*Enter the number of iterations ')); sxe (1,ne4) (£(10) /at(109)) prist(*itration id \t the r 0.3f \t function value %0.3¢ \a't Gy x1fG))); #prist all iteration value Enter the function 3*x-cos(x)-2 Enter the intial approximation 1 Enter the number of iterations 5 itration 1 the root 0.620 function value 0.046 itration 2 ‘the root 8.687 function value 9,000 itration 3 ‘the root 0.67 function value ¢.000 itration + the root 0.69 function value 0.000 itration 5 ‘the root 8.67 function value 2.000 6.4 Exercise: 1. Find a root of the equation Sir = cos.r+1, between (and 1, by Regnla-falsi a Perform 5 iterations. Ans: 0.607 2. Find a root of the equation ce = 2. beewe O and 1, by Regula-falsi method. Correct to 3 decimal places Ans: 0.853 3. Obtain a real positive root of rt — Perform 4 iterations. 1, ly Newton-Raphson method. Ans: 1.856 4. Obtain a real positive root of 48 Tr? +6 method. Perform 7 iterations. 0, near 3, hy Newton-Raphson Ans: 2.061LAB 7: Interpolation /Extrapolation using Newton’s forward and backward difference formula 7.1 Objectives: Use python 1. to interpolate using Newton's Forwanl interpolation method. 2. to interpolate ising Newton's backward interpolation method 3. to extrapolate using Newton's backwant interpolation method. 1. Use Newtons forward interpolation to obtain the interpolating polynomial and hence caleulate y(2) for the following: Sf) oo = fron aympy isport © sport mumpy as ap a = sotGsput('Enter aumber of data points: ‘3) 210 = mp.zeros((n)) ye os ((n,n)) # Reading data points print@Ester data fer x and y: ') for 4 in range(n) atCinput( tafteetr(i)et=4)) y(4](0) = floar(snpur( tyLtestr(ade']=")) # Generatiog forvard difference tatle for 4 in range(1,n) for j 2m range(O,a-4) yigh(a) = yl§-2d l4-4) ~ yg) (4-1) print (’\sPORWARD DIFFERENCE TABLE\n'); for 4 an range(O,a) print", 2f° ¢x(a)), end ’ suge€®, ma) pecotC*VtQenO.26* 4(y EA) (91). am prstO # obtaining the polysomial tonymbola(*t*) tr() # fis a Lint type data “"y pe(t-x10})/(x1 1) 2/0) f append (p) fora soge (m4) append (f (4-1) + (pea) /404)) pely-y 0) (0) fora nogo (m= 1) poly-poly*y(O)(i-t)-f{4! 80Bimp_poly-simplify (poly) print(*\nTHE INTERPOLATING POLYNOMIAL 18\o* print (simp_poly) # af you want to ssterpolate at sose poist the aext session vill help Anter=input(*Do you vast to interpolate at a point(y/n)? ') # > af anter-="y* a-float(iupatQ*enter the point ‘)) #2 interpol ~Lambdi ty (t simp. poly) result interpol (a) print('\aThe value of the function at’ ,a,‘se\n",result); Enter number of data points: 5 Enter data for x and y s[oy=t ylo)=8 xL)s3 y[t]=10 x[2} yiz~s2 xp31-7 yLa]-210 xlal-9 vyl@]=s02 FORWARD OFFFERENCE TABLE 1. 00 6.00) 4.00 9.00 3.00 10.00 52.00 96.00 5.00 62.00 148.00 144.00 7.00 240.00 292.00 9. 00 50200 THE INTERBOLATING POLYNORIAL 15 a 2 Let - 2.0% + 1et- 70 Do you mart to interpolate at » pointty/n)? y enter the paint 2 The value of the function at 2.0 is sa 2. Use Newtons backward erpolation to obtain the interpolating polynomial and : x P35 7 8 hence calculate ¥(8) for the following data: fy oy oty sna fees aympy sport isport aulmpy as ap import aye print(*Fhie wild nee Hevton's backword intepolation torania *) # Reading ausber of unknowns a= int(impur(*Eater muaber of data posats: *)) 4 Making numpy array of 5 bn x = size and imitialaziog # to zero for storing x and y value along with differences of y x = ap.zeroe((n)) y © ap.eeros (aya) 4 Reading data pointe aLprint@Eater data for x and y for 4 in range(a) x(4] = float Cinpure te€temtr d=) YiA](O) = tloarCispur € ty Emer Cade =") 4 Generating backvard difference table for 4 in range(1,a) for J an range(m-2,8-25-2) YOS)] © y(§)td-4) - yl yea) ca-a7 print @\BBACKWARD DIFFERENCE TABLE\E'); for 4 10 range (a) prise 00. 261 1x2), endo) for J te range(O, 3-4) Peant@ Men. 26° A¢yl4d(g)), emda") oO i the polynomial ‘tosymbols('r') po(t-xim-1))/(xit]-210)) #.append(p) for 4 in range(tyn-4) f.append(f (4-1) (pra) /C4°1)) poly=yin-1) (0) print (poly) for 4 sn range(a-4) poly=poly+yin-1) (is1]}+f(4 poly- simplify (poly) print @\nTHE INTERPOLATENG POLYNORIAL I8\n); Pprint (siap.poly) Wf you vant to interpolate at sone point the next session will help inter (Bo you vant to interpolate at @ point(y/n)? ') if dater=-"y* arsioat Geput Center the poise ")) anterpol=Lambdity (t , wim result interpol (a) print@\nthe value of the function ut! poly) Sie \n'yremmaey 5This will. use Newton's backward Intepolation Formala Enter number of data points’ 5 Enter data for x and ¥ xfo} ylol~6 a1] a yl}-t0 xf2]-5 yizl-«2 xB)? yEp-a10 xfa]-9 yia=se2 facto OLVFERENEE TABLE 1.00 6.9 Heo ise 2.00 S00 6200 32:00 8.00 Toe Pio.ee 00 96.00 Soo Sone 2.00 1ai.00 48.00 2.00 We THTERICLA EMG POLIHERIAL 1S 4 2 De you want to interpolate at a potot(y/n)? y fencer the point & The value of the function at 8.8 is 335.0 7.2 Exercise: 1. Obtain the interpolating polynomial for the following data xe 0123 yb 2 1 Ar ttt beth ae Find the number of men getting wage Rs. 100 from the following table: wage 0150-250 350 No. ofmen: 9 30 35 12 Ans: 23 men Using Newton's backward interpolation method obtain y(1G0) for the following data x: 100 150° 200 250 300 ys 1013 7 18 Ans: Using Newtons forward interpolation polynomial and calculate y{1) and y(10), x: 8 405 y: 18 84 15 Ans: 3.1 and 100 83LAB 8: Computation of area under the curve using Trapezoidal, Simpson's (!)"' and Simpsons (!)'" rule 8.1 Objectives: Use python 1. to dind area under the curve represented by a given function using Trapezoidal rule. 2. 0 find area ander the curve presented by a given function wing Simpson's (4)" rule, 3. to find aren under the curve represented by a given fianetion sing Simpson's ($)'" rule. 4. to find the area below the curve when discrete points on the curve are given. 8.2 Trapezoidal Rule 5 Evaluate: [ goby. # Definition of the function to integrate func (x) uel / (+x *= 2) 4 Function to implement trapezoidal zethod set trapezoidal (x0, an, a) b= Ga - x0) fa # Calculating step 4 Finding cum integration = my.func(x0) + my_fune(xn) # Adding firot and for soge, =) KOs 408 4 i-th step value integration - integration ~ 2+ my_fumc(k) # Adding areas of the trapezo: de # Proportioning eu of trapezoid a: integration - integration = h | 2 return antegrataon * Input section Loverlimst © fivat(sspur (Enter lower limit of integration: 7)) upper_limst © float (ssput ("Enter upper limit of integration: ")) subjdaterval = int (iuper(*Enter number of sub antervals: ")) # Call trapezoidal) xethod and get result result = trapezoidal (lover_limit, upper_limit, sub_iaterval) # print result egration recult by Trapezoidal method ic: * , reaule)Enter lower Limit of integration: 0 Enter upper Limit of integration: 5 Enter ovaber of sub intervals: 10 intagration result by Trapezoidal sethod is: 1.2731L940812301002 8.3 Simpson's (!)" Rule Evaluate [by 4 Defisition of the function to integrate def my_func (x) 1/GQsner 2D # Function to implement the Simpson "s one-third rule def simpsomi8(x0,x0,m) n= Ge - x0) / 2 # calculating step size * Finding cum integration = (my_fune(x0) + ay_fune(xn)) k= x0 for 4 an range (1,0) af 442 == 0 Amtegration - integration - 4 + ay_func(k) integration - integration « 2 + ay_func(k) kook # Finding final integration valve integration = integration = h = (1/3) revurs amtegration # Input section Loverlimit = (loat(ssput ("Enter lover limit of integration Upper limit = (loar(scpur (“Enter upper limit of dntegration wublinterval © ini (sspr(*Enter musber of aub intervala: ")) # Call trapezotdal () sethod and get result result = simpmoni3(lover_limit, upperlimit, sub_interyal) print(*integration result by Siapson's 1/3 method ia: 40,61" ) Enter lower Limit of integration: 0 Enter upper Limit of integration: § Enter number oF sub Intervals: 100 Integration result by Simpson's 1/3 method is: 1.404120 8.4 Simpson's 3/8th rule Evaluate Jf ghrdr using Simpson's 3/8 th nile, taking 6 sub intervals def simpsons_3.8_rule(£, a, b, 2) ”) ”» | Cresult)b= (b-a) fn B= f(a) + £6) for 4 im range(a, a, 8) seeds tee ae) for 4 im a1, 3) seeds flee wD for 4 in range(2, a-2, 3) sc= 28 fla>aeh) return 5° 3b / 8 ier £¢x) return 1/(1+xe*2) # function bere * upper finite # number of sub ister vals result ~ simpsons_3_8_rule(f, a, b, 2) prant( 3.8£ result) 1.27631 8.5 Exercise: \ a 1 L. Evaluate the integral dr wing Sampson's 4 rule ms = / +e * a Ans; 0.23108 os 2. Use Simpson's = rule to find | 17d by taking seven ordinates Ans: 0.5351 3. Evaluate using trapezoidal mule | sintrdr. Take » o Ans: 9/2 4. A solid of revolution is formed by rotating about the r-axis, the area between the ae~axis, the lines c= O and c= 1, and « curve through the points with the folle co-ordinates: 1.0000 0.9896 0.9589 0.9089 O85Estimate the volune of the solid formed using Simpson's yd rule, Hint: Required volume is fy? «dr. **[Ans: 2.8199]** 5. The velocity »(kan/min) of a moped which starts from rest, is given at fixed intervals of time ((inin) as follows: t 2 4 6 8 10 12 Mow IK 20 v Wo 2 9 32 20 UN 6 2 0 Estimate approximately the distance covered in twenty minutes, Answer for 5. We know that ds/dt=v. So to get distance (s) we have to integrate, Here h 10, v = 18, v3 = 25 ete. , ty = 0, 0 @ ve chall use simpecn’s 1/9 rule directly to estizate 10 18, 25, 29,32 ,20, 11 8 2, 0) h/3) © CCylO) sy 20) A+ Cy it) oy 31 *y (8) oy (7) oy (9) D+DeCyl2oylaloy 6)+y'81)) print (23.51 result ,im.*) 309. 33333 km.LAB 9: Solution of ODE of first order and first degree by Taylor’s series and Modified Euler’s method 9.1 Objectives Use python 1. to solve ODE by Taylor series method. 2. to solve ODE by Modified Euler method 3. to trace the solution curves. 9.2 Taylor series method to solve ODE Solve: #2 — 2y = Bet with y(0) # module taylor ‘WEY = caylor(deriv,x.y,xS8top,b) 4th-order Taylor series method for solving the initial value problem (y = {F(x,4y))), shore ies method at 2 0 using Taylor 0.1(0.1)0 iy) = (yf0l,ylt},...yfa-t}) xy = inits xStop = terminal value of x b= increment of x conditions nuspy iapor! array jet taylor (deray,x,y,x5top ,b) ee Y- X. append (2) Y. append (y? viste x © eBtop # Loop over integration steps D = derivéx.y) 4 Derivatives of 5 He 10 or J in range (3) # build Taylor series He wea D yoy: Diglew eae byt rexreh X.append(x) # Append results to Ylappend(y) # Iiaes X and Y retors array(X),array(Y) # Convert lista into arrays ¥ deriv = aser-supplied function that returue derivatives in the 4x 9 fy "lol y y*(2] yifa-t) yrtto} yd ye vit ant] yeer(o) yore tad yee ta: yi tint) peered gt ha) gray feud) jot derav (x,y) D © seron ((4,1)) 8S2-y (0) + 3eexp(x)) Avy (01+ Seexp (x)! Bey (O]> 2 exp(x)) 16+ yO) 48+cxp(x)! x= 0.0 # Initial value of = xStop = 0.3 # last value array (10.0]) # Initial values of y oa Step size Y = taylor (deriv,x.y, xStop ,h) y b x, print(*The required values are cat r= 40.2, y=J0.S€, 2970.28, y=%0.5¢, z= 0.28, yo10.88,2 = 10.28, y= £87 (X(0) ¥CO) X14) VLA) 212] 12) »113) ,Y31 0) The required values are :at x= 0.00, y=0.00000, x=0.10, y=0.34850, x = 0.20, y=0.81079,x = 0.30, y=1. 41590 Solve y+ 4y = 2? with initial conditions y(0) = 1 using Taylor series method at r 0.1,0.2. feos auspy isport arcay lel taylor (deriv .x.y.x8top,b) re O0 yeu X. append (x) Y- append (y) wivce x © RBtop # Loop over integration steps D = derivex.y) # Derivatives of y we 1 j @ # luild Taylor series We Hea a) y-y + Diglew es bysy! zo xek A-appond(x) # Append results to Yeappend(y) # lists X and ¥ array(X) array (¥) # Convert lists into arrays # deriv = vser-supplied function thet returns derivatives in the 4x 9 array fy*to} yf) ytt2] ... y'[a-t] yrtod y"(4) "C2 yrln-t) yer yer tad yt eria) 22. yt tend y**to} y**tt) y**t2) petted] jet deriv(x,y) D- aay) Di) = [xe+2-4+y 0) Da 2ex-Gex2°16+y (01) D2) = 2Bexs16-xe°2-64ry 0 DIS) = |-B+B2-x-64+x 9-24 256-y (0) xoreturn D x= 0.0 # Initial value xStop - 0.2 * last value y= array(11.0]) @ Intezal values of y hes 0.2 * Step size X,Y = taylor(deriv,x,y,x8top,b) print(*The required values are zat r= {0.2f, y=10_8£, ot, y x= 10.28, y=K0.5£°%(K(0) ,¥L0), 212 w¥ia),012),¥21)) The required values are :at x= 0.00, y=1.00000, x-0.10, y=0.66967, x = 0.20, y=0.45026 9.3 Buler’s method to solve ODE: Tosolve the ODE of the form 4 = f(r,y) with initial conditions y{r6) = fornmla is given bys yen = ed) + A (eae). Solve: yf =e" with y(0) = —L using Enler’s method at r= 0.2(0.2)0.6. o. The iterative Loport numpy ae ap Lsport matplotlib.pyplet as ple # Define parameters f= lusbdo x, y: mp.exp(-x) # ODE b= 0.2 ¢ Step ss yO» -1 # Initial Condition a3 # Eeplicrt Euler Method yiol = yo x10) -0 for 410 range(O, a) xlsctl-x leh yids 1) = yla) © metatad, ylal) print("The required values are at x= %0.24, ye%0.S£, x=%0.2f, y=¥0.6¢ x 2 40.2f, yokO St,x = XO. 28, £7, G20) .¥ 0 id) ,y (4) .2 12 x(3).¥/31)) print (*\n\a") plt.plot(x, y, ‘bo--', label=" Approximate’) plt.plot(x, ~ap.exp(-z), 'gr-', label="Ezact") plt.title(*Approrimate and Exact Solution™ ) pit. xlabel('x') pit. ylabel (*f(x)") plt. grid pit. legend (1oc=" best") plt. show 0)The required values are at x- 0.00, y--1.00000, x-0.20, y--0.80000, x = 0.40, y=-0.63625,x = 0.60, y=-0.50219 Approximate and Exact Solution 9 Approximate 3) Bact 25 20 x a 20 Ps ry 8 100 2y +e with (0) = 1 using Euler's method at r= 0.1,0.2 isport aumpy as ap isport matplotiib.pyplot as pit # Define parameters £ = lanbds x, yo -2ey-(ee*3)emplexp(-2ex) # ODE b= 0.1 # Step oi yO= 1 ¢ Initial Condition a2 # Explicit Euler Nethod yiol x10] -0 for 4 in range(O, a) x(i+t]-a(a]-b yld + 1] = ylal + metGxtal, ylaly print(*The required values are at plt.plot(z, y, ‘bo--', label="Approxizate (Euler's sethoa)") plt.title(*selution by Suler's method") pit. claber Cx") pit. ylabel(*£(z)") plt.gridQ pit. legend (loc=' best") pit. show ()The required values are at x= 0.00, y=1.00000, x=0.10, y=0. 80000, x=0.20, y>0. 64008 _ ‘Solution by Euler's method “@- Approximateléulers method) Ey cry 20 00) 1s w 9.4 Modified Euler's method ‘The iterative formula is: (n: h (n) Bw = w+ Slee we) + fet). n= 0.12 where, y\") is the n' approximation to y- The first iteration will use Euler's method: yl = yo + hf (ro.u9). Solve y= —ky with (0) = 100 using modified Euler’s method at r= 100, by taking n= 25, lepout aumpy am ap isport matplotlib. pyplot as ple lef modified.euler(t, x0, yO, b, ay x © mp.2eros€me1) y = ap.seros(aed) x[0) = x0 yio) = yo for 4 im range(n) (sea) = xfa] +h ki =a k2=a- + m1) yli-1] = ylal + 0.8 + (et = ka) recurs myreture 0.01 * y # ODE dy/ax = -ky modified_ouler(f, x0, yO, b, 9) nt("The required value at x= 70.2F, yoZ0.S#*%(x(4l,y{4))) ne (*\n\n") |# Ploteing the recuite pit. plot (x, y, ‘bo-") pit. claber(?s') |pae. yrabor¢ry:) pit. titie(’ Solution of dy/dx = -ky using Modified Euler\'s Method ') plt.grid(True) pit. show () The required value at x= 100.00, y-37. 25290 9.5 Exercise: 1. Find y(0.1) by Taylor Series exapnsion when y’ = r— y*, y(0) Ans: (0.1) = 0.9138 2. Find y(0.2) by Taylor Series exapmsion when y’ = 2y—1, (0) = 1, = 0.1 Ans: (0.2) = 0.86 93. Evaluate by modified! Euler's method: y’ = (n(x + y),y(0) = 2 at r= 0(0.2)0.8. . Solve by modified Huler’s method: y! = r+ y, 4) = 1, h= 0.1.2 = 0(0.1)0.3. Aus: 1.1105, 1.2492, 1.4004LAB 10: Solution of ODE of first order and first de- gree by Runge-Kutta 4th order method and Milne’s predictor and corrector method 10.1 Objectives: 1. To write a python program to solve first order differential equation using 4th order Runge Kutta method. 2. To write a python program to solve first order differential equation using Milne's predictor andl corrector tothioxl, 10.2 Runge-Kutta method Apply the Runge Kutta method to find the solution of dy/de = 1+ (y/x) at (2) taking h=0.2. Given that y(1) = 2. tres sympy isport oct mumpy am ap aot Rungekutta(g,x0,h,y0,xa) x, yesymbols (x,y) f= lambd ity (ix, y) sg) xt=x0-h Y= (yo whole xteoam kei-bet(x0, yO) ke2-bef (x0+h/2, yOrk1/2) karhef(20h/2, yOrk2 2) <£(x0+h, y0°K3) = (4/6) Cd De 263k) ¥. append (yt) aprise (POS. af xt) ae 19.96 Ly) xo-xt reture mp, round (Y,2) Rungakatea('1s(y/x)" +0.2,2,2) array((2. , 2.62, 3.27, 3.95, 4.66, 5.39]) 10.3 Milne's predictor and corrector method Apply Milne's predictor and corrector method to solve dy/dr = rt + (y/2) at y(-l) Given that y(1)=2, y(1.1)=2.2156, v(1.2}=24649, y(L.3)=2.7514, Use corrector formula thrive. # Nilne's method to solve first orde! 4 Use corr er formula thrice yor?y1-2.2186 y2=2.4649 y3-2.7514 heo.d xi-x0-h xQ-x1rh xdex2sh x4ex3eh tol fz.y) returs x 2(y/2) yi0=#(20, yo) yitet(aa,yt) YD #(22 192) yiSet(x8,y3) yap-yO- (4/3) = (2eytt-yt2-2-y13) print@predicted value of y4 ie %3.3¢*Ky4p) ylaet(x@, yap); for a anew. 4) yao y2=Ch/3)> ytd prins€ corrected val yi3+ 42) of y4 after \t iteration Zé iv \t 23.5f\t '% Gyayd yidet Ces, ya): predicted value of y4@ is 3.079 corrected value of y4 after iteration 1 is 3.07940 corrected value of y4 after iteration 2 is 3.07940 corrected value of y4 after iteration 3 is 3.07940 In the next program, function will take all the inputs from the user and display the answer, Apply Milne’s predictor and corrector metho to solve dy/dr = ac? + (y/2) at y(la). Given that y(1)=2, y(1.1}=2.2156, ¥(1.2)=2.4649, v(1.3)=2.7511, Use corrector formula thrice, fron aympy sport + lof Malme(g,x0.h, yO. 91.92.93) x.yraymbole(' x.) ') frlasbdity(!x.y) .g) xiexOoh x2ex1oh x3ex2°h aod ylo=t(x0, yo) yitet Gayl) yA2et (x2, y2) yi3et (x3, y3) yAp~yO= (40h /3)° (Dey 4-y12+2-y13) prist(*pradieted value of y4",y4p) yldet Grd, yap) for 4 us range (t.4) yAry2> (h/ 3) ° (ybde de yt yt2) print(teorrected valum of y4 . iteration ld ‘it.y4)4x4, ya) Bey/2',1,0.1,2,2.2186,2.4649, 2.7514) yu Milne (*= predicted value of y4 3.0792733333333335 corrected value of y4, iteration 1 3.0793962222292224 corrected value of y4 , iteration 2 3.079398270370371 corrected value of y4 , iteration 3 3.079398304506173 predictor and corrector method to solve dy/dr =r —y? , y(0)}=2 obtain 0.2. Use Runge-Kutta method to calculate required initial values. Y-RungeKatta('x-y+*2',0,0.2,0,0.8) print(y values from Range ~Kutta zethod:',¥) Milne (*x-yee2!,0,0.2,¥10) ,¥i1],¥2),¥/31) y values from Runge -Kutta method: [0. 0.02 0.08 0.18 0.3 ] predicted value of y4 0.3042133333333334 corrected value of y4 , iteration 1 0.3047636165214815 corrected value of y4 , iteration 2 0.3047412758696499 corrected value of y4 , iteration 3 0.3047421836520892 10.4 Exercisi 1. Find y(0.1) by Runge Kutta method when y’ Ans: (0.1) = 0.91379 #0) 2. Evaluate by Runge Kutta method : y= log(e+y),y(0) = 2 at x = ((0.2)08. Ams: 2.155, 2.418, 2.587, 2.801 3. Solve by Milnes method: yf = r+ y, y()=1, b=0.1, Calculate y(0-4) — Calculate required initial values from Re nge Kutta method. Ans: L58i649219 97
You might also like
Advanced Engineering Mathematics 4th Ed by K. A. Stroud-1 PDF
PDF
92% (24)
Advanced Engineering Mathematics 4th Ed by K. A. Stroud-1 PDF
1,057 pages
Mth101 Lec 23 To 45 by Kinza Bilal - 3
PDF
90% (10)
Mth101 Lec 23 To 45 by Kinza Bilal - 3
120 pages
Mathslabmanual Vtu
PDF
100% (1)
Mathslabmanual Vtu
84 pages
G Stephenson - P M Radmore - Advanced Mathematical Methods For Engineering and Science Students-Cambridge University Press (1990) PDF
PDF
100% (2)
G Stephenson - P M Radmore - Advanced Mathematical Methods For Engineering and Science Students-Cambridge University Press (1990) PDF
267 pages
Mathematical Methods For Scientists and Engineers by Richard P Feynman
PDF
100% (1)
Mathematical Methods For Scientists and Engineers by Richard P Feynman
162 pages
Cse Math Lab
PDF
No ratings yet
Cse Math Lab
47 pages
LabManualEngMath2 52 98
PDF
No ratings yet
LabManualEngMath2 52 98
47 pages
U AJjyu
PDF
No ratings yet
U AJjyu
36 pages
Cse Lab 1
PDF
No ratings yet
Cse Lab 1
4 pages
Ii Sem Maths Lab Manual - KRS
PDF
No ratings yet
Ii Sem Maths Lab Manual - KRS
8 pages
Final II CSE Lab Manual
PDF
No ratings yet
Final II CSE Lab Manual
52 pages
Lab Manual-MatLab CSE
PDF
No ratings yet
Lab Manual-MatLab CSE
51 pages
EEE 231 Lecture
PDF
No ratings yet
EEE 231 Lecture
15 pages
II Sem MathDept Manual - Students (CS)
PDF
No ratings yet
II Sem MathDept Manual - Students (CS)
64 pages
Maths LAB Programs BMATS201
PDF
No ratings yet
Maths LAB Programs BMATS201
10 pages
Mathematics Lab
PDF
No ratings yet
Mathematics Lab
6 pages
CS Scheme of Evaluation-1 - 240712 - 112858
PDF
No ratings yet
CS Scheme of Evaluation-1 - 240712 - 112858
9 pages
Lab Manual Engineering Maths 2 VTU Python
PDF
86% (7)
Lab Manual Engineering Maths 2 VTU Python
134 pages
python
PDF
No ratings yet
python
24 pages
Sadler Specialist Unit 3 and 4
PDF
No ratings yet
Sadler Specialist Unit 3 and 4
368 pages
EM FORMULAS
PDF
No ratings yet
EM FORMULAS
6 pages
Maths 2 QB(Musa)Nov 24
PDF
100% (1)
Maths 2 QB(Musa)Nov 24
6 pages
Mathematics
PDF
No ratings yet
Mathematics
25 pages
Pre Calculus Pt1
PDF
No ratings yet
Pre Calculus Pt1
57 pages
Gamma and Beta Functions B S Grewal
PDF
No ratings yet
Gamma and Beta Functions B S Grewal
9 pages
MATLAB Unit 3 Part 1
PDF
No ratings yet
MATLAB Unit 3 Part 1
32 pages
Equations_for_exam (1)
PDF
No ratings yet
Equations_for_exam (1)
23 pages
M&C imp Questions
PDF
No ratings yet
M&C imp Questions
13 pages
Numerical Techniques in Electromagnetics With MATLAB, Third Edition by Matthew N.O. Sadiku PDF
PDF
No ratings yet
Numerical Techniques in Electromagnetics With MATLAB, Third Edition by Matthew N.O. Sadiku PDF
278 pages
Maths 3rd Internal
PDF
No ratings yet
Maths 3rd Internal
56 pages
11th KC Sinha Math Lesson 3
PDF
No ratings yet
11th KC Sinha Math Lesson 3
48 pages
Arihant Physics
PDF
0% (1)
Arihant Physics
22 pages
fdsgdst
PDF
No ratings yet
fdsgdst
104 pages
New Doc 08-15-2023 22.13
PDF
No ratings yet
New Doc 08-15-2023 22.13
28 pages
NM Unit 1
PDF
No ratings yet
NM Unit 1
30 pages
Class 12 Maths All Chapter Formula
PDF
No ratings yet
Class 12 Maths All Chapter Formula
36 pages
Notes
PDF
No ratings yet
Notes
166 pages
Dashrath Nandan NMOUP (Complete) Notes
PDF
No ratings yet
Dashrath Nandan NMOUP (Complete) Notes
54 pages
Dashrath Nandan NMOUP (Unit-1) Notes
PDF
No ratings yet
Dashrath Nandan NMOUP (Unit-1) Notes
16 pages
Maths 1st - formula sheet
PDF
No ratings yet
Maths 1st - formula sheet
30 pages
maths
PDF
No ratings yet
maths
25 pages
M2 Notes
PDF
No ratings yet
M2 Notes
64 pages
MATHS CLASS 12 FORMULAS
PDF
No ratings yet
MATHS CLASS 12 FORMULAS
7 pages
Geg 412 - Numerical Methods in Engineering
PDF
No ratings yet
Geg 412 - Numerical Methods in Engineering
10 pages
Maths P1
PDF
No ratings yet
Maths P1
29 pages
رياضيات 4 - 123537-1
PDF
No ratings yet
رياضيات 4 - 123537-1
263 pages
Mathematics Assignment 1
PDF
No ratings yet
Mathematics Assignment 1
21 pages
(Ebook-Pdf) - Mathematics - Alder - Multivariate Calculus
PDF
No ratings yet
(Ebook-Pdf) - Mathematics - Alder - Multivariate Calculus
197 pages
Ch6 Multiple Integrals
PDF
No ratings yet
Ch6 Multiple Integrals
49 pages
MATH1510 Lecture Notes
PDF
No ratings yet
MATH1510 Lecture Notes
134 pages
Fourier Analysis
PDF
No ratings yet
Fourier Analysis
23 pages
00 Math 1 - Course Notes - Chap 1-5
PDF
No ratings yet
00 Math 1 - Course Notes - Chap 1-5
22 pages
Matrix 001
PDF
No ratings yet
Matrix 001
24 pages
ELE00038C 2023 24 Part I
PDF
No ratings yet
ELE00038C 2023 24 Part I
166 pages