Robert Israel

6577 Reputation

21 Badges

18 years, 213 days
University of British Columbia
Associate Professor Emeritus
North York, Ontario, Canada

MaplePrimes Activity


These are replies submitted by Robert Israel

Assuming you just want unordered pairs, you might try something like

> select(curry(`=`,1) @ igcd @ op, combinat[choose]({$100..110},2));

(though for larger examples this will probably be slower than using a nested seq)

Assuming you just want unordered pairs, you might try something like

> select(curry(`=`,1) @ igcd @ op, combinat[choose]({$100..110},2));

(though for larger examples this will probably be slower than using a nested seq)

It's a hit-or-miss thing.  Sometimes it works, sometimes not.  This one seems OK though.

 

Sum((-1)^n/n,n=1..infinity)

Ah, I see the problem.  The Standard GUI uses a different procedure for semilogplot, which (in Maple 11) does not give you good points on a logarithmic scale.  Try

> `plots/semilogplot`(sin(ln(x)), x = 0.1e-7 .. 10);

 

Ah, I see the problem.  The Standard GUI uses a different procedure for semilogplot, which (in Maple 11) does not give you good points on a logarithmic scale.  Try

> `plots/semilogplot`(sin(ln(x)), x = 0.1e-7 .. 10);

 

I'm puzzled.  That kind of behaviour occurred up to Maple 9.5, but I don't think it should occur in Maple 11.   The plot below was created in Maple 11 by the following command:

>  plots[semilogplot](sin(ln(x)),x=0.1e-7 .. 10);

Exactly what commands did you use?

I'm puzzled.  That kind of behaviour occurred up to Maple 9.5, but I don't think it should occur in Maple 11.   The plot below was created in Maple 11 by the following command:

>  plots[semilogplot](sin(ln(x)),x=0.1e-7 .. 10);

Exactly what commands did you use?

For example,

?Worksheet,Comparator

?Worksheet,FromString

Several of the pages mention "mw" as one of the output formats. 

For example,

?Worksheet,Comparator

?Worksheet,FromString

Several of the pages mention "mw" as one of the output formats. 

Suppose you want to choose k numbers from 1 to n with step size <= m (i.e. at most m-1 unpicked numbers adjacent).  Let f(n,k,m) be the number of ways of doing this.  By looking at cases of what is the first number, we get the recurrence

f(n,k,m) = sum( f(n-j, k-1, m), j = 1 .. min(m,n))

with f(n,0,m) = 0 if n >= m, 1 if n <= m.  The generating function g(z,k,m) = sum( f(n,k,m) * z^n, n = 0 .. infinity)  is

g(z,k,m) = (z^k*(z^m-1)^(k+1)/(z-1)^(k+1)

but I think it may be simpler to program f recursively (and fairly quick too, if option remember is used).

Now to make a random choice: the first element chosen should be j with probability f(n-j, k-1, m)/f(n,k,m), and then choose the rest recursively.  Thus:
 

f:= proc(n,k,m) option remember; 
  if k = 0 then 
     if n >= m then 0
     else 1
     end if
  else
    add(f(n-j, k-1, m), j = 1 .. min(m,n))
  end if
  end proc
choice1:= proc(n,k,m,a)
    local x, T, v,j;
    if k = 0 then return NULL end if;
    T:= f(n,k,m);
    x:= rand(1..T)();
    for j from 1 while f(n-j,k-1,m) < x do
      x:= x - f(n-j,k-1,m);
    end do;
    j+a, choice1(n-j, k-1, m, a+j)
  end proc;
 
 choice:= (n,k,m) -> [choice1(n,k,m,0)];

Thus, to choose 20 numbers from 1 to 50 with step size <= 4:

> choice(50, 20, 4);

[3, 5, 7, 8, 9, 11, 13, 15, 18, 21, 23, 26, 29, 31, 35, 36, 39, 41, 44, 48]

 

 

 

Suppose you want to choose k numbers from 1 to n with step size <= m (i.e. at most m-1 unpicked numbers adjacent).  Let f(n,k,m) be the number of ways of doing this.  By looking at cases of what is the first number, we get the recurrence

f(n,k,m) = sum( f(n-j, k-1, m), j = 1 .. min(m,n))

with f(n,0,m) = 0 if n >= m, 1 if n <= m.  The generating function g(z,k,m) = sum( f(n,k,m) * z^n, n = 0 .. infinity)  is

g(z,k,m) = (z^k*(z^m-1)^(k+1)/(z-1)^(k+1)

but I think it may be simpler to program f recursively (and fairly quick too, if option remember is used).

Now to make a random choice: the first element chosen should be j with probability f(n-j, k-1, m)/f(n,k,m), and then choose the rest recursively.  Thus:
 

f:= proc(n,k,m) option remember; 
  if k = 0 then 
     if n >= m then 0
     else 1
     end if
  else
    add(f(n-j, k-1, m), j = 1 .. min(m,n))
  end if
  end proc
choice1:= proc(n,k,m,a)
    local x, T, v,j;
    if k = 0 then return NULL end if;
    T:= f(n,k,m);
    x:= rand(1..T)();
    for j from 1 while f(n-j,k-1,m) < x do
      x:= x - f(n-j,k-1,m);
    end do;
    j+a, choice1(n-j, k-1, m, a+j)
  end proc;
 
 choice:= (n,k,m) -> [choice1(n,k,m,0)];

Thus, to choose 20 numbers from 1 to 50 with step size <= 4:

> choice(50, 20, 4);

[3, 5, 7, 8, 9, 11, 13, 15, 18, 21, 23, 26, 29, 31, 35, 36, 39, 41, 44, 48]

 

 

 

I'm pretty sure the Worksheet package does deal with .mw files: many of the examples in the help pages deal with these. 

 

I'm pretty sure the Worksheet package does deal with .mw files: many of the examples in the help pages deal with these. 

 

To get this to work you need to have Typesetting Level set to Extended.  Either do this from Tools, Options, Display or by the command

> interface(typesetting=extended);

This applies to most of the Typesetting package, and only in Standard GUI.

To get this to work you need to have Typesetting Level set to Extended.  Either do this from Tools, Options, Display or by the command

> interface(typesetting=extended);

This applies to most of the Typesetting package, and only in Standard GUI.

First 80 81 82 83 84 85 86 Last Page 82 of 187