A program written in Julia for solving minimisation problems using bisection
Algorithm
The program takes in four arguments: the first derivative of the objective function, the lower bound, the upper bound and the error tolerance.
It returns the approximate solution x and the number of iterations.
To run the program easily, you might want to check out the online Julia compiler and interpreter by Replit.
Alternatively, run julia main.jl
from the terminal. The results are printed as follows:
The approximate minimal point of the function is x ≈ 2.0786
The bisection method took 15 iterations.
To visualise the algorithm at work, one can perhaps keep track of the points visited when running the program (use print statements to log the x value for each iteration) and plot them on the graph of the objective function.
These are created using Desmos, keeping track of all 15 iterations of the program.