Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. int verify_first_5 (double coefficients [], double x_endpoints [])
  2. {
  3. int low_val = evaluate_f_x(coefficients, x_endpoints[0]);
  4. int high_val = evaluate_f_x(coefficients, x_endpoints[1]);
  5. int x_switch = 0;
  6.  
  7. if (x_endpoints[0] >= x_endpoints[1])
  8. {
  9. printf("Data warning: switching x endpoints!");
  10. x_switch = x_endpoints[0];
  11. x_endpoints[0] = x_endpoints[1];
  12. x_endpoints [1] = x_switch;
  13. }
  14.  
  15. else if((low_val*high_val) > 0)
  16. {
  17. printf("Data error: function does not ");
  18. printf("have opposite signs on endpoints");
  19. return 0;
  20. }
  21. else if (low_val && high_val == 0)
  22. {
  23. return 1;
  24. }
  25. else
  26. {
  27. return 1;
  28. }
  29.  
  30. }
  31.  
  32.  
  33.  
  34.  
  35. /**************************************************************
  36. * Function verify_tolerance verifies tolerance inputs
  37. * Input:
  38. * Accepts an array of tolerances
  39. *
  40. * Output:
  41. * returns 1 if data provided is valid; otherwise returns 0
  42. *
  43. *
  44. ***************************************************************/
  45.  
  46. double verify_tolerance (double tolerances[])
  47. {
  48.  
  49. if (tolerances[0] <0 || tolerances[1] < 0)
  50. {
  51. return 0;
  52. }
  53. else
  54. {
  55. return 1;
  56. }
  57.  
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement