Google Answers Logo
View Question
 
Q: math problems solution ( No Answer,   4 Comments )
Question  
Subject: math problems solution
Category: Computers
Asked by: ted1923-ga
List Price: $2.00
Posted: 15 Jun 2004 15:46 PDT
Expires: 15 Jul 2004 15:46 PDT
Question ID: 361588
I am looking for BASIC computer language program to solve simultaneous
equations of 5 or more unknowns

Clarification of Question by ted1923-ga on 21 Jun 2004 06:23 PDT
saem aero-ga, thanks for excellent tip of june 17 . I tried your
suggestion of substituding Q for A ,unfortunately it produced the same
error message:`Error  6 "Attempted to use avariable that was not
added"  `"attempted to use the same name for a nuneric variable and a
character variable" ` "attempted to use an array name subscript that
was not declared" this error message for statements #33,41 and 56.  
Error 5 :~ "the argument is outsidethe input range of commands and
functions requiring arguments." ~ "the subscript in the array is
ouside the input range" ~ :attempted to specify two arrays woith the
same name but different subscripts"  for statement #38

Clarification of Question by ted1923-ga on 21 Jun 2004 07:39 PDT
saem aero-ga, the program as shown is intended to be used on a
radioshack TRS 80 PC-1 pocket computer it works fine when used on it .
if i download the same program on a radio shack PC-5 or PC-6 it
produces the errors. I am told that the PC-6 is a beefier version of
the 5 and it uses "superset of BASIC", other than  that I know no
more. except that the PC-1 is made by Sharp and the PC-5 and 6 are
made by Casio. neither of whom can help me with any info (too old)

Request for Question Clarification by hedgie-ga on 14 Jul 2004 01:34 PDT
Those programs in BASIC do exist, but it may take more then $2 to find them.

I look at:,  Radio Shack TRS-80 Pocket Computer
 ... The TRS-80 PC-1 is the first-ever BASIC-programmable pocket-sized
computer! It's actually the Sharp PC-1211, sold by Radio Shack in the
US. ...
oldcomputers.net/trs80pc1.html 

and wonder if you need  to use that machine.
 If I recall, it had only integer
math. Would a modern calculator do?

Clarification of Question by ted1923-ga on 14 Jul 2004 05:22 PDT
THE PROGRAM i have shown below (it begins with: 1:"PRINT"SIMULTANEOUS
EQUATIONS"") will run very well on the radio shack PC-1. I was able to
down load the same program onto a radio shack PC-6 ( which is really a
Casio FX795P). it is on this PC-6 that the error messages described
elsewhere on this report appear. now i understand thePC-6 uses
"superset basic lang..I'm quoting some one on that... my question is.
what must i do to make the program which works fine on the PC-1 work
on the PC-6.  when you say it takes more than $2.00 to solve this
riddle ,what does it take?

Request for Question Clarification by hedgie-ga on 15 Jul 2004 05:51 PDT
Well - these are very rough estimates-
other people may differ in their evaluation

1) to find a program for solving N linear equation in standard Basic .. $20
2) to figure out old Basic for PC-1211 one would have to get a manual or
    borrow such machine - about $100. 
     If   PC-1211 would run extension of the one on PC-1, it would not
complain, so one would have to re-write usual program to this strange
BASIC.
3) To modify  program shown at comment
    "this is all very interesting ,i suppose .."
   to make it work - about $200 - on the best effort basis.
    The reason for that is that,  having a cursory look at it, and
 being quite familiar with standard
    BASIC, but not this version of it, I doubt it ever did work. It does not
    look like Gaussian algorithm and it looks like it may work for some 
    values and crash for others. I assume : is statement separator and it
    is simulating 2D arrays by 1D array - but not in a general way.
 Did you ever tested in for N>10 (N being number of equations)?

My suggestion is, if you need to use this particular calculator,  contact
Casio or find some users club, like may be this one
http://www.tek-tips.com/viewthread.cfm?spid=740&newpid=740&sqid=566367
   
It is unlikely that someone not used to this strange BASIC would want to
deal with program which loos this strange.

Hedgie
Answer  
There is no answer at this time.

Comments  
Subject: Re: math problems solution
From: saem_aero-ga on 16 Jun 2004 11:38 PDT
 
I would recommend a google search for the algorithm called "gaussian elimination".


Here is a FORTRAN subroutine i wrote a long time ago which performs
guassian elimination.  Note you must set up your equation in the form
Ax=B.

If you want to be really efficient make one for LU decomp.  I have a
LU decomp algorithm but I can't find it.

Anyway a quick translation to your basic language from FORTRAN should
solve ur little problem =)



!gauss elimination - This algorithm is verified but is not yet robust.
!the diagonal elements must be non-zero..

subroutine gauss(A, U, Q, n)
integer, intent(in) :: n !matrix size.
real, intent(inout) :: A(1:n,1:n)  !coefficient matrix.
real, intent(inout) :: Q(1:n)  !source term.
real, intent(out) :: U(1:n)  !return this solution to be returned by
the subroutine.
real :: multiply, summer

integer :: baserow,i,j,k


!temperar variables to see if this works:

baserow = 0  !this assumes that element A(1,1) is NOT zero.
if (A(1,1) == 0)then
  write(*,*) "ERROR on baserow forumlation A(1,1)==0"
end if

!this loop has been varified to change Q and A to proper matrix.
do j=1,n-1!j is column
  baserow = j
  if(A(baserow,j)==0)then
    write(*,*) "ERROR, divide by zero on multiply formulation"
  end if
  !forumate the multiplyer.
  do i = j+1,n !is row
    multiply = A(i,j)/(A(baserow,j))
    A(i,j) = 0 !explicitly known that this is zero.
    do k=j+1,n !go through elements (modify row)
      A(i,k)=A(i,k)-multiply*A(baserow,k)
    end do
    !modify the Q matrix.
    Q(i)=Q(i)-multiply*Q(baserow)
  end do
end do
!The upper triangle matrix should now be formed.
!Need to have backward substitution in place next

!It is now time to solve for U(i->n) by backward substitution.
do i=n,1,-1
  summer = 0 !reset our summation tool
  do k=i+1,n
    summer = summer - A(i,k)*U(i)
  end do
  U(i)=(Q(i)+summer)/A(i,i)
end do

end subroutine gauss
Subject: Re: math problems solution
From: ted1923-ga on 17 Jun 2004 06:05 PDT
 
this is all very interesting ,i suppose , however it is all
incomprehensible to me. my limited ken ,i guess. I am looking for
something that looks more like the following,(although this program
works on one computer  the computer i would like to use has "variablE
identification problem" with statements with the *)

  1:print?simultaneous equations?
  2:input?want new equations??,H$
  3ifH$=?Y?then12
  4input?want changes to equations?,I$5
  5:if I$=?Y? then 50 : DEFM 99
  6: input?want to solve Equations??, J$
  7: if J$=?Y? then 30
  8:input ?want to list equations?? ,L$
  9: if L$=?Y? then 40
  10: input ?want anwers again?? ,Z$
  11: if Z$=?Y? then 38: end
  12: input ?N=??,F
  13: if >1 then 23
  22: goto 12
  23:for A=1 to F: Print?Row?;A
  24:forB=1 to F:G=7+8*A+B
  25: A(G)=0: input A(G)
  26: next B :G=7+A : A(G)=0:  input?=??,A(G)
  28 : next A:goto  2
  30: for A=1 to F-1: if A(7+9*A)=0 then 60
  31: for B=A+1 to F
  32: E= -A(7+8*B+A)/ A(7=9*A): A(7+8*B+A)
  33 : G=7+8*B+D : A(G)=A(A)+E*A(7+8*A+D) : next D
* 34 : A(7+B)= A(7+B)+E*A(7+A) : next B : next A
  36 :for A=F-1 to step-1 : G=7+A : for B=A+1 to F
  37 : A(G)=A(G)- A(7+B)*A(G+7*A+B) : next B :A(G)=A(G)/A(G+8*A) :  next A 
* 38: Beep 2 : for A=1 to F: G=7+A : print ?X(?;A;?)=   ? : ; A(G) : next A
  39 : print ?done? : goto 2
  40 : for A= 1 to F : for B=1 to F : G=7+8*A=B : print ? E(?;A;B;?)= ? ;A(G)
* 41 : next B : G=7+A : print ?C(?;A;?)=? : ; A(G)
  42 next A : goto 2
  50: input ?element??,C: goto 54
  51 : goto 2
  54 : A= int(C/10): B= C-10*A : if  A<1 then 50 : if A>F then 50
  55 : if B<0 then 50: if B>f then 50: G=7+8*A+B : if B=0 let G=7+A
* 56 : print ?E(?;A;B;?)=?;A(G)
  57 ? input ?new value??, A(G)
  58 goto 50
  60 : for B = A+1 to F :if A(7+8*B+A)=0 next B : beep
  61 : print ?unsolvable? : goto 2: forC=1 to F : G=A(7+A+C)
  62 : A(7+8*A+C)=A(7=8*B+C) : A(7+8*B+C)=G : next C
  64 : G=A(7+A) = A(7+B):A(7+B)=G : goto 31: for C=1 to F
Subject: Re: math problems solution
From: pne-ga on 17 Jun 2004 10:16 PDT
 
Compare http://answers.google.com/answers/threadview?id=361846
Subject: Re: math problems solution
From: saem_aero-ga on 17 Jun 2004 10:23 PDT
 
I'm curious, what basic program are you using to execute this code?

I was looking at lines such as the ones you marked with *, it looks to
me like you are trying to reference the variable 'A' in a improper
way.  Sometimes the program wishes to look at the variable as an array
(like x(1), x(2), x(3)) or sometimes it wishes to not look at it as an
array (x, y, z).

The lines you have * all have something in common.  They all have A
with and without the (). A() is a array and A without the () is a
scalar.  Its confusing when you mix the two in your program.  What you
might want to try, to get around this little problem is... to change:

All A to Q  (because Q is not used yet)
All A(....)  Leave this alone
All A(...A...)  if you find a A inside of A() then change the A to Q.

That might get around your variable identification problem.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy