Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ######
- #Autor: Matuesz Wierzbicki
- ######
- using(Gadfly)
- function zad5()
- d_y = Int64[]
- i = 1
- while i < 41
- push!(d_y, i)
- i += 1
- end
- #tablica wypelniona kolejnymi liczbami z zakresu 1- 40
- #x_n+1 = (x_n)^2 + c, gdzie n = [1,2,3,...,]
- #1) c = -2 x_0 = 1
- c = -2
- x0 = 1
- d_x = collect(calcIter(40, x0, c))
- some_plot = plot(x = d_y, y = d_x ,
- Guide.XLabel("Index"), Guide.YLabel("Result"))
- c = -2
- x0 = 2
- d_x = collect(calcIter(40, x0, c))
- some_plot = plot(x = d_y, y = d_x ,
- Guide.XLabel("Index"), Guide.YLabel("Result"))
- c = -2
- x0 = float64(1.99999999999999)
- d_x = collect(calcIter(40, x0, c))
- some_plot = plot(x = d_y, y = d_x ,
- Guide.XLabel("Index"), Guide.YLabel("Result"))
- c = -1
- x0 = float64(1)
- d_x = collect(calcIter(40, x0, c))
- some_plot = plot(x = d_y, y = d_x ,
- Guide.XLabel("Index"), Guide.YLabel("Result"))
- c = -1
- x0 = float64(-1)
- d_x = collect(calcIter(40, x0, c))
- some_plot = plot(x = d_y, y = d_x ,
- Guide.XLabel("Index"), Guide.YLabel("Result"))
- c = -1
- x0 = float64(0.75)
- d_x = collect(calcIter(40, x0, c))
- some_plot = plot(x = d_y, y = d_x ,
- Guide.XLabel("Index"), Guide.YLabel("Result"))
- c = -1
- x0 = float64(0.25)
- d_x = collect(calcIter(40, x0, c))
- some_plot = plot(x = d_y, y = d_x ,
- Guide.XLabel("Index"), Guide.YLabel("Result"))
- #some_plot = plot(x = calc(4, x0, c))
- #draw(PNG("myplot.png", 6inch, 3inch), some_plot)
- end
- function calcIter(n, x_0, c)
- A = Float64[]
- j = 1
- println(A)
- i = 2
- push!(A, x_0)
- while i <= n
- temp = A[i-1]
- push!(A, temp^2 + c)
- i += 1
- end
- return A
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement