Guest User

Untitled

a guest
Aug 5th, 2024
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. Ideally how it should be set out:
  2.  
  3. define f(x)
  4. return x^2
  5.  
  6. define Algorithm()
  7. sum ← 0
  8. a ← 1
  9. b ← 2
  10. h ← 0.5
  11. left ← a
  12. right ← a + h
  13.  
  14. while right ≤ b do
  15. arc ← sqrt(f(right) - f(left)^2 + h^2)
  16. sum ← sum + arc
  17. left ← left + h
  18. right ← right + h
  19. end while
  20.  
  21. print sum
  22.  
  23.  
  24.  
  25. Alternatively and acceptably:
  26.  
  27. define f(x)
  28. return x^2
  29.  
  30. sum ← 0
  31. a ← 1
  32. b ← 2
  33. h ← 0.5
  34. left ← a
  35. right ← a + h
  36.  
  37. while right ≤ b do
  38. arc ← sqrt(f(right) - f(left)^2 + h^2)
  39. sum ← sum + arc
  40. left ← left + h
  41. right ← right + h
  42. end while
  43.  
  44. print sum
Advertisement
Add Comment
Please, Sign In to add comment