# [SciPy-User] point-curve distance estimation or calculation

josef.pktd@gmai... josef.pktd@gmai...
Wed Jun 2 08:29:30 CDT 2010

```On Wed, Jun 2, 2010 at 9:18 AM, Zachary Pincus <zachary.pincus@yale.edu> wrote:
>> Calculation is doable by applying this formula
>> http://mathcentral.uregina.ca/QQ/database/QQ.09.07/s/elliot1.php
>> But then, an estimation of the correct result is required, and it
>> takes a
>> lot of time for every step, if you have 25 million values in each set.
>>
>> First, there might be some functions useful to do this calculation
>> quite
>> fast (up to 5 minutes is quite acceptable), that I may have
>> overseen. That
>> may basically calculate the following internally

from the example here it looks like the minimum distance is a solution
to a degree 3 polynomial for each point

a+bx+bx**3 = 0

is there a vectorized way to find the real root of this?

Josef

>
> Are you applying the formula individually for each x,y point (slow),
> or are you applying the formula in parallel to an array of all the x,y
> points (potentially fast)?
>
> If the former, then you'll want to read up on some numpy tutorials
> until you see how to implement the formula without looping through
> each point (or post code here and someone can help); if the latter
> then maybe you can post code anyway and people can see if there are
> obvious bottlenecks.
>
> In principle it seems like applying the closed-form solution shouldn't
> be too slow, right? Unless I missed something, there's nothing
> iterative, right?
>
> Zach
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
```