Message Boards Message Boards

0
|
5160 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Finite difference method

Posted 9 years ago

I implement the following FINITE DIFFERENCE SCHEME in Mathematica but I do not get the right answer ( highlighted column in the table). Kindly help me get the right answer.

enter image description here

enter image description here

enter image description here

In[1]:= v = 1; m = 10; h = 0.1; t = 0.1; k = 0.00001; jj = 10000; r = \
0.001;

In[2]:= t = 
  Table[w[i, 0] = Exp[(Cos[\[Pi]*i*h] - 1)/(2 Pi*v)], {i, 0, m}] // N;

In[3]:= t1 = 
  Table[w[0, j + 1] == (1 - 2 r) w[0, j] + 2 r*w[1, j], {j, 0, jj}];

In[4]:= t2 = 
  Table[w[m, j + 1] == (1 - 2 r) w[m, j] + 2 r*w[m - 1, j], {j, 0, 
    jj}];

In[5]:= t3 = 
  Table[w[i, j + 1] == (1 - 2 r) w[i, j] + r*w[i + 1, j] + 
     r*w[i - 1, j], {i, 1, m - 1}, {j, 0, jj}];

In[6]:= t4 = Flatten[{t1, t2, t3}];

In[7]:= s = Solve[t4];

In[8]:= vv = Table[w[i, 1000], {i, 0, m}]; ss = vv /. s // Flatten

Out[8]= {0.985501, 0.978726, 0.959284, 0.929645, 0.893389, 0.854581, \
0.817182, 0.784618, 0.759545, 0.743798, 0.738435}

In[9]:= ans = 
 Table[-((ss[[i + 1]] - ss[[i - 1]])/ss[[i]])/h, {i, 2, 10}]

Out[9]= {0.267864, 0.511634, 0.70882, 0.840226, 0.891744, 0.856148, \
0.734593, 0.537418, 0.283805}
POSTED BY: Imran Khan

enter image description here

POSTED BY: Simon Cadrin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract