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
  • Hi, 

    This is more of an open discussion than a real question. Maybe it would gain to be displaced in the post section?

    Working with discrete random variables I found several inconsistencies or errors.
    In no particular order: 

    • The support of a discrete RV is not defined correctly (a real range instead of a countable set)
    • The plot of the probability function (which, in my opinion, would gain to be renamed "Probability Mass Function, see https://en.wikipedia.org/wiki/Probability_mass_function) is not correct.
    • The  ProbabiliytFunction of a discrte rv of EmpiricalDistribution can be computed at any point, but its formal expression doesn't exist (or at least is not accessible).
    • Defining the discrete rv "toss of a fair dice"  with EmpiricalDistribution and DiscreteUniform gives different results.


    The details are given in the attached file and I do hope that the companion text is clear enough to point the issues.
    I believe there is no major issues here, but that Maple suffers of some lack of consistencies in the treatment of discrete (at least some) rvs. Nothing that could easily be fixed.


    As I said above, if some think this question has no place here and ought to me moved to the post section, please feel free to do it.

    Thanks for your attention.


     

    restart:

    with(Statistics):


    Two alternate ways to define a discrete random variable on a finite set
    of equally likely outcomes.

    Universe    := [$1..6]:
    toss_1_dice := RandomVariable(EmpiricalDistribution(Universe));
    TOSS_1_DICE := RandomVariable(DiscreteUniform(1, 6));

    _R

     

    _R0

    (1)


    Let's look to the ProbabilityFunction of each RV

    ProbabilityFunction(toss_1_dice, x);
    ProbabilityFunction(TOSS_1_DICE, x);

    "_ProbabilityFunction[Typesetting:-mi("x",italic = "true",mathvariant = "italic")]"

     

    piecewise(x < 1, 0, x <= 6, 1/6, 6 < x, 0)

    (2)


    It looks like the procedure ProbabilityFunction is not an attribute of RV with EmpiticalDistribution.
    Let's verify

    law := [attributes(toss_1_dice)][3]:
    lprint(exports(law))

    Conditions, ParentName, Parameters, CDF, DiscreteValueMap, Mean, Median, Mode, ProbabilityFunction, Quantile, Specialize, Support, RandomSample, RandomVariate

     


    Clearly ProbabilityFunction is an attribute of toss_1_dice.

    In fact it appears the explanation of the difference of behaviours relies upon different definitions
    of the set of outcomes of toss_1_dice and TOSS_1_DICE

    LAW := [attributes(TOSS_1_DICE)][3]:
    exports(LAW):

    law:-Conditions;
    LAW:-Conditions;

    [(Vector(6, {(1) = 1, (2) = 2, (3) = 3, (4) = 4, (5) = 5, (6) = 6}))::rtable]

     

    [1 < 6]

    (3)


    From :-Conditions one can see that toss_1_dice is realy a discrete RV defined on a countable set of outcomes,
    but that nothing is said about the set over which TOSS_1_DICE is defined.

    The truly discrete definition of toss_1_dice is confirmed here :
    (the second result is correct

    ProbabilityFinction(toss_1_dice, x) = {0 if x < 1, 0 if x > 6, 1/6 if x::integer, 0 otherwise

    ProbabilityFunction~(toss_1_dice, Universe);
    ProbabilityFunction~(toss_1_dice, [seq(0..7, 1/2)]);

    [1/6, 1/6, 1/6, 1/6, 1/6, 1/6]

     

    [0, 0, 1/6, 0, 1/6, 0, 1/6, 0, 1/6, 0, 1/6, 0, 1/6, 0, 0]

    (4)


    One can also see that the Support of both of these RVs are wrong

    (see for instance https://en.wikipedia.org/wiki/Discrete_uniform_distribution)

    There should be {1, 2, 3, 4, 5, 6}, not a RealRange.

    Support(toss_1_dice);
    Support(TOSS_1_DICE);

    RealRange(1, 6)

     

    RealRange(1, 6)

    (5)

     

    0

     

    {1, 2, 3, 4, 5, 6}

     

     


    Now this is the surprising ProbabilityFunction of TOSS_1_DICE.
    This obviously wrong result probably linked to the weak definition of the conditions for this RB.

    # plot(ProbabilityFunction(TOSS_1_DICE, x), x=0..7);
    plot(ProbabilityFunction(TOSS_1_DICE, x), x=0..7, discont=true)

     


    These differences of treatments raise a lot of questions :
        -  Why is a DiscreteUniform RV not defined on a countable set?
        -  Why does the ProbabilityFunction of an EmpiricalDistribution return no result
            if its second parameter is not set to one  its outcomes.

     All this without even mentioning the wrong plot shown above.
     

    I believe something which would work like the module below would be much better than what is done

    right now

     

    EmpiricalRV := module()
    export MassDensityFunction, PlotMassDensityFunction, Support:

    MassDensityFunction := proc(rv, x)
      local u, v, N:
      u := [attributes(rv)][3]:
      if u:-ParentName = EmpiricalDistribution then
        v := op([1, 1], u:-Conditions);
        N := numelems(v):
        return piecewise(op(op~([seq([x=v[n], 1/N], n=1..N)])), 0)
      else
        error "The random variable does not have an EmpiricalDistribution"
      end if
    end proc:

    PlotMassDensityFunction := proc(rv, x1, x2)
      local u, v, a, b:
      u := [attributes(rv)][3]:
      if u:-ParentName = EmpiricalDistribution then
        v := op([1, 1], u:-Conditions);
        a := select[flatten](`>=`, v, x1);
        b := select[flatten](`<=`, a, x2);
        PLOT(seq(CURVES([[n, 0], [n, 1/numelems(v)]], COLOR(RGB, 0, 0, 1), THICKNESS(3)), n in b), VIEW(x1..x2, default))
      else
        error "The random variable does not have an EmpiricalDistribution"
      end if
    end proc:

    Support := proc(rv, x1, x2)
      local u, v, a, b:
      u := [attributes(rv)][3]:
      if u:-ParentName = EmpiricalDistribution then
        v := op([1, 1], u:-Conditions);
        return {entries(v, nolist)}
      else
        error "The random variable does not have an EmpiricalDistribution"
      end if
    end proc:

    end module:
     

    EmpiricalRV:-MassDensityFunction(toss_1_dice, x);
     

    piecewise(x = 1, 1/6, x = 2, 1/6, x = 3, 1/6, x = 4, 1/6, x = 5, 1/6, x = 6, 1/6, 0)

    (6)

    f := unapply(EmpiricalRV:-MassDensityFunction(toss_1_dice, x), x):
    f(2);
    f(5/2);
     

    1/6

     

    0

    (7)

    EmpiricalRV:-PlotMassDensityFunction(toss_1_dice, 0, 7);

     

     


     

    Download Discrete_RV.mw

     

     

    We need a check-off box for Maple Companion in the Products category of Question and Post headers.

    While you're looking at that, there's also a bug that the Product indication gets stripped off when converting a Post to a Question, which is a common Moderator action.

    Here is two solutions with Maple of the problem A2 of  Putnam Mathematical Competition 2019 . The first solution is entirely based on the use of the  geometry  package; the second solution does not use this package. Since the triangle is defined up to similarity, without loss of generality, we can set its vertices  A(0,0) , B(1,0) , C(x0,y0)  and then calculate the parameters  x0, y0  using the conditions of the problem. 


     

    The problem

    A2: In the triangle ∆ABC, let G be the centroid, and let I be the center of the
    inscribed circle. Let α and β be the angles at the vertices A and B, respectively.
    Suppose that the segment IG is parallel to AB and that  β = 2*arctan(1/3).  Find α.
     

    # Solution 1 with the geometry package
    restart;

    # Calculation

    with(geometry):
    local I:
    point(A,0,0): point(B,1,0): point(C,x0,y0):
    assume(y0>0,-y0*(-1+x0-((1-x0)^2+y0^2)^(1/2))+y0*((x0^2+y0^2)^(1/2)+x0) <> 0):
    triangle(t,[A,B,C]):
    incircle(ic,t, 'centername'=I):
    Cn:=coordinates(I):
    centroid(G,t):
    CG:=coordinates(G):
    a:=-expand(tan(2*arctan(1/3))):
    solve({Cn[2]=CG[2],y0/(x0-1)=a}, explicit);
    point(C,eval([x0,y0],%)):
    answer=FindAngle(line(AB,[A,B]),line(AC,[A,C]));

    # Visualization (G is the point of medians intersection)

    triangle(t,[A,B,C]):
    incircle(ic,t, 'centername'=I):
    centroid(G,t):
    segment(s,[I,G]):
    median(mB,B,t): median(mC,C,t):
    draw([A(symbol=solidcircle,color=black),B(symbol=solidcircle,color=black),C(symbol=solidcircle,color=black),I(symbol=solidcircle,color=green),G(symbol=solidcircle,color=blue),t(color=black),s(color=red,thickness=2),ic(color=green),mB(color=blue,thickness=0),mC(color=blue,thickness=0)], axes=none, size=[800,500], printtext=true,font=[times,20]);

    I

     

    Warning, The imaginary unit, I, has been renamed _I

     

    Warning, solve may be ignoring assumptions on the input variables.

     

    {x0 = 0, y0 = 3/4}

     

    answer = (1/2)*Pi

     

     


    # Solution 2 by a direct calculation

    # Calculation

    restart;
    local I;
    sinB:=y0/sqrt(x0^2+y0^2):
    cosB:=x0/sqrt(x0^2+y0^2):
    Sol1:=eval([x,y],solve({y=-(x-1)/3,y=(sinB/(1+cosB))*x}, {x,y})):
    tanB:=expand(tan(2*arctan(1/3))):
    Sol2:=solve({y0/3=Sol1[2],y0=-tanB*(x0-1)},explicit);
    A:=[0,0]: B:=[1,0]: C:=eval([x0,y0],Sol2[2]):
    AB:=<(B-A)[]>: AC:=<(C-A)[]>:
    answer=arccos(AB.AC/sqrt(AB.AB)/sqrt(AC.AC));

    # Visualization

    with(plottools): with(plots):
    ABC:=curve([A,B,C,A]):
    I:=simplify(eval(Sol1,Sol2[2]));
    c:=circle(I,eval(Sol1[2],Sol2[2]),color=green):
    G:=(A+B+C)/~3;
    IG:=line(I,G,color=red,thickness=2):
    P:=pointplot([A,B,C,I,G], color=[black$3,green,blue], symbol=solidcircle):
    T:=textplot([[A[],"A"],[B[],"B"],[C[],"C"],[I[],"I"],[G[],"G"]], font=[times,20], align=[left,below]):
    M:=plot([[(C+t*~((A+B)/2-C))[],t=0..1],[(B+t*~((A+C)/2-B))[],t=0..1]], color=blue, thickness=0):
    display(ABC,c,IG,P,T,M, scaling=constrained, axes=none,size=[800,500]);

    I

     

    Warning, The imaginary unit, I, has been renamed _I

     

    {x0 = 1, y0 = 0}, {x0 = 0, y0 = 3/4}

     

    answer = (1/2)*Pi

     

    [1/4, 1/4]

     

    [1/3, 1/4]

     

     

     


     

    Download Putnam.mw

     

    Maple can easily solve the B4 problem of the Putnam Mathematical Competition 2019  link

     

    B4.  Let F be the set of functions f(x,y) that are twice continuously differentiable for x≥1, y≥1 and that satisfy the following two equations:
        x*(diff(f(x, y), x))+y*(diff(f(x, y), y)) = x*y*ln(x*y)

    x^2*(diff(f(x, y), x, x))+y^2*(diff(f(x, y), y, y)) = x*y

     

    For each f2F, let

     

    "m(f) = min[s>=1]  (f(s+1,s+1)-f(s+1,s)-f(s,s+1)+f(s,s))"

     

    Determine m(f), and show that it is independent of the choice of f.


     

    # Solution

    pdsolve({
    x*diff(f(x,y),x)+y*diff(f(x,y),y) = x*y*ln(x*y),
    x^2*diff(f(x,y),x,x)+y^2*diff(f(x,y),y,y) = x*y
    });

    {f(x, y) = (1/2)*(x*y+2*_C1)*ln(x*y)-(1/2)*x*y-2*_C1*ln(x)+_C2}

    (1)

    f:=unapply(rhs(%[]), x,y);

    proc (x, y) options operator, arrow; (1/2)*(y*x+2*_C1)*ln(y*x)-(1/2)*y*x-2*_C1*ln(x)+_C2 end proc

    (2)

    h := f(s+1, s+1) - f(s+1, s) - f(s, s+1) + f(s, s);

    (1/2)*((s+1)^2+2*_C1)*ln((s+1)^2)-(1/2)*(s+1)^2-(s*(s+1)+2*_C1)*ln(s*(s+1))+s*(s+1)+(1/2)*(s^2+2*_C1)*ln(s^2)-(1/2)*s^2

    (3)

    minimize(h, s=1..infinity);

    (4+2*_C1)*ln(2)-1/2-(2+2*_C1)*ln(2)

    (4)

    answer = simplify(%);

    answer = 2*ln(2)-1/2

    (5)

     


    Download putnam2019-b4.mw

    Hi, 

    As an amusement,  I decided several months ago to develop some procedures to fill a simple polygon* by hatches or simple textures.

    * A simple polygon is a polygon  whose sides either do not intersect or either have a common vertex.

    This work started with the very simple observation that if I was capable to hatch or texture a triangle, I will be too to hatch or texture any simple polygon once triangulated.
    I also did some work to extend this work to non-simple polygons but there remains some issues to fix (which explains while it is not deliverd here).

    The main ideat I used for hatching and texturing is based upon the description of each triangles by a set of 3 inequalities that any interior point must verify.
    A hatch of this triangle is thius a segment whose each point is interior.
    The closely related idea is used for texturing. Given a simple polygon, periodically replicated to form the texture, the set of points of each replicate that are interior to a given triangle must verify a set of inequalities (the 3 that describe the triangle, plus N if the pattern of the texture is a simple polygon with N sides).

    Unfortunately I never finalise this work.
    Recently @Christian Wolinski asked a question about texturing that reminded me this "ancient" work of mine.
    So I decided to post it as it is, programatically imperfect, lengthy to run, and most of all french-written for a large part.
    I guess it is a quite unorthodox way to proceed but some here could be interested by this work to take it back and improve it.

    The module named "trianguler" (= triangulate) is a translation into Maple of Frederic Legrand's Python code (full reference given in the worksheet).
    I added my own procedure "hachurer" (= hatching) to this module.
    The texturing part is not included in this module for it was still in development.

    A lot of improvements can be done that I could list, but I prefer not to be too intrusive in your evaluation of this work. So make your own idea about it and do not hesitate to ask me any informations you might need (in particular translation questions).


    PS: this work has been done with Maple 2015.2
     

    restart:


    Reference: http://www.f-legrand.fr/scidoc/docmml/graphie/geometrie/polygone/polygone.html
                        (in french)
                        reference herein : M. de Berg, O. Cheong, M. van Kreveld, M. Overmars,  
                                                     Computational geometry,  (Springer, 2010)

    Direct translation of the Frederic Legrand's Python code


    Meaning of the different french terms

    voisin_sommet  (n, i, di)
            let L the list [1, ..., n] where n is the number of vertices
            This procedure returns the index of the neighbour (voisin) of the vertex (sommet) i when L is rotated by di

    equation_droite  (P0, P1, M)
            Let P0 and P1 two vertices and M an arbitrary point.
            Let (P0, P1) the vector originated at P0 and ending at P1 (idem for (P0, M)) and u__Z the unitary vector in the Z direction.
            This procedure returns (P0, P1) o (P0, M) . u__Z

    point_dans_triangle  (triangle, M) P1, P2]
            This procedure returns "true" if point M is within (strictly) the  triangle "triangle" and "false" if not.

    sommet_distance_maximale  (polygone, P0, P1, P2, indices)    
            Given a polygon (polygone) threes vertices P0, P1 and P2 and a list of indices , this procedure returns
            the vertex of the polygon "polygone" which verifies: 1/ this vertex is strictly within
            the triangle [P0, P1, P2] and 2/ it is the farthest from side [P1, P2] amid all the vertices that verifies point 1/.
            If there is no such vertex the procedure returns NULL.

    sommet_gauche (polygone)
            This procedure returns the index of the leftmost ("gauche" means "left") vertex in polygon "polygone".
            If more than one vertices have the same minimum abscissa value then only the first one is returned.

    nouveau_polygone(polygone,i_debut,i_fin)
            This procedure creates a new polygon from index i_debut (could be translated by i_first) to i_end (i_last)

    trianguler_polygone_recursif(polygone)
            This procedure recursively divides a polygon in two parts A and B from its leftmost vertex.
             If A (B) is a triangle the list "liste_triangles" (mening "list of triangles") is augmented by A (B);
             if not the procedure executes recursively on A and B.

    trianguler_polygone(polygone)
             This procedure triangulates the polygon "polygon"

    hachurer(shapes, hatch_angle, hatch_number, hatch_color)
             This procedure generates stes of hatches of different angles, colors and numbers


    Limitations:
       1/ "polygone" is a simply connected polygon
       2/  two different sides S and S', either do not intersect or either have a common vertex

    trianguler := module()
    export voisin_sommet, equation_droite, interieur_forme, point_dans_triangle, sommet_distance_maximale,
           sommet_gauche, nouveau_polygone, trianguler_polygone_recursif, trianguler_polygone, hachurer:

    #-------------------------------------------------------------------
    voisin_sommet := (n, i, di) -> ListTools:-Rotate([$1..n], di)[i]:



    #-------------------------------------------------------------------
    equation_droite := proc(P0, P1, M) (P1[1]-P0[1])*(M[2]-P0[2]) - (P1[2]-P0[2])*(M[1]-P0[1]) end proc:


    #-------------------------------------------------------------------
    interieur_forme := proc(forme, M)
      local N:
      N := numelems(forme);
      { seq( equation_droite(forme[n], forme[piecewise(n=N, 1, n+1)], M) >= 0, n=1..N) }
    end proc:


    #-------------------------------------------------------------------
    point_dans_triangle := proc(triangle, M)
      `and`(
              is( equation_droite(triangle[1], triangle[2], M) > 0 ),
              is( equation_droite(triangle[2], triangle[3], M) > 0 ),
              is( equation_droite(triangle[3], triangle[1], M) > 0 )
           )
    end proc:



    #-------------------------------------------------------------------
    sommet_distance_maximale := proc(polygone, P0, P1, P2, indices)
      local n, distance, j, i, M, d;

      n        := numelems(polygone):
      distance := 0:
      j        := NULL:

      for i from 1 to n do
        if `not`(member(i, indices)) then
          M := polygone[i];
          if point_dans_triangle([P0, P1, P2], M) then
            d := abs(equation_droite(P1, P2, M)):
            if d > distance then
              distance := d:
              j := i
            end if:
          end if:
        end if:
      end do:
      return j:
    end proc:


    #-------------------------------------------------------------------
    sommet_gauche := polygone -> sort(polygone, key=(x->x[1]), output=permutation)[1]:



    #-------------------------------------------------------------------
    nouveau_polygone := proc(polygone, i_debut, i_fin)
      local n, p, i:

      n := numelems(polygone):
      p := NULL:
      i := i_debut:

      while i <> i_fin do
        p := p, polygone[i]:
        i := voisin_sommet(n, i, 1)
      end do:
      p := [p, polygone[i_fin]]
    end proc:



    #-------------------------------------------------------------------
    trianguler_polygone_recursif := proc(polygone)
      local n, j0, j1, j2, P0, P1, P2, j, polygone_1, polygone_2:
      global liste_triangles:
      n  := numelems(polygone):
      j0 := sommet_gauche(polygone):
      j1 := voisin_sommet(n, j0, +1):
      j2 := voisin_sommet(n, j0, -1):
      P0 := polygone[j0]:
      P1 := polygone[j1]:
      P2 := polygone[j2]:
      j  := sommet_distance_maximale(polygone, P0, P1, P2, [j0, j1, j2]):

      if `not`(j::posint) then
        liste_triangles := liste_triangles, [P0, P1, P2]:
        polygone_1      := nouveau_polygone(polygone,j1,j2):
        if numelems(polygone_1) = 3 then
          liste_triangles := liste_triangles, polygone_1:
        else
          thisproc(polygone_1)
        end if:

      else
        polygone_1 := nouveau_polygone(polygone, j0, j ):
        polygone_2 := nouveau_polygone(polygone, j , j0):
        if numelems(polygone_1) = 3 then
          liste_triangles := liste_triangles, polygone_1:
        else
          thisproc(polygone_1)
        end if:
        if numelems(polygone_2) = 3 then
          liste_triangles := liste_triangles, polygone_2:
        else
          thisproc(polygone_2)
        end if:
      end if:

      return [liste_triangles]:
    end proc:


    #-------------------------------------------------------------------
    trianguler_polygone := proc(polygone)
      trianguler_polygone_recursif(polygone):
      return liste_triangles:
    end proc:


    #-------------------------------------------------------------------
    hachurer := proc(shapes, hatch_angle::list, hatch_number::list, hatch_color::list)

    local A, La, Lp;
    local N, P, _sides, L_sides, Xshape, ch, rel, p_rel, n, sol, p_range:
    local AllHatches, window, p, _segment:
    local NT, ka, N_Hatches, p_range_t, nt, shape, p_hatches, WhatHatches:

    #-----------------------------------------------------------------
    # internal functions:
    #
    # La(x, y, alpha, p) is the implicit equation of a straight line of angle alpha relatively
    #                    to the horizontal axis and intercept p
    #
    # Lp(x, y, P) is the implicit equation of a straight line passing through points P[1] and P[2]
    #
    # interieur_triangle(triangle, M)

    La := (x, y, alpha, p) -> cos(alpha)*x - sin(alpha)*y + p;
    Lp := proc(x, y, P::list) (x-P[1][1])*(P[2][2]-P[1][2]) - (y-P[1][2])*(P[2][1]-P[1][1] = 0) end proc;


    p_range    := [+infinity, -infinity]:
    NT         := numelems(shapes):

    AllHatches := NULL:

    for ka from 1 to numelems(hatch_angle) do
      A         := hatch_angle[ka]:
      N_Hatches := hatch_number[ka]:
      p_range_t := NULL:
      _sides    := []:
      L_sides   := []:
      rel       := []:
      for nt from 1 to NT do

        shape := shapes[nt]:
        # _sides  : two points description of the sides of the shape
        # L_sides : implicit equations of the straight lines that support the sides

        N        := [1, 2, 3];
        P        := [2, 3, 1];
        _sides   := [ _sides[] , [ seq([shape[n], shape[P[n]]], n in N) ] ];
        L_sides  := [ L_sides[], Lp~(x, y, _sides[-1]) ];

        # Inequalities that define the interior of the shape

        rel := [ rel[], trianguler:-interieur_forme(shape, [x, y]) ];
      
        # Given the orientation of the hatches we search here the extreme values of
        # the intercept p for wich a straight line of equation La(x, y, alpha, p)
        # cuts the shape.
        
        p_rel := NULL:
        
        for n from 1 to numelems(L_sides[-1]) do
          sol   := solve({La(x, y, A, q), lhs(L_sides[-1][n])} union rel[-1], [x, y]);
          p_rel := p_rel, `if`(sol <> [], [rhs(op(1, %)), rhs(op(3, %))], [+infinity, -infinity]);
        end do:
        p_range_t := p_range_t, evalf(min(op~(1, [p_rel]))..max(op~(2, [p_rel])));
        p_range   := evalf(min(op~(1, [p_rel]), op(1, p_range))..max(op~(2, [p_rel]), op(2, p_range)));

      end do: # end of the loop over triangles

      p_range_t := [p_range_t]:
      p_hatches := [seq(p_range, (op(2, p_range)-op(1, p_range))/N_Hatches)]:
      # Building of the hatches
      #
      # This construction is far from being optimal.
      # Here again the main goal was to obtain the hatches with a minimum effort
      # if algorithmic development.

      window      := min(op~(1..shape))..max(op~(1..shape)):
      WhatHatches := map(v -> map(u -> if verify(u, v, 'interval'('closed') ) then u end if, p_hatches), p_range_t):

      for nt from 1 to NT do
        for p in WhatHatches[nt] do
          _segment := []:
          for n from 1 to numelems(L_sides[nt]) do
             _segment := _segment, evalf( solve({La(x, y, A, p), lhs(L_sides[nt][n])} union rel[nt], [x, y]) );
          end do;
          map(u -> u[], [_segment]);
          AllHatches := AllHatches, plot(map(u -> rhs~(u), %), color=hatch_color[ka]):
        end do:
      end do;

    end do: # end of loop over hatch angles

    plots:-display(
      PLOT(POLYGONS(polygone, COLOR(RGB, 1$3))),
      AllHatches,
      scaling=constrained
    )

    end proc:

    end module:

     

    Legrand's example (see reference above)

     

     

    global liste_triangles:
    liste_triangles := NULL:

    polygone := [[0,0],[0.5,-1],[1.5,-0.2],[2,-0.5],[2,0],[1.5,1],[0.3,0],[0.5,1]]:

    trianguler:-trianguler_polygone(polygone):

    PLOT(seq(POLYGONS(u, COLOR(RGB, rand()/10^12, rand()/10^12, rand()/10^12)), u in liste_triangles), VIEW(0..2, -2..2))

     

    trianguler:-hachurer([liste_triangles], [-Pi/4, Pi/4], [40, 40], [red, blue])
     

     

    F := (P, a, b) -> map(p -> [p[1]+a, p[2]+b], P):

    MOTIF  := [[0, 0], [0.05, 0], [0.05, 0.05], [0, 0.05]];
    motifs := [ seq(seq(F(MOTIF, 0+i*0.075, 0+j*0.075), i=0..26), j=-14..13) ]:

    plots:-display(
      plot([polygone[], polygone[1]], color=red, filled),
      map(u -> plot([u[], u[1]], color=blue, filled, scaling=constrained), motifs)
    ):

    texture    := NULL:
    rel_motifs := map(u -> trianguler:-interieur_forme(u, [x, y]), motifs):
      
    for ref in liste_triangles do
      ref;
      #
      # the three lines below are used to define REF counter clockwise
      #
      g           := trianguler:-sommet_gauche(ref):
      bas         := sort(op~(2, ref), output=permutation);
      REF         := ref[[g, op(map(u -> if u<>g then u end if, bas))]];
      rel_ref     := trianguler:-interieur_forme(REF, [x, y]): #print(ref, REF, rel_ref);
      texture_ref := map(u -> plots:-inequal(rel_ref union u, x=0..2, y=-1..1, color=blue, 'nolines'), rel_motifs):
      texture     := texture, texture_ref:
    end do:

    plots:-display(
      plot([polygone[], polygone[1]], color=red, scaling=constrained),
      texture
    )

    [[0, 0], [0.5e-1, 0], [0.5e-1, 0.5e-1], [0, 0.5e-1]]

     

     

    MOTIF  := [[0, 0], [0.05, 0], [0.05, 0.05], [0, 0.05]];
    motifs := [ seq(seq(F(MOTIF, piecewise(j::odd, 0.05, 0.1)+i*0.1, 0+j*0.05), i=-0.2..20), j=-20..20) ]:
    plots:-display(
      plot([polygone[], polygone[1]], color=red, filled),
      map(u -> plot([u[], u[1]], color=blue, filled, scaling=constrained), motifs)
    ):

    texture    := NULL:
    rel_motifs := map(u -> trianguler:-interieur_forme(u, [x, y]), motifs):
      
    for ref in liste_triangles do
      ref;
      g := trianguler:-sommet_gauche(ref):
      bas := sort(op~(2, ref), output=permutation);
      REF := ref[[g, op(map(u -> if u<>g then u end if, bas))]];
      rel_ref     := trianguler:-interieur_forme(REF, [x, y]): #print(ref, REF, rel_ref);
      texture_ref := map(u -> plots:-inequal(rel_ref union u, x=0..2, y=-1..1, color=blue, 'nolines'), rel_motifs):
      texture     := texture, texture_ref:
    end do:

    plots:-display(
      plot([polygone[], polygone[1]], color=red, scaling=constrained),
      texture
    )

    [[0, 0], [0.5e-1, 0], [0.5e-1, 0.5e-1], [0, 0.5e-1]]

     

     

    MOTIF  := [[0, 0], [0.4, 0], [0.4, 0.14], [0, 0.14]]:
    motifs := [ seq(seq(F(MOTIF, piecewise(j::odd, 0.4, 0.2)+i*0.4, 0+j*0.14), i=-1..4), j=-8..7) ]:


    plots:-display(
      plot([polygone[], polygone[1]], color=red, filled),
      map(u -> plot([u[], u[1]], color=blue, filled, scaling=constrained), motifs)
    ):

    palettes := ColorTools:-PaletteNames():
    ColorTools:-GetPalette("HTML"):

    couleurs := [SandyBrown, PeachPuff, Peru, Linen, Bisque, Burlywood, Tan, AntiqueWhite,      NavajoWhite, BlanchedAlmond, PapayaWhip, Moccasin, Wheat]:

    nc   := numelems(couleurs):
    roll := rand(1..nc):

    motifs_nb      := numelems(motifs):
    motifs_couleur := [ seq(cat("HTML ", couleurs[roll()]), n=1..motifs_nb) ]:

    texture    := NULL:
    rel_motifs := map(u -> trianguler:-interieur_forme(u, [x, y]), motifs):
      
    for ref in liste_triangles do
      ref;
      g := trianguler:-sommet_gauche(ref):
      bas := sort(op~(2, ref), output=permutation);
      REF := ref[[g, op(map(u -> if u<>g then u end if, bas))]];
      rel_ref     := trianguler:-interieur_forme(REF, [x, y]): #print(ref, REF, rel_ref);
      texture_ref := map(n -> plots:-inequal(rel_ref union rel_motifs[n], x=0..2, y=-1..1, color=motifs_couleur[n], 'nolines'), [$1..motifs_nb]):
      texture     := texture, texture_ref:
    end do:

    plots:-display(
      plot([polygone[], polygone[1]], color=red, scaling=constrained),
      texture
    )

     

    MOTIF  := [ seq(0.1*~[cos(Pi/6+Pi/3*i), sin(Pi/6+Pi/3*i)], i=0..5) ]:
    motifs := [ seq(seq(F(MOTIF, i*0.2*cos(Pi/6)+piecewise(j::odd, 0, 0.08), j*0.3*sin(Pi/6)), i=0..12), j=-6..6) ]:


    plots:-display(
      plot([polygone[], polygone[1]], color=red, filled),
      map(u -> plot([u[], u[1]], color=blue, filled, scaling=constrained), motifs)
    ):


    motifs_nb      := numelems(motifs):
    motifs_couleur := [ seq(`if`(n::even, yellow, brown) , n=1..motifs_nb) ]:

    texture    := NULL:
    rel_motifs := map(u -> trianguler:-interieur_forme(u, [x, y]), motifs):
      
    for ref in liste_triangles do
      ref;
      g := trianguler:-sommet_gauche(ref):
      bas := sort(op~(2, ref), output=permutation);
      REF := ref[[g, op(map(u -> if u<>g then u end if, bas))]];
      rel_ref     := trianguler:-interieur_forme(REF, [x, y]): #print(ref, REF, rel_ref);
      texture_ref := map(n -> plots:-inequal(rel_ref union rel_motifs[n], x=0..2, y=-1..1, color=motifs_couleur[n], 'nolines'), [$1..motifs_nb]):
      texture     := texture, texture_ref:
    end do:

    plots:-display(
      plot([polygone[], polygone[1]], color=red, scaling=constrained),
      texture
    )

     

     


     

    Download Triangulation_Hatching_Texturing.mw

    We recently had a question about using some of the plotting commands in Maple to draw things. We were feeling creative and thought why not take it a step further and draw something in 3D.

    Using the geom3d, plottools, and plots packages we decided to make a gingerbread house.

    To make the base of the house we decided to use 2 cubes, as these would give us additional lines and segments for the icing on the house.

    point(p__1,[2,3,2]):
    point(p__2,[3,3,2]):
    cube(c1,p__1,2):
    cube(c2,p__2,2):
    base:=draw([c1,c2],color=tan);

    Using the same cubes but changing the style to be wireframe and point we made some icing lines and decorations for the gingerbread house.

    base_decor1:=draw([c1,c2],style=wireframe,thickness=3,color=red,transparency=0.2):
    base_decor2:=draw([c1,c2],style=wireframe,thickness=10,color=green,linestyle=dot):
    base_decor3:=draw([c1,c2],style=point,thickness=2,color="Silver",symbol=sphere):
    base_decor:=display(base_decor1,base_decor2,base_decor3);

    To create the roof we found the vertices of the cubes and used those to find the top corners of the base.

    v1:=vertices(c1):
    v2:=vertices(c2):
    pc1:=seq(point(pc1||i,v1[i]),i=1..nops(v1)):
    pc2:=seq(point(pc2||i,v2[i]),i=1..nops(v2)):
    topCorners:=[pc1[5],pc1[6],pc2[1],pc2[2]]:
    d1:=draw(topCorners):

    Using these top corners we found the midpoints (where the peak of the roof would be) and added the roof height to the coordinates.

    midpoint(lc1,topCorners[1],topCorners[2]):
    detail(lc1);

    point(cc1,[-(2*sqrt(3))/3 + 2, (2*sqrt(3))/3 + 3+1, 2]):
    d3:=draw(cc1):
    
    midpoint(lc2,topCorners[3],topCorners[4]):
    detail(lc2);

    point(cc2,[(2*sqrt(3))/3 + 3, (2*sqrt(3))/3 + 3+1, 2]):
    d4:=draw(cc2):

    With the midpoints and vertices at the front and rear of the house we made two triangles for the attic of the gingerbread house.

    triangle(tf,[topCorners[1],topCorners[2],cc1]):
    front:=draw(tf,color=brown):
    
    triangle(tb,[topCorners[3],topCorners[4],cc2]):
    back:=draw(tb,color=tan):

    Using these same points again we made more triangles to be the roof.

    triangle(trl,[cc1,cc2,pc1[5]]):
    triangle(trh,[pc2[2],pc1[6],cc1]):
    triangle(tll,[cc1,cc2,pc2[2]]):
    triangle(tlh,[pc2[1],pc1[5],cc2]):
    roof:=draw([trl,trh,tll,tlh],color="Chocolate");

    Our gingerbread house now had four walls, a roof, and icing, but no door. Creating the door was as easy as making a parallelepiped, but what is a door without more icing?

    door:=display(plottools:-parallelepiped([1,0,0],[0,1.2,0],[0,0,0.8],[0.8,1.9,1.6]),color="DarkRed"):
    door_decor1:=display(plottools:-parallelepiped([1,0,0],[0,1.2,0],[0,0,0.8],[0.8,1.9,1.6]),color="Gold",style=line):
    door_decor2:=display(plottools:-parallelepiped([1,0,0],[0,1.2,0],[0,0,0.8],[0.8,1.9,1.6]),color="Silver", style=line,linestyle=dot,thickness=5):
    door_decor:=display(door_decor1,door_decor2):

    Now having a door we could have left it like this, but what better way to decorate a gingerbread house than with candy canes? Naturally, if we were going to have one candy cane we were going to have lots of candy canes. To facilitate this we made a candy cane procedure.

    candy_pole:=proc(c:=[0,0,0], {segR:=0.1}, {segH:=0.1}, {segn:=7}, {tilt_theta:=0}, {theta:=0}, {arch:=true}, {flip:=false})
    local cane1,cane2,cane_s,cane_c,cane0,cane,i,cl,cd,ch, cane_a,tmp,cane_ac,cane_a1,cane00,cane01,cane02,cane_a1s,tmp2,cane_a2s:
    uses plots,geom3d:
    cl:=c[1]:
    cd:=c[2]:
    ch:=c[3]:
    cane1:=plottools:-cylinder([cd, ch, cl], segR, segH,style=surface):
    
    cane2:=display(plottools:-rotate(cane1,Pi/2,[[cd,ch,cl],[cd+1,ch,cl]])):
    cane_s:=[cane2,seq(display(plottools:-translate(cane2,0,segH*i,0)),i=1..segn-1)]:
    cane_c:=seq(ifelse(type(i,odd),red,white),i=1..segn):
    
    cane0:=display(cane_s,color=[cane_c]):
    
    if arch then
    
    cane_a:=plottools:-translate(cane2,0,segH*segn-segH/2,0):
    tmp:=i->plottools:-rotate(cane_a,i*Pi/24, [ [cd,ch+segH*segn-segH/2,cl+segR*2] , [cd+1,ch+segH*segn-segH/2,cl+segR*2] ] ):
    
    cane_ac:=seq(ifelse(type(i,odd),red,white),i=1..24):
    
                    cane_a1s:=seq(plottools:-translate(tmp(i),0,segH*i/12,segR*i/4),i=1..12):
    
    tmp2:=i->plottools:-rotate(cane_a1s[12],i*Pi/24,[[cd,ch+segH*segn-0.05,cl+segR*2],[cd+1,ch+segH*segn-0.05,cl+segR*2]]):
    
    cane_a2s:=seq(plottools:-translate(tmp2(i),0,-segH*i/500,segR*i/4),i=1..12):
    cane_a1:=display(cane_a1s,cane_a2s,color=[cane_ac]):
    cane00:=display(cane0,cane_a1);
    
                    if flip then
    
    cane01:=plottools:-rotate(cane00,tilt_theta,[[cd,ch,cl],[cd+1,ch,cl]]):
    cane02:=plottools:-rotate(cane01,theta,[[cd,ch,cl],[cd,ch+1,cl]]):
    cane:=plottools:-reflect(cane01,[[cd,ch,cl],[cd,ch+1,cl]]):
    
                    else
    
    cane01:=plottools:-rotate(cane00,tilt_theta,[[cd,ch,cl],[cd+1,ch,cl]]):
    cane:=plottools:-rotate(cane01,theta,[[cd,ch,cl],[cd,ch+1,cl]]):
    
                    end if:
    
                    return cane:
    
    else
    
                    cane:=plottools:-rotate(cane0,tilt_theta,[[cd,ch,cl],[cd+1,ch,cl]]):
    
                    return cane:
    
    end if:
    
    end proc:

    With this procedure we decided to add candy canes to the front, back, and sides of the gingerbread house. In addition we added two candy poles.

    Candy Canes in front of the house:

    cane1:=candy_pole([1.2,0,2],segn=9,arch=false):
    cane2:=candy_pole([2.8,0,2],segn=9,arch=false):
    cane3:=candy_pole([2.7,0.8,3.3],segn=9,segR=0.05,tilt_theta=-Pi/7):
    cane4:=candy_pole([1.3,0.8,3.3],segn=9,segR=0.05,tilt_theta=-Pi/7,flip=true):
    front_canes:=display(cane1,cane2,cane3,cane4):

    Candy Canes at the back of the house:

    caneb3:=candy_pole([1.5,4.2,2.5],segn=15,segR=0.05,tilt_theta=-Pi/3,flip=true):
    caneb4:=candy_pole([2.5,4.2,2.5],segn=15,segR=0.05,tilt_theta=-Pi/3):}
    back_canes:=display(caneb3,caneb4):

    Candy Canes at the left of the house:

    canel1:=candy_pole([0.8,1.5,2.5],segn=15,segR=0.05,tilt_theta=-Pi/7,theta=Pi/2):
    canel2:=candy_pole([0.8,2.5,2.5],segn=15,segR=0.05,tilt_theta=-Pi/7,theta=Pi/2):
    canel3:=candy_pole([0.8,4,2.5],segn=15,segR=0.05,tilt_theta=-Pi/7,theta=Pi/2):
    left_canes:=display(canel1,canel2,canel3):

    Candy Canes at the right of the house:

    caner1:=candy_pole([3.2,1.5,2.5],segn=15,segR=0.05,tilt_theta=-Pi/7,theta=Pi/2):
    caner2:=candy_pole([3.2,2.5,2.5],segn=15,segR=0.05,tilt_theta=-Pi/7,theta=Pi/2):
    caner3:=candy_pole([3.2,4,2.5],segn=15,segR=0.05,tilt_theta=-Pi/7,theta=Pi/2):
    right_canes:=display(caner1,caner2,caner3):
    
    canes:=display(front_canes,back_canes,right_canes,left_canes):

    With these canes in place all that was left was to create the ground and display our Gingerbread House.

    ground:=display(plottools:-parallelepiped([5,0,0],[0,0.5,0],[0,0,4],[0,1.35,0]),color="DarkGreen"):
    
    display([door,door_decor,d1,base,base_decor,d3,d4,front,back,roof,ground,canes],orientation=[-100,0,95]);

    You can download the full worksheet creating the gingerbread house below:

    Geometry_Gingerbread.mw

    I'm particularly interested in data analysis and more specifically in statistical analysis of computer code outputs.

    One of the main activity of this very broad field is named Uncertainty Propagation. In a few words it consists in perturbing the inputs of a computational code in order to understand (and quantify) how these perturbations propagates through the outputs of this code.

    At the core of uncertainty propagation is the ability to generate large numbers of "random" variations of the inputs. Knowing that these entries can be counted in tens, one sees that the first problem consists in generating "random" points in a space of potentially very large dimension.

    Even among my mathematician colleagues an impressive number of them is completely ignorant of the way "random" numbers are generated. I guess that a lot of Mapleprimes' users are too. My purpose is not to give a course on this topic and the affording litterature is vast enough for everyone interested might find informations of any level of complexity.
    Among those who have some knowledge about Pseudo Random Numbers Generators (PRNG), only a few of them know that a PRNG has to pass severe tests ("tests of randomness") before the streams of number it generates might  be qualified as "reasonably random" and therefore this PRNG might be released.

    One of most famous example of a bad PRNG is given by "randu" (IBM 1966, and probably used in Fortran libraries during more than 30 years), this same PRNG that Knuth qualified himself as the "infamous generator".

    These tests of randomness are generally gathered in dedicated libraries and Diehard is probably tone of the most known of them.
    Diehard has originally been developed by George Marsaglia more than twenty years ago and it's still widely ued today.

    I recently decided, not because I have doubts about the quality of the work done by Maplesoft, to test the Maple's PRNG named "Mersenne Twister". First, because it can do no harm to publish quantitative information that allows everyone to know that it is using a proven PRNG; second, because the (very simple) approach used here can fill the gaps I have mentioned above.

    Mersenne Twister (often dubbed mt19937) is considered as a very good PRNG; it is used in a lot of applications (including finance where it is not so rare to sample input spaces of dimensions larger than 1000... ok I know, mt19937 is often considered as a poor candidate for cryptography applications, but it's not my concern here).

    I have thus decided to spend some time to run the Diehard suite of tests on a sequence of integers numbers generated by RandomTools[MersenneTwister].


     

    restart:


    DIEHARD tests suite for Pseudo Random Numbers Generators (PRNG)

    Reference: http://webhome.phy.duke.edu/~rgb/General/dieharder.php

    The installation procedure (Mac OSX) can be found here
        https://gist.github.com/blixt/9abfafdd0ada0f4f6f26
    or here
        http://macappstore.org/dieharder/

    For other operating systems, please search on the web pages.


    dieharder [-h]   # for inline help
    dieharder -l      # to get the lists all the avaliable tests




    A description of the many tests can be found here:
        https://en.wikipedia.org/wiki/Diehard_tests
        https://sites.google.com/site/astudyofentropy/background-information/the-tests/dieharder-test-descriptions
        https://www.stata.com/support/cert/diehard/randnumb_mt64.out

    General theory about PRNG testing can be found here (a reference among many):
        http://liu.diva-portal.org/smash/get/diva2:740158/FULLTEXT01.pdf

    or here (more oriented to the NIST test suite)
        https://www.random.org/analysis/Analysis2005.pdf
        https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-22r1a.pdf



    In a terminal window execute the following commands for an exhaustive testing ("-a" option).
    The "-g 202" option means that the generator is replaced by a text format input file
    (use dieharder -h for more details).

    cd //..../Desktop/DIEHARD

    dieharder -g 202 -f SomeAsciiFile -a > //..../Desktop/DIEHARD/TheResultFile.txt

    Be carefull, the complete testing takes several hours (about 5 on my computer)



    __________________________________________________________________________________
     


    Maple's Mersenne Twister Generator

    Maple help page : RandomTools[MersenneTwister][GenerateInteger]
    (see rincluded references to the Mersenne Twister PRNG).

    Note: in the sequel this generator will be dubbed mt19937


    The Mersenne Twister is implemented in many softwares.
    It is higly likely that this PRNG (and the others these softwares propose) have been intensively
    tested with one of the existing PRNG testing libraries.
    Unfortunately only a few editors have made public the results of these tests (probably because
    the implementation in itself is rarely questioned... but a code typo is always a possibility).

    One exception is ths software STATA.
    A summary of the results can be found here
       https://www.stata.com/support/cert/diehard/.
    A complete description of the results of the tests passed is given here
       https://www.stata.com/support/cert/diehard/randnumb_mt64.out

    The classical pattern of the performances of mt19937 can be found here

       http://www2.ic.uff.br/~celso/artigos/pjo6.ps.

    and the table below comes from it (P means "Passed", F means "Failed"):


    ____________________________________________________________________________


    In the Maple code below, a sequence of N UnsignedInt32 numbers is generated from the
    Maple's Mersenne Twister and the result is exported in an ASCII file.
    The Seed is set to 1 (SetState(state=1)) to compare, with a small value of N (let's say N=10)
    the sequence produced by Maple's mt19937 with the the sequence of the same length generated
    by Diehard's mt19937.
    To generate this later sequence and save it in file Diehard_mt19937, just run in a terminan window
    the command (-S 1 means "seed = 1", -t 10 means "a sequence of length 10"):
       dieharder -S 1 -B -o -t 10 > Diehard_mt19937

    About the value of N:

    In http://webhome.phy.duke.edu/~rgb/General/dieharder.php it's recommend that N be at least
    equal to 2.5 million; STATA used N=3 million.
    Other web sources say this value is too small.
    For N=10 million the Maple's mt19937 doesn't pass the tests successfully.
    I used here N=50 million (the resulting ASCII file has size 537 Mo).



    Name of the input file.

    The file generated by Maple is named Maple_mt19937_N=5e7.txt



    One important thing is the preamble of a licit input file.

    This preamble must have 6 lines (the value 10 right to count must be set to the value of N).
    A licit preamble is of the form.

    #==================================================================

    # some text indicating the generator used

    #==================================================================

    type: d

    count: 10

    numbit: 32

    As Maple_mt19937_N=5e7.txt is generated from an ExportMatrix command, this preamble is added
    by hand.
     


    Running multiple Diehard tests

    To run the same tests used to qualify STATA's Mersenne Twister, open a terminal window,
    go to the directory that contains input file Maple_mt19937_N=5e7.txt and run this script:

     for i in {0,1,2,3,4,8,9,10,11,12,13,14,15,16}; do

        dieharder -g 202 -f Maple_mt19937_N=5e7.txt -d $i >> Diehard___Maple_mt19937_N=5e7

     done ;

    The results are then forked in the ASCII file Diehard___Maple_mt19937_N=5e7

     

    with(RandomTools[MersenneTwister]):

    dir := cat("/", currentdir(), "Desktop/DIEHARD/"):
    InputFile := cat(dir, "Maple_mt19937_N=5e7.txt"):

    SetState(state=1);

    N := 5*10^7:

    st := time():
    S := convert([seq(GenerateUnsignedInt32(), i=1..N)], Matrix)^+;
    time()-st;

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

     

    84.526

    (1)

    st := time():
    ExportMatrix(InputFile, S, format=rectangular, mode=ascii);
    time()-st;

    537066525

     

    61.926

    (2)


    Diehard's results


    Full test suite (about 5 hours of computational time)

    Command :
    dieharder -g 202 -f Maple_mt19937_N=5e7.txt -a > Diehard___ALL___Maple_mt19937_N=5e7


    The results are compared to those obtained for Diehard's mt19937.
    Two ways are used :

      - 1 - In a first stage one generates a stream of PRN and store it in an ASCII file (just as we did with Maple).
             The whole suite of tests is then run on this file.
             Commands (-g 013 codes for mt19937):

             dieharder -S 1 -g 013 -o -t 50000000 > Diehard_mt19937_N=5e7.txt
             dieharder -g 202 -f Diehard_mt19937_N=5e7.txt -a > Diehard___ALL___Diehard_mt19937_N=5e7



      - 2 - The whole suite is run by invoking directectly mt19937 "online"
             Commands :
             dieharder -S 1 -g 013 -t 50000000 -a > Diehard___ALL___Online


    A UNIX diff command has been used to verify that the two files Maple_mt19937_N=5e7.txt and
     Diehard_mt19937_N=5e7.txt were identical (thet were).

    Note that the Diehard doens't responds identically depending on the stream of random numbers comes from a file
    or is generated online (this last [- 2 -] situation seems to give better results).-

    Résumé (114 tests):
       - * - Maple's  and Diehard's  mt19937 respond exactly the same way when the stream of random
              numbers is read from an ASCII file (8 tests failed (******) and 6 weak (**)).
       - * - Diehard's  mt19937 fails 0 test and is weak on 4 tests when the stream is generated online
     

     

    restart:

    dir := currentdir():
    FromMapleFile     := cat(dir, "Diehard___ALL___Maple_mt19937_N=5e7"):
    FromDiehardFile   := cat(dir, "Diehard___ALL___diehard_mt19937_N=5e7"):
    FromDiehardNoFile := cat(dir, "Diehard___ALL___Online"):


    printf("                           ======================|======================|======================|\n"):
    printf("                          |   From Maple's file  | From Diehard's File  | Diehard online test  |\n"):
    printf("==========================|======================|======================|======================|\n"):
    printf("          test       ntup | p.value   Assessment | p.value   Assessment | p.value   Assessment |\n"):
    printf("==========================|======================|======================|======================|\n"):


    for k from 1 to 9 do
      LMF  := readline(FromMapleFile):
      LDF  := readline(FromDiehardFile):
      LDNF := readline(FromDiehardNoFile):
    end do:


    while LMF <> 0 do
      if StringTools:-Search("|", LMF) > 0 then
        res := StringTools:-StringSplit(LMF, "|")[[1, 2, 5, 6]];
        printf("%-20s  %3d | %1.7f ", res[1], parse(res[2]), parse(res[3]));
          if StringTools:-Search("WEAK"  , res[4]) > 0 then printf("    **     |")
        elif StringTools:-Search("FAILED", res[4]) > 0 then printf("  ******   |")
        else printf("  PASSED   |")
        end if:
      end if:
      LMF  := readline(FromMapleFile):

      if StringTools:-Search("|", LDF) > 0 then
        res := StringTools:-StringSplit(LDF, "|")[[5, 6]];
        printf(" %1.7f ", parse(res[1]));
          if StringTools:-Search("  WEAK"  , res[2]) > 0 then printf("     **    |")
        elif StringTools:-Search("  FAILED", res[2]) > 0 then printf("   ******  |")
        else printf("   PASSED  |")
        end if:
      end if:
      LDF  := readline(FromDiehardFile):
                         
      if StringTools:-Search("|", LDNF) > 0 then
        res := StringTools:-StringSplit(LDNF, "|")[[5, 6]];
        printf(" %1.7f ", parse(res[1]));
          if StringTools:-Search("WEAK"  , res[2]) > 0 then printf("     **    |")
        elif StringTools:-Search("FAILED", res[2]) > 0 then printf("   ******    |")
        else printf("   PASSED  |")
        end if:
        printf("\n"):
      end if:
      LDNF := readline(FromDiehardNoFile):


    end do:

                               ======================|======================|======================|
                              |   From Maple's file  | From Diehard's File  | Diehard online test  |
    ==========================|======================|======================|======================|
              test       ntup | p.value   Assessment | p.value   Assessment | p.value   Assessment |
    ==========================|======================|======================|======================|
       diehard_birthdays    0 | 0.9912651   PASSED   | 0.9912651    PASSED  | 0.8284550    PASSED  |
          diehard_operm5    0 | 0.1802226   PASSED   | 0.1802226    PASSED  | 0.5550587    PASSED  |
      diehard_rank_32x32    0 | 0.3099035   PASSED   | 0.3099035    PASSED  | 0.9575440    PASSED  |
        diehard_rank_6x8    0 | 0.2577249   PASSED   | 0.2577249    PASSED  | 0.3915666    PASSED  |
       diehard_bitstream    0 | 0.5519218   PASSED   | 0.5519218    PASSED  | 0.9999462      **    |
            diehard_opso    0 | 0.1456442   PASSED   | 0.1456442    PASSED  | 0.7906533    PASSED  |
            diehard_oqso    0 | 0.4882425   PASSED   | 0.4882425    PASSED  | 0.9574014    PASSED  |
             diehard_dna    0 | 0.0102880   PASSED   | 0.0102880    PASSED  | 0.5149193    PASSED  |
    diehard_count_1s_str    0 | 0.1471956   PASSED   | 0.1471956    PASSED  | 0.9517290    PASSED  |
    diehard_count_1s_byt    0 | 0.1158707   PASSED   | 0.1158707    PASSED  | 0.1568255    PASSED  |
     diehard_parking_lot    0 | 0.1148982   PASSED   | 0.1148982    PASSED  | 0.1611173    PASSED  |
        diehard_2dsphere    2 | 0.9122204   PASSED   | 0.9122204    PASSED  | 0.2056657    PASSED  |
        diehard_3dsphere    3 | 0.9385972   PASSED   | 0.9385972    PASSED  | 0.3620517    PASSED  |
         diehard_squeeze    0 | 0.2686977   PASSED   | 0.2686977    PASSED  | 0.8611266    PASSED  |
            diehard_sums    0 | 0.1602355   PASSED   | 0.1602355    PASSED  | 0.5103248    PASSED  |
            diehard_runs    0 | 0.1235328   PASSED   | 0.1235328    PASSED  | 0.9402086    PASSED  |
            diehard_runs    0 | 0.6341956   PASSED   | 0.6341956    PASSED  | 0.3274267    PASSED  |
           diehard_craps    0 | 0.0243605   PASSED   | 0.0243605    PASSED  | 0.1844482    PASSED  |
           diehard_craps    0 | 0.2952043   PASSED   | 0.2952043    PASSED  | 0.1407422    PASSED  |
     marsaglia_tsang_gcd    0 | 0.0000000   ******   | 0.0000000    ******  | 0.5840531    PASSED  |
     marsaglia_tsang_gcd    0 | 0.0000000   ******   | 0.0000000    ******  | 0.8055035    PASSED  |
             sts_monobit    1 | 0.9397218   PASSED   | 0.9397218    PASSED  | 0.9018886    PASSED  |
                sts_runs    2 | 0.8092469   PASSED   | 0.8092469    PASSED  | 0.2247600    PASSED  |
              sts_serial    1 | 0.2902851   PASSED   | 0.2902851    PASSED  | 0.9223063    PASSED  |
              sts_serial    2 | 0.9541680   PASSED   | 0.9541680    PASSED  | 0.6140772    PASSED  |
              sts_serial    3 | 0.4090798   PASSED   | 0.4090798    PASSED  | 0.2334754    PASSED  |
              sts_serial    3 | 0.5474851   PASSED   | 0.5474851    PASSED  | 0.7370361    PASSED  |
              sts_serial    4 | 0.7282286   PASSED   | 0.7282286    PASSED  | 0.2518826    PASSED  |
              sts_serial    4 | 0.9905724   PASSED   | 0.9905724    PASSED  | 0.6876253    PASSED  |
              sts_serial    5 | 0.8297711   PASSED   | 0.8297711    PASSED  | 0.2123014    PASSED  |
              sts_serial    5 | 0.9092172   PASSED   | 0.9092172    PASSED  | 0.3532615    PASSED  |
              sts_serial    6 | 0.4976615   PASSED   | 0.4976615    PASSED  | 0.9967160      **    |
              sts_serial    6 | 0.9853355   PASSED   | 0.9853355    PASSED  | 0.5537414    PASSED  |
              sts_serial    7 | 0.9675717   PASSED   | 0.9675717    PASSED  | 0.3804243    PASSED  |
              sts_serial    7 | 0.4446567   PASSED   | 0.4446567    PASSED  | 0.0923678    PASSED  |
              sts_serial    8 | 0.7254384   PASSED   | 0.7254384    PASSED  | 0.4544030    PASSED  |
              sts_serial    8 | 0.8984816   PASSED   | 0.8984816    PASSED  | 0.7501155    PASSED  |
              sts_serial    9 | 0.8255134   PASSED   | 0.8255134    PASSED  | 0.4260288    PASSED  |
              sts_serial    9 | 0.6609663   PASSED   | 0.6609663    PASSED  | 0.5622308    PASSED  |
              sts_serial   10 | 0.9984397     **     | 0.9984397      **    | 0.5789212    PASSED  |
              sts_serial   10 | 0.7987434   PASSED   | 0.7987434    PASSED  | 0.8599317    PASSED  |
              sts_serial   11 | 0.5552886   PASSED   | 0.5552886    PASSED  | 0.3546752    PASSED  |
              sts_serial   11 | 0.4417852   PASSED   | 0.4417852    PASSED  | 0.5042245    PASSED  |
              sts_serial   12 | 0.3843880   PASSED   | 0.3843880    PASSED  | 0.6723639    PASSED  |
              sts_serial   12 | 0.1514682   PASSED   | 0.1514682    PASSED  | 0.9428701    PASSED  |
              sts_serial   13 | 0.5396454   PASSED   | 0.5396454    PASSED  | 0.5793677    PASSED  |
              sts_serial   13 | 0.9497671   PASSED   | 0.9497671    PASSED  | 0.3370774    PASSED  |
              sts_serial   14 | 0.3616613   PASSED   | 0.3616613    PASSED  | 0.4372343    PASSED  |
              sts_serial   14 | 0.3996251   PASSED   | 0.3996251    PASSED  | 0.5185021    PASSED  |
              sts_serial   15 | 0.3847188   PASSED   | 0.3847188    PASSED  | 0.3188851    PASSED  |
              sts_serial   15 | 0.1012968   PASSED   | 0.1012968    PASSED  | 0.1631942    PASSED  |
              sts_serial   16 | 0.9974802     **     | 0.9974802      **    | 0.6645914    PASSED  |
              sts_serial   16 | 0.1157822   PASSED   | 0.1157822    PASSED  | 0.3465564    PASSED  |
             rgb_bitdist    1 | 0.4705599   PASSED   | 0.4705599    PASSED  | 0.8627740    PASSED  |
             rgb_bitdist    2 | 0.7578920   PASSED   | 0.7578920    PASSED  | 0.3296790    PASSED  |
             rgb_bitdist    3 | 0.9934502   PASSED   | 0.9934502    PASSED  | 0.5558012    PASSED  |
             rgb_bitdist    4 | 0.3674201   PASSED   | 0.3674201    PASSED  | 0.1607977    PASSED  |
             rgb_bitdist    5 | 0.7930273   PASSED   | 0.7930273    PASSED  | 0.9999802      **    |
             rgb_bitdist    6 | 0.8491477   PASSED   | 0.8491477    PASSED  | 0.3774760    PASSED  |
             rgb_bitdist    7 | 0.1537432   PASSED   | 0.1537432    PASSED  | 0.4715169    PASSED  |
             rgb_bitdist    8 | 0.9454030   PASSED   | 0.9454030    PASSED  | 0.9890644    PASSED  |
             rgb_bitdist    9 | 0.2017856   PASSED   | 0.2017856    PASSED  | 0.0571014    PASSED  |
             rgb_bitdist   10 | 0.9989305     **     | 0.9989305      **    | 0.4575834    PASSED  |
             rgb_bitdist   11 | 0.4441883   PASSED   | 0.4441883    PASSED  | 0.4960057    PASSED  |
             rgb_bitdist   12 | 0.7074388   PASSED   | 0.7074388    PASSED  | 0.6808850    PASSED  |
    rgb_minimum_distance    2 | 0.9604056   PASSED   | 0.9604056    PASSED  | 0.8859729    PASSED  |
    rgb_minimum_distance    3 | 0.5143592   PASSED   | 0.5143592    PASSED  | 0.3266204    PASSED  |
    rgb_minimum_distance    4 | 0.3779106   PASSED   | 0.3779106    PASSED  | 0.3537417    PASSED  |
    rgb_minimum_distance    5 | 0.4861264   PASSED   | 0.4861264    PASSED  | 0.9032057    PASSED  |
        rgb_permutations    2 | 0.9206310   PASSED   | 0.9206310    PASSED  | 0.8052940    PASSED  |
        rgb_permutations    3 | 0.9299743   PASSED   | 0.9299743    PASSED  | 0.2209750    PASSED  |
        rgb_permutations    4 | 0.8330345   PASSED   | 0.8330345    PASSED  | 0.5819945    PASSED  |
        rgb_permutations    5 | 0.2708879   PASSED   | 0.2708879    PASSED  | 0.9276941    PASSED  |
          rgb_lagged_sum    0 | 0.0794660   PASSED   | 0.0794660    PASSED  | 0.9918681    PASSED  |
          rgb_lagged_sum    1 | 0.5279555   PASSED   | 0.5279555    PASSED  | 0.1304600    PASSED  |
          rgb_lagged_sum    2 | 0.0433872   PASSED   | 0.0433872    PASSED  | 0.1149961    PASSED  |
          rgb_lagged_sum    3 | 0.0028004     **     | 0.0028004      **    | 0.2731577    PASSED  |
          rgb_lagged_sum    4 | 0.0000074     **     | 0.0000074      **    | 0.8978870    PASSED  |
          rgb_lagged_sum    5 | 0.1332411   PASSED   | 0.1332411    PASSED  | 0.2065880    PASSED  |
          rgb_lagged_sum    6 | 0.0412128   PASSED   | 0.0412128    PASSED  | 0.7611867    PASSED  |
          rgb_lagged_sum    7 | 0.0225446   PASSED   | 0.0225446    PASSED  | 0.4810145    PASSED  |
          rgb_lagged_sum    8 | 0.0087433   PASSED   | 0.0087433    PASSED  | 0.3120378    PASSED  |
          rgb_lagged_sum    9 | 0.0000000   ******   | 0.0000000    ******  | 0.1334315    PASSED  |
          rgb_lagged_sum   10 | 0.4147842   PASSED   | 0.4147842    PASSED  | 0.2334790    PASSED  |
          rgb_lagged_sum   11 | 0.0206564   PASSED   | 0.0206564    PASSED  | 0.6491578    PASSED  |
          rgb_lagged_sum   12 | 0.0755835   PASSED   | 0.0755835    PASSED  | 0.5332069    PASSED  |
          rgb_lagged_sum   13 | 0.3112028   PASSED   | 0.3112028    PASSED  | 0.4194447    PASSED  |
          rgb_lagged_sum   14 | 0.0000000   ******   | 0.0000000    ******  | 0.2584573    PASSED  |
          rgb_lagged_sum   15 | 0.0890059   PASSED   | 0.0890059    PASSED  | 0.0007064      **    |
          rgb_lagged_sum   16 | 0.2962076   PASSED   | 0.2962076    PASSED  | 0.1344984    PASSED  |
          rgb_lagged_sum   17 | 0.2696070   PASSED   | 0.2696070    PASSED  | 0.2242021    PASSED  |
          rgb_lagged_sum   18 | 0.0826388   PASSED   | 0.0826388    PASSED  | 0.0450341    PASSED  |
          rgb_lagged_sum   19 | 0.0000000   ******   | 0.0000000    ******  | 0.5508302    PASSED  |
          rgb_lagged_sum   20 | 0.0101437   PASSED   | 0.0101437    PASSED  | 0.4290150    PASSED  |
          rgb_lagged_sum   21 | 0.1417859   PASSED   | 0.1417859    PASSED  | 0.1624411    PASSED  |
          rgb_lagged_sum   22 | 0.0160264   PASSED   | 0.0160264    PASSED  | 0.5204838    PASSED  |
          rgb_lagged_sum   23 | 0.0535167   PASSED   | 0.0535167    PASSED  | 0.6571892    PASSED  |
          rgb_lagged_sum   24 | 0.0000000   ******   | 0.0000000    ******  | 0.8578906    PASSED  |
          rgb_lagged_sum   25 | 0.8453426   PASSED   | 0.8453426    PASSED  | 0.3568988    PASSED  |
          rgb_lagged_sum   26 | 0.2113484   PASSED   | 0.2113484    PASSED  | 0.9755715    PASSED  |
          rgb_lagged_sum   27 | 0.1903762   PASSED   | 0.1903762    PASSED  | 0.4356739    PASSED  |
          rgb_lagged_sum   28 | 0.0733066   PASSED   | 0.0733066    PASSED  | 0.8354990    PASSED  |
          rgb_lagged_sum   29 | 0.0000000   ******   | 0.0000000    ******  | 0.1716599    PASSED  |
          rgb_lagged_sum   30 | 0.0932124   PASSED   | 0.0932124    PASSED  | 0.0732090    PASSED  |
          rgb_lagged_sum   31 | 0.0000000   ******   | 0.0000000    ******  | 0.3497910    PASSED  |
          rgb_lagged_sum   32 | 0.0843455   PASSED   | 0.0843455    PASSED  | 0.5441949    PASSED  |
         rgb_kstest_test    0 | 0.4399862   PASSED   | 0.4399862    PASSED  | 0.9766581    PASSED  |
         dab_bytedistrib    0 | 0.0748312   PASSED   | 0.0748312    PASSED  | 0.7035800    PASSED  |
                 dab_dct  256 | 0.0919474   PASSED   | 0.0919474    PASSED  | 0.3985889    PASSED  |
            dab_filltree   32 | 0.1227533   PASSED   | 0.1227533    PASSED  | 0.7390925    PASSED  |
            dab_filltree   32 | 0.6819630   PASSED   | 0.6819630    PASSED  | 0.1773611    PASSED  |
           dab_filltree2    0 | 0.1774773   PASSED   | 0.1774773    PASSED  | 0.2088828    PASSED  |
           dab_filltree2    1 | 0.1718216   PASSED   | 0.1718216    PASSED  | 0.2257006    PASSED  |
            dab_monobit2   12 | 0.9999881     **     | 0.9999881      **    | 0.8084149    PASSED  |

     

     


     

    Download DIEHARD_test_of_MAPLE_MersenneTwister.mw

    A lot of supplementary details are given in the attached file.
    I let the readers discover by themselves if Maple's implementation of the Mersenne Twister PRNG is correct or not.
    Beyond this exercise, I hope this work will be useful to people who could be tempted to test their own generator.

     

     

    I am very pleased to announce that we have released a new version of the free Maple Companion app. For those you may have missed it, the first release of this app gave you a way to take a picture of math using your phone’s camera and upload it into Maple. Instructors have told me they’ve found this very useful in their classes, as they no longer have to deal with transcription errors as students enter problems into Maple.

    So that’s good. But version 2 is a lot better. The Maple Companion now solves math problems directly on your phone. It can handle problems from algebra, precalculus, calculus, linear algebra, differential equations, and more. No need to upload to Maple – students can solve the problem by hand, and then use the app to check their answer, try new operations on the same expression, and even create plots. And if they want to do even more, they can still upload the expression into Maple for more advanced operations and explorations.

    There’s also a built-in math editor, so you can enter problems without the camera, too. And if you use the camera, and it misinterprets part of your expression, you can fix it using the editor instead of having to retake the picture.  Good as the math recognition is, even in the face of some pretty poor handwriting, the ability to tweak the results has proven to be extremely useful.

    There’s lots more we’d like to do with the Maple Companion app over time, and we’d like hear your thoughts, as well. How else can it help students learn?  How else can it act as a complement to Maple? Let us know!

    Visit Maple Companion to learn more, find links to the app stores so you can download the app, and access the feedback form. And if you already have version 1, you can get the new release simply by updating the app on your phone.

     

    This update fixes the problems inadvertently introduced in Maple 2019.2, namely:

    • Maple failed to run the code in the maple.ini/.mapleinit initialization files when loading existing worksheets containing a restart() command
    • Installing some packages from the MapleCloud was unsuccessful

    For anyone who installed the 2019.2 update, installing 2019.2.1 will fix these problems.

    If you are at Maple 2019.1 or earlier, installing this update will bring you straight to Maple 2019.2.1.

    This update is available through Tools>Check for Updates in Maple, and is also available from our website on the Maple 2019.2.1 download page.

    If you are a MapleSim user, please note that these problems do not affect your use of MapleSim. If you use Maple on its own, and if you use Maple command initialization files and/or you need to install a package from the MapleCloud that does not work, please contact Maplesoft Technical Support for assistance.

    We sincerely apologize for the inconvenience and thank you for your patience as we worked through this issue.

    There was a discussion regarding Maple and two light sources a couple of days ago (unfortunately the content of that conversation has been removed by the original poster so if any of you thought you were getting early signs of alzheimers, rest assured the questions/posts were indeed there and you can all put your memories at ease for a little).

    I did indeed go back into Maple to see how far it was that we lost the two light source capability.  I can tell you that as far back as Maple 10.06 dual (or more) light sources was not working.  So I worked my way up - of course the OP of the deleted questions mentioned Maple Vr4 (I think), so I started there.  Maple 6 and Maple 7 is ok.  I was unable to check Maple 8 and 9 as my computers with that software are currently missing (probably buried in my shed somewhere - as long as the wife hasn't got rid of them.. anyways)

    So I'll share with you what once was.  From Maple 7, and an animated gif (which hopefully works) to illustrate two light sources (one brown light, and one mauve or purple light) and what it looked like from Maple 7.

    with(plots):
    setoptions3d(style=patchnogrid,projection=.9):
    a:=plot3d(-x^2-y^2-x*y,x=-1..1,y=-1..1,color=[.5,.9,.9],grid=[15,15]):
    b:=n->display(a,orientation=[n,60]):
    display([seq(b(10*n),n=0..35)],light=[90,-80,1,.2,.1],light=[90,40,1,.5,.8],insequence=true);

    The animation is not working so the uploaded gif file is here for you to check out. .. Couldn't upload the gif file so I've zipped it - that worked

    twolightsource.zip

    I'm only just hearing (haven't experienced) about some serious issues with the 2019.2 updates.  I would recommend waiting for Maplesoft to release an emergency 2019.3 fix update - Maplesoft can NOT leave the last update of 2019 in this state.

    After updating to Maple2019.2, the user initialization files maple.ini (Windows) and .mapleinit (Linux), which are placed into the user's home dierectories, are no longer read in upon startup. The behavior of Maple2019.1 was correct, the files were read.

    In order to estimate parameters of permanent magnet synchronous motor (PMSM) on-line and real-time, an adaptive on-line identification method for motor parameters is proposed. Resistance, inductance and PM flux of PMSM are achieved at the same time in the presented model. By means of Popov’s hyper-stability theory, the model of parameter identification is built in the rotor reference frame. And, PMSM d, q-axis voltage, current and their errors are used to obtain the adaptive laws of parameters. Popov’s hyper-stability theory guarantees stability of the system and convergence of the estimated parameters under certain conditions. The simulation and experimental results illustrate the validity and efficiency of the proposed method.

    We have just released updates to Maple and MapleSim.

    Maple 2019.2 includes corrections and improvements to a variety of areas in the product, including a new “Go to page ____” option in print preview (that am personally quite pleased about), sections are expanded by default when printing or exporting, a fix to a problem using non-executable math with text in document mode that sometimes made it impossible to advance to a new line using Enter, improvements to VectorCalculus, select, abs and other math functions, support for macOS Catalina, and more.  We recommend that all Maple 2019 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 2019.2 download page, where you can also find more details.

    For MapleSim users, the MapleSim 2019.2 family of products includes enhancements in the areas of model development and toolchain connectivity, including substantial enhancements to the MapleSim CAD toolbox.   For more details and download instructions, visit the MapleSim 2019.2 download page.

    Program of Transfer matrix method for solving the vibrational behavior of a cracked beam. For more details and comprehension check the paper entitled ''A transfer matrix method for free vibration analysis and crack identification of stepped beams with multiple edge cracks and different boundary conditions ''
     

    restart; with(LinearAlgebra)NULLNULL

    W11 := A[1]*cos(nu*x)+A[2]*sin(nu*x)+A[3]*cosh(nu*x)+A[4]*sinh(nu*x);

    theta11 := -A[1]*nu*sin(nu*x)+A[2]*nu*cos(nu*x)+A[3]*nu*sinh(nu*x)+A[4]*nu*cosh(nu*x)  NULL

    M11 := EI*(-A[1]*nu^2*cos(nu*x)-A[2]*nu^2*sin(nu*x)+A[3]*nu^2*cosh(nu*x)+A[4]*nu^2*sinh(nu*x))
    S11 := EI*(A[1]*nu^3*sin(nu*x)-A[2]*nu^3*cos(nu*x)+A[3]*nu^3*sinh(nu*x)+A[4]*nu^3*cosh(nu*x))
     

    MD11 := subs(A[1] = 1, A[2] = 0, A[3] = 0, A[4] = 0, W11); MD12 := subs(A[1] = 0, A[2] = 1, A[3] = 0, A[4] = 0, W11); MD13 := subs(A[1] = 0, A[2] = 0, A[3] = 1, A[4] = 0, W11); MD14 := subs(A[1] = 0, A[2] = 0, A[3] = 0, A[4] = 1, W11)
    NULL

    MD21 := subs(A[1] = 1, A[2] = 0, A[3] = 0, A[4] = 0, theta11); MD22 := subs(A[1] = 0, A[2] = 1, A[3] = 0, A[4] = 0, theta11); MD23 := subs(A[1] = 0, A[2] = 0, A[3] = 1, A[4] = 0, theta11); MD24 := subs(A[1] = 0, A[2] = 0, A[3] = 0, A[4] = 1, theta11)
     

    MD31 := subs(A[1] = 1, A[2] = 0, A[3] = 0, A[4] = 0, M11); MD32 := subs(A[1] = 0, A[2] = 1, A[3] = 0, A[4] = 0, M11); MD33 := subs(A[1] = 0, A[2] = 0, A[3] = 1, A[4] = 0, M11); MD34 := subs(A[1] = 0, A[2] = 0, A[3] = 0, A[4] = 1, M11)
     

    MD41 := subs(A[1] = 1, A[2] = 0, A[3] = 0, A[4] = 0, S11); MD42 := subs(A[1] = 0, A[2] = 1, A[3] = 0, A[4] = 0, S11); MD43 := subs(A[1] = 0, A[2] = 0, A[3] = 1, A[4] = 0, S11); MD44 := subs(A[1] = 0, A[2] = 0, A[3] = 0, A[4] = 1, S11)
     

     

    TM := Matrix(4, 4, [[MD11, MD12, MD13, MD14], [MD21, MD22, MD23, MD24], [MD31, MD32, MD33, MD34], [MD41, MD42, MD43, MD44]])

    C := Matrix(4, 4, [[1, 0, 0, 0], [0, 1, c44, 0], [0, 0, 1, 0], [0, 0, 0, 1]])NULL

    NULL    TM2 := subs(x = 0, TM); TM3 := subs(x = L, TM)

    with(MTM)

    TM4 := inv(TM)NULLNULL 

    TM5 := inv(TM2)NULL

    Y11 := MatrixMatrixMultiply(TM3, TM4)

        Y22 := MatrixMatrixMultiply(C, TM)   

    Y33 := MatrixMatrixMultiply(Y11, Y22)

    Y44 := MatrixMatrixMultiply(Y33, TM5)NULL

    BB11 := Y44[3, 3]

    BB12 := Y44[3, 4]

    BB21 := Y44[4, 3]

    BB22 := Y44[4, 4] 

    BB := Matrix(2, 2, [[BB11, BB12], [BB21, BB22]]) 

    NULL

    R11 := det(BB) 

    NULL

    L := .18; L1 := 1; h := 0.5e-2; b := 0.2e-1; rho := 957.5; area = b.h; m := rho*h*b; EI := 0.2682e10*b*h^3mu := ((m.(omega^2))*L^4/EI)^(1/4); x := .5; c44 := .1; c11 := 0NULLNULL

    plot(R11, omega = 1 .. 100)

     

     

     

    ``

    NULL

    NULL


     

    Download transfer.mw

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