[sage-support] Re: sage

2009-04-03 Thread John Cremona

I think I do understand what Armand is asking.  Let's see:

Say I have been using Magma for half an hour.  I typed lots of stuff,
including typos etc, and a whole lot of output has scrolled past.  Now
I want to keep all the commands that I typed, put them in a file,
sanitize them, ans use them later as a kind of script.  I can do that
in Magma like this:

> 2+2;
4
> Factor(x^2-1);

>> Factor(x^2-1);
 ^
Runtime error in 'Factor': Bad argument types
Argument types given: RngUPolElt[FldRat]

> R:=PolynomialRing(Rationals());
> Factor(x^2-1);

>> Factor(x^2-1);
 ^
Runtime error in 'Factor': Bad argument types
Argument types given: RngUPolElt[FldRat]

> Factorization(x^2-1);
[
,

]
> %S
SetSeed(2266693670, 0); 2+2;
Factor(x^2-1);
R:=PolynomialRing(Rationals());
Factor(x^2-1);
Factorization(x^2-1);

(deliberately full of beginner's mistakes!).

Now I think that Armand wants an equivalent to %S.  Presumably the
commands typed in will all be in a history file somewhere.

I may be wrong, of course!

John

On Apr 3, 4:15 am, William Stein  wrote:
> On Thu, Apr 2, 2009 at 8:04 PM, ARMAND BRUMER  wrote:
> > Dera William,
>
> > Thanks for the detailed answer. Unfortunately, I am dealing with collections
> > of many tens of thousands of "curves". I was able to load them into sage
> > with
>
> > load /Users/armandbrumer/sage/TORNOTSS6short.sage
>
> > I want to  reverse the process after using sage to modify the lists, for
> > instance by using liu's program.
>
> > If I understand you properly, there is no simple analogous command to save
> > my list of lists in text format.  So, what I need can  be done only by
> > changing the data to strings and then saving those strings...
>
> I'm still not sure what you're asking, but if you want to save objects
> (in a binary compressed format), in Sage you can save almost any data
> structure to disk, and load it back.  For this, the situation
> regarding this is *VASTLY BETTER* in Sage than it is in Magma.   The
> command that does this is simply called "save".  Here are some
> examples:
>
> sage: a = matrix(2, [1,2,3,-5/2])
> sage: save(a, 'test.sobj')
> sage: load('test.sobj')
> [   12]
> [   3 -5/2]
>
> Here's an example involving starting with the curves of conductor up
> to 100 in Cremona, saving the list of them, loading it back into a new
> session, changing something about one, saving the list again, then
> loading that back and verifying that the change was saved:
>
> sage: E = list(cremona_curves([1..100]))
> sage: len(E)
> 306
> sage: save(E, 'E.sobj')
> sage:
> Exiting SAGE (CPU time 0m1.48s, Wall time 1m0.36s).
> D-69-91-159-158:tmp wstein$ sage
> --
> | Sage Version 3.4, Release Date: 2009-03-11 |
> | Type notebook() for the GUI, and license() for information.|
> --
> sage: E = load('E.sobj')
> sage: len(E)
> 306
> sage: E[0].armand = 'brumer'
> sage: save(E, 'E.sobj')
> sage:
> Exiting SAGE (CPU time 0m0.32s, Wall time 0m17.92s).
> D-69-91-159-158:tmp wstein$ sage
> --
> | Sage Version 3.4, Release Date: 2009-03-11 |
> | Type notebook() for the GUI, and license() for information.|
> --
> sage: E = load('E.sobj')
> sage: E[0].armand
> 'brumer'
>
> When it comes to lists of lists, here is an example both of saving to
> an sobj (compressed binary format) and saving to plain text:
>
> sage: E = list(cremona_curves([1..100]))
> sage: v = [e.a_invariants() for e in E]
> sage: v[:3]
> [[0, -1, 1, -10, -20], [0, -1, 1, -7820, -263580], [0, -1, 1, 0, 0]]
> sage: save(v,'v.sobj')
> sage: len(load('v.sobj'))
> 306
> sage: open('v.txt','w').write(str(v))
> sage: open('v.txt').read()[:300]
> '[[0, -1, 1, -10, -20], [0, -1, 1, -7820, -263580], [0, -1, 1, 0, 0],
> [1, 0, 1, 4, -6], [1, 0, 1, -36, -70], [1, 0, 1, -171, -874], [1, 0,
> 1, -1, 0], [1, 0, 1, -2731, -55146], [1, 0, 1, -11, 12], [1, 1, 1,
> -10, -10], [1, 1, 1, -135, -660], [1, 1, 1, -5, 2], [1, 1, 1, 35,
> -28], [1, 1, 1, -2160, -39540'
> sage: vv = sage_eval(open('v.txt').read())
> sage: vv == v
> True
>
> William
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: sage

2009-04-03 Thread simon . king

Dear John,

On Apr 3, 10:58 am, John Cremona  wrote:
> I think I do understand what Armand is asking.  Let's see:
...
> Now I think that Armand wants an equivalent to %S.  Presumably the
> commands typed in will all be in a history file somewhere.

Wouldn't using the notebook solve the problem? Or perhaps using sage-
mode in emacs? Sorry if my question is stupid, i don't work with
either of them. But I agree it would be nice to be able to save the
history when working in the command line version of Sage.

Yours,
  Simon

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: sage

2009-04-03 Thread David Joyner

On Fri, Apr 3, 2009 at 5:17 AM,   wrote:
>
> Dear John,
>
> On Apr 3, 10:58 am, John Cremona  wrote:
>> I think I do understand what Armand is asking.  Let's see:
> ...
>> Now I think that Armand wants an equivalent to %S.  Presumably the
>> commands typed in will all be in a history file somewhere.
>
> Wouldn't using the notebook solve the problem? Or perhaps using sage-
> mode in emacs? Sorry if my question is stupid, i don't work with
> either of them. But I agree it would be nice to be able to save the
> history when working in the command line version of Sage.


BTW, in linux, Konsole allows you to save the history as a text file.
The way you do this depends on the version you use, but it is
pretty easy to figure out.



>
> Yours,
>      Simon
>
> >
>

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: sage

2009-04-03 Thread Craig Citro

> Now I think that Armand wants an equivalent to %S.  Presumably the
> commands typed in will all be in a history file somewhere.
>

Yep, the commands do get stored in a history file -- it's
~/.sage/ipython/history-sage from your home directory. Also, from the
command line, you can do %history to see the history of the live
session (with numbers as headings). The code that does this is in
_ip.IP.magic_history -- we could definitely write something that
extracts this data out into the same format Magma users might find
familiar, if that's desirable ... unless such a thing already exists?

-cc

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: sage

2009-04-03 Thread Dan Drake
On Fri, 03 Apr 2009 at 01:58AM -0700, John Cremona wrote:
> I think I do understand what Armand is asking.  Let's see:
> 
> Say I have been using Magma for half an hour.  I typed lots of stuff,
> including typos etc, and a whole lot of output has scrolled past.  Now
> I want to keep all the commands that I typed, put them in a file,
> sanitize them, ans use them later as a kind of script.  I can do that
> in Magma like this:
> 
[...]
> 
> Now I think that Armand wants an equivalent to %S.  Presumably the
> commands typed in will all be in a history file somewhere.

On the command line, there's log_text, log_html, and log_dvi. They
record (mostly) what you type into the session.

I recall fixing some nasty bugs in those functions, so if they've become
broken again I should take another look at them.

Dan

-- 
---  Dan Drake 
-  KAIST Department of Mathematical Sciences
---  http://mathsci.kaist.ac.kr/~drake


signature.asc
Description: Digital signature


[sage-support] Re: sage

2009-04-03 Thread Jason Grout

Dan Drake wrote:
> On Fri, 03 Apr 2009 at 01:58AM -0700, John Cremona wrote:
>> I think I do understand what Armand is asking.  Let's see:
>>
>> Say I have been using Magma for half an hour.  I typed lots of stuff,
>> including typos etc, and a whole lot of output has scrolled past.  Now
>> I want to keep all the commands that I typed, put them in a file,
>> sanitize them, ans use them later as a kind of script.  I can do that
>> in Magma like this:
>>
> [...]
>> Now I think that Armand wants an equivalent to %S.  Presumably the
>> commands typed in will all be in a history file somewhere.
> 
> On the command line, there's log_text, log_html, and log_dvi. They
> record (mostly) what you type into the session.
> 

I didn't know about these; these are really cool commands!

Is there maybe any way that the log_* commands could have an option to 
also include output? (maybe even typeset output for the dvi one and 
jsmath output for the html one...)

All three of the commands seemed to work for me.  I had some sort of 
error the first time I used log_dvi(), but it's worked every time since 
then.

Jason


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: sage

2009-04-03 Thread William Stein

On Fri, Apr 3, 2009 at 7:17 AM, Jason Grout  wrote:
>
> Dan Drake wrote:
>> On Fri, 03 Apr 2009 at 01:58AM -0700, John Cremona wrote:
>>> I think I do understand what Armand is asking.  Let's see:
>>>
>>> Say I have been using Magma for half an hour.  I typed lots of stuff,
>>> including typos etc, and a whole lot of output has scrolled past.  Now
>>> I want to keep all the commands that I typed, put them in a file,
>>> sanitize them, ans use them later as a kind of script.  I can do that
>>> in Magma like this:
>>>
>> [...]
>>> Now I think that Armand wants an equivalent to %S.  Presumably the
>>> commands typed in will all be in a history file somewhere.
>>
>> On the command line, there's log_text, log_html, and log_dvi. They
>> record (mostly) what you type into the session.
>>
>
> I didn't know about these; these are really cool commands!
>
> Is there maybe any way that the log_* commands could have an option to
> also include output? (maybe even typeset output for the dvi one and
> jsmath output for the html one...)
>
> All three of the commands seemed to work for me.  I had some sort of
> error the first time I used log_dvi(), but it's worked every time since
> then.

I wrote those commands in 2006 at Sage Days 1 after seeing the first
(not so good)attempt by some people to make an IPython GUI...  In a
sense they are a predecessor to the notebook, especially log_html().
I haven't used them myself in a long time.  Dan -- thanks for fixing
bugs in them, since I know they had "issues" when I wrote them!

 -- William

-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Problem in re-login to notebook using Mac

2009-04-03 Thread pong

I have just installed SAGE-3.4 on a Macbook (OS X 10.5.6), everything
seems fine except when I log out from a sage notebook session and try
relogin from the same page then I get an error. I'm pretty sure that
the password is correct cos I've just created it the first time I ran
notebook(). I even did notebook(reset=True) to reset the password but
it didn't help.

The username is "admin" and when I enter the password it brings me to
http://localhost:8000/login with a blank page instead of the
notebooks.

Any help?
I did a quick search with "MAC OS X notebook" in this group and didn't
find the answer of my question. Sorry if that has been asked before.

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Problem in re-login to notebook using Mac

2009-04-03 Thread kcrisman



On Apr 3, 12:04 pm, pong  wrote:
> I have just installed SAGE-3.4 on a Macbook (OS X 10.5.6), everything
> seems fine except when I log out from a sage notebook session and try
> relogin from the same page then I get an error. I'm pretty sure that
> the password is correct cos I've just created it the first time I ran
> notebook(). I even did notebook(reset=True) to reset the password but
> it didn't help.
>
> The username is "admin" and when I enter the password it brings me 
> tohttp://localhost:8000/loginwith a blank page instead of the
> notebooks.
>
> Any help?
> I did a quick search with "MAC OS X notebook" in this group and didn't
> find the answer of my question. Sorry if that has been asked before.

Are you getting the following title to the page?  Error | Sage
Notebook

Are you using Safari?  Does logging in work normally with Firefox?

If the answer to all this is yes, I have the same problem, but only
when logging in to our local server - my own computer logs me in
automatically as admin, I guess.  I haven't reported it because I
figured it was a problem with my Safari.  Please open a ticket if you
can replicate it with Safari and the title "Error | Sage Notebook",
and hopefully someone can get to the bottom of it.

- kcrisman
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Problem in re-login to notebook using Mac

2009-04-03 Thread Jose Guzman

kcrisman wrote:
>
> On Apr 3, 12:04 pm, pong  wrote:
>   
>> I have just installed SAGE-3.4 on a Macbook (OS X 10.5.6), everything
>> seems fine except when I log out from a sage notebook session and try
>> relogin from the same page then I get an error. I'm pretty sure that
>> the password is correct cos I've just created it the first time I ran
>> notebook(). I even did notebook(reset=True) to reset the password but
>> it didn't help.
>>
>> The username is "admin" and when I enter the password it brings me 
>> tohttp://localhost:8000/loginwith a blank page instead of the
>> notebooks.
>>
>> Any help?
>> I did a quick search with "MAC OS X notebook" in this group and didn't
>> find the answer of my question. Sorry if that has been asked before.
>> 
>
> Are you getting the following title to the page?  Error | Sage
> Notebook
>
> Are you using Safari?  Does logging in work normally with Firefox?
>
> If the answer to all this is yes, I have the same problem, but only
> when logging in to our local server - my own computer logs me in
> automatically as admin, I guess.  I haven't reported it because I
> figured it was a problem with my Safari.  Please open a ticket if you
> can replicate it with Safari and the title "Error | Sage Notebook",
> and hopefully someone can get to the bottom of it.
>
> - kcrisman
> >
>   
The same problem from my side when trying to log in the sagenb.org 
server. I use firefox (vimperator) under GNU/Debian Linux. The only 
solution I found was to clean the history.

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: how to read bitmap image files(.bmp) in sage

2009-04-03 Thread sageuser

Thanks for all the quick responses! This is exactly what I was looking
for.
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] error publishing worksheet at sagenb.org

2009-04-03 Thread Brian

When I publish a worksheet, I get a busted URL:

Worksheet is publicly viewable at http://:8000/home/pub/421
Published on April 03, 2009 05:19 PM

Brian
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: error publishing worksheet at sagenb.org

2009-04-03 Thread Timothy Clemans

Thanks for reporting a bug. We are aware of the issue which involves
address='' being set.

On Fri, Apr 3, 2009 at 8:20 PM, Brian  wrote:
>
> When I publish a worksheet, I get a busted URL:
>
> Worksheet is publicly viewable at http://:8000/home/pub/421
> Published on April 03, 2009 05:19 PM
>
> Brian
> >
>

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] help expressing formula

2009-04-03 Thread Brian

I was hoping to get help with using SAGE to plot this equation:
http://www.streetauthority.com/images/education/ytm.gif

This is the yield to maturity formula, expressing that a bond's price
is the sum of the present values of its future cash flows.

P = price of the bond
n = number of periods
C = coupon payment
r = required rate of return on this investment
F = maturity value
t = time period when payment is to be received

All variables are fixed except P and r, so my plot will be the
function P(r).

Once this is working, my next goal is to unfix n and have it vary on
the z axis.

A more basic question that could get me started is, how do I express
that summation?

Thanks, Brian

(Source: http://www.streetauthority.com/terms/y/yield-to-maturity.asp)
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: help expressing formula

2009-04-03 Thread Timothy Clemans

I'm not 100% sure but I think it would look something like

def maturity_formula(C, P, r):
return sum([C / (1 + r) ^ t + F / (1 + r) ^ n for t in range(1, n+1)])

On Fri, Apr 3, 2009 at 8:54 PM, Brian  wrote:
>
> I was hoping to get help with using SAGE to plot this equation:
> http://www.streetauthority.com/images/education/ytm.gif
>
> This is the yield to maturity formula, expressing that a bond's price
> is the sum of the present values of its future cash flows.
>
> P = price of the bond
> n = number of periods
> C = coupon payment
> r = required rate of return on this investment
> F = maturity value
> t = time period when payment is to be received
>
> All variables are fixed except P and r, so my plot will be the
> function P(r).
>
> Once this is working, my next goal is to unfix n and have it vary on
> the z axis.
>
> A more basic question that could get me started is, how do I express
> that summation?
>
> Thanks, Brian
>
> (Source: http://www.streetauthority.com/terms/y/yield-to-maturity.asp)
> >
>

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Plotting from linux console mode?

2009-04-03 Thread Alasdair

If I run a plot command from the linux console, the plot is created,
and displayed as an image in gqview (on my system).  Where does Sage
look for the application to display its plots?  I'd like to change
this, if possible, from gqview to ImageMagick's display.

Thanks,
Alasdair
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: help expressing formula

2009-04-03 Thread Brian

Thank you Timothy.  Here is the correct (I believe) code for that
equation.

def units(C, n, F, r):
return sum([C / (1 + r) ^ t for t in range(1, n+1)]) + F / (1 + r)
^ n

def price(C, n, F, r):
return 100 * (units(C, n, F, r) / F)

Here, units expresses the equation I linked to, and price gives the
scaled price, 100 being par.

For example, evaluating the expression below demonstrates the example
calculation from this site:
http://www.moneychimp.com/articles/finworks/fmbondytm.htm

units(70,4,1000,.0853)

That evaluates to ~950 as in the example, therefore giving a price of
~95:

price(70,4,1000,.0853)

And sure enough, plotting the price yield curve gives sensible
results:
plot(price(70,4,1000,var('y')),0,.2)

Now I would like to make a 3d plot where n and r are free.  The
trouble is, when I try it, I get the following error.  Would someone
point out my error?

plot(price(70,var('n'),1000,var('y')))

TypeError: range() integer start argument expected, got
sage.rings.integer.Integer.

Thanks, Brian

On Apr 3, 7:03 pm, Timothy Clemans  wrote:
> I'm not 100% sure but I think it would look something like
>
> def maturity_formula(C, P, r):
>     return sum([C / (1 + r) ^ t + F / (1 + r) ^ n for t in range(1, n+1)])
>
> On Fri, Apr 3, 2009 at 8:54 PM, Brian  wrote:
>
> > I was hoping to get help with using SAGE to plot this equation:
> >http://www.streetauthority.com/images/education/ytm.gif
>
> > This is the yield to maturity formula, expressing that a bond's price
> > is the sum of the present values of its future cash flows.
>
> > P = price of the bond
> > n = number of periods
> > C = coupon payment
> > r = required rate of return on this investment
> > F = maturity value
> > t = time period when payment is to be received
>
> > All variables are fixed except P and r, so my plot will be the
> > function P(r).
>
> > Once this is working, my next goal is to unfix n and have it vary on
> > the z axis.
>
> > A more basic question that could get me started is, how do I express
> > that summation?
>
> > Thanks, Brian
>
> > (Source:http://www.streetauthority.com/terms/y/yield-to-maturity.asp)
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: help expressing formula

2009-04-03 Thread William Stein

On Fri, Apr 3, 2009 at 7:45 PM, Brian  wrote:
>
> Thank you Timothy.  Here is the correct (I believe) code for that
> equation.
>
> def units(C, n, F, r):
>    return sum([C / (1 + r) ^ t for t in range(1, n+1)]) + F / (1 + r)
> ^ n
>
> def price(C, n, F, r):
>    return 100 * (units(C, n, F, r) / F)
>
> Here, units expresses the equation I linked to, and price gives the
> scaled price, 100 being par.
>
> For example, evaluating the expression below demonstrates the example
> calculation from this site:
> http://www.moneychimp.com/articles/finworks/fmbondytm.htm
>
> units(70,4,1000,.0853)
>
> That evaluates to ~950 as in the example, therefore giving a price of
> ~95:
>
> price(70,4,1000,.0853)
>
> And sure enough, plotting the price yield curve gives sensible
> results:
> plot(price(70,4,1000,var('y')),0,.2)
>
> Now I would like to make a 3d plot where n and r are free.  The
> trouble is, when I try it, I get the following error.  Would someone
> point out my error?
>
> plot(price(70,var('n'),1000,var('y')))
>
> TypeError: range() integer start argument expected, got
> sage.rings.integer.Integer.
>

The problem is that you're giving the symbolic variable "n" as input
to the range command (in your units function), but the range command
takes a pair of integers as input.

William

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Plotting from linux console mode?

2009-04-03 Thread William Stein

On Fri, Apr 3, 2009 at 7:43 PM, Alasdair  wrote:
>
> If I run a plot command from the linux console, the plot is created,
> and displayed as an image in gqview (on my system).  Where does Sage
> look for the application to display its plots?  I'd like to change
> this, if possible, from gqview to ImageMagick's display.


Set the environment variable SAGE_BROWSER.

William

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Plotting from linux console mode?

2009-04-03 Thread Alasdair

Thanks - in which file in the sage tree is this variable set?

-Alasdair

On Apr 4, 2:00 pm, William Stein  wrote:
> On Fri, Apr 3, 2009 at 7:43 PM, Alasdair  wrote:
>
> > If I run a plot command from the linux console, the plot is created,
> > and displayed as an image in gqview (on my system).  Where does Sage
> > look for the application to display its plots?  I'd like to change
> > this, if possible, from gqview to ImageMagick's display.
>
> Set the environment variable SAGE_BROWSER.
>
> William
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: help expressing formula

2009-04-03 Thread Brian

Indeed, thanks William.  I'm not understanding the problem though, as
range works with "ordinary" variables:

x=5
[t for t in range(1,x)]

Anyway, I changed the units function to not use a list comprehension,
and instead use this formula:
http://i.investopedia.com/inv/tutorials/site/advancedbond/yield9.GIF

The new units function:
def units(C, n, F, r):
return C * ((1 - (1 / (1 + r) ^ n)) / r) + F * (1 / (1 + r) ^ n)

And here we have arrived, successful, with the 3d plot expression:

plot3d(price(70,var('n'),1000,var('r')), (n,1,5), (r,0,5))

Hooray sage!  Very cool.

On Apr 3, 8:53 pm, William Stein  wrote:
> On Fri, Apr 3, 2009 at 7:45 PM, Brian  wrote:
>
> > Thank you Timothy.  Here is the correct (I believe) code for that
> > equation.
>
> > def units(C, n, F, r):
> >    return sum([C / (1 + r) ^ t for t in range(1, n+1)]) + F / (1 + r)
> > ^ n
>
> > def price(C, n, F, r):
> >    return 100 * (units(C, n, F, r) / F)
>
> > Here, units expresses the equation I linked to, and price gives the
> > scaled price, 100 being par.
>
> > For example, evaluating the expression below demonstrates the example
> > calculation from this site:
> >http://www.moneychimp.com/articles/finworks/fmbondytm.htm
>
> > units(70,4,1000,.0853)
>
> > That evaluates to ~950 as in the example, therefore giving a price of
> > ~95:
>
> > price(70,4,1000,.0853)
>
> > And sure enough, plotting the price yield curve gives sensible
> > results:
> > plot(price(70,4,1000,var('y')),0,.2)
>
> > Now I would like to make a 3d plot where n and r are free.  The
> > trouble is, when I try it, I get the following error.  Would someone
> > point out my error?
>
> > plot(price(70,var('n'),1000,var('y')))
>
> > TypeError: range() integer start argument expected, got
> > sage.rings.integer.Integer.
>
> The problem is that you're giving the symbolic variable "n" as input
> to the range command (in your units function), but the range command
> takes a pair of integers as input.
>
> William
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Problem in re-login to notebook using Mac

2009-04-03 Thread Crab

My answers to kcrisman are yes (Error|Sage Notebook), yes(using
Safari) and I don't know (I haven't tried firefox on Mac, used Firefox
for SAGE in Linux with no problems).

Okay I will open a ticket when I figured out how to do so.

On Apr 3, 9:38 am, kcrisman  wrote:
> On Apr 3, 12:04 pm, pong  wrote:
>
> > I have just installed SAGE-3.4 on a Macbook (OS X 10.5.6), everything
> > seems fine except when I log out from a sage notebook session and try
> > relogin from the same page then I get an error. I'm pretty sure that
> > the password is correct cos I've just created it the first time I ran
> > notebook(). I even did notebook(reset=True) to reset the password but
> > it didn't help.
>
> > The username is "admin" and when I enter the password it brings me 
> > tohttp://localhost:8000/loginwitha blank page instead of the
> > notebooks.
>
> > Any help?
> > I did a quick search with "MAC OS X notebook" in this group and didn't
> > find the answer of my question. Sorry if that has been asked before.
>
> Are you getting the following title to the page?  Error | Sage
> Notebook
>
> Are you using Safari?  Does logging in work normally with Firefox?
>
> If the answer to all this is yes, I have the same problem, but only
> when logging in to our local server - my own computer logs me in
> automatically as admin, I guess.  I haven't reported it because I
> figured it was a problem with my Safari.  Please open a ticket if you
> can replicate it with Safari and the title "Error | Sage Notebook",
> and hopefully someone can get to the bottom of it.
>
> - kcrisman
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: error publishing worksheet at sagenb.org

2009-04-03 Thread William Stein

2009/4/3 Timothy Clemans :
>
> Thanks for reporting a bug. We are aware of the issue which involves
> address='' being set.

I created a trac ticket about this earlier today:


http://trac.sagemath.org/sage_trac/ticket/5675

 -- William

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] jmol problem

2009-04-03 Thread Brian

When I go to this public worksheet, jmol renders as a black screen:
http://sagenb.org/home/pub/422/

Here is the output of the Java Console.

Java Plug-in 1.6.0_12
Using JRE version 1.6.0_12 Java HotSpot(TM) Client VM
User home directory = E:\Documents and Settings\brian

c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to 

Jmol applet jmolApplet0__1424380939856034__ destroyed
Jmol applet jmolApplet0__1672076516679526__ initializing
AppletRegistry.checkIn(jmolApplet0__1672076516679526__)
applet context: -applet
appletDocumentBase=http://sagenb.org/home/pub/422/
appletCodeBase=http://sagenb.org/java/jmol/
(C) 2008 Jmol Development
Jmol Version 11.6.16  2008-11-24 13:39
java.vendor:Sun Microsystems Inc.
java.version:1.6.0_12
os.name:Windows XP
memory:6.6/7.9
useCommandThread: false
appletId:jmolApplet0__1672076516679526__
urlImage=jar:http://sagenb.org/java/jmol/JmolApplet0.jar!/
jmol75x29x8.gif
FileManager opening http://sagenb.org/java/jmol/appletweb/SageMenu.mnu
defaults = "Jmol"
backgroundColor = "black"
language=en_US
FileManager opening 
http://sagenb.org/home/pub/422/cells/13/sage0-size500.jmol?1238821371
FileManager opening 
http://sagenb.org/home/pub/422/sage0-size500-117612907.jmol.zip
script compiler ERROR: command expected
line 1 command 1 of SCRIPT:
    
script ERROR: script compiler ERROR: command expected
line 1 command 1 of SCRIPT:
    
eval ERROR:
line 2 command 2 of file /home/pub/422/cells/13/sage0-size500.jmol?
1238821371:
 script >> "SCRIPT" <<
line 1 command 1:
 script >> "/home/pub/422/cells/13/sage0-size500.jmol?
1238821371" <<

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Problem in re-login to notebook using Mac

2009-04-03 Thread Timothy Clemans

There's a bug in the error.html template. I'm guessing the error
message would be about cookies not enable, see
http://trac.sagemath.org/sage_trac/ticket/4429 for the report on that
bug. As far as the error message not displaying that's fixed at
http://trac.sagemath.org/sage_trac/ticket/4135

On Sat, Apr 4, 2009 at 12:53 AM, Crab  wrote:
>
> My answers to kcrisman are yes (Error|Sage Notebook), yes(using
> Safari) and I don't know (I haven't tried firefox on Mac, used Firefox
> for SAGE in Linux with no problems).
>
> Okay I will open a ticket when I figured out how to do so.
>
> On Apr 3, 9:38 am, kcrisman  wrote:
>> On Apr 3, 12:04 pm, pong  wrote:
>>
>> > I have just installed SAGE-3.4 on a Macbook (OS X 10.5.6), everything
>> > seems fine except when I log out from a sage notebook session and try
>> > relogin from the same page then I get an error. I'm pretty sure that
>> > the password is correct cos I've just created it the first time I ran
>> > notebook(). I even did notebook(reset=True) to reset the password but
>> > it didn't help.
>>
>> > The username is "admin" and when I enter the password it brings me 
>> > tohttp://localhost:8000/loginwitha blank page instead of the
>> > notebooks.
>>
>> > Any help?
>> > I did a quick search with "MAC OS X notebook" in this group and didn't
>> > find the answer of my question. Sorry if that has been asked before.
>>
>> Are you getting the following title to the page?  Error | Sage
>> Notebook
>>
>> Are you using Safari?  Does logging in work normally with Firefox?
>>
>> If the answer to all this is yes, I have the same problem, but only
>> when logging in to our local server - my own computer logs me in
>> automatically as admin, I guess.  I haven't reported it because I
>> figured it was a problem with my Safari.  Please open a ticket if you
>> can replicate it with Safari and the title "Error | Sage Notebook",
>> and hopefully someone can get to the bottom of it.
>>
>> - kcrisman
> >
>

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: jmol problem

2009-04-03 Thread Timothy Clemans

I get the same. This historically has been a problem with the public
notebook(s).

On Sat, Apr 4, 2009 at 1:04 AM, Brian  wrote:
>
> When I go to this public worksheet, jmol renders as a black screen:
> http://sagenb.org/home/pub/422/
>
> Here is the output of the Java Console.
>
> Java Plug-in 1.6.0_12
> Using JRE version 1.6.0_12 Java HotSpot(TM) Client VM
> User home directory = E:\Documents and Settings\brian
> 
> c:   clear console window
> f:   finalize objects on finalization queue
> g:   garbage collect
> h:   display this help message
> l:   dump classloader list
> m:   print memory usage
> o:   trigger logging
> q:   hide console
> r:   reload policy configuration
> s:   dump system and deployment properties
> t:   dump thread list
> v:   dump thread stack
> x:   clear classloader cache
> 0-5: set trace level to 
> 
> Jmol applet jmolApplet0__1424380939856034__ destroyed
> Jmol applet jmolApplet0__1672076516679526__ initializing
> AppletRegistry.checkIn(jmolApplet0__1672076516679526__)
> applet context: -applet
> appletDocumentBase=http://sagenb.org/home/pub/422/
> appletCodeBase=http://sagenb.org/java/jmol/
> (C) 2008 Jmol Development
> Jmol Version 11.6.16  2008-11-24 13:39
> java.vendor:Sun Microsystems Inc.
> java.version:1.6.0_12
> os.name:Windows XP
> memory:6.6/7.9
> useCommandThread: false
> appletId:jmolApplet0__1672076516679526__
> urlImage=jar:http://sagenb.org/java/jmol/JmolApplet0.jar!/
> jmol75x29x8.gif
> FileManager opening http://sagenb.org/java/jmol/appletweb/SageMenu.mnu
> defaults = "Jmol"
> backgroundColor = "black"
> language=en_US
> FileManager opening 
> http://sagenb.org/home/pub/422/cells/13/sage0-size500.jmol?1238821371
> FileManager opening 
> http://sagenb.org/home/pub/422/sage0-size500-117612907.jmol.zip
> script compiler ERROR: command expected
> line 1 command 1 of SCRIPT:
>            
> script ERROR: script compiler ERROR: command expected
> line 1 command 1 of SCRIPT:
>            
> eval ERROR:
> line 2 command 2 of file /home/pub/422/cells/13/sage0-size500.jmol?
> 1238821371:
>         script >> "SCRIPT" <<
> line 1 command 1:
>         script >> "/home/pub/422/cells/13/sage0-size500.jmol?
> 1238821371" <<
>
> >
>

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: jmol problem

2009-04-03 Thread William Stein

2009/4/3 Timothy Clemans :
>
> I get the same. This historically has been a problem with the public
> notebook(s).

I 100% disagree.   This has *not* historically been a problem with the
public notebooks. I have used them millions of times with numerous
browsers from many places to draw 3d plots using jmol.

I just did the same plot on another public notebook server (on the
same machine) and it works fine:

http://demo2.sagenb.org/home/pub/3/

There is a serious problem with the Linux install (or vmware virtual
machine) that currently hosts sagenb.org, which manifest itself about
2 days ago -- for some reason the OS is randomly killing processes.
This could be the result of some sort of attack, or just some other
problem; I don't know.   That's probably what is responsible for your
graph at sagenb.org to not work.  I'm actually very surprised
http://sagenb.org is working at all.

William

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: help expressing formula

2009-04-03 Thread William Stein

2009/4/3 Brian :
>
> Indeed, thanks William.  I'm not understanding the problem though, as
> range works with "ordinary" variables:
>
> x=5
> [t for t in range(1,x)]

Here x "is" (or rather -- points to) the constant integer 5.  It's not
a symbolic variable.
If you do

   x = var('x')

then x is a symbolic variable.

>
> Anyway, I changed the units function to not use a list comprehension,
> and instead use this formula:
> http://i.investopedia.com/inv/tutorials/site/advancedbond/yield9.GIF
>
> The new units function:
> def units(C, n, F, r):
>    return C * ((1 - (1 / (1 + r) ^ n)) / r) + F * (1 / (1 + r) ^ n)
>
> And here we have arrived, successful, with the 3d plot expression:
>
> plot3d(price(70,var('n'),1000,var('r')), (n,1,5), (r,0,5))
>
> Hooray sage!  Very cool.
>
> On Apr 3, 8:53 pm, William Stein  wrote:
>> On Fri, Apr 3, 2009 at 7:45 PM, Brian  wrote:
>>
>> > Thank you Timothy.  Here is the correct (I believe) code for that
>> > equation.
>>
>> > def units(C, n, F, r):
>> >    return sum([C / (1 + r) ^ t for t in range(1, n+1)]) + F / (1 + r)
>> > ^ n
>>
>> > def price(C, n, F, r):
>> >    return 100 * (units(C, n, F, r) / F)
>>
>> > Here, units expresses the equation I linked to, and price gives the
>> > scaled price, 100 being par.
>>
>> > For example, evaluating the expression below demonstrates the example
>> > calculation from this site:
>> >http://www.moneychimp.com/articles/finworks/fmbondytm.htm
>>
>> > units(70,4,1000,.0853)
>>
>> > That evaluates to ~950 as in the example, therefore giving a price of
>> > ~95:
>>
>> > price(70,4,1000,.0853)
>>
>> > And sure enough, plotting the price yield curve gives sensible
>> > results:
>> > plot(price(70,4,1000,var('y')),0,.2)
>>
>> > Now I would like to make a 3d plot where n and r are free.  The
>> > trouble is, when I try it, I get the following error.  Would someone
>> > point out my error?
>>
>> > plot(price(70,var('n'),1000,var('y')))
>>
>> > TypeError: range() integer start argument expected, got
>> > sage.rings.integer.Integer.
>>
>> The problem is that you're giving the symbolic variable "n" as input
>> to the range command (in your units function), but the range command
>> takes a pair of integers as input.
>>
>> William
> >
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Plotting from linux console mode?

2009-04-03 Thread William Stein

2009/4/3 Alasdair :
>
> Thanks - in which file in the sage tree is this variable set?
>
> -Alasdair

In misc/viewer.py


sage: search_src('SAGE_BROWSER')
misc/viewer.py:if os.environ.has_key('SAGE_BROWSER'):
misc/viewer.py:BROWSER = os.environ['SAGE_BROWSER']
server/notebook/notebook_object.py:
SAGE_BROWSER environment variable, e.g., by putting
server/notebook/notebook_object.py: export
SAGE_BROWSER="firefox"


>
> On Apr 4, 2:00 pm, William Stein  wrote:
>> On Fri, Apr 3, 2009 at 7:43 PM, Alasdair  wrote:
>>
>> > If I run a plot command from the linux console, the plot is created,
>> > and displayed as an image in gqview (on my system).  Where does Sage
>> > look for the application to display its plots?  I'd like to change
>> > this, if possible, from gqview to ImageMagick's display.
>>
>> Set the environment variable SAGE_BROWSER.
>>
>> William
> >
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Plotting from linux console mode?

2009-04-03 Thread William Stein

2009/4/3 Alasdair :
>
> Thanks - in which file in the sage tree is this variable set?

You might have been asking how to set it yourself.  In linux (well,
bash) do e.g.,


 export SAGE_BROWSER="firefox"


 -- William

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] On best way to use plot() with functions...

2009-04-03 Thread Chris Seberino


def g(x):
return numerical_integral(sin(t),0,x)[0]

For the function g, this works:

sage: plot(g,x,2,4)

but not this

sage:plot(g(x), x, 2, 4)

If I'm not mistaken, the first form of plot above works with ALL
functions right?  So is there any reason to ever bother with second
form just because I *can* use it with symbolic functions?

Chris
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---