The density of the potassium carbonate aqueous solution varies with temperature and concentration. In an experiment to determine the density of carbonate was considered constant temperature and concentration was varied , giving the table:

x y

4 1.0276

12 1.1013

20 1.1801

28 1.2652

38 1.3480

45 1.4120

Write Scilab function is to use the Lagrange interpolation polynomial of the first degree to interpolate the value given by the user using the values of the vectors " x " and "y" passed as parameter.

To improve the approximation , the function must find the two values of X closest and use them in the polynomial . For example , if the user indicates that he wants to interpolate the value 25 , the program must use X0 = X1 = 20 and 28.

Example of program execution :

à x = [4 , 12, 20 , 28, 38 , 45] à y = [1.0276, 1.1013 , 1.1801 , 1.2652 , 1.3480 , 1.4120 ] à lagrange (25, x , y)

X values that were used to interpolate are 20 and 28 The estimate of 25 is 1.2332875

à lagrange (15, x , y) X values that were used to interpolate are: 12 and 20

The estimate of 15 is 1.13085

à lagrange (50, x , y) can not get an estimated 50 .

à lagrange (2, x , y) can not get an estimated 2

Thank you for the opportunity to help you with your question!

in general, do not need to be licensed or pass any standardized (or governmentally regulated) certification tests in order to call themselves "programmers" or even "software engineers.

Please let me know if you need any clarification. I'm always happy to answer your questions.

Jun 14th, 2015

Are you studying on the go? Check out our FREE app and post questions on the fly!