On Tue, Sep 20, 2016 at 09:22:19AM -0700, H. S. Teoh via Digitalmars-d-learn 
> On Tue, Sep 20, 2016 at 12:35:18PM +0000, Basile B. via Digitalmars-d-learn 
> wrote:
> [...]
> > Which means that I ask you if you can isolate c for
> > 
> > y = 1.0 - pow(1.0 - pow(0.5, 2.0/c), c * 0.5);
> > 
> > y is always f(0.5,c)
> That probably means the inverse cannot be expressed in terms of
> elementary functions. Probably the only thing you can do is to use
> some kind of numerical approximation, like some form of Newton's
> method or some such, to find the value of c.

It may be analytically very hard to solve this equation, but it's
probably not so hard to solve numerically. Based on the graph of the
equation produced by Wolfram Alpha, it seems that y must always lie
between 0 and 1, and that it has a horizontal asymptote at y=1.  At
around c=6 or thereabouts, y becomes very close to 1.  The value of c
for y=0.5 is approximately 2, so that seems like a good initial guess
for an iterative method.

So if y<0 or y>1, return NaN. If y=1, return +inf. Otherwise, use an
iterative method with a starting value of c=2. Because of the horizontal
asymptote at y=1, though, values of c much greater than 6 will probably
be quite inaccurate, so hopefully your application doesn't depend on the
exact value in that case!


Freedom of speech: the whole world has no right *not* to hear my spouting off!

Reply via email to