MaplePrimes Posts

MaplePrimes Posts are for sharing your experiences, techniques and opinions about Maple, MapleSim and related products, as well as general interests in math and computing.

Latest Post
  • Latest Posts Feed
  • If I evaluate :

    assume(0 <= a); full := integrate((sin(t)-t*cos(t))^2*cos(a*t)/t^5, t = 0 .. infinity)

    I seem to be getting the wrong result. Not only does the expression look strange (imaginary parts for a real integrand), but it seems also to give wrong results e.g.:

    This is one sort of Maple inconsistency that interests me. Why should the first example behave like evalf(Int(...)) and call `evalf/int` while the second example does not?

    I was looking at the timelimit command in Maple, and wonder about whether it might be improved .

    The help-page ?timelimit says that it suspends its checks while within builtin functions. It says that, inside builtins, the time limit is "ignored".

    But Maple has a lot of builtins. And significant portions of the work may go on within them. Does this make the timelimit() function not useful, from a practical point of view?

    What if timelimit were to make checks whenever garbage collection (gc) ocurred? That's a safe point, no? And gc can happen within some builtins? Or what if time checks were made at the same frequency that interrupt requests were checked? Those can happen within some builtins, at safe points.

    Those were my thoughts, until I tried it. The command anames(builtin) shows that rtable() is a builtin. But I have found that timelimit will function within at least some rtable() calls.

    I was reminded of this by another thread.

    It is faster to add in-place a large size storage=sparse float[8] Matrix into a new empty storage=rectangular float[8] Matrix than it is to convert it that way using the Matrix() or rtable() constructors.

    Here's an example. First I'll do it with in-place Matrix addition. And then after that with a call to Matrix(). I measure the time to execute as well as the increase in bytes-allocated and bytes-used.

    > with(LinearAlgebra):
    
    > N := 500:
    > A := RandomMatrix(N,'density'=0.1,
    >                   'outputoptions'=['storage'='sparse',
    >                                    'datatype'=float[8]]):
    
    > st,ba,bu := time(),kernelopts(bytesalloc),kernelopts(bytesused):
    
    > B := Matrix(N,'datatype'=float[8]):
    > MatrixAdd(B,A,'inplace'=true):
    
    > time()-st,kernelopts(bytesalloc)-ba,kernelopts(bytesused)-bu;
                                0.022, 2489912, 357907
    

    I reciently upgraded to maple 12, and am hoping it was not a mistake...  The "problem" is that now xmaple seems to have no clue as to the rules of precedence.  Before the upgrade (I was using 9.5) the expression 5/7*3 evaluated to 15/7 as it should.  Now, xmaple 12 thinks the answer is 5/21.

    Is there some sort of download to fix this, or perhaps some "please evaluate using standard rules of precedence" setting I can use so that xmaple 12 is able to do arithmetic at least as well as the old 9.5 version?

     

     

    Consider the following simple procedure

    >F:=proc(LL::{set(list(integer)), list(list(integer))})
        LL;
     end proc:

     

    Now execute this little loop

    In a recent post, a Maple user misunderstood what an assignment to f(x) meant. Since this is a common source of confusion, I thought it would be worthwhile to say more about this subject.

    What is f(x)?
    First, f(x) is a "function application" in Maple. It is f applied to the argument x. It is not really the same as what one thinks of as a function in mathematics. Consider a mathematical function such as sin(x+y). In Maple, this can be represented by an expression sin(x+y) or a procedure proc(x, y) sin(x+y) end proc (which can also be written in "operator form" as (x, y)->sin(x+y)). The expression or the procedure can then be assigned to a name such as g. The mathematical function is then represented by g in Maple, and not by g(x, y). Instead, if g is a procedure, then g(x, y) means "the procedure g called with arguments x and y". The "function" help page explains these concepts in more detail.

    What is f(x):=x^2 in 1-d math?
    Now let's move on to what f(x) := x^2 means. In 1-d math, this means, "Create a remember table entry for procedure f." This stores the expression x^2 so that when you enter f(x), that expression is automatically retrieved, and you avoid the expense of executing the body of the procedure . Similarly, if you enter f(1) := 5, then the value 5 is automatically returned when you enter f(1). Note that if you subsequently enter f(y), you won't get y^2 returned, unless f was already defined to return y^2 with input y. Remember tables are very useful and are heavily used by some Maple library procedures. However, the majority of Maple users do not need to worry about this feature and can do very useful things in Maple without ever knowing about it.

    Maple is missing the 'standard' notation for the cumulative normal distribution and uses the error function instead (for historical reasons I guess).

    However that would be quite convenient to read and formulae in a common notation.

    But note the mouse-over caption! See www.xkcd.com for todays (June 11, 2008) strip. This will be printed and posted at the door that seperates the Physics Dept. from the Math Dept. at most institutions.

    Tim

    Hello Everyone,

    This is more of a request for clarification than an actual problem:

    I have written a procedure that involves multiplication, inversion (using LinearSolve) and eigenvalues/vectors (using Eigenvectors) calculations. The matrices are large (~3600 x 3600), consist of floating point complex numbers, and on occasion I need to hold several in memory at once. Therefore, I want to make sure that all of the calculations (and storage of resulting matrices) are done using double precision, not arbitrary precision, in order to minimise the memory usage.

    A recent post asks how to create a Maple permutation iterator, that is, a procedure that, on successive calls, iterates through each permutation of a given input.  I suggested a routine that solved the problem, however, I wasn't satisfied with it.  It was slower than it should be.  Later I suggested an improvement.  Here is another improvement.  It uses the same algorithm (algorithm L, from The Art of Computer Programming, vol. 4, fasicle 2, by Donald E. Knuth) if the input has repeated elements, but uses a different method, algorithm T, ibid., if the input consists of distinct elements.  The sequences of permutations for the two algorithms differ, the second algorithm uses the initial order for the first element and consecutive outputs differ by one transposition.

    A random sample of length n drawn from Bernoulli distribution with probability of success prob, that has a correlation c with itself shifted back lag steps, can be generated using following procedure,

    SampleWithCorr:=proc(prob::And(numeric,satisfies(c->c>=0 and c<=1)),
    lag::posint,c::And(numeric,satisfies(c->c<=1 and c>=-1)),n::posint)
    local X,B,S,C,s,i;
    uses Statistics;
    X:=RandomVariable(Bernoulli(prob));
    S:=Sample(X,n);
    if n<=lag or s=0 then S else
    s:=signum(c);
    B:=RandomVariable(Bernoulli(abs(c)));
    C:=Sample(B,n-lag);
    if s=1 then 
    for i from lag+1 to n do
    if C[i-lag]=1 then S[i]:=S[i-lag] fi od;
    else for i from lag+1 to n do
    if C[i-lag]=1 then S[i]:=1-S[i-lag] fi od
    fi fi; S end:
    
    A:=Matrix(2,3,1,datatype=float[8]);
                                 [1.    1.    1.]
                            A := [              ]
                                 [1.    1.    1.]
    
    ArrayTools:-AddAlongDimension(A);
    
                                   [2., 2.]
    
    B:=Matrix(3,10,1,datatype=float[8]);
    
                 [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.]
                 [                                               ]
            B := [1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1.]
                 [                                               ]
    

    let the elements of each of the following sets

    1. A or B

    2. ( B or C)'

    3. ( D - C)'

    4 (A' or B' ) - ( A or B)

    5. ( C and D)' or B

    6. P (A)

     

    First 197 198 199 200 201 202 203 Last Page 199 of 308