I am trying to write a program that estimates sin(x) for a school assignment. Here is what I have so far:
Option Explicit
Function SinE(x, k)
Dim I As Single, start As Single, top As Single, bottom As Single, fact As Single
start = x
I = 1
fact = (2 * k) + 1
Function Factorial(a)
Dim J As Single
J = 1
For J = 1 To (a - 1)
a = a * J
Next J
Factorial = a
End Function
For I = 1 To k
top = ((-1) ^ k) * (x) ^ ((2 * k) + 1)
bottom = (Factorial(fact))
start = start + (top / bottom)
Next I
SinE = start
End Function
There is a compiler error around fact=((2*k)+1). It says there is an "expected end of function" and the 2 is highlighted. I don't know what this means or how to fix it.
Bookmarks