1.1½â£º m=3;
f=@(x)digit(digit(x^4,m)- digit(x^3,m)+ digit(3*x^2,m)+ digit(x-2,m),m);
g=@(x)digit(digit(digit( digit(digit(digit( (x-1)*x,m)+3,m)*x,m)+1,m)*x,m)-2,m); f(3.33) g(3.33)
ÓÐans = 121 ans =121
ʵ¼ÊÉÏ£¬µ±m=2ʱ£¬¾Í¿ÉÒÔ¿´³öÕâÁ½ÖÖËã·¨ÔÚ¼ÆËãµÄ¾«È·¶ÈÉϵÄÇø±ð£º m=2;
f=@(x)digit(digit(x^4,m)- digit(x^3,m)+ digit(3*x^2,m)+ digit(x-2,m),m);
g=@(x)digit(digit(digit( digit(digit(digit( (x-1)*x,m)+3,m)*x,m)+1,m)*x,m)-2,m); f(3.33) g(3.33)
ÓÐans = 120
ans =130£¬¿ÉÒÔ¿´³ö£¬Á½ÕßÔÚ¼ÆË㾫¶ÈÉϵIJ»Í¬Çø±ð£¬ÊýѧÉϺãµÈ£¬ÔÚÊýÖµÉϲ»Ò»¶¨ºãµÈ¡£ 1.2½â£º
£¨1£©¾«È·µ½Ð¡ÊýµãºóµÚÈý룬¹ÊÓÐ4λÓÐЧÊý×Ö £¨2£©¾«È·µ½Ð¡ÊýµãºóµÚÈý룬¹ÊÓÐ2λÓÐЧÊý×Ö £¨3£©¾«È·µ½Ð¡ÊýµãºóµÚÈý룬¹ÊÓÐ0λÓÐЧÊý×Ö 1.3 ½â;
¼ÇÔ²µÄÃæ»ýΪS£¬ÓÉÌâÒâÓÐ|e(S)|¡Ü1%¡£ÓÉS=¦Ðr2Öª£ºdS=2¦ÐrdrËùÒÔ dS/S=(2¦Ðrdr)/(¦Ðr2)=2(dr/r)
¡à|e(r)|¡Ö1£¯2|e(S)|¡Ü0.5¡Á1%=0.5% 1.4 ½â£º
ÓÉÌâÓУº|e(x)|¡Ü1/2¡Á10^-2 ; |e(y)|¡Ü1/2¡Á10^-2; |e(z)||¡Ü1/2¡Á10^-2
¡à|e£¨S£©|¡Ö|xe(x)+ye(y)|+ |ze(z)|^2¡Öx|e(x)|+y|e(y)|+z^2|z(z)|^2¡Ü4.21¡Á0.005+1.79¡Á1.005+2.11¡Á2.11¡Á0.005^2=0.03¡Ü1/2¡Á10^-1 ÓÖS=4.21*1.79+2.11^2=11.988 ¡àSÖÁÉÙ¾ßÓÐ3λÓÐЧÊý×Ö¡£
ÔÚ×Ö³¤Îª3µÄ¼ÆËã»úÉÏÔËÐУ¬Îó²îΪ£º
S1=4.21*1.79+2.11;
S2=digit(digit(4.21*1.79,3)+digit(2.11^2,3),3); err=S1-S2
err = -2.3541
1.6 ½â£º clc
disp('Please input the coefficients of');
disp('quadratic equation ax^2+bx+c=0, respectively') a=input('a='); b=input('b='); c=input('c=');
m=4; % m-digit rounding arithmetic
if abs(a) if abs(a) disp('Since a=0, quadrtic equation degenerates into a linear equation.') disp('The only solution of the linear eqution is') x=digit(-c/b,m) return end delta=b^2-4*a*c; temp=sqrt(delta); if b>0 x1=(-b-temp)/(2*a) end if b<0 x1=(-b+temp)/(2*a) end if b==0 x1=temp/(2*a) end x2=(c/a)/x1 ÔÚÊäÈëa=1,b=-112,c=2ºóÓнá¹ûx1 =111.9821 x2 =0.0179 kxnxn??£¬???x??? 1.8·½·¨Ò»£ºe??n?0n!n?0n!x?k(?x)n(?x)n?1/??1/?£¬???x???£¬ n!n!n?0n?0?·½·¨¶þ£ºe?1/ex?xclc; %Initialize the data x=5; k=10; m=4; %three-digit rounding arithmetic %------------------------------------ % Compute exp(x) by using Method (A) % with the computer precision results_1=1; power_x=1; for i=1:k factor_x=x/i; power_x=power_x*factor_x; results_1=results_1+power_x; end results_1 err_1=abs(exp(x)-results_1) %------------------------------------ % Compute exp(x) by using Method (A) % with the 3-digits precision results_2=1; power_x=1; for i=1:k factor_x=digit(x/i,m); power_x=digit(power_x*factor_x,m); results_2=digit(results_2+power_x,m); end results_2 err_2=abs(exp(x)-results_2) %------------------------------------ % Compute exp(x) by using Method (B) % with the computer precision t=-x; results_3=1; power_x=1; for i=1:k factor_x=t/i; power_x=power_x*factor_x; results_3=results_3+power_x; end results_3=1/results_3 err_3=abs(exp(x)-results_3) %------------------------------------ % Compute exp(x) by using Method (B) % with the 3-digits precision t=-x; results_4=1; power_x=1; for i=1:k factor_x=digit(t/i,m); power_x=digit(power_x*factor_x,m); results_4=digit(results_4+power_x,m); end results_4=digit(1/results_4,m) err_4=abs(exp(x)-results_4) %------------------------------------ ÉÏÊö³ÌÐòÓù«Ê½£¨1£©¼°£¨2£©·Ö±ðÔÚMatlabÐí¿É¾«¶Èϼ°ÏÞ¶¨ÔÚ×Ö³¤Îª4µÄËãÊõÔËËãÇé¿öϸø³ö µÄ½üËÆ¼ÆËã½á¹û£¬ÆäÖÐresults_1, results_2ΪÓ÷½·¨£¨1£©ÔÚÉÏÊöÁ½ÖÖÇé¿öϵļÆËã½á¹û£¬err_1, err_2ΪÏàÓ¦µÄ¾ø¶ÔÎó²î£»ÀàËÆµÄ£¬results_3, results_4ΪÓ÷½·¨£¨2£©ÔÚÉÏÊö