Graphical Physics Program Suggestions

103 views
Skip to first unread message

kstueve

unread,
Sep 22, 2009, 2:14:00 PM9/22/09
to sage-devel
As my work on prime_pi and nth_prime is drawing to a close, William
Stein and I have discussed the possibility of me making a graphical
physics program to be included in Sage, the free open source math
program.

An example of the desired functionality is to either with a few lines
of code from within a Sage worksheet, or by clicking buttons in a
graphical user interface (GUI) create a physics problem with
components such as ramps, blocks, balls, pulleys, and springs, and
processes such as motion (translational or rotational), collisions
(elastic, inelastic, completely inelastic), and forces (friction,
gravity, normal forces, driving forces, etc).

I am expecting the VIGRE grant from the National Science Foundation
(NSF) to support my work, so I will be able to devote a lot of time to
this project.

I would like to obtain any and all suggestions for what features,
functionality etc. could be included in this program. Please don't be
afraid to contribute an idea. No suggestion is too large or too
small.

A few of the possible ideas that I have come up with so far:

Allowing time to be solved for-e.g. exactly how long does it take for
an event to occur, such as for velocity to reach 0.

Using multi-precision arithmetic and error analysis to solve a problem
to a specified accuracy-e.g. what is the velocity of an object at a
certain time to the 100th decimal (for problems that don't include too
much chaos).

Creating a human readable physics problem specification language that
allows the locations and properties of each component to be specified
(perhaps similar to standard circuit specification languages).

Allow matrices, systems of DEs, tables of values, etc that describe
the physics problem to be accessed with Sage commands.

Symbolic solving for problems that lend themselves to symbolic
solving.

Plotting variables such as velocity, kinetic energy etc. with respect
to time.

Plotting more complicated functions such as the amount of time a block
takes to slide to the bottom of a ramp with respect to the ramp's
angle.

Make architecture easily extensible so new components can be made by
the user

Three dimensional graphics and problems (after 2D is finished)

Kevin Stueve
kst...@uw.edu

Fernando Perez

unread,
Sep 22, 2009, 3:27:42 PM9/22/09
to sage-...@googlegroups.com
On Tue, Sep 22, 2009 at 11:14 AM, kstueve <kevin....@gmail.com> wrote:
> An example of the desired functionality is to either with a few lines
> of code from within a Sage worksheet, or by clicking buttons in a
> graphical user interface (GUI) create a physics problem with
> components such as ramps, blocks, balls, pulleys, and springs, and
> processes such as motion (translational or rotational), collisions
> (elastic, inelastic, completely inelastic), and forces (friction,
> gravity, normal forces, driving forces, etc).
>

You might want to have a look at vpython:

http://vpython.org/

It originated at Carnegie Mellon as a program to teach undergraduate
physics such that with very little code (and critically, no 3d
programming or OpenGL knowledge), one could

create a physics problem with
> components such as ramps, blocks, balls, pulleys, and springs, and
> processes such as motion (translational or rotational), collisions
> (elastic, inelastic, completely inelastic), and forces (friction,
> gravity, normal forces, driving forces, etc).

:)

Even if it doesn't fit precisely your needs, it's probably good
inspiration and has been around for ~ 9 years. I've used it (the old
version) for small demos and it's really nice.

Cheers,

f

William Stein

unread,
Sep 22, 2009, 3:33:16 PM9/22/09
to sage-...@googlegroups.com

Thanks for pointing that out. So far, I've noticed Kevin is very
good at taking existing things and plugging them together.

Maybe he could provide an AJAX-style web-based interface to some
vpython functionality?

William

Jason Grout

unread,
Sep 22, 2009, 3:41:10 PM9/22/09
to sage-...@googlegroups.com
William Stein wrote:
> Maybe he could provide an AJAX-style web-based interface to some
> vpython functionality?

Since we also already have momentum for incorporating mayavi, we should
also point out the mayavi tvtk "visual" module, whose api is modeled
after vpython:

https://svn.enthought.com/enthought/wiki/TVTKIntroduction#visual

I've used vpython too, and I thought it was really nice and simple.

Jason

--
Jason Grout

Ondrej Certik

unread,
Sep 22, 2009, 5:51:05 PM9/22/09
to sage-...@googlegroups.com
On Tue, Sep 22, 2009 at 11:14 AM, kstueve <kevin....@gmail.com> wrote:
>

You might also consider integrating pydy in:

http://pydy.org/

it uses sympy to generate the equations of motion for a rigid body and
scipy to solve them.

Ondrej

Tom Boothby

unread,
Sep 22, 2009, 6:25:44 PM9/22/09
to sage-...@googlegroups.com
I spent a while thinking that I was going to be a mechanical engineer,
and took a few of the ME intro courses. Engineering statics and
dynamics can be phrased entirely in terms of linear algebra, though
the courses I took didn't present them as such. Materials analysis is
highly computational in nature and could be interesting. When I took
these courses, I'd spend about 1-2 hours a week programming my TI
calculator to do my homework, and about 5 minutes actually doing my
homework (for the record, my professors were aware of, and pleased as
punch with this approach).

When I took the physics prerequisites for these courses, the problems
we had to do were 1-2 variable toys. The engineering homework
frequently had a number of rigid bodies in motion relative to one
another -- and involved solving systems of linear equations in 6-10
variables. If I were you, I'd look through Hibbeler's texts for
"typical" problems that it should be easy to input and solve. In
fact, you can borrow my copy some time, if you like.

On Tue, Sep 22, 2009 at 11:14 AM, kstueve <kevin....@gmail.com> wrote:
>

Fernando Perez

unread,
Sep 22, 2009, 9:50:28 PM9/22/09
to sage-...@googlegroups.com
On Tue, Sep 22, 2009 at 12:41 PM, Jason Grout
<jason...@creativetrax.com> wrote:
> Since we also already have momentum for incorporating mayavi, we should
> also point out the mayavi tvtk "visual" module, whose api is modeled
> after vpython:
>
> https://svn.enthought.com/enthought/wiki/TVTKIntroduction#visual
>
> I've used vpython too, and I thought it was really nice and simple.

Prabhu may comment with more information, but in the meantime, it's
worth keeping in mind that 'tvisual' has significantly lower
performance than visual, and in this case I'm not sure it can be
fixed. The issue is that the traits event handling machinery proves
to be too much overhead when you're trying to render a 3d scene at
interactive framerates, and the geometry is already being computed by
a python loop. Since tvtk is based on traits, all the traits machinery
is still active and in this case may be a bit too much.

If memory serves me right, Prabhu wasn't super optimistic about being
able to match vpython performance with tvisual, but I could (and would
love to) be misremembering, or perhaps it's just a matter of putting
manpower into it and not a fundamental limitation.

I just mention it so you are aware that out of the box, tvisual's
performance is just not enough to be usable like vpython is (and I
only tested it on fairly simple examples).

In case you'd like to run a simple comparison (and perhaps things have
improved), I'm attaching a simple example of parabolic motion written
both for vpython (old version) and tvtk/visual. Caveat: I haven't run
this code in years, so I'm not sure it runs with today's vpython or
tvtk.

Cheers,

f

shoot.py
shoot_t.py

Prabhu Ramachandran

unread,
Sep 23, 2009, 7:41:56 AM9/23/09
to sage-...@googlegroups.com
On Wednesday 23 September 2009 07:20 AM, Fernando Perez wrote:
>> https://svn.enthought.com/enthought/wiki/TVTKIntroduction#visual
>>
>> I've used vpython too, and I thought it was really nice and simple.
>
> Prabhu may comment with more information, but in the meantime, it's
> worth keeping in mind that 'tvisual' has significantly lower
> performance than visual, and in this case I'm not sure it can be
> fixed. The issue is that the traits event handling machinery proves
> to be too much overhead when you're trying to render a 3d scene at
> interactive framerates, and the geometry is already being computed by
> a python loop. Since tvtk is based on traits, all the traits machinery
> is still active and in this case may be a bit too much.

Thanks Fernando. The speed issue is still true but I wouldn't blame
traits since that isn't the source of the bottleneck. I think there are
a little too many events and too many renders. I have not had the time
to profile it carefully.

> If memory serves me right, Prabhu wasn't super optimistic about being
> able to match vpython performance with tvisual, but I could (and would
> love to) be misremembering, or perhaps it's just a matter of putting
> manpower into it and not a fundamental limitation.

I am not sure at all, since I haven't had the chance to look closely
enough but it is possible that there are too many events flying around
calling too much Python code.

> In case you'd like to run a simple comparison (and perhaps things have
> improved), I'm attaching a simple example of parabolic motion written
> both for vpython (old version) and tvtk/visual. Caveat: I haven't run
> this code in years, so I'm not sure it runs with today's vpython or
> tvtk.

It does and visually there is no difference but there is an order of
magnitude speed difference between the two in terms of CPU time.

prabhu

Jaap Spies

unread,
Sep 23, 2009, 4:17:04 PM9/23/09
to sage-...@googlegroups.com

In Januari I made a very, very experimental spkg for vpython.
See:
http://sage.math.washington.edu/home/jsp/SPKGS/VPython/

Screenshots:
http://picasaweb.google.nl/j.spies88/Vpython?authkey=CFT7gXmyzAA#

Jaap


Fernando Perez

unread,
Sep 23, 2009, 7:31:14 PM9/23/09
to sage-...@googlegroups.com
On Wed, Sep 23, 2009 at 4:41 AM, Prabhu Ramachandran
<pra...@aero.iitb.ac.in> wrote:
> Thanks Fernando.  The speed issue is still true but I wouldn't blame
> traits since that isn't the source of the bottleneck. I think there are
> a little too many events and too many renders. I have not had the time
> to profile it carefully.
>

Thanks for the clarifications, Prabhu. I remembered the performance
drop, but wasn't sure what all of the reasons were under the hood and
I was worried I could misrepresent the issue.

It would really be great to have vpython-like performance with the
clean tvtk api! Here's to hoping it's possible :)

Cheers,

f

kstueve

unread,
Oct 23, 2009, 4:05:58 PM10/23/09
to sage-devel
Have any of you heard of Erik Neumann? He published some excellent
Java physics demos at http://www.myphysicslab.com/ He is in Seatle,
and has attended UW.

I have been looking into vector graphics with javascript. It appears
that circles, lines, and other curves are made out of lots of div
elements (to represent pixels and groups of pixels), most likely using
a third party library, such as jsDraw2D (see
http://ajax.phpmagazine.net/2009/04/jsdraw2d_javascript_graphics_l.html).

Kevin

Maurizio

unread,
Oct 23, 2009, 5:51:57 PM10/23/09
to sage-devel
I don't want to add confusion, but I hope you can also think about the
similarity between mechanical and electrical problems. After all, it's
always matter of solving differential equations, having voltage,
current, and so on, instead of mechanical quantities.
The good thing, from this perspective, is that you could take some
inspiration from the hundreds of SPICE tools, which already provide a
GUI to define electrical problems. If you transpose the analogous of a
netlist into something mechanical, you maybe already have a good
starting point, which also gives you compatibility to electrical
problem (which I would like :P).

Just to give a rough idea, you could read:
http://www.analog-europe.com/207200675
(this is just after some google search, but there are thousands of
references about circuit solvers).
The good thing, in my opinion, is that there is already a standard
notation for netlists. Maybe you could introduce the mechanical
equivalent of those :)

Regards

Maurizio

On 23 Ott, 22:05, kstueve <kevin.stu...@gmail.com> wrote:
> Have any of you heard of Erik Neumann?  He published some excellent
> Java physics demos athttp://www.myphysicslab.com/ He is in Seatle,

brandon...@gmail.com

unread,
Oct 24, 2009, 1:28:52 PM10/24/09
to sage-devel


On Sep 22, 6:25 pm, Tom Boothby <tomas.boot...@gmail.com> wrote:
> I spent a while thinking that I was going to be a mechanical engineer,
> and took a few of the ME intro courses.  Engineering statics and
> dynamics can be phrased entirely in terms of linear algebra, though
> the courses I took didn't present them as such.  

I've never had any ME courses and I'm also not very knowledgeable in
dynamical systems or physics, but I thought it was untrue that
linearization of the phase space is adequate to describe the dynamics
if the phase space isn't structurally stable:
http://en.wikipedia.org/wiki/Hartman-Grobman_theorem

kstueve

unread,
Nov 3, 2009, 9:23:48 AM11/3/09
to sage-devel
I am trying to make/find collision response code for arbitrary 2D
rigid bodies with rotation and friction (single point collisions).

I posted a question to the message board
https://sourceforge.net/projects/mjbworld/forums/forum/122133/topic/3448212/index/page/1
for the site http://www.euclideanspace.com/physics/dynamics/collision/twod/index.htm.
Here is the question I asked:
"http://www.euclideanspace.com/physics/dynamics/collision/twod/
index.htm describes 2D collisions with friction and rotation between
two rigid bodies at a single point.

Define a coordinate system and naming convention such that "a"
corresponds to body "a", "b" corresponds to body "b", prime refers to
final values, a lack of a prime refers to an initial value, "x" refers
to the axis perpendicular to the plane of collision, and "y" refers to
the axis parallel to the plane of collision. Define A and B to be the
contact points of bodies a and b.

For the initial value problem, there are 6 unknowns (the final x and y
velocities and final angular velocities of each body), and there
should be 6 equations.

Because there is friction, energy is not necessarily conserved.

Let me propose the 6 equations:

1) coefficient of restitution equation: c = (vbx' - vax') / (vax -
vbx)

2) conservation of x momentum (on linked page)

3) conservation of y momentum (on linked page)

4) conservation of angular momentum about the center of mass (on
linked page)

Now integrate with respect to time the friction equation Ff = mu * Fn
(force of friction equals coefficient of friction times the normal
force) and applying the result to either point A or B.

Impulse due to friction (y-axis) = mu * x-axis impulse

Impulse due to friction (y-axis) = mu * delta x momentum

If the y components of the velocities of points A and B are equal, the
impulse due to friction on either point is automatically 0 (providing
the last two equations). Otherwise, there is going to be an impulse
due to friction on both points.

mass * delta y velocity = mu * mass * delta x velocity

delta y velocity = mu * delta x velocity (whatever mass represents
here it cancels out)

5) Frictional impulse of body a: change in y component of linear
velocity of point A = mu * change in x component of linear velocity of
point A

6) Frictional impulse of body b: change in y component of linear
velocity of point B = mu * change in x component of linear velocity of
point B

Are these equations correct?"

I then replied to my own thread with "After reading more of the site,
I realize that equation 1 must refer to the converging and diverging
velocities of points A and B, not the center of mass of body a or b."
> kstu...@uw.edu

kstueve

unread,
Nov 13, 2009, 6:19:59 PM11/13/09
to sage-devel
Tom,

Thanks. I just bought Hibbeler's "Engineering Mechanics: Statics" and
"Engineering Mechanics: Dynamics" on Amazon. I saved 99% (and spent
$1.57 + 2 * 3.99) because I bought old editions.

Kevin Stueve
> > kstu...@uw.edu

kstueve

unread,
Nov 13, 2009, 8:09:58 PM11/13/09
to sage-devel
To sage-dev
Can someone please explain to me what traits are in the context of
tvisual? The wiki page for it (http://www.enthought.com/traits from
the page https://svn.enthought.com/enthought/wiki/TVTKIntroduction) is
a dead link.
A google search of either vpython.org or svn.enthought.com produces
many results for visual, but none for tvisual. I am guessing that
tvisual is part of TVTK and visual part of VPython.

I see tvtk at the page https://svn.enthought.com/enthought/wiki/TVTKIntroduction
(traited vtk), and vtk at http://mayavi.sourceforge.net/.
http://www.vtk.org/ says that vtk is the visualization toolkit.

Jason Grout said "Since we also already have momentum for
incorporating mayavi.." Can someone please give me details. Is Jason
saying that Sage-dev is in the process of making mayavi part of Sage,
so it would be easy to use parts of mayavi?

What are the benefits of using tvtk over vpython? Vpython is faster.
How does Tvtk has a cleaner API?

Does pydy handle collisions and contact forces? I have read papers
that say that calculating contact forces for a large number of
simultaneously contacting rigid bodies is an NP-hard problem that
involves quadratic programming. There is lots of interdependency.
You can have a normal force and friction force at each contact point.
But you have to make sure that normal forces only push, not pull, and
you have to make sure that kinetic friction opposes motion (or pending
motion), and static friction is less than mu * Fn. During a collision
you have to have an infinite force for an instant to keep the objects
from colliding. If you take the time integral of force, you get
impulse, which is a change in momentum (mass times velocity), so what
you are basically saying is that you have an instantaneous transfer of
momentum. If you have an ellipse roll, the normal force will increase
sharply to a maximum at the location of least curvature. If you have
a "rounded square" defined by a certain equation, the normal force
will reach infinity at the location of zero curvature. However, the
area under the curve is finite, meaning that an instantaneous impulse
is not occurring. You just need a very good numerical integrator.
Including kinetic friction can lead to situations where an
instantaneous impulse is needed to prevent inter-penetration at times
other than a collision. Additionally, in some cases there are
multiple allowed solutions for where the objects go.

I have considered using the penalty method for handling collisions,
which involves allowing inter-penetration and a virtual spring force
that appears during inter-penetration. However very large spring
constants must be used, leading to stiff equations. One benefit of
penalty methods is that the multiple solutions in impulse methods go
away-which solution you end up with depends on whether the objects
that are touching are inter-penetrating or just touching.

I am also considering handling only collisions between two objects at
a time (with rotation and friction), since most problems I want PPS
(PythonPhysicsSimulation) to handle would be covered. One problem
that might be left out is two gliders on a track colliding, but for
this problem, you could lock the gliders to the track and consider the
gliders hitting as collision of two bodies, not three. I think that
if you are careful, you could properly handle the gliders on a track
colliding with only two-object collision handling.

What I want to make is a program that does for freshman physics
(springs, ramps, collisions, rotation, pulleys, strings, etc) what my
circuit program at circuitengine.com does for freshman circuits (and
hopefully more). You click a button and make a spring, ramp, block,
pulley etc. You right click an object and adjust its properties. You
hit start. You can make graphs. You can ask it to tell you how long
it takes for something to happen (e.g. height of object A is 10m), and
it uses some sort of decrease and conquer (binary search in the worst
case, but better can be done if we make an estimate of when the event
happens) to find the exact time that that happens.

Could anyone recommend any programs that have this sort of
functionality for me to look at?

Does anyone have any thoughts on using OpenModelica?

Another question:
Time permitting, I would like to be able to solve symbolic physics
problems. Instead of just giving initial conditions and solving for
later values, it would be nice to say (symbolically) "it takes t
seconds for the ball to reach the basket, at what angle was it
thrown". How might you go about this? I think that this could be
done using a theorem prover of sorts that searches the space of
theorems that can be proven from a small set of axioms and givens and
a set of manipulation rules. Of course this is an NP-complete problem
that is intractable in general (think Fermat's last theorem), but most
problems given to freshman physics students are only a few steps long,
meaning that the tree of possible proofs is relatively small and can
be exhaustively searched.
Does Sage have the ability to symbolically simplify "sin^2(theta)+cos^2
(theta)" to "1"?

For numeric problems such as "at what angle must the ball be thrown to
reach the basket in 2 seconds?", it might be possible to use some sort
of binary search to find the correct value.

Here is a link to my (very early) pre-draft of my writeup, so that you
can view the bibliography.
http://docs.google.com/View?id=df9q29vh_45dfx2wmfg

I declare Crocker's rules. http://www.sl4.org/crocker.html

Kevin Stueve

William Stein

unread,
Nov 13, 2009, 10:44:38 PM11/13/09
to sage-...@googlegroups.com
On Fri, Nov 13, 2009 at 5:09 PM, kstueve <kevin....@gmail.com> wrote:
>
> To sage-dev
> Can someone please explain to me what traits are in the context of
> tvisual?  The wiki page for it (http://www.enthought.com/traits from
> the page https://svn.enthought.com/enthought/wiki/TVTKIntroduction) is
> a dead link.
> A google search of either vpython.org or svn.enthought.com produces
> many results for visual, but none for tvisual.  I am guessing that
> tvisual is part of TVTK and visual part of VPython.
>
> I see tvtk at the page https://svn.enthought.com/enthought/wiki/TVTKIntroduction
> (traited vtk), and vtk at http://mayavi.sourceforge.net/.
> http://www.vtk.org/ says that vtk is the visualization toolkit.
>
> Jason Grout said "Since we also already have momentum for
> incorporating mayavi.."  Can someone please give me details.  Is Jason
> saying that Sage-dev is in the process of making mayavi part of Sage,
> so it would be easy to use parts of mayavi?

No. To the best of my knowledge nobody is working on including
mayavai + vtk in Sage. VTK is quite difficult to build, to put it
mildly.

> What are the benefits of using tvtk over vpython?  Vpython is faster.
> How does Tvtk has a cleaner API?

Note that tvtk and vpython don't work via a web browser. Part of the
challenge of Sage -- and the opportunity -- is making capabilities
available via a webpage. For that, the only options are javascript
(=AJAX) or Java.

> Does anyone have any thoughts on using OpenModelica?

It's license is GPL-incompatible. However, I've been told they are in
the process of changing their license to be GPL-compatible. I hope
this happens.

>
> Another question:
> Time permitting, I would like to be able to solve symbolic physics
> problems.  Instead of just giving initial conditions and solving for
> later values, it would be nice to say (symbolically) "it takes t
> seconds for the ball to reach the basket, at what angle was it
> thrown".  How might you go about this?  I think that this could be
> done using a theorem prover of sorts that searches the space of
> theorems that can be proven from a small set of axioms and givens and
> a set of manipulation rules.  Of course this is an NP-complete problem
> that is intractable in general (think Fermat's last theorem),

Fermat's last theorem has nothing to do with NP complete problems, as
far as I know. What connection were you thinking of? I'm curious.

I'm also confused as to what doing physics symbolically has to do with
theorem provers.

> but most
> problems given to freshman physics students are only a few steps long,
> meaning that the tree of possible proofs is relatively small and can
> be exhaustively searched.
> Does Sage have the ability to symbolically simplify "sin^2(theta)+cos^2
> (theta)" to "1"?

Yes:
sage: var('theta')
theta
sage: f = sin(theta)^2 + cos(theta)^2
sage: f.trig_simplify()
1


> For numeric problems such as "at what angle must the ball be thrown to
> reach the basket in 2 seconds?", it might be possible to use some sort
> of binary search to find the correct value.
>
> Here is a link to my (very early) pre-draft of my writeup, so that you
> can view the bibliography.
> http://docs.google.com/View?id=df9q29vh_45dfx2wmfg
>
> I declare Crocker's rules.  http://www.sl4.org/crocker.html

And I exercise it :-)

William

>
> Kevin Stueve
>
>
> On Sep 23, 3:31 pm, Fernando Perez <fperez....@gmail.com> wrote:
>> On Wed, Sep 23, 2009 at 4:41 AM, Prabhu Ramachandran
>>
>> <pra...@aero.iitb.ac.in> wrote:
>> > Thanks Fernando.  The speed issue is still true but I wouldn't blame
>> > traits since that isn't the source of the bottleneck. I think there are
>> > a little too many events and too many renders. I have not had the time
>> > to profile it carefully.
>>
>> Thanks for the clarifications, Prabhu.  I remembered the performance
>> drop, but wasn't sure what all of the reasons were under the hood and
>> I was worried I could misrepresent the issue.
>>
>> It would really be great to have vpython-like performance with the
>> clean tvtk api!  Here's to hoping it's possible :)
>>
>> Cheers,
>>
>> f
> >
>



--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

kstueve

unread,
Nov 14, 2009, 12:51:21 AM11/14/09
to sage-devel


On Nov 13, 7:44 pm, William Stein <wst...@gmail.com> wrote:
> On Fri, Nov 13, 2009 at 5:09 PM, kstueve <kevin.stu...@gmail.com> wrote:
>
> > To sage-dev
> > Can someone please explain to me what traits are in the context of
> > tvisual?  The wiki page for it (http://www.enthought.com/traitsfrom
> > the pagehttps://svn.enthought.com/enthought/wiki/TVTKIntroduction) is
> > a dead link.
> > A google search of either vpython.org or svn.enthought.com produces
> > many results for visual, but none for tvisual.  I am guessing that
> > tvisual is part of TVTK and visual part of VPython.
>
> > I see tvtk at the pagehttps://svn.enthought.com/enthought/wiki/TVTKIntroduction
> > (traited vtk), and vtk athttp://mayavi.sourceforge.net/.
> >http://www.vtk.org/says that vtk is the visualization toolkit.
Automated theorem proving is NP-complete (because the boolean
satisfiability problem (which is NP-complete) reduces to finding a
proof of satisfiability (and a proof of satisfiability will exist with
length a fixed polynomial of the size of the original boolean
satisfiability problem) and proofs can be verified in time polynomial
of the length of the proof). I gave Fermat's last theorem as an
example of the difficulty of finding the correct 300 page permutation
of symbols that represents a correct proof of a statement. Perhaps it
sounded as if I was discussing trying many potential integer solutions
to x^n+y^n=z^n, which is not what I meant.
Asking a computer to find a 300 page proof of a statement like
Fermat's last theorem by search is a bad idea. I think asking a
computer to find a 5 line solution to a simple symbolic physics
problem (the sort you find in freshman physics) might be a good idea.
I am curious about how trig_simplify works. "return self.parent()
(self._maxima_().trigexpand().trigsimp())"
It doesn't seem to use search. Does anyone know if there are any
components of Sage that use search by an automated theorem prover?
http://en.wikipedia.org/wiki/Automated_theorem_proving#Decidability_of_the_problem
>
> I'm also confused as to what doing physics symbolically has to do with
> theorem provers.
Theorem proving can be attacked by doing a search of all theorems that
follow from the axioms (although it will take time exponential in the
length of the theorem). Many physics problems are presented
effectively as a set of equations. Solving a set of equations
symbolically (that is designed to be solved symbolically by a student
in several steps) can be attacked by doing a search of the equations
that follow from the original equations for one that gives the value
in question. The analogy to theorem proving is strong-you might be
searching for an equation/theorem of the form "x = _____"
As an example of the sort of problem for which I think search might be
useful (problem 83 on page 81 from Tipler Physics for Scientists for
Engineers):
"At 1/2 of it's maximum height, the speed of a projectile is 3/4 of
its initial speed. What was its launch angle?"
This is a symbolic problem that cannot be solved by plugging values
into a projectile motion equation from an equation sheet.
Is there a better way to approach such problems from a programming
point of view? I guess for this problem, you could just employ some
sort of numerical educated guess and check/Newton's method/binary
search algorithm, but such a solution does not show work or steps and
it would be easy to find a similar problem that is entirely symbolic.
Correct me if I'm wrong, but I believe that the only way to solve a
problem like this is to write down what you know and manipulate it
until you arrive at a solution (which is a search problem).

kstueve

unread,
Nov 15, 2009, 6:42:14 PM11/15/09
to sage-devel
I need my program to have a graphical interface when run either
locally or on a remote server. My options are either JavaScript and
Java for the GUI front-end that communicates with the main Python
program.

Does anyone have any thoughts on using one over the other? Although
Java
has the drawback that it isn't as widespread and seamless as
JavaScript, it does have powerful graphics capabilities. Do you think
Java would produce smoother animation?

I would appreciate it if anyone has any links to JavaScript libraries
(or general suggestions on making a JavaScript GUI front-end that
communicates with a Python program) that might be helpful.

Here are links to Phun/Algodoo, a powerful commercial 2D physics
program
that gives students a qualitative understanding of physics principles.
http://www.youtube.com/watch?v=0H5g9VS0ENM
http://www.algodoo.com/wiki/Home
That is the bar I am aiming for (with quantitative output too).

Kevin Stueve


On Nov 13, 5:09 pm, kstueve <kevin.stu...@gmail.com> wrote:
> To sage-dev
> Can someone please explain to me what traits are in the context of
> tvisual?  The wiki page for it (http://www.enthought.com/traitsfrom
> the pagehttps://svn.enthought.com/enthought/wiki/TVTKIntroduction) is
> a dead link.
> A google search of either vpython.org or svn.enthought.com produces
> many results for visual, but none for tvisual.  I am guessing that
> tvisual is part of TVTK and visual part of VPython.
>
> I see tvtk at the pagehttps://svn.enthought.com/enthought/wiki/TVTKIntroduction
> (traited vtk), and vtk athttp://mayavi.sourceforge.net/.http://www.vtk.org/says that vtk is the visualization toolkit.
> can view the bibliography.http://docs.google.com/View?id=df9q29vh_45dfx2wmfg

Pat LeSmithe

unread,
Nov 15, 2009, 6:58:35 PM11/15/09
to sage-...@googlegroups.com
On 11/15/2009 03:42 PM, kstueve wrote:
> I would appreciate it if anyone has any links to JavaScript libraries
> (or general suggestions on making a JavaScript GUI front-end that
> communicates with a Python program) that might be helpful.

There are some links at

http://wiki.sagemath.org/JavascriptResources

kstueve

unread,
Nov 15, 2009, 9:08:09 PM11/15/09
to sage-devel
SVG looks useful. But it doesn't work on Internet Explorer without
special software.
http://en.wikipedia.org/wiki/Scalable_Vector_Graphics

When I developed a Java applet, I had to spend great amounts of time
researching the idiosyncrasies of different browsers on how to embed a
Java applet with parameters. Since first being exposed to Java, the
<applet> tag had been deprecated, adding difficulty.

Then I learned that some operating systems don't have the latest
version of the Java Virtual Machine, and that some mice do not have a
right button.

If using JS (and related libraries) on all platforms may require extra
plugins, would Java make more sense, or do I just need to find ways to
use JS effectively?

Does anyone have any general suggestions on how I might want to
develop a GUI with animation and mouse interaction with JS?

Kevin Stueve

Pat LeSmithe

unread,
Nov 15, 2009, 11:45:14 PM11/15/09
to sage-...@googlegroups.com
On 11/15/2009 06:08 PM, kstueve wrote:
> If using JS (and related libraries) on all platforms may require extra
> plugins, would Java make more sense, or do I just need to find ways to
> use JS effectively?
>
> Does anyone have any general suggestions on how I might want to
> develop a GUI with animation and mouse interaction with JS?

It may be best to start with an existing package. How about GeoGebra

http://www.geogebra.org/

? Moreover, the best solution may involve both Java (e.g., for
rendering, interaction) and JavaScript (e.g., for control,
communication, updates). I think Jmol and GeoGebra are both JS-able.

kstueve

unread,
Nov 16, 2009, 12:51:05 AM11/16/09
to sage-devel
Pat, thanks for the links and suggestions. They were helpful.
GeoGebra and Jmol are written in Java. Jmol and GeoGebra can use
JavaScript to simplify embedding in a web-page. Is this what you mean
by JS-"able"?

Pat LeSmithe

unread,
Nov 16, 2009, 1:03:10 AM11/16/09
to sage-...@googlegroups.com
On 11/15/2009 09:51 PM, kstueve wrote:
> GeoGebra and Jmol are written in Java. Jmol and GeoGebra can use
> JavaScript to simplify embedding in a web-page. Is this what you mean
> by JS-"able"?

Yes. Although Sage, for now, does not make extensive use of either
project's JS API, we could use them, e.g., to update the applets
dynamically, with results computed on the notebook server.

Jmol

http://jmol.sourceforge.net/jslibrary/

GeoGebra

http://www.geogebra.org/en/wiki/index.php/GeoGebra_JavaScript_Methods

kstueve

unread,
Nov 17, 2009, 4:13:51 AM11/17/09
to sage-devel
How can you edit a plot in real time programatically? I have found
Ptplot useful in the past. It allows points to be added to a plot,
zooming, etc. Is there functionality like this in Sage? Would Ptplot
make a good addition to Sage? I would like some way to graph
quantities as they are changing (and being calculated), such as the
position or velocity of a body.
http://ptolemy.berkeley.edu/java/ptplot5.7/ptolemy/plot/doc/index.htm
Kevin Stueve

kstueve

unread,
Nov 27, 2009, 8:48:55 PM11/27/09
to sage-devel
I need help integrating a Python/Cython program (calculation/
simulation) with Java (GUI front-end with Swing, mouselistener,
animating graphics). If anyone has experience integrating different
languages with Sage and the notebook, experience combining Python (and
Cython/C) with other languages, or experience integrating server/
client code, you could probably help me out.

I know that if I write my code in Python/Cython, I can compile it to
C, and call the C program from Java. But I think a much better way to
do this would be to have Python/Cython call Java-that way you run a
Python/Cython program.

I have looked into this and found JPE Java-Python Extension and JPype,
which aim to provide a way for a standard Python program to call a
Java program. However, I fear that these may not work on all of the
platforms Sage supports.

And then I also will have to worry about letting the program be run
locally (easier), or from the Sage server (the Python/Cython would be
run on the server and the Java applet would be run locally), which
appears more difficult because I would presumably need to pipe mouse
actions and graphics calls over the Internet.
(this seems computationally expensive to me)

Is there a better option? I believe that even if I used JavaScript (a
client-side language) in place of Java, I would still need to pipe
mouse actions and graphics calls over the Internet (which I worry is
too computationally expensive). Am I wrong about this network
communication being too expensive?

If I did everything in Java, then it would be easier to run the
program locally or on a server (as an applet that is downloaded to the
client), but I don't have the feeling that Java is the best
environment to do development for Sage in (if possible in practice at
all).

What are my options? Should I just focus on making the program work
locally (either put functioning on the Sage server on a wish-list or
just require downloading the program and Sage to run it)? It sure
would look nice to see my program running on the Sage server with a
Java front-end on a smart phone.

If MMORPGs can handle the problem of having animating graphics
controlled by mouse and keyboard locally with communication with a
server orchestrating a large percentage of the interaction, then Sage
should be able to too. Maybe for the Python/Cython running on the
Sage server case, I could be very careful about the mouse actions that
are piped across the network. Instead of sending a packet every time
the mouse cursor moves a few pixels, maybe I could keep a queue of
mouse actions in the Java applet and then only send a packet every, oh
I don't know, fourth of a second with the total mouse movement. I
tried something similar to this (storing mouse actions in a queue and
then combining them into larger total movements before responding to
them) for a physics demo I made in Java. And as far as piping
graphics commands over the network, maybe instead of sending each and
every drawLine from the Sage server to the Java applet on the client,
maybe I could load the coordinates of the bodies into the applet, and
then only communicate the movement of the bodies (move(x,y,theta)).
Maybe I could have the Python/Cython compute the exact movement of the
bodies, but only give the Java applet a series of "snapshots" of
positions that are interpolated (likely better than linearly) by the
Java applet to create believable animation.

Kevin Stueve

On Nov 15, 3:42 pm, kstueve <kevin.stu...@gmail.com> wrote:
> I need my program to have a graphical interface when run either
> locally or on a remote server.  My options are either JavaScript and
> Java for the GUI front-end that communicates with the main Python
> program.
>
> Does anyone have any thoughts on using one over the other?  Although
> Java
> has the drawback that it isn't as widespread and seamless as
> JavaScript, it does have powerful graphics capabilities.  Do you think
> Java would produce smoother animation?
>
> I would appreciate it if anyone has any links to JavaScript libraries
> (or general suggestions on making a JavaScript GUI front-end that
> communicates with a Python program) that might be helpful.
>
> Here are links to Phun/Algodoo, a powerful commercial 2Dphysics
> program
> that gives students a qualitative understanding ofphysicsprinciples.http://www.youtube.com/watch?v=0H5g9VS0ENMhttp://www.algodoo.com/wiki/Home
> That is the bar I am aiming for (with quantitative output too).
>
> Kevin Stueve
>
> On Nov 13, 5:09 pm, kstueve <kevin.stu...@gmail.com> wrote:
>
>
>
> > To sage-dev
> > Can someone please explain to me what traits are in the context of
> > tvisual?  The wiki page for it (http://www.enthought.com/traitsfrom
> > the pagehttps://svn.enthought.com/enthought/wiki/TVTKIntroduction) is
> > a dead link.
> > A google search of either vpython.org or svn.enthought.com produces
> > many results for visual, but none for tvisual.  I am guessing that
> > tvisual is part of TVTK and visual part of VPython.
>
> > I see tvtk at the pagehttps://svn.enthought.com/enthought/wiki/TVTKIntroduction
> > (traited vtk), and vtk athttp://mayavi.sourceforge.net/.http://www.vtk.org/saysthat vtk is the visualization toolkit.
> > problems given to freshmanphysicsstudents are only a few steps long,

kstueve

unread,
Nov 28, 2009, 4:14:09 PM11/28/09
to sage-devel
I have another question. I need a parser for the d attribute of the
path element of svg (scalable vector graphics). I want my physics
program to be able import shapes drawn with an svg designer such as
inkscape. Pyparsing seems to meet my needs. This is a third party
python library. If I use Pyparsing in a program that I hope to become
a part of Sage, do I need to add doctests to Pyparsing? Are there
special rules for using third party libraries in Sage?

http://www.inkscape.org/ (inkscape homepage)
http://www.w3.org/TR/SVG/paths.html (svg spec)
http://sourceforge.net/projects/pyparsing/ (pyparsing page)
http://bytes.com/topic/python/answers/733884-pyparsing-svg (using
pyparsing to parse svg)

Kevin Stueve

Pat LeSmithe

unread,
Nov 29, 2009, 1:33:07 AM11/29/09
to sage-...@googlegroups.com
On 11/28/2009 01:14 PM, kstueve wrote:
> inkscape. Pyparsing seems to meet my needs. This is a third party

Pyparsing is already part of the Sage distribution:

sage: from matplotlib import pyparsing
Reply all
Reply to author
Forward
0 new messages