Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

H*curve fitting ko least square fit k name say

parha hua hai.iss main humny data ko dekhty huy ek formula


perdict krna hota hai.mathematica main iss k 2 methods hain ,
pehla yeh k ya tou aap terms bta dein given data ,
mm khud uss k coefficients calculate kry ga or data ko fit kr day
ga mgr zrori nhi hai k sab points main say curve guzray or iss main
error b kamm hoga jab k second method main hum formula develop
kr k dein gay or saath coefficeint b select kr k dein gay *L
H*first we will generate data*L
fp = Table@Prime@xD, 8x, 20<D
82, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71<

gp = ListPlot@fpD
70

60

50

40

30

20

10

5 10 15 20

H*this data is somehow parabolic .pehly hum iss pay linear fit lgye gain*L
? Fit

Fit@data, funs, varsD finds a least-squares fit to


a list of data as a linear combination of the functions funs of variables vars. ‡

ff = Fit@fp, 81, x<, xDH*here 1 and x are the initial


terms that we given to fit comman for making a function*L
- 7.67368 + 3.77368 x

pp = Plot@ff, 8x, 1, 20<D

60

50

40

30

20

10

10 15 20
2 15-Curve Fit ,Interpolation.nb

Show@gp, ppD
70

60

50

40

30

20

10

5 10 15 20

H*as some points are missing in this fit so we will increase the terms*L

ff = Fit@fp, 81, x, x ^ 2<, xD


- 1.92368 + 2.2055 x + 0.0746753 x2

pp = Plot@ff, 8x, 1, 20<D


70

60

50

40

30

20

10

10 15 20

Show@gp, ppD
70

60

50

40

30

20

10

5 10 15 20
15-Curve Fit ,Interpolation.nb 3

H*yahan pay humny koi formula nhi dia just terms


batyi hain or mm nay formula bna k return kr dia*L
H*yehi kaam hum ek oor method say b kr skty hain
jis main humny btana hota hai function kya hai*L

? FindFit

FindFit@data, expr, pars, varsD finds numerical values of the parameters pars that make expr give a
best fit to data as a function of vars. The data can have the form 88x1, y1, …, f1<, 8x2, y2, …, f2<, …<,
where the number of coordinates x, y, … is equal to the number of variables in the list vars. The
data can also be of the form 8 f1, f2, …<, with a single coordinate assumed to take values 1, 2, ….
FindFit@data, 8expr, cons<, pars, varsD finds a best fit subject to the parameter constraints cons. ‡

H*yahan pay parameters unknown coefficients hain*L

para = ff = FindFit@fp, 8a + b x + c x ^ 2<, 8a, b, c<, xD


8a ® - 1.92368, b ® 2.2055, c ® 0.0746753<

ff = a + b x + c x ^ 2 . para
- 1.92368 + 2.2055 x + 0.0746753 x2

pp = Plot@ff, 8x, 1, 20<D


70

60

50

40

30

20

10

10 15 20
4 15-Curve Fit ,Interpolation.nb

Show@gp, ppD
70

60

50

40

30

20

10

5 10 15 20

H*hum apni marzi say fit ya Findfit command use kr skty hain*L

H*exð49*L

para = FindFit@fp, 8a + b x + c x ^ 2<, 8a, b, c<, xD


8a ® - 1.92368, b ® 2.2055, c ® 0.0746753<

ff = a + b x + c x ^ 2 . para
- 1.92368 + 2.2055 x + 0.0746753 x2
15-Curve Fit ,Interpolation.nb 5

pp = Plot@ff, 8x, 1, 20<D


70

60

50

40

30

20

10

10 15 20

Show@gp, ppD
70

60

50

40

30

20

10

5 10 15 20
6 15-Curve Fit ,Interpolation.nb

H*exð50*L
H*liner or parabola oper ho chuka hai agr cube krna chahty hain tou x^3 b
add krein or agr quarta krna chahty hain tou x^4 add krein jessy oper
example main hua hai and tigonometric k liye neechy krny lgy hain*L
fp

82, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71<

ff = Fit@fp, 8Sin@xD, Cos@xD<, xD


8.02001 Cos@xD + 0.220441 Sin@xD

pp = Plot@ff, 8x, 1, 20<D

10 15 20

-5

gp
70

60

50

40

30

20

10

5 10 15 20
15-Curve Fit ,Interpolation.nb 7

Show@gp, pp, PlotRange ® AllD

60

40

20

5 10 15 20

H*jesa k nazar arha hai trigonometric terms say data pay


fit nhi horhi curve.agr sin or cos k argument main change laein
tou thore buht hogi like multiplyin wid 2 or dividing by 10*L
H*yeh b ho skta hai saath parabolic function b lein*L

ff = Fit@fp, 8Sin@xD, Cos@xD, x ^ 2<, xD


0.202261 x2 - 0.933186 Cos@xD - 0.793927 Sin@xD

pp = Plot@ff, 8x, 1, 20<D


80

60

40

20

10 15 20

Show@gp, pp, PlotRange ® AllD


80

60

40

20

5 10 15 20
8 15-Curve Fit ,Interpolation.nb

H*but phir b kuch zayada behtri nhi aayi*L

H*Exð51 is same as previous*L


H*now moving toward interpolation*L
H*First we will generate the data*L
Table@8x, Sin@xD<, 8x, 0, 2, 0.25<D
880., 0.<, 80.25, 0.247404<, 80.5, 0.479426<, 80.75, 0.681639<, 81., 0.841471<,
81.25, 0.948985<, 81.5, 0.997495<, 81.75, 0.983986<, 82., 0.909297<<

? Interpolation

Interpolation@8 f1, f2, …<D constructs an interpolation of the function values fi , assumed to correspond to x values 1, 2, … .
Interpolation@88x1, f1<, 8x2, f2<, …<D constructs an interpolation of the function values fi corresponding to x values xi .
Interpolation@888x1, y1, …<, f1<, 88x2, y2, …<, f2<, …<D constructs an interpolation of multidimensional data.
Interpolation@888x1, …<, f1, df1, …<, …<D constructs an interpolation that reproduces derivatives as well as function values.
Interpolation@data, xD find an interpolation of data at the point x. ‡

H*agr app simple dependent means function i value


dety ho tou woh x axis pay simple 1 ,2 and 3 lay ga*L
sin = Interpolation@%D

Interpolation::inhr : Requested order is too high; order has been reduced to 80<. ‡

InterpolatingFunction@881, 1<<, <>D

H*Number of data points kamm hain iss liye error aaya so hum zayada data
points use krein gay bcz by default interpolation ka order cubic hota hai*L

Table@8x, Sin@xD<, 8x, 0, 3, 0.25<D


880., 0.<, 80.25, 0.247404<, 80.5, 0.479426<, 80.75, 0.681639<, 81., 0.841471<,
81.25, 0.948985<, 81.5, 0.997495<, 81.75, 0.983986<, 82., 0.909297<,
82.25, 0.778073<, 82.5, 0.598472<, 82.75, 0.381661<, 83., 0.14112<<

sin = Interpolation@%D
InterpolatingFunction@880., 3.<<, <>D

sin@0.25D
0.247404

sin@0.2D
0.198692

Sin@0.2D
0.198669
15-Curve Fit ,Interpolation.nb 9

H*4 decimal points takk same hain digits


buit in command say or jo humny interpolate kia*L

H*iss function Hinterpolation say jo find kiaLpay hum


saray mathematical operations apply kr skty hain like *L
sin ^ 2

InterpolatingFunction@880., 3.<<, <>D2

NIntegrate@sin@sD, 8s, 0, Pi  2<D


0.999952

NIntegrate@Sin@sD, 8s, 0, Pi  2<D


1.

sin '@Pi  6D
0.865372

D@sin@xD, xD . x ® Pi  6  N
0.865372

D@Sin@xD, xD . x ® Pi  6  N
0.866025

H*Exð52*L
H*data given nhi hai so kuch b lay skty hain*L
d = 881.5, 2.1<, 82.3, 6.5<, 81.9, 4.3<, 81, 6.3<<;

i = Interpolation@dD
InterpolatingFunction@881., 2.3<<, <>D
10 15-Curve Fit ,Interpolation.nb

a = Integrate@i@kD, 8k, 1, 2.3<D


H*independent variable ki min value 1 or max value 2.3 hai*L
5.05736

u =.;

b = D@i@uD, uD;
u = 1.9;

Print@"The function =", i, "\nThe area under the curve=", a, "\nThe slope =", bD
The function =InterpolatingFunction @881., 2.3<<, <>D
The area under the curve =5.05736
The slope =7.40085

You might also like