Skip to content

Instantly share code, notes, and snippets.

@kenwebb
Last active March 28, 2020 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenwebb/42755a8b467c0596d81cae643e5aa615 to your computer and use it in GitHub Desktop.
Save kenwebb/42755a8b467c0596d81cae643e5aa615 to your computer and use it in GitHub Desktop.
19 Corvids (Crow) - Exponential Growth
<?xml version="1.0" encoding="UTF-8"?>
<!--Xholon Workbook http://www.primordion.com/Xholon/gwt/ MIT License, Copyright (C) Ken Webb, Sat Mar 28 2020 18:03:47 GMT-0400 (Eastern Daylight Time)-->
<XholonWorkbook>
<Notes><![CDATA[
Xholon
------
Title: 19 Corvids (Crow) - Exponential Growth
Description:
Url: http://www.primordion.com/Xholon/gwt/
InternalName: 42755a8b467c0596d81cae643e5aa615
Keywords:
My Notes
--------
March 28, 2020
This is the first in a possible series of workbooks related to Covid-19.
Each workbook will be named after a species of the Corvid family of birds (the Corvidae).
In this initial workbook, I will confirm exactly what is meant by "Exponential Growth", and will provide one or more examples.
Xholon act() code in existing Interest app (ref 5):
------------------------------------------
// time step multiplier
public static final int timeStepMultiplier = IIntegration.M_MINUTELY;
double balance = port[P_SavAcctBalance].getVal();
double iRate = port[P_InterestRate].getVal();
//for (int i = 0; i < timeStepMultiplier; i++) {
balance += (balance * iRate) / timeStepMultiplier;
//}
port[P_SavAcctBalance].setVal(balance);
// value after 10 timesteps: 271.828
References
----------
(1) https://en.wikipedia.org/wiki/Coronavirus_disease_2019
Coronavirus disease 2019 (COVID-19) is an infectious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2).
The disease was first identified in 2019 in Wuhan, the capital of China's Hubei province,
and has since spread globally, resulting in the 2019–2020 coronavirus pandemic.
(2) https://en.wikipedia.org/wiki/Corvidae
Corvidae is a cosmopolitan family of oscine passerine birds that contains the crows, ravens, rooks, jackdaws, jays, magpies, treepies, choughs, and nutcrackers.
In common English, they are known as the crow family, or, more technically, corvids.
Over 120 species are described.
The genus Corvus, including the jackdaws, crows, rooks, and ravens, makes up over a third of the entire family. Corvids are the largest passerines.
Corvids display remarkable intelligence for animals of their size and are among the most intelligent birds thus far studied.
(3) https://www.coursera.org/learn/covid-19/home/welcome
Science Matters: Let's Talk About COVID-19
by Imperial College London & Abdul Latif Jameel Institute for Disease and Emergency Analytics
(4) https://en.wikipedia.org/wiki/Exponential_growth
Exponential growth is a specific way that a quantity may increase over time.
It occurs when the instantaneous rate of change (that is, the derivative) of a quantity with respect to time is proportional to the quantity itself.
Described as a function, a quantity undergoing exponential growth is an exponential function of time, that is,
the variable representing time is the exponent (in contrast to other types of growth, such as quadratic growth).
If the constant of proportionality is negative, then the quantity decreases over time, and is said to be undergoing exponential decay instead.
In the case of a discrete domain of definition with equal intervals,
it is also called geometric growth or geometric decay since the function values form a geometric progression.
The formula for exponential growth of a variable x at the growth rate r, as time t goes on in discrete intervals (that is, at integer times 0, 1, 2, 3, ...), is
x t = x 0 ( 1 + r ) t {\displaystyle x_{t}=x_{0}(1+r)^{t}} x_{t}=x_{0}(1+r)^{t}
where x0 is the value of x at time 0.
This formula is transparent when the exponents are converted to multiplication.
For instance, with a starting value of 50 and a growth rate of r = 5% = 0.05 per interval, the passage of
one interval would give 50 × 1.051 = 50 × 1.05;
two intervals would give 50 × 1.052 = 50 × 1.05 × 1.05; and
three intervals would give 50 × 1.053 = 50 × 1.05 × 1.05 × 1.05.
In this way, each increase in the exponent by a full interval can be seen to increase the previous total by another five percent.
(The order of multiplication does not change the result based on the associative property of multiplication.)
Examples - Biology
The number of microorganisms in a culture will increase exponentially until an essential nutrient is exhausted.
Typically the first organism splits into two daughter organisms, who then each split to form four, who split to form eight, and so on
Because exponential growth indicates constant growth rate, it is frequently assumed that exponentially growing cells are at a steady-state.
However, cells can grow exponentially at a constant rate while remodeling their metabolism and gene expression.
A virus (for example SARS, or smallpox) typically will spread exponentially at first, if no artificial immunization is available.
Each infected person can infect multiple new people.
Examples - Finance
Compound interest at a constant interest rate provides exponential growth of the capital.
Difference equation
The difference equation
x t = a ⋅ x t − 1 {\displaystyle x_{t}=a\cdot x_{t-1}} x_{t}=a\cdot x_{{t-1}}
x(t) = a * x(t-1)
has solution
x t = x 0 ⋅ a t , {\displaystyle x_{t}=x_{0}\cdot a^{t},} x_{t}=x_{0}\cdot a^{t},
x(t) = x(0) * a^t
showing that x experiences exponential growth.
(5) existing Xholon apps
http://127.0.0.1:8888/Xholon.html?app=Interest&gui=clsc exponential
https://github.com/kenwebb/Xholon/blob/master/Xholon/src/org/primordion/dynsys/app/XhInterest.java
http://127.0.0.1:8888/Xholon.html?app=Fibonacci&gui=clsc not exponential
http://127.0.0.1:8888/Xholon.html?app=Gravity1&gui=clsc
]]></Notes>
<_-.XholonClass>
<PhysicalSystem/>
<!-- my existing Interest app -->
<InterestSystem/>
<SavingsAccountBalance/>
<Interest/>
<InterestRate/>
<!-- Bacteria project -->
<BacteriaSystem/>
<BacteriaCount/>
<Bacteria/>
<BacteriaGrowthRate/>
</_-.XholonClass>
<xholonClassDetails>
<!-- my existing Interest app
// ports
public static final int P_SavAcctBalance = 0;
public static final int P_InterestRate = 1;
-->
<Interest xhType="XhtypePureActiveObject">
<port name="port" index="0P_SavAcctBalance" connector="#xpointer(ancestor::InterestSystem/SavingsAccountBalance)"/>
<port name="port" index="1P_InterestRate" connector="#xpointer(ancestor::InterestSystem/InterestRate)"/>
</Interest>
<SavingsAccountBalance xhType="XhtypePurePassiveObject"/>
<InterestRate xhType="XhtypePurePassiveObject"/>
<Bacteria xhType="XhtypePureActiveObject">
<port name="port" index="0" connector="#xpointer(ancestor::BacteriaSystem/BacteriaCount)"/>
<port name="port" index="1" connector="#xpointer(ancestor::BacteriaSystem/BacteriaGrowthRate)"/>
</Bacteria>
<BacteriaCount xhType="XhtypePurePassiveObject"/>
<BacteriaGrowthRate xhType="XhtypePurePassiveObject"/>
</xholonClassDetails>
<PhysicalSystem>
<InterestSystem>
<SavingsAccountBalance>
<attribute name="val" value="100.00"/> <!-- dollars -->
</SavingsAccountBalance>
<Interest/>
<InterestRate>
<attribute name="val" value="0.1"/>
</InterestRate>
<!--<Plot/>-->
</InterestSystem>
<BacteriaSystem>
<BacteriaCount>
<attribute name="val" value="100.00"/> <!-- number of bacteria cells -->
</BacteriaCount>
<Bacteria/>
<BacteriaGrowthRate>
<attribute name="val" value="1.0"/>
</BacteriaGrowthRate>
<Plot/>
</BacteriaSystem>
</PhysicalSystem>
<Interestbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
const P_SavAcctBalance = 0; // port
const P_InterestRate = 1; // port
// value after 10 timesteps using timeStepMultiplier = 1: 259.37424601
// value after 10 timesteps using timeStepMultiplier = 256: 271.7751104074642
var me, balanceNode, irateNode, timeStepMultiplier, beh = {
postConfigure: function() {
me = this.cnode.parent();
balanceNode = me.port(P_SavAcctBalance);
irateNode = me.port(P_InterestRate);
timeStepMultiplier = 256;
me.println(this.toString());
},
act: function() {
var balance = balanceNode.val();
var iRate = irateNode.val();
for (var i = 0; i < timeStepMultiplier; i++) {
balance += (balance * iRate) / timeStepMultiplier;
}
balanceNode.val(balance);
me.println(this.toString());
},
toString: function() {
return "balance: "+ balanceNode.val();
}
}
//# sourceURL=Interestbehavior.js
]]></Interestbehavior>
<Bacteriabehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
var me, countNode, bgrateNode, timeStepMultiplier, beh = {
postConfigure: function() {
me = this.cnode.parent();
countNode = me.port(0);
bgrateNode = me.port(1);
timeStepMultiplier = 1;
me.println(this.toString());
},
act: function() {
var count = countNode.val();
var bgrate = bgrateNode.val();
for (var i = 0; i < timeStepMultiplier; i++) {
count += (count * bgrate) / timeStepMultiplier;
}
countNode.val(count);
me.println(this.toString());
},
toString: function() {
return "count: "+ countNode.val();
}
}
//# sourceURL=Bacteriabehavior.js
]]></Bacteriabehavior>
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml,
<svg width="100" height="50" xmlns="http://www.w3.org/2000/svg">
<g>
<title>InterestSystem</title>
<rect id="PhysicalSystem/InterestSystem" fill="#98FB98" height="50" width="50" x="25" y="0"/>
<g>
<title>SavingsAccountBalance</title>
<rect id="PhysicalSystem/InterestSystem/SavingsAccountBalance" fill="#6AB06A" height="50" width="10" x="80" y="0"/>
</g>
</g>
</svg>
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient>
</XholonWorkbook>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment