0% found this document useful (0 votes)
25 views2 pages

Mat Lab test 4th sem

This document contains source code for various numerical methods including linear regression, bisection method, and Newton's divided difference interpolation. It provides a detailed implementation of algorithms to fit a second-degree curve, solve equations, and perform interpolation with user-defined inputs. The code is attributed to Dibyalochan Sahu and includes comments for clarity on the operations performed.

Uploaded by

bibekanaik656
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
0% found this document useful (0 votes)
25 views2 pages

Mat Lab test 4th sem

This document contains source code for various numerical methods including linear regression, bisection method, and Newton's divided difference interpolation. It provides a detailed implementation of algorithms to fit a second-degree curve, solve equations, and perform interpolation with user-defined inputs. The code is attributed to Dibyalochan Sahu and includes comments for clarity on the operations performed.

Uploaded by

bibekanaik656
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
You are on page 1/ 2
1X Regression for 2nd degree curve ‘linear regression source code by dibyalechan sahu( 12300690) ‘source code by dibyalochan sahu(123mm0690) rae whe 0.8 0.6 0.7 0.8 0.9.1.0 1.1 1.215 x= [-40 @ 40 88 12@ 160]; y= [658 748 890 830 880 900 898 870 850]; y= [6900 8100 9350 10500 11700 12800]; % Finding a11 summations Sx; sys8; S260; 5x30; SeHse; srye8; s2yH0; 5 5x2=05 Sxy=0; for Seda sie ox + x(D5 in Xfinding all summations Sanaa sxesx+x(i)5 saat a 7 a Ry co syssyty (i); Bete bea 5 XRD ADCS x24x(4)*x(4)3 2 to a aye ()*y (4) 5 oa ye end 1S taxasanyn 5 sx3ysn2,0n 5 anys 292]; % setting contfictent matrbs Be (sy 5 sey 3 Seay]; X setting the nates ‘Az[sx2,sx;sx,n]; Nsetting coefficient matrix ser\s’siwa 2874 Finding solutions [sxyssy]; %setting solution matrix Pee: tlie, ‘inv(A)*B; %finding solution € = 501(3); w-5(1); Xslope of line fame wn FE nes y= X62 a eA a c#S(2); Sy-intercept of Line forlscain Fordntf(*\n Best Fit Line: IPs) = wat) 6 WHEL 6 5 lng 8 ats of stat Sw for i=1: Plott, vs Cots x, ws *-1): x itte(‘and oogree conve FAttine')s isbel(2e"95 fed Tegencbaca Pointe") est Fit Curve; st=0s srt Plot (x,y,'0'sx,yy)5 oven 39/05 a_— CCID Or Feat + O(d)-ymer2 volune=10;, ate ate QC) - GMC" + Bx) + 0°25 R=(m*volune)/moles; Ua « (secary rt fprintf('\n Universal Gas Constant:%f",R)} fortnt®(‘\n Goodness of Fit :3F'4R 2 4600; % ba Be 0.518; X O/gre a 0.427 = R2* TeR.s / Pes Be o.oses Re Ty Ps FOG) Pe eT (ee) sel (Gee byt eC: A Define the non-ideat gas equation oF Meo nT ey eS eae hye + wetes Fee) PRE TL OB) Ca/ (2 (04) * SQreCTDDD: 1 Tapa crane munter of erations ee ip tato th sciraty of the rst f= input( “Enter the munber of Sterations: *)3 ek = Tepett eater the accurecy oF the rests “5 X Initial guesses for the bisection nethod frst = 0; Tinga Sacer te Snel pose = ‘hide ane == 0 1 stem 7 ato) C2 ‘low = Snput(‘Snter the lower bound of the interval: “5 ant Sohigh = input( ‘Enter the upper bound of the interval: “3 SF F(a tow)» FhSeN) «8 forint#("\ntnvalia interval. The function mst have opposite signs at x yocontwnso tod te bounds") real = 0) | at); ent 1 sta So) mia (low 6 ham) / 25 sCFCeamig)) ace || (high = xo) / 2 < ace HPA tow) * Foxmta) <0 high = monidy tow = xia A Gahigh ool /2> ace Se aman —) > ace ferietC veer of iterations ae rot sufficient to ahteve desired orintt("\ont (0) of the equation eng Neto: tghin Neti = 1.64 seni a): {in oNumbar of trations are not sufcint to achieve desired accuracy): ssa ‘Sonn oR of he equaton using Bicacton Mathod= % 6 mg. x mid ed Xauss seidal method with partial pivoting trial gauss elimination method a ar ‘clear clear all ae ea Fa a el in input ("ENTER THE NUMBER OF EQUATIONS: *) eats emery ee Xfprintf(‘enter elements of Xd row:',i) for tetin oneal secs) ACL Setnput( eter eLenent:") a et for keen el 1 acai) fprintf(‘eter elements of solution matrix: *) rst ae torte) Bring ‘Enter elenert:*) = vend an for ist:n ‘enpsa(en 3) aan Alen, j)*AC4,5) for Fain nine A Den D/A = rl crsim) Bayete seme) for teledin B(A)atemp; infeA(k, i) feces aga Pa ACK, j)=A(k, J)-mFPA(A,9) for Setzn = ca 0 =8¢0)-8(1 for Jetin end Foe end eee ear) a ere sf sa 2). = aps ravine a ‘sumesumea(i,3)*x(5). oA ns xG)-a()-sia sf lagen ‘end printf eo spsten 1s 1 canton: for Aedin = print("\n x(44)=86 4 3(4)) eniSfs the code by Newton's divided difference Satérpolation mettod this code 1s done by eibyalockan sahu(123nn8658) lear 811 fe Sngut( ‘enter ruber of data potnts:") for Satin x(i)eingut( enter value" yeideinput( enter y values: ona heaved: etme ad LUD Method for ja3:net cle fe te-ga ‘table(i, 3)*(table(i+t,j-1)-table(i, j-1))/(table(i+j-2,1)-table(i,a)); Clear ra Azinput("enter coeff. matrix:") ; hmv i of eh iin eer) Beinput( enter solution astrix:") ; =a nelength(B) 5 forget 1 Poroctabtes3)) {L U}slu(A) end Bdash= L\B; Ssimesumpteable(1, 402) XeU\Bdash} nt ‘Fprintf(‘interpolated value oF y=Xf" sum) disp(X)

You might also like