[solved] any math guru here ?

General discussion for topics related to the FreeBASIC project or its community.
dafhi
Posts: 1641
Joined: Jun 04, 2005 9:51

Re: [solved] any math guru here ?

Post by dafhi »

my previous model did poorly on tests outside of -1 +1
this new version should last for a while :D

Code: Select all

/'
                    k
< ---- dk(0) ---- >|
           |       |<-- (2 steps)
           |<- dk(1/2) ->|
                   |<dk(2/2)>|

dk(1/2) = dk(0) * k^(1/2)

For example, k = 0.81 then k^(1/2) = 0.9
dk(0)=.81
dk(1/2) = .81*.9 = .729
dk(2/2) = .729*.9 = .81*.81

var sk = k^(1/steps)

now compute geometric sum
s = ( sk - sk^(steps+1)) / (1-sk)
'/

const     w = 960
const     h = 600

screenres w,h

sub result(yplot as integer, steps as integer, repeat as integer=8, k as single = 2/3)
  var sk = k^(1/steps)
  var s = (sk - sk^(steps*repeat+1)) / (1-sk) 'total distance
  var dk = (w - 1) / s 'window wid / distance
  k = 0
  for j as integer = 1 to repeat
    for i as integer = 1 to steps
      if i = 1 then
        circle (k, yplot), 2
      else:  pset (k, yplot)
      EndIf
      dk *= sk  'order important
      k += dk   '
    Next
  next: circle (k, yplot), 2
End Sub

var y = 10
for steps as integer = 2 to 15
  result y, steps
  y += 15
Next

sleep
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: [solved] any math guru here ?

Post by D.J.Peters »

@dafhi good job.

Joshy
Post Reply