I have implemented in C++ the code for a quasi-Newton method given by
$x_{n+1} = x_n - \dfrac{\delta f(x_n)}{f(x_n+\delta) - f(x_n)}$
for a computational project in which $f$ is a function given by:
$f(x) = 2e^{-ax}(a\sin(3x) + \cos(3x))$
One of the exercises asks to find the parameter $a$ and the coordinate $x$ so that the maximum value of the function $f$ is 3. In the problem is left as a suggestion that we use the above quasi-Newton method implemented to find the value of $x$ and the bisection method to find $a$. Any tip on how to do this?
Thanks,
Patrick
Your Quasi-Newton method is not correct, you need a $-$ after $x_n$. Note also that if $x$ is a local maximum, then $f'(x)=0$ and to solve this with your Quasi-Newton you don't have to provide $f''(x)$ analytically, as it's already estimated "in place" with finite differences ( i.e. $f'(x_0)= \frac{f(x_0+\delta) - f(x_0)}{\delta} + O(\delta)$).
After a quick test, I obtained $x = -0.09679574815$, $a= -6.209538561$. A plot confirms that the local maximum is $3$ at point $x$.
Another found solution is $x=-2.052921249$ and $a=0.1898554466$.
I applied "externally" the bisection method for the parameter $a$ and inside of it I used the quasi-Newton method in order to solve for $x$ the equation $f_a'(x)=0$ for different parameters $a$. As $(x,a)$ are coupled, you can't split the two methods.
I wrote the following C++ snippet: here
a1anda2are the leftmost and rightmost point of the starting interval in the bisection routine.