Re: [sage-support] Re: Exporting Sage notebook worksheet to SageTeX?

2012-02-08 Thread Stephen Hartke
On 2/8/12 10:30 PM, Stephen Hartke wrote:

> I could not immediately find a feature to export to SageTeX.  If such a
> feature does not already exist, how hard would it be to implement it?
>

On Wed, Feb 8, 2012 at 10:37 PM, Jason Grout wrote:

> I don't think it exists, but shouldn't be that hard.  Just get the text
> version of the worksheet (the "Edit" view) and:
>
> Replace
>
> {{{
> INPUT
> ///
> OUTPUT
> }}}
>
> with
>
> \begin{sageblock}
> INPUT
> \end{sageblock}
>
> (or use whatever sagetex environment you like)
>
> I guess it would be a bit harder to convert the text cells' html to latex,
> but should be doable.  But that would be about it, I think.
>

Jason,

Thanks for the suggestion!  I'd forgotten about getting the text version.
I'll try writing a script to replace input boxes as well replace the common
html with equivalent LaTeX (ie, replace "." with
"\emph{}").  If it seems useful, I'll share it once it's working.

Best wishes,
Stephen

-- 
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: Exporting Sage notebook worksheet to SageTeX?

2012-02-08 Thread Jason Grout

On 2/8/12 10:30 PM, Stephen Hartke wrote:

I've been writing a series of handouts for my class.  When writing them,
I like to initially use the Sage notebook as it allows me to quickly and
easily experiment with different examples, while still writing most of
the explanations.  However, for various reasons I'd like to be able to
post pdf versions or handout printed versions for my students.  Is it
possible to export a Sage notebook worksheet to SageTeX?  That would be
great!  The output from SageTeX I think looks better than printing from
a browser, and it is also allows more substantial LaTeX (and also easier
to write, since a TeX editor can be used) than jsMath does in the
comment boxes.

I could not immediately find a feature to export to SageTeX.  If such a
feature does not already exist, how hard would it be to implement it?


I don't think it exists, but shouldn't be that hard.  Just get the text 
version of the worksheet (the "Edit" view) and:


Replace

{{{
INPUT
///
OUTPUT
}}}

with

\begin{sageblock}
INPUT
\end{sageblock}

(or use whatever sagetex environment you like)

I guess it would be a bit harder to convert the text cells' html to 
latex, but should be doable.  But that would be about it, I think.


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] Exporting Sage notebook worksheet to SageTeX?

2012-02-08 Thread Stephen Hartke
I've been writing a series of handouts for my class.  When writing them, I
like to initially use the Sage notebook as it allows me to quickly and
easily experiment with different examples, while still writing most of the
explanations.  However, for various reasons I'd like to be able to post pdf
versions or handout printed versions for my students.  Is it possible to
export a Sage notebook worksheet to SageTeX?  That would be great!  The
output from SageTeX I think looks better than printing from a browser, and
it is also allows more substantial LaTeX (and also easier to write, since a
TeX editor can be used) than jsMath does in the comment boxes.

I could not immediately find a feature to export to SageTeX.  If such a
feature does not already exist, how hard would it be to implement it?

Thanks!
Stephen

-- 
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: jmol won't display

2012-02-08 Thread Jason Grout

On 2/8/12 6:18 PM, David wrote:

After playing around in the jmol console, and getting a weird error
involving DOCTYPE, I found some old info on the web, including from
Jonathan. I couldn't find a fix in a few minutes, but someone
speculated that it was a cookie thing. Bingo. I turned on third party
cookies, and it instantly worked. I can't see any extra cookies being
set though; very mysterious. I'm not so keen on allowing third party
cookies, so I turned it off and added an explicit "allow" for cookies
from our internal server, and it still works. I don't think I really
understand what's going on...

I'll check sagenb.org now, but I expect it will be fine.


Great!  I remember running into a cookie issue that Mike Hansen 
essentially solved for us last March.  I wonder if it was the same issue.


Jonathan: do you know what this third party cookies issue is about?

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: jmol won't display

2012-02-08 Thread David
Ah, presumably the whole ubuntu 10.04 thing is a red herring; I must
be accepting 3rd party cookies on the 11.04 machine. I'll check it
when I get home.

-- David

-- 
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: jmol won't display

2012-02-08 Thread David
After playing around in the jmol console, and getting a weird error
involving DOCTYPE, I found some old info on the web, including from
Jonathan. I couldn't find a fix in a few minutes, but someone
speculated that it was a cookie thing. Bingo. I turned on third party
cookies, and it instantly worked. I can't see any extra cookies being
set though; very mysterious. I'm not so keen on allowing third party
cookies, so I turned it off and added an explicit "allow" for cookies
from our internal server, and it still works. I don't think I really
understand what's going on...

I'll check sagenb.org now, but I expect it will be fine.

-- David

-- 
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] Coefficients of multivariate polynomials along with degrees

2012-02-08 Thread Mike Hansen
On Wed, Feb 8, 2012 at 3:29 PM, ObsessiveMathsFreak
 wrote:
> Is there no way of getting sage to give back the degree's of the
> corresponding multivariate polynomials as well. That is to return
> something like
>
> [[10,[100,1]],[3,[1,0]]]

exponents() is what you need:

sage: zip(B.coefficients(), B.exponents())
[(10, (100, 1)), (3, (1, 0))]

--Mike

-- 
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] Coefficients of multivariate polynomials along with degrees

2012-02-08 Thread Julian Rüth
* ObsessiveMathsFreak  [2012-02-08 15:29:03 
-0800]:
> Currently the code for obtaining the coefficients of a multivariate
> polynomials returns only a list of coefficients without returning the
> degrees as well. For example
> 
> f(x,y)=10*x^2*y+3*x
> B=f(x,y).polynomial(SR)
> print B.coefficients()
> [10, 3]
> 
> Is there no way of getting sage to give back the degree's of the
> corresponding multivariate polynomials as well.
You can use dict() for that. As in

sage: R. = SR[]
sage: f=10*x^2*y+3*x
sage: f.dict()
{(1, 0): 3, (2, 1): 10}

cheers,
julian


pgpf0gLgQa6gt.pgp
Description: PGP signature


[sage-support] Coefficients of multivariate polynomials along with degrees

2012-02-08 Thread ObsessiveMathsFreak
Currently the code for obtaining the coefficients of a multivariate
polynomials returns only a list of coefficients without returning the
degrees as well. For example

f(x,y)=10*x^2*y+3*x
B=f(x,y).polynomial(SR)
print B.coefficients()
[10, 3]


f(x,y)=10*x^100*y+3*x
B=f(x,y).polynomial(SR)
print B.coefficients()
[10, 3]

Is there no way of getting sage to give back the degree's of the
corresponding multivariate polynomials as well. That is to return
something like

[[10,[100,1]],[3,[1,0]]]

-- 
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] Add new/custom integral code to sage

2012-02-08 Thread ObsessiveMathsFreak
I have a certain integration result which Sage is currently unaware of. I 
need a way to make sage aware of it in some fashion, via substitution or 
anything else.

For example, sage currently cannot perform the following integral

sage: var(' k t')
sage: integrate(sqrt(1-k^2*sin(t)^2),t,0,pi/2)
integrate(sqrt(-k^2*sin(t)^2+1),t,0,pi/2)

In fact, the integral defines the elliptice function E(k).

Is there any way of substituting the unknown integral above for a function 
like E(k) in sage? Can sage be programmed to recognise such substitutions 
automatically?

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

2012-02-08 Thread Chappman
What y ou suggested all I tried it again today, thank you very much
for the help, I did use the def function that you suggest. All the
help and input is being put to good use.

Kind Regards
Chappman

On Feb 8, 6:48 pm, Anton Sherwood  wrote:
> Chappman wrote:
>
>  >> Yes I do want a function of some sort here, but I do not
>  >> want a "def chaps(u,v)" like what anton has done for now, [...]
>
> On 2012-2-08 02:39, Robert Bradshaw wrote:
>
> > It sounds like what you're saying is "I want a function,
> > but I don't want a function."  [...]
>
> Or "I want a function, but I don't like Python's function syntax."
>
> --
> Anton Sherwood *\\*www.bendwavy.org*\\*www.zazzle.com/tamfang

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

2012-02-08 Thread Anton Sherwood

Chappman wrote:
>> Yes I do want a function of some sort here, but I do not
>> want a "def chaps(u,v)" like what anton has done for now, [...]

On 2012-2-08 02:39, Robert Bradshaw wrote:

It sounds like what you're saying is "I want a function,
but I don't want a function."  [...]


Or "I want a function, but I don't like Python's function syntax."

--
Anton Sherwood *\\* www.bendwavy.org *\\* www.zazzle.com/tamfang

--
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: Ubuntu 11.10 SAGE compilation

2012-02-08 Thread William Stein
On Wed, Feb 8, 2012 at 10:27 AM, Jason Grout
 wrote:
> On 2/8/12 10:39 AM, firebird wrote:
>>
>> Thanks for the prompt response, but it is barely credible...
>
>
> Atlas will sometimes do tuning, which means that it will run the same
> program lots of times with different values in order to ascertain exactly
> what parameters to use to get the fastest linear algebra. Sometimes this
> tuning takes hours and hours, if atlas doesn't already know about your CPU
> and computer configuration.  The important thing then is to save that tuning
> information for the next time you compile atlas, or even better, submit that
> tuning information back upstream to the atlas project.

Also, the spkg-install attempts to build ATLAS in four different ways
before giving up:

print 'First attempt: automatic tuning.'
rc = build()
if rc!=0:
print 'Waiting 5 minutes...'
time.sleep(5*60)
print 'Second attempt: Re-running make.'
rc = make_core()
if rc!=0:
print 'Waiting 5 minutes...'
time.sleep(5*60)
try:
print 'Third attempt: use "fast" options.'
rc = build(arch='fast')
if rc!=0:
print 'Fourth attempt: use "base" options.'
rc = build(arch='base')
except NotImplementedError:
pass

assert rc==0, 'Failed to build ATLAS.'

>
> How long did you let it go before terminating?  What kind of computer are
> you compiling on?
>
> 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



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


[sage-support] Re: Ubuntu 11.10 SAGE compilation

2012-02-08 Thread Jason Grout

On 2/8/12 10:39 AM, firebird wrote:

Thanks for the prompt response, but it is barely credible...


Atlas will sometimes do tuning, which means that it will run the same 
program lots of times with different values in order to ascertain 
exactly what parameters to use to get the fastest linear algebra. 
Sometimes this tuning takes hours and hours, if atlas doesn't already 
know about your CPU and computer configuration.  The important thing 
then is to save that tuning information for the next time you compile 
atlas, or even better, submit that tuning information back upstream to 
the atlas project.


How long did you let it go before terminating?  What kind of computer 
are you compiling on?


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: Ubuntu 11.10 SAGE compilation

2012-02-08 Thread Volker Braun
Looks normal to me. Occasionally ATLAS prints some progress status, that 
would be more interesting to grep 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
URL: http://www.sagemath.org


[sage-support] Re: Programming animation

2012-02-08 Thread LFS
@Nils
Got the animation to work - Really pleased!  (Momentarily nothing will
publish - when it does I will add the link.)
Thanks for writing the script so simply. I was able to change things I
wanted to change.
BTW - if anyone copies and pastes the script from above, there is an
bad line break after "rmdir" that forces an error.
Thanks. Linda

-- 
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: Ubuntu 11.10 SAGE compilation

2012-02-08 Thread firebird
Volker

Thanks for the prompt response, but it is barely credible...

Enclosed are some of the more common lines (with frequencies at the
front) from install.log.  Is this what you would expect?  169
compilations of the same file?  I terminated the job after that.


526 make[10]: Leaving directory `/home/firebird/sage-4.8/spkg/build/
atlas-3.8.4.p1/ATLAS-build/tune/blas/level1'
526 make[10]: Entering directory `/home/firebird/sage-4.8/spkg/build/
atlas-3.8.4.p1/ATLAS-build/tune/blas/level1'
348   /home/firebird/sage-4.8/spkg/build/atlas-3.8.4.p1/
ATLAS-build/tune/sysinfo/time.o -lpthread -lm
178 /home/firebird/sage-4.8/spkg/
build/atlas-3.8.4.p1/ATLAS-build/tune/sysinfo/time.o
170 rm -f dfc.o dmm.o
170 rm -f dmm.c
169 gcc -DL2SIZE=4194304 -I/home/firebird/sage-4.8/spkg/build/
atlas-3.8.4.p1/ATLAS-build/include -I/home/firebird/sage-4.8/spkg/
build/atlas-3.8.4.p1/ATLAS-build/../src//include -I/home/firebird/
sage-4.8/spkg/build/atlas-3.8.4.p1/ATLAS-build/../src//include/contrib
-DAdd_ -DF77_INTEGER=int -DStringSunStyle -DATL_OS_Linux -
DATL_ARCH_Corei2 -DATL_CPUMHZ=3001 -DATL_SSE3 -DATL_SSE2 -DATL_SSE1 -
DATL_USE64BITS -DATL_GAS_x8664  -DATL_NCPU=4 -fomit-frame-pointer -
mfpmath=sse -mavx -O2 -fno-schedule-insns2 -fPIC -m64 -DATL_BETA=1 -c
dmm.c
169 gcc -DL2SIZE=4194304 -I/home/firebird/sage-4.8/spkg/build/
atlas-3.8.4.p1/ATLAS-build/include -I/home/firebird/sage-4.8/spkg/
build/atlas-3.8.4.p1/ATLAS-build/../src//include -I/home/firebird/
sage-4.8/spkg/build/atlas-3.8.4.p1/ATLAS-build/../src//include/contrib
-DAdd_ -DF77_INTEGER=int -DStringSunStyle -DATL_OS_Linux -
DATL_ARCH_Corei2 -DATL_CPUMHZ=3001 -DATL_SSE3 -DATL_SSE2 -DATL_SSE1 -
DATL_USE64BITS -DATL_GAS_x8664  -DATL_NCPU=4 -fomit-frame-pointer -
mfpmath=sse -mavx -O2 -fno-schedule-insns2 -fPIC -m64 -DdREAL -DtranAT
-DtranBN \
169   -o dfc.o -c /home/firebird/sage-4.8/spkg/build/
atlas-3.8.4.p1/ATLAS-build/../src//tune/blas/gemm/fc.c
169 gcc -DL2SIZE=4194304 -I/home/firebird/sage-4.8/spkg/build/
atlas-3.8.4.p1/ATLAS-build/include -I/home/firebird/sage-4.8/spkg/
build/atlas-3.8.4.p1/ATLAS-build/../src//include -I/home/firebird/
sage-4.8/spkg/build/atlas-3.8.4.p1/ATLAS-build/../src//include/contrib
-DAdd_ -DF77_INTEGER=int -DStringSunStyle -DATL_OS_Linux -
DATL_ARCH_Corei2 -DATL_CPUMHZ=3001 -DATL_SSE3 -DATL_SSE2 -DATL_SSE1 -
DATL_USE64BITS -DATL_GAS_x8664  -DATL_NCPU=4 -fomit-frame-pointer -
mfpmath=sse -mavx -O2 -fno-schedule-insns2 -fPIC -m64 -o xdfc dfc.o
dmm.o \
164 make[6]: Entering directory `/home/firebird/sage-4.8/spkg/build/
atlas-3.8.4.p1/ATLAS-build/tune/blas/gemm'
163 make[6]: Leaving directory `/home/firebird/sage-4.8/spkg/build/
atlas-3.8.4.p1/ATLAS-build/tune/blas/gemm'
162 make[7]: Entering directory `/home/firebird/sage-4.8/spkg/build/
atlas-3.8.4.p1/ATLAS-build/tune/blas/gemm'
161 make[7]: Leaving directory `/home/firebird/sage-4.8/spkg/build/
atlas-3.8.4.p1/ATLAS-build/tune/blas/gemm'

FireBird


On Feb 7, 10:49 pm, Volker Braun  wrote:
> ATLAS will not loop (though it takes almost forever and may fail to
> compile). You need more patience ;-)

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

2012-02-08 Thread Robert Bradshaw
It sounds like what you're saying is "I want a function, but I don't
want a function." Perhaps I could offer some better suggestions if I
understood why "def f(...)" isn't acceptable.

On Wed, Feb 8, 2012 at 1:16 AM, Chappman  wrote:
> Yes I do want a function of some sort here, but I do not want a "def
> chaps(u,v)" like what anton has done for now, both for my simplified
> and larger problem.
> Is there  a solution/method to this?
>
> Kind Regards
> Chappman
>
> On Feb 7, 9:35 pm, Robert Bradshaw 
> wrote:
>> On Tue, Feb 7, 2012 at 1:07 PM, Chappman  wrote:
>> > Hi Rob,
>> > I am pretty new to Sage and am not used to the syntex, so even though
>> > I write [y1,y2] , i do not mean it as a list.
>> > Basically what I am trying to do is try and get the folllowing code to
>> > work, if the summation does come out correct ly
>> > x would be equal to 5 , i.e. x=5.
>>
>> Sage will interpret [y1, y2] as a list (as will others reading your code).
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> > I would not need to specify when y1> > my summation that y2 in [1..y1], so y2 can never be bigger than y1.
>>
>> > So the way I want my code to work is basically, when doing the
>> > summation, the first one would be [y1,y2] = [1,1], then using my
>> > previously set criteries
>>
>> > if y1=y2:
>> >     [y1,y2]=2
>> > elif y1>y2:
>> >     [y1,y2]=1
>>
>> > this would make                        [y1,y2] = [1,1]=2
>> > my second summation would be [y1,y2] = [2,1]=1
>> > my last summation would be      [y1,y2] = [2,2]=2
>>
>> > so then x += [y1,y2]  = 5
>>
>> > -
>> > if y1=y2:
>> >     [y1,y2]=2
>> > elif y1>y2:
>> >     [y1,y2]=1
>>
>> > x=0
>> > for y1 in [1..2]:
>> >     for y2 in [1..y1]:
>> >          x += [y1,y2]
>> > print x
>> > -
>>
>> > Is there a method of not using a function like "def chap(u,v)" for
>> > this right now, because this is just a simplified problem, of my
>> > larger problem. Thank you for taking your time looking at this.
>>
>> If I understand your intent correctly, you do want a function here,
>> both for the simplified and larger problem. Is there a reason that
>> this doesn't work for you?
>>
>>
>>
>>
>>
>>
>>
>> > On Feb 7, 8:07 pm, Anton Sherwood  wrote:
>> >> On 2012-2-07 01:18, Chappman wrote:
>>
>> >> > Hi Rob,
>>
>> >> > with this syntex:
>>
>> >> >> x=0
>> >> >> for y_1 in [1..2]:
>> >> >>      for y_2 in [1..y_1]:
>> >> >>           x += [y_1,y_2]
>> >> >> print x
>>
>> >> > what I am trying to do is, trying to use the two numbers y_1 and y_2
>> >> > in x +=[y_1,y_2]
>> >> > to assign it a number from previously set conditions
>>
>> >> >> if y_1 = y_2:
>> >> >>      y_1 = y_2 = 2
>> >> >> elif y_1>y_2:
>> >> >>      y_1 = y_2 = 1
>>
>> >> > but currently my code is having trouble doing that.
>> >> > Is there a way to do this please?
>>
>> >> Are you trying to define [u,v] as a function whose value is 2 if the
>> >> arguments are equal and 1 if u>v?  (What if v> >> problems, you can't do that with [], because that symbol is reserved for
>> >> lists.
>>
>> >> Here's how I'd do what I think you're trying to do:
>>
>> >> # define a function of two inputs
>> >> def chap(u,v):
>> >>         if u==v: return 2
>> >>         # no 'else' needed, because 'return' breaks out of the function
>> >>         if u>v: return 1
>> >>         return None     # ought to be a numeric value
>>
>> >> x=0
>> >> for y1 in range(1,3):
>> >>         for y2 in range(1,y1+1):
>> >>                 x += chap(y1,y2)
>> >> print x
>>
>> >> --
>> >> Anton Sherwood *\\*www.bendwavy.org*\\*www.zazzle.com/tamfang
>>
>> > --
>> > 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 
>> > athttp://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

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

2012-02-08 Thread Chappman
Yes I do want a function of some sort here, but I do not want a "def
chaps(u,v)" like what anton has done for now, both for my simplified
and larger problem.
Is there  a solution/method to this?

Kind Regards
Chappman

On Feb 7, 9:35 pm, Robert Bradshaw 
wrote:
> On Tue, Feb 7, 2012 at 1:07 PM, Chappman  wrote:
> > Hi Rob,
> > I am pretty new to Sage and am not used to the syntex, so even though
> > I write [y1,y2] , i do not mean it as a list.
> > Basically what I am trying to do is try and get the folllowing code to
> > work, if the summation does come out correct ly
> > x would be equal to 5 , i.e. x=5.
>
> Sage will interpret [y1, y2] as a list (as will others reading your code).
>
>
>
>
>
>
>
>
>
> > I would not need to specify when y1 > my summation that y2 in [1..y1], so y2 can never be bigger than y1.
>
> > So the way I want my code to work is basically, when doing the
> > summation, the first one would be [y1,y2] = [1,1], then using my
> > previously set criteries
>
> > if y1=y2:
> >     [y1,y2]=2
> > elif y1>y2:
> >     [y1,y2]=1
>
> > this would make                        [y1,y2] = [1,1]=2
> > my second summation would be [y1,y2] = [2,1]=1
> > my last summation would be      [y1,y2] = [2,2]=2
>
> > so then x += [y1,y2]  = 5
>
> > -
> > if y1=y2:
> >     [y1,y2]=2
> > elif y1>y2:
> >     [y1,y2]=1
>
> > x=0
> > for y1 in [1..2]:
> >     for y2 in [1..y1]:
> >          x += [y1,y2]
> > print x
> > -
>
> > Is there a method of not using a function like "def chap(u,v)" for
> > this right now, because this is just a simplified problem, of my
> > larger problem. Thank you for taking your time looking at this.
>
> If I understand your intent correctly, you do want a function here,
> both for the simplified and larger problem. Is there a reason that
> this doesn't work for you?
>
>
>
>
>
>
>
> > On Feb 7, 8:07 pm, Anton Sherwood  wrote:
> >> On 2012-2-07 01:18, Chappman wrote:
>
> >> > Hi Rob,
>
> >> > with this syntex:
>
> >> >> x=0
> >> >> for y_1 in [1..2]:
> >> >>      for y_2 in [1..y_1]:
> >> >>           x += [y_1,y_2]
> >> >> print x
>
> >> > what I am trying to do is, trying to use the two numbers y_1 and y_2
> >> > in x +=[y_1,y_2]
> >> > to assign it a number from previously set conditions
>
> >> >> if y_1 = y_2:
> >> >>      y_1 = y_2 = 2
> >> >> elif y_1>y_2:
> >> >>      y_1 = y_2 = 1
>
> >> > but currently my code is having trouble doing that.
> >> > Is there a way to do this please?
>
> >> Are you trying to define [u,v] as a function whose value is 2 if the
> >> arguments are equal and 1 if u>v?  (What if v >> problems, you can't do that with [], because that symbol is reserved for
> >> lists.
>
> >> Here's how I'd do what I think you're trying to do:
>
> >> # define a function of two inputs
> >> def chap(u,v):
> >>         if u==v: return 2
> >>         # no 'else' needed, because 'return' breaks out of the function
> >>         if u>v: return 1
> >>         return None     # ought to be a numeric value
>
> >> x=0
> >> for y1 in range(1,3):
> >>         for y2 in range(1,y1+1):
> >>                 x += chap(y1,y2)
> >> print x
>
> >> --
> >> Anton Sherwood *\\*www.bendwavy.org*\\*www.zazzle.com/tamfang
>
> > --
> > 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 
> > athttp://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