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

Form1: "Cambie Los Valores de A y B"

The document contains code for 4 questions that use numerical methods like bisection, Newton-Raphson, and secant to find the zeros of functions. Question 1 uses bisection method in a loop to find the zero of the function f(y) between input values a and b to within an error tolerance eps. Question 2 uses Newton-Raphson method in a loop to iteratively find the zero of functions V(h) and Vd(h) to within an error tolerance eps. Question 3 uses secant method in a loop to iteratively find the zero of functions Y(x) and dY(x) between input values a and b to within an error tolerance eps

Uploaded by

cristian
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)
24 views

Form1: "Cambie Los Valores de A y B"

The document contains code for 4 questions that use numerical methods like bisection, Newton-Raphson, and secant to find the zeros of functions. Question 1 uses bisection method in a loop to find the zero of the function f(y) between input values a and b to within an error tolerance eps. Question 2 uses Newton-Raphson method in a loop to iteratively find the zero of functions V(h) and Vd(h) to within an error tolerance eps. Question 3 uses secant method in a loop to iteratively find the zero of functions Y(x) and dY(x) between input values a and b to within an error tolerance eps

Uploaded by

cristian
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/ 3

PREGUNTA 1

Public Class Form1


Function f(ByVal y As Single) As Single
Return 1 - ((20 ^ 2 * (3 + y)) / (9.81 * (3 * y - (y ^ 2) / 2) ^ 3))
End Function
Private Sub btnCalcular_Click()
Dim a, b, c, eps As Single
a = Val(txtA.Text)
b = Val(txtB.Text)
eps = 10 ^ -3
If f(a) * f(b) < 0 Then
Do
c = (a + b) / 2
If f(c) < eps Then
txtY.Text = Str(c)
Exit Sub
Else
If f(a) * f(c) > 0 Then
a=c
Else
b=c
End If
End If
Loop
Else
MsgBox("Cambie los valores de a y b")
Exit Sub
End If
End Sub

PREGUNTA 2

Public Class Form1


Function V(ByVal h As Single) As Single

Return Math.PI * h ^ 2 * (9 - h) / 3 - 30
End Function
Function Vd(ByVal h As Single) As Single
Return Math.PI * h * (6 - h)
End Function
Private Sub btnNewtonRaphson_Click()
Dim h0, h, eps As Single
eps = 10 ^ -3
h0 = Val(txtH0.Text)
Do
h = h0 - V(h0) / Vd(h0) cambiar newto de Segundo qrden
If Math.Abs(h - h0) < eps Then
txtH.Text = Str(h)
Exit Sub
Else
h0 = h
End If
Loop
End Sub
PREGUNTA 3

Public Class Form1


Function Y(ByVal x As Single) As Single
Return (1.75 / 120 * 50000 * 30000 * 450) * (-x ^ 5 + 2 * 450 ^ 2 * x ^ 3 - 450 ^ 4 *
x)

4)

End Function
Function dY(ByVal x As Single) As Single
Return (1.75 / 120 * 50000 * 30000 * 450) * (-5 * x ^ 4 + 6 * 450 ^ 2 * x ^ 2 - 450 ^
End Function
Private Sub btnSecante_Click()
Dim a, b, m, eps As Single
a = Val(txtA.Text)
b = Val(txtB.Text)
eps = 10 ^ -2
If dY(a) * dY(b) < 0 Then
Do
m = ((a * dY(b)) - (b * dY(a))) / (dY(b) - dY(a))

MsgBox(Str(dY(m)))
If Math.Abs(dY(m)) < eps Then
MsgBox("llego")
txtY.Text = Str(Y(m))
Exit Sub
Else
If dY(a) * dY(m) >= 0 Then
a=m
Else
b=m
End If
End If
Loop
Else
MsgBox("cambie los valores de a y b")
Exit Sub
End If
End Sub
End Class
PREGUNTA 4

Public Class Form1


Function f(ByVal t As Single) As Single
Return Math. 10 * (E ^ ( - 0.45 * t ) ) * cos ( 2 * t )
End Function
Function f2(ByVal t As Single) As Single
Return Math. 10
End Function
Private Sub btnCalcular_Click()
Dim t0, t, eps As Double
eps = 10 ^ -3
t0 = Val(txtT0.Text)
Do
t = t0 - f2(t0) / f(t0)
If Math.Abs(t - t0) < eps Then
txtT.Text = Str(t)
Exit Sub
Else
t0 = t
End If
Loop
End Sub
End Class

You might also like