William Stein wrote:
> On Sat, 17 Nov 2007 09:29:27 -0800, Jason Grout <[EMAIL PROTECTED]> wrote:
[snip]

> 
> I'm pretty excited about this!  I think it would be extremely amazingly
> useful if you could make up some more examples like this one
> 
> sage: a = Slider(1,10)
> sage: plot(sin(a()*x),-3,3)
> 
> and explain what they would do.   Also, if we could make it more like
> 
> sage: a = Slider([1..10])
> 
> i.e., have a discrete range as input, then doing caching would be easier.

Here are a few more examples.  You can look at the Manipulate help page 
at http://reference.wolfram.com/mathematica/ref/Manipulate.html for 
examples of the Mathematica command.

Slider(list) creates a slider on the list.  For example, 
Slider([1..10,step=.01]) creates a slider that goes from 1 to 10 on the 
list.

Slider([0,pi/3,pi/2,2*pi/3,pi]) creates a slider that takes on values of 
pi (note that these are symbolic values, rather than numeric values).

Slider([sin,cos,tan]) creates a slider that changes the function

Examples:

sage: a=Slider([1..10,step=.01])
sage: sin(a()) # outputs the sin of the slider.

sage: a=Slider([0,pi/3,pi/2,2*pi/3,pi])
sage: sin(a()) # outputs the sin of various fractions of pi.

sage: b=Slider([sin,cos,tan])
sage: (b())(a()) # Two sliders, the first selects the function and the 
second selects the fraction of pi.

sage: a=Slider([1..10])
sage: a()! # Compute the factorial of the selected number.

PlaneSlider(list,list) selects from the cartesian product of the lists. 
  This can be used to select a point on a plane.  The control presents a 
small rectangle with a dot in it.  You drag the dot to select a 
different point.

sage: a=PlaneSlider([1..10],[1,10]) # a grid
sage: some_function_that_takes_a_point(a()) # what function would take a 
list of two elements?

Checkbox() returns true or false.

sage: showtangent = Checkbox()
sage: point=Slider([0..3,step=.1])
sage: p=plot(sin(x),0,3)

# the following command shows the tangent line at the x-value given by 
the point slider if the tangent checkbox is checked.
sage: if(showtangent):
    (p+plot(sin(point())+cos(point())*(x-point()),0,3)).show()
else:
    p.show()


Buttons(list) makes a list of buttons, only one of which can be 
selected.  We could also make a RadioButton(list) widget.

sage: a=Buttons([sin,cos,tan])
sage: plot((a())(x),0,3).show() # Shows the selected function

Textbox() makes a user textbox.  Hmmm, we should probably make an 
optional validation function for this one!

sage: a=Textbox(default="sin")
sage: plot(eval(a())(x),0,3).show() # plots the function entered into 
the text box.

ColorChooser() makes a color chooser.

sage: a=ColorChooser(default="blue")
sage: plot(sin(x),0,3,color=a()).show() # I don't know how to set the 
color of a plot!



>> Performance might be a problem.  In that case, we could eventually have
>> some command that would cache the output of the expression for different
>> widget values so the update would be faster.
> 
> Performance without caching would be a major problem.  Performance with
> caching could be excellent.  E.g., in the above example we could autoload
> all 10 images, so that no communication with sage at all would be required,
> and scrolling would be instant.
> 
> Please please post several examples of what you imagine doing with this,
> which is the perfect first step.   Try to include examples that involve
> all the different controls that mathematica supports.


These aren't all of the controls in Mathematica (I think there's a menu 
control, for example).  It also doesn't touch on the "Dynamic" command 
which is much more powerful.

Here are some more references from Mathematica:

http://reference.wolfram.com/mathematica/tutorial/IntroductionToManipulate.html

http://reference.wolfram.com/mathematica/tutorial/IntroductionToDynamic.html

to be continued...

-Jason


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to