Results 1 to 10 of 12

Thread: how do you solve a system of linear equations in ThinBasic?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    hi Bob and Dan
    Bob, Octave does much beter than thinBasic, Dan, I did change the script to make it work.
    anyway, you can also drop the first column in the matrix and just make the first coefficient = 1,
    (also decrease the size of the dimensions by one) the rest of the coefficients will differ
    slightly because of this change, but it approximates the gamma function almost as well, (it needs to be checked).

    example thinBasic script, look carefully for the changes.
    Uses "console"
    Uses "math"
    Const n = 6 
    Dim As Ext g = 5 
    Dim As Ext a(n,n), b(n,n), c(n,1) 
    Dim As Integer i, j 
    'for n = 6, the following sets up matrix a as: 
    ' [[ 1,   1/2, 1/3, 1/4,  1/5,  1/6 ] 
    ' [  1/2, 1/3, 1/4, 1/5,  1/6,  1/7 ] 
    ' [  1/3, 1/4, 1/5, 1/6,  1/7,  1/8 ] 
    ' [  1/4, 1/5, 1/6, 1/7,  1/8,  1/9 ] 
    ' [  1/5, 1/6, 1/7, 1/8,  1/9,  1/10 ] 
    ' [  1/6, 1/7, 1/8, 1/9,  1/10, 1/11 ]] 
     
    For i=1 To n
                           '<< note the change 
      For j=1 To n  '<< note the change
        a(i,j)=1/(i+j-1)  '<< note the change
      Next
    Next
    For i=1 To n 
      c(i,1) = Factorial(i-1)/((i+g-0.5)^(i-0.5)/Exp(i+g-0.5)*Sqr(2*M_PI))-1 '<< note the change
    Next
    MAT b() = INV(a()) 
    MAT a() = b() * c()
    Console_WriteLine "C( 1) = 1" 
    For i=1 To n 
      Console_WriteLine "C("&Str$(i+1)&") = "&a(i,1) 
    Next 
    Console_WriteLine "All done. Press any key to finish"
    Console_WaitKey
    
    here are the coefficients as calculated with Maple
    c[0] := 1
    c[1] := 76.180091728331374539146745
    c[2] := -86.505320289513654614503042
    c[3] := 24.014097921606006186204527
    c[4] := -1.2317386147754424755938420
    c[5] := .120745388047503859955038e-2
    c[6] := -.4868518292851569517614e-5
    Last edited by jack; 15-08-2011 at 02:34.

Similar Threads

  1. operating system in thinbasic architecture ?
    By ioptic in forum thinBasic General
    Replies: 8
    Last Post: 14-01-2009, 23:53
  2. New advertising system in thinBasic community forum
    By ErosOlmi in forum Web and Forum
    Replies: 3
    Last Post: 04-08-2008, 18:07

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •