Functions are the basis for modeled flow and instantaneous converter definitions.  Functions also define the basis for any customized model component or factory.  Functions encompass mathematical, statistical, financial and date-time operations.  Where a symbol’s graphic cue is a stylized italic “ƒ” as is the case with customized model components and factories, and only one operation is applied, the graphic cue will show the operation. 


The following functions are implemented in the SD Calculator.  They are essential to build sophisticated system dynamics models. 

Mathematical, JAVA Strict Math and fdLibM (IEEE 754) Functions


The following mathematical functions are implemented by a converter. 


Constants

  1. Zero, One    0, 1, -1

  2. Pi    π

  3. Euler’s constant    e

  4. Largest Number      +/- ∞ or +/- (2-2-23) x 2127 or approximately +/- 3.4028 x 1038

  5. Smallest Number    +/- 1/∞ or +/- 2-126 or approximately +/- 1.1755 x 10-38

  6. nan    Not a number – a defined binary byte

  7. null    Null - nothing


Note that extended and double precision calculations will have different “smallest” and “largest” numbers


Arithmetic operations

  1. Sum     x + y

  2. Difference     x – y

  3. Product     x * y

  4. Quotient     x / y


Logical comparison operations

  1. Equal     =

  2. Not Equal    ≠

  3. Less than     <

  4. Greater than     >

  5. Less than or equal    ≤

  6. Greater than or equal     ≥


Boolean comparison operations

  1. Is    ≡

  2. Not     ¬

  3. And    ∧

  4. Or    ∨

  5. Exclusive Or (XOR)    ⊻


Negation is also allowed such as Not And or Nand (¬∧ or ⊼)


Conversions to integer in floating-point type

  1. Round     round(x)

  2. Round downward     floor(x)

  3. Round upward     ceil(x)

  4. Round toward zero    trunc(x)


Comparison operations

  1. Minimum     min(x,y)

  2. Maximum     max(x,y)

  3. Positive difference      dim(x,y)


Sign manipulation functions

  1. |x|    abs(x)


Exponential functions

  1. ex     exp(x)

  2. Ex    10exp(x)

  3. xy    pow(x,y)


Logarithmic functions

  1. ln x     log(x)

  2. log10 x     log10(x)

  3. logx y     logx(y)


Trigonometric functions

  1. cos x     cos(x)

  2. sin x     sin(x)

  3. tan x     tan(x)

  4. arccos x     acos(x)

  5. arcsin x     asin(x)

  6. arctan x     atan(x)


Hyperbolic functions

  1. cosh x     cosh(x)

  2. sinh x     sinh(x)

  3. tanh x     tanh(x)

  4. arccosh x     acosh(x)

  5. arcsinh x     asinh(x)

  6. arctanh x     atanh(x)


Error and gamma functions

  1. error x    erf(x)

  2. Γ(x)     gamma(x)


Miscellaneous functions

  1. Degrees to radians     toRadians

  2. Radians to degrees     toDegrees

  3. Square    sq(x)

  4. Cube    cb(x)

  5. Square root     sqrt(x)

  6. Cube root     cbrt(x)

  7. Hypotenuse     hypot(x,y)

  8. Remainder     remainder(x,y)

  9. Sign of a number     signum(x)

  10. Random number     random(x)


Financial Functions


Financial functions are implemented either in a converter or a factory model component.  The decision of which implementation is chosen rests on the time-wise nature of the function and the function library utilized by the developer. 


Time value of money operations:


Source data for time value of money calculations (solve for any one given the others):

  1. -PV present value

  2. -FV future value

  3. -n number of periods

  4. -I interest rate

  5. -PMT payment (and payment timing at the beginning or end of the period)


Two period specifications are processed:

  1. -N now

  2. -m for a period number from 0 to n


  1. P principle part of payment now N, at a period m

  2. I interest part of payment now N, at a period m

  3. ΣP cumulative principle paid now N, at a period m

  4. ΣI cumulative interest paid now N, at a period m

  5. ΣPMT cumulative payments paid now N, at a period m

  6. V value now N, at a period m

  7. m period for a value V

  8. mPV periods since present value for a value V or now N

  9. mFV periods to future value for a value V or now N


Depreciation operations:


Source data for asset depreciation calculations:

  1. -Cost (basis)

  2. -Salvage value at end of life

  3. -Lifetime (months or years)

  4. -Start of period (start of year, middle of year, a month of a year, or a date)


Four depreciation methods are processed:

  1. -SL straight line

  2. -DB declining balance

  3. -DDB double declining balance

  4. -SYD sum of years digits


Two period specifications are processed:

  1. -N now

  2. -m for a period number from 0 to n


Three results are calculated :

  1. -D depreciation for a specified period

  2. -ΣD accumulated depreciation at a specified period

  3. -DV depreciated value at a specified period


  1. SL depreciation now N, for a period m

  2. DB depreciation now N, for a period m

  3. DDB depreciation now N, for a period m

  4. SYD depreciation now N, for a period m

  5. SL accumulated depreciation now N, at a period m

  6. DB accumulated depreciation now N, at a period m

  7. DDB accumulated depreciation now N, at a period m

  8. SYD accumulated depreciation now N, at a period m

  9. SL depreciated value now N, at a period m

  10. DB depreciated value now N, at a period m

  11. DDB depreciated value now N, at a period m

  12. SYD depreciated value now N, at a period m


Ratios calculations:


  1. Current ratio

  2. Quick ratio

  3. Cash ratio

  4. Cash coverage ratio

  5. Times interest earned

  6. Asset turnover

  7. Inventory turnover

  8. Accounts payable turnover

  9. Accounts receivable turnover

  10. Average collection period

  11. Net profit margin (NP)

  12. Gross profit margin (GP)

  13. Return on assets (ROA)

  14. Return on equity (ROE)

  15. Return on investment (ROI)

  16. Dividend payout ratio (DPO)

  17. Earnings per share (EPS)

  18. Price earnings ratio (P/E)

  19. Equity multiplier ratio (A/E)

  20. Debt equity ratio (D/E)

  21. Debt assets ratio (D/A)


Other financial operations:


  1. Annual Percentage Rate (APR)

  2. Net Present Value (NPV)

  3. Internal Rate of Return (IRR, modified IRR)

  4. Bond Yield to Maturity (YTM)

  5. Bond Price (BPR)

  6. Capital Asset Pricing Model (CAPM)

  7. Constant Growth Model (CGM)

  8. Option Pricing Model (OPM)


Statistical Functions


Statistical functions are typically implemented by a factory model component as they operate on one or more data sets that might ordinarily result from a simulation.  In conventional calculator mode, the statistical factories accept inputs in the form of an array or a matrix of data. 


Descriptive Statistics:


  1. Count

  2. Minimum

  3. Maximum

  4. Range

  5. Mean (arithmetic, geometric, harmonic)

  6. Median

  7. Mode

  8. Quantile (quartile, quintile, decile, percentile)

  9. Deviation (standard, mean absolute, median absolute, maximum absolute)

  10. Coefficient of variation

  11. Variance

  12. Semivariance

  13. Skewness

  14. Kurtosis


Inferential Statistics:


  1. ANOVA analysis of variance

  2. ANCOVA analysis of covariance

  3. Normal probability density

  4. Normal cumulative distribution

  5. Binomial individual terms distribution

  6. Binomial cumulative terms distribution

  7. Poisson individual terms distribution

  8. Poisson cumulative terms distribution

  9. Beta distribution

  10. Gamma distribution

  11. Weibull distribution

  12. Z (normal) test

  13. T distribution

  14. T test

  15. Chi-squared distribution

  16. Chi-squared test

  17. F distribution

  18. F test


Correlation Analysis:


  1. Pearson product-moment

  2. Spearman’s rho

  3. Kendall’s tau


Regression Analysis (this section requires additional work)


Physical and Chemical Functions (this section requires additional work)


Physical and chemical functions are implemented either in a converter of a factory model component.  The decision of which implementation is chosen rests on the time-wise nature of the function and the function library utilized by the developer. 


Reactions of ions, atoms and molecules:


  1. acidity

  2. basicity

  3. oxidation

  4. reduction

  5. metal exchange

  6. pericyclic


Reactions of structural change:


  1. addition

  2. elimination

  3. substitution

  4. rearrangement


Reactions of functional groups:


  1. alkane

  2. alkene

  3. alkyne

  4. halide

  5. alchohol

  6. ether

  7. amine

  8. phosphene

  9. benzene

  10. nitro

  11. thiol

  12. sulfide

  13. nitrile

  14. aldehyde

  15. kytone

  16. carboxylic

  17. carboxylic derivative

  18. ester

  19. halide

  20. amide

  21. anhydride


Date and Time Functions


Types supported:


  1. Structure of Date and Time record
        year;
        month;
        date;
        hour;
        minute;
        second;
        monthOfYear;
        dayOfWeek;
        timeZone


  1. Date and Time numeric string
        YYYY-MM-DD HH:MM:SS±HHMM


  1. Structure of Long Date and Time record
        era;
        year;
        month;
        date;
        hour;
        minute;
        second;
        millisecond;
        am/pm;
        timeZone


Basic date and time functions:


  1. Get date and time

  2. Get date

  3. Get time

  4. Get time zone

  5. Get dayNumberOfWeek

  6. Get dayNumberOfYear

  7. Get weekNumberOfMonth

  8. Get weekNumberOfYear

  9. Set date and time

  10. Set date

  11. Set time

  12. Set time zone


Convert date and time strings into numeric representations:


  1. String to date and time

  2. String to date

  3. String to time


Convert numeric representations into date and time strings:


  1. Date and time to string

  2. Date to string

  3. Time to string


Time interval operations:


  1. Date with time interval since now

  2. Date interval since now; Time interval since now

  3. Date with time interval since date

  4. Date interval since date; Time interval since date

  5. Add date interval

  6. Add time interval

  7. Subtract date interval

  8. Subtract time interval


Date and time comparison operations:


  1. Compare date and time

  2. Compare date

  3. Compare time

  4. IsEqualTo date

  5. Earlier date

  6. Later date


Other Functions


Personalization and Localization:


  1. Get user

  2. Get / Set language

  3. Get/ Set location

  4. Get / Set default symbol size of small, medium or large

  5. Get / Set default symbol spacing of tight, moderate or loose


Number conversion:


  1. Get / Set number system

  2. Convert to Base2

  3. Convert to Base8

  4. Convert to Base10

  5. Convert to Base16

  6. Convert from / to


Notation conversion:


  1. Convert to fraction (to k/n or k/2n for n ≤ user specification)

  2. Convert to decimal


Currency conversion (ISO 4217, 10646):


  1. Get / Set currency system

  2. Convert to USD ($)    United States Dollar

  3. Convert to AUD (A$)    Australian Dollar

  4. Convert to CAD (C$)    Canadian Dollar

  5. Convert to MXN (M$)    Mexican Peso

  6. Convert to EUR (€)    Euro

  7. Convert to GBP (£)    Pound

  8. Convert to RUB (Руб)    Ruble

  9. Convert to JPY (¥)    Yen

  10. Convert to CNY (元)    Yuan Renminbi

  11. Convert to KRW (₩)    Won

  12. Convert to INR (₨)    Rupees

  13. Convert to XAU (oz)    gold (ounces)

  14. Convert from / to


Unit of measure conversion:


  1. Get / Set unit system

  2. Convert to Metric (meter, kilogram, liter, degC)

  3. Convert to Metric-Small (centimeter, gram, millimeter, degC)

  4. Convert to English (foot, pound, gallon, degF)

  5. Convert to English-Small (inch, ounce, ounce, degF)

  6. Convert from / to


Solver (inverse function solution):


  1.     x = ƒ-1 (y)    sol(y,ƒ(x))


Script commands and conditionals:


  1. If, Then, Else

  2. Do (a script)

  3. Display / Clear Display (a result, text string, picture)

  4. Print (a model, report, graph or table)

  5. Load, Unload (a model)

  6. Select (a page, palette, simple table/graph)

  7. Start, Stop, Pause, Resume (a simulation, movie)

  8. Wake, Sleep, Shut Down (the calculator)

  9. At, After  (a time, an interval)

  10. On (reference to system events)

  11. Loop / End Loop


System Dynamics Calculator  

The SD Model in Depth  ↑

The Model Builder

        System Dynamics Calculator

                The Calculator

                The SD Model in Depth

                        Stocks

                        Flows

                        Transformers

                        Converters

                        Variables

                        Factories

                        Customized Factory Packages

                        Abstraction Layers, Fragments and Scripts

                        Functions

                                Mathematical, JAVA Strict Math and fdLibM (IEEE 754) Functions

                                Financial Functions

                                Statistical Functions

                                Physical and Chemical Functions (this section requires additional work)

                                Date and Time Functions

                                Other Functions

                The Model Builder

                The Model Simulator

                Appendix: The Modeling Process

                System Dynamics CalculatorR1.pdf

                SD2ProjectProposalSDS.pdf