This program solves a system of two nonlinear algebraic equations:
x - y³ = 0 ln(x+2) - y = 0
using four iterative methods:
- Simple iteration (fixed-point iteration)
- Newton's method (with analytical Jacobian)
- Modified Newton's method (constant Jacobian matrix)
- Discrete Newton's method (finite-difference approximation of derivatives)
The program finds the two roots:
- Root 1: (-1.696595, -1.192686)
- Root 2: (97.07366, 4.59586)
Convergence is compared in terms of number of iterations. A Python script visualises the functions and the level lines of the residual sum of squares.
- C++ compiler with C++17 support (e.g., g++, clang++)
- GNU Make
- Python 3 with matplotlib and numpy (for visualisation)
git clone <your-repo-url>
cd <project-folder>
make # compile the program
make run # compile and run
Alternatively:
make
./nonlinear_system
To clean up:
make clean
After running ./nonlinear_system, the console shows a table comparing the four methods:
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– | | x | y | iter_num | –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– | simple iteration | 9.707e+01 | 4.596e+00 | 50 | –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– | newton | 9.707e+01 | 4.596e+00 | 6 | –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– | mod newton | 9.707e+01 | 4.596e+00 | 8 | –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– | discr newton | 9.707e+01 | 4.596e+00 | 6 | ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
(The exact values depend on the initial approximation and tolerance.)
Additionally, a Python script create_plot.py will be launched to display the graphs of the functions and the level lines of the residual sum of squares, with the roots marked.
. ├── Makefile ├── README.md ├── .gitignore ├── LICENSE ├── create_plot.py # Python script for visualisation ├── src/ │ ├── main.cpp │ ├── functions.cpp │ └── functions.h ├── docs/ │ └── task.pdf └── build/ # object files (ignored)
Name: @g30613740 Philip K.
Year: 2025
This project is distributed under the MIT License.
