[TIB] Re: help!! ti-89


[Prev][Next][Index][Thread]

[TIB] Re: help!! ti-89



Yikes!!! Forgive me if my rewrite offends you; all that indirection was 
driving me nuts. All I did was replace the indirection/index expressions 
with matrices, which would be a very good thing to learn if you are going to 
be working with data arranged in this manner. I haven't used the solver 
often, so I need to look it up if I am going to have an answer this weekend.

For lack of a comment character, I'm using a double slash // in its place.. 
just replace them with the comment symbol (c) when you try to use it on your 
calc..

Tavis

>>Thank you all for answering my previous questions
>>In the following programm I use the FDM (finite difference method) to 
>>calculate the voltage in a net of a particular shape.
>>I don't know how to solve the system of linear equations
>>If you any idea please tell me!
>>Here is the code
fdm()
Prgm
ClrIO
Request "Mx=",mx,0
Request "Nx=",nx,0
Request "My=",my,0
Request "Ny=",ny,0
Request "internal V",v1,0
Request "external V",v2,0
expr(v1)»v1
expr(v2)»v2
expr(mx)»mx
expr(nx)»nx
expr(my)»my
expr(ny)»ny

// Note newMat(a,b) creates a matrix
// with a rows and b columns.
newMat(nx,ny)»f
newMat(nx,my-1)»eqa
newMat(mx-1,ny)»eqb

// In place of #("f"&string(i)&"_"&string(j)), I used f[i,j].
// Much easier to read, isn't it?
// I don't know if I cleaned up everything, so you might want
// to double-check it.

For i,1,nx
// Since j is always 1, there's no need to keep storing to j
// Just put it in the index
v1»f[i,1]
EndFor
For j,1,ny
v1»f[1,j]
EndFor
For i,mx,nx
v2»f[i,my]
EndFor
For j,my,ny
v1»f[mx,j]
EndFor
For j,1,my
f[nx-1,j]»f[nx+1,j]
EndFor
For i,1,mx
f[i,ny-1]»f[i,ny+1]
EndFor
For i,2,nx
For j,2,my-1
  (f[i+1,j]+f[i-1,j]+f[i,j+1]+f[i,j-1])/4=f[i,j]»eqa[i,j]
  Disp eqa[i,j]:Pause
EndFor
EndFor
For i,2,mx-1
For j,my,ny
  (f[i+1,j]+f[i-1,j]+f[i,j+1]+f[i,j-1])/4=f[i,j]»eqb[i,j]
  Disp eqb[i,j]:Pause
EndFor
EndFor
eqa[2,2]»bool1
For i,2,nx
For j,2,my-1
  bool1 and eqa[i,j]»bool1
EndFor
EndFor
eqb[2,my]»bool2
For i,2,mx-1
For j,my,ny
  bool2 and eqb[i,j]»bool2
EndFor
EndFor
solve(bool1 and bool2,???????????)»sol
disp sol
pause
EndPrgm
>>The difficult part is with the question marks.
>>Please note tha nx>mx and ny>my

I know I haven't answered your question, but keep in mind, there is a lot of 
theory behind this, and I don't exactly know the system you just built, and 
don't use solve very often. I'll try to help you out, but I need to study 
this program more closely first.


_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail




Follow-Ups: