Advertisement
stevn

Lampe overfladeareal

Sep 18th, 2019
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #lavet af steven
  2.  
  3. lastvol = 0
  4.  
  5. grænse = 1005
  6.  
  7. f = function(x){ #f(x)
  8. y <- (-x^2+20*x)^(1/2)
  9. return(y)
  10. }
  11.  
  12.  
  13. t = function(x){ #f'(x)
  14. y <- 1/(2*(-x^2+20*x)^(1/2))*(-2*x+20)
  15. return(y)
  16. }
  17.  
  18.  
  19. p = function(x){ #f(x)
  20. y <- f(x)*(1+t(x)^2)^(1/2)
  21. return(y)
  22. }
  23.  
  24. h = seq(15.99, 20, 0.000001)
  25.  
  26.  
  27. for(i in 1:length(h)){
  28.  
  29.  
  30. vol = (integrate(p, 0, h[i]))
  31.  
  32. vol = vol$value*2*pi
  33.  
  34. print(vol)
  35.  
  36.  
  37.  
  38.  
  39.  
  40. if(lastvol < grænse & vol >= grænse){
  41. print("result!")
  42. print(h[i])
  43. break()
  44.  
  45. }
  46. lastvol = vol
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement