Jump to content

Recommended Posts

10 minutes ago, Joe Tauser said:

Use the floating point math to implement a Taylor series-


I'd run the equation a few times in a spreadsheet to see how far n has to increment to get the accuracy you're looking for.

Joe T.

Thanks Joe. That will return radians? I can use the degrees function to go back?

Link to comment
Share on other sites

  • MVP 2023

Yes, it will be radians.  1 radian = 57.2958 degrees.

It's actually not as hard as it looks.  Many moons ago, I needed to calculate the cosine of an angle in a Siemens S7-200, which does not have floating point.  Some obscure neuron fired in my brain and remembered studying Taylor series in school as the way to determine the values of trigonometric functions.  

Here's how to get cosine:

I used double integers (MLs or VD32 in SiemensSpeak) with a virtual decimal place of 4 and only had to take it out to k=4 to get a good value.  As you can see, if you go past that the numbers get really tiny and don't affect the value much.

If you expand the arcsin Tayor series out to n=4 the front part of the equation becomes just number that some nimble fingering on your calculator can arrive at and you can punch that in as a constant to multiply the x^(2n+1) amount by. 

It's no fun being an engineer if you don't stretch your brain sometimes.

Joe T.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...