Re: [sage-support] Re: Evaluating Symbolic Expressions

2011-11-02 Thread Laurent
In order to anticipate the next question, if you are wotking in a script 
instead of

the terminal.

The code

f(x,y)=x*y
print f(5,4)

raises
SyntaxError: can't assign to function call


The code
x,y=var('x,y')
f=x*y
print f(4,3)

raises
DeprecationWarning: Substitution using function-call syntax and unnamed 
arguments is deprecated and will be removed from a future release of 
Sage; you can use named arguments instead, like EXPR(x=..., y=...)


I know two correct ways to do that :

x,y=var('x,y')
f=x*y
print f(x=4,y=3)

or

x,y=var('x,y')
f=symbolic_expression(x*y).function(x,y)
print f(x,y)

Remark that

f=symbolic_expression(x*cos(y)).function(x,y)
print f(0,1)# 0
g=symbolic_expression(x*cos(y)).function(y,x)
print g(0,1)# 1!!

Hope it helps in any way

Laurent



--
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: Evaluating Symbolic Expressions

2011-11-02 Thread Rajeev Singh
On Wed, Nov 2, 2011 at 12:08 PM, Laurent moky.m...@gmail.com wrote:
 In order to anticipate the next question, if you are wotking in a script
 instead of
 the terminal.

 The code

        f(x,y)=x*y
        print f(5,4)

 raises
 SyntaxError: can't assign to function call


 The code
        x,y=var('x,y')
        f=x*y
        print f(4,3)

 raises
 DeprecationWarning: Substitution using function-call syntax and unnamed
 arguments is deprecated and will be removed from a future release of Sage;
 you can use named arguments instead, like EXPR(x=..., y=...)

 I know two correct ways to do that :

        x,y=var('x,y')
        f=x*y
        print f(x=4,y=3)

 or

        x,y=var('x,y')
        f=symbolic_expression(x*y).function(x,y)
        print f(x,y)

 Remark that

        f=symbolic_expression(x*cos(y)).function(x,y)
        print f(0,1)    # 0
        g=symbolic_expression(x*cos(y)).function(y,x)
        print g(0,1)    # 1!!

 Hope it helps in any way

 Laurent



 --
 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



Hi,

I think its a issue of parsing. If your file is called hello.py it
gives the errors you mentioned. However if you call your file
hello.sage it works. If you call your file hello.sage and run

sage hello.sage

it generates a hello.py which I append below -

# This file was *autogenerated* from the file temp.sage.
from sage.all_cmdline import *   # import sage library
_sage_const_5 = Integer(5); _sage_const_4 = Integer(4)
var('x,y')
__tmp__=var(x,y); f = symbolic_expression(x*y).function(x,y)
print f(_sage_const_5 ,_sage_const_4 )

I think you can now figure out how it is working. Hope it helps.

Rajeev

-- 
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: Numerical solution of systems of nonlinear (in)equalities

2011-11-02 Thread Urs Hackstein
1) solve doesn't work in my example.

2) I wonder whether fsolve could solve really *systems *of (in)equalities
or only one (in)equality.

Best regards,

Urs Hackstein

2011/10/31 achrzesz achrz...@wp.pl


 1)
 solve?
 (some nonlinear systems are solved numerically)

 2)
 from scipy.optimize import fsolve
 fsolve?

 3)
 from mpmath import findroot
 findroot?

 --
 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


Re: [sage-support] import .sage file [was : Evaluating Symbolic Expressions]

2011-11-02 Thread Laurent

Hi,

I think its a issue of parsing. If your file is called hello.py it
gives the errors you mentioned. However if you call your file
hello.sage it works. If you call your file hello.sage and run

sage hello.sage

it generates a hello.py which I append below -


I know that, but I never understood how to use it because if my file is 
named hello.sage, I cannot do

import hello.sage
in an other file. But if it is named hello.py, I can write
import hello

I admit I never got trough the doc about that issue ;)

Laurent

--
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: Creating Arrays in sage, and then writing a programme which refers back to the array and uses it.

2011-11-02 Thread Chappman
yes I am just trying to reasign totol prob again so that a new value
of total prob comes out .

On Nov 1, 12:24 am, Dan Drake dr...@kaist.edu wrote:
 On Mon, 31 Oct 2011 at 03:09PM -0700, Chappman wrote:
  Hi folks, I am relatively new to programming in Sagemath, and I am
  trying
  to find a method in of creating a n x n array, with probabilities as
  the entries of this array .

 Use a matrix, or even simpler, a list of lists.

     sage: m = matrix(3, [[1, 2, 3], [4,5,6], [7,8,9]])

  Here's the tricky part, then I have to create a coding program which
  uses the values in this array.

   For i=1 to 5;
         For j=1 to i-1;
            total_prob= (some type of simple formula which refers back
  to entries in the array)
         end;
  end;

 It looks like you're just reassigning total_prob again and again. Is
 that what you want?

 Dan

 --
 ---  Dan Drake
 -  http://mathsci.kaist.ac.kr/~drake
 ---

  signature.asc
  1KViewDownload

-- 
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: Numerical solution of systems of nonlinear (in)equalities

2011-11-02 Thread achrzesz

Hello Urs
fsolve from scipy does solve systems (look at scipy reference)
All functions I have mentioned solve nonlinear systems of *equations*

Maxima has also function mnewton solving nonlinear systems

Andrzej Chrzeszczyk

-- 
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: sagenb issues

2011-11-02 Thread Vinay Wagh
I am not sure whether my problem has anything to do with the topic of
this thread...

I want to define a Power Series Ring over QQ. The following code works
perfectly fine on my local computer (Ubuntu 11.10, Sage Version 4.7.1,
Release Date: 2011-08-11), whereas if I give the same on sagenb.org it
gives me an error.

I am defining the ring via:
R.x,y,z = PowerSeriesRing(QQ);

The error on sagenb:

Traceback (most recent call last):
  File stdin, line 1, in module
  File _sage_input_5.py, line 10, in module
exec compile(u'open(___code___.py,w).write(# -*- coding:
utf-8 -*-\\n +
_support_.preparse_worksheet_cell(base64.b64decode(Ui48eCx5LHo+ID0gUG93ZXJTZXJpZXNSaW5nKFFRKQpS),globals())+\\n);
execfile(os.path.abspath(___code___.py))
  File , line 1, in module

  File /tmp/tmpHLLnj7/___code___.py, line 2, in module
R = PowerSeriesRing(QQ, names=('x', 'y', 'z',)); (x, y, z,) =
R._first_ngens(3)
  File 
/sagenb/sage_install/sage-4.7/local/lib/python2.6/site-packages/sage/rings/power_series_ring.py,
line 183, in PowerSeriesRing
name = gens.normalize_names(1, name)
  File parent_gens.pyx, line 213, in
sage.structure.parent_gens.normalize_names
(sage/structure/parent_gens.c:2311)
IndexError: the number of names must equal the number of generators

My observation is if I fedine a Power Series Ring in 1 variable, then
sagenb accepts, but it seems it doesnt like multiple variables. In fact
none of the example in the documentation work for that matter. Please let
me know if there is some other issue involved...

Thanks and regards

-- VInay


On 28 October 2011 01:36, leif not.rea...@online.de wrote:

 On 27 Okt., 19:12, Volker Braun vbraun.n...@gmail.com wrote:
  On Thursday, October 27, 2011 11:01:19 AM UTC-4, leif wrote:
   Setting MAKE to make -jN when (re-)building Sage doesn't limit the
   *total* number of build jobs to N;
 
  It does limit the total number of build jobs within the current make.

 Provided the communication to the jobserver (through inherited file
 descriptors, whose numbers are passed in MAKEFLAGS) isn't broken,
 which currently apparently isn't always the case during the build.


  Of
  course it doesn't take into account make jobs that are run by different
  users, that run on different computers, that were invoked at a different
  time, etc.

 :-) I thought the number referred to all simultaneous 'make' jobs in
 the Milky Way.


 -leif

 --
 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: sagenb issues

2011-11-02 Thread Jason Grout

On 11/2/11 10:15 AM, Vinay Wagh wrote:

I am not sure whether my problem has anything to do with the topic of
this thread...

I want to define a Power Series Ring over QQ. The following code works
perfectly fine on my local computer (Ubuntu 11.10, Sage Version 4.7.1,
Release Date: 2011-08-11), whereas if I give the same on sagenb.org
http://sagenb.org it gives me an error.



sagenb.org is running Sage 4.7.  My guess is that is the problem here.

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: sagenb issues

2011-11-02 Thread Vinay Wagh
On 2 November 2011 20:49, Jason Grout jason-s...@creativetrax.com wrote:

 On 11/2/11 10:15 AM, Vinay Wagh wrote:

 I am not sure whether my problem has anything to do with the topic of
 this thread...

 I want to define a Power Series Ring over QQ. The following code works
 perfectly fine on my local computer (Ubuntu 11.10, Sage Version 4.7.1,
 Release Date: 2011-08-11), whereas if I give the same on sagenb.org
 http://sagenb.org it gives me an error.



 sagenb.org is running Sage 4.7.  My guess is that is the problem here.

 Thanks,

 Jason


I also suspected the same, but the documentation doesnot say anywhere that
the 4.7 does not support multi-var power series... (Or at least I couldnt
find!)

Thanks and regards
-- Vinay

-- 
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: sagenb issues

2011-11-02 Thread William Stein
On Wed, Nov 2, 2011 at 8:32 AM, Vinay Wagh wagh...@gmail.com wrote:

 On 2 November 2011 20:49, Jason Grout jason-s...@creativetrax.com wrote:

 On 11/2/11 10:15 AM, Vinay Wagh wrote:

 I am not sure whether my problem has anything to do with the topic of
 this thread...

 I want to define a Power Series Ring over QQ. The following code works
 perfectly fine on my local computer (Ubuntu 11.10, Sage Version 4.7.1,
 Release Date: 2011-08-11), whereas if I give the same on sagenb.org
 http://sagenb.org it gives me an error.


 sagenb.org is running Sage 4.7.  My guess is that is the problem here.

 Thanks,

 Jason

 I also suspected the same, but the documentation doesnot say anywhere that
 the 4.7 does not support multi-var power series... (Or at least I couldnt
 find!)

Sage has multivariate power series now!  Cool.  I remember people
talking about implementing them periodically for 6 years, and never
doing it.  I'm glad it's done now.

Note that http://test.sagenb.org/ has a newer version of sage.

 -- William


 Thanks and regards
 -- Vinay


 --
 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




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


Re: [sage-support] import .sage file [was : Evaluating Symbolic Expressions]

2011-11-02 Thread William Stein
On Wed, Nov 2, 2011 at 3:22 AM, Laurent moky.m...@gmail.com wrote:
 Hi,

 I think its a issue of parsing. If your file is called hello.py it
 gives the errors you mentioned. However if you call your file
 hello.sage it works. If you call your file hello.sage and run

 sage hello.sage

 it generates a hello.py which I append below -

 I know that, but I never understood how to use it because if my file is
 named hello.sage, I cannot do
 import hello.sage
 in an other file. But if it is named hello.py, I can write
 import hello

 I admit I never got trough the doc about that issue ;)

.sage files are not meant to be used like normal Python modules.  You
can only load or attach them.  I implemented this in 2005, when I was
basically implementing something like Magma on top of Python.  I'm not sure
this is good or bad, but I definitely find

   sage: attach file.sage

to be *useful* in practice.

William


 Laurent

 --
 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




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


Re: [sage-support] import .sage file [was : Evaluating Symbolic Expressions]

2011-11-02 Thread Laurent



.sage files are not meant to be used like normal Python modules.  You
can only load or attach them.  I implemented this in 2005, when I was
basically implementing something like Magma on top of Python.  I'm not sure
this is good or bad, but I definitely find

sage: attach file.sage

to be *useful* in practice.


Yep, attach is really usefull. However I've some big bunches of code 
using sage divided in several packages and I thus have to name them .py 
:) And then I have to use the difficult syntax.


It's not really an issue, but when I began I has some difficulties to 
understand why some pieces of code was working in a context and 
nonworking in an other.



Have a good afternoon,
Laurent

--
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