- 115 Views
- Uploaded on
- Presentation posted in: General

CS123 Quiz 2

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

CS123 Quiz 2

- HVAC system
- When t <=74, the fan rate is 2360;
- When t >= 86, the fan rate is 3870;

- (a) What is the formula when 74 < t < 86?
- Multiple ways to solve this problem
- The easiest way is to use solve function to solve linear equations of 2 unknowns
- solve({74*a+b=2360, 86*a+b=3870}, [a,b]);

- (b) What is the fan rate when the t is 75?
- Since 75 is between 74 and 86, we can define a function or procedure based on the formula from (a)
- a and b are known at this point
- use evalf() to approximate the result to a float point number
- To define a procedure
- fanRate:=proc(t) return evalf(a*t+b); end;

- Or, to define a function
- fanRate:=(t)->evalf(a*t+b);

- (c) Given a decimal point number, we need to round it up to the nearest multiple of then
- For example: 2380.8 => 2390

- In order to do so, we need to divide it by 10
- For example: 2380.8/10 => 238.08

- Then take its ceiling, to round it up(or down) to the nearest integer
- For example: ceil(238.08) => 239; or floor(238.08)=>238;

- At last, to multiple it by 10
- For example: 239 * 10 => 2390

- (d) use map function to easily apply the procedure you defined in (3) to the list of temperatures.
- Assume tempList is your list of temperatures
- map(C, tempList);

- (e)
- You already have the procedure definition so far, but you need to put the value of a and b back to the procedure, if you claim them before the procedure in (c) as I did.
- For example:
- result:=ceil((755/6*t-20855/3)/10)*10; (round up)
- Or floor((755/6*t-20855/3)/10)*10; (round down)