User Tools

Site Tools


gibson:teaching:fall-2014:math445:hw4

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
gibson:teaching:fall-2014:math445:hw4 [2014/10/07 19:17]
gibson
gibson:teaching:fall-2014:math445:hw4 [2014/10/10 09:33] (current)
gibson
Line 11: Line 11:
 **Problem 5:** Write a function ''​cartesian2polar''​ that converts Cartesian coordinates ''​x,​y''​ to polar coordinates ''​r,​ theta''​. Use it to compute the polar coordinates of ''​x=2,​ y=3''​. Hint: use the arctangent function ''​atan''​ to compute ''​theta''​ from ''​x''​ and ''​y''​. **Problem 5:** Write a function ''​cartesian2polar''​ that converts Cartesian coordinates ''​x,​y''​ to polar coordinates ''​r,​ theta''​. Use it to compute the polar coordinates of ''​x=2,​ y=3''​. Hint: use the arctangent function ''​atan''​ to compute ''​theta''​ from ''​x''​ and ''​y''​.
  
-**Problem 6:** Are there any values of ''​x,​y''​ for which your function from problem 4 fails? Try ''​(x,​y) = (-1,-1)''​''​(x,y(1,0)''​and ''​(x,y) = (-1,​0)''​. ​ Revise ''​cartesian2polar''​ function to fix these the problems these examples point out using ''​if-else''​ statements, so that your function gives correct ''​r,​ theta''​ values for all ''​x,​y''​ values.+**Problem 6:** Are there any values of ''​x,​y''​ for which your function from problem 4 fails? Try these values of ''​(x,​y)''​''​(1,0)(-1,0), (0,​0)''​. ​ Revise ''​cartesian2polar''​ function to fix these the problems these examples point out using ''​if-else''​ statements, so that your function gives correct ''​r,​ theta''​ values for all ''​x,​y''​ values.
  
 **Problem 7:** Write a ''​tempconvert''​ function that converts a temperature in any of C, F,or K units and converts it to any desired units. The function should take a single input argument ''​t''​. It should then prompt the user for the units of ''​t''​ using an ''​input''​ statement, prompt again for the desired units of the output, print a statement using ''​fprintf''​ of the form ''​67 F is equivalent to 292.594 K''​ (where the numbers and units depend on the input values), and then return the numerical value of the temperature in the desired output units. If the input temperature is below absolute value, the program should print an error message and return absolute zero in the desired units. ​ **Problem 7:** Write a ''​tempconvert''​ function that converts a temperature in any of C, F,or K units and converts it to any desired units. The function should take a single input argument ''​t''​. It should then prompt the user for the units of ''​t''​ using an ''​input''​ statement, prompt again for the desired units of the output, print a statement using ''​fprintf''​ of the form ''​67 F is equivalent to 292.594 K''​ (where the numbers and units depend on the input values), and then return the numerical value of the temperature in the desired output units. If the input temperature is below absolute value, the program should print an error message and return absolute zero in the desired units. ​
  
  
gibson/teaching/fall-2014/math445/hw4.txt ยท Last modified: 2014/10/10 09:33 by gibson