{"id":22535662,"url":"https://github.com/chinchalinchin/python-calc-cli","last_synced_at":"2025-07-13T19:07:28.752Z","repository":{"id":103707599,"uuid":"209833680","full_name":"chinchalinchin/python-calc-cli","owner":"chinchalinchin","description":"a python command line calculator. a project to help me understand discrete mathematics and numerical algorithms.","archived":false,"fork":false,"pushed_at":"2020-10-28T18:23:52.000Z","size":292,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T06:22:15.039Z","etag":null,"topics":["approximation-algorithms","mathematics","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chinchalinchin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-09-20T16:21:04.000Z","updated_at":"2021-01-23T03:54:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"ae09a936-38a7-4779-b367-22b343d09282","html_url":"https://github.com/chinchalinchin/python-calc-cli","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chinchalinchin/python-calc-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinchalinchin%2Fpython-calc-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinchalinchin%2Fpython-calc-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinchalinchin%2Fpython-calc-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinchalinchin%2Fpython-calc-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chinchalinchin","download_url":"https://codeload.github.com/chinchalinchin/python-calc-cli/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chinchalinchin%2Fpython-calc-cli/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265191121,"owners_count":23725264,"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":["approximation-algorithms","mathematics","python"],"created_at":"2024-12-07T10:08:12.193Z","updated_at":"2025-07-13T19:07:28.742Z","avatar_url":"https://github.com/chinchalinchin.png","language":"Python","readme":"_____________________________________________________________________________\r\n\u003ch1\u003eTHE BERTJEN COMMAND LINE CALCULATOR\u003c/h1\u003e\r\n_____________________________________________________________________________\r\n\r\n\u003ca href = \"https://github.com/chinchalinchin/bertjen\"\u003e Bertjen Github Repo\u003c/a\u003e\u003cbr\u003e\r\n_____________________________________________________________________________\r\n\r\n_____________________________________________________________________________\r\n\r\n\u003cb\u003eIntroduction\u003c/b\u003e\u003cbr\u003e\r\n_____________________________________________________________________________\r\n\r\nBertjen is a command line calculator that tries to use the bare minimum with regards to outside library imports. This means all mathematical functions and operations have been implemented with the basic arithmetical operations +, -, / and *, plus the usual logical operators FOR...EACH, NOT, AND, OR, and IF...THEN. \r\n\r\nThe purpose of this project to see how quickly and accurately these operations can be implemented using various techniques. \r\n\r\nFor example, there are currently three methods of approximating pi within Bertjen, one based on Liebniz's infinite series approximation, one on Newton's infinite series approximation and one based on John Machin's arctangent formula with the accompanying Taylor series approximation for arctangent. The Liebniz approximation takes significantly longer and produces less significant digits of accuracy, while the Machin approximation only requires 20 or so iterations versus the Newton approximation's 50.  Thus, we see the purpose of the project is in the author understanding the nature of finite mathematics and its implementation in computing machines. \r\n\r\nBertjen is broken up into two components: Berts and Jens. Berts are largely concerned with computation and approximation, while Jens are more concerned with user input validation  and output formatting, etc. Essentially, Berts do the calculation behind the scenes and Jens make sure those calculations get the correct input and then ensure the results are displayed appropriately\u003cbr\u003e\u003cbr\u003e\r\n_____________________________________________________________________________\r\n\u003cb\u003ePrerequisites\u003c/b\u003e\r\n_____________________________________________________________________________\r\nAll you need is Python! No numpy, no scipy, just sweet sweet Python.\r\n\r\n\u003ca href=\"https://www.python.org/downloads/\"\u003eDownload Python Here\u003c/a\u003e\u003cbr\u003e\u003cbr\u003e\r\n_____________________________________________________________________________\r\n\u003cb\u003eUsage\u003c/b\u003e\r\n_____________________________________________________________________________\r\nIf running from source, execute from the root folder the command\r\n\r\n\tpython ./bertjen.py\r\n\r\nThis will bring up the Bertjen Command Line Interface. Hopefully, the CLI should be relatively intuitive. A list of commands can be always be brought up with the 'M' menu command, printed here for completeness,\r\n\r\n\u003ci\u003eMain Commands\u003c/i\u003e\u003cbr\u003e\r\n\t1. CF : Count Function\u003cbr\u003e\r\n\t2. F : Factorial Function\u003cbr\u003e\r\n\t3. P : Power Function\u003cbr\u003e\r\n\t4. LOG : Logarithm Function\u003cbr\u003e\r\n\t5. E : Taylor Series Exponential Approximation\u003cbr\u003e\r\n\t6. LN : Halley's Method Natural Log Approximation\u003cbr\u003e\r\n\t7. COS : Taylor Series Cosine Approximation\u003cbr\u003e\r\n\t8. SIN : Taylor Series Sine Approximation\u003cbr\u003e\r\n\t9. TAN : Taylor Series Tangent Approximation\u003cbr\u003e\r\n\t10. ACOS : Taylor Series Arccosine Approximation\u003cbr\u003e\r\n\t11. ASIN : Taylor Series Arcsine Approximation\u003cbr\u003e\r\n\t12. ATAN : Taylor Series Arctangent Approximation\u003cbr\u003e\r\n\t13. SEC : Taylor Series Secant Approximation\u003cbr\u003e\r\n\t14. CSC : Taylor Series Cosecant Approximation\u003cbr\u003e\r\n\t15. COT : Taylor Series Cotangent Approximation\u003cbr\u003e\r\n\t16.ROOT : Binomial Series Root Approximation\u003cbr\u003e\r\n\t17. SQ : Newton's Method Square Root Approximation\u003cbr\u003e\r\n\t18. LPI : Liebniz Series Pi Approximation\u003cbr\u003e\r\n\t19. MPI : Machin Series Pi Approximation\u003cbr\u003e\r\n\t20. NPI : Newton Series Pi Approximation\u003cbr\u003e\r\n\t21. NORMPDF : Normal Probability Density Function\u003cbr\u003e\r\n\t22. BINPMF : Binomial Probability Mass Function\u003cbr\u003e\r\n\t23. NORMCDF : Normal Cumulative Distribution Function\u003cbr\u003e\r\n\t24. BINCDF : Binomial Cumulative Distribution Function\u003cbr\u003e\r\n\t25. BS : Black Scholes Option Function\u003cbr\u003e\r\n\r\n\u003ci\u003eAdmin Commands\u003c/i\u003e\u003cbr\u003e\r\n\t1. I : Integration Technique Settings\u003cbr\u003e\r\n\t2. V : Verbose Settings\u003cbr\u003e\r\n\t3. N : Angle Unit Settings\u003cbr\u003e\r\n\t4. S : Save Bertjen Configuration\u003cbr\u003e\r\n\t5. B : Calibrate Bertjen\u003cbr\u003e\r\n\t6. M : Print Menu\u003cbr\u003e\r\n\t7. H : Help Function\u003cbr\u003e\r\n\t8. Q : Quit\u003cbr\u003e\r\n\r\nThe 'H' help function provides a short description of all the functions Bertjen provides. Simply type \r\n\r\n\tH FUNCTION_NAME\r\n\r\nreplacing \u003ci\u003eFUNCTION_NAME\u003c/i\u003e with the appropriate function name. For example, \r\n\r\n\t\u003c\u003c h normcdf\r\n\t\u003e\u003e NORMAL CUMULATIVE PROBABILITY DISTRIBUTION FUNCTION\r\n\t\u003e\u003e Computes a normal probability --x P(X\u003cx) for a given mean\r\n\t\u003e\u003e --μ and standard deviation --σ\r\n\t\u003e\u003e ARGUMENTS\r\n\t\u003e\u003e --x : type : float :  Desired probability\r\n\t\u003e\u003e --μ : type : float :  Mean\r\n\t\u003e\u003e --σ : type : float :  Standard deviation\r\n\r\nNote that Bertjen is not case sensitive! \u003cbr\u003e\u003cbr\u003e\r\n_____________________________________________________________________________\r\n\u003cb\u003eFunction Input\u003c/b\u003e\r\n_____________________________________________________________________________\r\nBertjen is setup to receive the inputs directly from the command line if separated by a space, i.e.\r\n\r\n\tNORMCDF 3 4 5\r\n\r\nwill compute the normal cumulative probability up to 3 for a distribution with mean 4 and standard deviation 5. Bertjen will manually step through the program if not provided any arguments or provided the improper type of arguments, i.e. both\r\n\r\n\tNORMCDF\r\n\r\nand\r\n\t\r\n\tNORMCDF goobledygook\r\n\r\nwill initiate the command line program for that particular function. Bertjen will then step through the program and ask for the arguments of that function one by one.\u003cbr\u003e\u003cbr\u003e\r\n_____________________________________________________________________________\r\n\u003cb\u003eCalibration\u003c/b\u003e\r\n_____________________________________________________________________________\r\n\r\nIf Bertjen outputs an error, it may need calibrated to your system. Use the 'B' command to initate system calibration. Be sure to save your configuration with 'S' command, otherwise you will need to recalibrate the next time you start up Bertjen.\u003cbr\u003e\u003cbr\u003e\r\n_____________________________________________________________________________\r\n\u003cb\u003eCharacter Encoding\u003c/b\u003e\r\n_____________________________________________________________________________\r\nBertjen uses UTF-8 encoding to print Greek and Latin characters. (Hopefully, Hebrew soon. Need to learn more about Aleph-null and Aleph-one first.) If you are on Windows, you may run into the following UnicodeEncodingErrror\r\n\r\n\tUnicodeEncodeError: 'charmap' codec can't encode character '\\u03bc' in position 24: character maps to \u003cundefined\u003e\r\n\r\nOr something similar. If so, you need to set your terminal session encoding to UTF-8 with the following commands executed from the Windows Command Prompt,\r\n\r\n\tchcp 65001\r\n\tset PYTHONIOENCDOING=utf-8\r\n\u003cbr\u003e\u003cbr\u003e\r\n_____________________________________________________________________________\r\n\u003cb\u003eDockerfile\u003c/b\u003e\r\n_____________________________________________________________________________\r\n\r\n\r\nBuild the image with Docker from the root folder like you normally would,\r\n\r\n\tdocker build -t bertjen .\r\n\r\nWhen you run the image, make sure you do so with an interactive terminal,\r\n\r\n\tdocker run -it bertjen\r\n\u003cbr\u003e\u003cbr\u003e\r\n_____________________________________________________________________________\r\n\u003ch1\u003eTODO\u003c/h1\u003e\r\n_____________________________________________________________________________\r\n\r\n1. \u003cb\u003eFunction recursion\u003c/b\u003e\u003cbr\u003e\r\n_____________________________________________________________________________\r\n\r\nIn the future, Bertjen will (hopefully) feature function recursion so that commands such as\r\n\r\n\tCOS (PI*E(SIN(5)))\r\n\r\nwill have meaning. Still thinking about how to implement this functionality! \u003cbr\u003e\u003cbr\u003e\r\n2. \u003cb\u003eInteresting Normal CDF Behavior?\u003c/b\u003e\r\n_____________________________________________________________________________\r\nRight now, the Normal CDF simply uses a naive Simpson's Rule approximation (you can also set the Integration Technique to Left-Hand, Right-Hand or Trapezoid Rules, but Simpson's Rule provides the most accurate approximation). The algorithm as is also exploits symmetry in the normal distribution, so that if the desired probability is above the mean, the integral will be calculated from the mean to the point of interest and 0.5 will be add to the answer (i.e., half of the normal distribution is below the mean). The number of divisions is hardcoded into algorithm, so is equal in each case.\r\n\r\nIf the desired probability is to the left of the mean, the integral on the left hand side of the mean starts from the negligible point of 5 standard deviations away from the mean and integrates up to the desired location. \r\n\r\nThe calculations involving symmetry execute substantially faster than ones without, for some reason. Even though the same number of operations are being executed. Perhaps due to floating point arithmetic and round errors? \u003cbr\u003e\u003cbr\u003e\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchinchalinchin%2Fpython-calc-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchinchalinchin%2Fpython-calc-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchinchalinchin%2Fpython-calc-cli/lists"}