Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. ######
  2. #Autor: Matuesz Wierzbicki
  3. ######
  4. using(Gadfly)
  5. function zad5()
  6.  
  7. d_y = Int64[]
  8. i = 1
  9. while i < 41
  10. push!(d_y, i)
  11. i += 1
  12. end
  13. #tablica wypelniona kolejnymi liczbami z zakresu 1- 40
  14.  
  15. #x_n+1 = (x_n)^2 + c, gdzie n = [1,2,3,...,]
  16. #1) c = -2 x_0 = 1
  17. c = -2
  18. x0 = 1
  19. d_x = collect(calcIter(40, x0, c))
  20. some_plot = plot(x = d_y, y = d_x ,
  21. Guide.XLabel("Index"), Guide.YLabel("Result"))
  22.  
  23.  
  24. c = -2
  25. x0 = 2
  26. d_x = collect(calcIter(40, x0, c))
  27. some_plot = plot(x = d_y, y = d_x ,
  28. Guide.XLabel("Index"), Guide.YLabel("Result"))
  29.  
  30. c = -2
  31. x0 = float64(1.99999999999999)
  32. d_x = collect(calcIter(40, x0, c))
  33. some_plot = plot(x = d_y, y = d_x ,
  34. Guide.XLabel("Index"), Guide.YLabel("Result"))
  35.  
  36. c = -1
  37. x0 = float64(1)
  38. d_x = collect(calcIter(40, x0, c))
  39. some_plot = plot(x = d_y, y = d_x ,
  40. Guide.XLabel("Index"), Guide.YLabel("Result"))
  41.  
  42.  
  43. c = -1
  44. x0 = float64(-1)
  45. d_x = collect(calcIter(40, x0, c))
  46. some_plot = plot(x = d_y, y = d_x ,
  47. Guide.XLabel("Index"), Guide.YLabel("Result"))
  48.  
  49. c = -1
  50. x0 = float64(0.75)
  51. d_x = collect(calcIter(40, x0, c))
  52. some_plot = plot(x = d_y, y = d_x ,
  53. Guide.XLabel("Index"), Guide.YLabel("Result"))
  54.  
  55.  
  56. c = -1
  57. x0 = float64(0.25)
  58. d_x = collect(calcIter(40, x0, c))
  59. some_plot = plot(x = d_y, y = d_x ,
  60. Guide.XLabel("Index"), Guide.YLabel("Result"))
  61. #some_plot = plot(x = calc(4, x0, c))
  62. #draw(PNG("myplot.png", 6inch, 3inch), some_plot)
  63.  
  64.  
  65. end
  66.  
  67.  
  68. function calcIter(n, x_0, c)
  69. A = Float64[]
  70. j = 1
  71. println(A)
  72. i = 2
  73. push!(A, x_0)
  74. while i <= n
  75. temp = A[i-1]
  76. push!(A, temp^2 + c)
  77. i += 1
  78. end
  79. return A
  80. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement