ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 28 May 2012 01:40:31 +0200How to decrease the iteration step from 1 to 0.1?https://ask.sagemath.org/question/9008/how-to-decrease-the-iteration-step-from-1-to-01/ @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?Sun, 27 May 2012 20:43:01 +0200https://ask.sagemath.org/question/9008/how-to-decrease-the-iteration-step-from-1-to-01/Answer by calc314 for <pre><code>@interact
def _(a=((0.1)..(5.00))):
...
show(pl1+pl2+pl3+pl4);
</code></pre>
<p>I would like 'a' to be iterated by the step 0.1, and not 1.</p>
<p>How can I achieve this?</p>
https://ask.sagemath.org/question/9008/how-to-decrease-the-iteration-step-from-1-to-01/?answer=13622#post-id-13622You 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.
Mon, 28 May 2012 01:40:31 +0200https://ask.sagemath.org/question/9008/how-to-decrease-the-iteration-step-from-1-to-01/?answer=13622#post-id-13622Answer by DSM for <pre><code>@interact
def _(a=((0.1)..(5.00))):
...
show(pl1+pl2+pl3+pl4);
</code></pre>
<p>I would like 'a' to be iterated by the step 0.1, and not 1.</p>
<p>How can I achieve this?</p>
https://ask.sagemath.org/question/9008/how-to-decrease-the-iteration-step-from-1-to-01/?answer=13621#post-id-13621Here'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]
Sun, 27 May 2012 21:52:18 +0200https://ask.sagemath.org/question/9008/how-to-decrease-the-iteration-step-from-1-to-01/?answer=13621#post-id-13621