Carl Love

Carl Love

25324 Reputation

25 Badges

10 years, 240 days
Himself
Natick, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

Use ?LinearAlgebra,LeastSquares:

   X:= LinearAlgebra:-LeastSquares(A,Y);

It is a nuisance that geom3d requires you to label every object. The object model used in that package is much older than the modern one based on modules. In the modern module model, an object "is what it is", so to speak, regardless of what, or even if, you name it; in the older model, an object's properties are based on looking it up by name. (To "deconstruct" it, it seems that the evolution of the object model is analogous to the evolution of social classes.) But you can reuse the labels in geom3d, so the easiest way to do what you want is

    [seq](sort(Equation(TangentPlane(P, S, point(A, pt[])), [x,y,z])), pt in L);

(where all points are named A and all planes are named P).

If you do require distinct names for each object (so that you can look up their properties without recreating them), it is possible to construct names based on the numerical values of the point using nprintf:

[seq](
       sort(
            Equation(TangentPlane(nprintf("P%a",pt), S, point(nprintf("A%a", pt), pt[])), [x,y,z])
       )
      ,pt in L
 );

Unique names can also be created with cat, which is what John May did.

I made two very small changes to your procedure, and I almost got the series that you indicated, the only difference being that I got an alternating series. Here are a few tips to help you debug your procedures:

  1. Indent after each level of do loop.
  2. Use the trace command -- in this case trace(Ad) -- before running the procedure. This will show you the result of each assignment (":=") statement. 

And here are the small changes that I made:

  1. Do not use unevaluation quotes; for example use u[i,k] rather than 'u[i,k]'.
  2. Use add, not sum.

Construct a graph of 12 vertices, one for each set. I'll label the vertices simply 1 - 12 rather than S[1] - S[12]. Two vertices will share an edge iff the corresponding sets do not intersect. Then the answer is simply the size of the largest clique in the graph.

LL:=[

   [2, 4, 5, 8, 10], [1, 3, 6, 7, 11], [2, 5, 6, 9, 10], [1, 5, 6, 9, 11], [1, 3, 4, 7, 12], [2, 3, 4, 8, 12]

 , [2, 5, 10, 11, 12], [1, 6, 10, 11, 12] , [3, 4, 10, 11, 12], [1, 3, 7, 8, 9], [2, 4, 7, 8, 9], [5, 6, 7, 8, 9]

]:

use GraphTheory in CliqueNumber(Graph({seq}(seq({i,j}, j in LL[i]), i= 1..12))) end use;

                                                                 3

Looking at the graph with DrawGraph, one can easily see many 3-cliques. (3-cliques are easy to see because they are just triangles.) One example is {1,4,5}.

One problem in your code is that your comments block some of the essential code. In any line containing a #, anything to the right of the # is ignored. (So there's also no need to use quotation marks in your comments.) For example, you have a line

#` Step 4`  for i from 2 to M2 do

So, the part for i from 2 to M2 do will be ignored.

I almost never use 2D-input. I only use it when it is part of someone else's worksheet that I'm playing around with. The only way that I know how to get a new line is Control-Enter, same as in 1D input. When I use that, I don't get the extra space. What is the usual way to get a new line, the way that does give the extra space?

I've modified the above so that the axes don't change due to the erasure, and the original axes will be restored if the VIEW is reverted to default by a subsequent display. So it is now more like erasing part of a blackboard (and circles will remain circles), whereas before it was like cutting off part of the blackboard. I do this by keeping track of the extreme upper, lower, left, and right points as they pass through the transformer procedure. Then I add an invisible (color= white) plot of the two extreme points: lower left and upper right.

It probably goes without saying that this procedure should work for any 2D plot, not just BubblePlot.

Eraser:= proc(Plot::specfunc(function,PLOT))
# Uses the VIEW specification of a PLOT structure to erase points outside the view.
# Input: PLOT structure with VIEW; Output: The PLOT structure, modified.
   local
      x1,x2,y1,y2,newPlot
     ,minx:= infinity, miny:= infinity, maxx:= -infinity, maxy:= -infinity
     ,View:= indets(Plot, specfunc(anything, VIEW))
   ;
   if View = {} then  return Plot  end if;
   if nops(View) > 1 then  error "Multiple VIEWs found: %1", View  end if;
   View:= View[];
   newPlot:=
      plottools:-transform(
         subs(
            [x1,x2,y1,y2] =~ [op(1..4, map(op, subs(DEFAULT= -infinity..infinity, View)))]
           ,proc(x,y)
               if not(x::numeric and y::numeric) then  return [args][1..2]  end if;
               if x < minx then  minx:= x  end if;  if x > maxx then  maxx:= x  end if;
               if y < miny then  miny:= y  end if;  if y > maxy then  maxy:= y  end if;
               `if`(`or`(x1 > x,x > x2, y1 > y,y > y2), [undefined$2], [x,y])                  
            end proc
         )
      )(Plot)
   ;
   # Add two invisible (white) points at extreme corners of original plot so axes don't change.
   # plottools:-transform removes VIEW, so put it back.
   plots:-display(
       [plots:-pointplot([[minx,miny],[maxx,maxy]], color= white), newPlot]
      ,view= [op(1..2, View)]
    )
end proc:

Indeed, here is the procedure.  It takes a PLOT structure containing a VIEW as input and returns the PLOT structure with the appropriate points erased.

Eraser:= proc(P::specfunc(function,PLOT))
# Uses the VIEW specification of a PLOT structure to erase points outside the view.
   local
      x1,x2,y1,y2
     ,View:= indets(P, specfunc(anything, VIEW))
   ;
   if nops(View) = 0 then  return P  end if;
   if nops(View) > 1 then  error "Multiple VIEWs found: %1", View  end if;
   View:= View[];
   PLOT(
      op(
         plottools:-transform(
            subs(
               [x1,x2,y1,y2] =~ [op](map(op, subs(DEFAULT= -infinity..infinity, View)))
              ,(x,y)-> `if`(`or`(x1 > x,x > x2, y1 > y,y > y2), [undefined$2], [x,y])
            )
         )(P)
      )
     ,View
   )
end proc:

We can use plottools:-transform like an eraser on an existing PLOT structure by converting points outside a desired view to undefined. Then they will stay undefined if the VIEW is subsequently enlarged. (I'm using all caps for certain words because that's how they appear in the PLOT structure.)

a:= Statistics:-BubblePlot([4, 5, 2, 3], [1, 2, 7, 8], [8, 1, 3, 2]):
Eraser:= (x,y)-> [x, `if`(4 <= y and y <= 9, y, undefined)]:
a1:= plottools:-transform(Eraser)(a):
plots:- display(a1);

           [plot not shown in post]

plots:-display(a1, view= [default, 0..9]);

           [plot not shown in post]

The above procedure Eraser is ad hoc, for your particular view; but I can easily generalize it so that it will extract the range(s) from the VIEW option of an existing PLOT.

Note that however you change the view in a BubblePlot, the circles will be distorted to ellipses because they are created as POLYGONs, rather than as single points. This also means that they may be cut by an invisible horizontal or vertical line. If you want to erase points without changing the axes (which means that circles would stay circles), I'll have to think of something else.

I assume that you mean a memory limit, so that you can access your virtual memory. The command is (for example, to increase to 16 GB)

kernelopts(datalimit= 16*Unit(gibibyte));

However, having read your other recent post, I know that a lack of memory is not the true cause of your troubles. Get your bugs worked out on a smaller version of your problem first!

Addressing the OP's direct question: No, there is no limitation on set size. If you have the RAM for it, the Maple kernel can handle it. The Maple kernel will give you an explicit error message if it runs into any memory limitation.

I am assuming that by "create" you mean "plot". And I am assuming that your question could be rephrased as "How can one plot a function with a restriction on the abscissae ('x values') or on the ordinates ('y values')?" If those are not what you meant, please let me know.

There are many ways to do it. Here are just a few. Which one you choose may depend on what types of algebraic manipulation you need to do to the function before or after plotting (such as, how you decided on 0.2 and 1.3).

Method 1a: piecewise, abscissa-oriented:

f:= piecewise(Or(And(x>=0.19740,x=3.3390, x

plot(f, x= 0..2*Pi, discont);

Method 1b: piecewise, ordinate-oriented:

f:= piecewise(tan(x) >= .2 and tan(x) < 1.3, tan(x), undefined);

plot(f, x= 0..2*Pi, discont);

Method 2a: restricted plot, abscissa-oriented:

plots:-display(
   [plot(tan(x), x= 0.19740..0.91510), plot(tan(x), x= 3.3390..4.0567)]
   ,view= [0..2*Pi, DEFAULT]
);

Method 2b: restricted plot, ordinate-oriented:

plot(tan(x), x= 0..2*Pi, y= 0.2..1.3, discont);

Your expression contains five pairs of square brackets which should be parentheses. If this expression is the output of a Maple command, then the input must have had inappropriate square brackets.

Markiyan's answer is fine, but here is another way. I prefer to build each frame of an animation, and then animate it, rather than merging animations. I think this gives more flexibility for changes, and avoids some repetition of arguments.

ball:= Pt-> plots:-pointplot([Pt], color= blue, symbol= solidcircle, symbolsize= 20):
balls:= ()-> plots:-display(ball ~ ([args])):  # One frame
BallData:= [[1+sin, 1-sin], [sin,sin]]:  # All data in one place.
plots:-animate(balls, BallData(t), t= 0..2*Pi, scaling= constrained, frames= 100);

You have asterisks (*) after the word unapply. Get rid of those.

g := unapply*(funktion1, x, y);

                     ^

Also, change linalg:-inverse to LinearAlgebra:-MatrixInverse, or simply use (-1) as exponent. I guess your Jacobian is from the VectorCalculus package. You should explicitly reference the package. 

First 364 365 366 367 368 369 Page 366 of 369