[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LOGO-L> USA population



;Hello Everybody
;Here is a program to calculate the natural growth of the population
;of the USA; which is governed by the first order differential eqution
;     dp/dt = f(p,t) = a*p - b*p*p       
;Where a and b are the natural bioconstants for the american population 
;(found by statistical methods).
;The USA is still in the linear part of the curve while France (an old 
; nation) have reached the saturation part.At 2100 the USA would reach
;the natural maximum saturation.
;It is easy to adapt this simple code (based on Euler's approximation) 
;to solve any first order differential eqution knowing the initial 
;condition i.e. the value of the variable p0 at time t0.
;Best Regards
;Mhelhefny
;------------
to axis
pu setx -320 pd setx 320 label [time] pu setxy 0 -200 pd sety 230
label [population] home
end

to go
ts ct in_cond pr :s pr [] solve 0 type (se "press "any "key char 9) make "k rc
in_cond cs ht axis solve 1 pu setxy -180 -180 label :s
end

to in_cond
make "t0 1790 make "tf 2000 make "p0 3.9e6 make "p :p0 make "step 10
make "fun [(:p* .0313 - :p* :p* 1.58e-10)* :step]
make "s (se [Natural Population Growth in USA from] :t0 [to] :tf)
end

to solve :n
for [t :t0 :tf :step][
ifelse :n=0[type :t type char 9 pr round :p][setxy (:t- :t0) :p/1e6]
make "p :p+ run :fun]
end
;-------------
---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org.  Mail
questions about the list administration to logofdn@gsn.org.  To
unsubscribe send    unsubscribe logo-l    to majordomo@gsn.org.



Global SchoolNet Foundation - Linking Kids Around the World!
Copyright GSN - All Rights Reserved - Comments & Questions
Visit GSN's Global Schoolhouse for more exciting learning resources!
Search our Site - Home