[sage-support] Re: Sagetex issue

2010-03-02 Thread Adrián
Thanks, that's just what I needed, just the load instruction. I
finally got
it to work somehow.
Although it seems kind of weird that I get an error message after
I load the .sage file in the console, it always ends saying

IOError: [Errno 2] No such file or directory: 'sagetex_practice.sage'

but it doesn't matter since the .sout file always appears with an
extension
.sout.tmp in my home directory. Thanks a lot Berkin.

On 2 mar, 01:50, Berkin Malkoc  wrote:
> > The question I have is, how do I get SAGE to work out the resulting
> > .sage file that Latex creates after I compile it? I've read the
> > information
>
> In sage console you can simply run "load your_file.sage"
>
> On Tue, Mar 2, 2010 at 2:13 AM, Minh Nguyen  wrote:
> > Hi,
>
> > On Tue, Mar 2, 2010 at 10:18 AM, Adrián  wrote:
>
> > 
>
> > > Any help would be more than welcome.
>
> > Here are three sources of information on installing/using SageTeX:
>
> > * Make SageTeX known to TeX
> >http://www.sagemath.org/doc/installation/sagetex.html
>
> > * Installing and using SageTeX
> >http://www.sagemath.org/doc/reference/other/sagetex.html
>
> > * Using SageTeX
> >http://www.sagemath.org/doc/tutorial/sagetex.html
>
> > Another source of information is the README file of the SageTeX spkg.
> > Get hold of the SageTeX spkg, i.e. the compressed tarball
> > sagetex-2.2.3.spkg under this directory of your local Sage source
> > installation
>
> > SAGE_ROOT/spkg/standard
>
> > or from this URL
>
> >http://modular.math.jmu.edu/spkg/standard/sagetex-2.2.3.spkg
>
> > Uncompress that spkg using something like the following
>
> > tar -jxf sagetex-2.2.3.spkg
>
> > Then read the file
>
> > sagetex-2.2.3/src/README
>
> > --
> > Regards
> > Minh Van Nguyen
>
> > --
> > 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
> > URL:http://www.sagemath.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
URL: http://www.sagemath.org


[sage-support] Re: Solve fails for a cubic

2010-03-02 Thread Sharpie
On Mar 2, 8:10 pm, Sharpie  wrote:
> So I guess at this point my question is: is there another way to
> convert from a symbolic polynomial equation to a Polynomial Ring?  I
> The methods I used feel very hacky and I don't trust them.

Ok, so I think I found something in the manual page "Conversion of
symbolic expressions to other types" that finally clicked.  If I have:


y2 = var( 'y2' )

altDepths = 1.54027132807289 == y2 + 0.0906104881640050/y2^2 + 0.15


I can use the following function, to convert to a polynomial quotient
and then use Alex's tip to pick off the numerator and feed it to
roots():


from sage.symbolic.expression_conversions import PolynomialConverter

PolynomialConverter( y2, RR ).relation( altDepths,
operator.eq ).numerator().roots()

[(-0.236040904804615, 1), (0.286518993973450, 1), (1.33979323890406,
1)]


Probably as clean and straight-forwards as I will be able to find-- if
anyone knows a better way I would love to hear it!

-Charlie

-- 
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
URL: http://www.sagemath.org


[sage-support] Re: Solve fails for a cubic

2010-03-02 Thread Sharpie
On Mar 2, 2:34 pm, Alex Ghitza  wrote:
> The way I see it, it is not actually a question about the variable
> representing a real number; it is more a question of using polynomials
> and their specialised built-in roots() method rather than symbolic
> functions and the general-purpose solve().
>
>
> There might be an elegant way of doing this with symbolics, but I don't
> know it.  However, if I move everything to one side of the == sign, your
> f is a rational function (quotient of polynomials with real
> coefficients).  So my approach would be:
>
> sage: R. = RR[]               # polynomials in y2 with real coefficients
> sage: f = y2 + 0.0906104881640050/y2^2 + 0.150 - 1.54027132807289
> sage: f.numerator().roots()
> [(-0.236040904804615, 1), (0.286518993973450, 1), (1.33979323890405, 1)]
>
> Note that the first line tells Sage what y2 is: the variable in a
> polynomial ring with real coefficients.  Then when you define f, Sage
> automatically knows that f is a rational function (in particular, it's
> not an element of R, but of the fraction field of R:
> sage: parent(f)
> Fraction Field of Univariate Polynomial Ring in y2 over Real Field with 53 
> bits of precision
> )
>
> Anyway, I think it would make perfect sense to be able to just do
> f.roots() for a rational function and have this return the roots of the
> numerator, so that would make this a bit nicer.  For that matter, I
> think that for a rational function f we should have both f.zeroes() and
> f.poles() (and maybe also f.divisor()), and have f.roots() be an alias
> for f.zeroes().
>
> And again, maybe there should be a nice way of doing this within
> symbolics and somebody else can comment on this.
>
> Best,
> Alex
>
> --
> Alex Ghitza --http://aghitza.org/
> Lecturer in Mathematics -- The University of Melbourne -- Australia

Thanks again for taking the time to reply and please excuse my
apparent stubbornness-- I'm still trying to wrap my head around how/
why SAGE does some of the things it does so that I can build a
workflow around it.

My problem is that I can't figure out a way to start in the polynomial
ring because I'm starting with a system of physically based equations
and I would like to shown them with both a left and a right hand
side.  For example, the problem I was considering concerned open
channel flow in the presence of an obstruction.  The quantities of
interest are the water heights (y) and velocities (V) both upstream
and downstream of the obstruction which has a height of delta z.  The
important relationships are conservation of energy and continuity:


y1, y2, V1, V2, delZ, g = var( 'y1 y2 V1 V2 delZ g' )

energyBal = V1^2 / (2*g) + y1 == V2^2 / (2*g) + y2 + delZ

continuityEq = V1 * y1 == V2 * y2


I know some given information:


knownInfo = {
  V1:8/9,
  y1:1.5,
  delZ:  0.15,
  g:  9.81
}


So, then I can apply some substitution and solving to come up with my
cubic:


altDepths = energyBal.subs( continuityEq.subs(knownInfo).solve(V2)
[0] ).subs(knownInfo)
print( altDepths )

1.54027132807289 == y2 + 0.0906104881640050/y2^2 + 0.150


The whole reason I've been sticking so stubbornly to symbolic
expressions is that Polynomial Rings won't let me write the equations
in "natural" form-- such as showing that the analysis starts from the
assumption that E1 = E2.  So here I am looking for a nice way to
coerce what is obviously a polynomial to a Polynomial Ring.  At first,
I thought the obvious answer would be to call:

altDepths.poly( y2 )

But that doesn't work.  The poly() function appears to only deal with
re-arranging the coefficients of the polynomial if it is expressed in
more than one symbol. The behavior I would expect would be to also
examine the exponents of the polynomial terms in addition to the
coefficients-- something like the following:


def asPoly( express, sym ):
# Subtract everything to the left hand side
express = express - express.rhs()

# Recover coefficients for symbol
coeffList = express.coeffs( sym )

# Recover negative polynomial powers
powers = [ coef[1] for coef in coeffList if coef[1] < 0 ]

# If there are negative polynomial powers, multiply the
# expression by the absolute value of the smallest one.
if len( powers ):
express = express * sym ^ abs( min( powers ) )

return( express.full_simplify() )


Please excuse the code-- that was my very first python function and
I'm sure I abused most every language construct I used.  It does what
I want, but there's still some weirdness that throws me off:


asPoly( altDepths, y2 )

-y2^3 + 1.39027132807*y2^2 - 0.090610488164 == 0
# Looks good


asPoly( altDepths, y2 ).is_polynomial()

False
# Fail.

asPoly( altDepths, y2 ).polynomial( RR ).roots()

[(-0.236040904804615, 1), (0.286518993973450, 1), (1.33979323890406,
1)]
# But it still gives me what I wanted


So I guess at this point my question is: is there another way to
convert from a symbolic polynomial equation to a P

[sage-support] Re: quitting local sage notebook

2010-03-02 Thread Simon
If you didn't start the sage server through a terminal, then the above
won't work.
I have a script that contains:

#!/bin/sh
kill -9 `cat $HOME/.sage/sage_notebook.sagenb/twistd.pid`

It kills the entire sage process tree.


On Mar 2, 10:53 am, "D.C. Ernst"  wrote:
> Thanks!
>
> On Mar 1, 3:00 pm, William Stein  wrote:
>
> > On Mon, Mar 1, 2010 at 10:30 AM, Robert Bradshaw
>
> >  wrote:
> > > On Mar 1, 2010, at 9:02 AM, Dana Ernst wrote:
>
> > >> What's the proper way to quit a local sage notebook?  I've been signing
> > >> out of the web browser and then quitting terminal, which kills anything
> > >> running.  I have OSX 10.6.  Is this what you are supposed to do?
>
> > > You can kill the sage -notebook process with two interrupts (control-C).
>
> > I think one control-C now works.  (It used to be 2.)
>
> > 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
URL: http://www.sagemath.org


Re: [sage-support] image of a complex function

2010-03-02 Thread David Joyner
Does
http://trac.sagemath.org/sage_trac/ticket/6648
help?


On Tue, Mar 2, 2010 at 6:06 PM, davidp  wrote:
> For a class I am teaching, I would like to display an image in the
> plane---say a png-file--- and show how it is transformed under a
> complex function f: C --> C.  What is the best way to do this?
>
> Thanks,
> Dave
>
> --
> 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
> URL: http://www.sagemath.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
URL: http://www.sagemath.org


[sage-support] image of a complex function

2010-03-02 Thread davidp
For a class I am teaching, I would like to display an image in the
plane---say a png-file--- and show how it is transformed under a
complex function f: C --> C.  What is the best way to do this?

Thanks,
Dave

-- 
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
URL: http://www.sagemath.org


Re: [sage-support] Re: Solve fails for a cubic

2010-03-02 Thread Alex Ghitza
On Tue, 2 Mar 2010 05:27:45 -0800 (PST), Sharpie  wrote:
> Thanks for the reply Alex. I think I understand that by choosing a
> variable of the appropriate type, in this case one that is restricted
> to the real numbers, the roots can be determined in a straight-forward
> manner.

The way I see it, it is not actually a question about the variable
representing a real number; it is more a question of using polynomials
and their specialised built-in roots() method rather than symbolic
functions and the general-purpose solve().

> I had some more problems, but finally figured out how to coerce a
> expression of type symbolic to the real ring through a somewhat
> convoluted application of multiplication, full_simplify() and
> polynomial().
> 
> The cubic is the result of balancing a system of conservation
> equations and then substituting in known information:
> 
> y2 = var( 'y2' )
> 
> f  =  1.54027132807289 == y2 + 0.0906104881640050/y2^2 +
> 0.150
> 
> # Multiply to eliminate fractions.
> f  = f * y2^2
> 
> f.full_simplify().polynomial(RR).roots()
> 
> [(-0.236040904804615, 1), (0.286518993973450, 1), (1.33979323890405,
> 1)]

There might be an elegant way of doing this with symbolics, but I don't
know it.  However, if I move everything to one side of the == sign, your
f is a rational function (quotient of polynomials with real
coefficients).  So my approach would be:

sage: R. = RR[]   # polynomials in y2 with real coefficients
sage: f = y2 + 0.0906104881640050/y2^2 + 0.150 - 1.54027132807289
sage: f.numerator().roots()
[(-0.236040904804615, 1), (0.286518993973450, 1), (1.33979323890405, 1)]

Note that the first line tells Sage what y2 is: the variable in a
polynomial ring with real coefficients.  Then when you define f, Sage
automatically knows that f is a rational function (in particular, it's
not an element of R, but of the fraction field of R:
sage: parent(f)
Fraction Field of Univariate Polynomial Ring in y2 over Real Field with 53 bits 
of precision
)

Anyway, I think it would make perfect sense to be able to just do
f.roots() for a rational function and have this return the roots of the
numerator, so that would make this a bit nicer.  For that matter, I
think that for a rational function f we should have both f.zeroes() and
f.poles() (and maybe also f.divisor()), and have f.roots() be an alias
for f.zeroes().

And again, maybe there should be a nice way of doing this within
symbolics and somebody else can comment on this.


Best,
Alex

-- 
Alex Ghitza -- http://aghitza.org/
Lecturer in Mathematics -- The University of Melbourne -- Australia

-- 
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
URL: http://www.sagemath.org


Re: [sage-support] Re: Setting up a sage server securely for students' use

2010-03-02 Thread David Kirkby
On 2 March 2010 21:44, Andrzej Giniewicz  wrote:
>> How about a new "Administering Sage" book added to the documentation?
>> Setting up a campus server, security concerns, etc., could be noted in it.
>
> any news on this topic? I'll need something similar soon so I wonder
> if I should use Byungchuls description and some digging or there is
> already some draft of such document in one place somewhere, first time
> I will use sage outside of my local machine or from server hosted
> elsewhere
>
> Andrzej.
>
> --
> 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
> URL: http://www.sagemath.org
>

There are certainly some aspects which were not mentioned above.

1) How to start the server. You don't want to be in a position that if
the system gets rebooted, a power failure etc, that someone has to
manually restart the server.

The exact method of doing this would depend on your operating system.
I know I did this for Solaris 10, but there's not a lot of point in
sharing that in detail here.

But basically the root user must start the server, but you don't want
to run the server as root. So something like

   su - server /local-bins/start-sage

in a script which starts at boot. The 'su - server' makes whatever
runs in  /local-bins/start-sage run as the user 'server' and not as
'root'.

On Solaris one would ideally use the service management facility (SMF)
to start the process. That can then restart the server should it die
for any reason. When I set up

http://t2nb.math.washington.edu:8000

I did not use SMF, but that is the best way to do it on Solaris. I
used a simple startup script. That means the server would restart if
the system was booted, but it would not restart if a command caused it
to die. Since there have been instances of reported commands that can
crash the server, it would be sensible to have some way of ensuring it
gets restarted if it does crash. However, the SMF in Solaris would not
keep trying and trying - if it failed too often then it would be
considered a fault, and no further attempts made to restart it.

2) Another point is that I do not believe the options that would
appear to be available to sage actually work as they should do. In
particular, I was unable to get the server pool to work as a command
line option. Instead I use a python file - basically a slightly
modified one that William sent me.

# cat  /local-bins/start-sage
#!/usr/bin/env bash
nohup /homes/server/sage-4.3.0.1-Solaris-10-SPARC-sun4u-or-sun4v/sage
/homes/server/notebook.py >>  /homes/server/logfile.out&

The contents of  /homes/server/notebook.py are

# cat notebook.py
import sagenb.notebook.notebook_object as n

server_pool=['sa...@localhost']

n.notebook('sage_notebook', port=8000, accounts=True, address='',
 server_pool = server_pool, ulimit='-u 1000 -v 100 -t 3600',
open_viewer=False, timeout=20*60, secure=False, port_tries=0)


(I've not no idea if those are optimal in any way)

3) When I set this up on Solaris, I set it up in a 'zone'. I don't
know if Linux has any similar thing, but basically it is like a jail.
Even if a hacker manages to get root access in the zone, he is
confined to it. I've also limited the amount of memory and number of
CPUs that can be used in that zone.

I should add, I have never set up a server which is getting much use.
I only ever set them up on Solaris, and only recently has Sage run on
Solaris properly.


Dave

-- 
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
URL: http://www.sagemath.org


[sage-support] Re: Setting up a sage server securely for students' use

2010-03-02 Thread Jason Grout

On 03/02/2010 03:44 PM, Andrzej Giniewicz wrote:

How about a new "Administering Sage" book added to the documentation?
Setting up a campus server, security concerns, etc., could be noted in it.


any news on this topic? I'll need something similar soon so I wonder
if I should use Byungchuls description and some digging or there is
already some draft of such document in one place somewhere, first time
I will use sage outside of my local machine or from server hosted
elsewhere



I've put up my notes here: 
http://wiki.sagemath.org/DanDrake/JustEnoughSageServer#OtherInstructions 
and I've been updating them as I tweak our campus sage server.


Thanks,

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
URL: http://www.sagemath.org


Re: [sage-support] Re: Setting up a sage server securely for students' use

2010-03-02 Thread Andrzej Giniewicz
> How about a new "Administering Sage" book added to the documentation?
> Setting up a campus server, security concerns, etc., could be noted in it.

any news on this topic? I'll need something similar soon so I wonder
if I should use Byungchuls description and some digging or there is
already some draft of such document in one place somewhere, first time
I will use sage outside of my local machine or from server hosted
elsewhere

Andrzej.

-- 
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
URL: http://www.sagemath.org


[sage-support] Issues plotting a tree

2010-03-02 Thread M. Yurko
Hello,

I've recently been creating some diagrams of trees with sage and have
run into some difficulties getting the graphs to look decent. I have
frequently run into issues with labels of vertices overlapping. Is
there anyway to enforce a distance between vertices or otherwise
ensure that the labels don't overlap? I've tried fiddling with the
option of the show() method of the Graphics object, but I haven't had
any luck. In particular, changing the aspect_ratio setting only seems
to shrink the graph until it is unreasonably small. I would appreciate
any suggestions that anyone would have.

Thanks,
Mike Yurko

-- 
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
URL: http://www.sagemath.org


[sage-support] Re: strange 3d plot

2010-03-02 Thread ma...@mendelu.cz


On 2 bře, 20:29, Jason Grout  wrote:
> The patch should pass doctests, correct the problem you noticed, and be
> ready for review.
>

Incredibly fast, thank you!

Robert Marik

-- 
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
URL: http://www.sagemath.org


[sage-support] Re: strange 3d plot

2010-03-02 Thread Jason Grout

On 03/02/2010 09:21 AM, ma...@mendelu.cz wrote:

Dear sage-support

If I plot 3d graph using

sage: plot3d(sqrt(sin(x)*sin (y)), (x,0,12),(y,0,12) )

the output looks fine. The output of

sage: plot3d(sqrt(sin(x)*sin (y)), (x,0,2*pi),(y,0,2*pi) )

should be different but it is completely wrong (no graph and bounds
for z from 0.0 to 0.0156).
The plot for

sage: plot3d(sqrt(sin(x)*sin (y)), (x,0,(2*pi+pi/2)),(y,0,(2*pi+pi/
2)) )

looks fine again. Is it a bug in code for plot3d when determing z-
range?  Is it possible to force my z-range to show command?



The problem is that the point comparison function (that finds the 
minimum and maximum points of the function) does not account for the 
fact that the NaN values generated by the function are both not less and 
not greater than any finite number.  I've posted a patch to 
http://trac.sagemath.org/sage_trac/ticket/8424 which corrects this 
problem for two of the three places that points are compared in the 3d 
plotting code.  The third place is plot/plot3d/transform.pyx, and I 
don't have the time now to make sure my fix is right for that file or 
write the necessary doctests in that file to get this patch accepted.


The patch should pass doctests, correct the problem you noticed, and be 
ready for review.


Robert Bradshaw: you'd be the most natural person to review this patch, 
and it's really small.  Performance-wise, I see a slight performance 
increase after applying the patch in calculating the bounding box for 
the function above.


David Kirkby: I use the INFINITY #def'd constant and a c99 function 
isfinite from GCC's math.h.  Will these pose a problem on Solaris?


Thanks,

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
URL: http://www.sagemath.org


Re: [sage-support] Re: numerator has a funny parent() -- intentional ?

2010-03-02 Thread Robert Bradshaw

On Mar 1, 2010, at 11:46 AM, Pierre wrote:


oooh wait wait wait. I've said something totally confusing.

My previous two posts apply to rational fractions... for which indeed,
the numerator method gives the 'correct' answer ! The issue I raised
in my original post is the 'funny' behaviour when you ask for the
numerator of something in QQ[x] -- which, come to think of it, is
mathematically a little unsound. I just totally assumed this should
give the same answer as coercing into the field of rational fractions
and then applying numerator(), but it doesn't. You (Robert) assumed
something absolutely different.

(Now i still think it would be less surprising is sage acted as i
suggested, but i don't have strong feelings about it anymore :) )


In terms of usefulness, since for f(x) in QQ[x] we have f(x) = f(x)/1  
in QQ(x), coercing to the fraction field yields less information. I  
think things are more obvious to think about in terms of the  
denominator (which, for example, is used in matrices and polynomials  
over Q to "clear the denominator" to get something over the integers),  
and the numerator is then defined to agree with that.


Also, note that in QQ(x) the numerator/denominator are only defined up  
to a unit, so the currently returned answer is still valid there  
(though as you said has a different parent than you were expecting).


- Robert


--
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
URL: http://www.sagemath.org


[sage-support] Re: strange 3d plot

2010-03-02 Thread Jason Grout

On 03/02/2010 09:21 AM, ma...@mendelu.cz wrote:

Dear sage-support

If I plot 3d graph using

sage: plot3d(sqrt(sin(x)*sin (y)), (x,0,12),(y,0,12) )

the output looks fine. The output of

sage: plot3d(sqrt(sin(x)*sin (y)), (x,0,2*pi),(y,0,2*pi) )

should be different but it is completely wrong (no graph and bounds
for z from 0.0 to 0.0156).
The plot for

sage: plot3d(sqrt(sin(x)*sin (y)), (x,0,(2*pi+pi/2)),(y,0,(2*pi+pi/
2)) )

looks fine again. Is it a bug in code for plot3d when determing z-
range?  Is it possible to force my z-range to show command?

Many thanks
Robert




Yes, it does look like a bug.  I've published a relevant worksheet here: 
http://sagenb.org/home/pub/1706.  Notice that if you rotate the first 
plot so that the positive Z axis is pointing into the screen, you do see 
the plot, though the z-range on the plot make it a very funny looking 
graph.  You'll notice that the worksheet also prints out the evaluations 
of the function.


Thanks,

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
URL: http://www.sagemath.org


[sage-support] Re: numerator has a funny parent() -- intentional ?

2010-03-02 Thread luisfe
> -For the denominator: if there is a denominator function for the
> coefficients and these denominators have a lcm function, then return
> the lcm of the coefficients. This is an element of K, not K[x1,...,xn]

ooops
This sould read an element of wherever the denominator of elements in
K live.

-- 
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
URL: http://www.sagemath.org


[sage-support] Re: numerator has a funny parent() -- intentional ?

2010-03-02 Thread luisfe


On 1 mar, 20:46, Pierre  wrote:
> oooh wait wait wait. I've said something totally confusing.
>
> My previous two posts apply to rational fractions... for which indeed,
> the numerator method gives the 'correct' answer ! The issue I raised
> in my original post is the 'funny' behaviour when you ask for the
> numerator of something in QQ[x] -- which, come to think of it, is
> mathematically a little unsound. I just totally assumed this should
> give the same answer as coercing into the field of rational fractions
> and then applying numerator(), but it doesn't. You (Robert) assumed
> something absolutely different.
>
> (Now i still think it would be less surprising is sage acted as i
> suggested, but i don't have strong feelings about it anymore :) )
>
> so in any case, having realized this, i have found an ugly fix :
>
> sage: N= P.parent().fraction_field()(P).numerator()   # gives what i
> want !! always work !

Yes, this is intentional, I think that it is used somewhere for number
theory. As pointed out, there is no good definition for numerator of
an element in QQ[x].

The current implementation for polynomial rings K[x1,..,xn] is as
following:

-For the denominator: if there is a denominator function for the
coefficients and these denominators have a lcm function, then return
the lcm of the coefficients. This is an element of K, not K[x1,...,xn]
-If the previous computation fails, then return K(1) not K[x1,...,xn]
(1)

The numerator is the original polynomial times its denominator. This
is always in K[x1,..,xn]

It has its drawbacks, as you have found. In particular, the numerator
of an element in QQ[x] is not necessarily the same as the numerator of
the same element in QQ(x).

It has its advantages though. If you try this:

sage: K=QQ['x']
sage: L=K.fraction_field()['y']
sage: f=L.random_element()
sage: f.numerator()
sage: QQ['x','y'](f.numerator())

f lives in Q(x)[y], but its numerator can be coerced to Q[x,y] wich is
nice for some computations. So, in fact, it depends much on what are
you computing.

-- 
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
URL: http://www.sagemath.org


[sage-support] strange 3d plot

2010-03-02 Thread ma...@mendelu.cz
Dear sage-support

If I plot 3d graph using

sage: plot3d(sqrt(sin(x)*sin (y)), (x,0,12),(y,0,12) )

the output looks fine. The output of

sage: plot3d(sqrt(sin(x)*sin (y)), (x,0,2*pi),(y,0,2*pi) )

should be different but it is completely wrong (no graph and bounds
for z from 0.0 to 0.0156).
The plot for

sage: plot3d(sqrt(sin(x)*sin (y)), (x,0,(2*pi+pi/2)),(y,0,(2*pi+pi/
2)) )

looks fine again. Is it a bug in code for plot3d when determing z-
range?  Is it possible to force my z-range to show command?

Many thanks
Robert

-- 
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
URL: http://www.sagemath.org


[sage-support] Re: Solve fails for a cubic

2010-03-02 Thread Sharpie
On Mar 1, 3:02 am, Alex Ghitza  wrote:
> On Sun, 28 Feb 2010 23:02:08 -0800 (PST), Sharpie  
> wrote:
> > However, tonight I have been trying to solve an open channel flow
> > problem which requires me to find the roots of:
>
> >   y^3 - 1.39027132807289 * y^2 + 0.090610488164005 == 0
>
> > find_root() does return the correct answers-- but in this case both
> > positive roots are of interest so it would be nice to recover them
> > both at the same time.
>
> Hi,
>
> How about this:
>
> sage: R. = RR[]
> sage: f = y^3 - 1.39027132807289 * y^2 + 0.090610488164005
> sage: f.roots()
> [(-0.236040904804615, 1), (0.286518993973450, 1), (1.33979323890405, 1)]
>
> Is this what you were hoping for?
>
> Best,
> Alex
>
> --
> Alex Ghitza --http://aghitza.org/
> Lecturer in Mathematics -- The University of Melbourne -- Australia

Thanks for the reply Alex. I think I understand that by choosing a
variable of the appropriate type, in this case one that is restricted
to the real numbers, the roots can be determined in a straight-forward
manner.

I had some more problems, but finally figured out how to coerce a
expression of type symbolic to the real ring through a somewhat
convoluted application of multiplication, full_simplify() and
polynomial().

The cubic is the result of balancing a system of conservation
equations and then substituting in known information:

y2 = var( 'y2' )

f  =  1.54027132807289 == y2 + 0.0906104881640050/y2^2 +
0.150

# Multiply to eliminate fractions.
f  = f * y2^2

f.full_simplify().polynomial(RR).roots()

[(-0.236040904804615, 1), (0.286518993973450, 1), (1.33979323890405,
1)]


That gives the correct answer-- but it seems pretty darn inelegant,
distracted and burdensome to explain when presented in a homework
report.  I experimented with the "domain=" argument to var() to see if
it could help, but I didn't notice any changes.

If someone could suggest a way the above code could be cleaned up, I
would be very grateful!

-Charlie

-- 
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
URL: http://www.sagemath.org


[sage-support] Re: sage and readline problems

2010-03-02 Thread finotti
Dear all,

Thank you very much Minh for the reply!


On Mar 1, 3:33 pm, Minh Nguyen  wrote:

> I think it's not related to readline, but instead to something else.
> See some recent threads [1,2] in sage-support and sage-devel for the
> same/similar problem.

They seem to be different problems, as I am running on a terminal (not
emacs) and I do get suggestions for the completion.  It only messes up
the line.

I've searched this list and found a few suggestions, such as compiling
from source (with the readline dev libraries) and disabling colors.  I
tried the former, but it seems that the process crashed my laptop.  (I
*think* it overheated, but I am not sure.)  Which is funny on itself,
as I had done it before and this laptop is not that bad.  (It's a
Thinkpad T60 - Centrino Duo (not 2 Duo, though) with 3GB of memory.)

The second one does work, for what it worth, but it is a bit of a
shame to lose color...  (Of course, I can live with it.)  But maybe
this helps someone figure out what the issue really is?

To be more clear, here is what happens:

t60[~]$ sage
--
| Sage Version 4.3.3, Release Date: 2010-02-21   |
| Type notebook() for the GUI, and license() for information.|
--
sage: a=87435027504
sage: a.fac
a.factor a.factorial
sage: a.factor
   ^
   |
cursor moves
here ("e" of "sage")

I can continue to type (overwriting "e: a.factor") and it works, but
it makes it hard to read.

> > Any suggestions?
>
> If you are using Sage 4.3.2 or an earlier version, please upgrade to
> Sage 4.3.3 instead as the problem you described has been fixed in that
> release.

I am using 4.3.3 (binary for Ubuntu 9.04).

Thanks again for your help!

Luis

-- 
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
URL: http://www.sagemath.org