• My UNC Charlotte

  • Directory

  • Campus Events

  • Library

  • Prospective Students

    • About UNC Charlotte
    • Campus Life
    • Admissions
    • Graduate Admissions
  • Faculty and Staff

    • Human Resources
    • Auxiliary Services
    • Inside UNC Charlotte
    • Academic Affairs
  • Current Students

    • Athletics
    • Financial Aid
    • Advising
    • Student Health Center
  • Alumni and Friends

    • Alumni Association
    • Advancement
    • Foundation
    • Make a Gift
Steven Clark
Steven Clark
Associate Professor of Finance, Belk College of Business
  • My UNC Charlotte

  • Directory

  • Campus Events

  • Library

  • Prospective Students

    • About UNC Charlotte
    • Campus Life
    • Admissions
    • Graduate Admissions
  • Faculty and Staff

    • Human Resources
    • Auxiliary Services
    • Inside UNC Charlotte
    • Academic Affairs
  • Current Students

    • Athletics
    • Financial Aid
    • Advising
    • Student Health Center
  • Alumni and Friends

    • Alumni Association
    • Advancement
    • Foundation
    • Make a Gift
  • Home
  • Teaching
  • Seminars

Links

  • Belk College of Business
Teaching » FINN 6203 Financial Economic Theory » Maple Example

Maple Example

maple_ex.html

>    with(linalg);

[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, coldi...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, coldi...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, coldi...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, coldi...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, coldi...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, coldi...
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol, addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout, blockmatrix, charmat, charpoly, cholesky, col, coldi...

>    M:=matrix(3,4,[60,50,53,28,110,120,127,59,30,30,30,15]);

M := matrix([[60, 50, 53, 28], [110, 120, 127, 59], [30, 30, 30, 15]])

>    gausselim(M);

matrix([[60, 50, 53, 28], [0, 5, 7/2, 1], [0, 0, 10, 2]])

>    gaussjord(M);

matrix([[1, 0, 0, 6/25], [0, 1, 0, 3/50], [0, 0, 1, 1/5]])

>    P:=Vector[row]([5/10,1/10,4/10]);

P := Vector(%id = 27714064)

>    m:=[(6/25)/P[1],(3/50)/P[2],(1/5)/P[3]];

m := [12/25, 3/5, 1/2]

>    R1:=Vector[row]([M[1,1]/M[1,4],M[1,2]/M[1,4],M[1,3]/M[1,4]]);

R1 := Vector(%id = 27714144)

>    R2:=Vector[row]([M[2,1]/M[2,4],M[2,2]/M[2,4],M[2,3]/M[2,4]]);

R2 := Vector(%id = 27714184)

>    R3:=Vector[row]([M[3,1]/M[3,4],M[3,2]/M[3,4],M[3,3]/M[3,4]]);

R3 := Vector(%id = 27714264)

>    ER1:=dotprod(R1,P);#E(R1)

ER1 := 281/140

>    evalf(%);

2.007142857

>    ER2:=dotprod(R2,P);#E(R2)

ER2 := 589/295

>    evalf(%);

1.996610169

>    dotprod(R3,P);

2

>    s1:=sqrt(P[1]*(R1[1]-ER1)^2+(P[2])*(R1[2]-ER1)^2+(P[3])*(R1[3]-ER1)^2);#stdev(R1)

s1 := 1/140*379^(1/2)

>    evalf(%);

.1390565881

>    s2:=sqrt(P[1]*(R2[1]-ER2)^2+(P[2])*(R2[2]-ER2)^2+(P[3])*(R2[3]-ER2)^2);#stdev(R2)

s2 := 1/295*1619^(1/2)

>    evalf(%);

.1363959291

>    R1R2:=[R1[1]*R2[1],R1[2]*R2[2],R1[3]*R2[3]];

R1R2 := [1650/413, 1500/413, 6731/1652]

>    ER1R2:=dotprod(R1R2,P);#E(R1R2)

ER1R2 := 16481/4130

>    (ER1R2-ER1*ER2)/(s1*s2);#rho(R1,R2)

-699/613601*379^(1/2)*1619^(1/2)

>    evalf(%);

-.8923477772

>    mR1:=[m[1]*R1[1],m[2]*R1[2],m[3]*R1[3]];

mR1 := [36/35, 15/14, 53/56]

>    dotprod(mR1,P);#check that E(mR1)=1

1

>    mR2:=[m[1]*R2[1],m[2]*R2[2],m[3]*R2[3]];

mR2 := [264/295, 72/59, 127/118]

>    dotprod(mR2,P); #check that E(mR2)=1

1

>    Em:=dotprod(m,P); #E(m)=1/Rf

Em := 1/2

>    sm:=sqrt(P[1]*(m[1]-Em)^2+P[2]*(m[2]-Em)^2+P[3]*(m[3]-Em)^2);#stdev(m)

sm := 1/50*3^(1/2)

>    evalf(%);

.3464101616e-1

>    (1-Em*ER1)/(sm*s1);#rho(m,R1)

-25/1137*3^(1/2)*379^(1/2)

>    evalf(%);

-.7414122825

>    (1-Em*ER2)/(sm*s2);#rho(m,R2)

25/4857*3^(1/2)*1619^(1/2)

>    evalf(%);

.3587203024

>    yu:=1/Em+sm/Em*x;#upper part of MV frontier yu=Rf+sigma(m)/E(m)*x

yu := 2+1/25*3^(1/2)*x

>    yl:=1/Em-sm/Em*x;#lower part of MV frontier yl=Rf-sigma(m)/E(m)*x

yl := 2-1/25*3^(1/2)*x

>    Ex:=ER1*w+(1-w)*ER2;#E(Rp), Rp=wR1+(1-w)R2

Ex := 87/8260*w+589/295

>    sigma:=sqrt(w^2*s1^2+(1-w)^2*s2^2+2*w*(1-w)*(ER1R2-ER1*ER2));#stdev(Rp)

sigma := 1/8260*(4898091*w^2+1269296-4848088*w)^(1/2)

>    plot([[x,yu(x),x=0..0.2],[x,yl(x),x=0..0.2],[sigma(w),Ex(w),w=0..1]],color=[red,red,blue]);

[Maple Plot]

>    msq:=[(12/25)^2, (3/5)^2, (1/2)^2];#calculate m^2

msq := [144/625, 9/25, 1/4]

>    dotprod(msq,P);#E(m^2)

157/625

>    evalf(%);

.2512000000

>    moverEmsq:=625/157*[12/25, 3/5, 1/2];

moverEmsq := [300/157, 375/157, 625/314]

>    dotprod(moverEmsq,P);#E(m/E(m^2))

625/314

>    evalf(%);

1.990445860

>    mxmoverEmsq:=[m[1]*moverEmsq[1],m[2]*moverEmsq[2],m[3]*moverEmsq[3]];

mxmoverEmsq := [144/157, 225/157, 625/628]

>    dotprod(mxmoverEmsq,P);#check E(m*m/E(m^2))=1

1

>    v1:=[1,0,-6/5];

v1 := [1, 0, -6/5]

>    u2:=[1,-4,0];

u2 := [1, -4, 0]

>    v1u2:=[1,0,0];

v1u2 := [1, 0, 0]

>    v1sq := [1, 0, 36/25];

v1sq := [1, 0, 36/25]

>    v2 := u2-dotprod(v1u2, P)*v1/dotprod(v1sq, P);

v2 := [144/269, -4, 150/269]

>    v1v2 := [144/269, -4*0, -6/5*150/269];

v1v2 := [144/269, 0, -180/269]

>    dotprod(P, v1v2);

0

>    v2sq := [20736/72361, 16, 22500/72361];

v2sq := [20736/72361, 16, 22500/72361]

>    Restar := dotprod(P, v1)*v1/dotprod(P, v1sq)+dotprod(P, v2)*v2/dotprod(P, v2sq);

Restar := [7/157, -61/314, 3/628]

>    plot3d(-1/4*x2-5/6*x3, x2 = (-10 .. 10), x3 = (-10 .. 10),axes=NORMAL);

[Maple Plot]

>    [2, 2, 2] = moverEmsq+ga*Restar;

[2, 2, 2] = [300/157, 375/157, 625/314]+ga*[7/157, -61/314, 3/628]

>    g := (2-300/157)/(7/157);

g := 2

>    (2-375/157)/(-61/314);

2

>    (2-625/314)/(3/628);

2

>    dst:=diff(sigma,w);

dst := 1/16520/(4898091*w^2+1269296-4848088*w)^(1/2)*(9796182*w-4848088)

>    dE:=diff(Ex,w);

dE := 87/8260

>    dEoverdst := proc (w) options operator, arrow; 174*sqrt(4898091*w^2+1269296-4848088*w)/(9796182*w-4848088) end proc;

dEoverdst := proc (w) options operator, arrow; 174*sqrt(4898091*w^2+1269296-4848088*w)/(9796182*w-4848088) end proc

>    plot({dEoverdst(w),sqrt(3)/25},w=.5..1);

[Maple Plot]

>    solve(dEoverdst(w)=sqrt(3)/25);

161/279

>    evalf(%);

.5770609319

>

Click for more  

UNC Charlotte Homepage

Campus Links

  • Alerts
  • Jobs
  • Make a Gift
  • Maps / Directions
  • Accessibility

Resources

  • Alumni & Friends
  • Faculty & Staff
  • Prospective Students
  • Community
  • Current Students
  • Parents and Family

Stay In Touch

facebook instagram flickr linkedin twitter youtube maps

The University of North Carolina at Charlotte
9201 University City Blvd, Charlotte, NC 28223-0001
704-687-8622

© 2017 UNC Charlotte | All Rights Reserved
Contact Us | Terms of Use | University Policies
Skip to toolbar
  • Log In