|
|
|
|
|
|
|
|
CTK Exchange
oniwaka

guest
|
Dec-13-06, 03:16 PM (EST) |
|
"a = sin(f(x) * n); n = ???"
|
I'm being haunted by this problem! My only solution at this point is the dirtiest of programmers tricks(the lookup table), which is workable for the level of precision I need. However, I can't help but think there's a better solution. a = sin(f(x) * n) or a = (exp(complex(0, f(x) * n)) - exp(-complex(0, f(x) * n))) / 2j a and x are known Thanks in advance for any help you might offer. |
|
Alert | IP |
Printer-friendly page |
Reply |
Reply With Quote | Top |
|
|
alexb
Charter Member
1930 posts |
Dec-13-06, 03:23 PM (EST) |
 |
1. "RE: a = sin(f(x) * n); n = ???"
In response to message #0
|
Even assuming f(x) is a known function, the problem does not have a unique solution. Regardless, it requires a more or less standard application of arcsin: f(x)*n = arcsin(a) or f(x)*n = π - arcsin(a). There may be a question of efficiency of course, in which case a lookup table may be a viable alternative. |
|
Alert | IP |
Printer-friendly page |
Reply |
Reply With Quote | Top |
|
|
 |
oniwaka

guest
|
Dec-13-06, 09:19 AM (EST) |
|
2. "RE: a = sin(f(x) * n); n = ???"
In response to message #1
|
Thank you. I'll be able to rest easily now. Maybe I should take a math refresher course... I compiled a quick benchmark, and the lookup table is indeed faster in C. But since I'm prototyping in python, which has non-negotiable float precision (requiring type conversion for each lookup), arcsin(a)/f(x) is actually faster. Thanks again. |
|
Alert | IP |
Printer-friendly page |
Reply |
Reply With Quote | Top |
|
|
|

You may be curious to have a look at the old CTK Exchange archive. Please do not post there.
Copyright © 1996-2018 Alexander Bogomolny
|
|