On Fri, Jun 1, 2012 at 1:01 PM, krastanov.ste...@gmail.com
<krastanov.ste...@gmail.com> wrote:
> Not much better, however:
>
> array = np.ceil(1000*array)/1000
>
> On 1 June 2012 08:45, Bharath M R <catchmrbhar...@gmail.com> wrote:
>> Hi,
>> I was trying to implement interval arithmetic using numpy for plotting. I
>> could not possibly find a way
>> to **round up** a floating point value. ie sin(<1, 1>) = <0.841, 0.842>
>> rounded to 3 decimals. I would like

Defining the problem well is important. Do you really want to a) round
up, b) just need the interval, width=1/1000, that contains a given
point, or c) want the interval of width 1/1000 that has the point as
close to the center as possible?

The last routine I sent calculated b, this one calculates c:

def bounds(x, n):
    m = 10**-n
    a = x - m/2
    return a, a+m

>>> bounds(sin(1).n(),3)
(0.840970984807897, 0.841970984807897)

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to