1.Newton@Ì
f(x), df(x)
ÌÖW𦷮ð±¯D
restart;
y-f(x1) = (df(x1))(x-x1);
y - f(x1) = df(x1)(x - x1)
y = (df(x1))(x-x1)+f(x1);
y = df(x1)(x - x1) + f(x1)
y=0;
df(x1)(x-x1)+f(x1)=0;
df(x1)(x-x1)=-f(x1);
x-x1=-f(x1)/df(x1);
x=-f(x1)/df(x1)+x1;
y = 0
df(x1)(x - x1) + f(x1) = 0
df(x1)(x - x1) = -f(x1)
f(x1)
x - x1 = - ------
df(x1)
f(x1)
x = - ------ + x1
df(x1)
ñª@Ej
[g@
restart;
Digits := 10; f := unapply(exp(-x)-2*exp(-2*x), x); plot(f(x), x = -1 .. 2);
x -> exp(-x) - 2 exp(-2 x)
ñª@
x1:=-1.0: x2:=2.0:
f1:=f(x1): f2:=f(x2):
epsilon:=0.001: delta:=0.001:
for i from 1 to 100 do
x3:=(x1+x2)/2;
f3:=f(x3);
if (evalf(f1*f3)>=0.0) then
f1:=f3;
x1:=x3;
else
f2:=f3;
x2:=x3;
end if;
printf("%10.5f, %10.5f, %10.5f, %10.5f\n",
x1, x2, f1, f2);
if (abs(x2-x1)<delta) then
break;
end if;
if (abs(f2-f1)<epsilon) then
break;
end if;
end do:
printf("%dåç®, x = %.5f, f(x) = %.5f\n", i, x3, f(x3));
0.50000, 2.00000, -0.12923, 0.09870
0.50000, 1.25000, -0.12923, 0.12233
0.50000, 0.87500, -0.12923, 0.06931
0.68750, 0.87500, -0.00285, 0.06931
0.68750, 0.78125, -0.00285, 0.03861
0.68750, 0.73438, -0.00285, 0.01938
0.68750, 0.71094, -0.00285, 0.00866
0.68750, 0.69922, -0.00285, 0.00301
0.68750, 0.69336, -0.00285, 0.00011
0.69043, 0.69336, -0.00136, 0.00011
0.69189, 0.69336, -0.00063, 0.00011
11åç®, x = 0.69189, f(x) = -0.00063
Newton@
x4 := -1.0; df := unapply(diff(f(x), x), x); epsilon := 0.1e-2; delta := 0.1e-2; for i to 100 do x5 := x4-f(x4)/df(x4); printf("%10.5f,~%10.5f\n", x5, f(x5)); if abs(x5-x4) < delta then break end if; if abs(f(x5)-f(x4)) < epsilon then break end if; x4 := x5 end do; printf("%dåç®,~x~=~%.5f,~f(x)~=~%.5f\n", i, x4, f(x4));
x -> -exp(-x) + 4 exp(-2 x)
-0.55064, -4.28169
-0.13485, -1.47479
0.22538, -0.47607
0.49737, -0.13151
0.64833, -0.02397
0.69032, -0.00142
0.69314, -0.00001
0.69315, 0.00000
8åç®, x = 0.69314, f(x) = -0.00001
absÍâÎl
3(2004ú)
3(a)
restart;
with(plots): with(plottools):
Digits:=10:
f:=unapply(exp(-x)-x^2,x);
plot(f(x),x=-1..1);
2
x -> exp(-x) - x
x1:=-1.0: x2:=1.0:
f1:=f(x1): f2:=f(x2):
epsilon:=0.001: delta:=0.001:
for i from 1 to 100 do
x3:=(x1+x2)/2;
f3:=f(x3);
if (evalf(f1*f3)>=0.00) then
f1:=f3;
x1:=x3;
else
f2:=f3;
x2:=x3;
end if;
printf("%10.5f, %10.5f, %10.5f, %10.5f\n",
x1, x2, f1, f2);
if (abs(x2-x1)<delta) then
break;
end if;
if (abs(f2-f1)<epsilon) then
break;
end if;
end do:
printf("%dåç®, x = %.5f, f(x) = %.5f\n", i, x3, f(x3));
0.00000, 1.00000, 1.00000, -0.63212
0.50000, 1.00000, 0.35653, -0.63212
0.50000, 0.75000, 0.35653, -0.09013
0.62500, 0.75000, 0.14464, -0.09013
0.68750, 0.75000, 0.03018, -0.09013
0.68750, 0.71875, 0.03018, -0.02924
0.70312, 0.71875, 0.00065, -0.02924
0.70312, 0.71094, 0.00065, -0.01425
0.70312, 0.70703, 0.00065, -0.00679
0.70312, 0.70508, 0.00065, -0.00307
0.70312, 0.70410, 0.00065, -0.00121
11åç®, x = 0.70410, f(x) = -0.00121
x4:=-1.0:
df:=unapply(diff(f(x),x),x);
epsilon:=0.001: delta:=0.001:
for i from 1 to 100 do
x5:=x4-f(x4)/df(x4);
printf("%10.5f, %10.5f\n", x5, f(x5));
if (abs(x5-x4)<delta) then
break;
end if;
if (abs(f(x5)-f(x4))<epsilon) then
break;
end if;
x4:=x5;
end do:
printf("%dåç®, x = %.5f, f(x) = %.5f\n", i, x4, f(x4));
x -> -exp(-x) - 2 x
1.39221, -1.68973
0.83509, -0.26353
0.70983, -0.01214
0.70348, -0.00003
0.70347, -0.00000
5åç®, x = 0.70348, f(x) = -0.00003
3(b)
äºåæ³
x1:=-1.0: x2:=1.0:
f1:=f(x1): f2:=f(x2):
x_f:=0.7034674225;
lst1:=[]:
for i from 1 to 100 do
x3:=(x1+x2)/2;
f3:=f(x3);
if (evalf(f1*f3)>=0.00) then
f1:=f3;
x1:=x3;
else
f2:=f3;
x2:=x3;
end if;
lst1:=[op(lst1), log(abs(x_f-x3))];
end do:
printf("%dåç®, x = %.5f, f(x) = %.5f\n", i, x3, f(x3));
0.7034674225
101åç®, x = 0.70347, f(x) = 0.00000
Newtonæ³
x4:=-1.0:
df:=unapply(diff(f(x),x),x);
x_f:=0.7034674225;
lst2:=[]:
for i from 1 to 100 do
x5:=x4-f(x4)/df(x4);
lst2:=[op(lst2), log(abs(x_f-x5))];
x4:=x5;
end do:
printf("%dåç®, x = %.5f, f(x) = %.5f\n", i, x4, f(x4));
x -> -exp(-x) - 2 x
0.7034674225
101åç®, x = 0.70347, f(x) = 0.00000
l1:=listplot(lst1,linestyle=solid,legend="äºåæ³""):
l2:=listplot(lst2,linestyle=dashdot,legend="Newtonæ³""):
display([l1,l2]);
4(2008Nx)
restart;
Digits:=10:
f:=unapply(x^4-x-0.12,x);
plot(f(x),x=0..2);
4
x -> x - x - 0.12
x1:=0.0: x2:=2.0:
f1:=f(x1): f2:=f(x2):
epsilon:=1.0*10^(-8): delta:=1.0*10^(-8):
for i from 1 to 1000 do
x3:=(x1+x2)/2;
f3:=f(x3);
if (evalf(f1*f3)>=0.00) then
f1:=f3;
x1:=x3;
else
f2:=f3;
x2:=x3;
end if;
if (abs(x2-x1)<delta) then
break;
end if;
if (abs(f2-f1)<epsilon) then
break;
end if;
end do:
printf("%dåç®, x = %.5f, f(x) = %.5f\n", i, x3, f(x3));
28åç®, x = 1.03717, f(x) = 0.00000
6(ü@)
restart;
Digits:=10:
func:=x->x^2-4*x+1;
x1:=0: x2:=2:
f1:=func(x1): f2:=func(x2):
plot({(z-x1)*(f1-f2)/(x1-x2)+f1,func(z)},z=0..2);
x_f:=fsolve(func(x)=0,x)[1];
2
x -> x - 4 x + 1
0.2679491924
with(plots): with(plottools):
f:=func:
N:=40:
å²ç·æ³
x1:=0: x2:=2:
f1:=f(x1): f2:=f(x2):
lst1:=[]:
for i from 1 to N do
y1:=((f2-f1)/(x2-x1))*(x-x1)+f1:
x3:=fsolve(y1=0,x);
f3:=f(x3);
if (evalf(f1*f3)>=0.00) then
f1:=f3;
x1:=x3;
else
f2:=f3;
x2:=x3;
end if;
lst1:=[op(lst1), log(abs(x_f-x3))];
end do:
printf("%dåç®, x = %.5f, f(x) = %.5f\n", i, x3, f(x3));
41åç®, x = 0.26795, f(x) = 0.00000
äºåæ³
x1:=0.0: x2:=2.0:
f1:=f(x1): f2:=f(x2):
lst2:=[]:
for i from 1 to N do
x3:=(x1+x2)/2;
f3:=f(x3);
if (evalf(f1*f3)>=0.00) then
f1:=f3;
x1:=x3;
else
f2:=f3;
x2:=x3;
end if;
lst2:=[op(lst2), log(abs(x_f-x3))];
end do:
printf("%dåç®, x = %.5f, f(x) = %.5f\n", i, x3, f(x3));
41åç®, x = 0.26795, f(x) = -0.00000
Newtonæ³
x4:=0.0:
df:=unapply(diff(f(x),x),x):
lst3:=[]:
for i from 1 to N do
x5:=x4-f(x4)/df(x4);
lst3:=[op(lst3), log(abs(x_f-x5))];
x4:=x5;
end do:
printf("%dåç®, x = %.5f, f(x) = %.5f\n", i, x4, f(x4));
41åç®, x = 0.26795, f(x) = 0.00000
l1:=listplot(lst1,linestyle=solid,legend="ü@"):
l2:=listplot(lst2,linestyle=dashdot,legend="ñª@"):
l3:=listplot(lst3,linestyle=spacedash,legend="Newton"):
display([l1,l2,l3]);
7(2009Nx)
restart;
Digits:=10:
with(plots): with(plottools):
f:=unapply(cos(x)-x^2,x);
x_f:=fsolve(f(x)=0,x);
N:=50:
plot(f(x),x=0..1);
2
f := x -> cos(x) - x
x_f := 0.8241323123
äºåæ³
x1:=0.0: x2:=1.0:
f1:=f(x1): f2:=f(x2):
lst1:=[]:
for i from 1 to N do
x3:=(x1+x2)/2;
f3:=f(x3);
if (evalf(f1*f3)>=0.00) then
f1:=f3;
x1:=x3;
else
f2:=f3;
x2:=x3;
end if;
lst1:=[op(lst1), log(abs(x_f-x3))];
end do:
printf("%dåç®, x = %.5f, f(x) = %.5f\n", i, x3, f(x3));
51åç®, x = 0.82413, f(x) = -0.00000
å²ç·æ³
x1:=0.0: x2:=1.0:
f1:=f(x1): f2:=f(x2):
lst2:=[]:
for i from 1 to N do
y1:=((f2-f1)/(x2-x1))*(x-x1)+f1:
x3:=fsolve(y1=0,x);
f3:=f(x3);
if (evalf(f1*f3)>=0.00) then
f1:=f3;
x1:=x3;
else
f2:=f3;
x2:=x3;
end if;
lst2:=[op(lst2), log(abs(x_f-x3))];
end do:
printf("%dåç®, x = %.5f, f(x) = %.5f\n", i, x3, f(x3));
51åç®, x = 0.82413, f(x) = -0.00000
l1:=listplot(lst1,linestyle=solid,legend="ñª@"):
l2:=listplot(lst2,linestyle=dashdot,legend="ü@"):
display([l1,l2]);
8(2010Nx)
restart;
Digits:=10:
f:=unapply(x^3-3*x+3,x);
plot(f(x),x=-5..5);
3
x -> x - 3 x + 3
x1:=-3;
df:=unapply(diff(f(x),x),x);
epsilon:=0.001: delta:=0.001:
for i from 1 to 100 do
x2:=x1-f(x1)/df(x1);
printf("%10.5f, %10.5f\n", x2, f(x2));
if (abs(x2-x1)<delta) then
break;
end if;
if (abs(f(x2)-f(x1))<epsilon) then
break;
end if;
x1:=x2;
end do:
printf("%dñÚ, x = %.5f, f(x) = %.5f\n", i, x1, f(x1));
-3
2
x -> 3 x - 3
-2.37500, -3.27148
-2.14001, -0.38046
-2.10458, -0.00801
-2.10380, -0.00000
4ñÚ, x = -2.10458, f(x) = -0.00801
x3:=2;
df:=unapply(diff(f(x),x),x);
epsilon:=0.001: delta:=0.001:
for i from 1 to 100 do
x4:=x3-f(x3)/df(x3);
printf("%10.5f, %10.5f\n", x3, f(x3));
if (abs(x4-x3)<delta) then
break;
end if;
if (abs(f(x4)-f(x3))<epsilon) then
break;
end if;
x3:=x4;
end do:
printf("%dñÚ, x = %.5f, f(x) = %.5f\n", i, x3, f(x3));
2
2
x -> 3 x - 3
2.00000, 5.00000
1.44444, 1.68038
0.92887, 1.01482
3.39447, 31.92927
2.38301, 9.38346
1.71449, 2.89625
1.21672, 1.15109
0.41805, 1.81891
1.15275, 1.07357
0.06453, 2.80668
1.00400, 1.00005
-40.56380, -66619.86560
-27.05959, -19729.42266
úlðx=-3Ƶ½êÍ4ñÚÅðªoܵ½ªúlðx=2Ƶ½êÍvZʪoܹñŵ½B
最終更新:2013年01月09日 18:48