I think many people in the Julia community would use lambert_W(x::Number) and 
then warn people not to use anything but Real or Complex.

If you want full type safety, I think a Union(Real, Dual) is the way to go here.

 -- John

On Jan 22, 2014, at 10:26 AM, Hans W Borchers <[email protected]> wrote:

> Sorry, Jason, I didn't get it. What would you propose to use in 
> 
>     function lambert_W(x::Number)
>         ...
>     end
> 
> to allow dual and to forbid complex numbers? Or is it some additional test in 
> the body of the function.
> 
> Thanks, Hans Werner
> 
> 
> On Wednesday, January 22, 2014 6:31:51 PM UTC+1, Jason Merrill wrote:
> On Wednesday, January 22, 2014 4:25:38 AM UTC-8, Stefan Karpinski wrote:
> I wonder if Dual shouldn't be a subtype of Real. Of course, you can probably 
> have Dual complex numbers as well, but maybe those can be Complex{Dual} in 
> that case.
> 
> Complex{Dual} and Dual{Complex} are equally sensible notions. As long as du 
> and im commute, they're the same thing. Neither of them are "real" numbers in 
> the mathematical sense.
> 
> I wanted to make PowerSeries work over complex numbers, but ended up 
> restricting them to a Real field for now because the type issues got 
> confusing. It would be nice if we had a more precise way to talk about the 
> relationship between algebraic number types like this.
> 
> Sage is written by number theorists and has an interesting approach to 
> defining mathematical objects over various fields. I haven't taken the time 
> to understand exactly how their system works, though.

Reply via email to