Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Pkg.add("Decimals") # Not needed because this is on juliabox
- using Plots
- using Decimals
- # Defining Variables
- a = Decimal(0.15)
- b = Decimal(0.2)
- c = Decimal(1)
- d = Decimal(-2)
- n = Decimal(-0.5)
- t = 0
- cs =
- phi = Decimal(0.5)
- values = []
- column = Dict()
- # Creating the first column
- while n < Decimal(0.5)
- column[string(n)] = a + b*n^1 + c*n^2 + d*n^3
- n = n + Decimal(0.02)
- end
- # Add the first column to the array of values
- push!(values, column)
- # Starting an infinite loop
- while true
- n = Decimal(-0.5)
- column = Dict()
- # Creating the n'th column
- while n < Decimal(0.5)
- index = string(n)
- previousIndex = string(Decimal(n-Decimal(0.02)))
- if previousIndex == "-0.00"
- previousIndex = "0"
- end
- nextIndex = string((n+Decimal(0.02)))
- if index == "-0.5" || index == "0.5"
- column[index] = a + b*n^1 + c*n^2 + d*n^3
- else
- column[index] = Decimal(values[end][index] + (values[end][previousIndex]*phi - 2*values[end][index]*phi + values[end][nextIndex]*phi))
- end
- n = n+Decimal(0.02)
- end
- if length(values) > 1 && values[end-1] == values[end]
- break
- end
- push!(values, column)
- println(t)
- # println(values[end])
- # k = collect(keys(values[end]))
- # v = collect(values(values[end]))
- # plot(k, v)
- t = t + 4
- end
- println(values[1]["-0.48"])
- println("done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement