Παρασκευή 19 Ιουνίου 2026

Romberg Integration

 This program use a triangle array which start with one item.  Each step add another array of single value. Each array start with one item and append as we work more.

rsin() is sin() using radians (the sin() function use degrees).


'https://rosettacode.org/wiki/Numerical_integration/Romberg_integration#M2000_Interpreter

 https://en.wikipedia.org/wiki/Romberg%27s_method


Module Romberg_integration {
    function Romberg(func as lambda,lower,upper,steps,acc=1e-8) {
      h0= upper-lower
      s0= func(lower)+func(upper)
      single r[0][0]
      r[0][0]=s0*h0/2
      rr= 0
      n= 1
      for i=1 to steps
           ro= rr
         n= 2*n
         h= h0/n
         s=s0/2
         for j= 1 to n-1
            s+=func(lower+j*h)
         next
         f=1
         r[i][0] = s*h
         for k= 1 to i
            r1= r[i][k-1]
            r2= r[i-1][k-1]
            f*=4
            rr=(f*r1-r2)/(f-1)
            r[i][k]=rr
         next
         if Abs(rr-ro) < acc then exit for
      next
      =rr
    }
    print round(Romberg((lambda->rsin(number)),0,1,5),8)=0.45969769    ' true
    print round(Romberg((lambda->exp(number)),-3,3,5),6)=20.035749 ' true
}
Romberg_integration

Τετάρτη 10 Ιουνίου 2026

Αναβάθμιση του βιβλίου για τον προγραμματισμό με αντικείμενα

Κατεβάστε τη νεότερη έκδοση του Μ2000 από εδώ: https://github.com/M2000Interpreter/Environment/releases/tag/version14revision45

Υπάρχει το βιβλίο και το oop79.gsb το πρόγραμμα που περιέχει τα 97 προγράμματα του βιβλιου. Υπάρχει το Πρώτο που φτιάχνει τα χρώματα και τις γραμματοσειρές και ξεκινάει την Επίδειξη. Η Επίδειξη είναι ένα τμήμα που καλεί τα 97 τμήματα διαδοχικά. Με διάστημα εκτελούμε το επόμενο ενώ με άλλο πλήκτρο σταματάει η επίδειξη.

Σε κάποια προγράμματα πρέπει να κάνουμε κάτι για να τερματίσει.





Πέμπτη 4 Ιουνίου 2026

SubScript and SuperScript Numbers

This is an example to print subscript/superscript numbers.

Need the latest version or use @SubScript() and @SupScript() for calling simple functions

Module SupSub_Script_Example {
  If Mode<>22 then font "Arial New": Mode 22
  Locale 1033 ' works for 1032 too
  Print Part "A";SupScript(-12345.06789e-100)
  Print
  N=12
  Print Part "C";SubScript(N);"H";SubScript(2*N+2)
  Print
  Print Part "Rational = ";SupScript(123);"/";SubScript(456)
  Print
  Print Part "Just Subscript = A";SubScript(-12345.06789e-100)
  Print
  Function SubScript(x)
    local string r
    local s=""+x, i
    for i=1 to len(s)
      n=val(mid$(s,i,1))
      select case mid$(s,i,1)
      case "E"
        r+=chrcode$(0x1D07 ) '  chrcode$(0x1D49)
      case ","
        r+=","
      case "."
        r+="."  
      case "-"
        r+=chrcode$(0x208B)
      case "+"
        r+=chrcode$(0x208a)
      case else
        r+=chrcode$(0x2080+n)
      end select
    next
    =r
  End Function
  Function SupScript(x)
    local string r
    local s=""+x, i
    for i=1 to len(s)
      n=val(mid$(s,i,1))
      select case mid$(s,i,1)
      case "1"
        r+=chrcode$(0x00B9)
      case "2","3"
        r+=chrcode$(0x00B0+n)
      case "E"
        r+=chrcode$(0x1D31 ) '  chrcode$(0x1D49)
      case ","
        r+=chrcode$(0x02D2)
      case "."
        r+=chrcode$(0x22C5)    
      case "-"
        r+=chrcode$(0x207b)
      case "+"
        r+=chrcode$(0x207a)
      case else
        r+=chrcode$(0x2070+n)
      end select
    next
    =r
  End Function
}
SupSub_Script_Example