This piece of code answers 5.12 in Chapra’s Numerical Methods for Engineers. Useful for finding the max between the integrals [0,1] for the following function: f(x) = -2x^6 – 1.6x^4 +12x +1

Results: 13 iterations to get below error of <5% ; final xr: 0.90478

This answers Chapra’s 6.4. You have to run this as many times as you think there are roots, which is why it’s a good idea to graph the function first. I circled my initial guesses on the graph below for the hard-coded example: f(x) = -1 + 5.5x -4x^2 + 0.5x^3

I work as a bioinformatics developer in the clinical genomics field. I have a Master's degree in Computational Biology and Bioinformatics from George Mason University in Fairfax, VA. Interested in all things science and tech!
View all posts by Kevin Arvai