{"id":19396293,"url":"https://github.com/darkjoij/simple-math","last_synced_at":"2026-03-19T09:38:18.060Z","repository":{"id":113401459,"uuid":"528882735","full_name":"DarkJoij/simple-math","owner":"DarkJoij","description":"Includes functions for solving equations and tasks using formulas from a school mathematics course.","archived":false,"fork":false,"pushed_at":"2022-11-22T14:30:21.000Z","size":41,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-03T22:46:53.528Z","etag":null,"topics":["d","dlang","math","simple-math"],"latest_commit_sha":null,"homepage":"","language":"D","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DarkJoij.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}},"created_at":"2022-08-25T14:17:17.000Z","updated_at":"2022-11-21T15:36:45.000Z","dependencies_parsed_at":"2023-04-04T04:31:27.944Z","dependency_job_id":null,"html_url":"https://github.com/DarkJoij/simple-math","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/DarkJoij/simple-math","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DarkJoij%2Fsimple-math","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DarkJoij%2Fsimple-math/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DarkJoij%2Fsimple-math/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DarkJoij%2Fsimple-math/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DarkJoij","download_url":"https://codeload.github.com/DarkJoij/simple-math/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DarkJoij%2Fsimple-math/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30130358,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T12:40:50.676Z","status":"ssl_error","status_checked_at":"2026-03-05T12:39:32.209Z","response_time":93,"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":["d","dlang","math","simple-math"],"created_at":"2024-11-10T10:34:25.031Z","updated_at":"2026-03-05T14:31:30.643Z","avatar_url":"https://github.com/DarkJoij.png","language":"D","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple-math library\nA library that includes functions for solving equations and tasks using formulas from a school mathematics course.\n\n# Installition\n* Using DUB in console:\n```bash\ndub add simple_math\n```\n\n* Using `dub.json`:\n```json\n\"dependecies\": {\n\t\"simple-math\": \"~\u003e1.1.0\"\n}\n```\n\n* Using `dub.sdl`:\n```bash\ndependency \"simple-math\" version=\"~\u003e1.1.0\"\n```\n\n# Tools\n## Module `progressions`\n#### Arithmetical\n* `public T findArithmeticalD(T)(T[] progression)`\\\nFinds the difference of the arithmetic progression in an array consisting of numbers.\n\n* `public bool isArithmeticProgression(T)(T[] array)`\\\nChecks whether the passed array is an arithmetic progression.\n\n* `public T findAN(T)(T[] progression, T n)`\n* `public T findAN(T)(T a1, T d, T n)`\\\nFinds a member of the arithmetic progression at position N.\n\n* `public T findArithmeticSN(T)(T[] progression, T n)`\n* `public T findArithmeticSN(T)(T a1, T d, T n)`\\\nFinds the sum of N members of the arithmetic progression.\n\n#### Example\n```d\n// findArithmeticalD:\nassert(findArithmeticalD!ubyte([2, 3, 4, 5]) == 1);\nassert(findArithmeticalD!byte([5, 2]) == -3);\n\n// isArithmeticProgression:\nassert(isArithmeticProgression!ubyte([3, 2, 1]));\nassert(!isArithmeticProgression!ubyte([1, 5, 25]));\n\n// findAN(T)(T[] progression, T n):\nassert(findAN!ubyte([2, 3], 3) == 4);\nassert(findAN!float([5, 1, -3], 6) == -15.0);\n\n// findAN(T)(T a1, T d, T n):\nassert(findAN!ubyte(2, 1, 3) == 4);\nassert(findAN!float(5, -4, 6) == -15.0);\n\n// findArithmeticSN(T)(T[] progression, T n):\nassert(findArithmeticSN!ubyte([1, 2, 3], 5) == 15);\nassert(findArithmeticSN!byte([1, -2], 4) == -12);\n\n// findArithmeticSN(T)(T a1, T d, T n):\nassert(findArithmeticSN!ubyte(1, 1, 5) == 15);\nassert(findArithmeticSN!byte(1, -3, 4) == -12);\n```\n\n### Geometrical\n* `public T findGeometricQ(T)(T[] progression)`\\\nFinds the difference of the geometric progression in an array consisting of numbers.\n\n* `public bool isGeometricProgression(T)(T[] array)`\\\nChecks whether the passed array is an geometric progression.\n\n* `public bool isSequence(T)(T[] progression)`\\\nChecks whether the array is a sequence (q = 1, [1, 1, 1, ...]).\n\n* `public T findBN(T)(T[] progression, T n)`\n* `public T findBN(T)(T b1, T q, T n)`\\\nFinds a member of the geometric progression at position N.\n\n* `public T findGeometricSN(T)(T[] progression, T n)`\n* `public T findGeometricSN(T)(T b1, T q, T n)`\\\nFinds the sum of N members of the geometric progression.\n\n#### Example\n```d\n// findGeometricQ:\nassert(findGeometricQ!ubyte([25, 50, 100]) == 2);\nassert(findGeometricQ!byte([-2, -6, -18]) == 3);\n\n// isGeometricProgression:\nassert(isGeometricProgression!ubyte([1, 4, 16]));\nassert(!isGeometricProgression!ubyte([8, 10, 16]));\n\n// isSequence:\nassert(isSequence([2, 2]));\nassert(!isSequence([1, 2]));\n\n// findBN(T)(T[] progression, T n):\nassert(findBN!byte([-2, -6], 3) == -18);\nassert(findBN!float([100, 50, 25], 4) == 12.5);\n\n// findBN(T)(T b1, T q, T n):\nassert(findBN!byte(-2, 3, 3) == -18);\nassert(findBN!float(100, 0.5, 4) == 12.5);\n\n// findGeometricSN(T)(T[] progression, T n):\nassert(findGeometricSN!ubyte([1, 2], 3) == 7);\nassert(findGeometricSN!float([100, 25], 3) == 131.25);\n\n// findGeometricSN(T)(T b1, T q, T n):\nassert(findGeometricSN!ubyte(1, 2, 3) == 7);\nassert(findGeometricSN!float(100, 0.25, 3) == 131.25);\n```\n\n## Module `chances`\n* `public T chance(T)(T value, T from)`\\\nFinds the chance of `value` shares falling out of `from`.\n\n#### Example\n```d\nassert(chance!byte(5, 25) == 20);\nassert(chance!byte(19, 20) == 95);\n```\n\n## Module `percents`\n* `public T percents(T)(real value, real from)`\\\nFinds the percentage of `value` from `from` parameter.\n\n* `public T[] percentsCaptures(T)(T[] captures, T from)`\\\nFinds the percentage for each element in the array relative to the `from` parameter.\n\n#### Example\n```d\n// percents:\nassert(percents!ubyte(5, 10) == 50);\nassert(percents!float(2.5, 10) == 25.0);\n\n// percentsCaptures:\nfloat[] percentsOfTen = percentsCaptures!float([2.5, 7.5], 10);\nfloat[] expectedResults = [25.0, 75.0];\n\nforeach (ubyte i; 0 .. 2)\n\tassert(percentsOfTen[i] == expectedResults[i]);\n```\n\n## Module `square_equations`\n* `public T findDesc(T)(T a, T b, T c)`\\\nFinds the discriminant of the square equation based on the coefficients `a`, `b` and `c'.\n\n* `public T[] resolveFull(T)(T a, T b, T c)`\\\nFinds the roots of the full square equation and, if there are none, throws an error.\n\n* `public T[] resolveAB(T)(T a, T b)`\\\nFinds the roots of an incomplete square equation (`a`, `b`).\n\n#### Example\n```d\n// findDesc:\nassert(findDesc!byte(-1, 4, -3) == 4);\nassert(findDesc!byte(1, -1, 0) == 1);\n\n// resolveFull:\nint[] result = resolveFull!int(-1, 4, -3);\nint[] expectedResults = [1, 3];\n\nforeach (ubyte i; 0 .. 2)\n\tassert(result[i] == expectedResults[i]);\n\n// resolveAB:\nint[] result = resolveAB!int(1, -1);\nint[] expectedResults = [1, 0];\n\nforeach (ubyte i; 0 .. 2)\n\tassert(result[i] == expectedResults[i]);\n```\n\n## Module `trigonometry`\n* `public double sine(T)(T angleMeasure)`\\\nFinds the sine of the angle by its degree measure.\n\n* `public double cosine(T)(T angleMeasure)`\\\nFinds the cosine of the angle by its degree measure.\n\n* `public double tangents(T)(T angleMeasure)`\\\nFinds the tangents of the angle by its degree measure.\n\n* `public double cotangents(T)(T angleMeasure)`\\\nFinds the cotangents of the angle by its degree measure.\n\n#### Example\n```d\nassert(sine(30) == 0.5);\nassert(cosine(60) == 0.5);\nassert(tangents(45) == 1);\nassert(cotangents(45) == 1);\n```\n\n# Feedback\nOpen [issues](https://github.com/DarkJoij/simple-math/issues) and [pull requests](https://github.com/DarkJoij/simple-math/pulls) if it's mandatory. Thanks for reading and downloading.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkjoij%2Fsimple-math","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarkjoij%2Fsimple-math","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarkjoij%2Fsimple-math/lists"}