ClubEnsayos.com - Ensayos de Calidad, Tareas y Monografias
Buscar

Programacion


Enviado por   •  9 de Marzo de 2020  •  Ensayos  •  566 Palabras (3 Páginas)  •  206 Visitas

Página 1 de 3

Function g(x, a, b, c)

g = a * x ^ 4 + b * x ^ 2 + c

End Function

Function d(x, a, b, c)

d = (g(x + 0.0001, a, b, c) - g(x, a, b, c)) / 0.0001

End Function

'formula general programa

Sub FG_secan()

Worksheets("Hoja1").Range("a1:xfd1048546").Delete

MsgBox ("Este programa resuelve ecuaciones de segundo grado por la formula general y por el metodo de la secante ")

aqui:

a = InputBox("dame el coeficiente bicuadratico")

a = Val(a)

If a = 0 Then

MsgBox ("a no pude ser cero")

GoTo aqui

End If

b = InputBox("dame el coeficiente cuadratico")

b = Val(b)

c = InputBox("dame el termino independiente")

c = Val(c)

'vamos a tabular y luego grafiacar

Cells(1, 1) = "x"

Cells(1, 2) = "y"

aqui1:

a1 = InputBox("limite inferior")

a1 = Val(a1)

b1 = InputBox("limite superior")

b1 = Val(b1)

h = InputBox("de cuanto en cuanto")

h = Val(h)

n = (b1 - a1) / h + 1

i = 1

While i <= n

Cells(i + 1, 1) = a1

Cells(i + 1, 2) = g(a1, a, b, c)

a1 = a1 + h 'para que en la nueva iteracion actualice a

i = i + 1 'evolucion del contador

Wend

r = MsgBox("¿deseas tabular otra vez?", vbYesNo)

If r = vbYes Then

GoTo aqui1

End If

datos = Range(Cells(2, 1), Cells(n + 1, 2)).Address  'rango a graficar

    Set graf = Charts.Add    'gráfico y sus caraterísticas

    With graf

        .Name = "Gráfico"

        .ChartType = xlXYScatterSmoothNoMarkers

        .SetSourceData Source:=Sheets("Hoja1").Range(datos), PlotBy:=xlColumns

        .Location Where:=xlLocationAsObject, Name:="Hoja1"

      End With

dis = b ^ 2 - 4 * a * c

If dis < 0 Then

MsgBox ("las raices son imaginarias ")

ElseIf dis >= 0 Then

x1 = (-b + Sqr(b ^ 2 - 4 * a * c)) / (2 * a)

x2 = (-b - Sqr(b ^ 2 - 4 * a * c)) / (2 * a)

dis = x1

If dis < 0 Then

MsgBox ("las raices son imaginarias ")

ElseIf dis >= 0 Then

x3 = Sqr(x1)

dis = x1

If dis < 0 Then

MsgBox ("las raices son imaginarias ")

ElseIf dis >= 0 Then

x31 = -Sqr(x1)

dis = x2

If dis < 0 Then

MsgBox ("las raices son imaginarias ")

ElseIf dis >= 0 Then

x4 = Sqr(x2)

dis = x2

If dis < 0 Then

MsgBox ("las raices son imaginarias ")

ElseIf dis >= 0 Then

x41 = -Sqr(x2)

MsgBox ("las raices son " & x3 & ", " & x31 & "," & x41 & ", " & x4 & "ahora empieza secante")

...

Descargar como (para miembros actualizados)  txt (3.2 Kb)   pdf (30.8 Kb)   docx (8.1 Kb)  
Leer 2 páginas más »
Disponible sólo en Clubensayos.com