Consider the electromagnetic radiation inside a kiln, with a volume of 1 m3 and a temperature of 1500 K.

(a) What is the total energy of this radiation?

(b) Sketch the spectrum of the radiation as a function of photon energy.

(c). What fraction of all the energy is in the visible portion of the spectrum, with with wavelengths between 400 nm and 700 nm?

MIDTERM 1. CHAPTER 1,2,3,4 Chapter 1 Starting with MATLAB This chapter begins by describing the characteristics and purposes of the different windows in MATLAB. Next, the Command Window is introduced in detail. This chapter shows how to use MATLAB for arithmetic operations with scalars in a fashion similar to the way that a calculator is used. This includes the use of ele mentary math functions with scalars. The chapter then shows how to define scalar variables (the assignment operator) and how to use these variables in arithmetic calculations. The last section in the chapter introduces script files. It shows how to write, save, and execute simple MATLAB programs. Chapter 2 Creating Arrays The array is a fundamental form that MATLAB uses to store and manipulate data. An array is a list of numbers arranged in rows and/or columns. The simplest array (onedimensional) is a row or a column of numbers. A more complex array (two dimensional) is a collection of numbers arranged in rows and columns. One use of arrays is to store information and data, as in a table. In science and engineering, one dimensional arrays frequently represent vectors, and twodimensional arrays often represent matrices. This chapter shows how to create and address arrays, and Chapter 3 shows how to use arrays in mathematical operations. In addition to arrays made of numbers, arrays in MATLAB can also be a list of characters, which are called strings. Strings are discussed in Section 2.10. Chapter 3Mathematical Operations with Arrays Once variables are created in MATLAB they can be used in a wide variety of mathematical operations. In Chapter 1 the variables that were used in mathemati cal operations were all defined as scalars. This means that they were all 1 × 1 arrays (arrays with one row and one column that have only one element) and the mathematical operations were done with single numbers. Arrays, however, can be onedimensional (arrays with one row, or with one column), twodimensional (arrays with multiple rows and columns), and even of higher dimensions. In these cases the mathematical operations are more complex. MATLAB, as its name indi cates, is designed to carry out advanced array operations that have many applica tions in science and engineering. This chapter presents the basic, most common mathematical operations that MATLAB performs using arrays. Addition and subtraction are relatively simple operations and are covered first, in Section 3.1. The other basic operations—multiplication, division, and exponentiation—can be done in MATLAB in two different ways. One way, which uses the standard symbols (*, /, and ^), follows the rules of linear algebra and is presented in Sections 3.2 and 3.3. The second way, which is called elementby element operations, is covered in Section 3.4. These operations use the symbols .*, ./, and .^ (a period is typed in front of the standard operation symbol). In addi tion, in both types of calculations, MATLAB has left division operators ( .\ or \ ), which are also explained in Sections 3.3 and 3.4. Chapter 4Using Script Files and Managing Data A script file (see Section 1.8) is a list of MATLAB commands, called a program, that is saved in a file. When the script file is executed (run), MATLAB executes the commands. Section 1.8 describes how to create, save, and run a simple script file in which the commands are executed in the order in which they are listed, and in which all the variables are defined within the script file. The present chapter gives more details of how to input data to a script file, how data is stored in MAT LAB, various ways to display and save data that is created in script files, and how to exchange data between MATLAB and other applications. (How to write more advanced programs where commands are not necessarily executed in a simple order is covered in Chapter 6.) In general, variables can be defined (created) in several ways. As shown in Chapter 2, variables can be defined implicitly by assigning values to a variable name. Variables can also be assigned values by the output of a function. In addi tion, variables can be defined with data that is imported from files outside MAT LAB. Once defined (either in the Command Window or when a script file is executed) the variables are stored in MATLAB’s Workspace. Variables that reside in the workspace can be displayed in various ways, saved, or exported to applications outside MATLAB. Similarly, data from files outside MATLAB can be imported to the workspace and then used in MATLAB. Section 4.1 explains how MATLAB stores data in the workspace and how the user can see the data that is stored. Section 4.2 shows how variables that are used in script files can be defined in the Command Window and/or in script files. Section 4.3 shows how to output data that is generated when script files are exe cuted. Section 4.4 explains how the variables in the workspace can be saved and then retrieved, and Section 4.5 shows how to import and export data from and to applications outside MATLAB. 2. CHAPTER 5,6,7 Chapter 5 TwoDimensional Plots Plots are a very useful tool for presenting information. This is true in any field, but especially in science and engineering, where MATLAB is mostly used. MATLAB has many commands that can be used for creating different types of plots. These include standard plots with linear axes, plots with logarithmic and semilogarith mic axes, bar and stairs plots, polar plots, threedimensional contour surface and mesh plots, and many more. The plots can be formatted to have a desired appear ance. The line type (solid, dashed, etc.), color, and thickness can be prescribed, line markers and grid lines can be added, as can titles and text comments. Several graphs can be created in the same plot, and several plots can be placed on the same page. When a plot contains several graphs and/or data points, a legend can be added to the plot as well. This chapter describes how MATLAB can be used to create and format many types of twodimensional plots. Threedimensional plots are addressed sep arately in Chapter 9. An example of a simple two dimensional plot that was cre ated with MATLAB is shown in Figure 51. The figure contains two curves that show the variation of light intensity with distance. One curve is constructed from data points measured in an experiment, and the other curve shows the variation of light as predicted by a theoretical model. The axes in the figure are both linear, and different types of lines (one solid and one dashed) are used for the curves. The theoretical curve is shown with a solid line, while the experimental points are con nected with a dashed line. Each data point is marked with a circular marker. The dashed line that connects the experimental points is actually red when the plot is displayed in the Figure Window. As shown, the plot in Figure 51 is formatted to have a title, axis titles, a legend, markers, and a boxed text label. Chapter 6 Programming in MATLAB A computer program is a sequence of computer commands. In a simple program the commands are executed one after the other in the order they are typed. In this book, for example, all the programs that have been presented so far in script files are simple programs. Many situations, however, require more sophisticated pro grams in which commands are not necessarily executed in the order they are typed, or different commands (or groups of commands) are executed when the program runs with different input variables. For example, a computer program that calculates the cost of mailing a package uses different mathematical expres sions to calculate the cost depending on the weight and size of the package, the content (books are less expensive to mail), and the type of service (airmail, ground, etc.). In other situations there might be a need to repeat a sequence of commands several times within a program. For example, programs that solve equations numerically repeat a sequence of calculations until the error in the answer is smaller than some measure. MATLAB provides several tools that can be used to control the flow of a program. Conditional statements (Section 6.2) and the switch structure (Section 6.3) make it possible to skip commands or to execute specific groups of com mands in different situations. For loops and while loops (Section 6.4) make it possible to repeat a sequence of commands several times. It is obvious that changing the flow of a program requires some kind of decisionmaking process within the program. The computer must decide whether to execute the next command or to skip one or more commands and continue at a different line in the program. The program makes these decisions by comparing values of variables. This is done by using relational and logical operators, which are explained in Section 6.1. It should also be noted that userdefined functions (introduced in Chapter 7) can be used in programming. A userdefined function can be used as a subprogram. When the main program reaches the command line that has the userdefined function, it provides input to the function and “waits” for the results. The user defined function carries out the calculations and transfers the results back to the main program, which then continues to the next command. Chapter 7UserDefined Functions and Function Files A simple function in mathematics, f(x) , associates a unique number to each value of x. The function can be expressed in the form y = f(x) , where f(x) is usu ally a mathematical expression in terms of x. A value of y (output) is obtained when a value of x (input) is substituted in the expression. Many functions are pro grammed inside MATLAB as builtin functions, and can be used in mathematical expressions simply by typing their name with an argument (see Section 1.5); examples are sin(x), cos(x), sqrt(x), and exp(x). Frequently, in computer programs, there is a need to calculate the value of functions that are not builtin. When a function expression is simple and needs to be calculated only once, it can be typed as part of the program. However, when a function needs to be evaluated many times for different values of arguments, it is convenient to create a “user defined” function. Once a userdefined function is created (saved) it can be used just like the builtin functions. A userdefined function is a MATLAB program that is created by the user, saved as a function file, and then can be used like a builtin function. The function can be a simple, single mathematical expression or a complicated and involved series of calculations. In many cases it is actually a subprogram within a computer program. The main feature of a function file is that it has an input and an output. This means that the calculations in the function file are carried out using the input data, and the results of the calculations are transferred out of the function file by the output. The input and the output can be one or several variables, and each can be a scalar, vector, or an array of any size. In addition to being used as math functions, userdefined functions can be used as subprograms in large programs. In this way large computer programs can be made up of smaller “building blocks” that can be tested independently. Func tion files are similar to subroutines in Basic and Fortran, procedures in Pascal, and functions in C. The fundamentals of userdefined functions are explained in Sections 7.1 through 7.7. In addition to userdefined functions that are saved in separate func tion files and called for use in a computer program, MATLAB provides an option to define and use a userdefined math function within a computer program (not in a separate file). This can be done by using anonymous and/or inline functions, which are presented in Section 7.8. There are builtin and userdefined functions that have to be supplied with other functions when they are called. These func tions, which in MATLAB are called function functions, are introduced in Section 7.9. The last two sections cover subfunctions and nested functions. Both are meth ods for incorporating two or more userdefined functions in a single function file. 3. CHAPTER 5,9,10 Foundations of Monte Carlo Simulations In finance, asset pricing generally consists of computing the mathematical expectation of the payoffs. In this chapter, we describe how simulation techniques can be used to perform approximatively these mathematical expectations. This involves the notion of approximation precision. Several techniques exist that enhance the precision of the approximations and reduce the computation time. We introduce the Barraquand (1995) quadratic resampling technique used to improve the estimation precision for the variancecovariance matrix pervasive in financial modeling. We also introduce techniques that reduce the computation time and the variance reduction techniques such as the antithetic variables technique, the control variates technique and the importance sampling technique. We end the chapter with application examples which constitute exercises for the reader. The MATLAB programs are provided as solutions for the application cases. General Approach to the Valuation of Contingent Claims This chapter presents the basis for valuing contingent claims such as financial options. We begin with a brief definition of simple options, the most widely known contingent claims. Definition An option is a financial security or a real asset that gives the right to its owner/holder to buy or to sell another asset (called the underlying asset) at a specific date (maturity date or exercise date) or for a given period, and at a predetermined price (called strike price or exercise price). Many types of options, explicit or implicit, exist. A call option allows its owner to buy the underlying asset at the strike price before or at maturity date and a put option allows its owner to sell the underlying asset at the exercise price before or at the maturity date. Figures 9.1 and 9.2 depict the payoffs of an option at maturity date as a function of the price of the underlying asset. The option is called European if it can be exercised only at the maturity date. An option is said to be American if it can be exercised at any time before or at the maturity date. In addition to these relatively simple options, there are more complex options which depend on the complexity of the choice of the underlying assets and the payoff structure. One popular complex option are the so called Asian options whose payoffs depend on all the underlying asset price trajectories. Options whose payoffs depend on the trajectories of their underlying assets prices are called pathdependent options. We begin with the simple binomial pricing model to present the intuition of a hedge portfolio and the “riskneutralized” principle (term used in Ingersoll (1987)) or riskneutral pricing. Then we continue with the BlackScholes Merton partial differential equation. We also introduce the sensitivity coefficients called Greeks. Afterwards, we present the probabilistic approach of contingent claims valuation or the equivalent martingale approach using stochastic differential equations. The latter approach will form the backbone of the next chapter, which is on the pricing of complex options with no known analytical closed form solutions. Pricing Options using Monte Carlo Simulations Since the seminal works of BlackScholesMerton (1973) on European options valuation, a great number of derivative products have been engineered. However, in most cases it is difficult to find closed form formulas for the pricing of these commonly encountered complex options. Monte Carlo simulation techniques have proved to be a flexible and handy alternative to price these options. In this chapter, we proceed as follows. First, we start by valuing simple options called plain vanilla options, and then we introduce stochastic interest rates and/or stochastic volatilities. Second, we estimate the value of American options using the LeastSquare Linear Re gression Method of Longstaff and Schwartz (2001) and the Dynamic Programming Technique with Stratified States Aggregation of Barraquand and Martineau (1995). Third, we value Asian and barrier options using the approaches developed by Kemna and Vorst (1990) and El Babsiri and Noel (1998). Finally, to estimate the sensitivity coefficients of options or the Greeks, we discuss the pathwise derivatives and the likelihood ratio techniques proposed by Broadie and Glasserman (1996) and present the retrieval of volatility method of Cvitanic, Goukassian and Zapatero (2002). 4. CHAPTER 1,2,3,4 Introduction to Probability Since financial markets are very volatile, in order to model financial variables we need to char acterize randomness. Therefore, to study financial phenomena, we have to use probabilities. Once defined, we will see how to use probabilities to describe the evolution of random parameters that we later call random processes. The key step here is the quantitative construc tion of the events’ probabilities. First, one must define the events and then the probabilities associated to these events. This is the objective of this first chapter. Introduction to Random Variables In the previous chapter, we introduced some concepts of events and defined probabilities on sets of events. In this chapter, we will focus on the representation of realized events on the real axis and probability space in order to provide a quantification to be used in financial problems. A random variable is a function mapping the sample space Ω to the real axis. Afterwards, a complete characterization of such random variables will be given by introducing the probability density function, the cumulative distribution function and the characteristic function. We will show examples of the most frequentlyencountered random variables in finance. The characteristic function will be presented in order to give the reader a better understanding of random variables. We will not use it extensively later in the book, but it is useful to be familiar with it to enable us to follow some proofs. We will also introduce the concept of transformation of random variables. This concept is the basis of random variables simulation under known distributions and will be used in subsequent chapters. Random Sequences The preceding chapter has enabled us to describe and characterize random variables. However, many real phenomena, and particularly those encountered in finance, can be modeled by a sequence of random variables. This means that we need an asymptotic characterization of these random sequences in order to deduce their properties. These properties will be useful in many cases as we shall see. Convergence and limit concepts studied in this chapter will be useful when we have to characterize the precision, convergence and control of simulation techniques presented later. To construct the probability of events, we resort to the notion of relative frequency obtained by realizing a large number of random experiments and counting the number of outcomes. This repetition of experiments implies the use of a large number of random variables. We will study a very important property in statistics theory that will be useful later. Introduction to Computer Simulation of Random Variables In finance, as in many other areas of social and human sciences, it is often very difficult or even impossible to find an analytical solution for most of the problems we have to solve. This is the case with the evaluation of complex and interdependent financial products. However, there are many numerical techniques available to evaluate these products. One of the techniques that we present in this book is the computer based simulation method. From its inherent nature, this method offers a wide flexibility, especially when evaluating financial products dependent on many state variables. How can a computer generate random events, since if it executes a given algorithm knowing the initial result, we should be able to guess the results at the outset In fact, results generated on a computer are not conceptually random but, from the point of view of an observer, behave like random ones. These results occur with a statistical regularity as discussed in the previous chapters. The regularity associated with the results generated by a computer can be explained as follows: if the algorithm generated by a computer is chaotic then it will produce unpredictable results for an observer. Thus, to build a dynamically chaotic algorithm is sufficient to generate random events. The previous chapters showed how to obtain random variables for which we know the distribution function from a uniform random variable. The problem of generating random variables on computer is the same as generating a uniform random variable. In order to generate a uniform random variable without resorting to a complex chaotic dynamic, all we need to do is to build an algorithm such that the generated result has the statistical regularity of a uniform random variable. If the generated number is expressed with a binary representation, the number of 0 and 1 should be approximately equal, the number of two following 0 and two following 1 should be approximately equal, etc. In the last 50 years, we have seen researchers focussing on building algorithms that yield this statistical regularity. Because a computer has a finite precision, the generator can’t generate an infinite number of different outcomes but only a finite number of results. This means that the series of generated results is periodic. Generally, we choose the algorithm that gives us the longest possible period. In this chapter, we define basic concepts regarding the generation of random variables on computers and we present the techniques used to generate some widely used random variables in finance. After that, we present the simulation of random vectors using variancecovariance matrix decomposition techniques such as the Cholesky decomposition and the eigenvalue decomposition. The financial assets variancecovariance matrix decomposition is important in the study of risk factors, and more precisely in the pricing of financial instruments and risk management. Finally, we introduce the acceptancerejection and Monte Carlo Markov Chain (MCMC) generation methods that could both be used in many simulation cases in finance.