Joe Riel

9660 Reputation

23 Badges

20 years, 3 days

MaplePrimes Activity


These are answers submitted by Joe Riel

Your function is too wide for the screen. Try evalf[20](ratio); (the 20 is the number of digits used in the numerical computation).
It's not clear what function is given. Does that equation explicitly define the function y -> x(y) or does it implicitly define a function x -> y(x)? Are you restricted to reals? If complex, then you should try experimenting with the Maple plots[conformal] command. For example,
plots[conformal](exp, map(`*`, -1..1, 9/10*Pi*(1+I)));
You can use ListTools[Categorize] to partition the list of lists, the interesting part is comparing two sublists. The simplest way I could think of is to sort them and then compare them.
a[1] := [1,0,1,0]:
a[2] := [1,1,0,0]:
a[3] := [0,0,1,1]:
ListTools:-Categorize((x,y) -> sort(x) = sort(y)
                      , [a[1]+a[2], a[2]+a[3], a[3]+a[1]]
                     );
            [[2, 1, 1, 0], [1, 0, 2, 1]], [[1, 1, 1, 1]]
This can be made more efficient by using sorting with attributes, suitably modified.
To look at a value at, say, k=30, do i[30]. To find the maximum value of s, do
  K := 60:
  smax := max(seq(s[k], k=1..K));
To find the k's (there could be more than one) that corresponds to the maximum value of s, you could do
   kwc := [seq(`if`(s[k]=smax, k, NULL), k=1..K];
It would help if you showed some of your code. Or a simple representation of it. Otherwise we have to make a lot of assumptions about what you might have done or intend.

You might find the following plot instructive

restart;
a := proc(n::posint)
option remember;
    4*a(n-1)*(1-a(n-1));
end proc:
a(1) := 0.8:
plt1 := plot([4*x*(1-x),x], x=0..1, color=black):
plt2 := plot([seq([[a(i),a(i+1)],[a(i+1),a(i+1)]][], i=1..300)]):
plots[display]([plt1,plt2]);

Here is the approach I would take. First, assign a procedure that, given n, returns a(n). The computation of a(n) requires a(n-1); to make this fast we use the remember option. Also, to terminate the descent we assign the value of a(1).
a := proc(n::posint)
option remember;
    4*a(n-1)*(1-a(n-1));
end proc:
a(1) := 0.8:
Now we need to plot this. The easiest way is to use the Statistics:-LineChart procedure (yeah, that's kind of a deus ex machina, but it works).
Statistics:-LineChart([seq(a(i),i=1..300)]);
The usual way is to apply the evalf (evaluate-using-floating-point) function. Note, however, that in Maple, the symbol for pi is spelled Pi, with a capital P. There is no corresponding symbol for e, however, in Standard GUI, exp(1) is displayed as e (you can also enter it in 2D mode by typing e followed by Ctrl-Shift-Space and selecting the e (exponential) in the pop-up menu). If you are working in the Standard GUI you can select (highlight with mouse) the expression, right click, and select, say, Approximate -> 5 to get a five digit approximation.
If performance were an issue, then you should do
IR3 := proc(n::posint)
local M,i;
    M := Matrix(n,n);
    for i to n do
        M[i,-i] := -1;
    end do;
    return M;
end proc:
Expanding on Acer's suggestion:
makeVerify := proc(x, ver :: verification)
    if x :: 'set' then
        'set'({map(procname,x,ver)[]});
    elif x :: 'list' then
        map(procname,x,ver);
    else
        ver;
    end if;
end proc:

AreEqual := proc(s1, s2, ver :: verification)
    verify(s1,s2,makeVerify(s1,ver));
end proc:

AreEqual(S1,S2,Or(truefalse,float(5,digits=10,test=2)));

                                            true
This, however, isn't the way to go for large sets/lists. On reflection, I prefer the following method:
VerifyTools:-AddVerification(
    SeqOrFloat = proc(s1,s2, ver :: verification := float(5,digits=Digits,test=2))
        if s1 :: 'sequential' then
            verify(s1,s2, op(0,s1)(SeqOrFloat(ver)));
        elif s1 :: 'numeric' then
            verify(s1,s2, ver)
        else
            verify(s1,s2)
        end if;
    end proc );

verify(S1,S2, SeqOrFloat);
                                     true

verify(S1,S2, SeqOrFloat(float(5,digits=3)));
                                     false

verify(S1,S2, SeqOrFloat(float(5,digits=3,test=2)));
                                     true

verify(S1,S2, SeqOrFloat(float(5,digits=50,test=2)));
                                     false
If you only want the final set of sums, then be sure to use sets, not lists, in the internal computations, that can significantly reduce the combinatorial explosion, particularly if the input has repeated terms. Here is the fasted solution I've found (it returns a set):
f8 := proc(L)
local S,l,i,j;
    S := {L[1][]};
    for l in L[2..-1] do
        S := {seq(seq(i+j,i=S),j=l)}
    end do;
    S;
end proc:
One solution is to export the content of the worksheet as maple input, and then read that into a worksheet. In the worksheet that you want to save do
  File -> Export As
then type "myfile" in the "File Name" box and select "Maple Input (.mpl)" for the file type. If desired you can then inspect (and modify) the saved .mpl file in a text editor. In another Maple worksheet you can issue the command
  read "myfile.mpl";
You may have to specify the full path to myfile.mpl in the read statement.
What are the dimensions of your Matrix? Note that in your loop j is 0,5,10,...,45, so j+1 is 1,6,11,...,46, so your Matrix A, should have at least 46 columns. That is, you might first do A := Matrix(45,46): Without that, A is just an indexed table, not a Matrix.
How about the following (for the second part of the question):
evalindets['flat'](AAA, 'patfunc(string,anything)', curry(applyop, StringTools:-LowerCase, 1));
I used curry just to make you aware of it. You might prefer operator notation.
Probably the most straightforward method is to map the map function onto the sublists. This can be nicely done using map2 and the `/` function (`/`(a) = 1/a, `/`(a,b)=a/b, `/`(a,b,c,d) = a/(b*c*d)):
map2(map, `/`, test);
                       [[1, 1/2, 1/3, 1/4], [1/5, 1/6], [1/7, 1/8, 1/9]]
Another possibility is to use evalindets:
evalindets(test, numeric, `/`);
You might also use Not(list) as the type (second) argument in the call to evalindets.
First 101 102 103 104 105 106 107 Last Page 103 of 114