Chapter 1 Number System and Numerical Calculations



Chapter 1 Number System and Numerical CalculationsSafarzadehTable of ContentsTOC \o "1-2" \h \z \uThe Number System: PAGEREF _Toc23692966 \h 2Natural Numbers: PAGEREF _Toc23692967 \h 2Rational Numbers: PAGEREF _Toc23692968 \h 2Irrational Numbers: PAGEREF _Toc23692969 \h 2Real Numbers: PAGEREF _Toc23692970 \h 3Purely Imaginary Numbers: PAGEREF _Toc23692971 \h 3Complex Numbers: PAGEREF _Toc23692972 \h 3Absolute Value of a Real Number: PAGEREF _Toc23692973 \h 3The Order of Arithmetic Operations: PAGEREF _Toc23692974 \h 3Application in Finance: PAGEREF _Toc23692975 \h 4Future Value or Compounding PAGEREF _Toc23692976 \h 4Present Value or Discounting PAGEREF _Toc23692977 \h 6Net Present Value PAGEREF _Toc23692978 \h 7Internal Rate of Return PAGEREF _Toc23692979 \h 7Mathematical Relations: PAGEREF _Toc23692980 \h 7Ordered Pair PAGEREF _Toc23692981 \h 7Variable PAGEREF _Toc23692982 \h 8Coordinate Systems PAGEREF _Toc23692983 \h 8Rectangular Coordinates PAGEREF _Toc23692984 \h 9Polar Coordinates PAGEREF _Toc23692985 \h 9Presenting the Relationship Using Data PAGEREF _Toc23692986 \h 9Table PAGEREF _Toc23692987 \h 10Graph PAGEREF _Toc23692988 \h 10Solution of Equations PAGEREF _Toc23692989 \h 11Application in Finance PAGEREF _Toc23692990 \h 14Internal Rate of Return PAGEREF _Toc23692991 \h 14Perpetuity PAGEREF _Toc23692992 \h 15Logarithm PAGEREF _Toc23692993 \h 16Logarithmic Transformation PAGEREF _Toc23692994 \h 17Conversion of Logarithm Base PAGEREF _Toc23692995 \h 17Application in Finance PAGEREF _Toc23692996 \h 19Converting Price to Return PAGEREF _Toc23692997 \h 19Compounding PAGEREF _Toc23692998 \h 22Growth PAGEREF _Toc23692999 \h 23Progression PAGEREF _Toc23693000 \h 25Arithmetic Progression PAGEREF _Toc23693001 \h 25Geometric Progression PAGEREF _Toc23693002 \h 26The Number System:A number in general form can be written as a + bi, where a and b are real numbers, b ≠ 0, and i is the imaginary unit having the property i2=-1. A Number in this form is called a complex number. Furthermore, a is the real part of the number and bi is the imaginary part. The following are some concepts and definitions in number systems:Natural Numbers:A natural number is a whole number used in counting objects. Numbers such as 5, 2, and 10 are examples of natural numbers. These numbers are also called positive integers.Rational Numbers:A rational number is a ratio of two integers, positive or negative. A rational number, often called a fraction, may qualify as integer, such as 93=3. Therefore, all integers are considered to be rational numbers, but not all rational numbers are integers. Zero is considered a rational number.Irrational Numbers:Some numbers cannot be written as the ratio of two integers. Such numbers have infinite decimal expansions which are non-repeating. For example 2=1.41412...., π = 3.1415…., and e=2.718..... Some fractions, like 16=.1666, also have infinite decimal expansion. However, the difference between the two types is that the decimal expansions for rational numbers are repeating, like the sequence of 6 in 1666. Whereas, decimal expansions for irrational numbers are non-repeating.Real Numbers:Natural numbers, rational numbers, and irrational numbers taken together constitute the real number system.Purely Imaginary Numbers:For the equation x2+1=0, or any equation in the form x2+k=0, where k > 0, there is no real number that will satisfy the equation. Therefore, the solution of x2+1=0 is x=±-1=±i. For x2+k=0, the solution is x=±ik, where the solutions are purely imaginary plex Numbers:The real numbers and the imaginary numbers together form the complex number system.Absolute Value of a Real Number:The absolute value of a real number x, denoted by |x|, is equal to x if x > 0 and is equal to -x if x < 0. The absolute value of a number shows the magnitude, but it does not indicate whether the number is positive or negative.The Order of Arithmetic Operations:The order of arithmetic operations in R is similar to that of a calculator. It operates first on exponent (^ ), then on division (/), followed by multiplication (*), and finally addition (+) and subtraction (-). Anytime in doubt, it is highly advisable to use as many parentheses as needed, or as many parentheses as you like to make the operation clear. For example, a command such as 25^3/2 will raise 25 to the power of 3 and will divide the results by 2. However, if the intention was to have 25 raised to the power 32, 2532, the command should read as 25^(3/2).Example: Do the following arithmetic operations: 10+35, 34, 23612.#Numerical Calculation:10+3^5; 3^4; 236/12; ## [1] 253## [1] 81## [1] 19.66667#Using parentheses to make the calculation clear 25^3/2## [1] 7812.525^(3/2)## [1] 125Example: Find the numerical value of 12435*135+4513.#Numerical Calculation:sqrt((124/35)*(13/5)+45^(1/3))## [1] 3.573279Example: For the imaginary unit i = -1, find the values of (2 + 3i)(2 - 3i), (2 + 3i)(3 + 4i), and (2+3i)8.#Complex Number:x <- complex(real=2, imaginary = 3)y <- complex(real=2, imaginary = -3)z <- complex(real=3, imaginary = 4)x*y## [1] 13+0ix*z## [1] -6+17ix^8## [1] -239+28560iApplication in Finance:Future Value or CompoundingFor discrete compounding, the formula is S=A(1+rn)nt, where S is the compounded value, A is the initial investment, r is the interest rate, n is the frequency with which the interest is compounded a year, and t is the number of years. If the interest is compounded continuously, the compounding formula is S=Aert.Example: Find the compounded value of $100 deposited at a rate of 6% for 5 years, if the interest is compounded annually, quarterly, monthly, daily, or continuously. Solution:#Compounding annually:S=100*(1+.06)^5S## [1] 133.8226#Compounding quarterly:S=100*(1+.06/4)^(4*5)S## [1] 134.6855#Compounding monthly:S=100*(1+.06/12)^(5*12)S## [1] 134.885#Compounding daily:S=100*(1+.06/365)^(5*365)S## [1] 134.9826#Compounding Continuously:S=100*exp(1)^(.06*5)S## [1] 134.9859You may formulate the problem as a function in R where the frequency of interest is a parameter that can be changed based on the given assumptions. For annual compounding, set n = 1. For monthly compounding, set n = 12 and so on. For a continuous compounding you may set n to a very large number, say n=10000.#Functional Form of the Compounding Formula:#Compounding $a at interest rate r incurring with frequency n a year, for t years.s <- function(a, r, n, t) a*(1+r/n)^(n*t)s(100, .06, 1, 5)## [1] 133.8226s(100, .06, 4, 5)## [1] 134.6855s(100, .06, 12, 5)## [1] 134.885s(100, .06, 365, 5)## [1] 134.9826Do More Practice: 1- In the future value model above assume that t = 1, the initial investment is $100 and the interest rate is compounded annualy. Change the interest rate r to 7%, 8%, 9%, and 10%. Run the program and record the corresponding values of S. Graph the relationship between S and r. What is the relationship between the two variables?2- Find the compounded value of $1000 deposited at an annual rate of 6% after 10 years if: a- the interest is compounded annually. b- the interest is compounded quarterly. c- the interest is compounded monthly. d- the interest is compounded daily. e- the interest is compounded continuously (you may set n as a very large number as, n = 10000).Present Value or DiscountingA dollar to be earned in the future has less value today as it should be discouted to today’s value using the discount rate (r). That is, the present value (PV) of a dollar earned a year from today is PV=1.00(1+r). The present value of a dollar earned t years from today is PV=1.00(1+r)t. In general, the present value of n annual returns to be earned in the next n years is PV=R1(1+r)1 + R2(1+r)2 + R3(1+r)3 + …… + Rn(1+r)n.Example: An investment is expected to have a return of $22000 at the end of the first year, $28500 at the end of the second year, $32000, at the end of the third year, $18000 at the end of the fourth year, and $12000 at the end of the fifth year. At the end of the fifth year the business is expected to have a market value (MV) of $52000. What is the present value of the future returns if the interest rate is 6%?#Present Value of the returns for the next 5 years:PV <- 22000/1.06+ 28500/1.06^2+ 32000/1.06^3+ 18000/1.06^4+ 12000/1.06^5 PV## [1] 96212.22#Present Value of the market price of the business at the end year:PV_MV <- 52000/1.06^5#The Present Value of the investment (PVI):PVI <- PV + PV_MVPVI## [1] 135069.6You may also formulate the problem as a function in R where the number of years (n) is a parameter that can be changed based on the given assumptions.#Functional Form of the Discounting Formula:R <- c(22000, 28500, 32000,18000, 12000)pv <- function(R, r) sum(R/(1+r)^(1:length(R)))pv(R, .06)## [1] 96212.22PV_MV <- 52000/1.06^5PVI <- pv(R, .06) + PV_MVPVI## [1] 135069.6Net Present ValueNet present value, NPV, is the difference between the value of the initial investment, Io and the present value of investment, PVI. If NPV > 0, the investment is profitable. If NPV < 0, the investment will have a loss. When NPV = 0, the business is breaking even. For the present value example above, let’s assume that the initial investement was Io = $120000. With a discount rate of 6% the net present value will be 135069.60 - 120000 = 15069.60.Internal Rate of ReturnInternal rate of return is the discount rate at which the business breaks even or the net present value equals to zero, NPV = 0. To find the internal rate of return (IRR) find the zeroes of the break-even equation Io = PV. For the present value problem above the internal rate of return can be calculated as: 120000 - (22000(1.06)1 + 28500(1.06)2 + 32000(1.06)3 + 18000(1.06)4 + 64000(1.06)5) = 0. The numerator of the 5th year (64000) is the sum of the market value of the business at the ened of 5th year plus the 5th year’s return of $12000. By setting 1(1.06)1 = x. The NPV equation can be written as: 120000 - (12000x5+18000x4+32000x3+28500x2+74000x)=0. Solve the polynomial equation for x. Then, x = 11+r, or r=1x-1.#Internal Rate of Return:x <- polyroot(c(120000, -74000, -28500, -32000, -18000, -64000))#The only real root is 0.7937304. Therefore,r <- as.numeric(1/x - 1)## Warning: imaginary parts discarded in coercionr## [1] -0.7046095 -1.6169939 0.2598736 -1.6169939 -0.7046095Mathematical Relations:Before discussing mathematical relations, three concepts which will be used frequently in this section and later chapters will be introduced.Ordered PairAn ordered pair of numbers (x, y) is a set containing two elements, one of which (x) precedes the other (y). The element x is called the first coordinate, and the element y the second coordinate. The pair (x, y) is said to be “ordered” because the order in which the numbers appear is of significance. The pairs (5, 8) and (8,5) are different ordered pairs.VariableA variable is a symbol that may represent any member of a particular set and may take on different values.Example: Suppose that monthly observations on income and consumption of an individual are given as,#Income and spending as two varaiables:income <- c(2300, 2500, 1800, 2000, 1500, 2200) spending <- c(2040, 2350, 1740, 1850, 1450, 1960)#Income and spending paired together as two columns of datadata <- data.frame(income, spending)data## income spending## 1 2300 2040## 2 2500 2350## 3 1800 1740## 4 2000 1850## 5 1500 1450## 6 2200 1960Coordinate SystemsGeometrically, real numbers can be represented as points on a straight line. It is customary to draw this line horizontally and associate an arbitrary point on it with the integer zero. Points to the right of the zero point will represent positive numbers and points to the left will represent negative numbers. Such a line is called the x-axis and the point corresponding to zero is called the origin. The portion of the line to the right of zero is called the positive axis and the portion to the left of origin is called the negative axis. To present ordered pairs geometrically, draw a line perpendicular to the x-axis at the origin and call the line the y-axis. It is customary to draw the positive y-axis above the origin, and to draw the negative y-axis below the origin. The plane determined by the x- and y-axes is called the xy-plane,plot(data, main = "x-y Plane and Income-Spending Relation")Rectangular CoordinatesGiven an ordered pair of real numbers (x, y), we can associate this pair with a point (x, y) on the x-y plane. Rectangular coordinates use the distance from the origin on x and y axes to locate a point on the coordinate system.Polar CoordinatesAnother way to locate a point on the coordinate system is to use polar coordinates. The polar coordinates use a distance from a reference point, say origin, and an angle to describe locations. In polar coordinates, 0 is along a horizontal ray to the right of the reference point and angles are measured counterclockwise. Polar coordinates are written as ordered pairs (r,theta) where r is the polar distance or radius and theta is the measure of the polar angle.Presenting the Relationship Using DataA relationship between two variables can be expressed in three forms: Table, Graph, and Function.TableA relation here is defined as any set of ordered pairs (x, y), where x and y are real numbers.Example: The relationship between income (x) and spending (y) may be studied by listing of data and observing the relation.2300 20402500 23501800 17402000 18501500 14502200 1960GraphThe same information may be derived through plotting the paired observations on the coordinate system as shown in the income-spending graph above.##Function Function is a mathematical presentation of the relationship between two or more variables. A functional relationship between two variables can be expressed as y=f(x). See chapter 2 for more about functions.#EquationsAn equation is a statement of equality between two or more variables. The relationship between two or more variables may be studied by fitting an equation to the observed data and studying the mathematical relationship between the two variables. For example, for the income-consumption data above, we can fit an equation of a straight line. Fitting equations to data will be studied in Chapter 6. Here, assuming that such equation is estimated as C = 219 + 0.82Y, the plot of the points and the equation are shown in the following graph.#Income-Spending equation of line fitted to data;plot(income,spending, main="Income Spending Plot and Fitted Line")abline(lm(spending~income))Solution of EquationsThe solution of an equation in variable x is a set of numbers or objects that satisfies the equation.Example: Solve x2-4=0 Solution: Set x2=4 and solve for x. The solution is x = 4=O or x=±2. Example: Quadratic Equations: Solve the quadratic equation x2+2x-8=0. Solution: The general form of quadratic equation is ax2+bx+c=0, the solution of which is x=-b±(b2-4ac)2a. Using the values of the parameters a, b, and c from the given equation the x values are 2 and -4. Using R code polyroot,the problem is solved as:#Solving Polynomial Equations in R:polyroot(c(-8, 2, 1))## [1] 2-0i -4+0iExample: Find the solution set of the polynomial function x3-x2+4x-4=0. Solution: To solve a cubic equation or any polynomial equation of higher order for its zeros, use the graph of the equation to find an approximation to zeroes of the equation. Zeroes of an equation are the x-intercept of the equation. Alternatively, you may set arbitrary values for x to find an approximate value for x. For example, for the given cubic function, if x = 0, the value of the equation is -4. If x = 2, the value of the equation is +8. Therefore, the x-value that will make equation equal to zero lies between zero and two. By assigning x some values in this range we find that x = 1. This is only one of the solutions. Since the equation is a cubic equation, there should be two more solutions. To find the other two solutions, divide x3-x2+4x-4 by (x - 1) to get x3-x2+4x-4x-1 =x2+4. The solution of x2+4=0 is x=±2i. Using R the graph is shown below and the range of x is approximated around x = 1:#Graph of the cubic equation.curve(x^3-x^2+4*x-4, -10, 10); abline(h = 0)#Use polyroot command to find the rootspolyroot(c(-4, 4, -1, 1))## [1] 1-0i 0+2i 0-2iFrom the polyroot solution, the eqution has one real root at x = 1 and two imaginary roots of 2i and -2i.Do More Practice: Find the solution of the following equations. a) x3+4=0 b) x2-3x-4=0 c) x2-6x+25=0 d) x3+2x2+2x+1=0 e) x4-5x2+4=0Example: Find the solution set of |x+3| = 4. Solution: If x > -3, |x + 3| = x + 3. If x <3, |x + 3| = -(x + 3). Therefore, |x + 3| = 4 give rise to two equations, x + 3 = 4 and -x - 3 = 4, the solutions of which are x = 1 and -7. Using R the solution is:#Graph the function to estimate the roots of the function.f <- function(x) abs(x+3) - 4curve(f, c(-8, 8)); abline(h=0)#Find the roots.uniroot(f, c(-8, 0)) ## $root## [1] -7## ## $f.root## [1] 0## ## $iter## [1] 2## ## $init.it## [1] NA## ## $estim.prec## [1] 3uniroot(f, c(0, 8))## $root## [1] 1## ## $f.root## [1] 0## ## $iter## [1] 1## ## $init.it## [1] NA## ## $estim.prec## [1] 7Application in FinanceInternal Rate of ReturnInternal rate of return is the break-even discount rate for an investment. It is the rate at which the present value of the net future cash flow equals to the amount invested. That is, Io=R1(1+r)1+R2(1+r)2+R3(1+r)3 + ….. , where Io is the initial investment, Rt is the return at the end of the year t, and r is the discount rate.Example: Suppose a 24,000 initial investment has annual returns of 4,500 for five years and a scrap value of 2,500 at the end of the fifth year. The internal rate of return on the investment is calculated by setting the present value of the future returns equal to the value of investment . Therefore, formulate the problem as: 24000 = (4500(1+r)1 + 4500(1+r)2 + 4500(1+r)3 + 4500(1+r)4 + 4500+2500(1+r)5) and solve for r. Since the highest power of the polynomial equation is five, there will be five solutions to the equation. However, only one of the solutions is acceptable. Using R,#Internal rate of return:polyroot(c(24000, -4500, -4500, -4500, -4500, -7000))## [1] 0.3240848+1.303978i -1.1391481+0.791142i -1.1391481-0.791142i## [4] 0.9872694-0.000000i 0.3240848-1.303978i1/.9872694 - 1## [1] 0.01289476Do More Practice: 1- Change the initial investment in the preceding example to $25000, $26000, $27000, $28000, $29000, and $30000, and find the corresponding IRRs. Graph the relationship between the initial investments and the IRRs and comment on the relationship between the two variables.Example: Investment and Growth Suppose an initial investment of 10000 has a net return of 1000 at the end of first year and an expected future returns with an annual growth rate of 10% in the coming years. What is the net present value of the investment after 5 years, 10 years, 15 years, and 20 years if the discount rate is 6%? After how many years will the firm break even? Solution: Assuming the initial investment Io, the first year return R1, the growth rate g, and the discount rate r, the problem can be formulated as:NPV=sum(R*(1+g)i(1+r)i)-Io for i = 1:n.#Investment growthf <- function(n) sum(1000*(1.1)^1:n/(1.06)^1:n) - 10000f(5)## [1] -5919.923f(10)## [1] -890.3733f(15)## [1] 4126.444f(20)## [1] 9138.249#NPV at n = 11 is:f(11)## [1] 113.6029At n = 11, the net present value is positive and the investment is profitable.Do More Practice: 1- Change the initial investment in the preceding example to $12000, $14000, and $16000. Find the corresponding number of years that the business needs to break-even.2- What growth rate is needed for the firm to break-even in 5 years, if the discount rate is 6%?PerpetuityA Perpetuity is a security that yields a constant stream of identical cash payments forever. The value of the perpetuity is decided by the sum present value of the stream of payments for infinite number of years. That is, PV=sum(R(1+r)t) as t -> ∞. The price of the perpetuity P=Rr. Here, R is the constant annual payments and r is the discount factor.Example: A perpetuity yields a constant annual payments of $100 forever. What is the present value of the perpetuity if the discount rate is 5%? Solution: P = 100/.05 = 2000.#Perpetuity and time: Find the value of f(t) for t = 10, 20, 30 qnd 100.f <- function(t) sum(100/(1.05)^1:t)f(10)## [1] 275.4842f(100)## [1] 509.8509f(1000)## [1] 740.515f(10000)## [1] 970.814f(100000)## [1] 1201.077f(1000000)## [1] 1431.336f(10000000)## [1] 1661.594f(100000000)## [1] 1891.853As t -> ∞, the present value of PV=sum(R(1+r)t) approaches to P=Rr.LogarithmDefinition: Let y=bx , b > 0. We define the exponent x as the logarithm of y to the base b and write it as logby=x. Expressions y=bx and logby=x are equivalent. The logarithms of numbers to the base 10 are called common logarithms, and are denoted by log. The logarithms of numbers to the base e, the natural number, is called natural logarithm and is usually denoted by ln. Logarithms are one of the basic tools for linearizing (log-linearizing) non-linear relationships. This property of logarithms is used frequently in economic models, data analysis, and econometrics. Note that if the base of the logarithm is not defined most statistical programs take “log” as the natural logarithm.Logarithmic TransformationOne of the most important properties of the logarithm, which has many applications in statistics, is transforming non-linear relation to log-linear relation. Take two variables x and y and let z=x*y. Then, logz=logx+logy. That is, applying logrithm to z, which a nonlinear variable in terms of x and y, converts z to a log-linear relation in terms of logx and logy. The relation will hold no matter what the base of the logarithm is. Now, let’s assume w = x/y, applying log to w will convert the nonlinear relation to linear relation, logw = logx - logy. The transformation can be applied to exponents also. Let’s assume v=x*ym. Applying log to v converts v to a log-linear relation, logv=logx+m*logy, where m is a constant number.Conversion of Logarithm BaseIn some mathematical operations there maybe a need for conversion of logarithm base. Suppose you need to transform log2x to logex. This is done by logex=log2x*loge2.Inversion of Logarithm Base: logex=1logxe. The conversion and inversion rules can be easily proved using the definition of logarithm.Example: Find the logarithm of 356 to the base 2, 10, and e. Solution: Using R the values can be found as:#Lograrithmlog2(356)## [1] 8.475733log10(356)## [1] 2.55145log(356)## [1] 5.874931Example: The relationship between the labor input (L) and the quantity of output (Q) is given as: L: 1, 2, 3, 4, 5, 6 7 8 9 10 Q: 2, 7, 15, 29, 42, 51 57 62 64 62 a- Make a list of inputs and outputs and graph the relation. b- Make a list of the natural log values of paired inputs and outputs and plot it. c- Compare the two plots.L <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)Q <- c(2, 7, 15, 29, 42, 51, 57, 62, 64, 62)data <- cbind(L, Q)plot(L, Q, type="l", main="Plot of Labor Input and Output")lL <- log(L)lQ <- log(Q)plot(lL, lQ, type="l", main="Plot of the Logarithmic Values of Labor Input and Output")Solution: Although logarithmic transformations smooth the graph of the relationship between the two variables to some extent, it does not change the relation betwen the two variables. The two plots will look similar. However, the scales of the two plots are different and the logarithmic plot looks smoother than the other one.Application in FinanceConverting Price to ReturnHistorical prices (P) of an asset can be converted to returns (r) using either discrete or logarithmic formulas. Using discrete formula, rt=Pt-Pt-1Pt-1. Using logarithmitc method r = log(Pt)-log(Pt-1). In practice the use of the method depends on the frequency of data. For high frequency data such as daily or weekly data the common practice is the use of logarithmic method. For annual data, the use of discrete method is more common.Example: Download daily data for S&P500 for the period January 2nd to current, convert the index to return and graph S&P500 and return to S&P500.#Install quantmod package:#install.packages("quantmod", repos = "")library("quantmod")## Loading required package: xts## Loading required package: zoo## ## Attaching package: 'zoo'## The following objects are masked from 'package:base':## ## as.Date, as.Date.numeric## Registered S3 method overwritten by 'xts':## method from## as.zoo.xts zoo## Loading required package: TTR## Registered S3 method overwritten by 'quantmod':## method from## as.zoo.data.frame zoo## Version 0.4-0 included new data defaults. See ?getSymbols.# Download Datastart_date = "2014-01-01"end_date = "2018-12-31"getSymbols("^GSPC", start_date = "2014-01-01")## 'getSymbols' currently uses auto.assign=TRUE by default, but will## use auto.assign=FALSE in 0.5-0. You will still be able to use## 'loadSymbols' to automatically load data. getOption("getSymbols.env")## and getOption("getSymbols.auto.assign") will still be checked for## alternate defaults.## ## This message is shown once per session and may be disabled by setting ## options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.## [1] "^GSPC"#Check few rows of the downloaded datahead(GSPC)## GSPC.Open GSPC.High GSPC.Low GSPC.Close GSPC.Volume## 2007-01-03 1418.03 1429.42 1407.86 1416.60 3429160000## 2007-01-04 1416.60 1421.84 1408.43 1418.34 3004460000## 2007-01-05 1418.34 1418.34 1405.75 1409.71 2919400000## 2007-01-08 1409.26 1414.98 1403.97 1412.84 2763340000## 2007-01-09 1412.84 1415.61 1405.42 1412.11 3038380000## 2007-01-10 1408.70 1415.99 1405.32 1414.85 2764660000## GSPC.Adjusted## 2007-01-03 1416.60## 2007-01-04 1418.34## 2007-01-05 1409.71## 2007-01-08 1412.84## 2007-01-09 1412.11## 2007-01-10 1414.85#Select the Adjusted Price as the column of interest and call it spsp <- GSPC$GSPC.Adjustedhead(sp)## GSPC.Adjusted## 2007-01-03 1416.60## 2007-01-04 1418.34## 2007-01-05 1409.71## 2007-01-08 1412.84## 2007-01-09 1412.11## 2007-01-10 1414.85#Plot spplot(sp, main="S&P500 Index")#Convert sp index to return to sprsp <- diff(log(sp))head(rsp)## GSPC.Adjusted## 2007-01-03 NA## 2007-01-04 0.0012275323## 2007-01-05 -0.0061031679## 2007-01-08 0.0022178572## 2007-01-09 -0.0005168099## 2007-01-10 0.0019384723#Plot return to spplot(rsp, main="Retutn to S&P500")CompoundingHow long does it take to double the initial value of an investment if the interest rate is 8%. Solution: Using the annual compounding formula S=A(1+r)t, where S is the compounded value, A is the initial value, r is the interest rate and t is the time. The doubling of the initial investment renders 2A=A(1+.08)t. Therefore, solve for t in the equation 2=1.08t by taking the log as Log2=tLog1.08 or t=Log(2)Log(1.08)=9.006468 or 9 years and two days. Using R:#Doubling Savingt <- log(2)/log(1.08)t## [1] 9.006468.006468*365## [1] 2.36082Do More Practice: 1- How long does it take to double the initial value of an investment if the interest rate is 16%.2- How long does it take to quadruple the initial value of an investment if the interest rate is 8%.GrowthShow that if y grows exponentially at the rate of 20% from an initial value of 10, the natural log of y, logy, will grow at a constant rate along a line with a slope of .20. List the values of y and logy for t = 1 to 10 and plot the numbers. Compare the two graphs. Solution: y=10e.20t. The natural log of y, lny = ln10 + .20t. That is lny will change along a straight line with a slope of .20. To find the points for ploting, make a table of y and lny values for t = 0 to 10. You may use R to graph the relarions as:#Graphs of y and log(y):t <- 1:10y <- 10*exp(.20*t)plot(t, y, type= "l", main="Graph of t and y")plot(t, log(y), type="l", main="Graph of log(y)")ProgressionArithmetic ProgressionArithmetic progression is a sequence of numbers, each of which differs from its preceding number by a factor of constant. The constant number is called the common difference. For example, the following sequence of numbers a, a + d, a + 2d, .............., a + (n-1)d is a progression with an initial value of a and common difference of d.?In Business and Economics we are most concerned with the sum of a progression or with the nth element of the progression. The nth element of the arithmetic progression is a+(n-1)d and the sum is S=n(a+d(n-1)2).Example: List 20 elements of an arithmetic progression with an initial value of 4 and a common factor of 12. Find the 10th element and the sum of the first twenty elements. Solution: The numbers in the table follow the arithmetic progression rule which produces a table as t = c(4, 16, 28, …..). To find the 10th element and the sum, use the two formulas above. The 10th element of the progression is 4+(10-1)12=112 and the sum of 20 elements is S=20(4+12(20-1)2) = 2360. Using R:#Arithmetic Progression:n <- 1:20f <- function(a, d, n) a + (n - 1)*dt <- c(f(4, 12, n))t## [1] 4 16 28 40 52 64 76 88 100 112 124 136 148 160 172 184 196## [18] 208 220 232t[9]## [1] 100n <- 0:19s <- sum(f(4, 12, n))s## [1] 2120Example: A firm producing an initial output of 100 units can increase output by 10 units a week. The management is interested in knowing how many weeks it takes to achieve an output level of 1260 units. Solution: The increase in output follows an arithmetic progression with an initial value of 100 and a common increment factor of 10 units. That is, the ith week’s production is 100+10i, the sum of which over an unknown period x should be 1260. To find x, set the sum of the weekly production equal to 1260 and solve for x and solve the equation x(100+10(x-1)2)=1260 for x. This gives x = 9 and x = -28, where only x = 9 is an acceptable solution.Note that, as in the previous example i counts from 0 to x-1 and not 0 to x.Geometric ProgressionGeometric Progression is a sequence of numbers, each of which is obtained by multiplying the preceding term by a constant factor. The constant factor is called the common ratio. For example, the following numbers a, ar1, ar2 , ar3, ……., ar(n-1)form n-element geometric progression with an initial value of “a” and a common ratio of r. The nth element of the geometric progression is ar(n-1), and the sum is S=a(1-rn)1-r.Example: List 20 elements of a geometric progression with an initial value of 5 and a common ratio of 2. Find the 10th element and the sum of the first twenty elements. Solution: Using the geometric progression rule, the table of elements is t = c(5, 10, 20, ……). Using the two formulas above, the 10^th element is 5(2)10=2560, and the sum is S=5(1-220)(1-2)=5242875.#Geometric Progressionn <- 1:20f <- function(a, r, n) a*r^(n-1)t <- c(f(5, 2, n))t## [1] 5 10 20 40 80 160 320 640## [9] 1280 2560 5120 10240 20480 40960 81920 163840## [17] 327680 655360 1310720 2621440t[10]## [1] 2560n <- 1:10s <- sum(f(5, 2, n))s## [1] 5115Example: Macroeconomics Spending Multiplier Effect: In a two-sector, simple Keynesian macro-model of the economy with a consumption function of C=C0+bY, investment spending I=I0, government spending G=G0, and income identity Y=C+I+G, every one dollar increase in C0, I, or G will increase Y by the following amounts over time periods, Time Period: 1, 2, 3, …………………, n Increase in Y: 1, b, b2, b3 ………, b(n-1)Find the total increase in Y after n periods.Find the long-run effect of $1 spending in the economy. Solution: The progression is a geometric progression with an initial value of 1 and a common ratio of b. Using the sum formula for n years, Sn=1-bn1-b. In the long-run, bn approaches zero as b, the marginal propensity to consume (MPC) is less than one, b<1. Therefore, the long-run effect of one dollar spending in the econeomy will be S=11-b.Excercises:Future Value Problem: Find the compounded value of $100 deposited at a rate of 6% for 5 years, if the interest is compounded annually, quarterly, monthly, daily and continuously.Present Value Problem: An investment is expected to have a return of $22000 at the end of the first year, $28500 at the end of the second year, $32000, at the end of the third year, $18000 at the end of the fourth year, and $12000 at the end of the fifth year. At the end of the fifth year the business is expected to have a market value of $52000. What is the present value of the future returns if the interest rate is 6%? What is the present value of the investment?Net Present Value Problem: Net present value, NPV is the difference between the value of the initial investment, Io and the present value of investment, PVI. If NPV > 0, the investment is profitable. If NPV < 0, the investment will have a loss. Suppose an investment is expected to have returns of $22000, $28500, $32000, $18000, and $12000 at the end of each year for the next five years. At the end of the fifth year, the business is expected to have a market value of MV = $52000. Given that the initial investment is $120000, what is the net present value of the investment if the discount rate is 6%?Perpetuity: A Perpetuity is a security that yields a stream of annual payments at an annual rate of r forever. The value of the perpetuities is decided by the sum of the present value of the stream of payments for infinite number of years. That is, PV = sum(R/(1+r)t) when t =∞. Here, R is the annual payments and r is the discount factor. Suppose a perpetuity yields an annual payments of $1 forever. What is the present value of the perpetuity if discount rate is 5%?Internal Rate of Return: Internal rate of return is the interest rate at which NPV = 0 or PVI = Io.For the present value problem in question 4 find the internal rate of return.Find the rate of return on a $24,000 investment with an annual return of $4,500 for five years and a scrap value of $2,500 at the end of the fifth year.Solve the following equations:x2+2x-8=0.x2-9.x3-x2+4x-4=0.x5+3x2-8=0.Find the 10th and 20th terms of the following progressions a) 4, 7, 10, …………..b) 1, 43,53, ……… c) 3, 72, 4, ………. d) Find the sum of the first thirty terms of the progressions in problem 1.Find the 10th and the 20th terms of the following geometric progressions a) 3, 9, 27, ………..b) 3, 1, 13, ……….. c) 9, 6, 4, ……….. 9) Find the sum of the first 3, 5, and 10 terms of the geometric progressions in problem 3.What will be the total savings of a person 10 years from now if she deposits $100 at an annually compounded interest rate of 10% a year. How long does it take to double a principal of any amount at that rate?6- In a simple macro model of an economy C = 100 + .8Y, I = 200, and Y = C + I.a- Assume that investment (I) increases by $100. What is the effect on Y after 2 years, 5 years, and 10 years? What is final effect on Y? ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download