Re: [sage-support] sagetex and stereographic plots

2010-03-12 Thread Dan Drake
On Fri, 12 Mar 2010 at 01:27PM +0100, G. Damm wrote:
> is it possible to make stereographic 3d-plots with sagetex?
> I'd want to make a beamer-presentation with these plots and want to 
> help my students see the 3d.

Can Sage make stereographic 3-d plots? If there's a way to get a PNG
image of such a plot out of Sage, then you can get it into your
presentation.

What exactly do you mean by "stereographic"? Do you mean the kinds of
image in which there's two images, from slightly different angles, and
you project it using polarizing filters and the students wear polarized
glasses? Or those "magic eye" images that look like static unless you
cross your eyes just right?

My guess, though, is that if you are already using a computer and a
projector, it would be better to use an actual Jmol applet in your
class. Then, instead of a three-dimensional static image, your students
see something interactive, that can be twisted around, zoomed in and
out, and so on.

Dan

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


signature.asc
Description: Digital signature


[sage-support] test if an expression is polynomial

2010-03-12 Thread ma...@mendelu.cz
Dear support

the following two commands can be used to test, if a function is a
polynomial or quotient of two polynomials in x variable.

sage: (x^3+x+3+1/(x))._maxima_().polynomialp([x]).sage()
0

sage: ((x^3+x+3+1)/(x^4+3))._maxima_().polynomialp([x],"constantp",
"integerp").sage()
1

Is there a solution how to do this in pure Sage, without calling
Maxima? (I think that each call of Maxima takes a long time on my
server, especially the first call.)

Many thanks.

Robert

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


[sage-support] Re: convert trigonometric/hyperbolic functions to exponentials

2010-03-12 Thread Yann
And I guess the answer to Paul's question is then:

sage: (sinh(log(t)))._maxima_().exponentialize().sage()
1/2*t - 1/2/t

sage: (cos(log(t)))._maxima_().exponentialize().sage()
1/2*e^(-I*log(t)) + 1/2*e^(I*log(t))

-- 
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: convert trigonometric/hyperbolic functions to exponentials

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

On 12 bře, 21:19, Guillaume  wrote:
> > No, AFAIK, nothing other than explicit substitution with .subs().
>
> Hello,
>
> there are a few weird results. I'd like to solve this homogenous edo :
>
>  $tx'=x+\sqrt{x^2+y^2}$.
>
> using x=tu
>
> sage: t=var('t')
> sage: x(t) = function('x',t)
> sage: id(t)=t
> sage: u=function('u',t)
> sage: d=diff(u*id,t)
>

Is this what you want?

sage: t=var('t')
sage: x= function('x',t)
sage: id(t)=t
sage: u=function('u',t)
sage: d=diff(u*id,t)
sage: assume(t>0)
sage: DE=(t*d==x+sqrt(t**2+x**2)).subs_expr(x==u*id)
sage: A=desolve(DE,u)
sage: C=var('C')
sage: A._maxima_().ev(logarc=true).sage().solve(u)[0].subs(c=log(C))

u(t) == C*t - sqrt(u(t)^2 + 1)


sage: eq = u == C*t - sqrt(u^2 + 1)
sage: ((eq-C*t)^2).solve(u)

[u(t) == 1/2*(C^2*t^2 - 1)/(C*t)]


The fact that the integral in A in not evaluated is probably a bug.
You may want to open trac on this and test, if this bug is inside
Maxima or in Sage interface to Maxima.

Robert


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


[sage-support] Re: convert trigonometric/hyperbolic functions to exponentials

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


On 12 bře, 16:48, Burcin Erocal  wrote:
> On Fri, 12 Mar 2010 15:23:43 +0100
>
> Paul Zimmermann  wrote:
> > is there a way in Sage to convert expressions involving trigonometric
> > or hyperbolic functions to exponentials, like the convert/exp
> > function of Maple?
>
> > > convert(sinh(log(t)),exp);
> >                                           1
> >                                    t/2 - ---
> >                                          2 t
>
> > > convert(cos(log(t)),exp);  
> >                      1/2 exp(ln(t) I) + 1/2 exp(-I ln(t))
>
> No, AFAIK, nothing other than explicit substitution with .subs().
>

You can use something like this

desolve(t*diff(x,t)==x
+sqrt(x^2+t^2),x)._maxima_().ev(logarc=true).sage()
t == (sqrt(x(t)^2/t^2 + 1) + x(t)/t)*c

desolve(t*diff(x,t)==x+sqrt(x^2+t^2),x)
t == c*e^(arcsinh(x(t)/t))

Robert


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


[sage-support] Re: convert trigonometric/hyperbolic functions to exponentials

2010-03-12 Thread Guillaume

> No, AFAIK, nothing other than explicit substitution with .subs().

Hello,

there are a few weird results. I'd like to solve this homogenous edo :

 $tx'=x+\sqrt{x^2+y^2}$.

using x=tu

sage: t=var('t')
sage: x(t) = function('x',t)
sage: id(t)=t
sage: u=function('u',t)
sage: d=diff(u*id,t)

apparently, you can't substitute inside diff

sage: DE=(t*d==x+sqrt(t**2+x**2)).subs_expr(x==u*id)
sage: desolve(DE,[u,t])
arcsinh(u(t)) == c + integrate(abs(t)/t^2, t)
sage:  assume(t>0)
sage: desolve(DE,[u,t])
arcsinh(u(t)) == c + integrate(1/t, t)
sage: desolve(DE,[u,t],[1,0])

oups, first problem :

Division by 0
#0: ic1(soln=asinh(u) = 'integrate(abs(t)/t^2,t)+%c,xc=t = 0,yc=u = 1)
(ode2.mac line 297)
 -- an error. To debug this try: debugmode(true);

sage: sol=desolve(DE,[u,t]).simplify_exp()
arcsinh(u(t)) == c + log(t)

OK

sage: desolve(DE,[u,t],[0,1]).simplify_exp()

but the problem reamins the same. Welle, let's make the substitution
by hand :

sage: solp=sol.subs(c=0)
sage: solp
arcsinh(u(t)) == log(t)
sage: Sol=solve(solp,u)[0]
sage: Sol
u(t) == sinh(log(t))
sage: x(t)=t*Sol.rhs()
sage: x(t)
t*sinh(log(t))

here comes our hyp2exp problem...

sage: sh(a)=(exp(a)-exp(-a))/2
sage: x(t).substitute_function(sinh,sh).simplify_full()
t*sinh(log(t))

argh

sage: x
t |--> t*sinh(log(t))

x is what we expect. Is it t ?

sage: x(a).substitute_function(sinh,sh).simplify_full()
a*sinh(log(a))

no...and now, weirder and weirder...

sage: a*sinh(log(a)).substitute_function(sinh,sh).simplify_full()
1/2*a*log(a) - 1/2
sage: t*sinh(log(t)).substitute_function(sinh,sh).simplify_full()
1/2*t^2 - 1/2

this 1/2*a*log(a) - 1/2 is a bit unexpected...

well, I'm discovering sage but these results look strange.

cheers,
Guillaume

-- 
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: possible error in manual

2010-03-12 Thread John H Palmieri
On Mar 12, 9:18 am, Michael Beeson  wrote:
> On the pagehttp://www.sagemath.org/doc/reference/sage/symbolic/expression.html
>
> the first example has eqn.subs(x==5)  and I think it should be
> eqn.subs(x=5)

It seems to work either way, and there are examples in the
documentation using both: type

sage: eqn = (x-1)^2 <= x^2 - 2*x + 3
sage: eqn.subs?

to see the docs.

--
John

-- 
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: norm or absolute value

2010-03-12 Thread Yann
Hi,
Is this helping?

sage: var('a,b,z')
(a, b, z)
sage: f=a*z+i*b*z^2
sage: f.norm()
b*z^2*conjugate(b)*conjugate(z)^2 - I*a*z*conjugate(b)*conjugate(z)^2
+ I*b*z^2*conjugate(a)*conjugate(z) + a*z*conjugate(a)*conjugate(z)
sage: f.norm().full_simplify()
b^2*z^4 + a^2*z^2
sage: f.norm().factor()
(b^2*z^2 + a^2)*z^2

On Mar 12, 6:46 pm, Michael Beeson  wrote:
> sage: var('z'); var('a');var('b');
> sage: F = a*z + i*b*z^2
> sage:
>
> Now  F.norm() or something should give me  (a*z)^2 + (b*z^2)^2,  but I
> can't find a command to do that.
> I want to do this when F is a polynomial of degree 6 with complex
> rational coefficients to eliminate i and produce
> a polynomial of degree 12 with rational coefficients.

-- 
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] norm or absolute value

2010-03-12 Thread Michael Beeson
sage: var('z'); var('a');var('b');
sage: F = a*z + i*b*z^2
sage:

Now  F.norm() or something should give me  (a*z)^2 + (b*z^2)^2,  but I
can't find a command to do that.
I want to do this when F is a polynomial of degree 6 with complex
rational coefficients to eliminate i and produce
a polynomial of degree 12 with rational coefficients.

-- 
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: plot3d and expression evaluation

2010-03-12 Thread stefan
I think I've got a vague idea what happens here... The same thing also
happens when
I define the max() function myself:

sage: def my_max(x,y):
sage: if(x>y): return x
sage: else: return y

sage: fermi2(x,y,d,L) = 1 - 1/( exp( ( my_max(abs(x),abs(y))-L) /d)  +
1)

sage: fermi2
(x, y, d, L) |--> -1/(e^(-(L - abs(y))/d) + 1) + 1

This looks a bit like max(x,y) gets passed the the objects 'abs(x)'
and 'abs(y)'
and decides, for whatever reason, that 'abs(x)' is not greater than
'abs(y)', so
the else-clause gets executed and we are left with abs(y). Does this
make sense to
you? (I'm just thinking aloud, I got no idea how sage actually does
it)

Most likely the internal "max" function is defined in rather the same
way (it
just returns abs(x) instead of abs(y). )

The bottom line seems to be that it is a very dangerous game to mix
symbolic expressions and python functions. Is there some way to
control
when (and how) Sage evaluates expressions and invokes python
functions?
Something like saying "first evaluate abs(x) and abs(y) and then
invoke the
python function max() with the result of the evaluation"?


On Mar 12, 5:49 pm, Harald Schilly  wrote:
> Ah, I got it, the max function is evaluated during the definition of
> the function, look:
>
> sage: fermi(x,y,d,L) = 1 - 1/( exp( ( max(abs(x),abs(y))-L) /d)  + 1)
> sage: fermi
> (x, y, d, L) |--> -1/(e^(-(L - abs(x))/d) + 1) + 1
>
> especially:
> sage: max(abs(x),abs(y))
> abs(x)
>
> There is no y any more!
>
> H

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


Re: [sage-support] newbie to cython: wrap int func( int n, float x[] )

2010-03-12 Thread Robert Bradshaw

On Mar 12, 2010, at 9:05 AM, gerhard wrote:


Trying to wrap an existing library.
I managed to at least get started with a .spyx file as follows:

cdef extern from "stdlib.h":
 void *malloc(size_t size)
 int free(void*)
 int sizeof()
cdef extern from "func.h":
 int func( int n, float* x )
 cdef double* d

 def __cinit__(self):
 self.d = malloc( sizeof(double))
 self.n = 1
 def __dealloc__(self):
 free( self.d )
 def func( self, data ):
 cdef int i
 self.n = len(data)
 free( self.d )
 self.d =  malloc( self.n*sizeof(double) )
 for i from 0 <= i < self.n:
 self.d[i] = data[i]
 func( self.n, self.d )
 l = []
 for i from 0 <= i < self.n:
l.append( d[i] )
 return l
-
but this leaves much to be desired.
It should be a fairly standard operation
for which sage has good solutions.

Could someone please give me some pointers
as to how to improve the above?


Sounds like you want NumPy.

- Robert


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


[sage-support] possible error in manual

2010-03-12 Thread Michael Beeson
On the page
http://www.sagemath.org/doc/reference/sage/symbolic/expression.html

the first example has eqn.subs(x==5)  and I think it should be
eqn.subs(x=5)

-- 
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: plot3d and expression evaluation

2010-03-12 Thread stefan


On Mar 12, 5:47 pm, Harald Schilly  wrote:
> I'm not sure but there might be a bug or problem evaluating the
> expression. Anyways, going the "pure" python way works:
>
> sage: def fermi(x,y,d,L): return  1 - 1/( exp( ( max(abs(x),abs(y))-
> L) /d)  + 1)
>
> sage: plot3d(lambda x,y : fermi(x,y,0.2,1), (x,-2,2), (y,-2,2))
>
> Does this look fine?

Yes, the "pure python" way works. But defining the function that way,
I loose the ability to perform symbolic manipulations with it, don't I?

-- 
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] newbie to cython: wrap int func( int n, float x[] )

2010-03-12 Thread gerhard
Trying to wrap an existing library.
I managed to at least get started with a .spyx file as follows:

cdef extern from "stdlib.h":
  void *malloc(size_t size)
  int free(void*)
  int sizeof()
cdef extern from "func.h":
  int func( int n, float* x )
  cdef double* d

  def __cinit__(self):
  self.d = malloc( sizeof(double))
  self.n = 1
  def __dealloc__(self):
  free( self.d )
  def func( self, data ):
  cdef int i
  self.n = len(data)
  free( self.d )
  self.d =  malloc( self.n*sizeof(double) )
  for i from 0 <= i < self.n:
  self.d[i] = data[i]
  func( self.n, self.d )
  l = []
  for i from 0 <= i < self.n:
 l.append( d[i] )
  return l
-
but this leaves much to be desired.
It should be a fairly standard operation
for which sage has good solutions.

Could someone please give me some pointers
as to how to improve the above?

-- 
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: plot3d and expression evaluation

2010-03-12 Thread Harald Schilly
On Mar 12, 5:39 pm, stefan  wrote:
> I have encountered a somewhat strange problem ...

Ah, I got it, the max function is evaluated during the definition of
the function, look:

sage: fermi(x,y,d,L) = 1 - 1/( exp( ( max(abs(x),abs(y))-L) /d)  + 1)
sage: fermi
(x, y, d, L) |--> -1/(e^(-(L - abs(x))/d) + 1) + 1

especially:
sage: max(abs(x),abs(y))
abs(x)

There is no y any more!

H

-- 
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: plot3d and expression evaluation

2010-03-12 Thread Harald Schilly
On Mar 12, 5:39 pm, stefan  wrote:
> Basically, I am trying to plot this expression:
>
> #sage> fermi(x,y,d,L) = 1 - 1/( exp( ( max(abs(x),abs(y))-L) /d)  + 1)


I'm not sure but there might be a bug or problem evaluating the
expression. Anyways, going the "pure" python way works:

sage: def fermi(x,y,d,L): return  1 - 1/( exp( ( max(abs(x),abs(y))-
L) /d)  + 1)

sage: plot3d(lambda x,y : fermi(x,y,0.2,1), (x,-2,2), (y,-2,2))

Does this look fine?

H

-- 
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] plot3d and expression evaluation

2010-03-12 Thread stefan
Hello group,

I have encountered a somewhat strange problem in plotting a simple
function. It seems to be related to the issues described in the
tutorial section "Some Common Issues with Functions", but the lambda-
function trick does not work here.

I have uploaded a worksheet with what I have been trying so far here:
http://www.sagenb.org/home/steja/1/

Basically, I am trying to plot this expression:

#sage> fermi(x,y,d,L) = 1 - 1/( exp( ( max(abs(x),abs(y))-L) /d)  + 1)

as a function of (x,y) for some different values of d and L (nothing
too useful, I invented it as a toy project to get familiar with Sage).
I tried the following commands, but none of them works:

#sage> plot3d(lambda x,y: fermi(x,y,0.2,1),(x,-2,2),(y,-2,2))

#sage> def plfermi(x,y): return fermi(x,y,0.2,1)
#sage> plot3d(plfermi,(-2,2),(-2,2))

Both of these commands do plot something, but the result is wrong. I
also tried this:

#sage> pf(x,y) = fermi(x,y,0.2,1.0)
#sage> plot(pf,(-2,2),(-2,2))

Here, the result is an error message (which looks like Klingon
language to me).

Could somebody send some light down my way? I am almost dying to get
rid of Mathematica in favor of an open source CAS (because of their #*!
§ license that always seems to fail when one desperately needs it),
but I'm afraid I've still got a long way to go with Sage when I'm not
even able to plot a simple function...

-- 
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] sagetex and stereographic plots

2010-03-12 Thread G. Damm
Hello all,

is it possible to make stereographic 3d-plots with sagetex?
I'd want to make a beamer-presentation with these plots and want to 
help my students see the 3d.

Thanks,

Georg


signature.asc
Description: This is a digitally signed message part.


Re: [sage-support] convert trigonometric/hyperbolic functions to exponentials

2010-03-12 Thread Burcin Erocal
On Fri, 12 Mar 2010 15:23:43 +0100
Paul Zimmermann  wrote:

> is there a way in Sage to convert expressions involving trigonometric
> or hyperbolic functions to exponentials, like the convert/exp
> function of Maple?
> 
> > convert(sinh(log(t)),exp);
>   1
>t/2 - ---
>  2 t
> 
> > convert(cos(log(t)),exp);  
>  1/2 exp(ln(t) I) + 1/2 exp(-I ln(t))

No, AFAIK, nothing other than explicit substitution with .subs().

Implementing these shouldn't be too hard given the rewriting
capabilities of pynac. The problem is to provide an intuitive
user interface. 

Francois Maltey had some good suggestions for this. Putting these up on
the wiki has been on my todo list for quite some time, but I never
managed to find the time. I'd be glad to forward the relevant emails to
anyone interested in taking over this project.


Cheers,
Burcin

-- 
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] convert trigonometric/hyperbolic functions to exponentials

2010-03-12 Thread Paul Zimmermann
   Hi,

is there a way in Sage to convert expressions involving trigonometric or
hyperbolic functions to exponentials, like the convert/exp function of Maple?

> convert(sinh(log(t)),exp);
  1
   t/2 - ---
 2 t

> convert(cos(log(t)),exp);  
 1/2 exp(ln(t) I) + 1/2 exp(-I ln(t))

Paul Zimmermann

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


Re: 回复: [sage-support] Re: 3D plot in sage

2010-03-12 Thread wxuyec
Actually I do need them to be plotted by color.it seems that sage is not 
designed for this way.could anyone give some information aboutwhat open source 
software can do this?Thanks a lot!YC - 原文 - 发件人: Jason Grout 主 题: Re: 
回复: [sage-support] Re: 3D plot in sage时 间: 2010年3月12日  01:26:30On 03/12/2010 
03:51 AM, Marshall Hampton wrote:> One option is several implicit plots, 
colored by value, i.e. something> like:> > var('x,y,z')> 
f=cos(x)*cos(y)+cos(y)*cos(z)+cos(z)*cos(x)> > imps = []> plot_range = 
srange(0,3,.75)> color_range = [i/N(len(plot_range)) for i in 
range(len(plot_range))]> > for i,q in enumerate(plot_range):>  red 
= color_range[i]>  imps.append(implicit_plot3d(f-q==0, (x, -2, 2), (y, 
-2, 2), (z,> -2, 2), opacity = .5, rgbcolor = (red,0,1-red)))> > 
show(sum(imps))> If you didn't need them to be plotted by color, then you 
could use thecontour option, like in the doc examples:sage: 
implicit_plot3d((x^2 + y^2 + z^2), (x, -2, 2), (y, -2, 2), (z, -2,2), 
plot_points=60, contour=[1,3,5])Jason-- To post to this group, send email to 
sage-supp...@googlegroups.comto unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.comfor more options, visit this group at 
http://groups.google.com/group/sage-supportURL: http://www.sagemath.org

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


Re: 回复: [sage-support] Re: 3D plot in sage

2010-03-12 Thread Jason Grout
On 03/12/2010 03:51 AM, Marshall Hampton wrote:
> One option is several implicit plots, colored by value, i.e. something
> like:
> 
> var('x,y,z')
> f=cos(x)*cos(y)+cos(y)*cos(z)+cos(z)*cos(x)
> 
> imps = []
> plot_range = srange(0,3,.75)
> color_range = [i/N(len(plot_range)) for i in range(len(plot_range))]
> 
> for i,q in enumerate(plot_range):
>  red = color_range[i]
>  imps.append(implicit_plot3d(f-q==0, (x, -2, 2), (y, -2, 2), (z,
> -2, 2), opacity = .5, rgbcolor = (red,0,1-red)))
> 
> show(sum(imps))
> 

If you didn't need them to be plotted by color, then you could use the
contour option, like in the doc examples:
sage: implicit_plot3d((x^2 + y^2 + z^2), (x, -2, 2), (y, -2, 2), (z, -2,
2), plot_points=60, contour=[1,3,5])

Jason

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


Re: 回复: [sage-support] Re: 3D plot in sage

2010-03-12 Thread Marshall Hampton
One option is several implicit plots, colored by value, i.e. something
like:

var('x,y,z')
f=cos(x)*cos(y)+cos(y)*cos(z)+cos(z)*cos(x)

imps = []
plot_range = srange(0,3,.75)
color_range = [i/N(len(plot_range)) for i in range(len(plot_range))]

for i,q in enumerate(plot_range):
red = color_range[i]
imps.append(implicit_plot3d(f-q==0, (x, -2, 2), (y, -2, 2), (z,
-2, 2), opacity = .5, rgbcolor = (red,0,1-red)))

show(sum(imps))

-M. Hampton


On Mar 11, 2:21 am, wxu...@sohu.com wrote:
> I don't want to plot f(x,y,z)=0.Yes, it should a 4d plot as you said.can that 
> be done in sage?Thanks!YC - 原文 - 发件人: John H Palmieri 主 题: 
> [sage-support] Re: 3D plot in sage时 间: 2010年3月10日  07:04:29On Mar 10, 
> 9:39 am, wxu...@sohu.com wrote:> Hi everyone,I want do this thing as 
> follows in sage, is that 
> OK?var('x,y,z')f=cos(x)*cos(y)+cos(y)*cos(z)+cos(z)*cos(x)and then I want to 
> plot f. how can do it in sage?Thanks in advance!regards,YCIsn't this a 4d 
> plot?  Or do you want to plot f(x,y,z)=0?   In thatcase, you could dosage: 
> implicit_plot3d(f == 0, (x, -2, 2), (y, -2, 2), (z, -2, 2))--John-- To post 
> to this group, send email to sage-supp...@googlegroups.comto unsubscribe from 
> this group, send email to sage-support+unsubscr...@googlegroups.comfor more 
> options, visit this group 
> athttp://groups.google.com/group/sage-supportURL:http://www.sagemath.org

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