Anthony's VBA Forum Index Anthony's VBA Forum
Where the knowledge is shared
Menu
 Anthony's VBA Forum IndexHome Page
 Anthony's VBA Forum IndexForum Index
FAQFAQ
MemberlistMemberlist
UsergroupsUsergroups
RegisterRegister
ProfileProfile
Log in to check your private messagesMessages
Log inLogin/Out

Quick Search

Advanced Search

Links
Consulting
Products

Who's Online
[ Administrator ]
[ Moderator ]


Help w/VBA function 2calculate sine of an angle using series

 
Post new topic   Reply to topic     Anthony's VBA Forum Index -> General Excel VBA
View previous topic :: View next topic  
Author Message
feather



Joined: 19 Jul 2009
Posts: 1

PostPosted: Sun Jul 19, 2009 6:34 pm    Post subject: Help w/VBA function 2calculate sine of an angle using series Reply with quote

Can someone help me do this? I have no clue where to even start.
Thank you!

Write and Test a VBA function to calculate the sine of an angle using the series:

sin(x)=+(x^1/1!)-(X^3/3!)+(x^5/5!)-(x^7/7!)+...

The strategy in using a power series is to calculate and add terms until the absolute value of the last term is less than a specified tolerance.
There are a number of ways to handle the required loop and logic. The flowchart on the next page shows one approach. You may use this approach or develop your own. Be sure to include the following:
• The function itself should have the datatype Double.
• The function arguments will be the angle (x As Double) and an Optional, Boolean argument for degrees or radians.
• The maximum iterations (100) and the tolerance (0.00001) should be assigned inside the function code
• The loop should continue either until the absolute value of the last term is less than the tolerance, or maximum iterations are reached.
• There should be code inside the loop to calculate each term based on the loop counter and add with the appropriate sign (+ or -).
• There should be a message box to tell the user that maximum iterations were reached – this implies that the last term was not small enough to pass the tolerance test.


Write a subroutine to use the function which asks the user to enter a value of x. The results should be output to both the spreadsheet and via a message box. The user should be allowed to continue or stop after each x is entered. The results on the spreadsheet should form two columns .. one headed “x” and the other “sin (x)”.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Anthony's VBA Forum Index -> General Excel VBA All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group