1.1 Given two points with co-ordinates (r1,y1) and (x2,y2), there is a unique straight line connecting them of the form y = mx + c, where m is the gradient and e is a constant. Write down expressions for the coefficients, m and c, in terms of the co-ordinates of the points. This is lingar internolation

Advanced Engineering Mathematics
10th Edition
ISBN:9780470458365
Author:Erwin Kreyszig
Publisher:Erwin Kreyszig
Chapter2: Second-order Linear Odes
Section: Chapter Questions
Problem 1RQ
icon
Related questions
Question

8.1

Imagine you have a table of data (x;, Y:) but you need to estimate values between those
specific points. The data might be growth rates, chemical reaction rates, profits or even exper-
imental data.
Thus you require an approximate function y(x) at for x values in the range covered by the x;
values provided. We can use an interpolation scheme to estimate values for y for intermediate
values of x that are between values listed in the table.
1.1 Given two points with co-ordinates (x1,y1) and (x2,y2), there is a unique straight line
connecting them of the form y = m + c, where m is the gradient and c is a constant. Write
down expressions for the coefficients, m and c, in terms of the co-ordinates of the points. This
is linear interpolation.
1.2 Write a float function called interpolate that takes two pairs of float coordinates and
an intermediate x value (a total of 5 float arguments: x1, yl, x2, y2 and x). The function
should return a y value based on the straight line fit of the points. Incorporate your function
into a file interp.cpp.
Consider if your function needs to check the input values in any way and add any checking
you consider necessary.
1.3 Testing: Write a short main function in a file called testinterp.cpp to test your
function. Note that you will need a Makefile that is able to combine the two files interp.cpp
and testinterp.cpp to generate the test program: testinterp.
Have your program print out (using cout) what your interpolate function returns. Run
your program for the following point and report the values:
(x1,y1)=(1, 8.57), (x2,y2)=(2, 10.28) and an r value of 1.25.
Transcribed Image Text:Imagine you have a table of data (x;, Y:) but you need to estimate values between those specific points. The data might be growth rates, chemical reaction rates, profits or even exper- imental data. Thus you require an approximate function y(x) at for x values in the range covered by the x; values provided. We can use an interpolation scheme to estimate values for y for intermediate values of x that are between values listed in the table. 1.1 Given two points with co-ordinates (x1,y1) and (x2,y2), there is a unique straight line connecting them of the form y = m + c, where m is the gradient and c is a constant. Write down expressions for the coefficients, m and c, in terms of the co-ordinates of the points. This is linear interpolation. 1.2 Write a float function called interpolate that takes two pairs of float coordinates and an intermediate x value (a total of 5 float arguments: x1, yl, x2, y2 and x). The function should return a y value based on the straight line fit of the points. Incorporate your function into a file interp.cpp. Consider if your function needs to check the input values in any way and add any checking you consider necessary. 1.3 Testing: Write a short main function in a file called testinterp.cpp to test your function. Note that you will need a Makefile that is able to combine the two files interp.cpp and testinterp.cpp to generate the test program: testinterp. Have your program print out (using cout) what your interpolate function returns. Run your program for the following point and report the values: (x1,y1)=(1, 8.57), (x2,y2)=(2, 10.28) and an r value of 1.25.
Expert Solution
steps

Step by step

Solved in 4 steps

Blurred answer
Recommended textbooks for you
Advanced Engineering Mathematics
Advanced Engineering Mathematics
Advanced Math
ISBN:
9780470458365
Author:
Erwin Kreyszig
Publisher:
Wiley, John & Sons, Incorporated
Numerical Methods for Engineers
Numerical Methods for Engineers
Advanced Math
ISBN:
9780073397924
Author:
Steven C. Chapra Dr., Raymond P. Canale
Publisher:
McGraw-Hill Education
Introductory Mathematics for Engineering Applicat…
Introductory Mathematics for Engineering Applicat…
Advanced Math
ISBN:
9781118141809
Author:
Nathan Klingbeil
Publisher:
WILEY
Mathematics For Machine Technology
Mathematics For Machine Technology
Advanced Math
ISBN:
9781337798310
Author:
Peterson, John.
Publisher:
Cengage Learning,
Basic Technical Mathematics
Basic Technical Mathematics
Advanced Math
ISBN:
9780134437705
Author:
Washington
Publisher:
PEARSON
Topology
Topology
Advanced Math
ISBN:
9780134689517
Author:
Munkres, James R.
Publisher:
Pearson,