Task 2–1: Optimizing Functions
Use a solve block to find a number of maxima points of the zeroth order Bessel function of the first kind J0.
When possible, it is a good practice to plot the function that you want to optimize. With this approach, you can choose the appropriate guess values.
1. Plot the J0 function.
The J0 function has many maxima and minima points. Specifying a guess value helps in finding the closest one.
2. Insert a solve block, define the guess value for the maximum to be x1=5, and then use the maximize function to find the maximum around x1.
| Contrary to the find function, you must enter the J0 function without its list of arguments. |
3. Calculate the horizontal and vertical coordinates of the first maximum by evaluating xmax1 and J0(xmax1) outside the solve block.
4. Change the guess value and find the corresponding maximum.
5. Calculate the horizontal and vertical coordinates of the second maximum by evaluating xmax2 and J0(xmax2) outside the solve block.
6. Plot the two maxima points on the original plot.
Using the maximize Function Outside Solve Blocks.
When you do not have to specify constraints, you can use the maximize function outside solve blocks.
1. Type the first guess value and recalculate the corresponding maximum point.
2. Type the second guess value and recalculate the corresponding maximum point.
The same maximum points are returned by the maximize function.