Robert Israel

6577 Reputation

21 Badges

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

MaplePrimes Activity


These are replies submitted by Robert Israel

Then you'd better use that.  For example:

> n := 6:
   solve( eval( {seq(x[i-1]+x[i]+x[i+1]=i,i=1..n)}, {x[0]=0, x[n+1]=0}));

{x[1] = -2, x[2] = 3, x[3] = 1, x[4] = -1, x[5] = 4, x[6] = 2}

However, note that there's no solution if n+1 is divisible by 3.

You could try for a symbolic solution.

> rsolve({x(0)=0, x(i-1)+x(i)+x(i+1)=1}, x(i));

(1/3*I)*sqrt(3)*x(1)*(-1/2-(1/2*I)*sqrt(3))^i-(1/3*I)*x(1)*sqrt(3)*(-1/2+(1/2*I)*sqrt(3))^i-(2/3)*(-2/(1-I*sqrt(3)))^i/(1-I*sqrt(3))-(2/3)*(-2/(1+I*sqrt(3)))^i/(1+I*sqrt(3))+1/3

> simplify(evalc(%));

(2/3)*sqrt(3)*x(1)*sin((2/3)*i*Pi)-(1/3)*cos((2/3)*i*Pi)-(1/3)*sin((2/3)*i*Pi)*sqrt(3)+1/3

Note that I didn't use the end condition x(n+1) = 0.  That can be used to determine x(1) (if sin((2/3)*(n+1)*Pi) is not 0).

See the help page ?alloc.

I haven't seen your code, but it's possible that it really does require more memory than is available. 

See the help page ?alloc.

I haven't seen your code, but it's possible that it really does require more memory than is available. 

It seems simple enough to me.  The integral

8342_Untitled (2)_1.gif

is of the form int(V,U) where

8342_Untitled (2)_3.gif

and

8342_Untitled (2)_6.gif

so you can apply the integration by parts formula to it.  By the way, your pdf file doesn't seem to exist.

It seems simple enough to me.  The integral

8342_Untitled (2)_1.gif

is of the form int(V,U) where

8342_Untitled (2)_3.gif

and

8342_Untitled (2)_6.gif

so you can apply the integration by parts formula to it.  By the way, your pdf file doesn't seem to exist.

There are lots of equations due to Euler.  See e.g. en.wikipedia.org/wiki/Euler_equation#Euler.E2.80.94equations 

There are lots of equations due to Euler.  See e.g. en.wikipedia.org/wiki/Euler_equation#Euler.E2.80.94equations 

> allbitstrings:= proc(n)
   local A, fibfill;
   fibfill:= proc(i0,j0)
     local i, i1;
     # put bitstrings of length n-j0+1 in Matrix starting at A[i0,j0]
     if j0>=n+1 then return end if; # nothing to do
     fibfill(i0, j0+1);  # leave 0 in column j0 for first F[n-j0+2] rows
     i1:= i0 + combinat[fibonacci](n - j0 + 2);
    # 1 0 in columns j0 and j0+1 for next F[n-j0+1] rows
     for i from i1 to i1 + combinat[fibonacci](n - j0 + 1) - 1 do
        A[i,j0]:= 1
     end do;
     fibfill(i1, j0 + 2);
   end proc;
   A:= Matrix(combinat[fibonacci](n+2), n);
   fibfill(1,1);
   convert(A,listlist);
 end proc;

> allbitstrings(6);

[[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1], [0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 1], [0, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1], [0, 1, 0, 0, 1, 0], [0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 1, 0], [1, 0, 0, 1, 0, 0], [1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0], [1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0]]

> allbitstrings:= proc(n)
   local A, fibfill;
   fibfill:= proc(i0,j0)
     local i, i1;
     # put bitstrings of length n-j0+1 in Matrix starting at A[i0,j0]
     if j0>=n+1 then return end if; # nothing to do
     fibfill(i0, j0+1);  # leave 0 in column j0 for first F[n-j0+2] rows
     i1:= i0 + combinat[fibonacci](n - j0 + 2);
    # 1 0 in columns j0 and j0+1 for next F[n-j0+1] rows
     for i from i1 to i1 + combinat[fibonacci](n - j0 + 1) - 1 do
        A[i,j0]:= 1
     end do;
     fibfill(i1, j0 + 2);
   end proc;
   A:= Matrix(combinat[fibonacci](n+2), n);
   fibfill(1,1);
   convert(A,listlist);
 end proc;

> allbitstrings(6);

[[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1], [0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 1], [0, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1], [0, 1, 0, 0, 1, 0], [0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 1, 0], [1, 0, 0, 1, 0, 0], [1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0], [1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0]]

For Maple, atan should be arctan, pi should be Pi, and conj should be conjugate.

Your expression is the real part of an expression I'll call Q, which is actually real for ne in some intervals around the two solutions.
But in the complex plane, there will be a curve on which Re(Q) = 0.  So there is no point in calling solve(Re(Q)): even solve(z + conjugate(z)) produces nothing useful.  You might try solve(Q), but since Q is a complicated transcendental function it's unlikely that this will produce useful results either.  For numerical solutions you can try fsolve, which, as you've seen, produces only one solution at a time.  An alternative is RootFinding[Analytic], which produces all roots in a rectangle in the complex plane.

For Maple, atan should be arctan, pi should be Pi, and conj should be conjugate.

Your expression is the real part of an expression I'll call Q, which is actually real for ne in some intervals around the two solutions.
But in the complex plane, there will be a curve on which Re(Q) = 0.  So there is no point in calling solve(Re(Q)): even solve(z + conjugate(z)) produces nothing useful.  You might try solve(Q), but since Q is a complicated transcendental function it's unlikely that this will produce useful results either.  For numerical solutions you can try fsolve, which, as you've seen, produces only one solution at a time.  An alternative is RootFinding[Analytic], which produces all roots in a rectangle in the complex plane.

This may not be the best example to try, since B = 250000! is divisible by A = 150000!.  On my machine Maple took 0.390 seconds to calculate
B mod A = 0, after which the result is trivial.  How does your implementation do on a harder case of similar magnitude, say A = 10^(1000000) + 6^(1280000),
B = 7^1183000 + 11^960000 ?

This may not be the best example to try, since B = 250000! is divisible by A = 150000!.  On my machine Maple took 0.390 seconds to calculate
B mod A = 0, after which the result is trivial.  How does your implementation do on a harder case of similar magnitude, say A = 10^(1000000) + 6^(1280000),
B = 7^1183000 + 11^960000 ?

What exactly do you mean by "it"?

What exactly do you mean by "it"?

First 112 113 114 115 116 117 118 Last Page 114 of 187