# 2015S001/User talk:Mrkherad/Homework 10

### From CDS 130

## Contents |

## 1. Area estimation

Using Matlab to estimate the percentage of the area of the white shape in the box. You need to complete the matlab code provided below to obtain the image matrix.

In matlab, the follow code can be used to obtain a matrix (denoted as X) to represent the picture.

clear all; clc; M = imread('http://cds130.org/wiki/images/Iregular.jpg'); [X, map] = rgb2ind(M, 2); % the image matrix contains two colors only. image(X); colormap(map) colorbar [m, n] =size(X); % m and n correspond to the size of the image matrix.

counts=0; for i = 1:187 for j = 1:180 if X(i,j) == 0 counts = counts + 1; end end end percentage = counts / (187*180) percentage = 0.4870 (48.70%)

## 2. Integration

Given two mathematical functions and *g*(*x*) = *s**i**n*^{2}(*x*) − 0.5, calculate the area between the two curves from x=1.4 to x = 6.6 as shown in the following figure.

clear all; clc; xmin = 1.4; xmax = 6.6; n=100; dx=(xmax-xmin)/n; x=xmin:dx:xmax; f=(1./x).*(exp(-(log(x)-1).^2)); g=sin(x).^2-0.5; plot (x,f, '-g'); hold on plot (x, g, '-b'); area = 0; for x=1.4:dx:6.6-dx p=(1./x).*(exp(-(log(x)-1).^2)); x=x+dx; h=(1./x).*(exp(-(log(x)-1).^2)); area = area+abs((p+h)/2*dx); end area area = 1.2782

## 3. Calculation of PI

4. Area of an Ellipse. Suppose that we have an ellipse with major axis length 2a and minor axis length 2b. Without changing the answer to the problem, suppose that the major axis is on the x-axis. How do we find the area of the ellipse? (assuming a = 2 and b = 1; or any other values you want to use.)
Recall that the equation of an ellipse like the one picture above is given by: *x*^{2} / *a*^{2} + *y*^{2} / *b*^{2} = 1

## 4. Population Eqn.

Consider the following model of population

Every year, population increases a value of 10% of the population in the previous year. However, if the predicted population is over 100, a disease outbreak instantly kills 80% of this predicted population value. For example, if the predicted population is 110, then the next year the population is 0.2*110.

Use Matlab to plot population as a function of time for 40 years. Assume that the initial population is 20.

clear all; clc; P(1) = 20; for i = 1:40 P(i+1) = P(i) + 0.1*P(i); if P(i+1) > 100 P(i+1) = 0.2*P(i+1); end end P(40) Population at year 40 = 32.9158

## 5. Bacteria colony growth

Suppose a colony of 10000 bacteria is multiplying at the rate of r = 0.8 per hour per individual (i.e., an individual produces an average of 0.8 offspring every hour). How many bacteria are there after 10 hours? Assuming that the colony grows continuously and without restriction.

clear all; clc; B(1) = 1; for i = 1:10 B(i+1) = 0.8*B(i) + B(i); end B = B*10000; B(10) = 1.9836e+06

## 6. Radioactive Decay

The basic equation for modeling radioactive decay is

*d**X* / *d**t* = − *r**X*

where X is the amount of the radioactive substance at time t and r is the decay rate. Some radioactive substances decay into other radioactive substances which decay in turn. For example, Strontinum (*r*_{1} = 0.256 /hr) decays into Yttirum 92 ( *r*_{2} = 0.127 /hr ), which decays into Zirconium.

Starting at t = 0 with 5*x*10^{26} atoms of Strontium 92 and none of Yttrium. After 8 hours, how what are the compositions of the components?