Advertisement
stevn

Untitled

Mar 22nd, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. f1 <- function(x) {
  2. fx <- 6-(-x^2+8*x+9)^(1/2)
  3. return()
  4. }
  5.  
  6. f2 <- function(x) {
  7. fx <- (-x^2+24*x-119)^(1/2)
  8. return()
  9. }
  10. step = 0.01
  11.  
  12. x1 = seq(0, 8, step)
  13.  
  14. x2 = seq(8, 16, step)
  15.  
  16. y1 = 6-(-x1^2+8*x1+9)^(1/2)
  17.  
  18. y2 = (-x2^2+24*x2-119)^(1/2)
  19.  
  20.  
  21. x = c(x1, x2)
  22.  
  23. y = c(y1, y2)
  24.  
  25. plot(x, y)
  26.  
  27. A = 0
  28.  
  29. for(i in 2:(length(x))){
  30. current = step*y[i]
  31.  
  32. A = A+current
  33.  
  34. if(A >= 10){
  35. break()
  36. }
  37. }
  38.  
  39. print(x[i])
  40. print(A)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement