Hi Erik,

On Thu, Oct 29, 2009 at 1:55 AM, Erik <[email protected]> wrote:
>
> I would like to iterate a function:
>
> def f(x):
>    return( (1/5)*(x**3+x**2-3) )
> f(0)
>
> Running evaluate on the above yields the quantity -3/5. Rather than
> evaluating f(-3/5), is there a way to reference the previous output
> from evaluate, i.e. to evaluate f(previous) or some similar syntax?

Is the following what you want to do?

{{{
[mv...@sage ~]$ sage
----------------------------------------------------------------------
| Sage Version 4.2, Release Date: 2009-10-24                         |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: def f(x):
....:     return( (1/5) * (x**3 + x**2 - 3) )
....:
sage: f(0)
-3/5
sage: f(_)
-357/625
sage: f(_)
-698265543/1220703125
sage: f(_)
-5202240827516755391321839257/9094947017729282379150390625
sage: f(_)
-2151599640664253715605723175336621357676825636894981382634097915842012994460122338843/3761581922631320025499956919111186169019729781670680068828005460090935230255126953125
}}}

Notice that the underscore symbol "_" accesses the result of the
immediately previous computation.

-- 
Regards
Minh Van Nguyen

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to