0% found this document useful (0 votes)
53 views18 pages

Mobile Basic

This document contains code snippets and summaries of several numerical methods algorithms and calculations in Visual Basic, including: 1. Successive approximations method for finding roots of nonlinear equations. 2. For loop examples from 1 to 100 and with an if statement. 3. Calculation of x using a recursive formula in a for loop. 4. Code to determine the greater of two input numbers.
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)
53 views18 pages

Mobile Basic

This document contains code snippets and summaries of several numerical methods algorithms and calculations in Visual Basic, including: 1. Successive approximations method for finding roots of nonlinear equations. 2. For loop examples from 1 to 100 and with an if statement. 3. Calculation of x using a recursive formula in a for loop. 4. Code to determine the greater of two input numbers.
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/ 18

APROXIMACIONES SUCESIVAS

Sub main

Dim a,b,c,r,gx,z,xi as double

Dim i as integer

input "Valor de a",a

input "Valor de b",b

input "Valor de c",c

r=b/(2.0*a)

print -r,r

xi=0

for i=0 to 30

gx=-a*xi**2.0/b-(c/b)

print gx

z=xi

if z=gx then

print i

sleep 50000

else

xi=gx

end if

end for

end sub
CICLO FOR
Sub main

Dim i as integer

for i= 1 to 100

print i

end for

end sub
CALCULO DE X

Sub main

dim Xc,Xi,Xa as double

dim i as integer

Xi=1

for i=0 to 30

Xc=(1.0/5.0)*(2*Xi)+(8.0/Xi)

print Xc

Xa=Xi

if Xa=Xc then

print i

sleep 50000

else

Xi=Xc

end if

end for

end sub
EL MAYOR ES
sub main

dim a,b as double

input "Primer numero",a

input "Segundo numero",b

if a<b then

print "El Mayor es" ,b

else

print "El Mayor es",a

end if

end sub
FALSA POSICIÓN
sub main

dim i as integer

dim a,b,c,d,e,xc as double

dim fxn,fxp,xn,xp as double

dim xa,fxc as double

input "Valor de a",a

input "Valor de b",b

input "Valor de c",c

input "Valor de d",d

input "Valor de e",e

input "Valor de xn",xn

input "Valor de xp",xp

for i=0 to 100

fxn=a*xn*4+b*xn3+c*xn*2+d*xn+e

fxp=a*xp*4+b*xp3+c*xp*2+d*xp+e

xc=(xp*fxn-xn*fxp)/(fxn-fxp)

fxc=a*xc*4+b*xc3+c*xc*2+d*xc+e

print xc

if xa=xc then

print "La solucion es:"

print i

sleep 50000

else
if fxc>0.0 then

xp=xc

fxp=fxc

else

xn=xc

fxn=fxc

end if

end if

xa=xc

end for

end sub
FOR E IF
Sub main

Dim i as integer

for i= 1 to 50

print i

if i=10 then

sleep 10000

end if

end for

end sub
FORMULA GENERAL
sub main

dim a,b,c,x1,x2,r as double

input "valor de a",a

input "valor de b",b

input "valor de c",c

r=b**2-4.0*a*c

if r<0.0 then

print "Raices imaginarias"

else

print "Raices reales"

x1=(-b+sqrt(r))/(2.0*a)

x2=(-b-sqrt(r))/(2.0*a)

print "x1=",x1

print "x2=",x2

end if

end sub
NEWTON RAPHSON
sub main

dim a,b,c,d,e,x0 as double

dim fx,fx1,fx2 as double

dim xc,xa as double

dim i as integer

dim gx as double

input "Valor de a",a

input "Valor de b",b

input "Valor de c",c

input "Valor de d",d

input "Valor de e",e

input "Valor de x0",x0

fx=a*x0*4+b*x03+c*x0*2+d*x0+e

fx1=4.0*a*x0*3+3.0*b*x0*2+2.0*c*x0+d

fx2=12.0*a*x0**2+6.0*b*x0+2.0*c

print fx

print fx1

print fx2

gx=fx*fx2/(fx1**2)

if abs (gx)<1.0 then

print "Se cumple la condicion"


for i=0 to 100

xc=x0-fx/fx1

print xc

fx=a*xc*4+b*xc3+c*xc*2+d*xc+e

fx1=4.0*a*xc*3+3.0*b*xc*2+2.0*c*xc+d

if xa=xc then

print "la solucion es"

print i

sleep 50000

else

x0=xc

end if

xa=xc

end for

else

print "No se cumple la condicion"

end if

for i=0 to 100

xc=x0-fx/fx1

print xc

fx=a*xc*4+b*xc3+c*xc*2+d*xc+e

fx1=4.0*a*xc*3+3.0*b*xc*2+2.0*c*xc+d

if xa=xc then

print "la solucion es"

print i
sleep 500000

else

x0=xc

end if

xa=xc

end for

end sub
RAÍZ DE 2
Sub main

dim Xc,Xi,Xa as double

dim i as integer

Xi=1

for i=0 to 30

Xc=(1.0/2.0)*(Xi+2.0/Xi)

print Xc

Xa=Xi

if Xa=Xc then

print i

sleep 50000

else

Xi=Xc

end if

end for

end sub
MÉTODO DE LA SECANTE
Sub main

dim a,b,c,d,e,f as double

dim x1,x2,xc,xa as double

dim fx1,fx2,fxc as double

dim i as integer

input "Valor de a",a

input "Valor de b",b

input "Valor de c",c

input "Valor de d",d

input "Valor de e",e

input "Valor de f",f

input "Valor de x1",x1

input "Valor de x2",x2

for i=1 to 100

fx1=a*x1*5+b*x14+c*x13+d*x1*2+e*x1+f

fx2=a*x2*5+b*x24+c*x23+d*x2*2+e*x2+f

xc=x2-(x2-x1)*fx2/(fx2-fx1)

print xc

fxc=a*xc*5+b*xc4+c*xc3+d*xc*2+e*xc+f

if xa=xc then

print "La solucion es"

print i

sleep 50000

else

x1=x2
x2=xc

end if

xa=xc

end for

end sub
VOLUMENES

sub MAIN

dim l,b,h,r,v,A as double

DIM I AS INTEGER

print "1. Cubo "

print "2. Prisma cuadrangular"

print "3. Esfera"

print "4. Cono"

print "5. Cilindro"

print "6. Prismas"

print "7. Piramides"

input "Opcion ",i

while i<11

IF (I = 1) THEN

input "Media del lado",l

v=l*l*l

PRINT "Volumen",v

ELSEIF (I = 2) THEN

input "Medida del lado",l

input "Medida de la base",b

input "Medida de la altura",h

v=l*b*h

PRINT "Volumen",v
ELSEIF (I = 3) THEN

input "Medida del radio",r

v=4.0*r*r*r*3.1416/3.0

PRINT "Volumen",v

ELSEIF (I = 4) THEN

input "Medida del radio",r

input "Medida de la altura",h

v=3.1416*h*r*r/3.0

PRINT "Volumen",v

ELSEIF (I = 5) THEN

input "Medida del radio",r

input "Medida de la altura",h

v=3.1416*r*r*h

PRINT "Volumen",v

ELSEIF (I = 6) THEN

input "Medida de la altura",h

input "Area de la base",A

v=A*h

PRINT "Volumen",v

ELSEIF (I = 7) THEN

input "Medida de la altura",h

input "Area de la base",A

v=A*h/3.0

PRINT "Volumen",v
ELSEIF (I = 8) THEN

PRINT "EIGHT"

ELSEIF (I = 9) THEN

PRINT "NINE"

ELSE

PRINT "TEN"

END IF

sleep 7000

input "otra opcion ",i

end while

End sub
ÁREA DEL TRIANGULO
sub main

dim h,A,b as double

input "Valor de la Base",b

input "Valor de la Altura",h

A=b*h/2.0

print "El Area es:" ,A

end sub

You might also like