# Integration exercises

### From CDS 130

## 1. Area estimation

Using Matlab to estimate the percentage of the area of the shape in the box.

## 2. Integration

Consider the function . Write a Matlab program which

- asks the user to enter values xmin and xmax;
- (optional) plots this function from
*x**m**i**n*to*x**m**a**x*using a logarithmic y-axis; - calculates the area under this curve between
*x**m**i**n*and*x**m**a**x*.

Note: Use "input" to request user input in MATLAB. see http://www.mathworks.com/help/techdoc/ref/input.html for the documentation of input.

Request a text response. Assign a default value ('Y') by checking for an empty matrix.

reply = input('Do you want more? Y/N [Y]: ', 's'); if isempty(reply) reply = 'Y'; end

## 3. Calculation of PI

Suppose you don't know the value of π, but you know the area of a disk (the region inside a circle) is π*r*^{2} when the circle has radius r. Design a computational method, and implement the method in Matlab to calculate the value of π based on this information. (For example, you could draw a disk in an image, and calculate the area of the disk.). How accurate is your estimation of π?