[sage-support] Re: please test SageTeX 3.0

2015-08-26 Thread Dan Drake
...and, if anyone is in the mood to review a SageTeX-related ticket, here's 
an easy one about documentation: http://trac.sagemath.org/ticket/14343

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] please test SageTeX 3.0

2015-08-26 Thread Dan Drake
Hello all,

I'm emailing sage-support and sage-devel about the new version of SageTeX
that I just finished. It includes one small backwards-incompatible change,
so I think it's best that I tell everyone about this.

The incompatible change is with sageexample and sagecommandline
environments: previously, you could continue input lines with "... ", as
you see here:
https://github.com/dandrake/sagetex/blob/0aaf22bbf8ea04f7d98edd84ecca8d0f459ca388/example.tex#L454

Now, you have to use ": " which actually matches what you see in the
Sage interpreter. Old documents using the "... " (three dots) won't typeset
correctly using the new version of SageTeX (but of course it's easy to
search and replace to put in the correct bits).

Please try the new package. It's available from
https://www.dropbox.com/s/51qt8sijr5kjfl1/sagetex-3.0.tar.gz?dl=0 . You
should be able to use the new version just by putting sagetex.py and
sagetex.sty in the same directory as your .tex document; both Sage/Python
and TeX should pick up the new code and use that.

Let me know if you have any problems or have comments. I've opened a ticket
for the upgrade (http://trac.sagemath.org/ticket/19072) which should be
updated shortly.

Dan

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] how to create a long dict?

2015-05-19 Thread Dan Drake
On Wed, 20 May 2015 at 06:27AM +0800, Huayi Wei wrote:
> Hi, everyone,
> 
> I want to create a sparse matrix, so I need to create a dict first.
> I try to use `dict.fromkeys()` to do it, which like following:
> 
> ```
> sage: keys = [(0,1),(1,2)] # the length of keys maybe very long
> sage: values = [0,1] # values have the same length as keys
> sage: d = dict.fromkeys(keys,values)
> sage: d
> {(0, 1): [0, 1], (1, 2): [0, 1]}
> ```
> But the result is not what I want, and I want to get this:
> 
> ```
> {(0,1):0,(1,2):1}
> ```
> 
> Does there exist other way to do this? Hope to get your help, thanks
> very much.

Try just "dict()":

dict(zip(keys, values))
{(0, 1): 0, (1, 2): 1}

Here's how zip() works, if you don't already know:
https://docs.python.org/3.5/library/functions.html#zip


Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: [sage-support] latex and hold parameter

2015-01-20 Thread Dan Drake
On Fri, 16 Jan 2015 at 09:57AM -0800, Pedro Cruz wrote:
> An unexpected behaviour in latex() command (both 5.12 and 6.4 Sage 
> versions):
> 
> sage:   latex( 120/factorial(5,hold=True) )
> \frac{120}{120}
> sage:   latex( factorial(5,hold=True) )
> 5!
> 
> We need to "hold" the expression for proper latex transcription.
> 
> Is there any other way to avoid latex() to compute things?

I don't think so. My understanding is that this comes from the basic
semantics of Python; latex() will only see the integer 120, because
Python evaluates the factorial(). AFAIK there's just no concept of
"don't evaluate this yet" in Python, unless you use strings and eval().

In SageTeX, my experience is that this isn't as big a problem as you may
think. In your example, I would do something like

\begin{sagesilent}
n = 5
\end{sagesilent}

blah blah $120/\sage{n}! = 120/\sage{factorial(n)} =
\sage{120/factorial(n)}$.

Another option here is to use a symbolic variable:

\begin{sagesilent}
n = var('n')
\end{sagesilent}

blah blah $120/\sage{factorial(n)}$ which, when $n=5$, is
$\sage{120/factorial(n).subs(n=5)}$.



Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: [sage-support] Joint Mathematics Meetings in San Antonio

2015-01-07 Thread Dan Drake
On Tue, 06 Jan 2015 at 12:39PM -0800, William Stein wrote:
> Who is also going to the Joint Mathematics Meetings in San Antonio?

I'll be there.

Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: [sage-support] use load('f.sage') but with namespacing like 'import'

2015-01-02 Thread Dan Drake
On Wed, 31 Dec 2014 at 01:33PM -0600, Dan Drake wrote:
> In a .sage script, I can use load('f.sage') to load all the stuff from
> f.sage. But all the functions and definitions in f.sage get put into
> the same namespace as the script. I'd like to get the kind of
> namespace behavior you get when using the regular Python "import".

Solution: if you want it to act like "import", then use "import"...

If you've written stuff in f.sage that you'd like to access with
namespace support as above, the easy thing to do is to change f.sage to
f.py and add "from sage.all import *" at the top.

The only problem with this is that it won't work if you use any
Sage-specific syntax in f.sage, such as "[1..10]" or "A\b". But you can
easily fix that up by doing the preparsing yourself and pasting that
into f.py:

preparse('[1..10]') -> (ellipsis_range(Integer(1),Ellipsis,Integer(10)))

preparse(r'A\b') -> A * BackslashOperator() * b

Then do "import f" and it all works exactly the way you want.


Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


[sage-support] use load('f.sage') but with namespacing like 'import'

2014-12-31 Thread Dan Drake
Hi,

In a .sage script, I can use load('f.sage') to load all the stuff from
f.sage. But all the functions and definitions in f.sage get put into the
same namespace as the script. I'd like to get the kind of namespace
behavior you get when using the regular Python "import".

That is, if f.sage contains a function foo(), I want to do

load_with_namespace('f.sage')

and then access foo() with f.foo(), just as if I did 

import f

if "f" was a Python module.

(This just bit me: the parent script and the loaded script had variables
of the same name, and this caused confusing behavior when it should have
caused a "variable referenced before assignment" error.)

I think I can manually preparse the loaded .sage file and then import
that, but I'm wondering if there's a better way.

Thanks,

Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


[sage-support] sage-mode installation finished, but isn't working?

2014-12-29 Thread Dan Drake
Hello,

I'm not sure sage-mode is properly loading. I did "sage -i sage_mode"
but it didn't seem to install correctly. Log is attached, but I don't
see exactly what's going on. I have emacs 24.3 in Ubuntu 14.04.

After installing, the stuff in sage.el is loading, but seemingly nothing
else. I see something about sage-load.el and that wasn't generated, or
I can't find it.

Any ideas?

Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.
Found local metadata for sage_mode-0.12
Attempting to download package sage_mode-0.12
>>> Trying to download 
>>> http://www.sagemath.org/packages/upstream/sage_mode/sage_mode-0.12.tar.bz2
[.]
Checksum: 116148dad9ba4e421b2cefe8fdd8a23a5ef75780 vs 
116148dad9ba4e421b2cefe8fdd8a23a5ef75780
sage_mode-0.12

Setting up build directory for sage_mode-0.12
mv: cannot stat 'sage_mode-0.12*': No such file or directory
Finished set up

Host system:
Linux lime 3.13.0-43-generic #72-Ubuntu SMP Mon Dec 8 19:35:06 UTC 2014 x86_64 
x86_64 x86_64 GNU/Linux

C compiler: gcc
C compiler version:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/sage-6.4.1-x86_64-Linux/local/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../src/configure 
--prefix=/home/buildbot/build/sage/snapperkob/sage_git/build/local 
--with-local-prefix=/home/buildbot/build/sage/snapperkob/sage_git/build/local 
--with-gmp=/home/buildbot/build/sage/snapperkob/sage_git/build/local 
--with-mpfr=/home/buildbot/build/sage/snapperkob/sage_git/build/local 
--with-mpc=/home/buildbot/build/sage/snapperkob/sage_git/build/local 
--with-system-zlib --disable-multilib --disable-nls 
--enable-languages=c,c++,fortran --disable-libitm  
Thread model: posix
gcc version 4.9.2 (GCC) 

running build
running build_py
creating build
creating build/lib
copying xreload.py -> build/lib
copying sage_emacs.py -> build/lib
running install
running build
running build_py
running install_lib
copying build/lib/sage_emacs.py -> 
/opt/sage-6.4.1-x86_64-Linux/local/lib/python2.7/site-packages
copying build/lib/xreload.py -> 
/opt/sage-6.4.1-x86_64-Linux/local/lib/python2.7/site-packages
byte-compiling 
/opt/sage-6.4.1-x86_64-Linux/local/lib/python2.7/site-packages/sage_emacs.py to 
sage_emacs.pyc
byte-compiling 
/opt/sage-6.4.1-x86_64-Linux/local/lib/python2.7/site-packages/xreload.py to 
xreload.pyc
running install_egg_info
Writing 
/opt/sage-6.4.1-x86_64-Linux/local/lib/python2.7/site-packages/sage_mode-0.1-py2.7.egg-info
Byte compiling sage-mode with 'emacs'
Set the EMACS environment variable to compile with a different emacs.
Loading 00debian-vars...
Loading /etc/emacs/site-start.d/50auctex.el (source)...
Loading /usr/share/emacs/site-lisp/auctex.el (source)...
Loading /usr/share/emacs/site-lisp/preview-latex.el (source)...
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Error while loading 50dictionaries-common: Symbol's value as variable is void: 
debian-aspell-only-dictionary-alist
Loading /etc/emacs/site-start.d/50emacs-goodies-el.el (source)...
Loading /etc/emacs/site-start.d/50ess.el (source)...
Loading /etc/emacs/site-start.d/50haskell-mode.el (source)...
Loading /usr/share/emacs24/site-lisp/haskell-mode/haskell-mode-autoloads.el 
(source)...
Loading /etc/emacs/site-start.d/50org-mode.el (source)...
`flet' is an obsolete macro (as of 24.3); use either `cl-flet' or `cl-letf'.

In end of data:
../../../../../../share/emacs/site-lisp/sage-mode/cython-mode.el:205:1:Warning:
the following functions are not known to be defined: sage-mode,
python-beginning-of-block
Wrote 
/opt/sage-6.4.1-x86_64-Linux/local/share/emacs/site-lisp/sage-mode/cython-mode.elc

In sage-blocks-default-keybindings:
../../../../../../share/emacs/site-lisp/sage-mode/sage-blocks.el:106:15:Warning:
reference to free variable `sage-mode-map'
../../../../../../share/emacs/site-lisp/sage-mode/sage-blocks.el:109:15:Warning:
reference to free variable `inferior-sage-mode-map'

In end of data:
../../../../../../share/emacs/site-lisp/sage-mode/sage-blocks.el:134:1:Warning:
the function `sage-send-region' is not known to be defined.

Re: [sage-support] Solving system of equations

2014-12-02 Thread Dan Drake
On Tue, 02 Dec 2014 at 08:49AM -0800, SiL588 . wrote:
> but it gives the following error:
> TypeError: 'module' object does not support item assignment
> 
> What does it mean? It seems a pretty simple operation to me and I can't 
> understand what it is that i'm doing wrong.

In addition the problems Jim pointed out, "sys" is already defined as a
Python module. You can overwrite that definition, as he suggested, but
be aware that you won't be able to import and use the sys module then.

(See https://docs.python.org/2.7/library/sys.html for what the sys module
does.)


Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: [sage-support] Re: export 3D three.js graphics?

2014-12-02 Thread Dan Drake
On Mon, 01 Dec 2014 at 06:34PM -0800, William Stein wrote:
> That's a way to make a *static* image.  I strongly suspect that is not
> at all what Dan is asking for. He is probably asking for a way to
> embed a dynamic image in a website, with some combination of
> javascript, data, and a small library built on three.js.   Doing this
> is somewhere on my mental wish list,  but is not available in SMC yet.

Yeah, what I'd like is:

1. Do something with plot3d in Sage.
2. Get code for that particular scene with something like

P.save(format='threejs')

3. In my web page (a reveal.js slide deck, actually), do:

   load three.js library
   start a three.js scene, using data saved from plot3d

The key part is getting the scene data from Sage in a format that I can
save and hand off to three.js.


Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: [sage-support] export 3D three.js graphics?

2014-11-28 Thread Dan Drake
On Fri, 28 Nov 2014 at 12:14PM -0800, William Stein wrote:
> What precisely do you mean by "a three.js plot"?

Something like

http://sagecell.sagemath.org/?z=eJwrULBVyMnMS9WI1jDQAUJNHQUNQx0g1IzV5OUqyShKTc0q1ijQBADJxQot&lang=sage

or

var('x y')
plot3d(sin(x + y),(x,-10,10),(y,-10,10), threejs=true)


Are those using three.js? We are using Javascript stuff and not Java
anymore, right? I guess what I'm really asking for is how to export
whatever Javascript code we generate to make the 3D graphics so that I
can use it elsewhere.




Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


[sage-support] export 3D three.js graphics?

2014-11-28 Thread Dan Drake
Hi,

If I have a 2D plot, I can save it to an image file and then include
that image on any web page I like.

Is there a corresponding way to export a three.js plot so that I can
include it on a web page?

Thanks,

Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: [sage-support] Re: [sage-devel] How to input a large system of equations?

2014-09-18 Thread Dan Drake
On Thu, 18 Sep 2014 at 07:03AM -0700, Harald Schilly wrote:
> ... it works, but doesn't it call f way too often?

Yeah, my solution is quadratic, and you can do a loop and append in
linear time. In this case, I immediately thought of my applyntimes just
because it's sitting around in my Sage code folder and I use it. I guess
I was holding a hammer and it made his problem look like a nail...


Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: [sage-devel] How to input a large system of equations?

2014-09-18 Thread Dan Drake
On Thu, 18 Sep 2014 at 08:20AM +0200, Vincent Delecroix wrote:
> I had a look at NestList in Mathematica and there is nothing out of
> the box to compute
>   [x, f(x), f(f(x)), f(f(f(x))), ...]
> in Python. But still you can do the following one line program

I have a utility function that I use often that does this:

def applyntimes(f, arg, n):
"""
Returns f(f(f(...f(arg; that is, f composed with itself n times,
starting with arg. If n <= 0, we just return arg.
"""
if n <= 0:
return arg
else:
return reduce(lambda x, y: f(x), range(n), arg)


So the above list is

[applyntimes(f, x, n) for n in range(whatever)]



Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] using ? with sage-mode locks up emacs

2014-06-26 Thread Dan Drake
On Wed, 25 Jun 2014 at 10:06AM -0600, Ivan Andrus wrote:
> Upgrade to 0.11.  At least I don’t have any problems, and there was a
> similar issue fixed.

That seems to have fixed it. Thanks!


Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] Solving equation

2014-05-28 Thread Dan Drake
On Wed, 28 May 2014 at 08:14AM -0700, George Hokke wrote:
> Hi,
> what I want to do is to solve an equation in which the function contains a 
> numerical integral in its definition.
> Something like this:
> 
> sage: d=lambda y: numerical_integral(x**2+y,0,1)[0]
> sage: d(0)
> 0.
> 
> works until here.
> But now I'd want to do:
> 
> sage: solve(d(y)==1,y)
> ValueError: Integral has wrong number of parameters
> 
> Even of I try to pass 'y' as parameter in function d, I get an error.
> 
> Is there any way to do it?

Try find_root(). You want a root of d(y) - 1, so try:

find_root(lambda x: d(x) -1, -1, 1)

which gives 0.6667.


Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] Fwd: Sagemath cloud

2014-04-08 Thread Dan Drake
On Tue, 08 Apr 2014 at 10:29AM -0700, William Stein wrote:
> -- Forwarded message --
> From: Martin Smithe 
> Date: Tue, Apr 8, 2014 at 9:50 AM
> Subject: Re: Sagemath cloud
> To: William Stein 
> 
> 
> Hi William
> I am getting there. Can I write
> plot (x^(8/3), (x,-5,5))

Try plot(sign(x)*abs(x)^(8/3),-1,1)

That's in the documentation for plot -- do 

plot?

and look for the above construction (but with 1/3, not 8/3).

Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: Sagetex issues

2014-03-19 Thread Dan Drake
On Tue, 18 Mar 2014 at 01:52PM -0700, sder...@gmail.com wrote:
> It worked! So now I know what to do: point to the right sage exec in the 
> sage app folder lol! There are 2 and my simlink was pointing to the wrong 
> one.

I'm glad to hear you have it working!

I'd like to include some documentation of this. What exactly did you use
for the user command to run Sage?

Thanks,


Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: Sagetex issues

2014-03-18 Thread Dan Drake
Sorry for the delay in replying...

On Thu, 13 Mar 2014 at 08:20AM -0700, sder...@gmail.com wrote:
> For the second method... I have been using TeXMaker 
> for quite a while and I really like the GUI so... I don't know what to do. 
> Should I switch to TeXShop only when I compile with sagetex ?

You can use Texmaker. I downloaded it this morning and figured out what
you can do. (I think this will work -- I'm using Linux, but I think it
will also work on OS X.)

This is with the most recent version of Texmaker (4.1.1).

Under the User menu, go to User Commands, then Edit User Commands. I
used the first entry and called it "Run Sage". For the command, you can
use

sage %.sagetex.sage

Hit OK to save that. Then after you typeset your document, use
Alt-Shift-F1 to run Sage. On my computer, this creates the files in the
correct directory.

Does that help?

Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: Sagetex issues

2014-03-12 Thread Dan Drake
On Wed, 12 Mar 2014 at 10:04AM -0700, sder...@gmail.com wrote:
> Well the only problem is that I... don't use a script haha! I double click 
> on the sage file and a terminal window pops up and sage starts to process 
> the file. I get a few lines telling me it's working on the file and then 
> some files are created in my Home directory :
> 
> E2.sobj
> example.sagetex.scmd.tmp
> example.sagetex.sout.tmp
> and a folder : sage-plots-for-example.tex that contains plot-0.eps and pdf, 
> ..., plot-6.pdf, plot-7.png and plot8-png (and I can open the files so 
> they're not empty).

Ahh, that's very helpful. It looks like the Sage app on OS X is using
your home directory as the working directory. So we need to look at how
that works and get it to use the right directory.

Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: Sagetex issues

2014-03-12 Thread Dan Drake
On Tue, 11 Mar 2014 at 07:26AM -0700, sder...@gmail.com wrote:
> Thank you for your time.
> 
> A bunch of files are created :
> example_doctest.sage
> example.aux
> example.log
> example.out
> example.pdf
> example.sagetex.sage

Okay, so example.sagetex.sage is created. That leads me to think that
the script you're using to run Sage on that file isn't working in the
correct directory. Are you using TeXShop? How are you trying to run
Sage?

You might try putting "pwd" into that script by itself on a line; that
will print the directory the script is working in.


Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: Sagetex issues

2014-03-11 Thread Dan Drake
On Mon, 10 Mar 2014 at 09:08AM -0700, sder...@gmail.com wrote:
> kpsewhich answered :
> 
> sdermon-macbook:~ sdermon$ kpsewhich sagetex.sty
> 
> /usr/local/texlive/2013/../texmf-local/tex/latex/local/sagetex/sagetex.sty

Okay, that looks good. So the problem is example.sagetex.sage doesn't
exist. When you typeset example.tex, what files get created? 

(As for your other message, I think it's very unlikely that there's a
permissions issue.)

Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: Sagetex issues

2014-03-10 Thread Dan Drake
On Sun, 09 Mar 2014 at 07:14AM -0700, sder...@gmail.com wrote:
> Sage commandline 6
> Traceback (most recent call last):
>   File "/Users/sdermon/Documents/popo/example.sagetex.py", line 367, in 
> 
> _st_.endofdoc()
>   File 
> "/Applications/Sage-6.1.1.app/Contents/Resources/sage/local/lib/python2.7/site-packages/sagetex.py",
>  line 282, in endofdoc
> sagef = open(self.filename + '.sagetex.sage', 'r')
> IOError: [Errno 2] No such file or directory: 'example.sagetex.sage'
> logout

My guess is that your TeX is using a version of sagetex.sty that is
generating example.sage, not example.sagetex.sage. What do you get if
you do 

kpsewhich sagetex.sty

in a terminal?

Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


[sage-support] [ali.moha...@stu.yazd.ac.ir: a question about SAGE software]

2014-02-13 Thread Dan Drake
Can someone help this person? I really don't know anything about
Sage/Matlab stuff.

- Forwarded message from ali mohades  -
> Dear professor Drake
> 
> I have a question regarding SAGE software. 
> Is there a way to embed results of a SAGE calculation to a MatLab Software?
> would you please send me commands which help me to export a file from SAGE 
> to MatLab software.
> ???I appreciate if you hint me.
> 
> Thanks in advance???.
> 
> ???Sincerely Yours???,
> ???Ali Mohades???
- End forwarded message -



-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] Sagetex and TeXShop

2013-12-05 Thread Dan Drake
On Wed, 04 Dec 2013 at 03:09PM -0800, philipp.ui...@googlemail.com wrote:
> I'm pretty new to Sage, but it seems to be the program i was searching
> for a quite long time. Basically I'm interested in using sage's
> calculation in TexShop, but something seems to be broken in the
> automation if Sagetex in TeXShop. I hope someone could help me fixing
> the issues i have with it. For sure, I followed the instrutions given
> on the sage website, but for some reason Sagetex isn't working.

The key error message is:

/Applications/sage/local/bin/sage-preparse: File 'example.sage' is
missing

It looks like TeXShop's script assumes that SageTeX produces a file with
a ".sage" extension -- but that has long since changed; the generated
Sage files have an extension of ".sagetex.sage".

I forget exactly where TeXShop stores the scripts that run Sage (I think
it defaults to ~/Library/TeXShop/Engines/Inactive/Sage), but you can
edit that script -- there should be something in it that runs Sage on
"something.sage" (where "something" is perhaps $1 or other shell
stuff); you should change that to something.sagetex.sage.

Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: Inability to compute limit.

2013-11-08 Thread Dan Drake
On Fri, 08 Nov 2013 at 01:41PM -0800, kcrisman wrote:
> Dan, I'm on a train with horrible internet - can you open a ticket, post to 
> the Maxima list, etc.?  Thanks!

This is now http://trac.sagemath.org/ticket/15386.


Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: Inability to compute limit.

2013-11-08 Thread Dan Drake
On Fri, 08 Nov 2013 at 01:03PM -0800, kcrisman wrote:
> Note the "und" - undefined.  Maxima is probably noticing the (-1)^n piece...

I'm not sure it's the (-1)^n. I tried using cos(pi*n) instead and still
get "und":

sage: n = var('n')
sage: assume(n>0)
sage: series = -(3*n^2 + 1)*cos(pi*n)/sqrt(n^5 + 8*n^3 + 8)
sage: limit(series, n=infinity)
6/5*pi*und + 2/5*und

But observe:

sage: series = -(1)*cos(pi*n)/sqrt(n^5 + 8*n^3 + 8)
sage: limit(series, n=infinity)
0

(It also works with (-1)^n.)

It looks like Maxima is actually getting confused by the n^2 in the
denominator. Not sure what it's doing to find the limit.


Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] makestatic.py doesn't work?

2013-10-03 Thread Dan Drake
On Thu, 03 Oct 2013 at 02:03PM +0900, Iwao Kimura wrote:
> I'm testing some features of SageTeX.
> I found makestatic.py does not work properly.

That script has not been maintained well. (And by "not well", I mean
"not at all"!) I'm not surprised it has bitrotted. I'll take a look at
your errors and see if I can figure out what's going on.


Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] sagetex and beamer

2013-09-13 Thread Dan Drake
On Thu, 12 Sep 2013 at 04:06PM -0700, William Stein wrote:
> Did anybody write (or consider writing) the other approach to this,
> which is a tex file
> that gets processed directly by sage to make another tex file, which
> is then compiled.
> This is trickier for tools, but recently Harald pointed out to me that
> this is exactly what they do with R, and it works really well -- with
> something like that you have a lot of power... but it causes havoc for
> things like inverse/forward search, which bugs me.

I agree with Volker. I have thought about it, but you have to parse a
TeX file -- and my undrstanding is that the only thing around that can
really parse arbitrary TeX files is...the tex binary. TeX is a
programming language that can to some extent alter its syntax on the
fly, which makes parsing challenging/nightmarish.

That's part of why I believe that Rob Beezer's idea of writing his books
in XML is actually really smart. Because his book is in a perfectly
parseable format right from the start, he gets access to lots of great
tools, and can still turn his XML into TeX and typeset as normal.

(No, I'm not advocating everyone stop writing TeX and convert to some
XML dialect!)


Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] sagetex and beamer

2013-09-12 Thread Dan Drake
Hi David,

On Thu, 12 Sep 2013 at 11:51AM -0600, David Roe wrote:
> I'm trying to write some sagetex code that generates row reduction examples
> for matrices and I ran into a compatibility problem that seems to be
> different from the ones described in section 4.1 of the Sagetex manual.
> Here's a minimal example:

I'll try to dig into the details here (but I'm super busy with other
stuff, so realistically it may take me a while) but I do know that
Beamer does a lot of fancy stuff with its environments that make things
like your example not work as expected. There may be a limit to how far
you can push the Beamer/SageTeX combo.

Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] Another infelicity in sagetex : example.tex does not run with tikz prts uncommented (they did...)

2013-08-16 Thread Dan Drake
On Thu, 15 Aug 2013 at 12:40PM -0700, Emmanuel Charpentier wrote:
> I already reported problems with sagetex (version 5.10). Perusing the 
> sage-support archive hinted at possible problems due to deficient 
> installation with a semi-broken gcc (I'm usind Debian testing?
> So I bit the bullet and recompiled another Sage with SAGE_INSTALL_GCC=yes. 
> This was successful, but I ran into another problem with sagetex.

I haven't looked carefully at your TeX stuff yet, but it's very, very
unlikely that gcc is to blame for anything related to SageTeX. If
there's a problem, it's almost always with TeX or at the Python level in
Sage.

Dan

-- 
---  Dan Drake
-  www.math.wisc.edu/~ddrake/
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: Problem with sagetex with a large file (many sage calculations)

2013-05-04 Thread Dan Drake
On Fri, 03 May 2013 at 01:34PM -0700, Volker Braun wrote:
> Can you open a trac ticket with a minimal testcase? I realize that 
> "minimal" means pretty lengthy for your problem, but without any way to 
> reproduce it this is not going to get fixed.

Yes, please open a ticket with a testcase. I'd like to see what is
happening. 

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: sage is filling up my directory with files

2013-04-24 Thread Dan Drake
I've used attach and load for years without ever encountering this
problem. So there must be something about the code in your
threshold.sage file. Without seeing it, it's not likely we can help you.

On Wed, 24 Apr 2013 at 10:57AM -0700, davidp wrote:
> I think this problem has to do with attaching a file.  I noticed that 
> "attach" has been deprecated.  Using either 'attach' or '%attach' seems to 
> cause the proliferation of extra files.  The 'load' command or '%runfile' 
> does not seem to have this behavior.  The problem with the 'attach' command 
> seems like a bug to me.  Shouldn't these extra files be stored in some tmp 
> file in the sage directory that get erased at the end of the session, or 
> something like that?
> 
> Thanks,
> Dave
> 
> On Wednesday, April 24, 2013 8:53:56 AM UTC-7, davidp wrote:
> >
> > I just installed Sage 5.8 and am running it from the command line.  For 
> > some reason, it is filling up my directory with what looks like temporary 
> > files, e.g., threshold.sageJmarTS.py,  threshold.sageR9Gfg9, and on and 
> > on.  (I  attached code contained in a file called 'threshold.sage'.  I get 
> > the same behavior from other attached files.)  These files remain in the 
> > directory after i quit Sage.  Could someone tell me what's wrong?
> >
> > Thanks,
> > Dave  
> >
> 


Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: No DPI information in PNG files (parametric_plot3d)

2013-04-24 Thread Dan Drake
On Wed, 24 Apr 2013 at 10:31PM +0400, LRN wrote:
> As an experiment, try creating a simple image (say, a rectangle of
> 100x100 pixels), then save it as png, create multiple copies and give
> them different DPI values in Gimp.

The key idea, it seems to me, is that *I* am the one giving the image
different DPI values. The computer cannot, without input from me, figure
out what I want.

Discussions like this are part of why I would like vector-based output
for our 3D plotting.

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: No DPI information in PNG files (parametric_plot3d)

2013-04-24 Thread Dan Drake
On Wed, 24 Apr 2013 at 06:44AM -0700, LRN wrote:
> That said, i've noticed that you're using [scale=.4]. How would it look 
> without scale=.4? The point is that DPI info should allow typesetter to 
> guess image size correctly, and it should look OK without scaling.

Let me admit my ignorance here: for computer-generated raster graphics,
I don't understand what DPI might even *mean*. Let's say I use Sage to
make an images that 500 pixels by 500 pixels. To assign a meaningful
dots-per-inch value, you need to have an idea of how large the image
should appear. That seems ill-defined to me: the monitor I'm using right
now is around 90 dpi; my Nexus S smartphone is 233 dpi. (I'm assume
"dot" = "pixel".) How can Sage know the properties of the physical
display, or what the user wants? Maybe there's some standard or
mechanism that I don't know about, but it seems like this is something
we can't solve for the user.

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Short and localized measurement units names. Also typesetting

2013-04-24 Thread Dan Drake
On Wed, 24 Apr 2013 at 06:09PM +0400, LRN wrote:
> So, i can do things like:
> M = units.length.meter
> S = units.time.second
> speed = 2 * M/S
> speed
> 
> and get:
> 2*meter/second
> 
> or (in typesetting mode):
> \frac{2 \, \mbox{meter}}{\mbox{second}}
> 
> I have three problems with this.

I would recommend trying to use the LaTeX package SIunitx [1], which
works very hard to typeset units properly and supports localization. I
haven't thought of a nice way to get that to interact with SageTeX --
I've always just taken the number and used SIunitx to add the units.

I'd like to see units typeset themselves with SIunitx, but I'm not sure
how that would work with the notebook and MathJax.

Dan


References:
[1]  http://ctan.org/pkg/siunitx

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] No DPI information in PNG files (parametric_plot3d)

2013-04-23 Thread Dan Drake
On Tue, 23 Apr 2013 at 02:15PM +0400, LRN wrote:
> If you typeset it (i'm using XeLaTeX and SageTeX), you'll see that png
> files are upscaled (badly, i might add). Turns out - they lack DPI
> information. If you typeset it (completely, with XeLaTex+Sage+XeLaTeX
> dance) once, then open up the png file it produces and change its DPI
> metadata (in Gimp - Image->Print size...) to 300ppi, save it, then
> typeset it again (without running Sage to re-generate the image this
> time), it would render correctly on a page.
> 
> In the attached file i'm using width=4.2cm to do the same thing
> indirectly, to demonstrate how the image should look, but that's
> inconvenient (you have to do the math yourself and specify correct
> width and figsize (if needed) separately).

The 3D plot handling has never been very good; it's harder to work with
PNG files from TeX than vector formats such as EPS or PDF. And with so
many options for the graphics commands, it's hard to come up with
defaults that will make users happy while still allowing some people to
fiddle with them. The rendering, I think, is by Tachyon, not matplotlib.

> P.S. Note that i have to specify [png] when invoking sageplot,
> otherwise SageTeX will fall back to png, but then claim that png is
> unsupported (bullshit)

SageTeX uses the ifpdf package to detect PDF output; that message is
printed whenever \ifpdf is false. But that package doesn't work with
XeLaTeX. I can add in a check for that.



Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: Sage+TeX for Windows dummies

2013-04-22 Thread Dan Drake
On Mon, 22 Apr 2013 at 05:55AM -0700, kcrisman wrote:
> Dan, this seems like it might be a useful thing to include with SageTeX, 
> unless TeXWorks is planning on including this in an update.  It's just a 
> shell script, and could be put in an appropriate directory along with 
> updated Sage documentation for what to do if you are on Windows.

I looked it over. In any case, some instructions for Texworks users
would be nice. I like the idea of "standardizing" on Texworks, which
works on Windows, Mac, and Linux.

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: Sage+TeX for Windows dummies

2013-04-19 Thread Dan Drake
On Fri, 19 Apr 2013 at 05:47AM -0700, LRN wrote:
> Eventually i ended up setting up Debian in a VM, installing Sage,
> texlive, TeXWorks, and hooking it up to SageTeX. I have a problem
> though: TeXWorks does not run Sage automatically. There seems to be a
> way to run Sage from TeXShop, but TeXShop is not available as a
> package in Wheezy, so i'm stuck with TeXWorks. Is there a way to
> integrate it with SageTeX?

I don't know of a way. I want to look into Texworks and figure out if
that's possible, but right now I don't have a lot of time. I do see on
the Texworks site that they have some kind of scripting functionality --
what you want is something that automatically runs Sage after
typesetting. If they don't have that, you can always open a terminal and
run Sage there whenever you change any of the SageTeX commands in your
document.

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: Sage+TeX for Windows dummies

2013-04-18 Thread Dan Drake
On Sat, 13 Apr 2013 at 06:46PM -0700, kcrisman wrote:
> Dan, do you have any tips for using SageTeX on Windows?

I'm a bit late here, but sadly my only tip is: switch to OS X or Linux.
Which I know is not always a good option.

Until we have a working Cygwin port, I don't see any good options for
Windows. For now, the notebook is definitely the way to go.

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] generate latex from symbolic expression without \;

2013-04-09 Thread Dan Drake
On Tue, 09 Apr 2013 at 01:55AM -0700, shersonb wrote:
> As it stands, latex(2*x) will return:
> 
> 2 \, x
> 
> and thus leaves a space between the 2 and the x when compiled. This
> does not look very good, IMO. Is there an option some where that I can
> set so that this behavior is avoided, so that the above will return "2
> x" instead?

I would also like to remove those hard-coded spaces. It makes SageTeX
much less pleasant, since the output looks weird.

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: Help with SageTeX

2013-04-07 Thread Dan Drake
On Sun, 07 Apr 2013 at 01:34AM -0700, Gabriel wrote:
> Any ideas on this problem of double questions marks "??" in LaTeX with
> SageTeX ?

If you're seeing those, you haven't run Sage on the generated
.sagetex.sage file, or haven't typeset again after doing so.

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: Fwd: sage.maa.org

2013-04-04 Thread Dan Drake
On Thu, 04 Apr 2013 at 05:06AM -0700, kcrisman wrote:
> Now that I think about it, you shouldn't be able to make an account on it 
> anyway...  Dan, that's probably because OpenID is now allowed or something. 
>  In principle, one should have to know "the magic word" which only PREP 
> participants got. 

The version of Sage on that server predates the OpenID stuff, so AFAIK
the only way to get an account is knowing the magic word.

I do plan on upgrading the version of Sage after the semester is over,
so I'll make a note to disable OpenID logins when I do that.

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: sagetex documentation

2013-03-09 Thread Dan Drake
On Sat, 09 Mar 2013 at 06:06PM +, John Cremona wrote:
> Thanks, I have that file too: so the only error is in the
> documentation which gives the wrong path to the file.

This is now http://trac.sagemath.org/sage_trac/ticket/14264 .

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: sagetex documentation

2013-03-09 Thread Dan Drake
On Sat, 09 Mar 2013 at 06:06PM +, John Cremona wrote:
> I did not think that the Sage source distribution included pdf files,
> but it appears that I was wrong.

SageTeX includes PDFs of the documentation because we don't want to
assume a working TeX distribution is present. (Although if you don't have
such a thing, you likely won't be using SageTeX...) There's also the
typeset version of the example file, which is nice so users can compare
the source and the output. The PDFs add about 400 KB to the source
tarball which is reasonable, considering we also ship a compiler!

I do notice that the share/doc/sagetex directory doesn't have the
example.tex file, which it should. I'll try to fix that and change the
documentation.

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: Sagetex

2013-02-24 Thread Dan Drake
On Fri, 22 Feb 2013 at 07:50PM -0800, Nathan Carter wrote:
> Aha! After investigating a bunch, it turns out that I haven't updated my
> texlive install since the dawn of time,

That's pretty common with TeX installations, and it's a source of many
headaches with SageTeX!

> and a sagetex.sty comes with that and supercedes everything else. I'm
> in the process of upgrading my texlive install and we'll see if that
> fixes the problem. (Of course, if I could just reorder the paths in my
> kpsewhich -show-path=tex list, I could just prioritize the one that
> has the new sagetex.sty, but I don't know how to do that and the web
> wasn't helping, so I'll update texlive instead.)

A simpler fix is to simply delete or rename the sagetex.sty in the
TeXLive installation. But upgrading works too. :)

Glad to hear it's fixed.

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: Sagetex

2013-02-22 Thread Dan Drake
On Fri, 22 Feb 2013 at 07:05AM -0800, Nathan Carter wrote:
>6. Whether I run with the TeXShop engine (which indeed runs sage on the 
>.sage file) or do it manually (just LaTeX the file within TeXShop, then 
> run 
>sage from Terminal myself) I get the same error as the original poster, 
> AttributeError: 
>'module' object has no attribute 'openout'.

That's very strange. You have Sage 5.3, so you should have a pretty
recent version of SageTeX, but as far as I can tell, the openout problem
can only arise if you're using a really, really old version of SageTeX. 

Can you look at the top of the generated .sagetex.sage file and see if
it starts with something like:

## -*- encoding: utf-8 -*-
## This file (example.sagetex.sage) was *autogenerated* from example.tex
## with sagetex.sty version 2012/01/16 v2.3.3-69dcb0eb93de.

Your TeX installation might somehow be using an older .sty file (despite
your symlink, which seems like it should work fine) and generating a bad
.sage file. That's my best guess right now.

Inside Sage, you could do

   import sagetex
   sagetex.__version__

and see if it matches what the generated .sage file says.

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: sagetex difficulty

2012-12-15 Thread Dan Drake
On Sat, 15 Dec 2012 at 10:55AM -0800, pong wrote:
> Hi Dan my intention is to generate tests using sagetex and sage. So I will
> have something like
> 
> m = 'undefined' if denom==0 else (y2-y1)/(x2-x1)
> 
> .
> 
> then print out m at some point. So $\sage{m}$ does not work is denom==0
> but \sagestr{m} doesn't seem to work if denom<>0.
> Any suggestion?

You'll have to push the "use $ or not" decision to the Sage level. Try
something like this:


\begin{sagesilent}
  def f(x, y):
  if y == 0:
  return 'undefined'
  else:
  return '${0}$'.format(latex(x/y))
\end{sagesilent}

abc \sagestr{f(1, 2)} def \sagestr{f(1, 0)} ghi

That may be a little unsatisfying, but it should work. You could also
make your typing a little easier with something like

\newcommand{\foo}[2]{\sagestr{f(#1,#2)}}

(With "foo" and "f" changed to something meaningful.) Then you do
\foo{1}{2} in your document and it's easier to understand.

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: sagetex difficulty

2012-12-15 Thread Dan Drake
On Sat, 15 Dec 2012 at 02:45AM -0800, pong wrote:
> I am having the same trouble as John. Would you expand a little bit on your 
> solution:
> 
> for example
> $\sage{'Hello'}$
> causes an error. Where should I put the 'r' as suggested in your post (I 
> think stands for raw string)? I tried several combination but nothing seems 
> to work.

It causes an error because the \sage{} macro runs Sage's latex()
function on its argument, which in this case produces "\verb|Hello|".
Then TeX gets unhappy because of the verbatim text inside a math
environment.

If you just want the string 'Hello' inserted into your document, use
\sagestr{}. Or, don't surround \sage{} with dollar signs.

> > SAGE should not read Python escape codes inside $'s. As you've
> > noticed from the error message, SAGE doesn't even know it's still
> > doing it. It thinks it's parsing LaTeX.

There is no (easy/reasonable) way for SageTeX to detect whether \sage{}
was called within a math environment, and in any case, altering Sage's
behavior with respect to Python string conventions would require a lot
of work in the preparser that (1) would be difficult, and (2) represent
a large deviation from standard Python behavior that almost no one would
think is reasonable. (That's what I think, at any rate...)

Also, as was pointed out, you can use raw strings to avoid that
behavior. TeX is completely oblivious to the difference between
\sage{r"\nabla"} and \sage{"\nabla"}, so you can always use the former
to get your intended behavior.

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Matrix question

2012-11-26 Thread Dan Drake
On Mon, 26 Nov 2012 at 11:34AM -0800, Ken Levasseur wrote:
> I'm writing up some notes on matrices for my students and ran into this 
> inconsistency (I think).  I start by creating a matrix and augment its 
> transpose, just to have a non-square matrix:
> 
> A=Matrix([[3,1],[-1,2]])
> B=A.transpose()
> C=A.augment(B)
> 
> Now if I ask for the echelon form of C, I get this result, which isn't 
> fully reduced:
> 
> C.echelon_form()
>   [1 5 5 3 ]
>   [0 7 6 5 ]
> 
> 
> That's fine because 
> C.parent()
>Full MarixSpace of 2 by 4 dense matrices over Integer Ring
> 
> But I would expect that the inverse of A wouldn't be computed under this 
> condition, but
> 
> A.inverse()
>[ 2/7  -1/7 ]
>[1/73/7 ]
> 
> Is there a logical reason why this happens?

Good observation. I think the answer is that inverse() always bumps up
to the fraction field if the parent isn't a field. So when you ask for
the inverse, you are implicitly asking to change the parent if
necessary; echelon_form() doesn't include that implicit request. 

I'm not sure if that's a "logical reason", but most people seem to like
it. Should we have a "strict inverse" that throws a ValueError -- or
ZeroDivisionError -- when the parent isn't a field? (That's not
rhetorical or sarcastic, I really wonder if anyone thinks that's a good
idea.)

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] java style output format

2012-11-26 Thread Dan Drake
On Mon, 26 Nov 2012 at 10:10AM -0800, ijt wrote:
> I was wondering if there is any way to make sage produce an output
> that I can directly use in java code? I am using sage to compute
> gradients and hessians of multidim. functions which become quite large
> and replacing everything by hand is quite annoying.
> 
> For example, sage returns something like:
> 
> exp(x^2*log(z)-sqrt(y^5))
> 
> which in java code would look like
> 
> Math.exp(Math.pow(x,2)*Math.log(z)-Math.sqrt(Math.pow(y,5)))

I don't have a good answer for this (other than string manipulation and
regex matching -- if you want to be a little fancier, try the pyparsing
module), but there's a more general question here: how to rewrite Sage
expressions into other forms?

In some sense, we already do this in many places (the pty interfaces,
the LaTeX output), but I wonder if there's a nice way to overload some
of that stuff and define your own outputs, so that "exp()" becomes
"Math.exp()", just like

    latex(sin(x))

is

 \sin\left(x\right)


Thoughts?

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


[sage-support] graphics_array only shows axes labels on final plot

2012-10-17 Thread Dan Drake
Hello,

I did

sage: p = plot(arccosh(x/cos(x)), (x,5,6), axes_labels=['x','y=arccosh(x/cos 
x)'])
sage: q = plot(arcsin(-y/sinh(y)) + 2*pi, (y, 2.5, 3.4), 
axes_labels=['y','x=arcsin(-y/sinh y)'],color='red')
sage: graphics_array([p, q]).show()

and expected to see my axes labels on both plots -- but I only get the
label on the *second* plot. If you switch p and q, you still get the
label on the second plot. If I do [p, q, p], I only get the label on the
final plot.

This seems like a bug. Is there a workaround? (I have a talk this
afternoon and I'd like it to work!)

Thanks,

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: can't exponentiate an mpmath mpf number

2012-10-16 Thread Dan Drake
On Tue, 16 Oct 2012 at 11:00AM -0700, kcrisman wrote:
> This will call self.exp(), and apparently mpf numbers don't exponentiate 
> with that function, but instead:
>  
> def exp(self):
> """
> Returns the binary exponent of self ::
> 
> sage: from mpmath import mpf
> sage: mpf(1/64.).exp
> -6
> """
> return self._mpf_[2]
> 
> So there is a name conflict that exp(a) calls a.exp() but in mpmath this 
> does something totally different.
> 
> sage: a = mpmath.mpf('-0.0712959029907420240935')
> sage: a.exp
> -56
> sage: type(a.exp)
> 
> 
> Yup, can't call that.

Good find. This is now http://trac.sagemath.org/sage_trac/ticket/13608.

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


[sage-support] can't exponentiate an mpmath mpf number

2012-10-16 Thread Dan Drake
This is strange:

sage: import mpmath
sage: exp(mpmath.mpf('-0.0712959029907420240935'))

raises "TypeError: 'int' object is not callable". I can, of course, use
mpmath.exp on the number, but I would expect automatic conversion. 

This works, though:

sage: exp(-0.0712959029907420240935) 
0.93118631054266770709

And if I wrap the mpf in "N( )" to explicitly convert to a regular Sage
float, it works. 

I'm using 5.3 on 64-bit Linux. Is this expected behavior, or a bug?

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] SEGV in libatlas.so

2012-10-12 Thread Dan Drake
On Fri, 12 Oct 2012 at 05:21PM +0300, Georgi Guninski wrote:
> Simpler testcase:
> 
> g=graphs.CycleGraph(44);m=g.adjacency_matrix()
> m^7

This works for me. You'll need to give more information before anyone
can help you -- platform, whether you compiled yourself or use a binary,
etc.

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: why I can use "sage-slide.tex" to generate math output

2012-10-03 Thread Dan Drake
On Wed, 03 Oct 2012 at 07:34AM -0500, Jason Grout wrote:
> > the first, I use
> > latex sage-slide.tex
> > but the output is "sage-slide.sage" not "sage-slide.sagetex.sage"
> 
> That tells us that you are probably using a very old version of Sage.
> That may be the problem. What version of Sage are you using?

That's definitely an old version of SageTeX there. (In fact, it was you,
Jason, who suggested the name change! That was a good idea.) The
original poster should definitely upgrade to a newer version of Sage.


> > next, I use
> > sage sage-slide.sage
> >
> > the error msg is
> > Traceback (most recent call last):
> > File "sage-slides.py", line 5, in 
> > sagetex.openout('sage-slides')
> > AttributeError: 'module' object has no attribute 'openout'

That is really strange. SageTeX's Python module doesn't have any openout
function, and according to "hg grep", it never did. There's no openout
anywhere in the Sage source. I have no idea where that came from.

Upgrading to the most recent version of Sage sounds like the best thing
to do here.

Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] What's wrong with this comparison?

2012-09-12 Thread Dan Drake
On Wed, 12 Sep 2012 at 10:14PM +0800, P Purkayastha wrote:
> Can anyone point out what is wrong with this comparison:
> 
> sage: 0.2 + 0.1 == 0.3
> False
> 
> It seems baffling that something as simple as this returns False.

Off the top of my head, I'd say it's because comparing floating-point
numbers is tricky. As I understand, none of those numbers can be
expressed exactly as a float, so internally Python/Sage/whatever is
using an approximation -- and after the addition, the error is big
enough to return False.


Dan

--
---  Dan Drake
-  http://math.pugetsound.edu/~ddrake
---


signature.asc
Description: Digital signature


Re: [sage-support] Package to Draw Geometrical Figures

2012-07-07 Thread Dan Drake
On Sat, 07 Jul 2012 at 10:54AM -0700, ObsessiveMathsFreak wrote:
> Is there a sage package that allows quick and simple drawing of geometrical 
> (esp. euclidean) figures. Just a way to draw points, lines, circles, and to 
> mark angles and lengths in a shorthand way.
> 
> Something like tkz-euclide, but within sage.

I don't know if this is exactly what you want, but do investigate
GeoGebra (http://geogebra.org). With it, you can make very nice
Euclidean figures and export them to HTML, TikZ, and others.

It's not part of Sage, but it works very well and I like it a lot.

Dan

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


signature.asc
Description: Digital signature


[sage-support] change the default viewpoint in a 3D plot?

2012-06-28 Thread Dan Drake
Here's a question about changing the viewpoint in a 3d plot:

- Forwarded message from "Gagnon, Jacob A" -
> Thanks. The server is up now. I have quick question about plot3d. If
> you try my interact at http://users.wpi.edu/~jgagnon/sagetest.html
> with parameters 0, 0, 0.75, 2, 2, then the orientations of the contour
> plot and 3d plot are not aligned. How do I make the default
> orientation of the 3d plot be a XY plane view with an additional
> slight rotation about the x axis? I would like to do this
> automatically instead of right click view XY plane and then rotate
> about the x axis with the mouse.

The relevant code is:

@interact
def _(mux=slider(-2,2,0.5,default=0,label='mux'),muy=slider(-2,2,
0.5,default=0, label='muy'),rho=slider(-0.75,.75, 0.25,default=0,
label='rho'),sx=slider(0.1,2, 0.1,default=1,
label='sx'),sy=slider(0.1,2, 0.1,default=1, label='sy')):
f(x,y) =

1/(2*pi*sx*sy*sqrt(1-rho^2))*exp(-1/(2*(1-rho^2))*((x-mux)^2/sx^2+(y-muy)^2/sy^2-2*rho*(x-mux)*(y-muy)/sx/sy))
g(x)=f(y=0)
h(y)=f(x=0)
p1=contour_plot(f(x,y),(x,-5,5),(y,-5,5),cmap='hsv')
p2=plot3d(f(x,y),(x,-5,5),(y,-5,5))
p3=plot(g(x),(x,-5,5))
p4=plot(h(y),(y,-5,5))
show(p1,figsize=3)
show(p2,figsize=3)


Do we have a way of specifying a viewpoint when doing a 3d plot?

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] sagetex difficulty

2012-06-12 Thread Dan Drake
On Tue, 12 Jun 2012 at 02:49PM +0100, John Cremona wrote:

> The second machine I tried (which I will not have access to until I go
> home) had only just been upgraded to ubuntu 12.04, so it is surprising
> that it's using an old texlive version.

Debian (and hence Ubuntu) only has TeXLive 2009. I don't really know why
they've had such trouble packaging a newer version, but in any case,
both Debian and Ubuntu package maintainers have utterly ignored my
requests to remove the extra files:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=655545
https://bugs.launchpad.net/ubuntu/+source/texlive-extra/+bug/512284

> Now I have (following your instructions very carefully ;))
> 
> jec%ls -l /usr/share/texmf-texlive/tex/latex/sagetex
> total 20
> -rw-r--r-- 1 root root  5807 Jun 21  2009 old-crappy-sagetex.sty
> -rw-r--r-- 1 root root 10487 Jun 12 14:44 sage-5.0-sagetex.sty
> lrwxrwxrwx 1 root root20 Jun 12 14:44 sagetex.sty -> sage-5.0-sagetex.sty
> 
> and all is well!

Using the symlink and a versioned filename is a nice idea.

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] sagetex difficulty

2012-06-12 Thread Dan Drake
On Tue, 12 Jun 2012 at 09:57AM +0100, John Cremona wrote:
> You are right: it shows
> 
> (/usr/share/texmf-texlive/tex/latex/sagetex/sagetex.sty
> 
> (which I should have noticed yesterday, sorry), despite this:
> 
> jec%kpsewhich sagetex.sty
> /home/jec/texmf/tex/generic/sagetex/sagetex.sty

Aha! Once again I am bitten by TeXLive. Putting SageTeX into TeXLive was
a big mistake.

I am puzzled by kpsewhich returning the newer version, though -- I
thought the very idea of that program was to return what TeX would find
when typesetting. But it seems not.

> I could get round this (as I have root access) by killing the old
> texlive version, but there should be a better way.

Removing the old version is actually a very good solution. If you want
to be very cautious, just rename
/usr/share/texmf-texlive/tex/latex/sagetex/sagetex.sty to
"old-crappy-sagetex.sty" or whatever. You could also update to a newer
version of TeXLive, but getting rid of the old sagetex.sty solves the
immediate problem.

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] sagetex difficulty

2012-06-11 Thread Dan Drake
On Mon, 11 Jun 2012 at 05:37PM +0100, John Cremona wrote:
> 3. I ran latex on that file twice.  A file example.sage was created.

That's the weird thing to me: on the LaTeX end, if you're using
sagetex.sty as included with 5.0, it should create
"example.sagetex.sage". If it made example.sage, then it must be an
older version of sagetex.sty that somehow got used.

Can you try doing

$ latex example.tex | grep sagetex

That should give you a full path to whatever LaTeX is using when
typesetting your file. That *should* be the same as what "kpsewhich
sagetex.sty" returns, but perhaps something strange is happening.

> What did I do wrong?  By the way, if I cd into
> $HOME/texmf/tex/generic/sagetex/  and there run latex on the
> example.tex file there, it creates a file example.sagetex.sage on
> which sage runs fine, and after rerunning latex (twice) I get a dvi
> file which looks perfect.

That tells me that LaTeX must be getting confused somewhere. We just
need to figure out what wrong version of sagetex.sty it is finding.

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Crash report: integral of ln(1+4/5*sin(x)) crashes Maxima and Sage

2012-06-07 Thread Dan Drake
On Thu, 07 Jun 2012 at 02:13PM -0700, Benjamin Jones wrote:
> On Mac OS X 10.6.8 intel core i7 and sage-5.0 (also sage-5.1.beta2) I can 
> crash sage (and Maxima) by evaluating:

I tested this on 4.8 and all of the 5.0 betas I have around. This is on
an 8-core Xeon machine running Ubuntu 12.04 (but the binaries were built
when it was 10.04):

drake@sagenb:~/s$ for d in sage-* ; do echo -n $d && $d//sage -c
"x=var('x');print integrate(ln(1+4/5*sin(x)), x, -3.1415, 3.1415)" ; done 

resulted in

sage-4.8: integrate(log(4/5*sin(x) + 1), x, -3.1415, 3.1415)
sage-5.0.beta1: integrate(log(4/5*sin(x) + 1), x, -3.1415, 3.1415)
sage-5.0.beta2 integrate(log(4/5*sin(x) + 1), x, -3.1415, 3.1415)

All these failed:

sage-5.0.beta3
sage-5.0.beta4
sage-5.0.beta5
sage-5.0.beta6
sage-5.0.beta7
sage-5.0.beta8
sage-5.0.beta9
sage-5.0.beta11
sage-5.0.beta12
sage-5.0.beta13
sage-5.0.beta14
sage-5.0.rc0
sage-5.0.rc1
sage-5.0

sage-5.1.beta0
sage-5.1.beta1
sage-5.1.beta2

So we should look between 5.0.beta2 and 5.0.beta3, I guess.

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Re: maximization on interval

2012-05-25 Thread Dan Drake
On Fri, 25 May 2012 at 08:53AM -0700, MathLynx wrote:
> But why does minimization seem to work fine?

H, I didn't read your message carefully enough. The "maximize"
version just calls the minimize function with the negative of the
function. I've been working on ticket #2607, so maybe I'll try to track
down what is happening. 

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Re: maximization on interval

2012-05-24 Thread Dan Drake
On Thu, 24 May 2012 at 03:15PM -0700, MathLynx wrote:
> So here are two work-arounds:
> 
> A=find_minimum_on_interval(-x*sin(x),.5,2.5)
> (-1)*A[0]
> 
> and
> 
> A=x*sin(x)
> A.find_maximum_on_interval(.5,2.5)
> 
> - but neither of these is really satisfying.  A function as fundamental as 
> max of a continuous function over an interval should not run into and error 
> message like

I get the same message for some symbolic functions; it seems like trig
functions, uh, trigger the bug. As a workaround, you can do "lambda x:
x*sin(x)" to get it to work.

(Although see http://trac.sagemath.org/sage_trac/ticket/2607 for other
problems with that function.)

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Still no way to use interact in published notebooks?

2012-05-07 Thread Dan Drake
On Mon, 07 May 2012 at 09:54PM -0700, allycat wrote:
> I have spent the past few days trying to figure out the best way to
> make an interactive web application related to some computational
> biology calculations. It seems like Sage could be a great way to do
> this: the code could easily be written in Sage and @interact could be
> used to create the desired parameter input from the user. However, I
> need a way to allow the public to interact with such a program. I
> thought that since Sage worksheets can be published, this would be
> easy. However, it seems like @interact does not work in published
> worksheets! There are some threads on this from a few years ago. Has
> this issue been solved since then? If not, does anyone know any
> work-arounds or other ways to create applet like functionality from
> Sage?

Try the Sage cell server: aleph.sagemath.org. 

>  (2) I am hiring somebody (thanks to NSF funding) right now to create
> a system for using @interact completely outside of the Sage notebook.

I think Jason Grout and his students beat you to that. :)

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Array and Loop in Sagetex

2012-05-03 Thread Dan Drake
On Thu, 03 May 2012 at 04:58PM +0530, Priyanka Kapoor wrote:
>  \begin{sageblock}
> v= [x^2, sin(x)]
>  \end{sageblock}
> 
>  Here's a plot of $f$ from $-2$ to $2$:
> for i in range(2):
> \sageplot[width=10cm]{plot(v[i],(x,
> -2,2),legend_label='sin(x)',aspect_ratio =1)}
>  \end{document}

You are putting Python code into your TeX document, but TeX will typeset
it, not ask Python/Sage to process it.

It looks like you want TeX to do the loop. Try the forloop package:
http://www.ctan.org/tex-archive/macros/latex/contrib/forloop/

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] sagetex question

2012-03-30 Thread Dan Drake
On Fri, 30 Mar 2012 at 11:24AM -0700, Tom Judson wrote:
> I have a question about sagetex.  Is it possible to run sagetex if you are 
> using a remote server as opposed to a local copy of sage.  I run sagetex 
> locally on my Mac, but I have a graduate student who would like to use 
> sagetex on a PC.  She is currently doing all of her Sage computations on a 
> server.  Does anyone have experience with this?

The remote-sagetex.py tool was designed for that...but it was relatively
brittle to start with, and (as Jason pointed out) has been broken for a while. 
:(


On Fri, 30 Mar 2012 at 01:34PM -0500, Jason Grout wrote:
> There used to be a way, but it's currently broken, and no one (that
> I know) has fixed it yet.
> 
> It would be cool if someone could change it to use aleph to do the
> computations.

I suppose you have a certain someone in mind... :) I'll look over the
cell server docs and think about this.

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Separation of constants.

2012-03-28 Thread Dan Drake
On Tue, 27 Mar 2012 at 11:21PM -0700, Eric Kangas wrote:
> I have this long chain of terms with with many constant terms. I would like 
> to know if there is a way to separate the constant terms from the terms 
> with the variable I am trying to solve for with the solve function. So I 
> don't have to wait as long for the solve function to go through each 
> non-relevant term.

Some kind of .coeffs() call should work:

sage: x,y,z = var('x y z')
sage: foo = x*2*y + x*y*z + y*z + z + 1
sage: foo.coeffs(x)
[[y*z + z + 1, 0], [y*z + 2*y, 1]]

If y and z are constants, then the ", 0" element of the list
(coefficient of x^0) is the constant coefficient of "foo".

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Re: sage server in OS 10.6

2012-03-16 Thread Dan Drake
On Fri, 16 Mar 2012 at 04:11PM -0700, Mike OS wrote:
> When I save and quit the worksheet, I go back to my home page.
> If I click sign out, nothing happens.

Are you using Firefox? This happens with some recent versions of
Firefox. Does that same thing happen with another browser?

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] sage server in OS 10.6

2012-03-06 Thread Dan Drake
On Tue, 06 Mar 2012 at 12:53PM -0800, Mike OS wrote:
> I'd like to set up a sage notebook server at my campus. Since this is
> beyond my expertise, I asked the College IT specialists to handle it.
> Of course, they are very concerned about vulnerabilities, so they will
> only allow access from on campus.

That's probably a wise idea.

> 3. The part of the "how-to" instructions that leave me coldest are the
> "here is where we create the accounts sage1 ... sageN" on the server
> and try our best to keep people from exploiting them. They even go as
> far as talking about filesystem ACLs ... which tells me we don't want
> to go anywhere near this.
> 
> So, my question to you, as someone who hopefully understands the
> desired
> outcome better than I, is:
> 
> Does a sage notebook server require interactive logins? I'm thinking,
> but am not quite sure, that the interactive logins are for students to
> run sage from a command line, and as long as one creates sufficient
> accounts in the notebook server itself (not accounts on the host where
> the notebook server is hosted) the notebook server can exist without
> interactive logins.

The mathematician in me wants to say, the computer won't be very useful
if no one can log in and interact with it. So yes, it requires
interactive logins. :)

I think the answer your IT person wants is: no, the "sageN" accounts
don't need to be remotely accessible, but since the users will be given
a full Python process in those accounts, they can do most things that an
interactive login would give them, since they can use os.system() and
the subprocess module, can fork bomb the server, and so on.

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Question about plot

2012-02-23 Thread Dan Drake
On Fri, 24 Feb 2012 at 01:39AM -0200, Juan Grados wrote:
> I need smooth line, (interpolation the points), line(vec) plot line without
> smoth

If a regression line is good enough, see:
http://markmail.org/message/lipt7edldscsaaqb (another one of Jason's
messages!)


Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Re: polygon graph is too small (wrong scale)

2012-02-23 Thread Dan Drake
On Thu, 23 Feb 2012 at 12:31PM -0800, Goebbe wrote:
> @Jason:
> In Sage 4.8:
> When adding a polygon to a plot, the aspect ratio of the polygon is
> used. When adding a plot to a polygon, again, the aspect ratio of the
> polygon is used. This is unexpected.

There was some discussion of plotting and aspect ratios last autumn:

https://groups.google.com/d/topic/sage-devel/dGHy4ZbBa48/discussion
https://groups.google.com/d/topic/sage-devel/kguQRuyNj7c/discussion
https://groups.google.com/d/topic/sage-devel/EAy7ZHh9C6k/discussion

> Would it make sense / would it be possible to keep the default aspect
> ratio of the first graph? My guess it that from the users point of
> view using the aspect ration of the first graph would make a lot of
> sense - at least when the polygon fits into the first graph.

I would find it strange if the sum of plots was noncommutative, at least
in terms of aspect ratio.

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Re: Windows 7, Virtualbox, can't connect to sage server with Chrome

2012-02-13 Thread Dan Drake
On Mon, 13 Feb 2012 at 05:42AM -0600, Jason Grout wrote:
> On 2/13/12 2:42 AM, emil wrote:
> >  When creating it I studied the docs by
> >Dan Drake and Jason Grout in detail and tried to implement it the best
> >I could.
> 
> I should point out that I'm also no pro sys admin, but I try to be
> careful and read a lot about it.

Same here!

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Re: jmol won't display

2012-02-07 Thread Dan Drake
On Mon, 06 Feb 2012 at 08:58PM -0600, Jason Grout wrote:
> Do you have the Sun Java installed, or the Iced Tea thing?  IIRC,
> you need to install the sun jdk; the iced tea version won't work. I
> know others have dealt with java issues with jmol on ubuntu before
> (for example, Dan Drake, if I recall correctly).

IcedTea would almost/sorta/kinda work for me -- sometimes. I've since
just installed Oracle Java. I almost think we should explicitly not
support the IcedTea plugin, since it doesn't seem to actually work
properly.

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Re: Problem with sagetex with a large file (many sage calculations)

2012-01-20 Thread Dan Drake
On Fri, 20 Jan 2012 at 10:51AM -0800, Steven McKay wrote:
> That's the problem.  It only seems to happen when I run desolve_odeint
> several times.  The later runs seem to choke.  Note that sage does
> *not* choke on any later sage calculations other than desolve.
> So, I don't really have a minimal example.  I will try to see if I can
> come up with one, but it might not be that small.  Do you want me to
> send it to you directly?

I spent some time yesterday afternoon, and it does seem like multiple
calls to one of the DE solvers is the problem. But I don't know much
more than that right now.

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Problem with sagetex with a large file (many sage calculations)

2012-01-19 Thread Dan Drake
On Fri, 16 Dec 2011 at 12:41PM -0800, Steven McKay wrote:
> Hi,
> I have been writing a large set of notes for Differential Equations,
> and have come across an annoying problem (that is probably my fault.)
> After adding enough sage constructions to my latex file, I started
> getting errors like:
> 
[...]
> 
> Which repeats over and over many times.  This is only for
> constructions using desolve_odeint, and only for the later sage
> constructions, not the earlier ones. *However*, the same sage code in
> a notebook runs as expected without errors.  So I know I don't have
> any errors in my code that is doing this. In fact, I took the sections
> with the "offending code" and compiled them separately in a smaller
> document, and the sage code ran correctly.
> 
> So, it seems as if I am overloading sage with too many calculations.
> This confuses me, however, because I thought sage did each calculation
> separately.

It does them separately, but all in one session.

I'm not sure what is happening here. Can you provide a minimal example
that demonstrates the problem? I've never seen anything like this, and
can't imagine why it would happen. 

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Two problems using SageTex on Sage 4.7.2

2012-01-19 Thread Dan Drake
On Fri, 16 Dec 2011 at 03:54AM -0800, Anthony Wickstead wrote:
> The first, that I can work around although it is redious, is that
> sagetex when processing "test.tex" now produces "test.sagetex.sage"
> rather than "test.sage". When processed using remote-sagetex.py this
> puts plots into a directory "sage-plots-for-test.sagetex.tex".
> Unfortunately when running LaTeX on test.tex again LaTeX looks in
> "sage-plots-for-test.tex" for the plots. A rename can get around this
> but it is a bit of a pain.

remote-sagetex.py hasn't been maintained very much, and I'm actually a
bit surprised it even works. I've made a note to fix this, which won't
happen in the immediate future because of travel and the start of
classes. But it's on my lsit.

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] sage build FAIL - An error occurred while installing patch-2.5.9.p2

2012-01-19 Thread Dan Drake
Having patch fail to build sounds truly strange. Is your source tarball
corrupt? I'd check the md5sum and make sure it's correct. 

If it is, then something bizarre is happening so that patch isn't
building addext.o, argmatch.o, and those other files.



Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] "sagesilent" block in a "newcommand" macro

2012-01-16 Thread Dan Drake
On Mon, 16 Jan 2012 at 03:10AM -0800, jplab wrote:
> But since I'm a lazy guy, I want tex to do the work for me. That's why
> I thought of a tex command that would:
> 
> 1) take all the needed arguments;
> 2) run a sagesilent block;
> 3) include the produced tikz picture (produced in the sagesilent
> block, included in a file).
> 
> All that in a very nice tex command.
> 
> Something like (replacing the polytope things by a matrix for
> simplication reasons...):
> 
> \newcommand{\tikzimage}[1]{\begin{sagesilent}
>M=matrix([[1,1],
> [2,2]])
>Image=latex(M)
>  
> open('dessin.tex', 'w').write(Image);
>   \end{sagesilent}
>   \input{dessin.tex}
>   }

My first thought is, why do you need to write to an external file? It
looks like you could just do

\newcommand{\tikzimage}[1]{\sage{matrix([1,1],[2,2])}}

Another (untested!) idea is: use a regular sagesilent block to set up a
function that does what you want, and then use \sagestr to pull in the
code you want. Something like

\begin{sagesilent}
  def foo(x):
return 'some tikz code with {0} in it'.format(x)
\end{sagesilent}

\newcommand{\tikzimage}[1]{\sagestr{#1}}

The \sagestr macro just pulls in a string, it doesn't run latex() on its
argument -- see the "Make Sage write your LaTeX for you" and the
"Plotting functions in TikZ with SageTeX" sections of the example file:
https://bitbucket.org/ddrake/sagetex/src/tip/example.tex (and the
typeset version:
https://bitbucket.org/ddrake/sagetex/downloads/example.pdf.

Do any of these ideas work for you?

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Animation with sage?

2012-01-12 Thread Dan Drake
On Thu, 12 Jan 2012 at 03:31AM -0800, LFS wrote:
> Hi - I seem to be always asking questions...
> I wanted to animate flux. I found these links:
> http://www.sagemath.org/doc/reference/sage/plot/animate.html and
> http://wiki.sagemath.org/animate
> I tried the code, but it would not evaluate. It wanted me to install
> something called ImageMagick, which appeared to be very complicated.

In Linux, you should be able to install ImageMagick with your package
manager; on a Mac, I see there's a binary install available from the
ImageMagick website. What seems complicated about it? What trouble did
you have trying to install it?

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] issue with combining sub lists into a list

2012-01-09 Thread Dan Drake
On Mon, 09 Jan 2012 at 10:39AM -0800, Eric Kangas wrote:
> Hi,
> 
> I have a list of sublists where I would like to combine these sub
> lists into one list.
> 
> Here is my code where I created this list of sublists.

I see you've gotten one answer, but I thought I would add that this is
really just a Python question, so if you're searching for answers,
using "python" will help.

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Help with plotting from Mathematica using SageTeX

2011-12-25 Thread Dan Drake
On Sat, 24 Dec 2011 at 10:27AM -0800, Sony wrote:
> \documentclass{article}
> \usepackage{sagetex}
> \begin{document}
> \begin{sagesilent}
> mathematica('myplot = Plot[Sin[x], {x, 0, 2 Pi}]')
> mathematica('Export["%s/example3.eps", myplot]'%os.getcwd())
> \end{sagesilent}
> \includegraphics{example3}
> \end{document}

What do those commands give you when run inside a Sage session? 

When I try that on the only computer I can access with Mathematica, the
second command fails. Your error message indicates that Mathematica is
somehow not creating the .eps file.

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Does 'plot' evaluate the function at random points?

2011-12-14 Thread Dan Drake
On Wed, 14 Dec 2011 at 05:39PM +0200, v...@ukr.net wrote:
>   Hello!
>   I have noticed a strange unpredictable behaviour of the "plot"
> function today. 
> 
> Here is the situation:
> I have a data set in the following form:
> [[2006, 289.5750],
> [2007, 289.5470],
> [2008, 289.4790],
> [2009, 289.5860], 
> [2010, 289.6200]]
> 
> and a function to work with these data:
> 
> def dGT(t):
> number = int(round(t))-temperature[0][0]
> return round(temperature[number+1][1]- \
>   temperature[number][1],3)
> 
> 
> Then I want to plot this function in some range. It turns out that the
> result is more or less unpredictable. I simply do the following to test:
> 
> ## Plotting ##
> total_plot = plot(dGT, marker=".", xmin=2000, xmax=2010, color='blue',
> plot_points=2010-2000+1, adaptive_recursion=0) total_plot += plot(dGT,
> marker=".",xmin=2000, xmax=2010, color='red', plot_points=2010-2000+1,
> adaptive_recursion=0) total_plot += plot(dGT, marker=".",xmin=2000,
> xmax=2010, color='green', plot_points=2010-2000+1,
> adaptive_recursion=0) total_plot += plot(dGT, marker=".",xmin=2000,
> xmax=2010, color='cyan', plot_points=2010-2000+1, adaptive_recursion=0)
> total_plot += plot(dGT, marker=".",xmin=2000, xmax=2010,
> color='magenta', plot_points=2010-2000+1, adaptive_recursion=0)
> total_plot += plot(dGT, marker=".",xmin=2000, xmax=2010,
> color='yellow', plot_points=2010-2000+1, adaptive_recursion=0)
> total_plot += plot(dGT, marker=".",xmin=2000, xmax=2010, color='black',
> plot_points=2010-2000+1, adaptive_recursion=0)
> 
> total_plot.show(figsize=[10,4], gridlines='minor')

Perhaps you want list_plot, since you are plotting discrete points?

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Re: transforming numbers into lists.

2011-12-08 Thread Dan Drake
On Thu, 08 Dec 2011 at 05:24PM -0800, Eric Kangas wrote:
> Now that I have code ready. There is another issue that I found. I
> need to figure out how to find a set sequence of numbers in the list.
> I know in mathematica there is a function called take which allows for
> you to display a partial list from a to b in the list, but I don't see
> that option available in sage. I tried pop, and index those list
> functions aren't useful to me.

This is a simple matter of Python list indexing. Perhaps you should look
up a Python tutorial or Python book; since Sage is based on Python,
anything you can do in Python, you can do in Sage.

Dan

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


signature.asc
Description: Digital signature


[sage-support] why is this contour integral wrong?

2011-12-04 Thread Dan Drake
I keep wondering whether Sage is making a mistake, or I'm not
understanding complex analysis. I'm a little afraid to learn the answer.
:)

Take f(z) = (z-I)*(z-1)^2/(z-(-1/2-I/3)). It's analytic everywhere
except at -1/2-I/3, where it has a simple pole. So, if I integrate over
a circle centered at 0 of radius, say, 2, the answer should be

2*pi*I*(residue of f at -1/2 - I/3),

which is pi*(181/27 + 19*I/36). However, when I try to do the contour
integral, I get:

sage: integrate(f(2*exp(I*t)) * 2*I*exp(I*t), (t, 0, 2*pi))
0

even though the contour encloses the pole. It works if I center the
circle around the pole:

sage: integrate(f(-1/2-I/3 + exp(I*t)) * I*exp(I*t), (t, 0, 2*pi))
(19/36*I + 181/27)*pi

and also if I integrate over the square with vertices 1+i, 1-i, -1-i,
-1+i. What's wrong with the circle at the origin?

Note that Mathematica gets this right, although you need to ask for full
simplification: with f[z_] = (z-I)*(z-1)^2/(z-(-1/2-I/3)), you get

In[5]:= Integrate[f[2*Exp[I*t]] * 2*I*Exp[I*t], {t, 0, 2*Pi}]//FullSimplify

 181   19 I
Out[5]= (--- + ) Pi
 27 36

Any ideas?

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] SageTeX, Numpy, and Verbatim Environment

2011-12-03 Thread Dan Drake
On Sat, 03 Dec 2011 at 09:16AM -0800, Mark wrote:
> I'm trying to represent Sage non-native elements in a LaTeX document
> using SageTeX.  Sage generates the representation without complaint,
> but the result does not compile properly on the second LaTeX step
> (LaTeX-Sage-LaTeX*).  Latex complains about missing $ inserted.  I've
> included a simple illustration below with a numpy array.

The first place to look for these kind of problems is the .sagetex.sout
file, which in this case, has

newlabel{@sageinline1}{{%
\begin{array}{l}
\verb|[[1|\phantom{x}\verb|2]|\\
\phantom{x}\verb|[3|\phantom{x}\verb|4]]|
\end{array}}{}{}{}{}}

What strikes me there is \verb -- verbatim stuff does not play nicely
as the argument to another command.

The problem here is that NumPy matrices emit goofy LaTeX code. As a
workaround, you should convert your NumPy matrices to Sage matrices.
Here's one way to do it; perhaps someone else knows a better way:

\sage{matrix(npmatrix.tolist())}


Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Tests for convergence

2011-11-29 Thread Dan Drake
On Tue, 29 Nov 2011 at 10:58PM +, Ignas Anikevicius wrote:
> I like sage a lot and I want to use it a lot as well, but sometimes my
> ignorance of the abilities of SAGE does not let me do that. I was
> wondering if there is any way of running convergence tests for
> infinite series in SAGE?

Well, if you have a formula for the nth coefficient of your series, you
can try using the ratio or root tests: 

x, n = var('x n')
a(n) = x^n   # formula for the nth term
assume(0http://mathsci.kaist.ac.kr/~drake
---


signature.asc
Description: Digital signature


Re: [sage-support] Re: unsupported operand type(s) ????????

2011-11-16 Thread Dan Drake
On Wed, 16 Nov 2011 at 03:02AM -0800, Simon King wrote:
> [1,1] in Python (thus, also in Sage) is a list. Lists can't be added
> or subtracted.

Lists can be added, but addition of lists is concatenation -- not at all
what the OP wants.

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] R code into Sagemath code

2011-11-07 Thread Dan Drake
On Mon, 07 Nov 2011 at 03:12PM -0800, Chappman wrote:
> prob.att.win.dice1 <- 0
> 
>   for (y in 2:6){
> for (z in 1:(y-1)){
>   prob.att.win.dice1 <- prob.att.win.dice1 + probs.y[y]*probs.z[z]
> }
>   }

I know nothing about R, but my guess is that the Sage version of the
above code is:

prob_att_win_dice1 = 0

for y in [2..6]:
for z in [1..(y-1)]:
prob_att_win_dice1 += probs.y[y] * probs.z[z]

You'll have to make sure that probs.y and probs.z have the right
probabilities for that to work.

Note that there's a much more compact way to do that summation: just
write

sum(probs.y[y] * probs.z[z] for z in [1..(y-1)] for y in [2..6])

(Not tested; you may need to reverse the "for y" and "for z" bits.)

I would recommend reading up on basic Python programming, which would
cover loops and so on.

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Creating Arrays in sage, and then writing a programme which refers back to the array and uses it.

2011-10-31 Thread Dan Drake
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
Description: Digital signature


Re: [sage-support] Bessel Contour Plot problem

2011-10-17 Thread Dan Drake
On Mon, 17 Oct 2011 at 03:37PM -0700, Eric Kangas wrote:
> Sage: contour_plot(lambda y,t: (sqrt(t^2+y^2)/(2*pi*y))*(bessel_J(0,
> t ).arccos()), (t, 0, 3), (y, 0, 4), fill = false, axes_labels=['$gro
> $','$kro$'], contours = [0.1, 0.2, 0.3, 0.5, 0.7, 1.0, 2.0, 4.0],
> fill=False, legend_label='qwall');
> 
> This is the error message that I get when processing the code:
> 
> The error I get is: File "", line 1 SyntaxError:
> keyword argument repeated (, line 1).

You are using the keyword argument "fill" twice: you have both
"fill=false" and "fill=False". The usual Python boolean False is spelled
with a capital F, so I'm guessing Sage/Python is confused since you are
giving it two different values for "fill". 

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Sagetex fails to interpret input

2011-10-11 Thread Dan Drake
On Tue, 11 Oct 2011 at 11:09PM +0200, Jose Guzman wrote:
> AttributeError: 'sage.rings.integer.Integer' object has no attribute
> 'rstrip'
> 
>  Running Sage on example.sage failed! Fix example.tex and try again.
> 
> I moved $SAGEROOT/local/share/texmf/tex/ to /usr/local/share/texmf
> following the instructions to install sagetex.
> 
> Does anybody knows what's wrong here?

Your TeX installation is finding an old version of sagetex.sty. Do 

 kpsewhich sagetex.sty

If the result is inside your distribution's TeX installation, you
need to make TeX ignore that file. I would rename or delete the old
sagetex.sty and use the above command to make sure that TeX is finding
the sagetex.sty that comes with your current version of Sage.

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Re: integral of exp(-x^2)*cos(x) from -pi to pi is complex?

2011-10-08 Thread Dan Drake
On Sat, 08 Oct 2011 at 01:05AM -0700, achrzesz wrote:
> The exact integral
> 
> 1/2*(erf(pi - 1/2*I) + erf(pi + 1/2*I))*sqrt(pi)*e^(-1/4)
> 
> contains *real* expression
> 
> (erf(pi - 1/2*I) + erf(pi + 1/2*I))
> 
> but maxima/sage can't check that it is real
> 
> In WolframAlpha one can check that
> 
> Im[Erf[Pi-1/2*I]+Erf[Pi+1/2*I]]
> 
> iz zero

Hrm...but I get:

(erf(pi - 1/2*I) + erf(pi + 1/2*I)).n()

resulting in "TypeError: Unable to convert 3.14159265358979 -
0.500*I", which, as I've figured out, comes from the first
erf(). It seems like .n() should return CC values when necessary, but
the obvious workaround doesn't, well, work around the problem:

erf(pi - 1/2*I).real_part().n()

gives the same TypeError -- and suggests I use real_part()! Neither

CC(erf(pi - 1/2*I))

nor

CC(erf(pi - 1/2*I).real_part(), erf(pi - 1/2*I).imag_part())

work. We need to work on the numerical approximation stuff for the error
function!

Dan

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


signature.asc
Description: Digital signature


[sage-support] integral of exp(-x^2)*cos(x) from -pi to pi is complex?

2011-10-07 Thread Dan Drake
This is strange:

sage: (integrate(exp(-x^2)*cos(x),(x,-pi,pi))/pi).n()

complains that "Unable to convert 3.14159265358979 - 0.500*I
to float". Which is odd, given that I'm integrating a real-valued
function. But it gets weirder: if I try to use .abs(), it *still* complains:

sage: (integrate(exp(-x^2)*cos(x),(x,-pi,pi))/pi).abs().n()

...same error.

Meanwhile:

sage: numerical_integral(exp(-x^2)*cos(x), (-pi,pi))   
(1.3804038617166086, 1.5567746861731315e-14)

I'm guessing this is a Maxima problem. Any ideas what's going on?

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] sagetex

2011-10-05 Thread Dan Drake
On Wed, 05 Oct 2011 at 10:15AM -0700, David Hren wrote:
>  Error in Sage code on line 8 of HWK7.tex! Traceback follows.
> Traceback (most recent call last):
>   File "/home/dave/Desktop/HWK7.py", line 7, in 
> _st_.inline(_sage_const_0 , sin(pi))
>   File "/home/dave/sage-4.7.1/local/lib/python2.6/site-packages/
> sagetex.py", line 73, in inline
> s.rstrip() + '}{}{}{}{}}\n')
>   File "element.pyx", line 328, in
> sage.structure.element.Element.__getattr__ (sage/structure/element.c:
> 2794)
>   File "parent.pyx", line 277, in
> sage.structure.parent.getattr_from_other_class (sage/structure/
> parent.c:2940)
>   File "parent.pyx", line 175, in
> sage.structure.parent.raise_attribute_error (sage/structure/parent.c:
> 2709)
> AttributeError: 'sage.symbolic.expression.Expression' object has no
> attribute 'rstrip'
> 
>  Running Sage on HWK7.sage failed! Fix HWK7.tex and try again.
> 
> I'm not sure what is going on here; any idea? I'm running Ubuntu
> 11.04.

With high probability, Kile used a outdated version of sagetex.sty
included with your TeX distribution, instead of the current version of
sagetex.sty from Sage. If you do

kpsewhich sagetex.sty

is it the file you got from your Sage installation, or something in the
TeXLive directories? If it's from TeXLive, I would delete it or rename
it, or make sure that the good sagetex.sty is found before the bad one.

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Re: why doesn't [lambda x: bessel_J(n, x) for n in [0,1]] work?

2011-10-04 Thread Dan Drake
On Wed, 05 Oct 2011 at 12:40AM -0500, Jason Grout wrote:
> On 10/4/11 11:14 PM, Mike Hansen wrote:
> >On Tue, Oct 4, 2011 at 9:09 PM, Dan Drake  wrote:
> >>It seems unreasonably annoying to plot a bunch of Bessel functions
> >>together. How can I work around this?
> >
> >This is due to the way binding works in list comprehensions.  For a
> >good explanation and workaround, see
> >http://stackoverflow.com/questions/139819/why-results-of-map-and-list-comprehension-are-different
> 
> In particular, this is one way to do it:
> 
> sage: f0, f1 = [lambda x,n=n: bessel_J(n, x) for n in [0,1]]
> sage: f0(0)
> 1.00

Thanks Mike and Jason. (And Andrzej for the simple workaround I should
have thought of...) The "lambda x,n=n:" looks weird, but the
Stackoverflow page explained it well enough.

Dan

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


signature.asc
Description: Digital signature


[sage-support] why doesn't [lambda x: bessel_J(n, x) for n in [0,1]] work?

2011-10-04 Thread Dan Drake
I want a list of Bessel functions, suitable for feeding to plot(). But I get:

sage: f0, f1 = [lambda x: bessel_J(n, x) for n in [0,1]]  
sage: f0(0)
0.000
sage: bessel_J(0,0)
1.0

That is, I get two copies of bessel_J(1, x), instead of J_0 and J_1. Why
doesn't that list comprehension work? Why does the lambda function seem
to wait until n has its last value?

Something like [sin(n*x) for n in range(5)] works as expected.

It seems unreasonably annoying to plot a bunch of Bessel functions
together. How can I work around this?

Dan

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


signature.asc
Description: Digital signature


Re: [sage-support] Re: notes on creating HTML5 video with Sage's animate()

2011-09-23 Thread Dan Drake
On Fri, 23 Sep 2011 at 04:15AM -0700, dimpase wrote:
> I'm trying to open link https://sagenb.kaist.ac.kr:8066/home/pub/41
> but to no avail (neither yesterday, nor today... must be our campus firewall 
> settings...)

Hrm, perhaps it doesn't like the port number. Try this:

http://sagenb.org/home/pub/3222

Dan

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


signature.asc
Description: Digital signature


[sage-support] notes on creating HTML5 video with Sage's animate()

2011-09-21 Thread Dan Drake
Hello,

I wanted to create some video files for my students (we're studying the
wave equation, which begs for animation) and post them on the web where
they can be easily watched. The easiest way to do this is to create
videos in formats understand by browsers that implement the HTML5
 tag. (Basically anything reasonably recent does, except for IE8
and before -- which, sadly, is most of the browser market here.)

I wrote some notes on producing such videos and thought someone might
find them useful: https://sagenb.kaist.ac.kr:8066/home/pub/41. Comments
welcome.

(BTW, here's the videos I made:

  http://klee.kaist.ac.kr/wave.webm
  http://klee.kaist.ac.kr/wave.mp4

The thick green plot is the shape of a plucked string, and the red and
blue plots are the traveling waves you get with d'Alembert's solution to
the wave equation.)

Dan

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


signature.asc
Description: Digital signature


  1   2   3   4   >