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

Universidad Nacional Pedro Ruiz Gallo: "Año de La Lucha Contra La Corrupción e Impunidad"

The document contains 5 exercises involving polynomial and exponential functions in MATLAB. For each exercise, the document defines a function, sets the bounds and tolerance for the bisection method, and applies the bisection method to find the root of the function within the bounds.

Uploaded by

Katty Lizana
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)
46 views

Universidad Nacional Pedro Ruiz Gallo: "Año de La Lucha Contra La Corrupción e Impunidad"

The document contains 5 exercises involving polynomial and exponential functions in MATLAB. For each exercise, the document defines a function, sets the bounds and tolerance for the bisection method, and applies the bisection method to find the root of the function within the bounds.

Uploaded by

Katty Lizana
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/ 28

UNIVERSIDAD NACIONAL PEDRO

RUIZ GALLO
"Año de la lucha contra la
corrupción e impunidad”

Facultad:
Ingeniería Civil, Sistemas y Arquitectura

Escuela Profesional:
Ingeniería Civil

Docente:
Ing. Rimarachín López Betty

Curso:
Matemática Básica II _ Curso de MATLAB

Tema:
Funciones Polinómicas y Exponenciales

Integrantes:
Eneque Acosta Cristhian Rufino
Lizana Vásquez Jimmy Anthony Daniel
Ciclo:
Segundo (II)

31 de mayo de 2019
EJERCICIO 1:
clc
clear
x=(-2.5:0.01:5);
y1=x.^3+3;
y2=exp(x);
plot(x,y1,'r','linewidth',1)
hold on
plot(x,y2,'b','linewidth',1)
xlabel('EJE X')
ylabel('EJE Y')
grid on
title('Ejercicio 1')
hold off
function y=feje1Abis(x)
y=x^3+3-exp(x);
end

>>clear
>> a=4,b=5,toler=10^(-7)
a=
4
b=
5
toler =
1.000000000000000e-07
>> [c] = bisec('feje1Abis',a,b,toler)
0 4.00000000000 5.00000000000 4.50000000000 4.10786869948
1 4.50000000000 5.00000000000 4.75000000000 -5.41240952719
2 4.50000000000 4.75000000000 4.62500000000 -0.07113245770
3 4.50000000000 4.62500000000 4.56250000000 2.15211603854
4 4.56250000000 4.62500000000 4.59375000000 1.07531113786
5 4.59375000000 4.62500000000 4.60937500000 0.51097205001
6 4.60937500000 4.62500000000 4.61718750000 0.22216303257
7 4.61718750000 4.62500000000 4.62109375000 0.07607893695
8 4.62109375000 4.62500000000 4.62304687500 0.00261450834
9 4.62304687500 4.62500000000 4.62402343750 -0.03422361287
10 4.62304687500 4.62402343750 4.62353515625 -0.01579571740
11 4.62304687500 4.62353515625 4.62329101563 -0.00658839651
12 4.62304687500 4.62329101563 4.62316894531 -0.00198639216
13 4.62304687500 4.62316894531 4.62310791016 0.00031419606
14 4.62310791016 4.62316894531 4.62313842773 -0.00083606356
15 4.62310791016 4.62313842773 4.62312316895 -0.00026092513
16 4.62310791016 4.62312316895 4.62311553955 0.00002663762
17 4.62311553955 4.62312316895 4.62311935425 -0.00011714321
18 4.62311553955 4.62311935425 4.62311744690 -0.00004525266
19 4.62311553955 4.62311744690 4.62311649323 -0.00000930749
20 4.62311553955 4.62311649323 4.62311601639 0.00000866508
21 4.62311601639 4.62311649323 4.62311625481 -0.00000032120
22 4.62311601639 4.62311625481 4.62311613560 0.00000417194
23 4.62311613560 4.62311625481 4.62311619520 0.00000192537

c=
4.623116195201874
EJERCICIO 2:
clc
clear
x=(-3:0.01:3);
y1=x.^4;
y2=x+3;
plot(x,y1,'g','linewidth',1)
hold on
plot(x,y2,'k','linewidth',1)
xlabel('EJE X')
ylabel('EJE Y')
grid on
title('Ejercicio 1')
hold off
function y=feje2Abis(x)
y=x^4-x-3;
end

>> clear
>> a=-2,b=-1,toler=10^(-6)
a=
-2
b=
-1
toler =
1.000000000000000e-06
>> [c] = bisec('feje2Abis',a,b,toler)
0 -2.00000000000 -1.00000000000 -1.50000000000 3.56250000000
1 -1.50000000000 -1.00000000000 -1.25000000000 0.69140625000
2 -1.25000000000 -1.00000000000 -1.12500000000 -0.27319335938
3 -1.25000000000 -1.12500000000 -1.18750000000 0.17604064941
4 -1.18750000000 -1.12500000000 -1.15625000000 -0.05641078949
5 -1.18750000000 -1.15625000000 -1.17187500000 0.05780321360
6 -1.17187500000 -1.15625000000 -1.16406250000 0.00019997731
7 -1.16406250000 -1.15625000000 -1.16015625000 -0.02822863287
8 -1.16406250000 -1.16015625000 -1.16210937500 -0.01404523825
9 -1.16406250000 -1.16210937500 -1.16308593750 -0.00693037108
10 -1.16406250000 -1.16308593750 -1.16357421875 -0.00336713366
11 -1.16406250000 -1.16357421875 -1.16381835938 -0.00158406257
12 -1.16406250000 -1.16381835938 -1.16394042969 -0.00069216376
13 -1.16406250000 -1.16394042969 -1.16400146484 -0.00024612351
14 -1.16406250000 -1.16400146484 -1.16403198242 -0.00002308067
15 -1.16406250000 -1.16403198242 -1.16404724121 0.00008844643
16 -1.16404724121 -1.16403198242 -1.16403961182 0.00003268240
17 -1.16403961182 -1.16403198242 -1.16403579712 0.00000480075
18 -1.16403579712 -1.16403198242 -1.16403388977 -0.00000913999
19 -1.16403579712 -1.16403388977 -1.16403484344 -0.00000216963

c=
-1.164034843444824
EJERCICIO 3:
clc
clear
x=(-4:0.01:4);
y1=1/2*x.^3;
y2=6*x-4;
plot(x,y1,'m','linewidth',1)
hold on
plot(x,y2,'y','linewidth',1)
xlabel('EJE X')
ylabel('EJE Y')
grid on
title('Ejercicio 3')
hold off
function y=feje3Abis(x)
y=(1/2)*x^3-6*x+4;
end

>> clear
>> a=0,b=1,toler=10^(-7)
a=
0
b=
1
toler =
1.000000000000000e-07
>> [c] = bisec('feje3Abis',a,b,toler)
0 0.00000000000 1.00000000000 0.50000000000 1.06250000000
1 0.50000000000 1.00000000000 0.75000000000 -0.28906250000
2 0.50000000000 0.75000000000 0.62500000000 0.37207031250
3 0.62500000000 0.75000000000 0.68750000000 0.03747558594
4 0.68750000000 0.75000000000 0.71875000000 -0.12684631348
5 0.68750000000 0.71875000000 0.70312500000 -0.04494285583
6 0.68750000000 0.70312500000 0.69531250000 -0.00379729271
7 0.68750000000 0.69531250000 0.69140625000 0.01682332158
8 0.69140625000 0.69531250000 0.69335937500 0.00650904700
9 0.69335937500 0.69531250000 0.69433593750 0.00135488389
10 0.69433593750 0.69531250000 0.69482421875 -0.00122145290
11 0.69433593750 0.69482421875 0.69458007813 0.00006665340
12 0.69458007813 0.69482421875 0.69470214844 -0.00057741528
13 0.69458007813 0.69470214844 0.69464111328 -0.00025538482
14 0.69458007813 0.69464111328 0.69461059570 -0.00009436668
15 0.69458007813 0.69461059570 0.69459533691 -0.00001385689
16 0.69458007813 0.69459533691 0.69458770752 0.00002639819
17 0.69458770752 0.69459533691 0.69459152222 0.00000627064
18 0.69459152222 0.69459533691 0.69459342957 -0.00000379313
19 0.69459152222 0.69459342957 0.69459247589 0.00000123875
20 0.69459247589 0.69459342957 0.69459295273 -0.00000127719
21 0.69459247589 0.69459295273 0.69459271431 -0.00000001922
22 0.69459247589 0.69459271431 0.69459259510 0.00000060977
23 0.69459259510 0.69459271431 0.69459265471 0.00000029528
c=
0.694592654705048
EJERCICIO 4:
clc
clear
x=(-4:0.01:2);
y1=exp(x./3);
y2=3./(1+x.^2);
plot(x,y1,'c','linewidth',1)
hold on
plot(x,y2,'r','linewidth',1)
xlabel('EJE X')
ylabel('EJE Y')
grid on
title('Ejercicio 4')
hold off
function y=feje4Abis(x)
y=exp(x/3)-3/(1+x^2);
end

>> clear
>> a=1,b=2,toler=10^(-6)
a=
1
b=
2
toler =
1.000000000000000e-06
>> [c] = bisec('feje4Abis',a,b,toler)
0 1.00000000000 2.00000000000 1.50000000000 0.72564434762
1 1.00000000000 1.50000000000 1.25000000000 0.34616508907
2 1.00000000000 1.25000000000 1.12500000000 0.13085348358
3 1.00000000000 1.12500000000 1.06250000000 0.01581835354
4 1.00000000000 1.06250000000 1.03125000000 -0.04363104032
5 1.03125000000 1.06250000000 1.04687500000 -0.01374359875
6 1.04687500000 1.06250000000 1.05468750000 0.00107795854
7 1.04687500000 1.05468750000 1.05078125000 -0.00632266068
8 1.05078125000 1.05468750000 1.05273437500 -0.00261981291
9 1.05273437500 1.05468750000 1.05371093750 -0.00077029287
10 1.05371093750 1.05468750000 1.05419921875 0.00015399139
11 1.05371093750 1.05419921875 1.05395507813 -0.00030811110
12 1.05395507813 1.05419921875 1.05407714844 -0.00007704994
13 1.05407714844 1.05419921875 1.05413818359 0.00003847320
14 1.05407714844 1.05413818359 1.05410766602 -0.00001928775
15 1.05410766602 1.05413818359 1.05412292480 0.00000959288
16 1.05410766602 1.05412292480 1.05411529541 -0.00000484740
17 1.05411529541 1.05412292480 1.05411911011 0.00000237275
18 1.05411529541 1.05411911011 1.05411720276 -0.00000123732
19 1.05411720276 1.05411911011 1.05411815643 0.00000056772
c=
1.054118156433105
EJERCICIO 5:
clc
clear
x=[-3:0.01:3]
y1=x.^3;
y2=x+1;
plot(x,y1,'m','linewidth',2)
hold on
plot(x,y2,'k','linewidth',2)
xlabel('EJE X')
ylabel('EJE Y')
grid on
title('Ejercicio 5')
hold off
function y=feje5Abis(x)
y=x^3-x-1;
end

>> clear
>> a=1,b=2,toler=10^(-7)
a=
1
b=
2
toler =
1.000000000000000e-07
>> [c] = bisec('feje5Abis',a,b,toler)
0 1.00000000000 2.00000000000 1.50000000000 0.87500000000
1 1.00000000000 1.50000000000 1.25000000000 -0.29687500000
2 1.25000000000 1.50000000000 1.37500000000 0.22460937500
3 1.25000000000 1.37500000000 1.31250000000 -0.05151367188
4 1.31250000000 1.37500000000 1.34375000000 0.08261108398
5 1.31250000000 1.34375000000 1.32812500000 0.01457595825
6 1.31250000000 1.32812500000 1.32031250000 -0.01871061325
7 1.32031250000 1.32812500000 1.32421875000 -0.00212794542
8 1.32421875000 1.32812500000 1.32617187500 0.00620882958
9 1.32421875000 1.32617187500 1.32519531250 0.00203665067
10 1.32421875000 1.32519531250 1.32470703125 -0.00004659488
11 1.32470703125 1.32519531250 1.32495117188 0.00099479097
12 1.32470703125 1.32495117188 1.32482910156 0.00047403882
13 1.32470703125 1.32482910156 1.32476806641 0.00021370716
14 1.32470703125 1.32476806641 1.32473754883 0.00008355244
15 1.32470703125 1.32473754883 1.32472229004 0.00001847785
16 1.32470703125 1.32472229004 1.32471466064 -0.00001405875
17 1.32471466064 1.32472229004 1.32471847534 0.00000220949
18 1.32471466064 1.32471847534 1.32471656799 -0.00000592464
19 1.32471656799 1.32471847534 1.32471752167 -0.00000185758
20 1.32471752167 1.32471847534 1.32471799850 0.00000017596
21 1.32471752167 1.32471799850 1.32471776009 -0.00000084081
22 1.32471776009 1.32471799850 1.32471787930 -0.00000033243
23 1.32471787930 1.32471799850 1.32471793890 -0.00000007823
c=
1.324717938899994
EJERCICIO 6:
clc
clear
x=[-3:0.01:3]
y1=x.^4;
y2=12*x+8;
plot(x,y1,'g','linewidth',1)
hold on
plot(x,y2,'b','linewidth',1)
xlabel('EJE X')
ylabel('EJE Y')
grid on
title('Ejercicio 6')
hold off
function y=feje6Abis(x)
y=x^4-12*x-8;
end

>> clear
>> a=2,b=3,toler=10^(-5)
a=
2
b=
3
toler =
9.999999999999999e-06
>> [c] = bisec('feje6Abis',a,b,toler)
0 2.00000000000 3.00000000000 2.50000000000 1.06250000000
1 2.00000000000 2.50000000000 2.25000000000 -9.37109375000
2 2.25000000000 2.50000000000 2.37500000000 -4.68334960938
3 2.37500000000 2.50000000000 2.43750000000 -1.94969177246
4 2.43750000000 2.50000000000 2.46875000000 -0.47930812836
5 2.46875000000 2.50000000000 2.48437500000 0.28255468607
6 2.46875000000 2.48437500000 2.47656250000 -0.10062282905
7 2.47656250000 2.48437500000 2.48046875000 0.09040262946
8 2.47656250000 2.48046875000 2.47851562500 -0.00525070283
9 2.47851562500 2.48046875000 2.47949218750 0.04254078485
10 2.47851562500 2.47949218750 2.47900390625 0.01863624986
11 2.47851562500 2.47900390625 2.47875976563 0.00669057616
12 2.47851562500 2.47875976563 2.47863769531 0.00071938738
13 2.47851562500 2.47863769531 2.47857666016 -0.00226579504
14 2.47857666016 2.47863769531 2.47860717773 -0.00077323816
15 2.47860717773 2.47863769531 2.47862243652 -0.00002693397
16 2.47862243652 2.47863769531 2.47863006592 0.00034622456
c=
2.478630065917969
EJERCICIO 7:
clc
clear
x=[-5:0.01:5]
y1=10*x.^2+3;
y2=x.^4;
plot(x,y1,'c','linewidth',1)
hold on
plot(x,y2,'k','linewidth',1)
xlabel('EJE X')
ylabel('EJE Y')
grid on
title('Ejercicio 7')
hold off
function y=feje7Abis(x)
y=10*x^2-x^4+3;
end

>> clear
>> a=3,b=4,toler=10^(-5)
a=
3
b=
4
toler =
9.999999999999999e-06
>> [c] = bisec('feje7Abis',a,b,toler)
0 3.00000000000 4.00000000000 3.50000000000-24.56250000000
1 3.00000000000 3.50000000000 3.25000000000 -2.94140625000
2 3.00000000000 3.25000000000 3.12500000000 5.28881835938
3 3.12500000000 3.25000000000 3.18750000000 1.37278747559
4 3.18750000000 3.25000000000 3.21875000000 -0.73336887360
5 3.18750000000 3.21875000000 3.20312500000 0.33229726553
6 3.20312500000 3.21875000000 3.21093750000 -0.19737047330
7 3.20312500000 3.21093750000 3.20703125000 0.06825243286
8 3.20703125000 3.21093750000 3.20898437500 -0.06436147426
9 3.20703125000 3.20898437500 3.20800781250 0.00199482993
10 3.20800781250 3.20898437500 3.20849609375 -0.03117098003
11 3.20800781250 3.20849609375 3.20825195313 -0.01458499007
12 3.20800781250 3.20825195313 3.20812988281 -0.00629430890
13 3.20800781250 3.20812988281 3.20806884766 -0.00214954670
14 3.20800781250 3.20806884766 3.20803833008 -0.00007731019
15 3.20800781250 3.20803833008 3.20802307129 0.00095877192
16 3.20802307129 3.20803833008 3.20803070068 0.00044073388
c=
3.208030700683594
EJERCICIO 8:
clc
clear
x=[3:0.01:5]
y1=3*(x-4).^2;
y2=log(x);
plot(x,y1,'r','linewidth',1)
hold on
plot(x,y2,'k','linewidth',1)
xlabel('EJE X')
ylabel('EJE Y')
grid on
title('Ejercicio 8')
hold off
function y=feje8Abis(x)
y=3*(x-4)^2-log(x);
end

>> clear
>> a=4,b=5,toler=10^(-7)
a=
4
b=
5
toler =
1.000000000000000e-07
>> [c] = bisec('feje8Abis',a,b,toler)
0 4.00000000000 5.00000000000 4.50000000000 -0.75407739678
1 4.50000000000 5.00000000000 4.75000000000 0.12935538195
2 4.50000000000 4.75000000000 4.62500000000 -0.35960137096
3 4.62500000000 4.75000000000 4.68750000000 -0.12693064130
4 4.68750000000 4.75000000000 4.71875000000 -0.00173924652
5 4.71875000000 4.75000000000 4.73437500000 0.06307019973
6 4.71875000000 4.73437500000 4.72656250000 0.03048100511
7 4.71875000000 4.72656250000 4.72265625000 0.01432476086
8 4.71875000000 4.72265625000 4.72070312500 0.00628122749
9 4.71875000000 4.72070312500 4.71972656250 0.00226810806
10 4.71875000000 4.71972656250 4.71923828125 0.00026371016
11 4.71875000000 4.71923828125 4.71899414063 -0.00073794833
12 4.71899414063 4.71923828125 4.71911621094 -0.00023716412
13 4.71911621094 4.71923828125 4.71917724609 0.00001326176
14 4.71911621094 4.71917724609 4.71914672852 -0.00011195399
15 4.71914672852 4.71917724609 4.71916198730 -0.00004934682
16 4.71916198730 4.71917724609 4.71916961670 -0.00001804270
17 4.71916961670 4.71917724609 4.71917343140 -0.00000239052
18 4.71917343140 4.71917724609 4.71917533875 0.00000543561
19 4.71917343140 4.71917533875 4.71917438507 0.00000152255
20 4.71917343140 4.71917438507 4.71917390823 -0.00000043399
21 4.71917390823 4.71917438507 4.71917414665 0.00000054428
22 4.71917390823 4.71917414665 4.71917402744 0.00000005515
23 4.71917390823 4.71917402744 4.71917396784 -0.00000018942
c=
4.719173967838287
EJERCICIO 9:
clc
clear
x=[0:0.01:2]
y1=8*log(x+1);
y2=5-3*x;
plot(x,y1,'b','linewidth',1)
hold on
plot(x,y2,'y','linewidth',1)
xlabel('EJE X')
ylabel('EJE Y')
grid on
title('Ejercicio 9')
hold off
function y=feje9Abis(x)
y=8*log(x+1)+3*x-5
end

>> clear
>> a=0,b=1,toler=10^(-5)
a=
0
b=
1
toler =
9.999999999999999e-06
>> [c] = bisec('feje9Abis',a,b,toler)
0 0.00000000000 1.00000000000 0.50000000000 -0.25627913513
1 0.50000000000 1.00000000000 0.75000000000 1.72692630348
2 0.50000000000 0.75000000000 0.62500000000 0.75906252625
3 0.50000000000 0.62500000000 0.56250000000 0.25779682103
4 0.50000000000 0.56250000000 0.53125000000 0.00242516249
5 0.50000000000 0.53125000000 0.51562500000 -0.12650183885
6 0.51562500000 0.53125000000 0.52343750000 -0.06193314285
7 0.52343750000 0.53125000000 0.52734375000 -0.02972782595
8 0.52734375000 0.53125000000 0.52929687500 -0.01364480739
9 0.52929687500 0.53125000000 0.53027343750 -0.00560819345
10 0.53027343750 0.53125000000 0.53076171875 -0.00159110849
11 0.53076171875 0.53125000000 0.53100585938 0.00041712871
12 0.53076171875 0.53100585938 0.53088378906 -0.00058696445
13 0.53088378906 0.53100585938 0.53094482422 -0.00008491151
14 0.53094482422 0.53100585938 0.53097534180 0.00016611019
15 0.53094482422 0.53097534180 0.53096008301 0.00004059974
16 0.53094482422 0.53096008301 0.53095245361 -0.00002215579
c=
0.530952453613281
EJERCICIO 10:
clc
clear
x=[0.5:0.01:0.9]
y1=exp(x);
y2=1./x.^2;
plot(x,y1,'c','linewidth',1)
hold on
plot(x,y2,'m','linewidth',1)
xlabel('EJE X')
ylabel('EJE Y')
grid on
title('Ejercicio 10')
hold off
function y=feje10Abis(x)
y=exp(x)-1/x^2;
end

>> clear
>> a=0,b=1,toler=10^(-7)
a=
0
b=
1
toler =
1.000000000000000e-07
>> [c] = bisec('feje10Abis',a,b,toler)
0 0.00000000000 1.00000000000 0.50000000000 -2.35127872930
1 0.50000000000 1.00000000000 0.75000000000 0.33922223883
2 0.50000000000 0.75000000000 0.62500000000 -0.69175404257
3 0.62500000000 0.75000000000 0.68750000000 -0.12696500976
4 0.68750000000 0.75000000000 0.71875000000 0.11613898521
5 0.68750000000 0.71875000000 0.70312500000 -0.00266052167
6 0.70312500000 0.71875000000 0.71093750000 0.05739400810
7 0.70312500000 0.71093750000 0.70703125000 0.02753446412
8 0.70312500000 0.70703125000 0.70507812500 0.01247941681
9 0.70312500000 0.70507812500 0.70410156250 0.00492012415
10 0.70312500000 0.70410156250 0.70361328125 0.00113247858
11 0.70312500000 0.70361328125 0.70336914063 -0.00076335118
12 0.70336914063 0.70361328125 0.70349121094 0.00018473116
13 0.70336914063 0.70349121094 0.70343017578 -0.00028926813
14 0.70343017578 0.70349121094 0.70346069336 -0.00005225801
15 0.70346069336 0.70349121094 0.70347595215 0.00006623919
16 0.70346069336 0.70347595215 0.70346832275 0.00000699124
17 0.70346069336 0.70346832275 0.70346450806 -0.00002263322
18 0.70346450806 0.70346832275 0.70346641541 -0.00000782095
19 0.70346641541 0.70346832275 0.70346736908 -0.00000041484
20 0.70346736908 0.70346832275 0.70346784592 0.00000328820
21 0.70346736908 0.70346784592 0.70346760750 0.00000143668
22 0.70346736908 0.70346760750 0.70346748829 0.00000051092
23 0.70346736908 0.70346748829 0.70346742868 0.00000004804
c=
0.703467428684235

You might also like