Hi, Piotr, If you cast u to be a real number, as in the below example, it 
produces the intended behavior:

def F(u):
    return arg( (-3 + RR(u) )^(1/3) )

numerical_integral(F,1,2)

This is because in your previous code example, u is a python floating 
point, and by default python throws an error when taking a fractional 
negative power of a float. However, Sage's real floating point numbers 
don't have the same restriction, which is probably what you were expecting 
instead. Hope this solves the problem!

Matt

On Friday, July 5, 2019 at 4:58:12 PM UTC-4, Piotr Sniady wrote:
>
> Dear Developers,
>
> the code below produces a function which for any real u<3 gives as value 
> \pi/3.
> One can check that for any given number Sage has no problems to evaluate 
> this function
> and that it gives the right value.
>
> For strange reason I cannot integrate this function numerically.
> Also, I cannot plot this function.
>
> Magically, while for any given value Sage has no problems to give a 
> complex root of a negative number,
> for numerical integration the behavior of the root changes.
>
> Any help would be appreciated.
>
> Yours,
>
> Piotr
>
>
>
> def F(u):
>     return arg( (-3 + u )^(1/3) ).n()
>
> numerical_integral(F,1,2)
>
>
>
>
> Error message:
>
> negative number cannot be raised to a fractional power
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/5d9a0405-079f-4877-801b-00e84e8db27a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to