Monday, May 24, 2010

Create the sine function without libraries in C++?

ive heard that you can make the sine function without the math library. you have to use something like x-x^2/3!...

Create the sine function without libraries in C++?
Yes! You absolutely can. In fact, all the standard c libraries are simply code that is/was re-written again and again and again, so they finally made it part of the standard library.





//caveat: example only...math is from your own question





double _my_sine(double x)


{


return x-( (x*x) / (1*2*3) );


}





Now, please note we've given this, our sine() function, a unique name that is different than the standard C's math library function...calling this one "_my_sine()".





This is important so the compiler gets/uses the correct sine function, and that we also know which one we're using...
Reply:Dear, Its A Math Question, Not Programming :(


I Really Can Understand That It Is An Assignment Or Something Like That





I Know That Your Instructor Wants You To Understand From Where This Comes From, But I Believe Rewriting Algorithms Will Not Be Useful As Searching To Create New Ones








http://www.homeschoolmath.net/teaching/s...





Hope This Help





You Have To
Reply:Um, to the previous answerer, you don't HAVE to capitalize every word in a sentence.





The definition of function Sine(A) is, for any right triangle with one angle equaling angle A is





Opposite


Sin(A)= ------------


Hypotenuse





You do know what those are, right? (Hypotenuse is opposite the right angle, Opposite is opposite angle A).





UNfortunately, the only ways I know of defining sine are by using other trigonometric functions.


Pi 1


Sin(A)= Cos(------- - A) = ----------


2 csc A





Edit: Follow the site listed below, this text editor doesn't preserve the spacing for the dividing.


No comments:

Post a Comment