python 反三角函数(特别是 arcsin)

发布于 2024-07-17 13:33:33 字数 584 浏览 8 评论 0原文

我目前正在尝试运行涉及三角学的东西,但我遇到了涉及 math.asin 函数的问题(它也适用于 acos 和 atan,但在这些情况下,它对我想做的事情影响较小)。 我在其他地方找到的帮助线程中的两篇文章很好地总结了这个问题;

抱歉,我刚刚又试了一遍, 发现

a = sin(2)
b = asin(a)
b 不 = 2

但是

a = cos(2)
b = acos(a)
b 确实= 2

因为 y = sin(x) 是一个重复项 函数,有多个值 x 对于每个 y 值。 即罪(2) = 正弦(1.14) = 0.909

因此,当你执行 x = asin(y) 时, 你只会得到一个介于 -PI/2 <= x <= PI/2

我从数学上理解这是为什么,但我想知道是否有人可以帮助我找到一个范围内的所有解决方案,而不仅仅是它自动给出的解决方案。 谢谢=]

I'm currently trying to get something to run involving trigonometry but I've run across a hitch involving the math.asin function (it also applies to acos and atan but in those cases it less affects what I'm trying to do). The issue is best summarised by two posts from a help thread I found about it elsewhere;

Sorry, I have just tried it again and
found that

a = sin(2)
b = asin(a)
b doesnt = 2

but

a = cos(2)
b = acos(a)
b DOES= 2

Because y = sin(x) is a repetitive
function, there is more than one value
of x for every value of y. ie sin(2) =
sin(1.14) = 0.909

Therefore, when you do x = asin(y),
you will only ever get a value between
-PI/2 <= x <= PI/2

I understand mathematically why this is but I was wondering if anyone could give me a hand in finding all the solutions within a range rather than just the one it gives automatically. Thanks =]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

空城缀染半城烟沙 2024-07-24 13:33:33

让我们考虑范围 [0, 2π)。

对于acos,每个值 x 也有另一个可能的值 2π - x。 (画出余弦图,您就会看到它。)

对于 asin,每个正值 x 在 π - x 处都有另一个可能的值; 每个负值在 3π - x 处都有一个可能值。

请随意绘制更多图表以推广到更大的范围。 :-)

Let's consider the range [0, 2π).

For acos, each value x also has another possible value at 2π - x. (Picture the cosine graph and you'll see it.)

For asin, each positive value x has another possible value at π - x; each negative value has a possible value at 3π - x.

Feel free to draw further graphs to generalise to greater ranges. :-)

Saygoodbye 2024-07-24 13:33:33

acrsin(a) 的所有解为:

b、pi - b、2pi + b、2pi + (pi - b) 等。

All the solutions for acrsin(a) will be:

b, pi - b, 2pi + b, 2pi + (pi - b), etc.

天冷不及心凉 2024-07-24 13:33:33

正如其他人已经详细解释的那样,您为 a 选择了一个值,由于三角函数的(重复)性质,导致 asin() 的结果不确定。

尽管如此,我只是想指出,由于更通用的 浮点精度问题

对于浮点,您不能不能保证这

a == asin(sin(a))

一点

a == (a / b) * b

。 请小心。

As others have already explained in detail you picked a value for a that leads to indetermined results for asin() due to the (repetitive) nature of the trigonometric functions.

Nevertheless I just wanted to point out that expecting to be able to get the exact same result back on an invers operation with floating points will probably fail due to a more general Floating point accuracy problem

With floating point you can not guarantee that

a == asin(sin(a))

or

a == (a / b) * b

for that matter. Just be careful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文