{"id":24111380,"url":"https://github.com/skhelladi/eq_edit","last_synced_at":"2025-08-28T08:06:28.627Z","repository":{"id":215800047,"uuid":"739802014","full_name":"skhelladi/EQ_EDIT","owner":"skhelladi","description":"EQ_EDIT is a simple C++ code that evaluate a mathematical expression with variables and some standard mathematical functions given as a string.","archived":false,"fork":false,"pushed_at":"2024-01-16T12:12:39.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-11T02:33:37.396Z","etag":null,"topics":["equation-evaluator","mathematics"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skhelladi.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}},"created_at":"2024-01-06T15:36:34.000Z","updated_at":"2024-01-06T16:06:47.000Z","dependencies_parsed_at":"2024-01-06T17:23:24.833Z","dependency_job_id":"971bb1e2-dcdf-4655-b911-4f470aa83d9e","html_url":"https://github.com/skhelladi/EQ_EDIT","commit_stats":null,"previous_names":["skhelladi/eq_edit"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skhelladi%2FEQ_EDIT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skhelladi%2FEQ_EDIT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skhelladi%2FEQ_EDIT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skhelladi%2FEQ_EDIT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skhelladi","download_url":"https://codeload.github.com/skhelladi/EQ_EDIT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241113529,"owners_count":19911902,"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":["equation-evaluator","mathematics"],"created_at":"2025-01-11T02:33:44.268Z","updated_at":"2025-02-28T06:46:13.574Z","avatar_url":"https://github.com/skhelladi.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EQ_EDIT - A C++ Equation Evaluator\n\nEQ_EDIT is a simple C++ code that evaluate a mathematical expression with variables and some standard mathematical functions given as a string. The variables and functions used in the equation are defined and their values are passed to the function that evaluates the equation. The code is presented in a single header file `EQ_EDIT.hpp` which contains the `EQ_EDIT` class.\n\nThe code allows the following mathematical operators to be used in the equation:\n- `+` - Addition\n- `-` - Subtraction\n- `*` - Multiplication\n- `/` - Division\n- `^` - Power\n- `()` - Parentheses\n\nthe following mathematical functions to be used in the equation:\n- `abs` - Absolute value\n- `int` - Integer part\n- `frac` - Fractional part\n- `rond` - Round\n- `log` - Logarithm (base 10)\n- `ln` - Natural logarithm\n- `exp` - Exponential\n- `sin` - Sine\n- `cos` - Cosine\n- `tan` - Tangent\n- `sh` - Hyperbolic sine\n- `ch` - Hyperbolic cosine\n- `th` - Hyperbolic tangent\n- `asin` - Arcsine\n- `acos` - Arccosine\n- `atan` - Arctangent\n- `ash` - Hyperbolic arcsine\n- `ach` - Hyperbolic arccosine\n- `ath` - Hyperbolic arctangent\n\nand the following mathematical constants to be used in the equation:\n- `pi` - \u0026pi; number\n- `e` - Euler's number\n\nIt is possible to add new functions and constants to the code by modifying the `EQ_EDIT.hpp` file.\n\n## How it Works\nThe application uses the `EQ_EDIT` class to evaluate mathematical equations. The variables used in the equation are defined and their values are passed to the `Value` method of the `func_eq` object. This method evaluates the equation and returns the calculated value.\nAnother way to use the code is to define the variables and the equation using the `setVar` and `setEquation` methods of the `EQ_EDIT` class. The `getValue` method of the `func_eq` object, without any arguments, is then called to evaluate the equation.\n\n## How to Use the Code\nTo use the code, you need to include the `EQ_EDIT.hpp` header file in your code. You can then create an instance of the `EQ_EDIT` class and use it to evaluate mathematical equations. See the code examples below for more details.\n\n## Code example\n### Example 1\nA first example is presented in the `example1.cpp` file. \n```cpp\n#include \u003ciostream\u003e\n#include \"EQ_EDIT.hpp\"\nusing namespace std;\nint main()\n{\n    EQ_EDIT func_eq;\n    double x = 10;\n    double beta = 1.5;\n    string equation = \"-(x^2/2)+20+2*beta+alpha\";\n    double value    = func_eq.getValue(true,equation,{{\"x\",x},{\"beta\",beta},{\"alpha\",0.5}});\n    cout\u003c\u003c\"----------------------------------\"\u003c\u003cendl;\n    cout\u003c\u003c\"          EXAMPLE 1              \"\u003c\u003cendl;\n    cout\u003c\u003c\"----------------------------------\"\u003c\u003cendl;\n    cout \u003c\u003c \"Equation exp.: \" \u003c\u003c func_eq.getEquation() \u003c\u003c endl;\n    cout \u003c\u003c \"Number of variables: \" \u003c\u003c func_eq.getNVar() \u003c\u003c endl;\n    cout \u003c\u003c \"Value: \" \u003c\u003c value \u003c\u003c endl;\n    return 0;\n}\n```\n\nHere is a description of each line of code:\n```cpp\n#include \"EQ_EDIT.hpp\"\n```\nIncludes the `EQ_EDIT.hpp` header file which contains the `EQ_EDIT` class.\n\n```cpp\nEQ_EDIT func_eq;\n```\nCreates an instance of the `EQ_EDIT` class which is used to evaluate mathematical equations.\n\n```cpp\ndouble x = 10;\ndouble beta = 1.5;\nstring equation = \"-(x^2/2)+20+2*beta+alpha\";\n```\nDefines the variables `x`, `beta`, and `alpha` and the equation to evaluate.\n\n```cpp\ndouble value = func_eq.Value(true,equation,{{\"x\",x},{\"beta\",beta},{\"alpha\",0.5}});\n```\nCalls the `Value` method of the `func_eq` object to evaluate the equation. The equation expression, the variables, and their values are passed as arguments to the `Value` method. The first argument of the `Value` method is a boolean that indicates if the equation expression should be calculated or not. If this argument is set to `true`, the `Value` method returns the calculated value of the equation.If this argument is set to `false`, it returns `0`.\n\n```cpp\ncout \u003c\u003c \"Equation: \" \u003c\u003c func_eq.getEquation() \u003c\u003c endl;\ncout \u003c\u003c \"Number of variables: \" \u003c\u003c func_eq.getNVar() \u003c\u003c endl;\ncout \u003c\u003c \"Value: \" \u003c\u003c value \u003c\u003c endl;\n```\nDisplays the equation, the number of variables in the equation, and its calculated value.\n\n### Example 2\nAnother example is presented in the `example2.cpp` file. \n```cpp\n#include \u003ciostream\u003e\n#include \"EQ_EDIT.hpp\"\nusing namespace std;\nint main()\n{\n    EQ_EDIT func_eq;\n    double x = 10;\n    double beta = 1.5;\n    func_eq.setVar({{\"x\",x},{\"beta\",beta},{\"alpha\",M_PI/4}});\n    func_eq.setEquation(\"-(x^2/2)+20+2*beta+sin(alpha)\");\n    double value    = func_eq.getValue();\n    cout\u003c\u003c\"----------------------------------\"\u003c\u003cendl;\n    cout\u003c\u003c\"          EXAMPLE 2              \"\u003c\u003cendl;\n    cout\u003c\u003c\"----------------------------------\"\u003c\u003cendl;\n    cout \u003c\u003c \"Equation exp.: \" \u003c\u003c func_eq.getEquation() \u003c\u003c endl;\n    cout \u003c\u003c \"Number of variables: \" \u003c\u003c func_eq.getNVar() \u003c\u003c endl;\n    cout \u003c\u003c \"Value: \" \u003c\u003c value \u003c\u003c endl;\n    return 0;\n}\n```\nIn this example the variables are defined and the equation is set using the `setVar` and `setEquation` methods of the `EQ_EDIT` class:\n\n```cpp\nfunc_eq.setVar({{\"x\",x},{\"beta\",beta},{\"alpha\",M_PI/4}});\nfunc_eq.setEquation(\"-(x^2/2)+20+2*beta+sin(alpha)\");\ndouble value    = func_eq.getValue();\n```\nSets the values of the variables and the equation to evaluate. The `getValue` method of the `func_eq` object, *without any arguments*, is then called to evaluate the equation.\n\n\n## License\n\nThis project is licensed under the GPL-3 license.\n\nUnless you explicitly state otherwise, any contribution intentionally submitted by you for inclusion in this project shall be licensed as above, without any additional terms or conditions.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskhelladi%2Feq_edit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskhelladi%2Feq_edit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskhelladi%2Feq_edit/lists"}