{"id":37004716,"url":"https://github.com/irrevion/science","last_synced_at":"2026-01-14T00:38:48.497Z","repository":{"id":204458012,"uuid":"711749981","full_name":"irrevion/science","owner":"irrevion","description":"PHP library for extended mathematical operations","archived":false,"fork":false,"pushed_at":"2025-08-15T22:08:22.000Z","size":604,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-27T15:13:51.422Z","etag":null,"topics":["complex-numbers","linear-algebra","math","matrix","physics","quaternion","science","units-converter","vector"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/irrevion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null}},"created_at":"2023-10-30T05:15:05.000Z","updated_at":"2025-08-15T22:08:26.000Z","dependencies_parsed_at":"2024-12-17T07:48:08.809Z","dependency_job_id":"c74e72ac-d2a7-40ed-ad0b-cac750c73f56","html_url":"https://github.com/irrevion/science","commit_stats":{"total_commits":110,"total_committers":1,"mean_commits":110.0,"dds":0.0,"last_synced_commit":"3f6a71c75979e0c08254192c3b23620842e4f2fa"},"previous_names":["irrevion/science"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/irrevion/science","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irrevion%2Fscience","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irrevion%2Fscience/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irrevion%2Fscience/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irrevion%2Fscience/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/irrevion","download_url":"https://codeload.github.com/irrevion/science/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/irrevion%2Fscience/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["complex-numbers","linear-algebra","math","matrix","physics","quaternion","science","units-converter","vector"],"created_at":"2026-01-14T00:38:48.391Z","updated_at":"2026-01-14T00:38:48.475Z","avatar_url":"https://github.com/irrevion.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# science\nPHP library for extended mathematical operations. Its mostly focused on operations with Complex numbers, Quaternions and Linear Algebra.\n\n## Key features and advantages\n- Improved `Math::pow($base, $exponent)` function, able to raise any real or complex number to any real or complex exponent\n- Support for [Complex](docs/Math/Entities/Complex.md) numbers and Quaternions ( just like Python with [NumPy](https://numpy.org/) + [PyQuaternion](http://kieranwynn.github.io/pyquaternion/) + [SymPy](https://www.sympy.org/) )\n- Physics units conversion (more units to be added...) using `(new Quantity(0.7, IAU::parsec))-\u003econvert(SI::metre)`\n\n## Installation\nLibrary is available on [Packagist](https://packagist.org/packages/irrevion/science) and could be installed using CLI command:\n```bash\ncomposer require irrevion/science\n```\n\n## Usage\nIf installed via composer include composer generated autoloader and add `use irrevion\\science\\Math\\Math` statement for example.  \nIf you are not using composer or using a custom folder you can modify and include [custom autoloader](https://github.com/irrevion/science/blob/main/dev/autoloader.php).  \nExample:\n```php\nrequire_once(\"../autoloader.php\");\n\nuse irrevion\\science\\Helpers\\Utils;\nuse irrevion\\science\\Math\\Operations\\Delegator;\nuse irrevion\\science\\Math\\Math;\nuse irrevion\\science\\Math\\Entities\\{Scalar, Fraction, Imaginary, Complex};\n```\n\n## Examples\nScalar is a basic number class:\n```php\nuse irrevion\\science\\Math\\Entities\\Scalar;\n\n$n = new Scalar(5);\nprint(\"Scalar to string is {$n}\\nType of n is \".($n::class).\"\\n\");\n// Outputs:\n// Scalar to string is 5\n// Type of n is irrevion\\science\\Math\\Entities\\Scalar\n```\nBasic arithmetic operations available:\n```php\n$sum = $n-\u003eadd(new Scalar(3));\n$diff = $n-\u003esubtract(new Scalar(2));\n$prod = $n-\u003emultiply(new Scalar(10));\n$quotient = $n-\u003edivide(new Scalar(3));\n```\nAs mentioned above, significant enhancement of pow() function has been made:\n```php\nuse irrevion\\science\\Helpers\\Utils;\nuse irrevion\\science\\Math\\Math;\nuse irrevion\\science\\Math\\Operations\\Delegator;\nuse irrevion\\science\\Math\\Entities\\{Scalar, Fraction, Imaginary, Complex};\n\n$x = 2;\n$y = 3;\n$z = Math::pow($x, $y);\nprint \"{$x}**{$y} is {$z} ( \".Delegator::getType($z).\" ) \\n\";\n// Output: 2**3 is 8 ( integer )\n\n$x = new Scalar(25);\n$y = new Scalar(2);\n$z = Math::pow($x, $y);\nprint \"{$x}**{$y} is {$z} ( \".($z::class).\" ) \\n\";\n// Output: 25**2 is 625 ( irrevion\\science\\Math\\Entities\\Scalar )\n\n$x = new Scalar(25);\n$y = new Scalar(-2);\n$z = Math::pow($x, $y);\nprint \"{$x}**{$y} is {$z} ( \".($z::class).\" ) \\n\";\n// Output: 25**-2 is 0.0016 ( irrevion\\science\\Math\\Entities\\Scalar )\n\n$x = new Scalar(-1.678903);\n$y = new Scalar(-2.5);\n$z = Math::pow($x, $y);\nprint \"{$x}**{$y} is {$z} ( \".($z::class).\" ) \\n\";\n// Output: -1.678903**-2.5 is [8.3827564317097E-17 + -0.27380160345158i] ( irrevion\\science\\Math\\Entities\\Complex )\n// Vanilla PHP will give you: NAN\n// Python will give you: (8.382756431709652e-17-0.2738016034515765j)\n\n$x = new Scalar(Math::E);\n$y = new Imaginary(Math::PI);\n$z = Math::pow($x, $y);\nprint \"e**πi is {$z} ( \".($z::class).\" ) \\n\";\n// Output: e**πi is [-1 + 1.2246467991474E-16i] ( irrevion\\science\\Math\\Entities\\Complex )\n// Python gives: (-1+1.2246467991473532e-16j)\n// Expected: -1 by formulae e**πi+1=0\n\n$x = new Scalar(125);\n$y = new Fraction('1/3');\n$z = Math::pow($x, $y);\nprint \"{$x}**{$y} is {$z} ( \".($z::class).\" ) \\n\";\n// Output: 125**1/3 is 5 ( irrevion\\science\\Math\\Entities\\Scalar )\n\n$x = new Scalar(4);\n$y = new Complex(2.5, 2);\n$z = Math::pow($x, $y);\nprint \"{$x}**{$y} is {$z} ( \".($z::class).\" ) \\n\";\n// Output: 4**(2.5+2i) is [-29.845986458754 + 11.541970902054i] ( irrevion\\science\\Math\\Entities\\Complex )\n// Python gives: (-29.845986458754275+11.541970902053793j)\n```\nIt is also possible to get all roots of a number\n```php\n$roots = (new Complex(-64))-\u003eroots(3);\nprint Utils::printR($roots).\" \\n\";\n// Output: [[2 + 3.4641016151378i], [-4 + 4.8985871965894E-16i], [2 + -3.4641016151378i]]\n```\nSo, as you can see, the following operations are supported:\n- raise of real number to a real power\n- raise of real number to a fractional power (2/3 means cubic root squared)\n- raise of negative number to a rational or real power (1/n is n-th root of a number)\n- raise of an any number to negative power (rational or real)\n- raise of a number to imaginary or complex power\n- raise of an any available value (entity-type instance: mixed/numeric, Scalar, Fraction, Imaginary, [Complex](docs/Math/Entities/Complex.md), ComplexPolar, QuaternionComponent, Quaternion, Vector, etc) at least to positive integer power\n\n## Versions history\n\n~dev-main\n- Symbolic math implementation started\n- Physics: Added Rydberg energy, kilometre, attometre, angstrom and Bohr radius units\n\nv0.0.5\n- Matrix inversion implemented (as well as methods for finding cofactor matrix, adjugate, minors, row echelon form, reduced REF, rank)\n- Complex power, exponentiation, natural logarythm implemented\n- Quaternions added\n- Physics: Added units Dalton, Apostilb, Planck energy\n\nv0.0.4\n- Vector checking methods added (orthogonal, collinear, coplarar)\n- Angle between vectors calculation added\n- Physics: Angle units added\n\nv0.0.3\n- Matrix determinant implemented\n- Physics: New units added (Ohm, Farad, Watt, etc)\n\nv0.0.2\n- Added units in physics\n- Fixed fallback autoloader\n- Implemented search by unit entity in physical unit categories\n\nv0.0.1\n- Basic entities implemented\n- Composer requirements are met\n\n\n\n## Documentation\n\n- [Math](docs/Math/Math.md)\n\t- Numbers, Entities \u0026 Matrices\n\t\t- [NaN](docs/Math/Entities/NaN.md)\n\t\t- [Scalar](docs/Math/Entities/Scalar.md)\n\t\t- [Fraction](docs/Math/Entities/Fraction.md)\n\t\t- [Imaginary](docs/Math/Entities/Imaginary.md)\n\t\t- [Complex](docs/Math/Entities/Complex.md)\n\t\t- [ComplexPolar](docs/Math/Entities/ComplexPolar.md)\n\t\t- [QuaternionComponent](docs/Math/Entities/QuaternionComponent.md)\n\t\t- [Quaternion](docs/Math/Entities/Quaternion.md)\n\t\t- [Vector](docs/Math/Entities/Vector.md)\n\t\t- [Matrix](docs/Math/Transformations/Matrix.md)\n\t- Symbolic Math\n\t\t- [Symbols](docs/Math/Symbols/Symbols.md)\n\t\t- Operations\n\t\t- [Expressions](docs/Math/Symbols/Expressions.md)\n- [Physics](docs/Physics/Physics.md)\n\t- [Quantity](docs/Physics/Entities/Quantity.md)\n- Helpers\n\t- Utils - miscellaneous functions toolbox\n\t- Delegator - type manager and delegator\n\t- [R - array-like object constructor](docs/Helpers/R.md)\n\t- M - 2-dimensional R\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firrevion%2Fscience","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Firrevion%2Fscience","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firrevion%2Fscience/lists"}