EasyManua.ls Logo

Texas Instruments TI-92+ - Page 396

Texas Instruments TI-92+
507 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
so the equations to be solved are
a + b + c = -1
4a + 2b + c = -11
9a + 3b + c = -29
To make the eventual routine more general-purpose, rewrite the equations to set the right-hand sides
equal to zero:
a + b + c + 1= 0
4a + 2b + c + 11 = 0
9a + 3b + c + 29 = 0
This routine, called solvemul(), returns the solutions as a list:
solvemul(eqlist,vlist)
func
©Solve multiple equations
©eqlist: list of expressions
©vlist: list of variables
©returns list of solutions in vlist order
©calls strsub() in same folder
©25dec99/dburkett@infinet.com
local s,vdim,k,t,vk,vloc,dloc
dim(vlist)vdim
©Build expression to solve
""s
for k,1,vdim-1
s&string(eqlist[k])&"=0 and "s
endfor
s&string(eqlist[vdim])&"=0"s
©Solve for unknown variables
string(expr("solve("&s&","&string(vlist)&")"))s
©Convert solution string to list
newlist(vdim)t
strsub(s,"and",":")s ©Change "and" to ":"
strsub(s," ","")s ©Strip blanks
for k,1,vdim
instring(s,string(vlist[k]))vloc
instring(s,":",vloc)dloc
if dloc=0: dim(s)+1dloc
mid(s,vloc+2,dloc-vloc-2)t[k]
endfor
©Return coefficient list
seq(expr(t[k]),k,1,vdim)
Endfunc
The input parameters are eqlist and vlist, where eqlist is a list of expressions to solve, and vlist is the
list of variables for which to solve. solvemul() assumes that the expressions in eqlist are equal to zero.
11 - 3

Table of Contents

Related product manuals