MrAbbas 0 Newbie Poster

Hello there,

I'm writing a simple code to make a n*4 matrix .. first i filled it with zeroes

x0 = input("Please enter x0 = ")

h = input("Please define step size h = ")


s = input("Please specifiy the point at which you need the solution y(x) >> ")


n = (s*1.0)/h
n = int(n)


x = [[0]*4]*n


for i in range(n):
    print x[i][0],x[i][1],x[i][1],x[i][3]


for i in range(n):
    x[i][0]=x0
    x[i][1]=x0+(0.5*h)
    x[i][2]=x0+(0.5*h)
    x[i][3]=x0+h
    print x0
    x0+=h
    
    
    
 
for i in range(n):
    print x[i][0],x[i][1],x[i][1],x[i][3]

the output is something like this

Please enter x0 = 0
Please define step size h = .1
Please specifiy the point at which you need the solution y(x) >> .2
0 0 0 0
0 0 0 0
0
0.1
0.1 0.15 0.15 0.2
0.1 0.15 0.15 0.2

It should actually be

Please enter x0 = 0
Please define step size h = .1
Please specifiy the point at which you need the solution y(x) >> .2
0 0 0 0
0 0 0 0
0
0.1
0 0.05 0.05 0.1
0.1 0.15 0.15 0.2

I appeciate your help ...