Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. # Pkg.add("Decimals") # Not needed because this is on juliabox
  2. using Plots
  3. using Decimals
  4.  
  5. # Defining Variables
  6. a = Decimal(0.15)
  7. b = Decimal(0.2)
  8. c = Decimal(1)
  9. d = Decimal(-2)
  10. n = Decimal(-0.5)
  11. t = 0
  12. cs =
  13. phi = Decimal(0.5)
  14. values = []
  15. column = Dict()
  16.  
  17. # Creating the first column
  18. while n < Decimal(0.5)
  19. column[string(n)] = a + b*n^1 + c*n^2 + d*n^3
  20. n = n + Decimal(0.02)
  21. end
  22.  
  23. # Add the first column to the array of values
  24. push!(values, column)
  25.  
  26. # Starting an infinite loop
  27. while true
  28. n = Decimal(-0.5)
  29. column = Dict()
  30.  
  31. # Creating the n'th column
  32. while n < Decimal(0.5)
  33. index = string(n)
  34. previousIndex = string(Decimal(n-Decimal(0.02)))
  35. if previousIndex == "-0.00"
  36. previousIndex = "0"
  37. end
  38. nextIndex = string((n+Decimal(0.02)))
  39. if index == "-0.5" || index == "0.5"
  40. column[index] = a + b*n^1 + c*n^2 + d*n^3
  41. else
  42. column[index] = Decimal(values[end][index] + (values[end][previousIndex]*phi - 2*values[end][index]*phi + values[end][nextIndex]*phi))
  43. end
  44. n = n+Decimal(0.02)
  45. end
  46.  
  47. if length(values) > 1 && values[end-1] == values[end]
  48. break
  49. end
  50.  
  51. push!(values, column)
  52.  
  53. println(t)
  54. # println(values[end])
  55.  
  56. # k = collect(keys(values[end]))
  57. # v = collect(values(values[end]))
  58. # plot(k, v)
  59.  
  60. t = t + 4
  61. end
  62. println(values[1]["-0.48"])
  63. println("done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement