Ask Your Question
0

How to decrease the iteration step from 1 to 0.1?

asked 2012-05-27 20:43:01 +0100

dnizetic gravatar image

updated 2012-05-27 20:43:12 +0100

@interact
def _(a=((0.1)..(5.00))):
  ...
  show(pl1+pl2+pl3+pl4);

I would like 'a' to be iterated by the step 0.1, and not 1.

How can I achieve this?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2012-05-27 21:52:18 +0100

DSM gravatar image

Here's one approach, which works by giving Sage enough values that it can guess what step you want:

sage: (0.1, 0.2, .., 0.5)
<generator object ellipsis_iter at 0x11bce0fa0>
sage: list(0.1, 0.2, .., 0.5)
[0.100000000000000, 0.200000000000000, 0.300000000000000, 0.400000000000000, 0.500000000000000]
edit flag offensive delete link more
2

answered 2012-05-28 01:40:31 +0100

calc314 gravatar image

You can also specify the details using the command slider. The syntax is:

slider(a,b,step,start_value)

For example, you might have the following:

@interact
def _(a=slider(0.1,5.0,0.1,3)):
    print a

This defines a slider with values from 0.1 to 5 that steps by 0.1, and the interact will launch with the slider set to 3.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-05-27 20:43:01 +0100

Seen: 455 times

Last updated: May 28 '12