Mac Dude

1551 Reputation

17 Badges

12 years, 125 days

MaplePrimes Activity

These are answers submitted by Mac Dude

In your code all vectors are of datatype=anything. In fact,your answers are stored as unevaluated expressions. If you use vectors of datatype=float then you avoid that. But to do that you'll have to change ans to a matrix so you can store your results one per cell; as it is, each element of ans stores a set.


You need to spell out r(phi) everywhere.

Once you do that, dsolve comes back with an unevaluated integral. So you'll have to help Maple to get to the solution you want. I am no expert on elliptical integrals so someone else needs to chime in here.

Mac Dude.


Your post seems to have many symbols and other pieces missing in your statement of the problem, at least on my screen (Ffx on Mac OS X). So we cannot really help a lot. Please check your post (and next time, use the preview button to check before posting).

But some hints:

vx and vy are integrals of 0 over t. I'll let you figure out what this gives. There may be a typo in the expr. for vy.

It actually looks like you really want to solve a differential equation, the equation of motion for your ball. Explicit integration should work for this problem, but you'll need to be careful in setting up your problem and do it right. The alternative is dsolve. But nowhere do I see the equations stated that actually govern the motion of the ball. Typically you would setup an equation equating the change in momentum with the force(s) acting on the ball and solve (integrate) that. Note that in Maple you can define an equation with "=" which is different from an assignment (":="). (And equations can be assigned to names...).

I suggest when you write your Maple program, you comment at every step what it supposedly does (# comment). Then you can compare this with your classroom notes, or your buddies, and see whether it actually does that. In that way you may also identify the missing pieces.




What is the point?




Try interface(displayprecision=<no_of_digits>); I think that will do what you want. It defaults to -1, which means print all Digits.

Mac Dude

You are certainly correct in perceiving Maple's bewildering range of data constructs as confusing.

While I won't claim to be an expert, I have found a few considerations to be worthwhile.

First (and I learned it on Mapleprimes): Maple distinguishes between mutable and immutable structures. Lists (as mentioned below) are immutable. So not suitable for manipulation of elements. Arrays, Matrices and Vectors are mutable. The underlying construct is a so-called rtable. Matrix is 2-d, Vector is 1-d, Array can have any dimensions. Lists and I believe sets as well are immutable. Then there are tables, which are associative arrays (or hashes, as Perl afficionados would call them).

Then there are datatypes. An Array, Vector etc. can have a datatype like float, integer, string, or that catch-all type anything.

As you already found out, you use Matrix and Vector when doing linear algebra. Specifically, you'll want to initialize them as datatype float if you want to do numerics. You'll need datatype anything if you want to do symbolic math.

I like using Arrays for storing data structures (like records or lists or...) that I am not doing much or any math with. But Array is also needed for higher-dimensional objects (>2-d).

Lists I use mostly in function-call arguments, as substitution lists & similar.

Sets are just that in a mathematical sense. No two elements are alike. I am not doing set theory so I use them rarely.

The Programming Guide exposes a number of these types in more detail.

But as far as efficiency goes I find the datatype is most important. Blind use of datatype anything will slow things down.

Mac Dude.

As the OP advised me, my comment yesterday on his follow-up question did not post, although he did get a notification... so here it is again.

(frst and scnd are the differentials wrt. phi from the worksheet)

For unequal amplitutes, one can still see what happens over a long time, esp. when t = infinity:


This can only be zero if sin(phi)=0 or sin(phi)=Pi (or multiples of 2*Pi of course). We can then plug that in and evaluate for arbitrary t:


where _Z2~ is an integer ≥0. So we now know that for phi = 0 we have an extremum at values of t corresponding to half cycles.

Plugging this result into scnd we get



confirm that the 2nd derivative is >0 for t>0 to confirm that we have a minimum. It is trivial to show that for Phi=Pi we get the other sign in the derivative i.e. a maximum. (Don't worry about _Z2~ vs _Z1~; I reran pieces of the sheet inbetween; these are the same generated variables)

So the problem is solved for unequal amplitudes under the condition that we look at complete half-cycles.

Mac Dude.

I have had the same problem (discussed here on Mapleprimes) when sharing worksheets between Maple 15 and 17. The "solution" I finally found is to quit and restart Maple completely, opening the offending worksheet as the first sheet to open. That seems to fairly reliably get this unclogged. It is kind-of annoying, but one of the lesser problems with Maple.

I am on Mac OS X.

Mac Dude

With all due respect: Nonlinearfit needs to be used properly to work.

Data type has to be Vector. Fit variables should be declared. Initial values have to be provided.



X := convert([Data[.., 1]],Vector):
Y := convert([Data[.., 2]],Vector):
f := a+b*x^c+d*x^e:

sol:=NonlinearFit(f, X, Y, x,parameternames=[a,b,c,d,e],initialvalues=[a=50,b=1,c=1,d=1,e=2]);

This finds a good solution immediately. There is some funny business @ x<0 which I'll leave to the OP to figure out.

pagan showed you how to create a plot file. I personally would edit this file. Photoshop will work although it is not optimal, if you use Mac OS X consider GraphicConverter. If the ps file cannot be edited then you can chose gif as device which will create a bitmap (use height and width in plotoptions to get enough resolution). Note that in a gif you lose the ability to edit text.

Post-editing---if feasible---is usually much quicker than trying to coerce Maple (or any program, for that matter) to output something it does not want to.

Mac Dude

Well, the pedestrian way would be to use LinearAlgebra:-Column to extract the columns from Matrix C and compare them with each one in H in a do loop. You can probably also use something like H[..,colNo] to get at the columns. You can use seq to avoid some of the explicit looping.There may be more elegant methods out there.

Mac Dude

These do work.

However, I have had situations where the GUI (i.e. the Java process) would hang, typically when loop constructs are involved. If the Java process hangs, you are out of luck. One of the penalties with using Java, I guess. On the plus side: you can scroll up and down your code while it is running... Also, I have had some success with restoring a worksheet from the backup that Maple saves (and that is left if you abort the whole Maple session), although the process to do that is way too inflexible for my taste.

Mac Dude.


Here is what I would do:

X:=Matrix([seq([x, x^2, 8-4*x], x=0..2.9, 0.1)]):

plots:-pointplot takes the option connect=true if you want lines instead of points.

As a Perl programmer would say: "There is more than one way to do it."

Mac Dude.

You may want to look at MathType. It is the Equation Editor on steroids. You can copy the MathML from Maple and paste it into a MathType widow. I haven't actually tried it yet. They have a 30-day evaluation period. I think it costs $60 or so, maybe less for academic or student use.


Mac Dude

Well, the info you give is kind-of terse, isn't it.

Let me speculate, then: You get warnings about certain variables implicitly declared local. The way to avoid that is to explicitly declare them like so:

local vara,varb;
local answer:=42;

... (procedure body)

end proc;

Note: the local declarations have to come before the executable statements making up the procedure.

I strongly suggest you d/l the Programming Guide. It's all in there.

Mac Dude

First 15 16 17 18 19 20 Page 17 of 20