© Irfan Turk 2019
I. TurkPractical MATLABhttps://doi.org/10.1007/978-1-4842-5281-9_3

3. Economic Modeling

Irfan Turk1 
(1)
Nilufer, Bursa, Turkey
 

In this chapter, new functions that are used in the examples are first defined. Following that, simple and compound interest, percentage change, and cost, revenue, and profit topics are examined in different sections. Before the examples are presented, necessary formulas used in the solutions are explained in each section.

Preliminaries

In this section, new terminology used in this chapter is introduced. MATLAB has symbolic data types for calculations in algebraic equations as shown in Chapter 1. The diff(f,x) function takes the derivative of symbolic f with respect to x variable. As an illustration we can take a look at the following input typed at the command prompt.
> syms x
> f=x^3-7*x^2+6*x-61;
> y=diff(f,x)
y =
3*x^2 - 14*x + 6
> t=diff(f,x,2)
t =
6*x - 14
>
After defining x as a symbolic variable and f, the derivative of f is calculated with respect to x with diff(f,x) and the calculation is assigned to the y variable. Then second derivative of f function is calculated with diff(f,x,2) and the result is assigned to the t variable.
> syms x
> y=x^2+2*x-8;
> w=8*x+16;
> solve(y,x)
ans =
 -4
  2
> solve(w,x)
ans =
-2
>
In the preceding code, using the solve function , roots of y, and solution of w are found that make the equations zero.
> syms x
> y=3*x^2-2*x-6;
> MyFunc = matlabFunction(y);
> MyFunc(2)
ans =
     2
> MyFunc(3)
ans =
    15
>

Here, using matlabFunction(y), the equation for y is converted to a MATLAB function. After that y(2), and y(3) are evaluated with the MyFunc function.

Simple and Compound Interest

Interest is the fee paid to borrow money. In most cases, interest is paid when people put their money in bank accounts (i.e., into savings accounts), depending on the contract. In general, two types of interest are calculated, simple and compound interest.

Simple Interest

Simple interest is calculated by multiplying the principal amount , annual rate, and time measured by year. For simple interest, the earned amount is not included in the principal amount at the end of the year. In other words, simple interest is only earned on the principal amount. If the time is not given in years, then it is converted to years. As an example, if the time is given as six months, then time is calculated as $$ T=frac{1}{12}ast 6=0.5 $$. If it is given as 30 days, then the time is calculated as $$ T=frac{1}{365}ast 30 $$ (sssuming that a year is calculated as 365 days). For calculating simple interest, the following formula is used.
$$ I=Past Rast T $$

where I is the interest, P is the principal, R is the annual interest rate, and T if the time measured in years.

Example 3-1. Write code to calculate payment amount for a certain principal loan, annual rate, and time in months for a bank. The code should ask the user these values, and should print the total payment and interest paid on the screen.

Solution 3-1. The following code can be used to accomplish the given task.

Example3p1.m
%Example3p1
%This code calculates simple interest
P = input('Enter Principal Amount: ');
R = input('Enter Annual Rate: ');
T = input('Enter Time As Month: ');
Interest=P*R*(1/12)*T;
Total = P + Interest;
fprintf('Paid Interest Amount is: %.2f ',Interest)
fprintf('Total Payment is: %.2f ',Total)
In the code, the input function is used to enter a value on the screen. Once the value is entered, it is assigned to P, R, and T as specified earlier. Once the code is run, the following output is obtained.
> Example3p1
Enter Principal Amount: 2000
Enter Annual Rate: 0.20
Enter Time As Month: 24
Paid Interest Amount is: 800.00
Total Payment is: 2800.00
>

Example 3-2. Omar put $80,000 into a bank with a 35% annual interest rate. He plans to withdraw his money at the end of 19 months after depositing it. The bank allows customers to withdraw their funds monthly as well. Write code to calculate the amount of money he will ger at the end of 19 months.

Solution 3-2. The following code can be used to accomplish the given task.

Example3p2.m
%Example3p2
%This code calculates interest
P = 8e+4;
R=35/100;
T=(1/12)*18;
I=P*R*T;
Balance = P + I;
fprintf('Balance is %.2f ',Balance);
Once the code is run, the following output is obtained.
> Example3p2
Balance is 122000.00
>

Compound Interest

Compound interest is different from simple interest. For compound interest, interest is earned on the interest accrued as well. After calculating the interest on principal amount, that value is added to the principal and the new amount becomes the new principal amount. The same process is repeated up to the present or for each cycle. To find only the earned interest, the principal amount is subtracted from the total earnings. For the calculation of compound interest, the following formula is used.
$$ I=Past {left(1+{R}^{prime}
ight)}^C-P $$
where I is the Interest, P is the principal, R’ is the periodic interest rate, and C is the compounding period. Periodic interest rate, R’, is the rate applied to the sum of the principal amount and earned interest for every period. Compounding period, C, is the the total number periods for which the interest is applied. Periodic interest rate is calculated by dividing the annual rate by yearly compounding periods.
$$ {R}^{prime }=frac{Annual rate}{Periods per year} $$
As an illustration, for P = $100, annual rate = 15%, periods per year = 3 (R′ = 5%), and C = 4, total earned amounts (balances) can be calculated for 16 months as shown in Table 3-1.
Table 3-1

An Illustration

Period

Interest

Balance

Starting

 

$100.00

4 months

$100.00*5%=$5.00

$105.00

8 months

$105.00*5%=$5.25

$110.25

12 months

$110.25*5%=$5.51

$115.76

16 months

$115.76*5%=$5.79

$121.55

Example 3-3. Write code to calculate the total balance with a compound interest rate for the information given in Table 3-1.

Solution 3-3. The following code can be used to accomplish the given task.

Example3p3.m
%Example3p3
%This code calculates compound interest
format short
P = 100;
Rprime=0.05;
C=4;
Balance = P*((1+Rprime)^C);
disp(Balance)
Once the code is run, the following output is obtained.
> Example3p3
  121.5506
>

Example 3-4. Jennifer puts $150,000 into a bank account that pays a compound interest rate annually of 12%. If she gets her money from the bank after 5 years, how much interest does she get?

Solution 3-4. The following code can be used to accomplish the given task.

Example3p4.m
%Example3p4
%This code calculates compound interest
format short
P = 15e+4;
Rprime=0.12;
C=5;
Balance = P*((1+Rprime)^C);
Interest = Balance - P;
fprintf('Obtained interest: %.20f ',Interest)
Once the code is run, the following output is obtained.
> Example3p4
Obtained interest: 114351.25248000008286908269
>

Percentage Change

We often encounter problems with percentage change in real life. There are three important concepts to understand to solve such types of problems.
  • More than x% of A = $$ A+Aast frac{x}{100}=Aast frac{left(100+x
ight)}{100} $$

  • Less than x% of A = $$ A-Aast frac{x}{100}=Aast frac{left(100-x
ight)}{100} $$

  • % change = $$ frac{new  value- old  value}{old  value}ast 100 $$ percent

Example 3-5. Martin’s annual salary is $50,000 this year. He will get a 20% raise for the next year. What will Martin’s annual salary be for the next year?

Solution 3-5. The following code can be used to calculate the salary.

Example3p5.m
%Example3p5
%This code calculates percentage increment
Salary = 5e+4; %5e+4 = 50000
NextY = Salary*(120/100);
fprintf('Martins Next Year Salary is: %.2f ',NextY)
Once the code is run, the following output is obtained.
> Example3p5
Martins Next Year Salary is: 60000.00
>

Example 3-6. Martin’s market sells melon with a 40% markup at $28 per kilogram. If he wants to sell it with a 20% discount from the original cost, how much does the melon cost Martin per kilogram? Write code that shows the cost and price after discount.

Solution 3-6. The following code can be used to calculate the cost and discounted price.

Example3p6.m
%Example3p6
%This code calculates percentage
Melon = 28;
CostAmount = Melon*(100/140);
NewPrc = CostAmount*(80/100);
fprintf('Melon costs: %.2f per kg ',CostAmount);
fprintf('Price After Discount: %.2f per kg ',...
    NewPrc);
Once the code is run, the following output is obtained.
> Example3p6
Melon costs: 20.00 per kg
Price After Discount: 16.00 per kg
>

Example 3-7. A bookstore sells a book at $50 and the price was reduced to $35. What is the percentage change on the price of the book?

Solution 3-7. The following code can be used to calculate the percentage change.

Example3p7.m
%Example3p7
%This code calculates % change
OldPrice = 50;
NewPrice = 35;
PercChange = ((NewPrice-OldPrice)/OldPrice)*100;
fprintf('Percentage Change= %.2f ',PercChange);
Once the code is run, the following output is obtained.
> Example3p7
Percentage Change= -30.00
>

As shown in the output, there is a negative (-) sign in front of 30.00. That indicates that the price has decreased. If it is positive (+), then it indicates that there is an increase.

Cost, Revenue, and Profit

In all businesses, keeping a clear and proper financial account is extremely important. Calculation of cost, revenue, and profit plays an important role in this regard. In this section, we deal with these three important concepts.

Cost

Cost, also known as total cost, is the monetary value spent to produce or obtain an item. In general, the cost of something can be calculated by using the linear function
$$ C(x)= mx+b $$

The marginal cost is represented by m, and b represents the fixed costs.

Example 3-8. Alexander’s biking company produces bike to sell. Production of each bike costs the company $50 and other fixed costs of the company are $35. Write code to calculate the total cost of produced bikes. The code should ask the for number of bikes produced to complete the calculation.

Solution 3-8. The following code can be used to accomplish the given task.

Example3p8.m
%Example3p8
%This code calculates cost (total cost)
Number = input('Number of bikes for production ');
Cost = @(x) 50*x+35;
CostCalculation = Cost(Number);
disp(['The cost is ', num2str(CostCalculation)])
Once the code is run, and number of bikes is entered as 10, the following output is obtained.
> Example3p8
Number of bikes for production
10
The cost is 535
>

Revenue

Revenue is the total money obtained from selling Q items at price P.
$$ R=Qast P $$

In this equation, R represents revenue, Q represents the number of items sold, and P represents the price of each item sold. Finding the total revenue by using the given formula is not that difficult. There are questions that require the user to find the maximum revenue in different cases. The next example is such a question.

Example 3-9. Alexander’s cinema company sells tickets for a film showing. The cinema has 1,000 seats. One ticket costs $8 currently. Alexander wants to increase the price. From past experience, he thinks that if he increases the price $0.50 for each ticket, then 50 fewer people will attend the showing. Find the price of a ticket that maximizes revenue.

Solution 3-9. Let x be the number of $0.50 increases. Therefore, $8.00 + $0.50x represents the price of one ticket and 1,000 - 50x represents the number of tickets sold. Then the revenue can be calculated as R = (1000 − 50x) ∗ (8.00 + 0.50x). From here, we can write R =  − 25x2 + 100x + 8000. The following code can be used to accomplish the given task. Then we need to find an x value that maximizes the R value. This is the part where we need to enter into the code and solve for x to make R the maximum value. The following code can be used to achieve this.

Example3p9 .m
%Example3p9
%This code finds maximum value
syms x
R = -25*x^2+100*x+8000;
Derivat = diff(R,x);
Number = solve(Derivat,x);
EvalFunc = matlabFunction(R);
MaxVal = EvalFunc(double(Number));
disp(['Maximum Revenue is ',...
    num2str(MaxVal)])

In this code, the R function is entered as a symbolic function. Then its derivative is found by using the diff function. The obtained linear equation is solved by using the solve function. The obtained Number value shown is a symbolic data value. To convert it to a floating number, the double function is used. In the meantime, the R symbolic function is converted to a MATLAB function to evaluate R at x=Number value. Finally, the maximum value is shown with the disp function.

Once the code is run, the following output is obtained.
> Example3p9
Maximum Revenue is 8100
>

Remark 3-1. For quadratic equations (i.e., f(x) = ax2 + bx + c, a ≠ 0 and a, b, c ∈ R), maximum value or minimum value can be calculated depending on the sign of a. If the sign is negative (-), then the maximum value can be derived from the equation. If the sign is positive (+), then the minimum value of the equation can be found. This can be done in two ways. In the first way, $$ fleft(frac{-b}{2a}
ight) $$ gives us the maximum or minimum value. In the second case, the derivative of f(x) is calculated, and the f(x) = 0 equation is solved. The root of f(x) gives us the maximum or minimum value depending on the sign of a as well.

In the preceding problem, the second method is preferred for finding the maximum value.

Profit

Profit can be defined as the difference between the revenue (total revenue) and the cost (total cost).
$$ Pr =mathrm{R}-mathrm{C} $$

where Pr stands for profit, R stands for revenue, and C stands for cost.

Example 3-10. A company sells t-shirts with cost function C(x) = 3 + 2x, and the revenue function is R(x) =  − x2 + 4x + 12 where x indicates the number of t-shirts. For the maximum revenue value R, find x. Then by using the same x, calculate cost (C) and profit (Pr).

Solution 3-10. The following code can be used for the solution.

Example3p10.m
%Example3p10
%This code profit
syms x
R = -x^2+4*x+12;
Derivat = diff(R,x);
Number = double(solve(Derivat,x));
C = @(x) 3+2*x;
Rev = @(x) -x^2+4*x+12;
disp(['For maximum R, x =',...
    num2str(Number)])
Profit=Rev(Number)-C(Number);
disp(['Profit, Pr=',...
    num2str(Profit)])
Here, R, which stands for revenue, is defined in the fourth row. Using this, the maximum x variable is calculated by taking its derivative and setting it equal it to zero so that its solution can be found using the solve function. Then the same revenue and cost function are defined as anonymous functions. These functions are evaluated at x=Number, and the results are shown with the disp function . Once the code is run, the following output is obtained.
> Example3p10
For maximum R, x =2
Profit, Pr=9
>

Problems

  • 3.1. Bushra put her $180,000 into a bank with a 25% annual interest rate (simple). She plans to withdraw her money at the end of 34 months after depositing. The bank allows customers to withdraw their funds monthly as well. Write code to calculate the amount of money Bushra gets at the end of 34 months.

  • 3.2. Alexander puts $240,000 into a bank account that pays a compound interest rate of 20% annually. If he gets his money from the bank after 8 years, how much interest does he get?

  • 3.3. David’s market sells watermelon with a 30% markup at $39 per kilogram. If he wants to sell it with a 10% discount from of the original cost, how much does the watermelon cost David per kilogram? Write code that shows the cost and price after discount.

  • 3.4. A coffee shop sells a mug for $20 and then changes the price to $25. What is the percentage change on the price?

  • 3.5. Benjamin’s biking company produces bikes to sell. The production of each bike costs the company $40 and other fixed costs to the company are $25. Write code to calculate the total cost of the bikes produced. The code should also calculate the cost of producing seven bikes.

  • 3.6. Lily’s cinema company sells tickets for a film showing. The cinema has 1,200 seats. One ticket currently costs $10. Lily wants to increase the price. From past experience, Lily thinks that if she increases the price $0.50 for each ticket, then 20 fewer people will attend the showing. Find the price of the ticket that maximizes revenue.

  • 3.7. For a given function R(x) = 2x2 − 4x + 2 find the minimum value of R(x). Explain the possibility of finding the maximum value of R(x).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.232.95