This is the result of doing ">> diary 9_15_98", doing a bunch of matlab stuff, then editing the file to put in some comments for you to read. >> x = -5:.01:5; >> size(x) ans = 1 1001 >> p0 = 1*ones(size(x)); note: I want p0 to be a vector of the same size as x. ones(size(x)) is a vector of all ones that is the same size of x. try zeros(size(x)) and rand(size(x)) to compare. >> p1 = 1 - (x-pi/2); >> p2 = 1 - (x-pi/2) + 1/2*(x-pi/2).^2; >> p3 = p2; >> p4 = p3 - 1/8*(x-pi/2).^4; >> plot(x,exp(cos(x))); >> hold on >> plot(x,p1); oooops! I wanted to do p0 with a solid line, not p1. So I erase it by writing over the solid line with a black solid line (that's the k) since my graph is on a black background. If it was on a white background, I'd use 'w-' to write over it. >> plot(x,p1,'k-'); >> plot(x,p0); >> plot(x,p1,'--'); >> plot(x,p2,'-.'); >> plot(x,p4,':'); >> figure(1) >> axis([0,pi/2,-1,2]) >> axis([0,pi,-1,2]) >> axis([0,pi,-1,3]) >> title('approximating f(x) = exp(cos(x)) at x = pi/2') >> gtext('solid: f and p0'); place the text on the figure and then click the mouse button to make it stick. >> gtext('dashed: p1'); >> gtext('dot-dashed: p2 and p3'); >> gtext('dotted: p4'); >> print -dps fig_9_15.ps A reminder of how flops works: >> flops(0) >> A = rand(2,2); B = rand(2,2); A*B ans = 1.3093 0.4449 0.5764 0.1145 >> flops ans = 16 >> flops(0) >> A = rand(3,3); B = rand(3,3); A*B ans = 1.2356 0.4703 0.1538 1.1485 0.6809 0.2147 1.7031 1.0568 0.2983 >> flops ans = 54 >> flops(0) >> A = rand(4,4); B = rand(4,4); A*B ans = 1.4040 2.0709 1.9408 1.2746 0.9690 1.3392 1.2309 0.8056 1.3183 1.9266 1.8600 1.2582 1.3419 2.0032 1.7002 1.2974 >> flops ans = 128 >> quit 128 flops.