{"id":19418474,"url":"https://github.com/sudipto3331/false-position-numerical-method-implementation-in-python","last_synced_at":"2025-02-25T03:42:24.285Z","repository":{"id":254969601,"uuid":"848125660","full_name":"sudipto3331/False-Position-Numerical-Method-Implementation-in-Python","owner":"sudipto3331","description":"This repository contains a Python implementation of the False Position Method, also known as the Regula Falsi Method, for finding roots of nonlinear equations. Additionally, the script compares the performance of the False Position Method with the Bisection Method, saving results in an Excel file (`LAB2.xls`).","archived":false,"fork":false,"pushed_at":"2024-08-27T07:22:54.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-07T17:29:52.637Z","etag":null,"topics":["excel","excel-export","false-position-method","numerical-methods","python3","spyder-python-ide"],"latest_commit_sha":null,"homepage":"https://sudiptomondal.me/","language":"Python","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/sudipto3331.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2024-08-27T07:16:04.000Z","updated_at":"2024-08-27T07:25:23.000Z","dependencies_parsed_at":"2024-08-27T08:34:47.749Z","dependency_job_id":"ac7fc147-c3ad-436a-bb55-a20cb53e01eb","html_url":"https://github.com/sudipto3331/False-Position-Numerical-Method-Implementation-in-Python","commit_stats":null,"previous_names":["sudipto3331/false-position-method-implementation-in-python"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudipto3331%2FFalse-Position-Numerical-Method-Implementation-in-Python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudipto3331%2FFalse-Position-Numerical-Method-Implementation-in-Python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudipto3331%2FFalse-Position-Numerical-Method-Implementation-in-Python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sudipto3331%2FFalse-Position-Numerical-Method-Implementation-in-Python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sudipto3331","download_url":"https://codeload.github.com/sudipto3331/False-Position-Numerical-Method-Implementation-in-Python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240599180,"owners_count":19826959,"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":["excel","excel-export","false-position-method","numerical-methods","python3","spyder-python-ide"],"created_at":"2024-11-10T13:14:05.573Z","updated_at":"2025-02-25T03:42:24.263Z","avatar_url":"https://github.com/sudipto3331.png","language":"Python","readme":"# False Position Method Implementation in Python\n\nThis repository contains a Python implementation of the False Position Method, also known as the Regula Falsi Method, for finding roots of nonlinear equations. Additionally, the script compares the performance of the False Position Method with the Bisection Method, saving results in an Excel file (`LAB2.xls`).\n\n### Table of Contents\n- [False Position Method Theory](#false-position-method-theory)\n- [Dependencies](#dependencies)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Code Explanation](#code-explanation)\n- [Example](#example)\n- [Files in the Repository](#files-in-the-repository)\n- [Input Parameters](#input-parameters)\n- [Troubleshooting](#troubleshooting)\n- [Author](#author)\n\n### False Position Method Theory\nThe False Position Method is a numerical technique for finding roots of a function. It works by drawing a secant line between two points that bracket the root and using the intersection of this line with the x-axis as the next approximation. It combines elements of the Bisection and Secant methods.\n\n**Steps:**\n1. Choose initial guesses \\( x_l \\) and \\( x_u \\) such that \\( f(x_l) \\times f(x_u) \u003c 0 \\).\n2. Compute the intersection point \\( x_c \\) of the line connecting \\( (x_l, f(x_l)) \\) and \\( (x_u, f(x_u)) \\).\n3. Replace either \\( x_l \\) or \\( x_u \\) with \\( x_c \\) such that the interval continues to bracket the root.\n4. Iterate until the desired relative error is achieved or the maximum number of iterations is reached.\n\n### Dependencies\nTo run this code, you need the following libraries:\n- `numpy`\n- `math`\n- `xlwt`\n- `xlrd`\n- `xlutils`\n\n### Installation\nTo install the required libraries, you can use `pip`:\n```sh\npip install numpy xlwt xlrd xlutils\n```\n\n### Usage\n1. Clone the repository.\n2. Ensure the script and the Excel file (`LAB2.xls`) are in the same directory.\n3. Run the script using Python:\n    ```sh\n    python false_position_method.py\n    ```\n4. Provide the required inputs when prompted:\n    - Enter the first initial value (\\( x_l \\)).\n    - Enter the second initial value (\\( x_u \\)).\n    - Enter the desired percentage relative error.\n    - Enter the number of iterations.\n\n5. The script will compute the iterations and save the results, comparing both methods in an Excel file named `LAB2.xls`.\n\n### Code Explanation\nThe code starts by importing the necessary libraries and defining the function whose root is to be found. It then defines two functions for the Bisection Method and False Position Method. The script takes user input for initial values, desired relative error, and number of iterations, and then calls these functions. The results are written into an Excel sheet.\n\nBelow is a snippet from the code illustrating the main logic:\n\n```python\ndef fnc(x):\n    return (667.38/x)*(1-math.exp(-0.146843*x))-40\n\ndef bisection(fxl, fxu, err, ite):\n    # Initialization and iteration logic for Bisection Method\n    ...\n\ndef fasleposition(fxl, fxu, err, ite, index):\n    # Initialization and iteration logic for False Position Method\n    ...\n```\n\nThe code completes by saving the final results into the Excel file `LAB2.xls`, showing a comparison between the two methods.\n\n### Example\nBelow is an example of how to use the script:\n\n1. **Run the script**:\n    ```sh\n    python false_position_method.py\n    ```\n\n2. **Enter the input values**:\n    ```\n    Enter 1st initial value: 20\n    Enter 2nd initial value: 30\n    Enter desired percentage relative error: 0.001\n    Enter number of iterations: 50\n    ```\n\n3. **Output**:\n    - The script will compute the iterations using both the Bisection Method and False Position Method and print intermediate results on the console.\n    - The final results, comparing both methods, will be saved in an Excel file named `LAB2.xls`.\n\n### Files in the Repository\n- `false_position_method.py`: The main script for performing the False Position and Bisection Methods.\n- `LAB2.xls`: Excel file generated by running the script.\n\n### Input Parameters\nThe script prompts for the following input values:\n- Initial guess for the lower bound (`xl`).\n- Initial guess for the upper bound (`xu`).\n- Desired percentage relative error (`err`).\n- Number of iterations (`ite`).\n\n### Troubleshooting\n1. **Initial Input Values**: Ensure that the initial guesses bracket the root (`f(xl) * f(xu) \u003c 0`). If they do not, the script will print \"Wrong initial input\".\n2. **Function Evaluation**: The function `(667.38/x)*(1-math.exp(-0.146843*x))-40` is hardcoded. Modify it as needed for different functions.\n3. **Excel File Creation**: Ensure you have write permissions in the directory where the script is run to save the Excel file.\n4. **Python Version**: This script is compatible with Python 3. Ensure you have Python 3 installed.\n\n## Author\nScript created by sudipto3331.\n\n---\n\nThis documentation should guide you through understanding, installing, and using the False Position and Bisection Methods script. For further issues or feature requests, please open an issue in the repository on GitHub. Feel free to contribute by creating issues and submitting pull requests. Happy coding!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsudipto3331%2Ffalse-position-numerical-method-implementation-in-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsudipto3331%2Ffalse-position-numerical-method-implementation-in-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsudipto3331%2Ffalse-position-numerical-method-implementation-in-python/lists"}