Joe Riel

9660 Reputation

23 Badges

20 years, 6 days

MaplePrimes Activity


These are answers submitted by Joe Riel

You might be able to do

map(op@indets, vec[1], numeric);

however, that fails with `@`(1, {1}) because indets returns a set, so duplicates are removed.

A good solution may require more knowledge of structure of the input.   If all elements have the form `@`(integer, {float1,float2,...}) then you could simply do
 

[seq('op(1,e),op([2,..],e)', e in vec[1])];

A simpler method is to select the lines of code and then click the Format drop-down box and pick the Formatted tag.

Use the print function.  That puts the plot into the print stream, which actually does the plotting. Thus,

makeplot:= proc(p)
    plotsetup('ps'
              , 'plotoutput'=`p.eps`
              , 'plotoptions'=`portrait,noborder`
             );
    try
        print(plots:-display(p));
    finally
        plotsetup('default');
    end try;
end proc:

The try/finally statement ensures that plotsetup('default') is called even if an error occurs when plotting.

If the Matrices are square than you should consider using the inplace option (see LinearAlgebra,MatrixMultiply).

For nonsquare, numeric matrices the order in which they are multiplied [associated] can substantially affect the speed of the operation.  Precomputing the optimal grouping is then worthwhile.  I don't know whether Maple provides a procedure for doing so.

Change nprintf to sprintf.  That will return a string rather than a name.

The error you made is not inserting a catenation operator on both sides of the i.
Note that cat is preferred over ||.  You could also use nprintf:

for i to 20 do
    part := nprintf("cord@fan%d@part.part", i);
    GetDimensionValue(doc, part);
end do:

 

Are you using the old [deprecated] networks package or the new GraphTheory package? 

Robert's solution is nice.  Alternatively you could substitute values for E and S:

 max(subs([S=-infinity,E=-infinity],MM));

Substituting NULL would also work.

Note that your example reveals a minor Maple bug.

 max(MM);
Error, (in simpl/max) arguments must be of type algebraic

It should return

 max(S,E,2)

Curiously I ran into that a few weeks ago, but didn't get around to submitting an SCR. Will do so.

You probably don't want to assign directly to elements of a list; that is limited to lists with less than 100 elements.  You could, instead, use subsops.  For example:

b := [[2, 3], 1, 2, 3, 4, 5]:

replace := proc(b)
local c;
    c := b[2..-1];
    c := ListTools:-MakeUnique(subsop(b[1,1]=b[1,2],c));
    subsop(b[1,1]=1+max(subsop(b[1,1]=b[1,2],c)), c);
end proc:

replace(b);
                                 [1, 6, 4, 5]

Do elements 2..-1 of the original list have any structure that you can take advantage of? For example, are they sorted?  Unique?

I only looked at your original post.  There are some syntax errors, specifically, using square brackets for the int. Also the call to Split only works on a pure integral, so you want to remove the 2/Pi factors (and use Int, the inert form of the integral). 

I see Robert Israel already mentioned those problems. 

You might use a Matrix. For example
 

y := x^2: 
f := unapply(y,x):
M := Matrix([seq([x,f(x)], x = 0..0.75, 0.01)]):

The description of the first problem is not specific.  Here are a few examples you might consider:

L0 := [];
L1 := [a];  # return a, or raise an error?
L2 := [1,a]: # does that return 1? Or raise an error?
L3 := [1,Pi]: # does that raise an error? Return Pi? Or return a numerical approximation of Pi (3.14159)?

You might want to pass these lists to Maple's max command to see what it does.

Note that one would normally not want to return 'ERROR'.  Rather, the more usual operation is to raise an error by calling the Maple error command, which generates an error message and halts the evaluation.

The 'clever' student might cheat and do the following

MY_MAX := proc(L)
local mx;
    mx := max(op(L)); # op isn't necessary for Maple 12+
    if not mx::'realcons' then
         error "could not compute maximum";
    end if;
    return mx;
end proc:

Try

koords := readdata("data_koordinate.txt", 3);

What sort of content are you attempting to import?  Could you give a small example?

Note that x=1..6 does not uniquely specify a portion of the curve. With that in mind, you could do

with(Student[VectorCalculus]):
curve := <y^2+y, y>:
sol1 := solve(curve[1]=1, y);
sol6 := solve(curve[1]=6, y);

plot([curve[1],curve[2], y=sol1[2]..sol6[1]]);

ArcLength( curve, y=sol1[2]..sol6[1] );

First 83 84 85 86 87 88 89 Last Page 85 of 114