0% found this document useful (0 votes)
32 views

'M' 'Linewidth' On 'B' 'Linewidth' 'Eje X' 'Eje Y' 'Ejemplo 1' On Off

The document describes two examples of using the bisection method to find the root of a function. The first example finds the root of the function f(x)=x^3+3-exp(x) between -2 and -1. The second example finds the root of the function f(x)=x^4-x-3 between -2 and -1. For each example, the bisection method is applied with a tolerance of 10^-7 or 10^-6, respectively. The results show the iterative steps to converge on the root.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

'M' 'Linewidth' On 'B' 'Linewidth' 'Eje X' 'Eje Y' 'Ejemplo 1' On Off

The document describes two examples of using the bisection method to find the root of a function. The first example finds the root of the function f(x)=x^3+3-exp(x) between -2 and -1. The second example finds the root of the function f(x)=x^4-x-3 between -2 and -1. For each example, the bisection method is applied with a tolerance of 10^-7 or 10^-6, respectively. The results show the iterative steps to converge on the root.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

EJEMPLO 1

clc
clear
x=[-2:0.001:5];
y1=x.^3+3;
y2=exp(x);
plot(x,y1,'m','linewidth',1)
hold on
plot(x,y2,'b','linewidth',1)
xlabel('Eje x')
ylabel('Eje y')
title('Ejemplo 1')
grid on
hold off
axis([-2 5 -10 140])

function y=feje1Abis(x)
y=x.^3+3-exp(x)
end

>> a=-2,b=-1,tol=10^(-7)

a = -2

b = -1

tol = 1.0000e-07
>> [c]=bisec('feje1Abis',a,b,tol)

y = -5.1353
y = 1.6321
y = -0.5981
0 -2.00000000000 -1.00000000000 -1.50000000000 -0.59813016015
y =0.7604
1 -1.50000000000 -1.00000000000 -1.25000000000 0.76037020314
y = 0.1476
2 -1.50000000000 -1.25000000000 -1.37500000000 0.14755102920
y = -0.2080
3 -1.50000000000 -1.37500000000 -1.43750000000 -0.20797980347
y =-0.0260
4 -1.43750000000 -1.37500000000 -1.40625000000 -0.02597484589
y = 0.0618
5 -1.40625000000 -1.37500000000 -1.39062500000 0.06183700215
y =0.0182
6 -1.40625000000 -1.39062500000 -1.39843750000 0.01819467703
y =-0.0038
7 -1.40625000000 -1.39843750000 -1.40234375000 -0.00382401324
y = 0.0072
8 -1.40234375000 -1.39843750000 -1.40039062500 0.00720182826
y =0.0017
9 -1.40234375000 -1.40039062500 -1.40136718750 0.00169303428
y =-0.0011
10 -1.40234375000 -1.40136718750 -1.40185546875 -0.00106445745
y =3.1455e-04
11 -1.40185546875 -1.40136718750 -1.40161132813 0.00031454638
y =-3.7489e-04
12 -1.40185546875 -1.40161132813 -1.40173339844 -0.00037489104
y =-3.0156e-05
13 -1.40173339844 -1.40161132813 -1.40167236328 -0.00003015621
y =1.4220e-04
14 -1.40167236328 -1.40161132813 -1.40164184570 0.00014219911
y =5.6022e-05
15 -1.40167236328 -1.40164184570 -1.40165710449 0.00005602246
y = 1.2933e-05
16 -1.40167236328 -1.40165710449 -1.40166473389 0.00001293338
y =-8.6114e-06
17 -1.40167236328 -1.40166473389 -1.40166854858 -0.00000861135
y = 2.1610e-06
18 -1.40166854858 -1.40166473389 -1.40166664124 0.00000216103
y = -3.2252e-06
19 -1.40166854858 -1.40166664124 -1.40166759491 -0.00000322516
y =-5.3206e-07
20 -1.40166759491 -1.40166664124 -1.40166711807 -0.00000053206
y = 8.1448e-07
21 -1.40166711807 -1.40166664124 -1.40166687965 0.00000081448
y =1.4121e-07
22 -1.40166711807 -1.40166687965 -1.40166699886 0.00000014121
y = -1.9543e-07
23 -1.40166711807 -1.40166699886 -1.40166705847 -0.00000019543
c = -1.4017

ejercicio 2
clc
clear
x=[-4:0.001:5];
y1=x.^4;
y2=x+3;
plot(x,y1,'m','linewidth',2)
hold on
plot(x,y2,'b','linewidth',2)
xlabel('Eje x')
ylabel('Eje y')
title('Ejemplo 1')
grid on
hold off
axis([-4 5 -10 140])
function y=feje2Abis(x)
y=x.^4-x-3
end

a=-2,b=-1,tol=10^(-6)

a = -2
b = -1
tol = 1.0000e-06

>> [c]=bisec('feje2Abis',a,b,tol)
y = 15
y = -1
y =3.5625
0 -2.00000000000 -1.00000000000 -1.50000000000 3.56250000000
y =0.6914
1 -1.50000000000 -1.00000000000 -1.25000000000 0.69140625000
y = -0.2732
2 -1.25000000000 -1.00000000000 -1.12500000000 -0.27319335938
y = 0.1760
3 -1.25000000000 -1.12500000000 -1.18750000000 0.17604064941
y =-0.0564
4 -1.18750000000 -1.12500000000 -1.15625000000 -0.05641078949
y =0.0578
5 -1.18750000000 -1.15625000000 -1.17187500000 0.05780321360
y =1.9998e-04
6 -1.17187500000 -1.15625000000 -1.16406250000 0.00019997731
y = -0.0282
7 -1.16406250000 -1.15625000000 -1.16015625000 -0.02822863287
y =-0.0140
8 -1.16406250000 -1.16015625000 -1.16210937500 -0.01404523825
y =-0.0069
9 -1.16406250000 -1.16210937500 -1.16308593750 -0.00693037108
y = -0.0034
10 -1.16406250000 -1.16308593750 -1.16357421875 -0.00336713366
y =-0.0016
11 -1.16406250000 -1.16357421875 -1.16381835938 -0.00158406257
y = -6.9216e-04
12 -1.16406250000 -1.16381835938 -1.16394042969 -0.00069216376
y =-2.4612e-04
13 -1.16406250000 -1.16394042969 -1.16400146484 -0.00024612351
y =-2.3081e-05
14 -1.16406250000 -1.16400146484 -1.16403198242 -0.00002308067
y = 8.8446e-05
15 -1.16406250000 -1.16403198242 -1.16404724121 0.00008844643
y =3.2682e-05
16 -1.16404724121 -1.16403198242 -1.16403961182 0.00003268240
y =4.8007e-06
17 -1.16403961182 -1.16403198242 -1.16403579712 0.00000480075
y =-9.1400e-06
18 -1.16403579712 -1.16403198242 -1.16403388977 -0.00000913999
y = -2.1696e-06
19 -1.16403579712 -1.16403388977 -1.16403484344 -0.00000216963
c =-1.1640

You might also like