求解包含二伽玛函数的方程组的最有效方法是什么?

发布于 2024-08-28 01:49:45 字数 741 浏览 6 评论 0原文

求解涉及双伽玛函数的方程组的最有效方法是什么?

我有一个向量 v,我想求解向量 w,使得对于所有 i:

digamma(sum(w)) - digamma(w_i) = v_i

w_i > 0

我找到了 gsl 函数 gsl_sf_psi,它是 digamma 函数(使用某种级数计算)。是否有一个恒等式可以用来简化方程?我最好的选择是使用求解器吗?我正在使用C++0x;哪种求解器最容易使用且速度最快?


根据我的初步研究,双伽玛不容易可逆(搜索逆双伽玛给出了通过二分搜索工作的算法),因此整个系统没有简化是有道理的。

因此,使用求解器现在留下两个问题:处理 digamma 计算非常慢的事实,以及处理 w_i > 的限制。 0,否则当 w_i = 0 时,digamma(w_i) 会崩溃。

对于第一个问题,我想也许我应该为最近计算的 digamma 值实现一个缓存——我认为这是一个好主意,但不知道关于寻根算法如何工作的更多内容。

我的想法是解决第二个问题是找到w'_i = log(w_i)。这样,w'_i就在整条线上。我想知道这是否是一个好主意。可能没有直接找到 digamma(exp(w')) 的函数?此外,该算法可能在 w' 空间中采取步骤,但不会改进事情,因为从 w'->w 的映射会损失一些精度,因此 w' 的两个元素可能映射到相同的 w。

仍然存在找到一个好的、快速的寻根算法的问题。我想我可以在一个单独的问题中问这个问题。

谢谢...

What is the most efficient way to solve system of equations involving the digamma function?

I have a vector v and I want to solve for a vector w such that for all i:

digamma(sum(w)) - digamma(w_i) = v_i

and

w_i > 0

I found the gsl function gsl_sf_psi, which is the digamma function (calculated using some kind of series.) Is there an identity I can use to reduce the equations? Is my best bet to use a solver? I am using C++0x; which solver is easiest to use and fast?


From my preliminary research, digamma is not easily invertible (searching for inverse digamma gives algorithms that work by binary search), so it makes sense that there would be no simplification to the whole system.

So, using a solver now leaves two problems: dealing with the fact that digamma is very slow to calculate, and dealing with the restriction that w_i > 0, or else digamma(w_i) will crash for w_i = 0.

For the first problem, I thought maybe I should implement a cache for recently calculated values of digamma -- I thought that would be a good idea, but don't know much about how root-finding algorithms work.

My idea was to solve the second problem was to find w'_i = log(w_i). That way, w'_i are on the whole line. I wonder if this is a good idea. There's probably no function to find digamma(exp(w')) directly? Also, the algorithm might take steps in w' space and not improve things because the mapping from w'->w loses some precision and so two elements of w' might map to the same w.

There's still the question of finding a good, fast rootfinding algorithm. I think I may ask that in a separate question.

Thanks...

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

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

发布评论

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

评论(1

叹倦 2024-09-04 01:49:45

我建议使用求解器是最好的主意,主要是因为考虑各种方程的各种稳定性和收敛区域可能很棘手,而且重新发明轮子是没有用的。虽然我从未真正解决过像您提到的那样的系统,但我认为以下库之一很可能有您想要的解决方案:

另外,如果这些都没有你想要的,你可以看看 GNU Octave 或类似的东西如何解决系统问题然后阅读他们的文档,了解他们用来实现解决该问题所需的功能的算法。从这里开始,更多的是弄清楚如何使用算法,如何实现它,以及在哪些情况下值得这样做(Octave、Matlab、Mathematica 的文档非常全面,并列出了在大多数情况下定义了该算法的出版物) ,如果您正在寻找开源/免费替代品,还有 Scilab 和 SageMath,并且有一些方法可以在 C++ 中使用这些例程(但我不确定这有多容易或多困难)

希望有所帮助。

I would suggest that using a solver would be the best idea, mainly because considering the various stability and convergence regions for various equations might be tricky and it is no use reinventing the wheel. While I have never really solved a system like the one you mentioned, I think one of the following libraries are highly likely to have a solution that you want:

Also, if neither of these has exactly what you want, you could see how GNU Octave or something alike solve the system and then read their documentation about the algorithm they use to implement the functions needed to solve it. From there it is more about figuring out how the algorithm is used, how to implement it, and in which cases is it worthwhile (documentation of Octave, Matlab, Mathematica is very comprehensive and lists the publications that have the algorithm defined in most cases), there are also Scilab and SageMath if you are looking for opensource/free alternatives, and there are ways to use routines from these from within C++ (but I'm not sure how easy or difficult that would be)

Hope that helps.

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