timing problems in mathematica
- To: mathgroup at yoda.physics.unc.edu
- Subject: timing problems in mathematica
- From: BENNINGA at wilma.wharton.upenn.edu
- Date: Tue, 6 Oct 92 13:17 EDT
Can someone help me? The following Mathematica program produces
a triangular matrix of real numbers. My problem is that the
TIMING differs each time I run the program. Here are some sample
times (in seconds) for tmax=5:
19.28, 19.99, 20.93, 21.86,.66.02.
The last time was when I returned to tmax=5 after running the
program for tmax=30 (that one took 2090.34 seconds!).
I'm running Mma on a 80486 under MS-Windows. I should add that
I'm new to the program.
While I'm at it: Does anyone out there have a problem with a
jumpy cursor? Occassionally disappearing text?
Thanks,
Simon Benninga
Finance Department, Wharton School
Univ. of Pennsylvania
BENNINGA at WHARTON.UPENN.EDU
HERE'S THE PROGRAM
Clear[beta1,beta2,gamma1,gamma2,s0,LHS,s,j,t]
gamma1=2;gamma2=14; s0=0.45;
beta1=0.9;beta2=0.95;
tmax=5;
initial=(1-s0)^gamma2/s0^gamma1;
LHS[t_,s_]:=initial*(beta1/beta2)^t*(s^gamma1/(1-s)^gamma2);
c[t_,j_]:=Which[j<=t,FindRoot[LHS[t,s]==u^j*d^(t-
j),{s,0.5}],j>t,0];
(* The following command produces a matrix of numbers only: *)
cons=Table[c[t,j][[1,2]],{t,0,tmax},{j,0,t}] ;