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

Onkar

The document is a Python script for curve fitting that prompts the user to input additional x and y values. It calculates various sums related to the x and y data, including the sum of products and squares. Finally, it computes the coefficients a and b for the linear equation y=ax+b and displays the resulting equation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Onkar

The document is a Python script for curve fitting that prompts the user to input additional x and y values. It calculates various sums related to the x and y data, including the sum of products and squares. Finally, it computes the coefficients a and b for the linear equation y=ax+b and displays the resulting equation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

#Onkar suryawanshi

#ROLL NO;S411071
#CURVE FITTING

n=int(input("enter the number of entries,n="))


#creation of the list
x=[5,10,15,20,25]
y=[17,26,32,45,56]
print("enter the value of x:")
for i in range (1,n+1,1):
x_data=int(input())
x.append(x_data)
print("the values of x are",x)
print("enter the value of y:")
for i in range (1,n+1,1):
y_data=int(input())
y.append(x_data)
print("the values of y are",y)

sum0=0
sum1=0
sum2=0
sum3=0
for i in range (0,n,1):
sum0=sum0+x[i]
sum1=sum1+y[i]
sum2=sum2+(x[i]*y[i])
sum3=sum3+(x[i]*x[i])

print("the sum of all x elements will be :",sum0)


print("the sum of all y elements will be :",sum1)
print ("the sum of the product x*y will be:",sum2)
print ("the sum of the product x*x will be:",sum3)
ds=float(sum0*sum0-n*sum3)
da=float(sum1*sum0-n*sum2)
db=float(sum0*sum2-sum1*sum3)
a=float(da/ds)
b=float(db/ds)
print ("the term a form the equation y=ax+b will be",a)
print ("the term a form the equation y=ax+b will be",b)
print ('the equation of straight line is y=%0.6fx+%0.6f'%(a,b))

You might also like