Is this the optimal code for what I'm trying to do? On my MacBook, it
takes a good minute or so before the graph appears. Not that I'm
complaining...

On Nov 21, 9:56 pm, Robert Bradshaw <rober...@math.washington.edu>
wrote:
> On Nov 21, 2009, at 7:50 PM, Jason Grout wrote:
>
>
>
>
>
> > Sterling wrote:
> >> I'm trying to duplicate what this Mathematica code does in SAGE:
>
> >> F[z_]=4*Log[z^3]-2*Log[z^3-8]
> >> a=ContourPlot[If[y<Sqrt[3]*x, Im[F[x+I*y]]], {x, 0, 4}, {y, 0, 4},
> >> ContourShading->False, Contours->30]
> >> b=Plot[Sqrt[3]*x, {x, 0, 4}]
> >> Show[a, b]
>
> >> I originally used this (this doesn't include the sqrt(3)*x line in  
> >> the
> >> code above):
>
> >> z = var('z')
> >> f(z) = 4*log(z^3)-2*log(z^3-8)
> >> g = lambda x,y: imag(f(x+y*I))
> >> a = contour_plot(g,(x,0,4),(y,0,4),fill=False,contours=30)
>
> >> Robert Bradshaw suggested I use:
>
> >> g = lambda x,y: imag(f(x+y*I)) if y < sqrt(3)*x else float('nan')
>
> >> It works, but as Robert said, it isn't really pretty. Any  
> >> suggestions?
>
> > You could write it out:
>
> > def g(x,y):
> >     if y < sqrt(3)*x:
> >         return imag(f(x+y*I))
> >     else:
> >         return float('nan')
>
> > Is that prettier?
>
> I was referring to the result.
>
>
>
>
>
>
>
> > Note that if you give a pure python function like this, it doesn't  
> > make
> > sense to specify the variable names in the contour_plot statement, as
> > the arguments are just stuffed into the functions in the order.
>
> > Hmm...should we analyze the function's argument names so that
>
> > def f(x,y):
> >    return x*sin(y)
> > plot3d(f, (x,0,3),(y,-6,6))
>
> > and
>
> > plot3d(f, (y,0,3),(x,-6,6))
>
> > give the same plots?
>
> Yes, I think that's worth trying at least, though somewhat orthogonal  
> to the issue at hand...
>
> - Robert
>
>  sage.png
> 73KViewDownload
>
>  Picture 1.png
> 118KViewDownload

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

Reply via email to