2.1 Write a new float function called lookup for your interp.cpp file that takes two float arrays and a float number as arguments. The first array will contain r; and the second will contain the...


only need answer for 2.2


2.1 Write a new float function called lookup for your interp.cpp file that takes two float<br>arrays and a float number as arguments. The first array will contain r; and the second will<br>contain the corresponding y; values. The float number given is the x value for which an<br>1<br>interpolated y is needed. You will need to write code to locate the index, i, such that x; <<br>I < Li+1. Keep your code general, without making any assumptions about the values, ri, other<br>than that they are increasing order.<br>Remember to do something appropriate if r has a bad value. You may find that just 3<br>arguments to the function lookup is not enough to do this. You probably want to test your<br>function with some prints at this stage just to make sure the index chosen is correct (but don't<br>leave those prints in the final version).<br>2.2 If you can assume that the x; values are uniformly spaced and you know the spacing,<br>is there a fast and simple way to find the right index? Note: Don't change your code.<br>

Extracted text: 2.1 Write a new float function called lookup for your interp.cpp file that takes two float arrays and a float number as arguments. The first array will contain r; and the second will contain the corresponding y; values. The float number given is the x value for which an 1 interpolated y is needed. You will need to write code to locate the index, i, such that x; < i="">< li+1.="" keep="" your="" code="" general,="" without="" making="" any="" assumptions="" about="" the="" values,="" ri,="" other="" than="" that="" they="" are="" increasing="" order.="" remember="" to="" do="" something="" appropriate="" if="" r="" has="" a="" bad="" value.="" you="" may="" find="" that="" just="" 3="" arguments="" to="" the="" function="" lookup="" is="" not="" enough="" to="" do="" this.="" you="" probably="" want="" to="" test="" your="" function="" with="" some="" prints="" at="" this="" stage="" just="" to="" make="" sure="" the="" index="" chosen="" is="" correct="" (but="" don't="" leave="" those="" prints="" in="" the="" final="" version).="" 2.2="" if="" you="" can="" assume="" that="" the="" x;="" values="" are="" uniformly="" spaced="" and="" you="" know="" the="" spacing,="" is="" there="" a="" fast="" and="" simple="" way="" to="" find="" the="" right="" index?="" note:="" don't="" change="" your="">

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here