Você está na página 1de 22

UNIVERSIDAD NACIONAL MAYOR DE SAN MARCOS

METODOS NUMERICOS
ALUMNO: QUIQUE VASQUEZ, JESUS RICARDO
MAR X LIMA-PERU
2021

FACULTAD D E INGENIERIA ELECTRONICA Y


ELECTRICA
RESOLUCION DE PROBLEMAS:

%Programa que dice si exise el area del triangulo


%lados del triangulo
%sin_script
b=input('lado 1 base = ');
a=input('lado 2 = ');
c=input('lado 3 = ');
if a-c < b & b <(a+c);
disp('El area existe')

else
disp('El area no existe')
end
clc
a=input("Ingrese el valor del primer lado del triangulo :")
b=input("Ingrese el valor del segundo lado del triangulo :")
c=input("Ingrese el valor del tercer lado del triangulo :")
if(a>0 && b>0 && c>0)
disp ("Existe el area de un triangulo");
else
disp ("No existe area de un triangulo");
endif
clc
function [d,i]=mcuadrada(C)
C=[1 2 3;4 5 6;7 8 9]
d = det(C)
if(d!=0)
i= inv(C);
endif
endfunction
%Programa que genera una tabla de funcionesdisp('
===================================================
======')disp(' f g h p ')disp('

===================================================
======')for n=2:0.5:6 f = log10(10*n);g = f*sin(10*n);h = f+
g;p = f-g;disp(fprintf(' %d',f ,g,h,p))endfordisp('
===================================================
======')
% Script File: poldata
%
close all

n=input('Ingrese el número de vertices:');


i=1;
x=zeros(1,n);
y=zeros(1,n);

while i<n+1
axis([-10 10 -10 10])
grid on
[X,Y]=ginput(1);
x(1,i)=X(1,1);
y(1,i)=Y(1,1);
plot(x(1:i),y(1:i),x(1:i),y(1:i),'0')
axis([-10 10 -10 10])
grid on

i=i+1;
end

plot([x x(1)],[y y(1)],x,y,'0')


axis([-10 10 -10 10])
grid on
clc
clear
X= -3:0.001:3;
Y= X.^3-4*X;
plot(X,Y,'r','linewidth',2)
function V=problema7(r,h)
disp('Volumen del cono')
r=input('radio=');
h=input('altura=');
V=(1/3)*pi*r^2*h;
disp('la respuesta es:')
disp(V)
end
n = 200;
R = 1;
tita = [0:(2*pi/n):2*pi];
x = R*cos(tita);
y = R*sin(tita);
figure(1)
plot(x,y,'-b')
axis equal
axis([-1.5 1.5 -1.5 1.5])
set(gca,'XTick',[-1.5:0.5:1.5])
set(gca,'XTickLabel',{'-1.5','-1.0','-0.5','0.0','0.5','1.0','1.5'})
set(gca,'YTick',[-1.5:0.5:1.5])
set(gca,'YTickLabel',{'-1.5','-1.0','-0.5','0.0','0.5','1.0','1.5'})
set(gca,'Fontsize',10)
n = input("Ingrese la cantidad de datos:")
numeros = zeros(1,n);
for i = 1:n
numeros(i) = input(">>");

endfor
for i= 1:n
raiz = numeros(i)^(1/3);
printf("%d %5.2f \n",numeros(i),raiz);
endfor
La 10
%calcular el area de un triangulo ingresando por consola la altura y
base
disp('ingrese la altura');
h=input('');
disp('ingrese la base');
b=input('');
disp('el area del triangulo es: ');
area=(b*h)/2
disp(' desea calcular otra area? ');
area1=input('');

while (area1==1)

disp('ingrese la altura');
h=input('');
disp('ingrese la base');
b=input('');
disp('el area del triangulo es: ');
area=(b*h)/2
disp(' desea calcular otra area? ');
area1=input('');
if(area1==0)
break
endif

endwhile
clear all
clc
disp('PROGRAMA QUE CALCULA EL PRECIO A PAGAR POR
VENTA DE MEMORIAS')

%INGRESO DE DATOS
n=input('Ingrese el numero de memorias a comprar ')

%CALCULOS
if n<7
pu=100;
elseif n<=8
pu=90;
else
pu=80;
endif
pago=pu*n;
fprintf('El pago unitario es : %.2f',pu)
fprintf('El pago total es: %.2f',pago)
clear all
clc
disp('PROGRAMA QUE CALCULA EL PRECIO DE UNA TORTA')

pe=0;
%INGRESO DE DATOS
while(pe<1 || pe>3)
disp('solo existe 3 pesos de torta: 1,2 y 3 kg.')
pe=input('Ingrese el peso de la torta en kg. ')
endwhile
disp('Ingreso del peso correcto')

opc1=input('¿Desea agregar pasas? si=1 no=0: ')


opc2=input('¿Desea agregar nueces? si=1 no=0: ')
opc3=input('¿Desea agregar frutas? si=1 no=0: ')
%CALCULOS
if pe==1
pago=50;
elseif pe==2
pago=50;
elseif pe==3
pago=50;
endif

pago1=pago+5*(opc1+opc2+opc3);
%RESULTADOS
fprintf('El precio total a pagar es: %.2f', pago1)
clear all
clc
disp('PROGRAMA QUE CALCULA LOS PROMEDIOS
ARITMETICA, GEOMETRICA, ARMONICA')
%INGRESO DE DATOS
a1=input('Ingrese el 1er numero: ')
b1=input('Ingrese el 2do numero: ')

%RESULTADOS
if a1*b1<0
disp('Debio escoger ambos numeros con signos iguales')
else

fprintf('El promedio aritmetico es %f\n',prob15_ma(a1,b1))


fprintf('El promedio geometrico es %f\n',prob15_mg(a1,b1))
fprintf('El promedio armonico es %f\n',prob15_mh(a1,b1))
endif
clear all
clc
disp('PROGRAMA CALCULA SEN(X) POR SERIE DE MACLAURIN')
%INGRESO DE DATOS
x1=input('Ingrese el valor de x: ')

%RESULTADOS
fprintf('El valor aproximado por las series de maclaurin es: %.4f
\n',prob16(x1))
fprintf('El exacto de sen(x) es %.4f \n',sin(x1))

function fx= prob16(x)


fx=0;
for i=1:100
fx=fx+(-1)^(i+1)*x^(2*i-1)/factorial(2*i-1);
error=x^(2*i-1)/factorial(2*i-1);
if error<0.001
break;
endif
endfor
endfunction

Você também pode gostar