Joe Riel

9048 Reputation

23 Badges

16 years, 345 days

MaplePrimes Activity


These are answers submitted by Joe Riel

The third and fourth arguments to BinarySearch are optional.  If you do supply them, they must correspond to strict less than and equals, respectively.  These would only be supplied if needed, for example, if the elements in the list required a special test. In your case, because the elements are numeric, just use the defaults:

L := [2,3,4,5]:
ListTools:-BinarySearch(L,3); # --> 2

It returns the position (index from 1) of the element in the list. That is, op(2,L) = 3.

For labels you can use html.  For example, change the caption to

<html>&alpha;</html>

About the simplest solution is

rangetolist := rng-> [seq(rng)]:

Adding a type declaration to the formal argument

rangetolist := (rng::range) -> [seq(rng)]:

A somewhat more restrictive type declaration

rangetolist := (rng::(integer..integer)) -> [seq(rng)]:

To handle a range that may decrease

rangetolist := (rng::(integer..integer)) -> [seq(rng,-sign(`-`(op(rng))))]:

Haven't actually tested these...

Another approach

subsindets(A, specfunc(v), f -> subs(t=tau,f));

For fans of minimalism,

subsindets(A, specfunc(v), eval, t=tau);

An alternative, to avoid using an indexed name, is the following (entered as 1D Maple input):

`f__&alpha;,&beta;`;

Because typing such variables is time-consuming, I'd consider defining macros or aliases for them. For example

macro(fab = `f__&alpha;,&beta;`):
fab/(1 + fab);
         fα,β/(1 + fα,β)

@Alger A call to evalc will simplify the results assuming any unknown variables are real.

simplify(evalc(Re(Z)));
     (w^2*Rs*(Lm + lpr)^2*g^2 + w^2*Lm^2*Rpr*g + Rpr^2*Rs)/(Rpr^2 + w^2*(Lm + lpr)^2*g^2)

The assignment statement to M1 has no semicolon at the end. Also, the assignment to result__1DP has some weird issue.  To resolve it, select the entire worksheet, convert to 1D Math input (right-click, select Convert To --> 1D Math Input) and manually fix the weird solve (you'll see it). 

Am not sure exactly what you want.  I'm not familar with that package, and after downloading it, am surprised it doesn't provide a way to list the available profiles.  Regardless, with a proper debugger it isn't hard to figure it out.  Here's how you can get a list of the profiles.

kernelopts('opaquemodulues'=false): # allows accessing local members of module
tmp := [indices]( AISCShapes:-AISCTable,'nolist'): # get the indices to the data table
lprint~(sort(tmp)): # sort and print them (just for checking).

You could assign this list to a combobox or listbox, however, given its length I think there may be better options.

What does FileTools:-IsReadable(...) return for the path?  If you pass a directory name (a mistake, regardless) to ImageTools:-Read for which you don't have read permission, it will somewhat confusingly respond with the error message you are reporting.  That should be fixed.

Variables declared in a procedure can be given a type. An error will be raised if the variable is then assigned a value that doesn't match the type, provided kernelopts(assertlevel=2) has been set.  For example

kernelopts('assertlevel'=2):
proc() local k :: integer;
   k := 1/2;
end proc();
Error, (in anonymous procedure) assertion failed in assignment, expected integer, got 1/2
data := ExcelTools:-Import("rr.xlsx");

That assigns data to be a 1049x2 Matrix.

xls := "New_Microsoft_Excel_Worksheet.xlsx":
data := ExcelTools:-Import(xls):
y := x^n/(1+m*x^n):
Statistics:-Fit(y, data, x, 'output = parametervalues');
       [m = 2.10000000004366, n = 2.49999999966826]

1. The parenthese in the final statement are mismatched;
2. The equal sign in the preceding statement should be an assignment operator;
3. The multiplication sign after m in the final statement is missing.

I think this is what you want

if P2 = -Q2 then
    return Expand( x-P1 ) mod p;
else 
    m := Expand( (3*P1^2+a)/(2*P2) );
    return Expand( (y-P2 -m*(x-P1) ) / (x+P1+Q1-m^2  ));
end if;

There is no statement separator (: or ;) after the local y statement.

For the second problem, assign to h, not h(x). 

While you could use a piecewise, a regular conditional seems better. What you planning to do with the sum (which is syntactically incorrect)? Better here would be to use an add. I'll assume you want to assign it to something, say s[k]:

for k from 0 to 10 do
   z[k] := ifelse(k=0, 1, 0);
   s[k] := add((m^2-1)/z/(z[k]+1), m=0..k);  # this makes no sense
end do:

Note my comment; it doesn't make much sense to use both z and z[k] in an expression, though it is valid in Maple because z, following the assignment to z[k], is now a table, which will evaluate to a name (z). Unless you need to use z[k] later, I'd probably do something like

for k from 0 to 10 do
   zk := ifelse(k=0, 1, 0);
   s[k] := add((m^2-1)/z/(zk+1), m=0..k);
end do:

That avoids any weirdness with using a name (z) that evaluates to a table. However, it isn't clear whether you actually meant to use the unassigned name, z, in the expression. Maybe the addendum should be (m^2-1)/zk/(zk+1).

First 8 9 10 11 12 13 14 Last Page 10 of 110