[sage-support] phase portrait with sage.

2011-03-20 Thread Renard Tod
I trying to make phase portrait with sage (without using maple) with
plot_vector_field function, but all my tryings fail.
My system looks like:

x''+x=f(x)

, where f(x)=
 a, when xb
 x*a/b, when -b=x=b
 -a, when x-b

a,b - predefined constants (positive)

how I must do this?

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


[sage-support] Re: sage server

2011-03-20 Thread tbensky
Hi Jason-
Sorry to keep bugging you about this but I think I'm getting closer to
getting this working. I have found a bunch of apache mod_rewrites has
taken care of many problems, but I the the ajax calls are still
broken. I have identified a javascript function called asych_request
which appears to be a prime candidate for a base-url prefix.

My problem now is that the javascript code appears to be compressed or
shrouded in the deployed sage math version. Is there a command or
section of the makefile that rebuilds the deployed javascript code
(in /javascript) from the readable code found in the devel
directory? I am thinking that I could add a base url to this function,
rebuild it, and see if that moves this along.
Thanks,
Tom

On Mar 18, 5:03 pm, Jason Grout jason-s...@creativetrax.com wrote:
 On 3/18/11 6:22 PM, tbensky wrote:

  Thanks Jason---I found a todo.txt in the sagebn directory referencing
  some need for base_url. Is this what you are referring to? Some
  base_url on the html pages? When I inspect my Apache Proxy logs,
  Javascript calls to things like trash_notebook are routed to my /var/
  www/trash_notebook directory, as are things like /var/www/eval, etc.
  These obviously need to be rerouted, but I am looking to dive into the
  core sage javascript code? This would be painful.

 That todo note was what I was thinking about.  Unfortunately, after
 reading a bit more, it seems that the html base tag only works for
 relative URLs on a page, but there are plenty of javascript and css
 things that are absolute references.  So I don't know how much it would
 do, and it looks like a much bigger (but still doable!) job to go
 through each URL and replace it with either a relative URL or a URL that
 uses some option from the notebook command to change the base directory.

 Jason

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


[sage-support] Re: Problem in displaying graphs

2011-03-20 Thread pong
With some fiddling,

\sageplot{Graph(d).plot(), axes_pad=0.1)

works around the problem.

On Mar 19, 6:50 pm, pong wypon...@gmail.com wrote:
 Sage plots some graphs with vertices partially chopped off.
 For example:

 sage: d={1:[2,3,5], 2:[3], 3:[4,5], 4:[5]}
 sage: Graph(d).plot()

 I thought the bug was fixed, but looks like it still exists.
 There is a work around using something like G.show(axes_pad=0.1).
 However, I couldn't make it works with sagetex because axes_pad seems
 to have no effect on G.plot().

 Any help?
 Thanks in advance

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


[sage-support] Re: phase portrait with sage.

2011-03-20 Thread achrzesz
import scipy.integrate
import matplotlib.pyplot as plt
import numpy
a=1.0
b=2.0

def fun(t):
if t=-b:
return -a
elif fb:
return t*a/b
else:
return a

g=lambda t:fun(t)

N=100
time_step=0.1
time_end=10.0
t0=0.0
x0=[[0.5*k,0.5*k] for k in range(-10,10)]

def f(x,t):
return [x[1],-x[0]+g(x[0])]

time_range=[t0..time_end, step=time_step]
plt.figure()
for n in range(10):
sol = scipy.integrate.odeint(f,x0[n],time_range)
x = sol[:,0]
y = sol[:,1]
plt.plot(x,y)
plt.savefig('phase.png')

#corresponding vector field
x0,x1=var('x0 x1')
p=plot_vector_field ((x1,-x0+g(x0)),(x0,-8,8),(x1,-8,8))

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


[sage-support] Re: phase portrait with sage.

2011-03-20 Thread Marshall Hampton
Slightly more Sage-ified version of the above very nice solution:

import scipy.integrate
a=1.0
b=2.0

def fun(t):
if t=-b:
return -a
elif fb:
return t*a/b
else:
return a

g=lambda t:fun(t)

N=100
time_step=0.1
time_end=10.0
t0=0.0
x0=[[0.5*k,0.5*k] for k in range(-10,10)]

def f(x,t):
return [x[1],-x[0]+g(x[0])]

time_range=[t0..time_end, step=time_step]
x0=[[0.5*k,0.5*k] for k in range(-10,10)]
sol_lines = Graphics()
for n in range(10):
sol = scipy.integrate.odeint(f,x0[n],time_range)
sol_lines += line(sol,rgbcolor=hue(.3+n/15.0))

x0,x1=var('x0 x1')
p=plot_vector_field ((x1,-x0+g(x0)),(x0,-9,9),(x1,-7,7))

show(sol_lines + p, figsize = [9,7])

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