Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. # Pkg.add("Decimals") # Not needed because this is on juliabox
  2.  
  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. phi = Decimal(0.5)
  13. values = []
  14. column = Dict()
  15.  
  16. # Creating the first column
  17. while n < Decimal(0.5)
  18. column[string(n)] = a + b*n^1 + c*n^2 + d*n^3
  19. n = n + Decimal(0.02)
  20. end
  21.  
  22. # Add the first column to the array of values
  23. push!(values, column)
  24.  
  25. # Starting an infinite loop
  26. while true
  27. n = Decimal(-0.5)
  28. column = Dict()
  29.  
  30. # Creating the n'th column
  31. while n < Decimal(0.5)
  32. index = string(n)
  33. previousIndex = string(n-Decimal(0.02))
  34. nextIndex = string(n+Decimal(0.02))
  35. if index == "0.5"
  36. column[index] = Decimal(0.25)
  37. else
  38. column[index] = values[end][index] + (values[end][previousIndex]*phi - 2*values[end][n]*phi + values[end][nextIndex]*phi)
  39. end
  40. n = n+Decimal(0.02)
  41. end
  42.  
  43. if values[end]["0.48"] == values[end]["0.46"]
  44. break
  45. end
  46.  
  47. push!(values, column)
  48. t = t + 4
  49. end
  50.  
  51. println("done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement