I am trying to write a small script to help my company out. I came across Julia on a web search naturally when looking for more speed. I am just getting my feet wet with programming so please be patient with me.
This is one piece of the code that I know is very inefficient, so any help is greatly appreciated. FYI, the final version will include pulling the initial variables from a SQL database that could include 100k records. So basically this code could be ran 100k times in the final version at any time (along with many more calculations). Please comment anywhere I could add more efficiency, because speed is absolutely critical. I have a spreadsheet I can provide that shows the methodology a little clearer if it would help. My main question though is why am I getting the BoundsError()... Thanks for all of the help. qi=3454.0 di=0.6 b=0.9 mnths=600 AI=(1/b)*((1-di)^-b-1) ai=AI/12 q(t)=qi/(1+b*ai*t)^(1/b) Q=[q(t-1) for t=1:3] a=((Q[2]/Q[3])^b-1)/b mOil=zeros(Float64,mnths) #Is it worth creating a function here? mOil[1]=(Q[1]^b/((1-b)*ai))*(Q[1]^(1-b)-Q[2]^(1-b)) mOil[2]=(Q[2]^b/((1-b)*a))*(Q[2]^(1-b)-Q[3]^(1-b)) R=zeros(Float64,mnths) R[1]=mOil[2]/(mOil[2]-mOil[1])+b for i=1:2 R[i+1]=R[1]-i*b end for i=3:600 #Getting a BoundsError() here #mOil[i]=mOil[i-1]*(R[i]/(R[i]-1)) R[i+1]=R[1]-i*b end