MaplePrimes Posts

MaplePrimes Posts are for sharing your experiences, techniques and opinions about Maple, MapleSim and related products, as well as general interests in math and computing.

Latest Post
  • Latest Posts Feed
  • A customer wondered if they could create a plot of points on a polar axis, and if they could zoom a polar plot.

     We suggested a couple of options for making these plots, and (although zooming is not supported in polar coordinates in Maple 2020) an alternative to manually scale a polar plot.

    Hope it's a useful demonstration.

    rho := [seq(i, i = 1 .. 10)];
    theta := [seq((2*j*Pi)/10, j = 1 .. 10)];
    nby2 := zip(`[]`, rho, theta);
    
    # Method A of plotting points in polar basis
    with(plots);
    pointplot(rho, theta, coords = polar, axiscoordinates = polar, connect = false, color = "HotPink", symbol = soliddiamond);
    
    #Method B to create polar point plot
    polarplot(nby2, style = point, color = "green", symbol = solidbox);
    
    #narrow view of polar plot around first point as a substitute for zooming
    polarplot(nby2, style = point, color = "OrangeRed", symbol = solidcircle, coordinateview = [0 .. 2, Pi/5 - Pi/20 .. Pi/5 + Pi/20])
    
    

    Download polar-point-plot-with-zoom.mw

    Recently I came back on the general problem of drawing the syntactic graph of a mathematical expression.
    Probably some of you have already done this as students for it is a classic when you learn recursive procedures, chained lists or graphs.

    I wasn't interested in doing this with Maple, because Maple had already done  a part of the job thanks to the procedure ToInert.
    More of this, the package GraphTheory seemed to possess all the required features to obtain quickly this syntactic graph.
    Nevertheless it took me a lot of time to fix (almost all) the problems.
    The issues are mainly of two orders:

    1. ToInert is very verbose: a necessary feature when you want to have a non ambiguous syntax of an expression, but partly useless for simple visualization.
      Here is an example
      ToInert(f(x))
      _Inert_FUNCTION(_Inert_NAME("f"), _Inert_EXPSEQ(_Inert_NAME("x")))

       

    2. GraphTheory 
      Once the inert form of the expression is known, it is necessary to put it in a form that can be manipulated by the procedures of the GraphTheory package.
      More precisely one needs to transform this inert form into a set of lists [a, b], where a and b are two neighboring vertices of the syntactic graph and [a, b] the directed arc from a to b.
      As the syntactic graph is a tree, this implies using edges {a, b} instead of arcs [a, b].
      The problem is that some operators are commutative while others are not: for the latter this means that the edges and vertices on the syntactic graph must appear in an order that respects the non-commutativity.
      Here his a toy example where I manually buid the syntactic graphs of a/b and b/a: the two graphs are identical and this comes from the fact that edges in Graph( edges )  must be a set, thus an ordered structure whose order doesn't care about non-commutativity.

      restart:
      with(GraphTheory):
      # The first is aimed to represent the expression a/b
      # while the second is aimed to represent the expression b/a
      Gdiv := Graph({{"/", "a"}, {"/", "b"}}):
      g1 := DrawGraph(Gdiv, style=tree, root="/", title=a/b):
      
      Gdiv := Graph({{"/", "b"}, {"/", "a"}}):
      g2 :=DrawGraph(Gdiv, style=tree, root="/", title=b/a):
      
      plots:-display(<g1 | g2>)
      

      Download ab_ba.mw

       

    After several attempts, I decided to discard the GraphTheory package, that is to deprive myself of all the interesting features one needs to manipulate a graph.

    The result is given on the attached file (... and the content of the worksheet can't be loaded as usual).

    Download Syntactic_Graph.mw

    Here is an example


    Twelve test cases are given, all the corresponding syntactic graphs are correct, but one of them (test case iexpr=1) seems incorrect because the right child of a parent P is located to the right of the left child of a parent P', even though P' is to the right of P.
    This could be corrected by modifying the way the posiitons are computed in procedure Place.


    PS : It doesn't seem that Maple has a built-in procedure to construct the syntactic graph of a mathematical expression.
    But maybe I'm wrong?


     

     

    In the two examples below (in the second example, the range for the roots is simply expanded), we see bugs in both examples (Maple 2018.2). I wonder if these errors are fixed in Maple 2020?
     

    restart;

    solve({log[1/3](2*sin(x)^2-3*cos(2*x)+6)=-2,x>=-7*Pi/2,x<=-2*Pi}, explicit, allsolutions); # Example 1 - strange error message
    solve({log[1/3](2*sin(x)^2-3*cos(2*x)+6)=-2,x>=-4*Pi,x<=-2*Pi}, explicit, allsolutions);  # Example 2 - two roots missing

    Error, (in assume) contradictory assumptions

     

    {x = -(11/3)*Pi}, {x = -(10/3)*Pi}

    (1)

    plot(log[1/3](2*sin(x)^2-3*cos(2*x)+6)+2, x=-7*Pi/2..-2*Pi);
    plot(log[1/3](2*sin(x)^2-3*cos(2*x)+6)+2, x=-4*Pi..-2*Pi);

     

     

    Student:-Calculus1:-Roots(log[1/3](2*sin(x)^2-3*cos(2*x)+6)=-2, x=-7*Pi/2..-2*Pi);  # OK
    Student:-Calculus1:-Roots(log[1/3](2*sin(x)^2-3*cos(2*x)+6)=-2, x=-4*Pi..-2*Pi);  # OK

    [-(10/3)*Pi, -(8/3)*Pi, -(7/3)*Pi]

     

    [-(11/3)*Pi, -(10/3)*Pi, -(8/3)*Pi, -(7/3)*Pi]

    (2)

     


    I am glad that  Student:-Calculus1:-Roots  command successfully handles both examples.

     

    Download bugs-in-solve.mw

    Spectroscopy is both qualitative and quantitative, so one can use spectral data tables of elements to do some fairly accurate Light Engineering.

    Some nifty emulation of the spectral distributions of many non-LED popular lamps, which allows for direct utility calculations based on many different parameters including chromaticity, space type, lifetime, occasion, application, cost and efficiency. 7 such parameters are used with constrained weight optimization to fish out some of the more popular lamp types used in many situations today.

    References (inline) the following docs:

    The Science of Color, the Emission Spectra of the Elements and Some Lamp Engineering Applications

    and

    The Double Amici Prism Hand-held Spectroscope

    First link main Theory, second link experimental verification.

    Usage: Maple 18 main document code with library and data files. Download, unzip and run document for some quick results. Don't move library/data files relative to main doc. For further results and particular details, such as particular spectra & lamps, UN-comment the relevant commands in sections and execute individually after you have executed the entire sheet at least once.

    Will be modified some time later to deal with LEDs. Based on elemental spectral data published by NIST. Suggestions 4 Improvements/Errors @ followup, here.

    Elements.zip

    For sample pics generated with the above code, click on the first reference link. All pictures therein were generated using this code.

    --

    Cheers,

    Yiannis

    A customer wondered if it was possible to create 2-line tickmarks on Maple plots like so

     

     

    We achieved this using typeset, fractions, and backticks. Worksheet follows.

    2line-tickmarks-mprimes.mw

     

    Hi,
    This post is inspired by a recent question maple least square fit error... where the OP was simulating what appeared to be a stochastic process known as the Drunkard's walk (see for instance The_Drunkard's_Walk).


    In the case of the PO, the drunk took a step forward or a step backward (say along a narrow, long corridor) with equal probabilities. In addition one assumes that the step the drunkhard takes is independent of all the steps he did before.
    His move is what is called a (1D) Random_walk

    This little application based on MAPLETS (ok, I know that some people see them as old-fashioned technology).

    It draws a sequence of several drunkard's walks, all of identical number of steps, and interactively plots the current histogram of the arrival point (the point where he is at the end of his walk -which should be the door if the same pub he started from if he is an inveterate drunkhard or if he knows a little about statistics- ).

    The code contains 2 procedures :

    • f_step_by_step (n, Discrete=false/true) 
      n : number of steps
      Discrete = false (default value) plot the histogram of the arrivals point as if these points were realizarions of a continuous random variable
      In this simple model these arrivals can take only integer values between -n and +n included; the Discrete=true option is recommended but it takes more walks for it to converge to the asymptotic distribution (see below).

      Once launched, f_step_by_step opens a maplet containing a Plotter and 2 buttons. A first walk is displayed, clic the "Plot" button to draw another and repeat the operation as many times as you want.
       
    • f_automatic (n, m, Discrete=false/true) 
      d and Discrete both have the same meaning than for f_step_by_step.
      m is the number of random walk you want to draw
      The code is set to draw 1000 walks of 1000 steps ; this correspong roughly to 250 Mb of memory used.

      f_automatic contains a call to Threads:-Sleep to delay the display, the argument of Sleep is set to 0.25 second and must be modified within the procedure (its value could be passed to f_automatic as an argument).

      In my opinion it is the more interesting of the two procedures.
       

    The values of the current mean and standard deviation are displayed as title.

    The purpose is before all educative and can be seen as an illustration of the (one of) Central Limit Theorem(s) (CLT)

    A little bit of theory:
    Let X[n] the position of the drunkhard after n steps; his position X[n+1] is either X[n]-1 or X[n]+1 with equal probabilities.
    The displacement X[n+1]-X[n] is a discrete random variable S with outcomes -1 and +1 and it's easy to find its variance is equal to 1.
    The position of the trunkard after n steps is just a realization of the n independant and identically distributed, random variables S1, ...Sn whose distribibution is equal to the one of S.
    Thus :

    • Expectation (S1 + ... +Sn)  = 0 
    • Variance (S1 + ... +Sn)  = n 
      For n=1000 steps, the standard deviation of the arrivals is about 31.6)

    CLT says that the distribution of S1 + ... +Sn  tends to a Gaussian distribution as n tends to infinity.

    What is the exact distribution of the arrivals?
    Another way to represent S is to write S = 2*B-1 where B is a Bernoulli random variable with parameter 1/2. The random variable "Arrival" is  twice the sum of N indpendent rabdom variables such like S 
    and thus its distribution is 2*Binomial(N, 1/2)-N.

    What is the rate of convergence of the histogram to the true probability function?
    For a sample of size N drawn from a continuous random variables, its histogram has:

    • a bias error of order 1/K (K being the number of bins)
    • a Linfinity error of order  K*sqrt( log(K) / M )  (M number of drunkhard's walks)
      see for instance Lec2_density.pdf

    Using the option Discrete=true corresponds to the choice K=2*N+1, in this case the choice with the highest Linfinity error (the larger K the smaller the bias but the larger the  Linfinity error).
    This is the reason I introduced the possibility to graw histograms and bar (column) graphs: for the same value of M the Linfinity error of the histogram (for instance with the default number of bins Maple uses) is nuch slower than the one of the comumn graph.



    A few "internal" parameters.
    I already spoke about the delay to display txo succesive walks.
    Other parameters could be:

    • The value of minbins in the case discrete=false (default)
      This value is fixed to 2*sqrt(M).
       
    • The width in the "view" option of the plot: it's left part displays the drunkhard's walk and it's right one the histogram of the arrivals (after a rotation of -Pi/2). 
      This value si fixed to 5/4*M.
      Note that the histogram is dynamically rescaled in order it's height is always 1/4*number_of_steps.
       
    • The height of the view option is set to -Q..Q where Q is equal to 4 standard deviations of the theoritical distribution of the arrivals.
      The continuous envelope of this distribution is red plotted in red (its height is normalized to M/4, see above). 
      One can show this standard deviation iverifies sqrt(M).
      In my opinion using a full vertical scale (-M..M) doesn't give pretty drunkward's walkes because they seem to more concentrated around the value 0.
       



    WATCHOUT
    Starting from 0 any walk with an odd number of steps will give an odd arrival and any walk with an even number of steps will give an even arrival. Thus the exact number of outcomes for the arrivals are:

    • 2*n if n is odd
    • 2*n-1 if n is even
       


    Other application
    This maplet can be used as illustration of the Galton Board (also known as the Bean_machine)


    Why using maplets?
    Another solution could have been to use animate. But to draw the M drunkard's walks, you would have had to use M frames. An excessive task that I'm not even sure Maple would have been able to handle.
    I guess that imbeded components could do the job too, but I'm not as comfortable with them as I am with maplets.

    To illustrate what the code does an image of the final result is given below.

    Drunkard_walk.mw

    'Export as pdf' is not one of the  'Export as' options on  a Mac. Instead, you should follow these instructions, from

    ?pdf:

     
    1. Open the worksheet that you want to export.
    2. From the File menu, select Print.
    3. Specify options for export to PDF as described in Section Options for Export to PDF below.
    4. From the PDF drop-down list, select Save as PDF...
    5. In the Save As dialog, enter a filename.
    Click Save.

     

    I am testing Maple 2020.2 with new Latex with Physics version latest 879.

    The latex generated now issues \! between the symbol and the () next to it to improve the spacing. This post is just to let anyone using the package mleftright in Latex, that this will cause a problem. So it is better to remove this package if you are allready using it.

    Here is an example

    eq:=y(x)=exp(x/2);
    Latex(eq)
    
                  y \! \left(x \right) = {\mathrm e}^{\frac{x}{2}}

    In earlier version of Physics:-Latex (now it is just Latex), the above generated this

                 y  \left(x \right) = {\mathrm e}^{\frac{x}{2}}

    Notice, no \! in earlier version.

    If you happen to be using \usepackage{mleftright} to improve the spacing for \left and \right, which I was using, you'll get negative side effect. A solution is to remove this package. Here is an example showing the above Latex compiled with this package added, and without it, so you can see the differerence.

    \documentclass[12pt]{book}
    \usepackage{amsmath} 
    \usepackage{mleftright}
    \mleftright
    \begin{document}
    
    With the package mleftright loaded
    
    which gives using latest Latex V 879. Maple 2020.2
    \[
      y \! \left(x \right) = {\mathrm e}^{\frac{x}{2}}
    \]
                
    And which gives using earlier Physics Latex. Using Maple 2020.1
    \[
      y \left(x \right) = {\mathrm e}^{\frac{x}{2}}
    \]
    \end{document}

    This is the output without using this package. by removing the inlcude command in the above Latex code and not calling mlfright. Now the problem is gone:

    I like the effect added from \! , which is a manual way to improve the space, which this package was doing.

    just be careful not to use mleftright package now, which is a somewhat popular package in latex and It was recommended to use sometime ago to improve the spacing, as it will over correct the spacing, and looks like not needed any more with latest Maple Latex.

     

     

    We have just released updates to Maple and MapleSim.

    Maple 2020.2 includes corrections and improvements to printing and export to PDF, support for macOS 11.0, more MATLAB connectivity, resolves issues with the installation of the Maplesoft Physics Updates, and more.  We recommend that all Maple 2020 users install these updates.

    This update is available through Tools>Check for Updates in Maple, and is also available from our website on the Maple 2020.2 download page, where you can also find more details.

    If you are also a MapleSim user, this Maple update will be installed automatically when you update your MapleSim installation to the newly released MapleSim 2020.2. The MapleSim update also includes many updates to MapleSim, the MapleSim CAD Toolbox, specialized MapleSim libraries, MapleSim connectivity tools, and MapleSim Insight.  You will find details about new features and improvements, as well as instructions on obtaining the update, on the MapleSim 2020.2 page.


    One forum had a topic related to such a platform. ( Edited: the video is no longer available.)

    The manufacturer calls the three-degrees platform, that is, having three degrees of freedom. Three cranks rotate, and the platform is connected to them by connecting rods through ball joints. The movable beam (rocker arm) has torsion springs.  I counted 4 degrees of freedom, because when all three cranks are locked, the platform remains mobile, which is camouflaged by the springs of the rocker arm. Actually, the topic on the forum arose due to problems with the work of this platform. Neither the designers nor those who operate the platform take into account this additional fourth, so-called parasitic degree of freedom. Obviously, if we will to move the rocker with the locked  cranks , the platform will move.
    Based on this parasitic movement and a similar platform design, a very simple device is proposed that has one degree of freedom and is, in fact, a spatial linkage mechanism. We remove 3 cranks, keep the connecting rods, convert the rocker arm into a crank and get such movements that will not be worse (will not yield) to the movements of the platform with 6 degrees of freedom. And by changing the length of the crank, the plane of its rotation, etc., we can create simple structures with the required design trajectories of movement and one degree of freedom.
    Two examples (two pictures for each example). The crank rotates in the vertical plane (side view and top view)
    PLAT_1.mw


    and the crank rotates in the horizontal plane (side view and top view).

    The program consists of three parts. 1 choice of starting position, 2 calculation of the trajectory, 3 design of the picture.  Similar to the programm  in this topic.

     

     

    It would be useful if there was a category (or subcategory) of scientific domain (e.g. physics, methematics, economics...)  in which Maple is applied. Thus it would become very convinient for someone who have a question on a specific topic to find a possible answer. 

    I like how the Julia community has been organised in https://discourse.julialang.org, so I would suggest to implement something similar in Maple Primes

    When this question was asked here earlier, I neglected to suggest or to emphasize two further items.  Now, on revising Mathematics for Chemistry with [Maple], I recognise that I should have included these two objectives for inclusion in Maple 2021.

    - an extended and improved spreadsheet with symbolic capability; I suspect that Maple was the only software for symbolic computation to include such a facility, which sadly has become deprecated, for no obvious reason.

    - a much extended capability to solve integral equations; publications dating from 1976 -- i.e. before Maple! -- have shown what is possible; Maple's capabilities for differential equations might still be superior, although the competition is becoming close, so further efforts in the development of both differential and integral equations are timely and appropriate.  Related to differential equations is naturally the extension of capabilities of special functions, both to extend present functions and to produce new functions, such as those of Lame.

    I created a little procedure to automatically size text areas based on content. It sizes the text area based on wraparound and tab characters, something that the autosize for the code edit region does not do. (Hint to Maple developers)

    Enjoy.

        AutosizeTextArea:=proc(TextAreaName, {intMinRows::nonnegint:=5, intMinChars::nonnegint:=50, intMaxChars::nonnegint:=140})
            description "Autosizes the TextArea based on content",
                      "Parameters",
                      "1) TextAreaName__The name of the textarea",
                      "Optional Parameters",
                      "intMinRows________Minimum number of visible rows",
                      "intMinChars_______Minimum character width",
                      "intMaxChars_______Maximum character width";
            uses DocumentTools, StringTools;          
            local strLines, intLongestLine, nLines;
            strLines := Split(GetProperty(TextAreaName,'value'),"\n");
            intLongestLine := max('numelems'~(strLines));
            # Count the characters in each line (add 7 extra characters for each tab). Determine the number of lines to display each line due to wraparound, then add all these together
            #   to determine the number of rows to display.
            nLines := add(ceil~(('numelems'~(strLines) + StringTools:-CountCharacterOccurrences~(strLines, "\t")*~7)/~intMaxChars));
            SetProperty(TextAreaName, 'visibleRows', max(nLines, intMinRows), 'refresh' = true);
            SetProperty(TextAreaName, 'visibleCharacterWidth', min(max(intLongestLine, intMinChars),intMaxChars), 'refresh' = true);
        
        end proc:

    A fascinating race is presently running (even if the latest results seem  to have put an end to it).
    I'm talking of course about the US presidential elections.

    My purpose is not to do politics but to discuss of a point of detail that really left me puzzled: the possibility of an electoral college tie.
    I guess that this possibility seems as an aberration for a lot of people living in democratic countries. Just because almost everywhere at World electoral colleges contain an odd number of members to avoid such a situation!

    So strange a situation that I did a few things to pass the time (of course with the earphones on the head so I don't miss a thing).
    This is done with Maple 2015 and I believe that the amazing Iterator package (that I can't use thanks to the teleworking :-( ) could be used to do much more interesting things.

     

    restart:

    with(Statistics):

    ElectoralCollege := Matrix(51, 2, [

    Alabama,        9,        Kentucky,        8,        North_Dakota,        3,

    Alaska,        3,        Louisiana,        8,        Ohio,        18,

    Arizona,        11,        Maine,        4,        Oklahoma,        7,

    Arkansas,        6,        Maryland,        10,        Oregon,        7,

    California,        55,        Massachusetts,        11,        Pennsylvania,        20,

    Colorado,        9,        Michigan,        16,        Rhode_Island,        4,

    Connecticut,        7,        Minnesota,        10,        South_Carolina,        9,

    Delaware,        3,        Mississippi,        6,        South_Dakota,        3,

    District_of_Columbia,        3,        Missouri,        10,        Tennessee,        11,

    Florida,        29,        Montana,        3,        Texas,        38,

    Georgia,        16,        Nebraska,        5,        Utah,        6,

    Hawaii,        4,        Nevada,        6,        Vermont,        3,

    Idaho,        4,        New_Hampshire,        4,        Virginia,        13,

    Illinois,        20,        New_Jersey,        14,        Washington,        12,

    Indiana,        11,        New_Mexico,        5,        West_Virginia,        5,

    Iowa,        6,        New_York,        29,        Wisconsin,        10,

    Kansas,        6,        North_Carolina,        15,        Wyoming,        3
    ]):
     

    ElectoralCollege := Vector(4, {(1) = ` 51 x 2 `*Matrix, (2) = `Data Type: `*anything, (3) = `Storage: `*rectangular, (4) = `Order: `*Fortran_order})

    (1)

    add(ElectoralCollege[..,2]):
    tie := %/2;

    269

    (2)

    ec := convert(ElectoralCollege, listlist):

    # Sets of states that form an electoral college tie

    R      := 10^5:
    nbties := 0:
    states := NULL:
    for r from 1 to R do
      poll  := combinat:-randperm(ec):
      cpoll := CumulativeSum(op~(2, poll)):
      if tie in cpoll then
        nbties := nbties+1;
        place  := ListTools:-Search(tie, cpoll);
        states := states, op~(1, poll)[1..place]:   # see below
      end if:
    end do:

    # electoral college tie is not so rare an event
    # (prob of occurrence about 9.4 %).
    #
    # Why the hell the US constitution did not decide to have an odd
    # number or electors to avoid ths kind of situation instead of
    # introducing a complex mechanism when tie appears????

    nbties;
    evalf(nbties/R);

    states := [states]:

    9397

     

    0.9397000000e-1

    (3)

    # What states participate to the tie?

    names := sort(ElectoralCollege[..,1]):

    all_states_in_ties := [op(op~(states))]:

    howoften := Vector(
                        51,
                        i -> ListTools:-Occurrences(names[i], all_states_in_ties)
                ):

    ScatterPlot(Vector(51, i->i), howoften);

     

    # All the states seem to appear equally likely in an electoral college tie.
    # Why? Does someone have a guess?
    #
    # The reason is obvious, as each state must appear in the basket of a candidate,
    # then in case of a tie each state is either in op~(1, poll)[1..place] (candidate 1)
    # or either in op~(1, poll)[place+1..51] (candidate 2);
    # So, as we obtained 9397 ties, each states appears exactly 9397 times (with
    # different occurences in the baskets of candidate 1 and 2).

     

    # Lengths of the configurations that lead to a tie.
    #
    # Pleas refer to the answer above to understand why Histogram(lengths) should be
    # symmetric.
    lengths := map(i -> numelems(states[i]), [$1..nbties]):
    sort(Tally(lengths))

    [14 = 1, 15 = 2, 16 = 7, 17 = 36, 18 = 78, 19 = 179, 20 = 341, 21 = 507, 22 = 652, 23 = 849, 24 = 1015, 25 = 1041, 26 = 1056, 27 = 997, 28 = 862, 29 = 657, 30 = 515, 31 = 300, 32 = 158, 33 = 95, 34 = 41, 35 = 6, 36 = 2]

    (4)

    Histogram(lengths, range=min(lengths)..max(lengths), discrete=true)

     

    ShortestConfigurations := map(i -> if lengths[i]=min(lengths) then states[i] end if, [$1..nbties]):
    print~(ShortestConfigurations):

    [New_York, Wisconsin, Illinois, Kentucky, Florida, New_Jersey, Mississippi, Indiana, Virginia, Maryland, California, Massachusetts, North_Carolina, Texas]

    (5)

    LargestConfigurations := map(i -> if lengths[i]=max(lengths) then states[i] end if, [$1..nbties]):
    print~(LargestConfigurations):

    [Alaska, Tennessee, North_Carolina, South_Carolina, District_of_Columbia, Colorado, Minnesota, Georgia, South_Dakota, New_Hampshire, Wyoming, Ohio, Rhode_Island, Arizona, Delaware, Montana, West_Virginia, Vermont, Michigan, Kentucky, Louisiana, Arkansas, Maine, Missouri, New_Mexico, Virginia, Maryland, Oregon, Wisconsin, Iowa, Kansas, Connecticut, North_Dakota, Nevada, Hawaii, Oklahoma]

     

    [West_Virginia, Maryland, Massachusetts, Colorado, South_Dakota, Kentucky, Kansas, Wyoming, North_Dakota, Indiana, Michigan, Utah, Louisiana, Ohio, Alabama, Nebraska, Connecticut, Illinois, Oklahoma, Alaska, New_Jersey, District_of_Columbia, Oregon, Nevada, Missouri, Delaware, Washington, New_Hampshire, Arizona, Maine, South_Carolina, Hawaii, Vermont, Montana, Rhode_Island, Idaho]

    (6)

    # What could be the largest composition of a basket in case of a tie?
    # (shortest composition is the complementary of the largest one)

    ecs   := sort(ec, key=(x-> x[2]));
    csecs := CumulativeSum(op~(2, ecs)):

    # Where would the break locate?

    tieloc := ListTools:-BinaryPlace(csecs, tie);

    csecs[tieloc..tieloc+1]

    [[North_Dakota, 3], [Alaska, 3], [Delaware, 3], [South_Dakota, 3], [District_of_Columbia, 3], [Montana, 3], [Vermont, 3], [Wyoming, 3], [Maine, 4], [Rhode_Island, 4], [Hawaii, 4], [Idaho, 4], [New_Hampshire, 4], [Nebraska, 5], [New_Mexico, 5], [West_Virginia, 5], [Arkansas, 6], [Mississippi, 6], [Utah, 6], [Nevada, 6], [Iowa, 6], [Kansas, 6], [Oklahoma, 7], [Oregon, 7], [Connecticut, 7], [Kentucky, 8], [Louisiana, 8], [Alabama, 9], [Colorado, 9], [South_Carolina, 9], [Maryland, 10], [Minnesota, 10], [Missouri, 10], [Wisconsin, 10], [Arizona, 11], [Massachusetts, 11], [Tennessee, 11], [Indiana, 11], [Washington, 12], [Virginia, 13], [New_Jersey, 14], [North_Carolina, 15], [Michigan, 16], [Georgia, 16], [Ohio, 18], [Pennsylvania, 20], [Illinois, 20], [Florida, 29], [New_York, 29], [Texas, 38], [California, 55]]

     

    40

     

    Array(%id = 18446744078888202358)

    (7)

    # This 40  states coniguration is not a tie.
    #
    # But list all the states in basket of candidate 1 and look to the 41th state (which is
    # in the basket of candidate 2)

    ecs[1..tieloc];
    print():
    ecs[tieloc+1]

    [[North_Dakota, 3], [Alaska, 3], [Delaware, 3], [South_Dakota, 3], [District_of_Columbia, 3], [Montana, 3], [Vermont, 3], [Wyoming, 3], [Maine, 4], [Rhode_Island, 4], [Hawaii, 4], [Idaho, 4], [New_Hampshire, 4], [Nebraska, 5], [New_Mexico, 5], [West_Virginia, 5], [Arkansas, 6], [Mississippi, 6], [Utah, 6], [Nevada, 6], [Iowa, 6], [Kansas, 6], [Oklahoma, 7], [Oregon, 7], [Connecticut, 7], [Kentucky, 8], [Louisiana, 8], [Alabama, 9], [Colorado, 9], [South_Carolina, 9], [Maryland, 10], [Minnesota, 10], [Missouri, 10], [Wisconsin, 10], [Arizona, 11], [Massachusetts, 11], [Tennessee, 11], [Indiana, 11], [Washington, 12], [Virginia, 13]]

     

     

    [New_Jersey, 14]

    (8)

    # It appears that exchanging Virginia and New_Jersey increases by 1 unit the college of candidate 1
    # and produces a tie.

    LargestBasketEver := [ ecs[1..tieloc-1][], ecs[tieloc+1] ];

    add(op~(2, LargestBasketEver))

    [[North_Dakota, 3], [Alaska, 3], [Delaware, 3], [South_Dakota, 3], [District_of_Columbia, 3], [Montana, 3], [Vermont, 3], [Wyoming, 3], [Maine, 4], [Rhode_Island, 4], [Hawaii, 4], [Idaho, 4], [New_Hampshire, 4], [Nebraska, 5], [New_Mexico, 5], [West_Virginia, 5], [Arkansas, 6], [Mississippi, 6], [Utah, 6], [Nevada, 6], [Iowa, 6], [Kansas, 6], [Oklahoma, 7], [Oregon, 7], [Connecticut, 7], [Kentucky, 8], [Louisiana, 8], [Alabama, 9], [Colorado, 9], [South_Carolina, 9], [Maryland, 10], [Minnesota, 10], [Missouri, 10], [Wisconsin, 10], [Arizona, 11], [Massachusetts, 11], [Tennessee, 11], [Indiana, 11], [Washington, 12], [New_Jersey, 14]]

     

    269

    (9)

    # The largest electoral college tie contains 40 states (the shortest 11)


     

    Download ElectoralCollegeTie.mw

    Controlled platform with 6 degrees of freedom. It has three rotary-inclined racks of variable length:

    and an example of movement parallel to the base:

    Perhaps the Stewart platform may not reproduce such trajectories, but that is not the point. There is a way to select a design for those specific functions that our platform will perform. That is, first we consider the required trajectories of the platform movement, and only then we select a driving device that can reproduce them. For example, we can fix the extreme positions of the actuators during the movement of the platform and compare them with the capabilities of existing designs, or simulate your own devices.
    In this case, the program consists of three parts. (The text of the program directly for the first figure : PLATFORM_6.mw) In the first part, we select the starting point for the movement of a rigid body with six degrees of freedom. Here three equations f6, f7, f8 are responsible for the six degrees of freedom. The equations f1, f2, f3, f4, f5 define a trajectory of motion of a rigid body. The coordinates of the starting point are transmitted via disk E for the second part of the program. In the second part of the program, the trajectory of a rigid body is calculated using the Draghilev method. Then the trajectory data is transferred via the disk E for the third part of the program.
    In the third part of the program, the visualization is executed and the platform motion drive device is modeled.
    It is like a sketch of a possible way to create controlled platforms with six degrees of freedom. Any device that can provide the desired trajectory can be inserted into the third part. At the same time, it is obvious that the geometric parameters of the movement of this device with the control of possible emergency positions and the solution of the inverse kinematics problem can be obtained automatically if we add the appropriate code to the program text.
    Equations can be of any kind and can be combined with each other, and they must be continuously differentiable. But first, the equations must be reduced to uniform variables in order to apply the Draghilev method.
    (These examples use implicit equations for the coordinates of the vertices of the triangle.)

    First 32 33 34 35 36 37 38 Last Page 34 of 308