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 answers submitted by Doug Meade

Try this:
with( plots ):
contourplot( sin(x*y), x=-3..3, y=-3..3, contours=[-1,-1/2,0,1/2,1], grid=[50,50] );
The contours option accepts either an integer (# of contours to display) or a list of values (specific contours to show). The grid option is often needed to get enough resolution to produce a reasonable picture. I hope this is useful, 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/~meade/
I see only one error in what you have typed in your message. In the definition of the functino i you need a * (or /) between the 3 and the x. If you ignore this error and try your plot command, the result is "Error, empty plot.". This makes sense because the function i is not defined. I hope this does explain your situation. 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/~meade/
In your procedure the first command attempts to reassign the value of the first argument of the procedure. This is forbidden. I believe you want to be printing a1, b1, and c1 (not a, b, and c1) in the fprintf statement. I appears to me that you do not need m or n. Simply change the three print statements to print(a-1,b+1) (twice) and print(a,b). I do not understand your procedure. Do you want the values of a and b to change throughout the procedure? If so, then maybe you do need m and n (declared as local variables). You would start with:
m := a;
n := b;
and replace the first two print statements with
m := m-1;
n := n+1;
and move the third print statement outside the if statement. This will print the current values of m and n on each pass through the loop. Lastly, first two parts of the if statement can be combined. Here is the version of the procedure that I created:
Prob1 :=proc(a,b,c)
  local die, a1,b1,c1,pSum,pSumMod,pX1Mod,pX2Mod,pAbs,m,n;
  m:=a;
  n:=b;
  die:=rand(1..6);
  for c1 to c do
    a1:=die();
    b1:=die();
    printf("variableA, %d, variableB, %d, %d",a1,b1,c1);
    pSum:=a1+b1;
    pSumMod:=modp(pSum,2);
    pX1Mod:=modp(a1,2);
    pX2Mod:=modp(b1,2);
    pAbs:=a1-b1;

    if (pSumMod=0 and (pAbs<4 or -4<pAbs))
       or
       (((pX1Mod=0 and pX2Mod=1) or (pX1Mod=1 and pX2Mod=0))
        and ((2<pAbs or pAbs<-2)))
    then
      m:=m-1;
      n:=n+1;
    fi;
    print(m, n);
  od;
end;
---------------------------------------------------------------------
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/~meade/
This one is short and sweet. The subject line says it all. OK. I will offer a little more explanation. The default setting of displayprecision is -1, which means to display Digits digits. Positive integer values give the number number of decimal places displayed in any floating-point number. For example:
SAVEdp := interface(displayprecision=3):
exp(1.);
                          2.718
1.;
                          1.000
interface(displayprecision=SAVEdp);
Hmm. Interesting. When I copied and pasted the above from the worksheet into this window, e appeared with 10 decimal places and 1. appeared with 0 decimal places. This suggests that the true value is retained and only the display is affected. (A distinction between content and presentation. That's good to know.) I hope you learn as much from this as I have. 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/~meade/
What do you expect to see? The Dirac ``function'' is zero everywhere except zero, where it is undefined. Remember that the Dirac function is not really a function. It is a distribution. In Maple, the constant is represented by Pi (the uppercase P is required). You should change sum to add in your definition of f. Then you can do something like the following:
f := t -> add( Dirac(t-k*Pi), k=1..20 );
g := x -> int( f(t), t=-infinity..x );
plot( g, 0..100 );
The plot takes a while, but you will clearly see the expected graph. I hope this has been instructive. 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/~meade/
<\pre>
You have some nice ideas for how to use maplets. I have a fair amount of experience writing maplets (see my blog on MaplePrimes or visit http://www.math.sc.edu/calclab/M4C/MapletsForCalculus.html). If you, or anyone, desires access to the maplets on our secure site please send e-mail to me and I will create a temporary account for you. I am not aware of any way to create tabs within a maplet. You can have menus, and you might be able to do something with this. My first recommendation is to make each tab a separate maplet window. You can have many windows open at once, but control resides with the last one opened and cannot be changed except to close the window (then the control reverts to the calling window - a stack).
---------------------------------------------------------------------
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/~meade/
There are three missing characters in your code. First, the argument of the Maplet command must appear in parentheses. The third character is a missing right parenthesis in the Button command. Here is the revised code:
with(Maplets[Elements]):
MapleCalculator:=Maplet(     # inserted (
[
["Field 1", TextField['TF1'](10)]
,
["Field 2", TextField['TF2'](10)]
,
[Button ("Calculate", Evaluate('TF3' =('TF1' + 'TF2')))]     # inserted )
,
["Value: ", TextField['TF3'](10)]
]):                          # inserted )
Maplets[Display](MapleCalculator);
I hope this is helpful, 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/~meade/
<\pre>
Brian, You need to create a .m file from your computations. To do this, use the save command. The basic syntax would be:
save vars, "file.m";
See the online help for details. Be sire to include appropriate path information for your system. Otherwise, it might take as much time to locate the file as it did for Maple to complete the computations in the first place. (:-)) I hope this is useful, 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/~meade/
<\pre>
In some cases it is not feasible to use :=. In such situations, the assign command can be helpful:
assign( var1=vec2[1] );
I hope this is helpful, 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/~meade/
<\pre>
A more general way to produce a plot composed of different objects (or similar objects produced with different options) is to use the display command from the plots package. For example:
with( plots ):
P1 := implicitplot( abs(x)+abs(y)=1, x=-2..2, y=-2..2, color=blue, grid=[25,25] ):
P2 := implicitplot( abs(x)=1, x=-1..1, y=-1..1, color=blue, thickness=2 ):
P3 := plot( [1,-1], x=-1..1, color=blue, thickness=2 ):
P4 := implicitplot( x^2+y^2=1, x=-2..2, y=-2..2, color=red ):
display( [P1,P2,P3,P4], scaling=constrained, title="A Combined Plot", insequence=true );
Note that display can be used to create an animation consisting of the individual plots by changing the last command to
display( [P1,P2,P3,P4], scaling=constrained, title="An Animation", insequence=true );
I hope this is also useful, 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/~meade/
<\pre>
It appears to me that you are missing a * for the multiplication in the numerator of the integrand. Try:
f1:= (2*x*(c-Pi/2))/sqrt(1-sin(c));
                            /    1   \  

                        2 x |c - - Pi|  

                            \    2   /  

                       -----------------

                                   (1/2)

                       (1 - sin(c))     
fint:= int(f1, x=0..1);
                               1        

                           c - - Pi     

                               2        

                       -----------------

                                   (1/2)

                       (1 - sin(c))     
limit(fint,c=(Pi/2), right);
                              (1/2)

                             2     
Is this what you expect to see? I hope this helps, 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/~meade/
<\pre>
The set of solutions returned by fsolve is ideally suited for creating the quadruples that you want. Here is how I would revise the last part of your worksheet:
> PTS := NULL;
> for lambda from 0 by .1 to 1 do
>   fsolve({Wage2, Wage1}, {w[1], w[2]}, w[1] = 0 .. infinity, w[2] = 0 .. infinity);
>   PTS := PTS, eval([w[1], w[2], G[1], G[2]], % )
> end do;
> [PTS];
You can now do whatever makes sense with the quadruples in the list [PTS]. I hope this helps, 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/~meade/
<\pre>
Your question is not clear, to me. You should be aware that D is a built-in command in Maple. The command included in your posting assigns a value to D(x1). Do you really want to say the derivative of x1 (a function) is the expression on the RHS? I'm guessing this is not what you intend. From your interest in solving for gx I assume that you might have a differential equation:
eq := D(x1) = a1*fx+a2*gx-alpha*Ab;
Note that the Maple name eq is assigned to an equation. To solve this equation for another Maple name, gx, use the solve command. Here are three possible ways to do this, each differs only in the specific way the result is returned.
s1 := solve( eq, gx );     # expression
s2 := solve( eq, {gx} );   # set w/equation
s3 := solve( eq, {gx} )[]; # equation
If you do not want D(x1) to refer to a derivative, change this to something else, say Dx1. I hope my assumptions have been reasonably close to what you are seeking. 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/~meade/
<\pre>
Christopher, Your post appears to have been corrupted. The inequality that you used was viewed as HTML and not displayed. What you posted as an inequality appears as "3-xy+5". Regardless of what you really intended to post, I believe Maple can create the plot you are seeking. The command to use is inequal from the plots package. For full information, see the online help for this command by entering:
?plots,inequal
Typical usage of the inequal command is illustrated below:
with( plots ):
inequal( 5-x>y+2, x=0..5, y=0..5 );
inequal( { 5-x>y+2, y>=x }, x=0..5, y=0..5 );
Note that these plots identify 4 different parts within the viewing window: feasible region, excluded region, open lines, and closed lines. The appearance of each of these sets can be controlled via optional arguments to the inequal command. For example:
inequal( { 5-x>y+2, y>=x }, x=0..5, y=0..5,
         optionsexcluded=(color=blue),
         optionsfeasible=(color=red),
         optionsopen=(color=cyan,thickness=2),
         optionsclosed=(color=pink,linestyle=2, thickness=2) );
I hope this is helpful, 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/~meade/
<\pre>
Emrah, Just move the plot command inside the loop. In some cases it might be necessary to put the plot command inside a print statement to force it to be shown. If you do not want to clutter your worksheet with a long sequence of plots, you can have the plots sent to separate windows. To do this, click on Options ... under the Tools menu. Under the Display tab, the sixth item is Plot display. Change this from Inline to Window. To make the change, click (at the bottom of the window) either Apply to Session or Apply Globally. You will get one window per plot. If this is too much, then you should add logic to print selected plots. Here's a simple example to illustrate:
for k from 1 to 10 do
  if isprime(k) then
    print(plot( [ [i,sin(i)]$i=1..k ], style=point ))
  end if;
end do;
I hope this is helpful, 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/~meade/
<\pre>
First 39 40 41 42 43 44 Page 41 of 44