Dear Marshall,

Thanks a lot for your help. This should work in this case, but I don't
think I could get around using substitutions altogether (see, for
example, this thread:
http://groups.google.com/group/sage-support/browse_thread/thread/e62a83a6ac3c5d1d/e6e535972106bb15?lnk=gst&q=python+stan#e6e535972106bb15).
Should this be filed as a bug in subs?

Cheers
Stan




On Feb 9, 8:34 pm, Marshall Hampton <[email protected]> wrote:
> I would guess the problem stems from the
>
> sage: length = daylength.subs(locals()).n()
>
> line somehow.  I would recommend making daylength a function, instead
> of substituting.
>
> I am still not sure exactly what the problem is in the original code
> though.
>
> On Feb 9, 12:35 pm, Stan Schymanski <[email protected]> wrote:
>
> > Dear all,
>
> > For some reason, the meaning of the global constants pi and e (and
> > maybe others) becomes unavailable to the plot command in the following
> > example. Is this a bug?
>
> > ----------------------------------------------------------------------
> > | Sage Version 3.2, Release Date: 2008-11-20                         |
> > | Type notebook() for the GUI, and license() for information.        |
> > ----------------------------------------------------------------------
>
> > sage: var('h delta phi doy t')
> > (h, delta, phi, doy, t)
> > sage: h = 1/12*pi*(t-12)
> > sage: delta = -23.45*pi/180*cos(2*pi*(doy+10)/365)
> > sage: sinbeta = cos(h)*cos(delta)*cos(phi)+sin(delta)*sin(phi)
> > sage: daylength = 12+24/180*arcsin(tan(phi)*sin(delta)/cos(delta))*180/
> > pi
> > sage: plot(pi*x,x,0,1)
>
> > sage: plot(exp(x),x,0,1)
>
> > sage: doy = 180
> > sage: phi = (30*pi/180).n()
> > sage: length = daylength.subs(locals()).n()
> > sage: t0 = 12-0.5*length
> > sage: t1 = 12+0.5*length
> > sage: plot(pi*x,x,0,1)
> > ERROR: An unexpected error occurred while tokenizing input
> > The following traceback may be corrupted or invalid
> > The error message is: ('EOF in multi-line statement', (546, 0))
> > [...]
> > ValueError: free variable: pi
>
> > sage: plot(exp(x),x,0,1)
> > [...]
> > ValueError: free variable: e
>
> > Funnily enough, the following fixes the pi-problem for the time being:
>
> > sage: pi=pi.n()
>
> > But e=e.n() does not fix the e-problem.
>
> > Can anyone help?
>
> > Thanks a lot,
> > Stan
--~--~---------~--~----~------------~-------~--~----~
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
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to