Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. A series expansion for the natural log of x valid for x >0.5 is: Write a VBA

ID: 3750043 • Letter: 3

Question

3. A series expansion for the natural log of x valid for x >0.5 is: Write a VBA program to evaluate this series. Use a Do While loop to continue the series until a term satisfies the tolerance or a maximum number of terms is calculated. Apply your series to x - 3, with a maximum of 100 terms and a tolerance of 0.5e-7. Output should include your answer, the correct value, the number of terms used, the last term computed, and the difference between the correct and the series values. Begin with and turn in a flowchart

Explanation / Answer

Private Sub cmdclear_Click()


txtx.Text = ""


txtTolerance.Text = ""


txtMaxTerms.Text = ""


End Sub


Private Sub cmdCompute_Click()


Dim x As Integer, n As Integer, i As Integer


Dim num_of_terms As Integer


Dim tol As Double


Dim term As Double


Dim sumofterms As Double


Dim res As Double


Dim logx As Double


x = CInt(txtx.Text)


logx = Log(x)


tol = CDbl(txtTolerance.Text)


num_of_terms = CInt(txtMaxTerms.Text)


tol = CDbl(txtTolerance.Text)


For i = 0 To CInt(txtMaxTerms.Text)


n = (2 * i + 1)


term = (1 / n) * ((x - 1) / (x + 1)) ^ n


Sum = Sum + term


If Abs(logx - (2 * Sum)) <= tol Then Exit For


Next i


res = 2 * Sum


Range("B4").Value = x


Range("B5").Value = i


Range("B6").Value = tol


Range("B8").Value = res


Range("B9").Value = logx


Range("B10").Value = i


Range("B11").Value = term


Range("B12").Value = logx - res


End Sub

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote