Reputation: 571
I need someone to tell me why I get
compile error : Expected array
as soon as I try to use my function and what should be changed to get the result. As much as I understand there's no need in array usage according to task(explained below the code).
Public Function papild(x)
Dim s As Double, A As Double
Dim P As Integer
s = 0.5 + (x - system.Math.Pi) / 1
A = (x - system.Math.Pi) / 1
P = 2
Do While Abs(A) > 0.0001
A = -A * (x - system.Math.Pi) * (x - system.Math.Pi) / P(P + 1)
s = s + A
P = P + 1
Loop
papild = s
End Function
----------------------------------------------------------------------------------------------
I'll try my best to explain the task of mine, I hope it would be useful for you to point out what's done wrong.
* Conditions: using ^ operator is forbidden. *
There's : Elements row sum formula - and argument variation range - (-π/2) to (π/2) [Step: π/30].
My actions: one column is being used for argument value (first cell(@ Formula bar) =PI()/-2));every next cell is (@Formula bar) ="cell above" + PI()/30.;Writing the code(above) and calling the function in second column, using appropriate column one cell as function argument.
Thanks in advance.
(Sorry for my poor English, especially for math terminology)
Upvotes: 0
Views: 114
Reputation: 152505
as per the comments:
Public Function papild(x)
Dim s As Double, A As Double
Dim P As Integer
s = 0.5 + (x - Application.WorksheetFunction.Pi()) / 1
A = (x - Application.WorksheetFunction.Pi()) / 1
P = 2
Do While Abs(A) > 0.0001
A = -A * (x - Application.WorksheetFunction.Pi()) * (x - Application.WorksheetFunction.Pi()) / P ^ (P + 1)
s = s + A
P = P + 1
Loop
papild = s
End Function
Upvotes: 2