Re: Numeric root-finding in Python

2012-02-20 Thread Mark Lawrence
On 21/02/2012 01:33, David Monaghan wrote: On Sun, 12 Feb 2012 10:20:17 -0500, inq1ltd wrote: I don't know the first thing about this math problem however, if I were to code this I might try ; except ZeroDivisionError: assert w = -1 rather than; except ZeroDivisionError:

Re: Numeric root-finding in Python

2012-02-20 Thread David Monaghan
On Sun, 12 Feb 2012 10:20:17 -0500, inq1ltd wrote: > > >I don't know the first thing about this math problem however, > >if I were to code this I might try ; > > except ZeroDivisionError: > assert w = -1 > >rather than; > > except ZeroDivisionError: > assert w == -1 Why? DM

Re: Numeric root-finding in Python

2012-02-12 Thread Dave Angel
On 02/12/2012 06:05 PM, Steven D'Aprano wrote: On Sun, 12 Feb 2012 12:18:15 -0800, Mark Dickinson wrote: On Feb 12, 6:41 am, Steven D'Aprano wrote: err = -a/b # Estimate of the error in the current w. if abs(err)<= 1e-16: break If the result you'r

Re: Numeric root-finding in Python

2012-02-12 Thread Steven D'Aprano
On Sun, 12 Feb 2012 12:18:15 -0800, Mark Dickinson wrote: > On Feb 12, 6:41 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: > >>             err = -a/b  # Estimate of the error in the current w. >>             if abs(err) <= 1e-16: >>                 break > > If the result you're e

Re: Numeric root-finding in Python

2012-02-12 Thread Steven D'Aprano
On Sun, 12 Feb 2012 13:52:48 +, Robert Kern wrote: > I don't have any advice for fixing your code, per se, but I would just > grab mpmath and use their lambertw function: That's no fun! I'd never see mpmath before, it looks like it is worth investigating. Nevertheless, I still intend workin

Re: Numeric root-finding in Python

2012-02-12 Thread Terry Reedy
On 2/12/2012 5:10 AM, Eelco wrote: On Feb 12, 7:41 am, Steven D'Aprano wrote: This is only peripherally a Python problem, but in case anyone has any good ideas I'm going to ask it. I have a routine to calculate an approximation of Lambert's W function, and then apply a root-finding technique t

Re: Numeric root-finding in Python

2012-02-12 Thread Mark Dickinson
On Feb 12, 6:41 am, Steven D'Aprano wrote: >             err = -a/b  # Estimate of the error in the current w. >             if abs(err) <= 1e-16: >                 break If the result you're expecting is around -1.005, this exit condition is rather optimistic: the difference between the two Py

Re: Numeric root-finding in Python

2012-02-12 Thread Dave Angel
On 02/12/2012 10:20 AM, inq1ltd wrote: I don't know the first thing about this math problem however, if I were to code this I might try ; except ZeroDivisionError: assert w = -1 You top-posted. Please type your response after whatever you're quoting. In my case, I only need a

Re: Numeric root-finding in Python

2012-02-12 Thread inq1ltd
I don't know the first thing about this math problem however, if I were to code this I might try ; except ZeroDivisionError: assert w = -1 rather than; except ZeroDivisionError: assert w == -1 jimonlinux On Sunday, February 12, 2012 06:41:20 AM Steven D'Aprano wro

Re: Numeric root-finding in Python

2012-02-12 Thread Robert Kern
On 2/12/12 6:41 AM, Steven D'Aprano wrote: This is only peripherally a Python problem, but in case anyone has any good ideas I'm going to ask it. I have a routine to calculate an approximation of Lambert's W function, and then apply a root-finding technique to improve the approximation. This mos

Re: Numeric root-finding in Python

2012-02-12 Thread Mark Lawrence
On 12/02/2012 10:10, Eelco wrote: On Feb 12, 7:41 am, Steven D'Aprano wrote: This is only peripherally a Python problem, but in case anyone has any good ideas I'm going to ask it. I have a routine to calculate an approximation of Lambert's W function, and then apply a root-finding technique to

Re: Numeric root-finding in Python

2012-02-12 Thread 88888 Dihedral
在 2012年2月12日星期日UTC+8下午2时41分20秒,Steven D'Aprano写道: > This is only peripherally a Python problem, but in case anyone has any > good ideas I'm going to ask it. > > I have a routine to calculate an approximation of Lambert's W function, > and then apply a root-finding technique to improve the approx

Re: Numeric root-finding in Python

2012-02-12 Thread Eelco
On Feb 12, 7:41 am, Steven D'Aprano wrote: > This is only peripherally a Python problem, but in case anyone has any > good ideas I'm going to ask it. > > I have a routine to calculate an approximation of Lambert's W function, > and then apply a root-finding technique to improve the approximation.

Numeric root-finding in Python

2012-02-11 Thread Steven D'Aprano
This is only peripherally a Python problem, but in case anyone has any good ideas I'm going to ask it. I have a routine to calculate an approximation of Lambert's W function, and then apply a root-finding technique to improve the approximation. This mostly works well, but sometimes the root-fin