- Add output parameter to methods for objective function calls - Adjust the code to reduce objective function calls to some methods
		
			
				
	
	
		
			38 lines
		
	
	
		
			931 B
		
	
	
	
		
			Matlab
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			931 B
		
	
	
	
		
			Matlab
		
	
	
	
	
	
| %
 | |
| % The main script for the assignment.
 | |
| % * Calls the bisection method for different epsilon values (Question 1)
 | |
| % * Calls every method for different lambda values, in order to plot
 | |
| %   the iterations needed. (All questions, part A)
 | |
| % * Calls every method for 3 different lambda values, in order to plot
 | |
| %   the [a, b] convergence. (All questions part B)
 | |
| %
 | |
| 
 | |
| disp (" ");
 | |
| disp (" ");
 | |
| disp ('1. Number of iterations for different epsilon values for min_bisection');
 | |
| disp ('----');
 | |
| bisection_over_epsilon;
 | |
| 
 | |
| methods = {
 | |
|     @min_bisection;
 | |
|     @min_golden_section;
 | |
|     @min_fibonacci;
 | |
|     @min_bisection_der
 | |
| };
 | |
| 
 | |
| disp (" ");
 | |
| disp (" ");
 | |
| disp ('2. Number of iterations for different lambda values');
 | |
| disp ('----');
 | |
| for i = 1:length(methods)
 | |
|     iterations_over_lambda(methods{i});
 | |
| end
 | |
| 
 | |
| 
 | |
| disp (" ");
 | |
| disp (" ");
 | |
| disp ('3. [a, b] interval convergence');
 | |
| disp ('----');
 | |
| for i = 1:length(methods)
 | |
|     interval_over_iterations(methods{i});
 | |
| end |