Fall Semester 2000
P5720 Students need to do Exercise 2 here, in addition to the final project.
It is time for Elwood to trade in his old jalopy, a very beat up car from the Disco Era. He goes to a used car dealer and finds the perfect vehicle for $10000. The dealer offers Elwood a loan to pay for the car, with monthly payments of $188.70 for 5 years.
Elwood then tries to see what he can get for his old jalopy. The dealer tells him that the jalopy is worthless. Elwood disagrees, and gives his car an affectionate kick in the tire to make his point. But as he does this, the front door falls off and crashes to the ground, splitting open along its rusty seams. Elwood and the dealer just stare at it: It is stuffed to the brim with unmarked US dollar bills, wierdly, $10000 in all.
Elwood is now tempted to pay cash. But he remembers that Alice's Bank & Trust is offering a special money market account which pays out monthly at a tax-free rate of R = 6% per year. If he puts his money into this account, drawing out the car payments every month, then, at the end of 5 years, will he have saved or will he be further in dept to the car dealer than if he had just paid the cash up front?
For definiteness, assume Elwood's car payments are due at the end of each month. In the scenario where he invests with Alice's Bank & Trust, at the end of one month he would have
A_1 = A_0 * (1+R/12) - Pwhere A_0 is the initial amount he puts into Alice's bank and P is his monthly payment. The factor of (1+R/12) is the amount his account grows during the month. At the end of two, three months, he would have
A_2 = A_1*(1+R/12) - P = A_0 * (1+R/12)^2 - P * [(1+R/12) + 1] A_3 = A_2*(1+R/12) - P = A_0 * (1+R/12)^3 - P * [(1+R/12)^2 + (1+R/12) + 1]respectively. Generalize these formulae for A_N, the amount of money Elwood has after N months, in terms of a power series in (1+R/12). Use Maple's 'sum' command to find a simple form for A_N and to solve this exercise. Put your final answer as a comment at the end of a Maple script,
# Elwood would [save/lose] $xxxxExport your Maple session to a plain text file elwood.txt and submit it in the usual way.
This is a problem to be solved using Maple. The help facility ?dsolve,numeric may be useful here.
You are trying to send a crate full of supplies, total mass equal to 25 kg, across a very deep gorge, with sides separated by 100 meters. A rope of length 70 meters is suspended from a point directly above the middle of this gorge. The end of the rope just reaches you, and it can reach the person directly opposite you waiting for the crate on the other side of the gorge.
You want to swing the crate so that it just reaches your colleague awaiting the supplies, i.e., when the crate gets the opposite side of the gorge, it should have a velocity of zero. In the absence of air resistance, you have an easy problem, that of the simple pendulum from Introductory Physics. Unfortunately, this is the real world and there is viscous drag from the air. Assume that the drag force on the crate has a magnitude of
f_drag = 5 * 10^(-4) * v^1.1where v is the speed.
What initial speed must you give the crate to ensure that it reaches the person on the other side of the gorge? Treat the rope as massless. Solve this using Maple's dsolve command. In your session, find the initial speed that gives a speed of less than 0.01 m/s at the receiver's position. Assign your answer to a variable vstart and calculate a trajectory with this value.
Hint: think backwards. Also, Maple is a little weak in terms of letting you manipulate dsolve. You want the velocity at some position X0=x(t=t0). If you solve for t0, you'd have your answer by plugging the result into v(t0). While you can create functions x(t),v(t) [see examples in ?dsolve,numeric] Maple seems unwilling to let you do anything like "fsolve(x(t)=X0,t)" to get t when x=x0. You'll need workaround. One possibility (though there are undoubtedly more elegant ways) is to guess at t0 and use 3 points (t,x(t)) to
Turn in a plain-text copy of your Maple session, rope.txt.
Here we return to financial matters.
An option is a contract which enables one to buy or sell a security (e.g., a stock) at a specified price on a specfied date. There is no obligation for the holder of an option to actually follow through on the purchase or sale. Options, like stocks, have a monetary value and they are traded (bought and sold) just like stocks. Here we look at a famous way to determine the value of a certain kind of option.
Consider the S&P 500 Index as a security (it is actually based on the average of 500 stock prices). As of early December 2000, the value, or price, of the index is around 1300--1400 (units of US dollars). You can purchase a call option to obtain a "share" of the S&P 500 for a "strike price" of 1325 on the 19th of January, 2001 (the option's "expiration date"). This gives you the right to buy a share for a price of 1325 on 19-Jan. If on that day the S&P 500 is worth more, say, 1425, your option lets you buy a share at 1325; you could thus sell it immediately for 1425, making a 100 dollar profit. In this case, the option would have a value of 100 dollars on its expiration date.
Alternatively, if the S&P 500 Index has a value of 1225 on its expiration date, then your option gives you no bargain: If you "exercised" tyhe option contract, that is, if you went through with the purchase of a share for 1325, you'd be paying 100 dollars more than the share is worth, a 100 dollar loss. You might think that the option would be worth -100 dollars, but remember that the option contract does not oblige you to exercise it. So the value of the option is simply zero, i.e., it is worthless.
This may sound a little sweet -- your option makes you money if the price of the S&P is above 1325 on 19-Jan, but doesn't require that you fork over cash if the price goes below 1325 on that date. The bad news is that to "enter into an option contract", you have to actually buy the option, just like you would buy a share of stock (in fact, options are traded, just like stocks). The price that you would pay for the option is a little sticky to determine: If it were now mid-December, and your option was the S&P 500 call (1325 strike price, 19-Jan-2001 exp. date), how much would it be worth now when the value of the Index is 1225? Would it be worthless? Not necessarily. The Index value could go higher than 1325 by 19-Jan, making your option worth something. Conversely, if the S&P 500 Index were at 1425 now, it would not necessarily be worth 100 dollars, since by the time 19-Jan rolled around the index might climb or fall to values other than 1425. Thus, the value of the option depends on (unkown) behavior of Index.
Certainly, some factors that detemine the price of an option include how much time is left between now and the option's expiration date, and how "volatile" the Index is. If the Index is not volative, that means it won't change that much in value between now and the expiration. So for the S&P option, its value would be close to 100 if the Index were at 1425 and close to 0 if the Index were at 1225. On the other hand, if the Index's price had high volatility, with wild fluctuations, the option would have greater value even when the Index was at 1225, since the Index could easily swing to high values by the expiration date. In general, the greater the uncertainty in the future value of the Index, the more expensive the price of the option.
The price of options can be estimated quantitatively using the famous Black-Scholes equation, which incorporates these factors. The BS option price formula is
C = S*N(d1)-K*exp(-r*(t))*N(d2), d1 = (ln(S/K)+(r+0.5*sig^2)*t)/(sig*sqrt(t)), d2 = d1-sig*sqrt(t),where
C = price of the option contract S = the current value of the security (the S&P 500 Index, 1315) K = the strike price (1325) sig = volatility (a measure of the uncertainty in future security values) r = the rate of return of a "safe" investment like a U.S. Treasury Bond t = time to expiration dateand
N = 0.5+Integrate[t=0 to t=x] dt exp(-(t^2)/2)/sqrt(2*pi).Note that the integral is the function Gerf() introduced in Assignment 08, Exercise 2.
For this problem, use Maple to find price for a call option to buy a share of the S&P 500 (trading symbol SPX) at 1325 with an expiration date of January 18, 2001. Use K:=1325, sig:=0.32, r:=0.08, and t:=1.25/12 (units: S,K=$; sig=yr^(-1/2); r = yr^(-1); and t=yr). For the value of S, go to the Chicago Board Options Exchange (CBOE) homepage (or any stock price quote server) to get a current price C. (The value of r=8% per year is a rough guess for the current "no-risk" rate of return, while sig=0.32 comes from the "CBOE volatility index" [symbol VIX] given on the CBOE website -- feel free to use an updated value.) You can check your answer by comparing it with the current trading price of the option (symbol: SXYAE.
Caution: As you can guess, option prices vary A LOT more than the price of the underlying security on which they are based. Prices may double or drop by a factor of a few on timescales of a day or less. Also, the Black-Scholes pricing formula is designed for European-style call options (not to be explained here!) and does not work consistently well for individual stocks. It may be better for Index-based options, though. Penultimately, note that the price of an option as quoted by the CBOE website reflects that of an option to buy (or sell) a single share. Yet to enter an option contract you typically must buy an option for 100 shares. Thus if you see an option selling for 50 dollars, and you place 1 order with your e-broker, expect to pay 5000 dollars for your contract.
Finally, do not forget that while all investment is speculation, at least buying stocks means that you are giving money to a company to do something productive. The same may not be said of options.
Submit your answer in a file option.txt, exported text from the Maple worksheet you used to solve the problem.
This is an exercise using Maple. Consider a chain of 4 unit-mass particles connected together by springs of unit spring constant. The two particles at the ends of the chain are attached to fixed walls by similar sptrings. Schematically, the system looks like:
| |
|-www-O-www-O-www-O-www-O-www-|
| |
(the www's are supposed to be springs, and O's are particles).
All motion is restricted to 1 dimension, longitudinal displacements
along the chain.
a) The equation of motion for this system can be written as
d^2/dt^2 X = A Xwhere X is a 4-D vector whose i^th component is the displacement of the i^th particle from its equilibrium position, and A is a 4x4 matrix. In a Maple session, set up the matrix A for this system. You may wish to start with the Maple worksheet ~p5720/examples/mtrxintro.mws. Next, find the eigenvectors and eigenvalues of this matrix.
At t=0, suppose the displacement vector is X=(0,0,1,0) and the time derivative of X is (0,0,0,0). Find the displacement vector at t=10 units.
Hint: As discussed in lecture, it is simple to solve the equation of motion if the displacement vector is proportional to any one eigenvector (the problem reduces to that of a simple harmonic oscillator). The more general case is also straightforward when one recognizes that any displacement vector can be written as a linear combination of eigenvectors; the contribution of each eigenvector to a given displacement vector is determined by taking the dot product. Potentially useful Maple commands: with(linalg), eigenvectors, dotprod.
Export your Maple session to a plain text file called chain.txt, and submit only this file.
(To view an animation of a partial solution to this problem, try
blackstar> sm < ~p5720/src/chain.smThe individual displacements are shown on the vertical axis, while the horizontal axis gives the particle index.)
Often it is important for you to be able to produce an image of your scientific results, not only to display them to others, but to help you understand the relevant physics.
Write a C++ code, image.cc, to create a 400x400 pixel image in ppm format (something that can be viewed by xv or gimp). Start by creating an array of characters ("unsigned char", meaning 1-byte datatype with numerical value of 0 to 255):
typedef unsigned char uchar; // now we can use "uchar" to mean "unsigned char"
int main()
{
int nx = 400; // image HEIGHT
int ny = 400; // image WIDTH
uchar **a = new uchar* [nx];
a[0] = new uchar [nx*nx];
for (int i=1; i<nx; i++) a[i] = a[i-1]+ny;
Now you have allocated a big chunk of memory (400x400 bytes)
in the form of an array whose elements can be accessed using
"a[i][j]", for example.
Then set the elements of "a" to values from 0 to 255. These values will correspond to the brightness of pixels when displayed as an image (0=dark,255=bright). (You may have to use a cast [e.g., a[i][j]=uchar(7.0*sin(..)+...)] to convert your values explicitly into unsigned characters.)
Next, write out your data to a file "image.ppm", using
string fname = "image.ppm"; ofstream fppm(fname.c_str()); fppm << "P5" << endl; fppm << ny << " " << nx << endl; fppm << 255 << endl; fppm.write(a[0],nx*ny*sizeof(uchar)); fppm.close();Note that the first three lines of the output file are plain text, containing the string "P5" (indicates greyscale ppm format) then two intger numbers indicating the size of the image (ny=WIDTH, nx=HEIGHT). The third line, "255", indicates the the range of brightness values. Finally, we write the array using a binary write member function of ofstream. We spit out the array all at once -- all nx*ny bytes. Note the "sizeof()" function. This tells write() homw many bytes to dump out. Here sizeof(uchar) is unity, but if we were writing out an array of doubles, sizeof(double) [typically 8 bytes] would need to be included [that is, write() works with sizes in bytes, not in number of elements].
Hint: The header files fstream, string and cmath may be useful.
Turn in only your c++ code image.cc.
If you want, you can pack your array "a" with a simple function, but you might want to experiment. For example, the image
is pretty easy to make: set all pixels to zero at first, then go through and change the brightness of pixels according to whether they lie within circles about a few well-chosen positions.