acer

33188 Reputation

29 Badges

20 years, 207 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Mac Dude I think that it would be simple to just use the read command (on a file with actual Maple statements rather than strings, and skip parse altogether).

If script.mpl contains the plaintext statements,

read "dat.mpl";
a,b,c;

and if plaintext file dat.mpl contains the line,

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

then executing the command line maple on script.mpl goes like,

$ maple18 -F script.mpl
    |\^/|     Maple 18 (X86 64 LINUX)
._|\|   |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2014
 \  MAPLE  /  All rights reserved. Maple is a trademark of
 <____ ____>  Waterloo Maple Inc.
      |       Type ? for help.
> read "dat.mpl";
                              a, b, c := 1, 2, 3

> a,b,c;
                                    1, 2, 3

A good place to start would be to understand the instructor's original code, by studying what it does.

See if you can add a sensible comment (in Maple, using a line starting with a # symbol) for each line of the code. (There aren't very many lines of code.)

The idea is that someone unfamiliar with the method should be able to understand the method and the code, by reading your comments.

But by having to write such comments, you end up understanding what it does. At that point, understanding the modification task will be much easier.

If you hope for people here to help modify the code then you're likely going to have to provide it in a form other than an image (or image within pdf). Few people will want to type it out themselves.

The image shows 2D Math. I suggest you work with 1D Maple Notation and a Worksheet for this, not 2D Math input mode and a Document. This is a programming assignment, after all. (Search Maple's help, or this site, for instructions on switching those two preferences.)

acer

Are you trying to open the worksheet off of the MapleCloud, from within Maple? If so then do you usually login to the MapleCloud using a Google ID?

Or are you pointing your browser at a URL which is supposed to link to a worksheet (off a course website, say)?

acer

restart:
ee := abs(exp(2*Pi*I*x)+exp(2*Pi*I*y)):     

int( combine(evalc(ee)), [x=0..1, y=0..1] );

                                      4
                                     ----
                                      Pi

acer

Have you tried with fsolve's `avoid` option?

Is, build up a set of the solutions generated so far. Then call fsilve on the total range of interest. If a new solution is returned then augment the set. Repeat, until it fails to find another distinct root.

That is what Student:-Calculus1:-Roots command does, so you could just try using that.

For such problems with just one varying "parameter" there are other techniques. Searching this site should reveal links to convenient front-end to using Rootfinding:-Nextzero to sweep a range for all roots. Rootfinding:-Analytic has also been used.

acer

@Aakanksha The code I posted runs as expected in the Standard GUI of my Maple 9.50. Does it not run for you? (The plots take about 20 seconds or so.)

Here is the second plot, in which the real component is red and the imaginary component is blue. This was done at default working precision, and I get pretty much the same at Digits=300.

@Aakanksha It does not seem that your `capacity` is purely real-valued for the range L=1..4. That kind of thing will prevent `plot` from being able to produce a single curve for your expression, as is.

If the code below I delayed assignment of the various parameters with floats, and kept the upper index of the summation as `NN` an unknown name so that it could do symbolic summation. (The results seem to concur with those obtained using numeric upper index 100, with `add` or `sum`.) This made `capacity` faster to plot, and more compact.

The code produces a red curve for the real part, and a blue curve for the imaginary part of `capacity`.

Do you have some reason -- physical grounds of the problem, say -- to think that `capacity` should be real-valued with L=1..4 ?

The float values given to `k` and `L` get into the various exponents in your expression, so I suppose then that you really do want principal roots and not real-valued surds.

restart:

N1:=sum(((yo^((b-a+2*p-1)/2)*z^((b-a+2*p-1)/2)*GAMMA((1-(b-a+2*p))/2))
        /(p!*GAMMA(p-a+1)*GAMMA(1+((1-(b-a+2*p))/2)))),p=0..NN):
N2:=sum(((yo^((b+a+2*p-1)/2)*z^((b+a+2*p-1)/2)*GAMMA((1-(b+a+2*p))/2))
        /(p!*GAMMA(p+a+1)*GAMMA(1+((1-(b+a+2*p))/2)))),p=0..NN):
N1:=eval(N1,NN=100):
N2:=eval(N2,NN=100):

x:=(Pi*csc(a*Pi))/(GAMMA(m*L)*GAMMA(k)):

c:=x*(N1-N2):

cc:=log[2](1+1/c):

me:=MeijerG([[],[1-((b+1)/2)]],[[-(b+1)/2,a/2,-a/2],[]],(z*yo)):

m1:=((z*yo)^((b+1)/2))/(GAMMA(m*L)*GAMMA(k)):
m:=2; k:=24.503; a:=k-m*L; b:=k+m*L-1;
z:=(k*m)/10^(0.1*15):

yo:=10^(0.1*10):

pp:=m1*me:

capacity:=cc*pp;

plot([Re,Im](capacity),L=-4..4, color=[red,blue],
     adaptive=false, numpoints=200);

plot([Re,Im](capacity),L=0..4, color=[red,blue],
     adaptive=false, numpoints=200);

Digits:=200:
plot([Re,Im](capacity),L=0..4, color=[red,blue],
      adaptive=false, numpoints=40);
Digits:=10:

By the way, do you have an old version of Maple? If so, which one is it?

@casperyc You may wish to recompute the rank using a (weakest, fastest) Normalizer that can correctly determine that all pivot choices were not hidden zeroes. Note that we could find other examples for which `simplify` is not strong enough (either as Normalizer or as check on the Determinant).

Also note that for some other examples you may get a division-by-zero error while simplifying the determinant computed (as you did it) via the RREF. Trouble starts in pivot selection, and in the most severe case your check might produce just an error message.

And all the above is only trying to deal with identifying pivots that simplify identically to zero. This topic can become far more complicated if you also wish to account for sets of values of the indeterminate names which make the rank even smaller (because they make all pivot choices zero for some given row's pivot determinantion step). Technically, your rank=8 answer is true only under a set of caveats (on the indeterminates) that none of the pivots used become zero.

@Stephan That is worth remembering. Thanks for sharing. To summarize with a smaller example,

restart:

P := piecewise( x<=t, 1/a, x>t, (1+b)/a ):

#simplify( P*a ); simplify( P*a, piecewise );
#expand( P*a ); combine( P*a );

convert( P*a, piecewise, x );
                             /   1        x <= t
                            {                   
                             \ 1 + b      t < x 

@oldstudent There are several ways to ensure that the origin is included in the view.

For example, given your DataTable3,

plots:-display(plot([[0,0]]), plots:-pointplot( DataTable3 ));

minx,maxx:=(min,max)(DataTable3[..,1]):
plots:-pointplot( DataTable3, view=[min(-0.1,miny)..maxx, default] ); 

@oldstudent Do you want,

plots:-pointplot( DataTable3 );

That routine accepts an m-by-2 Matrix, and interprets the two columns as x and y values.

 

@jonlg 

  • The help-page for topic rtable_indexing may be of use, if you haven't seen it yet. It ought to be linked from more pages than it is, IMO.

    (If I used round brackets to index into R, it was probably by omission, as I was editing your own second attachment. I try not to use round-bracket "programmer indexing" unless I need to, so that I'll know there was a reason for it when I return to the worksheet after a long time.)

  • If you haven't read it yet, the Programming Manual is worth a read. (Download from here.)

@fereydoon_shekofte bytesused is not right, since it can report the bytes processed by garbage collection that may have nothing to do with the storage of the expression just assigned to a name. It is not a representation of the memory used to store anything in particular. The "used" in "bytesused" does not refer to memory that is storing a thing.

Up until recently the difference in kernelopts(bytesalloc) was a somewhat OK measure. But it can be way off, in modern versions, as garbage collection can now release memory to the OS. It was never perfect for this, either.

Part of the difficulty is that the operation to construct a thing can involve memory for temporary objects that are no longer present upon completion of the construction. It seems to me that you don't want that counted, is that right? You want only the bytes used to store a thing internally?

If you want a measure that is somewhat near proportional to the memory needed only to store a value then perhaps you could look at its `length`, or the `length` of it sprintf'd to %m format (so-called dotm). Those are not always in bytes, but they might be reasonably close to proportional. It could be tricky to handle modules.

As best I can guess at present, you might be wanting to do something like this...

MapleSimulation_test_a0.mw

@jonlg You've used `A` in two different ways. Let's keep the line that assigns to `A` the uninitialized 4-dimensional Array.

Let's focus on the first loop. You don't want to assign that operator (taking 4 parameters n,b,theta,m) to the name `A` as that will just clobber the earlier Array assignment. Let's assign that operator to the name `Afunc` instead, for now.

You may not need Afunc to be defined inside the loop. It'll depend on how this all gets unmuddled.

You can use square-bracket indexing for R, on the left hand side of that assignment in that first loop. It's makes things more clear (IMO) if you only use round-brackets for indexing when it is necessary. It's less confusing when you read this years later. I'll use you round-bracketing style below, even though I'm pretty such it mostly?! means indexing.

Now, a key thing: In your assignment to R(n+1) you have the term A(n). What is does that mean? As you had it as an operator `A` takes 4 parameters. I suspect that your A(n) here is intended as a function call to your operator `A`. But if so then what are the 2nd, 3rd, and 4th parameters (ie. b, theta, and m) supposed to be for that term A(n) in that assignment to R(n+1)?

Are you trying to set it up so that for each and every any fixed set of values of b, theta, and m the sequence of R values and A values should be computed using those formulae?

First 362 363 364 365 366 367 368 Last Page 364 of 607