Doug Meade

 

Doug

---------------------------------------------------------------------
Douglas B. Meade <><
Math, USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Phone: (803) 777-6183 URL: http://www.math.sc.edu

MaplePrimes Activity


These are replies submitted by Doug Meade

Will, I am happy that MaplePrimes is now officially released. The improvements over the past year or so have made the site much more user-friendly and informative. I hope the Maple community accepts it and the traffic can pick up. One suggestion for further improvement: update the MaplePrimes logo to remove the "beta". This should not be a problem. Doug ----------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Alasdair, Your procedure works fine for me. I am using Maple 10.05 under Windows. You did not say how you tried to call your procedure, or whatresponse Maple gives you. All I did was copy your code to a worksheet, then added one more line:
testplot(10);
The result is the graph of y=x for x=0 to x=21 drawn as a red dashed line with ten segments. How does this differ from what you see? Doug ------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Jenni, Your request is very common, and seems very reasonable. However, in many cases Maple uses different algorithms than you, I, or any human would use. (We can think, and make choices based on experience, personal preference, .... A computer can only follow an algorithm.) The blog post talks about how you can construct a worksheet that shows the steps used in solving a problem. This is not what I believe you are seeking. It is possible to ask Maple to show more information about what it is doing when you execute a command. One of the easiest ways to see intermediate output is to change the printlevel from 1 to a higher number. For example,
printlevel := 100;
For the two examples you give, this does nothing for the first one (diff). For simplify, you do see some intermediate work, but it's not very illuminating. But, if you change the first example from diff to int, then you will see something of interest. (Actually, you will see much more than you really want to see!) For more information about printlevel, consult the online help (?printlevel). I hope this has been helpful, Doug ------------------------------------------------------------ Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Jenni, Your request is very common, and seems very reasonable. However, in many cases Maple uses different algorithms than you, I, or any human would use. (We can think, and make choices based on experience, personal preference, .... A computer can only follow an algorithm.) The blog post talks about how you can construct a worksheet that shows the steps used in solving a problem. This is not what I believe you are seeking. It is possible to ask Maple to show more information about what it is doing when you execute a command. One of the easiest ways to see intermediate output is to change the printlevel from 1 to a higher number. For example,
printlevel := 100;
For the two examples you give, this does nothing for the first one (diff). For simplify, you do see some intermediate work, but it's not very illuminating. But, if you change the first example from diff to int, then you will see something of interest. (Actually, you will see much more than you really want to see!) For more information about printlevel, consult the online help (?printlevel). I hope this has been helpful, Doug ------------------------------------------------------------ Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Roman's comments are all appropriate, but do not answer the main question in the original posting. Maple's $ (dollar) and seq commands provide a partial solution, but only with unit steps. (I should point out that it's possible to use non-integer limits, but the step is always 1, e.g., $(1/2,5/2);) But, it's not difficult to create a simple procedure to mimic MATLAB's behavior. The following implementation is not very efficient as new memory is used each time through the loop. It would be more efficient to compute the number of elements in the list and to use this to create an appropriately sized array - but I have a meeting that I have to go to and don't have time to add this functionality.
SEQ := proc()
  local hi, i, L, lo, step;
  if   nargs=3 then lo,step,hi:=args;
  elif nargs=2 then lo,hi:=args; step:=1;
  else error "incorrect number of arguments; 2 or 3 arguments required"
  end if;
  L := NULL;
  for i from lo to hi by step do
    L := L, i;
  end do;
  return [L]
end proc:

SEQ(1,10);        # MATLAB: 1:10
                [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
SEQ(1,2,10);      # MATLAB: 1:2:10
                        [1, 3, 5, 7, 9]
SEQ(0.,0.02,0.5); # MATLAB: 0:0.02:0.5
[0., 0.02, 0.04, 0.06, 0.08, 0.10, 0.12, 0.14, 0.16, 0.18, 0.20, 0.22, 0.24,
  0.26, 0.28, 0.30, 0.32, 0.34, 0.36, 0.38, 0.40, 0.42, 0.44, 0.46, 0.48, 0.50
  ]
I hope this has been useful, Doug ------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Roman's comments are all appropriate, but do not answer the main question in the original posting. Maple's $ (dollar) and seq commands provide a partial solution, but only with unit steps. (I should point out that it's possible to use non-integer limits, but the step is always 1, e.g., $(1/2,5/2);) But, it's not difficult to create a simple procedure to mimic MATLAB's behavior. The following implementation is not very efficient as new memory is used each time through the loop. It would be more efficient to compute the number of elements in the list and to use this to create an appropriately sized array - but I have a meeting that I have to go to and don't have time to add this functionality.
SEQ := proc()
  local hi, i, L, lo, step;
  if   nargs=3 then lo,step,hi:=args;
  elif nargs=2 then lo,hi:=args; step:=1;
  else error "incorrect number of arguments; 2 or 3 arguments required"
  end if;
  L := NULL;
  for i from lo to hi by step do
    L := L, i;
  end do;
  return [L]
end proc:

SEQ(1,10);        # MATLAB: 1:10
                [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
SEQ(1,2,10);      # MATLAB: 1:2:10
                        [1, 3, 5, 7, 9]
SEQ(0.,0.02,0.5); # MATLAB: 0:0.02:0.5
[0., 0.02, 0.04, 0.06, 0.08, 0.10, 0.12, 0.14, 0.16, 0.18, 0.20, 0.22, 0.24,
  0.26, 0.28, 0.30, 0.32, 0.34, 0.36, 0.38, 0.40, 0.42, 0.44, 0.46, 0.48, 0.50
  ]
I hope this has been useful, Doug ------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Maple's result is an equation. You want to define a function, say Y, using the right-hand side (rhs) of this equation. The following will do this for you:
Y := unapply( rhs(%), x,_C1,_C2 );
or, if you wish to have a function that depends only on x, use
Y := unapply( rhs(%), x );
If you have a system of ODEs, the result from dsolve will be a set of equations. In this case you have to find the correct equation, and cannot assume the solutions will always be presented in the same order. The eval command can be used in these situations:
ode2 := {diff(y(x),x)=v(x), diff(v(x),x)=2*y(x)+1}:
S := dsolve(ode2);
Y := unapply( eval(y(x),S), x );
V := unapply( eval(v(x),S), x );
I hope these suggestions allow you to do what you want. Doug ------------------------------------------------------------ Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Ricky, I am using Maple 10.03. You might want to check with Maplesoft Technical Support to see if this is something that has been fixed between 9.5 adn 10. Good luck, Doug ----------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
Ricky, I am using Maple 10.03. You might want to check with Maplesoft Technical Support to see if this is something that has been fixed between 9.5 adn 10. Good luck, Doug ----------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
I do not see that there is any problem doing what you want. Maybe I misunderstand your problem, but it would seem that this is what Maple does by default. I have uploaded a Maple 10 worksheet that contains the definition of a maplet that does exactly what you describe (as I understand it). You can access the file via MapleNet or download the worksheet. Here are the relevant URLs: View 178_TestMaplet.mw on MapleNET or Download 178_TestMaplet.mw You could easily add another button to evaluate your expression as a floating point number. However, as was remarked to your original post, you need to be aware that Maple expects the arguments to trig functions in radians. Thus, evaluating your expression would require multiplying A and C by Pi/180, e.g., in my UPDATEa procedure replace the definition of a by
a := evalf( b*sin(A*Pi/180)/sin(C*Pi/180) );
I hope this gets you closer to what you want. Doug --------------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
A colleague asked me about this about a week ago. I have kept him informed of the discussion here. Here is his latest message to me: I should clarify that I was going to mention in my last email a recent download of mine. My hesitation and decision not to was based on the fact that I do not have a problem with the delete key in any other application (that I have used recently). So presumably there is an issue with Maple. On the other hand, if Maple is using Java on my computer and my other applications are not, then maybe the new download affects Java somehow. I started up Maple again and do not see any reference to Java or any indication that it is using Java in its preferences, so I am not sure what to make of that. Maybe someone else can inform me or us how to tell the Java application being used in Maple on a Mac. I see something called a Java 1.4.2 plugin settings on my mac and also, in the same folder, a Java 1.3.1 plugin settings. The download that I made recently (which I think I did mention earlier to you) is called "Mouse Locator" - see http://www.macupdate.com/info.php/id/17513 When I installed this, it also asked for a function key assignment to activate it. I used F1 initially and then changed it at some point to see if the assignment itself was causing the problem with Maple. Changing the function key assignment to F12 did not correct the problem with Maple. I did unactivate Mouse Locator and restart Maple, and this does not help. I would get rid of Mouse Locator (which is only mildly of interest to me), but I am not sure how to do this. It is in my preference window now, and I do not see an option to uninstall. I can ask Dave about this sometime. But again, if Mouse Locator even caused the problem, it seems to me that there is still a Maple issue as well since the problem was not present in my other programs. I hope this is helpful. Doug ----------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
The initial questions, and response, all fit into the traditional framework of computer programming from the (mid)-20th century. In many situations the index is really a red herring. What you really want to do is loop through every solution in the list. Maple supports this directly. For example,
solutions := [ fsolve(equation,t) ];
for f in solutions do
  <whatever you want to do with each solution>
end do;
If the operation(s) to be applied to each solution are in single procedure (command) then you could even collapse the loop into:
seq( <expression involving f>, f=solutions );
If the operation(s) to be applied to each solution are in single procedure (command) then you could even collapse the loop into:
map( MyManipulations, solutions );
The above is functionally equivalent to
seq( MyManipulations(f), f=solutions );
which is equivalent to
ANS := NULL;
for f in solutions do
  ANS := ANS, MyManipulations(f);
end do;
[ANS];
To be more explicit, consider:
solutions := [fsolve( x^5+x^4+x^3+x^2+x+1=0, x, complex )];
[seq( Re(f)/Im(f), f=solutions )];
map( f->Re(f)/Im(f), solutions );
MyManipulations := x -> `if`(Im(x)=0,Re(x)^2,Re(x)/Im(x));
map( MyManipulations, solutions );
I hope this is useful, Doug ----------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
The initial questions, and response, all fit into the traditional framework of computer programming from the (mid)-20th century. In many situations the index is really a red herring. What you really want to do is loop through every solution in the list. Maple supports this directly. For example,
solutions := [ fsolve(equation,t) ];
for f in solutions do
  <whatever you want to do with each solution>
end do;
If the operation(s) to be applied to each solution are in single procedure (command) then you could even collapse the loop into:
seq( <expression involving f>, f=solutions );
If the operation(s) to be applied to each solution are in single procedure (command) then you could even collapse the loop into:
map( MyManipulations, solutions );
The above is functionally equivalent to
seq( MyManipulations(f), f=solutions );
which is equivalent to
ANS := NULL;
for f in solutions do
  ANS := ANS, MyManipulations(f);
end do;
[ANS];
To be more explicit, consider:
solutions := [fsolve( x^5+x^4+x^3+x^2+x+1=0, x, complex )];
[seq( Re(f)/Im(f), f=solutions )];
map( f->Re(f)/Im(f), solutions );
MyManipulations := x -> `if`(Im(x)=0,Re(x)^2,Re(x)/Im(x));
map( MyManipulations, solutions );
I hope this is useful, Doug ----------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
I must preface my comments with the acknowledgement that I do not claim to be an expert with assumptions in Maple. But, ... In the posted worksheet I found it odd that alist was a list and not a set. getassumptions returned a set the first time but a list when assigned to alist. I could not reproduce this result in Maple 10; in both cases the returned result is a set. This is curious too as it appears that the assumptions on D(v)(m~) appear twice in this set. I found it curious that Maple indicates the assumptions have been added to m (not v) - note the appearance of m~ and not v~. I tried to remove the assumptions on m with forget(m), but this had no apparent effect on either m or v. Likewise for forget(v). And, trying to use forget on D(v) or D(v)(m) produced errors. (forget(D,v) is acceptable syntax but has no apparent effect.) Re-execute the block with additionally and getassumptions. Two new assumptions are added to this SET, even though the new elements appear to be the same as earlier elements. This is further evidence to me that something is being done to the assumptions on other parts of these expressions. Then, as a last attempt, I looked at getassumptions(m) and was surprised to see that this returned exactly the four conditions that were originally expected from getassumptions(v). I hope all of this gives some insight to somebody who has more expertise with the assume facility. Doug ----------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
If I understand your question, this should be possible with implicitplot. Here's how I would do it:
> implicitplot( [y=x^2,x=1,x=2], x=0..3, y=0..10 );
Note that each of the three curves must be given as an equation. I hope this is useful, Doug ----------------------------------------------------------------- Prof. Douglas B. Meade Phone: (803) 777-6183 Department of Mathematics URL: http://www.math.sc.edu/~meade/ USC, Columbia, SC 29208 E-mail: mailto:meade@math.sc.edu
First 71 72 73 74 75 76 Page 73 of 76