{"id":20160184,"url":"https://github.com/trizen/math-bacovia2","last_synced_at":"2026-05-12T17:35:26.824Z","repository":{"id":68776044,"uuid":"90022885","full_name":"trizen/Math-Bacovia2","owner":"trizen","description":"Experimental symbolic math library for Perl.","archived":false,"fork":false,"pushed_at":"2020-12-09T13:55:47.000Z","size":54,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-13T13:49:59.782Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"artistic-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trizen.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-02T10:55:39.000Z","updated_at":"2020-12-09T13:55:50.000Z","dependencies_parsed_at":"2023-02-26T22:46:01.088Z","dependency_job_id":null,"html_url":"https://github.com/trizen/Math-Bacovia2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trizen%2FMath-Bacovia2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trizen%2FMath-Bacovia2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trizen%2FMath-Bacovia2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trizen%2FMath-Bacovia2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trizen","download_url":"https://codeload.github.com/trizen/Math-Bacovia2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241597914,"owners_count":19988335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T00:12:41.711Z","updated_at":"2026-05-12T17:35:26.786Z","avatar_url":"https://github.com/trizen.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Math-Bacovia\n\nMath::Bacovia is a symbolic math library, with support for numerical evaluation (including support for complex numbers).\n\n# EXAMPLE\n\n```perl\nuse 5.014;\nuse Math::Bacovia qw(:all);\n\nmy $x = Symbol('x');\nmy $y = Symbol('y');\n\nsay $x+$y;               #=\u003e Sum(Symbol(\"x\"), Symbol(\"y\"))\nsay $x-$y;               #=\u003e Difference(Symbol(\"x\"), Symbol(\"y\"))\nsay $x*$y;               #=\u003e Product(Symbol(\"x\"), Symbol(\"y\"))\nsay $x/$y;               #=\u003e Fraction(Symbol(\"x\"), Symbol(\"y\"))\n\nsay $x**$y;              #=\u003e Power(Symbol(\"x\"), Symbol(\"y\"))\n\nsay Log($x);             #=\u003e Log(Symbol(\"x\"))\nsay Log($x)+Log($y);     #=\u003e Log(Product(Symbol(\"x\"), Symbol(\"y\")))\n\nsay Exp($x);             #=\u003e Exp(Symbol(\"x\"))\nsay Exp($x)*Exp($y);     #=\u003e Exp(Sum(Symbol(\"x\"), Symbol(\"y\")))\n\n\nsay \"\\n=\u003e Sum:\";\nmy $sum = Fraction(0, 1);\n\nfor my $n (1..10) {\n    $sum += Fraction(1, $n);\n}\nsay $sum;                     #=\u003e Fraction(10628640, 3628800)\nsay $sum-\u003enumeric;            #=\u003e 7381/2520\n\n\nsay \"\\n=\u003e Product:\";\nmy $prod = Product();\n\nfor my $n (1..3) {\n    $prod *= Exp(Fraction(1, $n));\n}\n\nsay $prod-\u003epretty;            #=\u003e (exp(1) * exp(1/2) * exp(1/3))\nsay $prod-\u003esimple-\u003epretty;    #=\u003e exp(11/6)\nsay $prod-\u003enumeric;           #=\u003e 6.25470095193632871640207...\n\n\nsay \"\\n=\u003e Alternative representations:\";\nsay join ', ', Power(3, 5)-\u003ealternatives(full =\u003e 1);   #=\u003e Power(3, 5), Exp(Product(Log(3), 5)), 243\n```\n\n\n# DESCRIPTION\n\nThe types supported by this library are described bellow:\n\n#### # `Symbol(name, value=undef)`\n\nRepresents a symbolic value. Optionally, it can have a numerical value (or any other value).\n\n#### # `Number(value)`\n\nRepresents a numerical value.\n\n#### # `Fraction(numerator, denominator)`\n\nRepresents a symbolic fraction.\n\n#### # `Difference(minuend, subtrahend)`\n\nRepresents a symbolic subtraction.\n\n#### # `Power(base, power)`\n\nRepresents a symbolic exponentiation in a symbolic base.\n\n#### # `Log(x)`\n\nRepresents the natural logarithm of a symbolic value.\n\n#### # `Exp(x)`\n\nRepresents the natural exponentiation of a symbolic value.\n\n#### # `Sum(a, b, c, ...)`\n\nRepresents a summation of an arbitrary (finite) number of symbolic values.\n\n#### # `Product(a, b, c, ...)`\n\nRepresents a product of an arbitrary (finite) number of symbolic values.\n\n# SPECIAL METHODS\n\nAn interesting feature is the support for alternative representations (provided by the method `alternatives()`),\nwhich uses common mathematical identities to create symbolically equivalent expressions from the self-expression.\n\nBellow we describe the special methods provided by this library:\n\n#### # `alternatives()`\n\nReturns a list with alternative representations from the self-expression.\n\nExample:\n\n```perl\nsay for Exp(Log(Fraction(1,3)) * 2)-\u003ealternatives;\n```\n\nOutput:\n\n```ruby\nExp(Product(2, Log(Fraction(1, 3))))\nPower(Fraction(1, 3), 2)\nExp(Product(2, Log(1/3)))\nPower(1/3, 2)\n```\n\nThe options supported by this method are:\n\n```perl\n    log  =\u003e 1,    # will try to generate logarithmic alternatives\n    full =\u003e 1,    # will try to generate more alternatives (it may be slow)\n```\n\nThe options can be provided as:\n\n```perl\n$obj-\u003ealternatives(\n    full =\u003e 1,\n    log  =\u003e 1,\n);\n```\n\nExample:\n\n```perl\nsay for Power(3, 5)-\u003ealternatives(full =\u003e 1);\n```\n\nOutput:\n\n```ruby\nPower(3, 5)\nExp(Product(Log(3), 5))\n243\n```\n\n**WARNING:** The number of alternative representations grows exponentially! For non-trivial expressions,\nthis process may take a very long time and use lots of memory. In combination with the B\u003cfull\u003e option\n(set to a true value), the returned list may contain hundreds of even thousands of alternative representations.\n\n#### # `simple()`\n\nReturns a simplification of the self-expression.\n\n```perl\nsay Exp(Log(Log(Exp(Exp(Log(Symbol('x')))))))-\u003esimple;\n```\n\nOutput:\n\n```perl\nSymbol(\"x\")\n```\n\nAccepts the same options as the `alternatives()` method.\n\n#### # `expand()`\n\nReturns an expanded version of the self-expression.\n\n```perl\nsay Power(Fraction(5, 7), Fraction(1, 3))-\u003eexpand(full =\u003e 1);\n```\n\nOutput:\n```perl\nExp(Product(Log(Fraction(5, 7)), Fraction(1, 3)))\n```\n\nAccepts the same options as the `alternatives()` method.\n\n#### # `pretty()`\n\nReturns a human-readable stringification of the self-expression.\n\n```perl\nsay Power(3, Log(Fraction(1, 2)))-\u003epretty;\n```\n\nOutput:\n```ruby\n3^log(1/2)\n```\n\n#### # `numeric()`\n\nEvaluates the self-expression numerically and returns the result as a [Math::AnyNum](https://metacpan.org/release/Math-AnyNum) object.\n\n```perl\nmy $x = Symbol('x', 13);\nmy $expr = ($x**2 - $x + 41);\n\nsay $expr-\u003enumeric;     #=\u003e 197\n```\n\n# DEPENDENCIES\n\nMath::Bacovia requires the following modules:\n\n* [Math::AnyNum](https://metacpan.org/pod/Math::AnyNum)\n* [List::UtilsBy](https://metacpan.org/pod/List::UtilsBy)\n\n# INSTALLATION\n\nTo install this module, run the following commands:\n\n    perl Build.PL\n    ./Build\n    ./Build test\n    ./Build install\n\n# SUPPORT AND DOCUMENTATION\n\nAfter installing, you can find documentation for this module with the\nperldoc command.\n\n    perldoc Math::Bacovia\n\nYou can also look for information at:\n\n* MetaCPAN\n  - https://metacpan.org/pod/Math::Bacovia\n\n* AnnoCPAN, Annotated CPAN documentation\n  - http://annocpan.org/dist/Math-Bacovia\n\n* CPAN Ratings\n  - http://cpanratings.perl.org/d/Math-Bacovia\n\n# LICENSE AND COPYRIGHT\n\nCopyright (C) 2017 Daniel Șuteu\n\nThis program is free software; you can redistribute it and/or modify it\nunder the terms of the the Artistic License (2.0). You may obtain a\ncopy of the full license at:\n\nhttp://www.perlfoundation.org/artistic_license_2_0\n\nAny use, modification, and distribution of the Standard or Modified\nVersions is governed by this Artistic License. By using, modifying or\ndistributing the Package, you accept this license. Do not use, modify,\nor distribute the Package, if you do not accept this license.\n\nIf your Modified Version has been derived from a Modified Version made\nby someone other than you, you are nevertheless required to ensure that\nyour Modified Version complies with the requirements of this license.\n\nThis license does not grant you the right to use any trademark, service\nmark, tradename, or logo of the Copyright Holder.\n\nThis license includes the non-exclusive, worldwide, free-of-charge\npatent license to make, have made, use, offer to sell, sell, import and\notherwise transfer the Package with respect to any patent claims\nlicensable by the Copyright Holder that are necessarily infringed by the\nPackage. If you institute patent litigation (including a cross-claim or\ncounterclaim) against any party alleging that the Package constitutes\ndirect or contributory patent infringement, then this Artistic License\nto you shall terminate on the date that such litigation is filed.\n\nDisclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER\nAND CONTRIBUTORS \"AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR\nPURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY\nYOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR\nCONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR\nCONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,\nEVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrizen%2Fmath-bacovia2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrizen%2Fmath-bacovia2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrizen%2Fmath-bacovia2/lists"}