Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 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. values = []
  13. column = Dict()
  14.  
  15. # Creating the first column
  16. while n < Decimal(0.5)
  17. column[n] = a + b*n^1 + c*n^2 + d*n^3
  18. n = n + Decimal(0.02)
  19. end
  20.  
  21. # Add the first column to the array of values
  22. push!(next, column)
  23.  
  24. # Starting an infinite loop
  25. while true
  26. n = Decimal(-0.5)
  27. column = Dict()
  28.  
  29. # Creating the n'th column
  30. while n < Decimal(0.5)
  31. index = string(n)
  32. lastIndex = string(n-Decimal(0.02))
  33. nextIndex = string(n+Decimal(0.02))
  34. column[index] = values[end][index] + (values[end][lastIndex]*phi - 2*values[end][n]*phi + values[end][nextIndex]*phi)
  35.  
  36. if values[end][n] == values[end][lastIndex]
  37. break
  38. end
  39.  
  40. n = nextIndex
  41. end
  42.  
  43. if values[end][string(n)] == values[end][string(n-Decimal(0.02))]
  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