Mac Dude

1526 Reputation

17 Badges

10 years, 298 days

MaplePrimes Activity


These are answers submitted by Mac Dude

(D(x))(t) is a differentiating operator. diff(x'(t),x(t)) is a differentiating operation. Don't assign anything to these; I am surprised Maple does not barf at these assignments. If you want to define differential equations, write D(x)(t) = ... (use = rather than :=). This defines an equation that Maple can do something with.

In your last block you are dooing it right: you are assigning a differential to a name (a variable); so no problem here.

I don't know enough about what you want to achieve so cannot help beyond this.

M.D.

 

You have 3 equations with 2 unknowns which means there is no general exact solution. It depends on the numbers whether there is a specific solution. Be that as it may, use only two equations.

If you use only two of the three equations, in your first case, solve() will do this without any fuss:

solve([a = sin(w*t1 + phi),b = sin(w*t2 + phi)],[w,phi],explicit);

The result is a bit messy so I spare this board printing it, and there are branch cuts to consider, but nothing is out of the ordinary here. Since you have periodic functions you will likely have an infinite number of solutions; use the option allsolutions to solve to get more than the first one.

I'll leave it to you to figure out the 2nd case.

Check the help on solve to find out its options.

Mac Dude

 

We do not know what is in your launch.ini file (I assume you refer to the Maple initialization file, which I thought was maple.ini on Windows, but I could be wrong) so we cannot tell for sure, but I think it is unlikely to be the problem.

I have had some issues in Maple (15 and up, standard GUI, worksheet mode) when selecting the entire output including the terminating characters. If I want to copy output for later paste I usually make sure the selection range does NOT include the final (invisible) character and does NOT extend to the next line. On occasion I would not copy the last visible character and add that one manually (usually it is a closing bracket). There is certainly no general issue with copy-pasting output or even parts of it. Do note that sometimes the pasted input looks different as Maple may use a different form internally than what the pretty-printer produces.

For really long output, taro's suggestion to use lprint is not a bad one, alternatively, you may just want to write out the variable to a file and read it back in as a string. You can use "parse" to convert it back to an expression.

Mac Dude

 

In your definition of w(n) there is no way to tell when the recursion is to stop. Typically, the recursive call would be w(n-1), and in the definition of w you return when n=0. Or something similar, depending on your specific problem.

As is, if w(n) calls w(n) the recursion can never stop. Hence the error you got.

Also; you appear to use = as assignment operator; that should be :=. Furthermore, to prevent grief I suggest you use the arrow operator to define a function:

f:= (x,w,t) -> x*w*t;
r:=(n) -> n; # and what is that supposed to do??

The way you wrote it f is not going to work as you expect. Note that the parameters to f are simple names; you use the functions when you call f (as in result:=f(x(n),w(n),t)).

If you explain a little more whatyou are actually up to then I am sure we can be more specific.

Mac Dude.


 

Try adding a vertical label with a lot of blank spaces, like "...,labels=[typeset(" ").typeset("                        ")]);

Unless you changed the default the label will be printed in horizontal orientation thus creating the space you want.

Mac Dude

 

D is a protected name (the differentiel operator) in Maple and cannot be assigned to. So choose some other name.

Also, do you want "D" to be a Matrix, or a function? If a Matrix, you need to pre-define it as such else Maple will create a table (an associative array, what other languages call a hash). If n is known you would use square brackets rather than braces to do the assignment; but you can also use braces in what Maple calls "programmer indexing", which allows to dynamically enlarge the Matrix, but then the indices always start at 1. RTFM for this topic.

I think the latest versions of Maple may allow for the notation you use for D to define a function, at least in 2-D input. Due to the similarity to programmer indexing I would suggest you do not use that notation but rather Maple's arrow operator to define a function (if that is what you really intended). While maybe a bit weird initially, you get used to it quickly and will appreciate the uniqueness of it.

M.D.

 

Here is an attempt to give you at least a feeling for what these do and what their main thrust is. Note that I am a Maple user and a LaTeX user, have used Mma maybe 10 years ago and have dabbled in Matlab.

Maple and Mma are computer algebra systems (CAS) so you can use both of these to do analytic work incl. solving of equations and solving of differential equations (ODE and PDE). Each of these systems have certain limitations I cannot really go into too deeply here. Maple and Mma also nowadays have extensive numerical capabilities; I have analysed whole experimental data sets with thousands of records in Maple, but not any with millions of records. Maple allows you to write complex code and also build a GUI for ease of usage. I assume recent versions of Mma allow the same. Maple has a certain amount of object-oriented capabilities but is not a full-fledged oo language. Mma is stronger as a language for functional programming than Maple according to others I discussed this with.

Matlab originated as a "wrapper" around LaPACK and BLAS (highly optimized linear algebra and matrix routines). Over the years it acquired many more capabilitie incl. the ability to write GUIs and also, I believe, some analytic (or algebraic) capabilities. The matrix capabilities are highly optimized and efficient (I believe more so that Maple's although I have not done a direct comparison). Matlab's freeware cousin Octave has oo capabilities; I assume Matlab as well (but I don't know that for a fact).

For both Maple and Matlab there are Toolboxes you can buy to extend their abilities e.g. in simulation or digital filter design. Again, Maple allows algebraic work whereas I suspect in Matlab you are quickly relegated to doing numerics. In my professional environment (particle accelerators), Matlab is in widespread use for anything from data analysis and processing to being embedded in the control system, making use of its GUI and plotting capabilities. Mma (and to a lesser extent maple) are used by our people to do theory.

Finally, LaTeX is a different beast altogether: it is a document description language built on top of the TeX typesetting system. Maple and Mma both have the ability to create LaTeX code from (pieces of) their workbooks so you can include that into a larger LaTeX document (e.g. a paper you are writing).

If you need help in deciding which of these to use (e.g. to buy) please indicate what you want to do with it. If your aims are general (i.e. "I am a n-th year student of physics..." or similar), I suspect Maple or Mma have broader applicability than Matlab due to their analytic capabilities. I am a Maple user and use Maple in a teaching environment, therefore I am biased towards Maple. If you need it primarily for data analysis or numeric work, Matlab maybe better suited, in parts due to its widespread use for such things. In that case it is worth investing Octave as well; maybe not as powerful or polished as Matlab, but free. Note that, unless you are a professional and large-scale user, questions like efficiency are likely of secondary importance. Any of Maple, Mma and Matlab will be able to cope with relatively large problems, if my experience with Maple is any indication here.

So, let us know what your applications are and we'll take it from there.

M.D.

Well, you refer to "the above output" but the above lines are actually Maple input.

Then, "Maple-friendly format" is a little ambiguous. Do you want to be able to save a whole worksheet as text, input and output, and be able to read it back in? Or is writing input only sufficient as you can always run the read-in sheet and recreate the output. If all you want to write is a specific variable; tomleslie has shown how to do that.

In the standard GUI you can save worksheets in various formats using File>Export... In the following dialog; chose the format you want: Maple text refers to saving input and pretty-printed output in ASCII form. You CANNOT read this back in as Maple chokes on various issues. If you save as Maple Input; only the input gets saved in ASCII as a .mpl file but no output. You CAN read this back in and run it to recreate the output.

HTH,

M.D.

The "Open Recent..." item in the File menu has a "Restore Backup" item that has, on rare occasion, given me back  some work that got clobbered. You can also try looking  for a "<filename>_MAS.bak" file in your working directory and try opening that. However, in general it is retyping time.

For the next time, though, when you get the "Kernel connection lost" message, save right then! If cmd-s does not work, quit Maple at which time it'll ask you whether you want to save the sheet, to which you answer "Yes." Your sheet will be saved.

M.D.

Your need is not quite clear. But assuming that upon reading-in the Excel data you end up with some kind of variable holding text strings and you want to use these text strings as variable names to assign to, you can use assign() to do that. Example:

restart;
t:="Test":
assign(cat(``,t)=3): # assigns 3 to variable Test
assign(cat(``,"Test2")=3):
Test;
            3
Test2;
             3

The cat() construct is to coerce the strings to Maple names. There may be other methods to do this conversion. At the same time you can use cat() to pre-pend some common identifier.

HTH, post more details if I missed your question.

Mac Dude

Check the downloaded file with an editor (since it is csv you can do that, but you may need to skip the FileTools:-RemoveDirectory in DL()). Most likely the last line (or one line somewhere) is too short or otherwise malformed. ImportMatrix is not particularly graceful when it comes to irregularities in files to be imported.

M.D.

Edit: Oops; did not see the other replies before posting. However, the point to inspect the downloaded .csv file is still valid; inspecting .xlsx files from the same sheet does not count as they can (will) differ.

I copy-pasted your statements above into Maple 15 and I am getting the expected plots. The first one is from -10..10 (Maple-picked default); the second one is from -1..1 as expected. Will try Maple 17 later.

Are you sure there isn't something in your code that is not in your post? Or that somehow plot got redefined? You can test for that by copy-pasting the line into a new sheet.

M.D.

Edited: added question about redefined plot function.

Here is what I get on Maple 15 in the Standard interface:

restart;A := <a,b,c>;

a := 1:  b := 2: c := 3:
A;

B:=convert(A, list);

A;

B;

seq(A[i],i=1..3);

The output from the seq command as well as the result for B indicate that in fact A has been set... weird.

Exporting this as Maple Input and reading it into CLI Maple (same installation) I get this:

> A := <a,b,c>;
                                             [a]
                                             [ ]
                                        A := [b]
                                             [ ]
                                             [c]

> a := 1:  b := 2: c := 3:
> A;
                                          [1]
                                          [ ]
                                          [2]
                                          [ ]
                                          [3]

> B:=convert(A, list);
                                     B := [a, b, c]

> A;
                                          [1]
                                          [ ]
                                          [2]
                                          [ ]
                                          [3]

> B;
                                       [1, 2, 3]

> seq(A[i],i=1..3);
                                        1, 2, 3

The output from the convert function is a bit weird, otherwise this is as I would have expected. Note that convert produces unexpected output in both cases (GUI and CLI).

Can't be too cautious, can't we, when using computer-generated results.

Mac Dude.

What about

M:=ArrayTools:-RandomArray(1000,1000,distribution=normal);

?

On my machine (PowerMac G5 running Maple 15; both ancient by modern standards) this is practically instant.

It seems to be preferable to just about any of the other methods mentioned, except that you get to scale the numbers yourself to the range you want; and you get to figure out what range they cover to begin with as the docs don't actually say that.

Mac Dude

 

(I did this before Carl's and Markiyan's answers, so I might as well post it)

How about this:

restart;
with(geom3d):
with(plots):
TruncatedIcosahedron(football,point(C,(0,0,0)),1):

PlotFootball:=proc(tr::float)
    
    local i::integer;
    display(seq(polygonplot3d(Matrix(faces(football)[i]),axes=none,scaling=constrained,transparency=tr),i=1..32)):
    
end proc:

PlotFootball(0.00);

The whole loop can be combined in the seq. Note that seq in general will be faster than a do loop.

M. D.

First 8 9 10 11 12 13 14 Last Page 10 of 20