Robert Israel

6577 Reputation

21 Badges

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

MaplePrimes Activity


These are answers submitted by Robert Israel

The ~ is not a multiplication sign, it is indicating that you have made an assumption on a.  If you don't want to see ~ after variables that have assumptions on them, go (in the Standard interface) to Tools, Options, Display, and change the "Assumed variables:" option from Trailing Tildes to No Annotation, then click Apply to Session (to affect only this Maple session) or Apply Globally (to make this change permanent).

Consider out as a function of b:

> out :=  sum(x^2, x=a..b);
   F:= unapply(out, b);

The summand must be F(x) - F(x-1).

> normal(F(x) - F(x-1));

x^2

And the initial value must be one more than a value of b that would make out = 0.

> solve(out = 0, b);

a-1, -1/2*a-1/4+1/4*(-12*a^2+12*a+1)^(1/2), -1/2*a-1/4-1/4*(-12*a^2+12*a+1)^(1/2)

Actually, by default every variable is assumed to be complex, so there's no need to tell Maple that. What you want is assume.  For example, you can enter

> assume(x, real);

and then x will be considered to be real.  In particular this affects simplification: identities that are true for real x but not for complex x can be used.  However, it doesn't prevent you from assigning a non-real value to x (and in fact when a value is assigned to x, that removes all assumptions that have been made on x).

This can be considered as an Assignment Problem (see e.g. http://en.wikipedia.org/wiki/Assignment_problem).   It can be solved as a linear programming problem using LPSolve in the Optimization package.

This sort of thing can be done using a Maplet.  For example:

> P:= proc() 
    local i,p,pl;
    uses plots, plottools, Maplets[Tools];
    p:= 0:
    Set('PL1'= plot([[0,0],[1,0]],view=[0..1, 0..10^6],axes=box));
    for i from 1 to 10^6 do
      if isprime(i) then
         p:= p+1;
         if (p mod 100 = 0) then
          Set('PL1' = display(rectangle([0,0],[1/3,p]),rectangle([2/3,0],[1,i]),view=[0..1,0..10^6],
             title=sprintf("%d primes up to %d",p,i),axes=box));
         end if
      end if;
    end do;
    Set('PL1' = display(rectangle([0,0],[1/3,p]),rectangle([2/3,0],[1,i]),view=[0..1,0..10^6],
             title=sprintf("%d primes up to %d",p,10^6),axes=box));
end proc;  

with(Maplets[Elements]):
M:= Maplet([[Plotter[PL1](plot([[0, 0], [0, 0]], view = [0 .. 1, 0 .. 10^6],axes=box))],
[Button("Go",Evaluate(function="P")),
Button("Done",Shutdown())]]):
Maplets[Display](M);

YourTable:= table([a=12, th=15, ch = 14, l = 12, k = 4, ck = 22]);
# or however you want to create your table

with(plots):
listplot(convert(YourTable,list));

# or if you want something a bit fancier:

with(plots):
E,V:= map(op,[indices(YourTable)]),map(op,[entries(YourTable)]);
P1:= listplot(V, style=point, symbol=box):
P2:= textplot([seq([i,V[i]-1,E[i]],i=1..nops(E))]);
display(P1,P2,axes=none);

Another way to do it is to draw the triangle twice:

> draw([T1(colour=gray,filled=true),T1(colour=black,thickness=3)],axes=none);

There's never any point in accepting a candidate who isn't the best so far.  When you do have a candidate who is the best so far, the decision to accept or reject can only be based on how many candidates have been seen and remain to be seen - the only other information you have are the relative ranks of the candidates you've already rejected, and these are independent of the rank of the current candidate.  Moreover, it's easy to see that if you would accept the k'th candidate (if that one is the best so far), then you should also accept the (k+1)'th (if that one is the best so far).  So we are left with a strategy of the form: reject all candidates before the k'th, and then accept the next one who is the best so far.  Let A_k be the event that this strategy succeeds.  To find P(A_k), we condition on the position B of the best candidate.  Clearly if B < k the strategy fails.  On the other hand, if B = b >= k the strategy succeeds if and only if the best of the first b-1 candidates is in a position < k.  Thus,

P(A_k | B = b) = 0 if b < k,
                           (k-1)/(b-1) if b >= k

Since P(B=b) = 1/n for b = 1, ..., n, we have

P(A_k) = sum(P(A_k | B = b)*P(B=b), b=1..n) = 1/n * sum((k-1)/(b-1), b=k .. n).

With n = 100, the optimal k is actually 38, while 100*exp(-1) = 36.78794412.   The optimal probability is .3710427790, which is a bit more than exp(-1).  In fact, the results you quote are only using the first term in an asymptotic expansion, and n*exp(-1) is not quite the optimal k for large n: n*exp(-1) + 1 - exp(-1)/2 is more like it. 

> P:= unapply(1/n*sum((k-1)/(b-1),b=k..n), k);

     (k - 1) Psi(n) - (k - 1) Psi(k - 1)
P := k -> -----------------------------------
                     n                 

> map(simplify,asympt(P(n*exp(-1)+t), n, 3));

                                       (-1 + exp(1)) exp(-1)   
exp(-1) ln(n) - exp(-1) (-1 + ln(n)) + --------------------- -
                                                2 n            

    1   //          2                                          
  ----- \\6 exp(2) t  - 12 exp(2) t + 5 exp(2) + 1 + 6 exp(1) t
      2                                                        
  12 n                                                         

             \        \    /1 \
   - 6 exp(1)/ exp(-1)/ + O|--|
                           | 3|
                           \n /

> solve(diff(%,t),t);

                        -2 exp(2) + exp(1)
                      - ------------------
                             2 exp(2)     

combine(expand(%));

                             1        
                         1 - - exp(-1)
                             2        

> map(simplify,asympt(P(n*exp(-1) + 1 - 1/2*exp(-1)),n,3));

                                         (-1 + exp(1)) exp(-1)
  exp(-1) ln(n) - exp(-1) (-1 + ln(n)) + ---------------------
                                                  2 n         

       (1 + 2 exp(2)) exp(-1)    /1 \
     + ---------------------- + O|--|
                   2             | 3|
               24 n              \n /

> map(simplify,asympt(P(n*exp(-1)+1-1/2*exp(-1))-P(n*exp(-1)),n,3));

            (-1 - 4 exp(2) + 4 exp(1)) exp(-1)    /1 \
          - ---------------------------------- + O|--|
                              2                   | 3|
                           8 n                    \n /

> evalf(%);

                      0.9051258449    /1 \
                      ------------ + O|--|
                            2         | 3|
                           n          \n /





There are really 6 equations (one for each = sign).  The other thing is that you need multiplication signs (or spaces if you're using 2D math input, but don't leave out the spaces).

> eqs:= {64*(a-b+c+d+e+f+g)=32*(b-a-c-d-e-f-g),
 64*(a-b+c+d+e+f+g)=16*(7*c- a-b-d-e-f-g),
 64*(a-b+c+d+e+f+g)=8*(15*d-a-b-c-e-f-g),
 64*(a-b+c+d+e+f+g)=4*(31*e-a-b-c-d-f-g),
 64*(a-b+c+d+e+f+g)=2*(63*f-a-b-c-d-e-g),
 64*(a-b+c+d+e+f+g)=127*g-a-b-c-d-e-f};

> solve(eqs);

{a = 33*g, b = 64*g, c = 16*g, d = 8*g, e = 4*g, f = 2*g, g = g}

chrem([565,56],[5656,565]);

      2183781

There are several good methods.  One is:

> plots:-display([plot([x^2,x^3],x=0..1,colour=blue), 
            plottools:-transform((x,y) -> [x,y+x^3])(
plot(x^2 - x^3, x = 0 .. 1, filled = true, colour=cyan))]);

 

What is this line(x)?  You need to define this function.  The other problems are:

1) pi should be Pi

2) sin^2(x) is interpreted as sin^(2(x)).  You want sin(x)^2.

3) Your } should be ].

Your pde is for the Laplace equation in a sector of an annulus (using polar coordinates).  Map this to a rectangle by a conformal transformation: x = ln(r), y = theta.  Then use a Fourier cosine series for f to get a solution of the form

B(x,y) = a[0]/2 + sum(a[m] * cosh(m*Pi/beta*(x - ln(R1))) * cos(m*Pi/beta*(y-theta0)), m = 1 .. infinity)

with(plots):
f:= (x,y) -> x*y^2/(x^2 + y^2 + 1);
contourplot(f(x,y), x=-2..2, y=-2..2, contours=8, filledregions=true, colouring=[blue,red], axes=box);

contourplot3d(f(x,y), x=-2..2, y=-2..2, contours=8, filledregions=true, colouring=[black,"LightGray"], axes=box);

Write the equation as s*sin(z) + z*cos(z) = 0 (corresponding to mu = z/b and s = h*b).  Using the Intermediate Value Theorem, if s > 0 there will be one solution in each interval (n-1/2)*Pi < z < n*Pi for positive integers n.  It's not hard to see that this solution is unique.  Moreover, for n large the solution will be near (n-1/2)*Pi.  So we take z = (n-1/2)*Pi + t.

> f:= s*sin(z) + z*cos(z);
  Q :=expand(eval(f, z = (n-1/2)*Pi + t)/(-1)^n) assuming n::posint;

Q := -s*cos(t)+sin(t)*Pi*n-1/2*sin(t)*Pi+sin(t)*t

> asympt(RootOf(Q,t),n);

Pi*_Z1+s/Pi/n+1/2*(-2*Pi*_Z1+Pi)/Pi^2*s/n^2+1/12*(-12*s-4*s^2+3*Pi^2+12*Pi^2*_Z1^2-12*Pi^2*_Z1)/Pi^3*s/n^3-1/16*s*(-2*Pi^3+12*Pi^3*_Z1-24*Pi^3*_Z1^2-16*Pi*_Z1*s^2-48*s*Pi*_Z1+24*s*Pi+8*Pi*s^2+16*Pi^3*_Z1^3)/Pi^4/n^4-1/240*s*(-480*s^2-48*s^4-320*s^3+480*Pi^2*_Z1^2*s^2+1440*s*Pi^2*_Z1^2+120*Pi^4*_Z1+480*Pi^4*_Z1^3-360*Pi^4*_Z1^2-1440*s*Pi^2*_Z1-480*Pi^2*_Z1*s^2+120*Pi^2*s^2+360*s*Pi^2-240*Pi^4*_Z1^4-15*Pi^4)/Pi^5/n^5+O(1/(n^6))

We must take _Z1 = 0 to get the root that is near 0.

> eval(%, _Z1 = 0);

s/Pi/n+1/2/Pi*s/n^2+1/12*(-12*s-4*s^2+3*Pi^2)/Pi^3*s/n^3+1/8*s/Pi^3*(Pi^2-12*s-4*s^2)/n^4+1/240*s*(480*s^2+48*s^4+320*s^3-120*Pi^2*s^2-360*s*Pi^2+15*Pi^4)/Pi^5/n^5+O(1/(n^6))

First 28 29 30 31 32 33 34 Last Page 30 of 138