NAME

App::CalcAccumulatedInflation - Calculate accumulated inflation (or savings rate, etc) over the years

VERSION

This document describes version 0.052 of App::CalcAccumulatedInflation (from Perl distribution App-CalcAccumulatedInflation), released on 2021-07-17.

SYNOPSIS

See the included script calc-accumulated-inflation.

CONTRIBUTOR

perlancar (on netbook-dell-xps13) <perlancar@gmail.com>

FUNCTIONS

calc_accumulated_inflation

Usage:

calc_accumulated_inflation(%args) -> any

Calculate accumulated inflation (or savings rate, etc) over the years.

Examples:

  • See accumulated 6%/year inflation for 10 years:

    calc_accumulated_inflation(yearly_rate => 6);

    Result:

    [
      { index => 1, year => 0 },
      { index => "1.0600", year => 1 },
      { index => 1.1236, year => 2 },
      { index => "1.1910", year => 3 },
      { index => 1.2625, year => 4 },
      { index => 1.3382, year => 5 },
      { index => 1.4185, year => 6 },
      { index => 1.5036, year => 7 },
      { index => 1.5938, year => 8 },
      { index => 1.6895, year => 9 },
      { index => 1.7908, year => 10 },
    ]
  • See accumulated 5.5%/year inflation for 7 years:

    calc_accumulated_inflation(yearly_rate => 5.5, years => 7);

    Result:

    [
      { index => 1, year => 0 },
      { index => "1.0550", year => 1 },
      { index => "1.1130", year => 2 },
      { index => 1.1742, year => 3 },
      { index => 1.2388, year => 4 },
      { index => "1.3070", year => 5 },
      { index => 1.3788, year => 6 },
      { index => 1.4547, year => 7 },
    ]
  • Indonesia's inflation rate for 2003-2014:

    calc_accumulated_inflation(rates => [5.16, 6.4, 17.11, 6.6, 6.59, 11.06, 2.78, 6.96, 3.79, 4.3, 8.38, 8.36]);

    Result:

    [
      { index => 1, year => 0 },
      { index => 1.0516, rate => "5.16%", year => 1 },
      { index => 1.1189, rate => "6.40%", year => 2 },
      { index => 1.3103, rate => "17.11%", year => 3 },
      { index => 1.3968, rate => "6.60%", year => 4 },
      { index => 1.4889, rate => "6.59%", year => 5 },
      { index => 1.6536, rate => "11.06%", year => 6 },
      { index => 1.6995, rate => "2.78%", year => 7 },
      { index => 1.8178, rate => "6.96%", year => 8 },
      { index => 1.8867, rate => "3.79%", year => 9 },
      { index => 1.9678, rate => "4.30%", year => 10 },
      { index => 2.1327, rate => "8.38%", year => 11 },
      { index => "2.3110", rate => "8.36%", year => 12 },
    ]
  • How much will your $100,000 grow over the next 10 years, if the savings rate is 4%; assuming this year is 2021:

    calc_accumulated_inflation(base_index => 100000, base_year => 2021, yearly_rate => 4, years => 10);

    Result:

    [
      { index => 100000, year => 2021 },
      { index => "104000.0000", year => 2022 },
      { index => "108160.0000", year => 2023 },
      { index => "112486.4000", year => 2024 },
      { index => "116985.8560", year => 2025 },
      { index => 121665.2902, year => 2026 },
      { index => 126531.9018, year => 2027 },
      { index => 131593.1779, year => 2028 },
      { index => "136856.9050", year => 2029 },
      { index => 142331.1812, year => 2030 },
      { index => 148024.4285, year => 2031 },
    ]

This routine generates a table of accumulated inflation over a period of several years. You can either specify a fixed rate for every years (yearly_rate), or specify each year's rates (rates). You can also optionally set base index (default to 1) and base year (default to 0).

This function is not exported.

Arguments ('*' denotes required arguments):

  • base_index => float (default: 1)

  • base_year => float (default: 0)

  • rates => array[float]

    Different rates for each year, in percent.

  • yearly_rate => float

    A single rate for every year, in percent.

  • years => int (default: 10)

Return value: (any)

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/App-CalcAccumulatedInflation.

SOURCE

Source repository is at https://github.com/perlancar/perl-App-CalcAccumulatedInflation.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-CalcAccumulatedInflation

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2021, 2019, 2017, 2015 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.