0% found this document useful (0 votes)
47 views16 pages

Practica 1

The document contains code to plot two functions. It defines vectors x and y to plot a square root plus quadratic function, and vectors x1 and g to plot a sine function. It uses subplot to display the two plots, with the first plotting the square root plus quadratic function and titled "Function 1", and the second plotting the sine function

Uploaded by

Rodrigo Sena
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)
47 views16 pages

Practica 1

The document contains code to plot two functions. It defines vectors x and y to plot a square root plus quadratic function, and vectors x1 and g to plot a sine function. It uses subplot to display the two plots, with the first plotting the square root plus quadratic function and titled "Function 1", and the second plotting the sine function

Uploaded by

Rodrigo Sena
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/ 16

E=-(2-(1/3)*(3+(1/5)*(1+(1/2)))+2+(1/6))*3^4+(27^(1/3))

E=

-245.4000

format bank

>> E

E=

-245.40

E=2-(1-1/2)/(1+(1/(3+(1/1/4))))

E=

1.6176

format rat

>> E

E=

55/34

E= sqrt(12) + (5*sin(153*pi/180))

E=

5.7341
a) Ejemplo del vector fila de A
A = [-2 2 5]
A=
-2 2 5

b) Matriz A
A = [-2 2 5; 1 7 -1]
A=
-2 2 5
1 7 -1

Coordenada a23
A(2,3)
ans =
-1

c) A(2,3) = 4
A=
-2 2 5
1 7 4

d) A(2,:)
ans =
1 7 4

e) A(:,3)
ans =
5
4

f) A(:,2)=[]
A=
-2 5
1 4
g) sum(A)
ans =
-1 9

A) A = ones([2,2])
A=
1 1
1 1

B) A = zeros([3,2])
A=
0 0
0 0
1 0

C) A = [1 1 1 1]

A=

1 1 1 1

>> A = diag(A)
A=
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
B = [-2 4;1 9;-6 7]

B=

-2 4

1 9

-6 7

>> C = [2 3; -4 5]

C=

2 3

-4 5

>> D = [2 -4 -5; 4 5 6]

D=

2 -4 -5

4 5 6
>> E = [7 -1 2; 3 -4 2; 6 0 9]

E=

7 -1 2

3 -4 2

6 0 9

>> F = [4 2;-3 3]

F=

4 2

-3 3

>> G = [1 -2;3 4]

G=

1 -2

3 4

a) C + F
ans =
6 5
-7 8

b) 2F - 4C
2*F - 4*C
ans =
0 -8
10 -14

c) B *D
B.*D
Matrix dimensions must agree.

d) 𝐹𝑡 ∗ 𝐶𝑡
F'.*C'
ans =
8 12
6 15

e) 𝐹−1
F.^-1
ans =
0.2500 0.5000
-0.3333 0.3333
f) 𝑡𝑟(2𝐶 + 𝐹)
(2.*C + F)'
ans =
8 -11
8 13

g) 𝑣𝑎𝑙𝑜𝑟𝑒𝑠 𝑝𝑟𝑜𝑝𝑖𝑜𝑠 𝑑𝑒 𝐹
eig(F)
ans =
3.5000 + 2.3979i
3.5000 - 2.3979i

h) |𝐸|
abs(E)
ans =
7 1 2
3 4 2
6 0 9

i) 𝐶∗𝐹 (𝑚𝑢𝑙𝑡𝑖𝑝𝑙𝑖𝑐𝑎𝑐𝑖𝑜𝑛 𝑐𝑜𝑜𝑟𝑑𝑒𝑛𝑎𝑑𝑎 𝑝𝑜𝑟 𝑐𝑜𝑟𝑑𝑒𝑛𝑎𝑑𝑎)


C .* F
ans =
8 6
12 15

j) 𝐹^𝐶 (𝑜𝑝𝑒𝑟𝑎𝑐𝑖ó𝑛 𝑐𝑜𝑜𝑟𝑑𝑒𝑛𝑎𝑑𝑎 𝑎 𝑐𝑜𝑟𝑑𝑒𝑛𝑎𝑑𝑎)


F .^ C
ans =
16.0000 8.0000
0.0123 243.0000

k) Triangular superior de 𝐸
triu(E)
ans =
7 -1 2
0 -4 2
0 0 9

l) Dimensión de B
size(B)
ans =
3 2

m) Máxima dimensión de B
max(B(:))
ans =
9
n) Rango de E
range(E)
ans =
4 4 7

o) Descomposición LU de la matriz G
[L,U] = lu(G)
L=
0.3333 1.0000
1.0000 0

U=
3.0000 4.0000
0 -3.3333

p) Descomposición QR de la matriz G
[Q,R] = qr(G)
Q=
-0.3162 -0.9487
-0.9487 0.3162

R=
-3.1623 -3.1623
0 3.1623

a) v = [3 6 7 8 9 4]
v=
3 6 7 8 9 4

b) v(4)
ans =
8

c) v(3:6)
ans =
7 8 9 4

d) v(5)=[]
v=
3 6 7 8 4
x = [-2,1]

x=

-2 1

y = exp(3*x) – 3

y=

-2.9975 17.0855

title ('grafica de la funcion fx')

xlabel ('coordenada x')

ylabel ('coordenada y')

grid on

plot(x,y, 'r')

syms x

syms y

ezplot(9*x^2 - y^2 == 9,[-3,3])

ezplot(9*x^2 - y^2 == 9,[-3,3],[-4,4])


g = 'abs(x-1)';

x = ([-4,3]);

y = eval(g);

plot(x,y)

hold on

f = '(x +3)/2';

z = [-3 4];

s = eval(f)

plot(z,s)

hold on

fx1 = '(((x.^3) + 1).^3)';

x = [-3,-1];

y = eval(fx1);

plot(x,y)

fx2 = '((15.*x)-1)';

z = [-1,1];

s = eval(fx2);

plot(z,s)

fx3 = '(cos(0))';

t = [1,3];
u = eval(fx3);

plot(t,u)

title ('Grafica funcion por trozos f(x)')

text (0,0,'origen')

hold off

f = '(5.*(x.^3)+2)';
x = ([-3 3]);
y = eval(f);
plot(x,y)

a)
t = linspace(-pi/2,pi,100)
plot(sin(t),4*cos(t))

b) t = linspace(-pi,pi,100)
plot3(sin(t),cos(t),t)
[X,Y] = meshgrid([-4,4],[-4,4]);
Z = (X.^2 - Y.^2);
surf(X,Y,Z)
grid on

x = [-2,3];
y = [-1.5,1.5]
[X,Y] = meshgrid(x,y);
r = (x-4*y-3*z==2);
mesh (r)

x = [0,4];
y1 = ((1/4)*log(x+1));
plot(x,y1)
hold on
y2 = ((1/4)*log(x+1));
plot(x,y2)
hold off

> syms x

>> factor((x^4)-12*x)

ans =

[ x, x^3 - 12]
expand(((3/(4-x))+(1/x))/(x+2))

ans =

1/(x^2 + 2*x) + 3/(- x^2 + 2*x + 8)

x = 3;

>> f = x^3 + abs(x+2) + exp(2*x)

f=

435.4288

syms x

>> h = (1/36)*(((3.*x.^5)/5)+(18.*x.^2)+((4.*exp(3+x))/3)+27.*cos(x)-(1/3)*cos(3.*x))

h=

exp(x + 3)/27 - cos(3*x)/108 + (3*cos(x))/4 + x^2/2 + x^5/60

diff(h,3)

ans =

exp(x + 3)/27 - sin(3*x)/4 + (3*sin(x))/4 + x^2

f = ((x.^4+4.*x+8)/(3.*x-2))

f=

(x^4 + 4*x + 8)/(3*x - 2)


>> f2 = diff(f,2)

f2 =

(18*(x^4 + 4*x + 8))/(3*x - 2)^3 - (6*(4*x^3 + 4))/(3*x - 2)^2 + (12*x^2)/(3*x - 2)

syms x

>> format long

limit((1+x).^(1/x),0)

ans =

exp(1)

x = 3;

>> y = 2;

>> f = 4.*log(x) + 3.*y.^3 + x.*y + 3.*x

f=

43.3944

syms x

>> I = @(x) cos(x).^2;

>> integral(I,0,inf)

ans =

5.6719e+26
syms x

f = x.^4 - 4.*x.^2 - 3 == 0;

solve(f)

ans =

(7^(1/2) + 2)^(1/2)

-(7^(1/2) + 2)^(1/2)

(2 - 7^(1/2))^(1/2)

-(2 - 7^(1/2))^(1/2)

A = [3 -4; 4 2];

>> B = [2;7];

>> a = A';

>> solucion = a*B

solucion =

34

f = (sqrt(2.*x +4) + (5.*x.^3) + (3.^x));

>> diff(f,2)

ans =

30*x + 3^x*log(3)^2 - 2^(1/2)/(4*(x + 2)^(3/2))


Syms x

syms y

>> f = ((x.*y) - ((5.*x.^3).*y) + ((3.*y.^3).*x));

diff(f,x,y)

x,y =

- 15*x^2 + 9*y^2 + 1

parciales

>> diff(f)

X’ =

- 15*x^2*y + 3*y^3 + y

diff(f,y)

y’ =

- 5*x^3 + 9*x*y^2 + x

>> f = ((3.*y.^3) + ((x.^4).*(y.^2)) + 8);

>> diff(f,x)

x=

4*x^3*y^2

>> diff(f,y)

y=

2*x^4*y + 9*y^2
I =(4/(1+x^2));

int(I,0,1)

ans =

pi

a) n = input('ingrese un numero');
producto = 1;
for i = 2:4:n
i;
producto = Producto*i;
end
producto
fprintf('el producto final es: %i/n',producto)

b) x=-1:0.1:2;
y=sqrt(x)+5*x.^2;
x1=0:pi/100:2*pi;
g=sin(3*x1);
subplot(1,2,1)
plot(x,y)
title 'funcion 1'
subplot(1,2,2)
plot(x1,g)
title 'funcion 2'

You might also like