tomleslie

5338 Reputation

15 Badges

9 years, 275 days

MaplePrimes Activity


These are answers submitted by tomleslie

N:=infinity;

ought to work.

I have just tried it - know what, it does work!

The attached shows how to use the scaletorange option in the densityplot() command, to achieve what I suggested earlier. This does not produce an error.

I have never used this option before. I guess the difference between us is that I read the manual to figure out how to do it, and you did/could not

densPlot2.mw

You really should avoid making stupid remarks such as "MATLAB is much stronger". I started using Matlab in 1988, and Maple in 1995, and have been using both (off and on) since those dates. In my working life I have written a lot more Matlab code than Maple code - and no Matlab is not "stronger"

I am prepared to admit that since I have been using both of these programs for so long I am in no position to work out which is easier for a "beginner". However "beginners" are in no position to comment on the relative capabilities of these two programs - so don't.

As a MAple begiiner, I recommend that you type tutorial in the search box for Maple help - then work your way through the 10 basic tutorials which show up

Have you ever tried reading the manual?

As a general rule I would consider it extemely painful to construct a partial solution in Maple/Matlab and then swap to the other for subsequent processing, sso the first two of the following would be my preferred options

  1. (Probably get me lynched on this site but) Matlab has a pretty good solver for pde's - check out pdepe/pdeval. So I would give serious consideration to constructing the whole problem in Matlab
  2. Maple can definitely solve your pde, so when you say "I am trying to manipulate this data but am struggling with it" then maybe somewhere here can help. Bear in mind that Maple can definitely solve your pde, and we/you have access to all the solution data: I feel pretty sure that however you want to manipulate this data, it can be done. We just need to know what your problems are
  3. OK! The option I would not recommend. You *can* use the plotools[getdata]() command to get all relevant data for an individual plot. Note that thsi will include all sorts of guff about axis labels, captions etc, but somewhere within the data structure returned by plottools[getdata]()  will be a matrix of the x-y values which are being plotted.

You can try this third option with the "toy" example

p1:=plot(x^2, 0..10);
plottools[getdata](p1);

where the third entry will be the matrix of values which are to be plotted. In principle, this matrix can be extracted and  exported to matlab. A similar process could be applied to a sequence of plots - as in your animation - so exporting  a sequence of matrices to matlab.

I probably wouldn't be using the pds:-plot or pds:-animate methods, but rather the pds:-value method, which will just generate data directly without going throgh the whole" plot" stage. The admitted drawback of this approach is that this will inevitably result in data being being generated at a fixed number of "range" points which you will have to specify. And will you get the data spacing "suficiently" small to generate "smooth" curves? - probablty only by experiment. The flip side of this issue is that if you use the pds:plot+getdata() approach, then the data spacinig is adaptive: if the curve is changing "rapidly", then more points will be generated. It is therefore highly unlikely that the matrices generated by this approach for a sequence of plots would be the same size. So will export differetn size matrices to matlab - now this can be handled, you just have to be aware of it.

If you decide to go with this third approach, then I have no doubt it can be done - just lots of awkward details whch you will have to deal with.

Given my choice, I'd prefer to go with either (1) or (2) in the above list

Your first question is relatively simple - just use combine().

I was amazed how awkward it was to implement your second question. I thought that there must be some buil-in simplification which would handle this.

I ended up writing a little procedure to do it. This works for all the test cases I have tried, but it is pretty ugly, and it *may* be possible to construct a summand or range definitions for which it will operate incorrectly. I can't help thinking that there must be a better/easier way!

See the attached for details

sumProbs.mw

The answer in your picture is correct, although presented in a rather odd way. Read/execute the attached file for details

cubicSol.mw

The first thing you have to appreciate is that you don't need filler spaces - every formatted print statement in every programming language developed since the year dot allows you to specify a "field width". Given a fieldWidth of (say) 10, then applying it to the integer '1', will print nine leading spaces, followed by the value '1' - so forget "fillers"

The first thing you have to do is examine all of your data to find out the maximum "length" of any integer you have to print, and then set the fieldWidth to this value+1. After that you just need to figure out how much data, eg rows in a matrix or table, entries in a listlist whatever. The following works for data as a listlist, and could be easily modified for any other 2D data representation

  restart;
#
# Set up some toy data to be printed
#
   slf:= [ [  1, 100, 1000, 100000000],
             [ 99, 9999,  9,  9999],
             [ 23456, 12, 237, 9]
           ]:
#
# Based on the number of entries in an
# individual "row" of whatever data is
# supplied, construct an appropriate
# format string, allowing for the maximum
# length which might be required
#
   ff:= cat
          ( seq
            ( cat
              ( "%",
                 max
                 ( map
                   ( length~, slf )
                   )+1,
                  "d"
              ),
              j=1..numelems(slf[1])
           ),
          "\n"
        ):
#
# Now print all the data
#
   seq
   ( printf
      ( ff, slf[j][] ),
      j=1..numelems(slf)
    );

I don't really think that you problem is specific to Maple: if you define a table in, for example, MSWord then you will see the same issues: namely that alignment of "entries" within cells can only be done on a row or column basis, not on an individual cell basis. This becomes problematic when cells are merged - obvious example

If I merge several cells in a column, and then choose to set cell-content alignment across rows, which row determines the alignmennt with the merged cells??? Hint: it will generally be ether the top or bottom of the merged cells, and can depend on how you selected them!! As in "select the bottom cell, swipe up and merge", can result in different behaviour from "select the top cell, swipe down and merge"

On a purely pragmatic basis, I tend to set my row and column alignments to "center". This seems to avoid most issues

So far as I am aware, the print command produces output when it is executed. Consider the simple (if somewhat risky) test case of an infinite loop

for i from 1 by 1 do
     print(i):
end do:

This loop is infinite: so if you believe that the ouput of the print() statement will not be displayed until the loop is finished, you will see nothing.

On the other hand, if you see any output, then it is being produced as it is executed. Before you try this, make sure you find out where the big STOP button on the toolbar is, otherwise you will be sitting there for a very loonnnggggg time!

Attached worksheet shows three ways to do composition of permutations, including the one you have tried, using the deprecated group package. You really shouldn't be using this, so pick one of the first two options

permComp.mw

Perhaps you are making the assumption that the derivative order 'i' is a positive integer. Maple will not make this assumption - after all, you might want some kind of fractional derivative!!!

If you are happy with the assumption that the derivative order is a positive integer, then

restart;
F := Vector( [ p[1]*p[6]*(p[2]-x[1]-x[2])-p[3]*x[1],
                     p[4]*p[6]*(p[2]-x[1]-x[2])-p[5]*x[2]
                   ]
                 ):
timefull := [ x[1] = x[1](t),
                   x[2] = x[2](t)
                ]:
assume(i::posint);
Fdiffi := [ diff (subs(timefull, F[1]), t$i),
               diff( subs(timefull, F[2]), t$i)
           ];

should provide the answer you require. Although since you declare 'F' to be a vector and 'Fdiffi' will be returned as a list, this is a little "untidy". Slightly better might be

restart;
F := Vector( [ p[1]*p[6]*(p[2]-x[1]-x[2])-p[3]*x[1],
                     p[4]*p[6]*(p[2]-x[1]-x[2])-p[5]*x[2]
                  ]
                ):
timefull := [ x[1] = x[1](t),
                   x[2] = x[2](t)
                ]:
assume(i::posint);
Fdiffi:=map( diff, subs(timefull, F), t$i);

where 'Fdiffi' will also be a vector

Once upon a time the limit on the number of columns in an Excel file was 256: anything in the .xls file format was restricted to 256 columns

Somewhere around Excel2007 the number of allowed rows/columns in an Excel spreadsheet was greatly increased - I think it is now 16384 columns (provided you are using .xlx files)

However, for reasons I do not know, Maple still seem to be applying the restriction of 256-column output. Probably a good idea if one assumes "old" Excel installations and a bad idea for more modern ones.

The simplest workaround is to split your matrix in two, with 150 columns in each, then export these to two separate worksheets in the same Excel file. As an example, the following will work for a 300x300 matrix

restart;
XLM:=LinearAlgebra[RandomMatrix] (300,300);
ExcelTools[Export](XLM[1..300, 1..150], "J:/Users/Tomleslie/myMaple/xlTest.xls", "A"):
ExcelTools[Export](XLM[1..300, 151..300], "J:/Users/Tomleslie/myMaple/xlTest.xls", "B"):

Obviously you will have to change the file path/name to something appropriate for your system. However the result will be an Excel workbook with two worksheets 'A' and 'B'. If you really want these in a single workhseet, then you can perform a simply cut/paste operation within Excel (assuming you Excel is post 2007-ish!)

In the absence of a return statement, procedures will return the output of the last evaluated statement - so in your exaample, you will get the value of solve05(ll):

On the other hand if you use an explict return statement, as in

LTTS:=proc(ff)
           local ll,r,r1,r2,r3;
           ll:=rhs(ff)-lhs(ff);
           return solve01(ll),
                     solve02(ll),
                     solve03(ll),
                     solve04(ll),
                     solve05(ll):
          end:

this will return the values solve01(ll), solve02(ll), solve03(ll), solve04(ll), solve05(ll), as a sequence

Try reading the help page for proc() which states quite clearly

The value of a procedure invocation is the value of the last statement executed, or the value specified in a return statement.

According to the manual

The packages() calling sequence returns a list of the packages bound using the with command. The packages are listed in the order that they were bound.

You need to tell maple that the function q1(t) has units of Coulombs, and similarly diff(q1(t), t) has units of coulombs/sec (or amperes if you prefer). The following executes

restart:
R := 500*Unit(ohm);
C := .5*Unit(microfarad);
V := 20*Unit(volt);
ode := R*diff(q1(t), t)*Unit(coulomb)/Unit(second)+q1(t)*Unit(coulomb)/C = V;
dsolve(ode);

but the result for q1(t) is displayed without units :-(

I've tried a few variations of the above, same outcome

First 102 103 104 105 106 107 108 Last Page 104 of 118