MaplePrimes Questions

Search Questions:

Latest Questions Latest Questions Feed

Say the values of i^2 are being calculated from within a procedure,

 

mytest:=proc(n)

local ans;

    ans:=0;

    for i from 1 to n do

   ans:=ans+i^2;

   end do;

   return ans;

end proc;

 

Could I have a (time series) plot of i^2, while the values are being calculated?

The above is a toy example. What I want to archieve is to track a particular intermidiate values while the procedure is running.

 

Thanks,

 

casper

It puzzles me that some of the choices for Clickable Math don't return a result. The image below shows four choices for clickable math. I would like it to "factor" exactly as shown in the upper left choice, but nothing happens after clicking the choice. (No matter how many times I try.) The choices "2D Plot" and "Isolate" return results ("Complete the square", in this case, also does not work).

My guess is that I'm asking it to operate on only the denominator of the rhs of the equation, but then why is the choice displayed at all. I've noticed this for some time in certain cases (like since version 17 was release).

Is there a way to make the choice return a result ? In this case, I don't find an equivalent command (factor, the denominator) using a right click. (In this case, I'll use another command "covert" "parfrac" . . .)

I want Clickable Math to make it easy.

 

Thanks. Cheers !

 

 

I was under the impression that I could declare the type of the return value from a procedure to be a tuple of two posints as follows:

  foo := proc () :: posint, posint; 12, 13; end proc;

and then use it for multiple assignment as

  i, j := foo();

Of course, I have to set

  kernelopts(assertlevel = 2):

if I want Maple to actually check that foo returns two posints as promised.

All this seems to work as expected, including getting an error message if the returned value has the wrong type.

So, why does Maple IDE claim that this is a syntax error? Is there a difference between the syntax accepted by Maple and Maple IDE, and if so which is correct?

I typed (x-a)(x-a) into Maple 18 (the only thing in a new document) and got x(x-a)-a 

I'm wondering why it is evaulated like this?

Is this because of a setting?

BTW, I evaluated at a=4 first. 

Here´s the problem:

I´m ussing the command readdata to import a large ammount of data from a .txt file. So far, so good.

The problem is when I have to switch computers from home to office and I need to work with my .mw file. Every time I do the switching between the computers I have to replace all the directory information for maple to read the .txt file in the new location.

Is there any way to tell maple to look for the file in a relative way instead of a absolute direction in the hard drive?

I know this is maybe a beginners question, but thanks in advance.

I tried to find the root distritubion of a polynomial? 

When p=1, q=3, the following command works.


with(plots):

eq:=u^(2*q)+1-2*K*u^(q-p);

p:=1;   q:=3;

unitcircle:=implicitplot(x^2+y^2 = 1, x = -1 .. 1, y = -1 .. 1, scaling = constrained);

animate(complexplot,[[solve(eq, u)],style = point,symbolsize=10,color="red"],frames=50,K=-1..1,background=unitcircle, scaling=constrained, trace=20 );

However, when I tried p=2, q=3, only one root was shown on the animation.  

But   "complexplot([solve(eq,u)],style=point)"      showed  6 roots anyway.

I have no idea what was wrong. 

 

 


k:=0.99: with(RealDomain):

m:=1: Digits:=2:

x:=(Pi*csc(Pi*(k-m)))/(0.693*GAMMA(k)*GAMMA(m));

x := -1.4*Pi*csc(0.1e-1*Pi)

m1:=MeijerG([[-m],[1-m]],[[0,-m,-m],[k-m]],(-m*k)/snr);

m1 := MeijerG([[-1.], [0.]], [[0., -1., -1.], [-0.1e-1]], -.99/snr)

m2:=MeijerG([[-k],[1-k]],[[0,-k,-k],[m-k]],(-m*k)/snr);

m2 := MeijerG([[-.99], [0.1e-1]], [[0., -.99, -.99], [0.1e-1]], -.99/snr)

c:=x*((((m*k)/snr)^m)*m1-(((m*k)/snr)^k)*m2);

c := -1.4*Pi*csc(0.1e-1*Pi)*(.99*MeijerG([[-1.], [0.]], [[0., -1., -1.], [-0.1e-1]], -.99/snr)/snr-.99*(1/snr)^.99*MeijerG([[-.99], [0.1e-1]], [[0., -.99, -.99], [0.1e-1]], -.99/snr))

with(plots):

Warning, the name changecoords has been redefined

plot(c,snr=0..10);

Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

Error, empty plot

 

 


Download capacity_kfading.mw

k:=0.99: with(RealDomain):

m:=1: Digits:=2:

x:=(Pi*csc(Pi*(k-m)))/(0.693*GAMMA(k)*GAMMA(m));

x := -1.4*Pi*csc(0.1e-1*Pi)

m1:=MeijerG([[-m],[1-m]],[[0,-m,-m],[k-m]],(-m*k)/snr);

m1 := MeijerG([[-1.], [0.]], [[0., -1., -1.], [-0.1e-1]], -.99/snr)

m2:=MeijerG([[-k],[1-k]],[[0,-k,-k],[m-k]],(-m*k)/snr);

m2 := MeijerG([[-.99], [0.1e-1]], [[0., -.99, -.99], [0.1e-1]], -.99/snr)

c:=x*((((m*k)/snr)^m)*m1-(((m*k)/snr)^k)*m2);

c := -1.4*Pi*csc(0.1e-1*Pi)*(.99*MeijerG([[-1.], [0.]], [[0., -1., -1.], [-0.1e-1]], -.99/snr)/snr-.99*(1/snr)^.99*MeijerG([[-.99], [0.1e-1]], [[0., -.99, -.99], [0.1e-1]], -.99/snr))

with(plots):

Warning, the name changecoords has been redefined

plot(c,snr=0..10);

Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

Error, empty plot

 

 


Download capacity_kfading.mw

k:=0.99: with(RealDomain):

m:=1: Digits:=2:

x:=(Pi*csc(Pi*(k-m)))/(0.693*GAMMA(k)*GAMMA(m));

x := -1.4*Pi*csc(0.1e-1*Pi)

m1:=MeijerG([[-m],[1-m]],[[0,-m,-m],[k-m]],(-m*k)/snr);

m1 := MeijerG([[-1.], [0.]], [[0., -1., -1.], [-0.1e-1]], -.99/snr)

m2:=MeijerG([[-k],[1-k]],[[0,-k,-k],[m-k]],(-m*k)/snr);

m2 := MeijerG([[-.99], [0.1e-1]], [[0., -.99, -.99], [0.1e-1]], -.99/snr)

c:=x*((((m*k)/snr)^m)*m1-(((m*k)/snr)^k)*m2);

c := -1.4*Pi*csc(0.1e-1*Pi)*(.99*MeijerG([[-1.], [0.]], [[0., -1., -1.], [-0.1e-1]], -.99/snr)/snr-.99*(1/snr)^.99*MeijerG([[-.99], [0.1e-1]], [[0., -.99, -.99], [0.1e-1]], -.99/snr))

with(plots):

Warning, the name changecoords has been redefined

plot(c,snr=0..10);

Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

Error, empty plot

 

 


Download capacity_kfading.mw

k:=0.99: with(RealDomain):

m:=1: Digits:=2:

x:=(Pi*csc(Pi*(k-m)))/(0.693*GAMMA(k)*GAMMA(m));

x := -1.4*Pi*csc(0.1e-1*Pi)

m1:=MeijerG([[-m],[1-m]],[[0,-m,-m],[k-m]],(-m*k)/snr);

m1 := MeijerG([[-1.], [0.]], [[0., -1., -1.], [-0.1e-1]], -.99/snr)

m2:=MeijerG([[-k],[1-k]],[[0,-k,-k],[m-k]],(-m*k)/snr);

m2 := MeijerG([[-.99], [0.1e-1]], [[0., -.99, -.99], [0.1e-1]], -.99/snr)

c:=x*((((m*k)/snr)^m)*m1-(((m*k)/snr)^k)*m2);

c := -1.4*Pi*csc(0.1e-1*Pi)*(.99*MeijerG([[-1.], [0.]], [[0., -1., -1.], [-0.1e-1]], -.99/snr)/snr-.99*(1/snr)^.99*MeijerG([[-.99], [0.1e-1]], [[0., -.99, -.99], [0.1e-1]], -.99/snr))

with(plots):

Warning, the name changecoords has been redefined

plot(c,snr=0..10);

Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

Error, empty plot

 

 


Download capacity_kfading.mw

require help to overcome this warning. Thanks.

How do I solve Smith Chart...

Yesterday at 8:37 AM jared 5

How do I mark a value on circles

I want to plot Smith Chart and calculate the value Correspond to circles.

Any one can give me some suggestions or better idea to plot Smith Chart.

There are my code:Doc1.doc

 

 

Hi Maple friends.

x(x+y)^4 = y(3*x-y)^2

When I differentiate implicitly by hand, I get:

-5*x^4-4*x^3*y+3*y^2/x^4-6*x*y+3*y^2 (my lecturer also got this solution)

Maple gives the result as: 

(-2*x(x+y)^3*(D(x))(x+y)+3*y(3*x-y)*(D(y))(3*x-y))/(2*x(x+y)^3*(D(x))(x+y)+y(3*x-y)*(D(y))(3*x-y))

Maybe I am doing something wrong in Maple? From the context menu, I choose implicit differentiation, and then select y as the dependent variable. How can I get Maple to give the same solution?

Thanks in advance.

I have some lengthy formulas in the maple. I don't want to waste time on rewritting them in a word document.
Is there a way to import those equations in a clean and tidy form to a word document or the mathtype program or something else! :)

I wanted to answer a question and show an animation contained in an animated gif file. The file is small gif file and is on my local drive on my PC.

I am not able to find a way to include it here as I can easily do on stackexchange so it plays on the screen when someone sees the post.

Does this forum support such a feature? I tried the image->include, and in the URL I typed  C:\foo.gif, but nothing showed up on the post. So it did not work that way.

I've been instructed to create an animation showing the changing plots of a single square waveform using 5,10,20,40,80,160,320, and 640 terms in my Fourier series. This is my code right now: 

 

with (plots):
L := [seq(2^i, i = 0 .. 6)];


[1, 2, 4, 8, 16, 32, 64]


animate( plot, [2/((2*n-1)*Pi))*sin((2*n-1)*Pi*x], n=L);
Error, `)` unexpected

 

It doesn't work. Can anyone explain what I'm doing wrong, or how to solve my question?

dualaxisplot(listplot(sols[2], color = red), listplot(sols[1], color = blue), style = line, gridlines = false);

How can I define general matrices in Maple and do symbolic manipulation - for example specifying a matirx M to be of dimension n x m where n and m are integers ?

The permanent of a square matrix is defined similarly to the determinant, as a sum of products of sets of matrix entries that lie in distinct rows and columns. However, where the determinant weights each of these products with a ±1 sign based on the parity of the set, the permanent weights them all with a + 1 sign.While the determinant can be computed in polynomial time by Gaussian elimination, the permanent cannot. Valiant has showed that computing permanents is #P-hard, and even #P-complete for matrices in which all entries are 0 or 1 [L.G. Valiant, The Complexity of Computing the Permanent, Theoretical Computer Science 8 (1979) 189–201]. The development of both exact and approximate algorithms for computing the permanent of a matrix is an active area of research. (see Wikipedia: computing the permanent, more details on permanent)

The best known general exact algorithm is due to H. J. Ryser (1963) [Ryser, Herbert John (1963), Combinatorial Mathematics, The Carus mathematical monographs, The Mathematical Association of America. Ryser formula ]. Ryser's formula can be evaluated using O(2^{n}*n^2) arithmetic operations, whereas O(n!*n) arithmetic operations if we compute the permanent using the definition.

There have been codes of Ryser's algorithm for computing the permanent written in C language and Matlab. I cannot find a Ryser's procedure in Maple. So I try to write a Maple procedure to compute the permanent using Ryser's algorithm. The code is as follows:

permanentRyser := proc (M::Matrix) 
      local S, T, B, m, n, s, i, j, rowsum, sum, prod, perm;
      m, n := op(1, M);
      if m <> n then
               error "expecting a square Matrix, got dimensions %1, %2", m, n
      end if;
      rowsum := 0;
      sum := 0;
      prod := 1; 
      S := combinat:-subsets([seq(1 .. m)]);
      Snextvalue();
      while not Sfinished do
             T := Snextvalue();
             s := numelems(T);
             B := LinearAlgebra:-SubMatrix(M, [1 .. m], T);
             for i to m do
                  for j to s do
                          rowsum := rowsum+B[i][j];
                 end do;
                 prod := prod*rowsum; 
                 rowsum := 0;
             end do; 
            prod := (-1)^s*prod;
            sum := sum+prod;
            prod := 1 ;
      end do;
      perm := expand((-1)^m*sum) ;
end proc:
The last second statement "perm := expand((-1)^m*sum) ;" I mean to compute the permanent of  a matrix containing a variable, e.g. the characteristic matrix. If the matrix is numeric, then "expand" should be deleted.

Now I have two questions:

1. Suppose that A is random matrix of order 20, the time(permanentRyser(A)) is about 716 seconds and time(LinearAlgebra:-Permanent(A)) is about 66 seconds. We can see that LinearAlgebra:-Permanent(A) is much faster than permanentRyser(A).  I don't know whether the code I written is accurate and efficient. Thanks to anyone who gives a more efficient procedure of computing the permanent using Ryser's formular.

2. The source code of the function permanent is as follows.

proc (A::(`~Matrix`(square)), ` $`)
     option `Copyright (c) 1999 Waterloo Maple Inc. All rights reserved.`;
     local m, n, t1;
     m, n := op(1, A);
     if m <> n then
              error "expecting a square Matrix, got dimensions %1, %2", m, n
     end if;
     if n = 1 then t1 := A[1, 1] ;
     else
            tools/ClearRememberTable(Permanent/pminor`);
            t1 := [`$`(1 .. n)];
            t1 := Permanent/pminor(A, t1, t1, n)
      end if
end proc

I cannot understand the source code. Does the source code compute the permanent by Laplacian expansion? If the LinearAlgebra:-Permanent() compute the permanent by Laplacian expansion, then it should take more time than by using Ryser's algorithm.

Thanks all.

1 2 3 4 5 6 7 Last Page 1 of 1045