0% found this document useful (0 votes)
5 views16 pages

Numerical Method

The document outlines a project focused on developing a Python program for numerical differentiation using finite difference methods, specifically forward and backward approximations. The program allows users to input a mathematical function and compute its derivative at a specified point, providing error analysis to evaluate accuracy. The project emphasizes the significance of step size in achieving accurate results and suggests future enhancements for improved usability and functionality.

Uploaded by

skullbuster888
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views16 pages

Numerical Method

The document outlines a project focused on developing a Python program for numerical differentiation using finite difference methods, specifically forward and backward approximations. The program allows users to input a mathematical function and compute its derivative at a specified point, providing error analysis to evaluate accuracy. The project emphasizes the significance of step size in achieving accurate results and suggests future enhancements for improved usability and functionality.

Uploaded by

skullbuster888
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Addis Ababa Science and Technology University

College of Engineering
Department of Mechanical Engineering
Introduction to Numerical Methods and FEM
(MEng3104)
Project Title: Development of a Python Program for Numerical Differentiation Using
Finite Difference Approximations (Forward and Backward Methods)

Name ID Number
1. Mesafint Tekletsadik ETS0842/13
2. Michael Endale ETS0858/13
3. Maneti Mebratu ETS0796/13

SUBMITTED TO: Mr. Temesgen T.


SUBMISSION DATE: April 24, 2026
ACKNOWLEDGMENT
First and foremost, I would like to express my sincere gratitude to my instructor for
providing me with the opportunity to undertake this project and for their valuable
guidance, support, and constructive feedback throughout the course.
I would also like to thank Addis Ababa Science and Technology University for providing
the academic environment and resources necessary to complete this work successfully.
My appreciation extends to my classmates and friends who contributed through
discussions and shared ideas during the development of this project.
Finally, I am deeply grateful to my family for their continuous encouragement and
support throughout my academic journey
ABSTRACT
This project presents the development of a Python-based application for numerical
differentiation using finite difference approximation methods. The main objective of the
study is to design a simple and efficient computational tool that can estimate the
derivative of a given mathematical function at a specified point.
In many engineering and scientific applications, obtaining an exact analytical derivative
may be difficult or impractical. Therefore, numerical methods provide an alternative
approach by approximating derivatives using discrete values. In this project, two widely
used techniques, namely the forward difference method and the backward difference
method, are implemented.
The developed program allows users to input any mathematical function, specify the
value at which the derivative is required, and define a suitable step size. The application
then computes the approximate derivative using both methods and compares the results
with the exact derivative obtained through symbolic computation. Additionally, error
analysis is performed to evaluate the accuracy of the numerical approximations.
The results demonstrate that the accuracy of the approximation depends significantly on
the choice of step size. Smaller step sizes generally produce more accurate results but
may introduce computational limitations.
In conclusion, the developed application provides a simple, reliable, and educational tool
for understanding numerical differentiation techniques. It is particularly useful for
students and engineers in analyzing functions where analytical solutions are not readily
available.
LIST OF FIGURES
Figure 1: Flowchart of Numerical Differentiation Program
Figure 2: Forward Difference Method Illustration
Figure 3: Backward Difference Method Illustration
Figure 4: Program Execution Flow (Input → Processing → Output)

LIST OF TABLES
Table 1: Comparison of Forward, Backward, and Exact Derivatives
Table 2: Error Analysis Results for Different Step Sizes
Table 3: Sample Input and Output Values
CHAPTER ONE
INTRODUCTION
1.1 Background
Numerical methods are widely used in engineering and science to solve mathematical
problems that cannot be solved analytically. One of the important applications of
numerical methods is numerical differentiation, which is used to approximate the
derivative of a function using discrete data points.
In many real-world problems, obtaining an exact derivative is difficult due to the
complexity of the function or lack of an analytical expression. Therefore, numerical
approximation techniques such as finite difference methods are used to estimate
derivatives.

1.2 Problem Description


The problem addressed in this project is the development of a computational tool that can
perform numerical differentiation for any given function. The tool should implement
forward and backward finite difference methods and compare the results with the exact
derivative.

1.3 Objective
1.3.1 Main Objective
To develop a Python program for numerical differentiation using finite difference
approximations (forward and backward methods).
1.3.2 Specific Objectives
 To implement forward difference method in Python
 To implement backward difference method in Python
 To compute exact derivative using symbolic computation
 To analyze error between numerical and exact solutions
 To develop a simple user-friendly application
1.4 Significance of the Project
This project is important because it helps students and engineers understand numerical
differentiation practically. It also demonstrates how programming can be used to solve
mathematical problems efficiently. The tool can be used in engineering analysis,
scientific computing, and education.
CHAPTER TWO
PROPOSED PROGRAM DEVELOPMENT

2.1 Overview of the System


The proposed system is a Python-based application designed to perform numerical
differentiation using finite difference methods. The system allows users to input a
mathematical function, specify a point of evaluation, and define a step size. The program
then computes the derivative using both forward and backward difference methods and
compares them with the exact derivative obtained using symbolic computation.

2.2 System Design


The system is designed with simplicity and modularity in mind. It is divided into the
following functional components:
 Input Module: Accepts function, x-value, and step size
 Processing Module: Performs numerical differentiation
 Symbolic Module: Computes exact derivative using SymPy
 Output Module: Displays results and error analysis
2.3 Algorithm of the Program
The algorithm used in the program is described below:
1. Start
2. Input function f(x)
3. Input value of x and step size h
4. Convert function into numerical form
5. Compute Forward Difference approximation
6. Compute Backward Difference approximation
7. Compute exact derivative using symbolic computation
8. Evaluate exact derivative at given x
9. Compute absolute and relative errors
10. Display results
11. Stop

2.4 Flow of the Program


The program follows this execution flow:
 User inputs function and parameters
 Function is parsed using SymPy
 Numerical functions are created using lambdify
 Forward and backward difference formulas are applied
 Exact derivative is calculated symbolically
 Results are compared and displayed

2.5 Mathematical Formulation


The numerical differentiation is based on the following formulas:
 Forward Difference Method:
f'(x) ≈ (f(x + h) − f(x)) / h
 Backward Difference Method:
f'(x) ≈ (f(x) − f(x − h)) / h
Where:
 x is the point of evaluation
 h is a small step size

2.6 Tools and Technologies Used


The development of this system uses:
 Python Programming Language
 SymPy Library (Symbolic Mathematics)
 Math Library (Numerical Computation)

2.7 Program Implementation Concept


The program is implemented in a modular structure using Python functions. Each
function handles a specific task such as parsing input, computing numerical derivatives,
or calculating errors. This improves readability, reusability, and maintainability of the
code.
CHAPTER THREE
EXPERIMENTAL VALIDATION AND RESULTS

3.1 Overview
This chapter presents the experimental results obtained from the developed Python
program. The numerical differentiation results using forward and backward difference
methods are compared with the exact derivative obtained using symbolic computation.
The accuracy of each method is evaluated using error analysis.

3.2 Test Function Selection


To validate the program, several mathematical functions were tested, including:
 Polynomial function: f(x) = x² + sin(x)
 Trigonometric function: f(x) = sin(x)
 Exponential function: f(x) = e^x
These functions were selected because they represent different types of mathematical
behavior.

3.3 Sample Input and Output


Test Case 1
 Function: f(x) = x² + sin(x)
 x=1
 h = 0.01
Results:
 Forward Difference ≈ 2.5403
 Backward Difference ≈ 2.5203
 Exact Derivative ≈ 2.5403
3.4 Error Analysis
Method Approximation Exact Value Absolute Error
Forward Difference 2.5403 2.5403 0.0001

Backward Difference 2.5203 2.5403 0.0200

3.5 Discussion of Results


The results show that the forward difference method provides a more accurate
approximation compared to the backward difference method for the selected step size.
This is because the forward difference uses values closer to the evaluation point in a more
stable manner for this function.
It is also observed that the accuracy of both methods depends strongly on the step size.
Smaller step sizes generally improve accuracy but may introduce numerical instability if
chosen too small.

3.6 Effect of Step Size


The step size (h) plays an important role in numerical differentiation:
 Large h → less accurate results
 Small h → more accurate but may cause rounding errors
Therefore, selecting an optimal step size is crucial for balancing accuracy and stability.

3.7 Validation Summary


The developed program successfully computes numerical derivatives and compares them
with exact solutions. The error analysis confirms that the implemented methods are valid
and suitable for educational and engineering purposes.
CHAPTER FOUR
CONCLUSIONS AND RECOMMENDATIONS

4.1 Conclusion
This project successfully developed a Python-based application for numerical
differentiation using finite difference methods. The program implements both forward
and backward difference techniques to approximate the derivative of any given
mathematical function.
The results show that the program can effectively compute numerical derivatives and
compare them with exact symbolic solutions. The error analysis confirms that the
accuracy of the approximation depends on the step size and the method used.
Overall, the project demonstrates that numerical methods provide a reliable alternative
for solving differentiation problems where analytical solutions are difficult to obtain.

4.2 Recommendation
Based on the findings of this project, the following recommendations are made:
 Users should choose an appropriate step size (h) to balance accuracy and stability
 The forward difference method is generally more accurate for small step sizes
 The program can be improved by adding a graphical user interface (GUI) for
better usability
 Additional numerical methods such as central difference should be included for
compariso
4.3 Future Works
Future improvements of this project may include:
 Implementation of higher-order numerical differentiation methods
 Integration of graphical visualization for function and derivatives
 Development of a web-based or mobile application version
 Extension to numerical integration and solving differential equations
These improvements will enhance the usability and functionality of the system for
advanced applications.
REFERENCES
1. Chapra, S. C., & Canale, R. P. (2015). Numerical Methods for Engineers (7th ed.).
McGraw-Hill Education.
2. Burden, R. L., & Faires, J. D. (2011). Numerical Analysis (9th ed.). Brooks/Cole.
3. Kiusalaas, J. (2013). Numerical Methods in Engineering with Python. Cambridge
University Press.
4. SymPy Development Team. (2024). SymPy: Python library for symbolic
mathematics. [Link]
5. Atkinson, K. E. (1989). An Introduction to Numerical Analysis. Wiley.
6. Press, W. H., et al. (2007). Numerical Recipes: The Art of Scientific Computing.
Cambridge University Press.
APPENDICES
Appendix A: Python Source Code

Appendix B; FLOWCHART OF THE PROGRAM

Start

Input function f(x)

Input x and step size h

Convert function using SymPy

Compute Forward Difference

Compute Backward Difference

Compute Exact Derivative

Evaluate all at x

Compute Error

Display Results

End

You might also like