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
  • Magnet lattices for particle accelerators (the sequence of focusing and bending magnets and drift sections making up a beam line) are often designed numerically using computer codes like MAD that model each beam-line element using either a matrix description or numeric integration, or some other algorithm. The Lattice package for Maple—recently published in Maplesoft's Application Center—allows modelling such beam lines using the full algebraic power of Maple. In this way, analytic solutions to beam-optics problems can be found in order to establish feasibility of certain solutions or study parameter dependencies. Beam lines are constructed in an intuitive way from standard beam-optical elements (drifts, bends, quadrupoles etc.) using Maple's object-oriented features, in particular Records which represent individual elements or whole beam lines. These Records hold properties like the first-order transport matrices, element length and some other properties plus, for beam lines, the elements the line is composed of. Operations like finding matched Twiss (beam-envelope) functions and dispersion are implemented and the results can be plotted. The Lattice package knows about beam matrices and can track such matrices as well as particles in a beam. The tracking function (map) is implemented separately from the first-order matrices thus allowing nonlinear or even scattering simulations; at present sextupole elements, compensating-wire elements and scattering-foil elements take advantage of this feature. Standard textbook problems are programmed and solved easily, and more complicated ones are readily solved as well €”within the limits set by Maple's capabilities, memory and computing time. Many investigations are possible by using standard Maple operations on the relevant properties of the beam lines defined. An interesting possibility is, e.g., using Maple's mtaylor command to truncate the transfer map of a beam line to a desired order, making it a more manageable function.

    The package can output a beam-line description in MAD8 format for further refinement of the solution, cross-checking the results and possibly more detailed tracking.

    Developed initially for my own use I have found the package useful for a number of accelerator design problems, teaching at the US Particle Accelerator School as well as in modelling beam lines for experiments I have been involved in. Presently at Version 1.0 the package still has limits; esp. the higher-order descriptions are not yet as complete as desirable. Yet already many practical design problems can be tackled in great detail. The package is backwards compatible to Maple 15. It can be found in the Application center together with help database files (old and new style) and a Users Guide.

    An example showing the flavor of working with the package is attached (FODO_example.mw). It analyzes a FODO cell, the basic cell used in many ring accelerators.

    Uli Wienands, aka Mac Dude

    The method of solving underdetermined systems of equations, and universal method for calculating link mechanisms. It is based on the Draghilev’s method for solving systems of nonlinear equations. 
    When calculating link mechanisms we can use geometrical relationships to produce their mathematical models without specifying the “input link”. The new method allows us to specify the “input link”, any link of mechanism.

    Example.
    Three-bar mechanism.  The system of equations linkages in this mechanism is as follows:

    f1 := x1^2+(x2+1)^2+(x3-.5)^2-R^2;
    f2 := x1-.5*x2+.5*x3;
    f3 := (x1-x4)^2+(x2-x5)^2+(x3-x6)^2-19;
    f4 := sin(x4)-x5;
    f5 := sin(2*x4)-x6;

    Coordinates green point x'i', i = 1..3, the coordinates of red point x'i', i = 4..6.
    Set of x0'i', i = 1..6 searched arbitrarily, is the solution of the system of equations and is the initial point for the solution of the ODE system. The solution of ODE system is the solution of system of equations linkages for concrete assembly linkage.
    Two texts of the program for one mechanism. In one case, the “input link” is the red-green, other case the “input link” is the green-blue.
    After the calculation trajectories of points, we can always find the values of other variables, for example, the angles.
    Animation displays the kinematics of the mechanism.
    MECAN_3_GR_P_bar.mw 
    MECAN_3_Red_P_bar.mw

    (if to use another color instead of color = "Niagara Dark Orchid", the version of Maple <17)

    Method_Mechan_PDF.pdf






    In this course you will learn automatically using Maple course Statics applied to civil engineering especially noting the use of components properly. Let us see the use of Maple to Engineering.

    Static_for_Engineering.mw

    (in spanish)

    Atte.

    Lenin Araujo Castillo

    Ambassador of Maple

    You, I, and others like us, are the beneficiaries of decades of software evolution.

    From its genesis as a research project at the University of Waterloo in the early 80s, Maple has continually evolved to meet the challenges of technical computing.

    #Most  dediction of  depth of field of optical lens  involves various simplification,  hence cannot be used  for  close up photography.  With Maple, it is easy to obtain  precise   Depth of field  formuar for optical lens  without  any simplification

     

    > restart; h := H = F^2/(N*coc)+F; E0 := 1/d+1/D0 = 1/F; E1 := 1/(d+e)+1/D2 = 1/F; E2 := a/(d+e) = coc/delta; E3 := a = F/N; eq := {E0, E1, E2, E3, h}; var := {D2, N, coc, d, delta}; e := -delta; sol1 := solve(eq, var); t1 := op(sol1)[1]; Dfar := op(t1)[2]; e := delta; sol2 := solve(eq, var); t2 := op(sol2)[1]; Dnear := op(t2)[2];

     

    >

    >
    >

    >
    >
    >

    IntegerPoints2  procedure generalizes  IntegerPoints1  procedure and finds all the integer points inside a bounded curved region of arbitrary dimension.  We also use a brute force method, but to find the ranges for each variable  Optimization[Minimize]  and   Optimization[Maximize]  is used instead of  simplex[minimize]  or  simplex[minimize] .

    Required parameters of the procedure: SN is a set or a list of  inequalities and/or equations with any number of variables, the Var is the list of variables. Bound   is an optional parameter - list of ranges for each variable in the event, if  Optimization[Minimize/Maximize]  fails. By default  Bound  is NULL.

    If all constraints are linear, then in this case it is recommended to use  IntegerPoints1  procedure, as it is better to monitor specific cases (no solutions or an infinite number of solutions for an unbounded region).

    Code of the procedure:

    IntegerPoints2 := proc (SN::{list, set}, Var::(list(symbol)), Bound::(list(range)) := NULL)

    local SN1, sn, n, i, p, q, xl, xr, Xl, Xr, X, T, k, t, S;

    uses Optimization, combinat;

    n := nops(Var);

    if Bound = NULL then

    SN1 := SN;

    for sn in SN1 do

    if type(sn, `<`) then

    SN1 := subs(sn = (`<=`(op(sn))), SN1) fi od;

    for i to n do

    p := Minimize(Var[i], SN1); q := Maximize(Var[i], SN1);

    xl[i] := eval(Var[i], p[2]); xr[i] := eval(Var[i], q[2]) od else

    assign(seq(xl[i] = lhs(Bound[i]), i = 1 .. n));

    assign(seq(xr[i] = rhs(Bound[i]), i = 1 .. n)) fi;

    Xl := map(floor, convert(xl, list)); Xr := map(ceil, convert(xr, list));

    X := [seq([$ Xl[i] .. Xr[i]], i = 1 .. n)];

    T := cartprod(X); S := table();

    for k while not T[finished] do

    t := T[nextvalue]();

    if convert(eval(SN, zip(`=`, Var, t)), `and`) then

    S[k] := t fi od;

    convert(S, set);

    end proc:

     

    In the first example, we find all the integer points in the four-dimensional ball of radius 10:

    Ball := IntegerPoints2({x1^2+x2^2+x3^2+x4^2 < 10^2}, [x1, x2, x3, x4]):  # All the integer points

    nops(Ball);  # The total number of the integer points

    seq(Ball[1000*n], n = 1 .. 10);  # Some points

                                                                        48945

                      [-8, 2, 0, -1], [-7, 0, 1, -3], [-6, -4, -6, 2], [-6, 1, 1, 1], [-5, -6, -2, 4], [-5, -1, 2, 0],

                                    [-5, 4, -6, -2], [-4, -5, 1, 5], [-4, -1, 6, 1], [-4, 3, 5, 6]

     

     

    In the second example, with the visualization we find all the integer points in the inside intersection of  a cone and a cylinder:

    A := <1, 0, 0; 0, (1/2)*sqrt(3), -1/2; 0, 1/2, (1/2)*sqrt(3)>:  # Matrix of rotation around x-axis at Pi/6 radians

    f := unapply(A^(-1) . <x, y, z-4>, x, y, z):  

    S0 := {4*x^2+4*y^2 < z^2}:  # The inner of the cone

    S1 := {x^2+z^2 < 4}:  # The inner of the cylinder

    S2 := evalf(eval(S1, {x = f(x, y, z)[1], y = f(x, y, z)[2], z = f(x, y, z)[3]})):

    S := IntegerPoints2(`union`(S0, S2), [x, y, z]);  # The integer points inside of the intersection of the cone and the rotated cylinder

    Points := plots[pointplot3d](S, color = red, symbol = solidsphere, symbolsize = 8):

    Sp := plot3d([r*cos(phi), r*sin(phi), 2*r], phi = 0 .. 2*Pi, r = 0 .. 5, style = surface, color = "LightBlue", transparency = 0.7):

    F := plottools[transform]((x, y, z)->convert(A . <x, y, z>+<0, 0, 4>, list)):

    S11 := plot3d([2*cos(t), y, 2*sin(t)], t = 0 .. 2*Pi, y = -4 .. 7, style = surface, color = "LightBlue", transparency = 0.7):

    plots[display]([F(S11), Sp, Points], scaling = constrained, orientation = [25, 75], axes = normal);

          

     

     

    In the third example, we are looking for the integer points in a non-convex area between two parabolas. Here we have to specify ourselves the ranges to enumeration (Optimization[Minimize] command fails for this example):

    P := IntegerPoints2([y > (-x^2)*(1/2)+2, y < -x^2+8], [x, y], [-4 .. 4, -4 .. 8]);

    A := plots[pointplot](P, color = red, symbol = solidcircle, symbolsize = 10):

    B := plot([(-x^2)*(1/2)+2, -x^2+8], x = -4 .. 4, -5 .. 9, color = blue):

    plots[display](A, B, scaling = constrained);

         

     

     IntegerPoints2.mw

     

    Disclaimer: This blog post has been contributed by Dr. Nicola Wilkin, Head of Teaching Innovation (Science), College of Engineering and Physical Sciences and Jonathan Watkins from the University of Birmingham Maple T.A. user group*. 

    We all know the problem. During the course of a degree, students become experts at solving problems when they are given the sets of equations that they need to solve. As anyone will tell you, the skill they often lack is the ability to produce these sets of equations in the first place. With Maple T.A. it is a fairly trivial task to ask a student to enter the solution to a system of equations and have the system check if they have entered it correctly. I speak with many lecturers who tell me they want to be able to challenge their students, to think further about the concepts. They want them to be able to test if they can provide the governing equations and boundary conditions to a specific problem.

    With Maple T.A. we now have access to a math engine that enables us to test whether a student is able to form this system of equations for themselves as well as solve it.

    In this post we are going to explore how we can use Maple T.A. to set up this type of question. The example I have chosen is 2D Couette flow. For those of you unfamiliar with this, have a look at this wikipedia page explaining the important details.

    In most cases I prefer to use the question designer to create questions. This gives a uniform interface for question design and the most flexibility over layout of the question text presented to the student.

    1. On the Questions tab, click New question link and then choose the question designer.
    2. For the question title enter "System of equations for Couette Flow".
    3. For the question text enter the text

      The image below shows laminar flow of a viscous incompressible liquid between two parallel plates.



      What is the system of equations that specifies this system. You can enter them as a comma separated list.

      e.g. diff(u(y),y,y)+diff(u(y),y)=0,u(-1)=U,u(h)=0

      You then want to insert a Maple graded answer box but we'll do that in a minute after we have discussed the algorithm.

      When using the questions designer, you often find answers are longer than width of the answer box. One work around is to change the width of all input boxes in a question using a style tag. Click the source button on the editor and enter the following at the start of the question

      <style id="previewTextHidden" type="text/css">
      input[type="text"] {width:300px !important}
      </style>


      Pressing source again will show the result of this change. The input box should now be significantly wider. You may find it useful to know the default width is 186px.
    4. Next, we need to add the algorithm for this question. The teacher's answer for this question is the system of equations for the flow in the picture.

      $TA="diff(u(y),y,y) = 0, u(0) = 0, u(h) = U";
      $sol=maple("dsolve({$TA})");


      I always set this to $TA for consitency across my questions. To check there is a solution to this I use a maple call to the dsolve function in Maple, this returns the solution to the provided system of equations. Pressing refresh on next to the algorithm performs these operations and checks the teacher's answer.

      The key part of this question is the grading code in the Maple graded answer box. Let's go ahead and add the answer box to the question text. I add it at the end of the text we added in step 3. Click Insert Response area and choose the Maple-graded answer box in the left hand menu. For the answer enter the $TA variable that we defined in the algorithm. For the grading code enter

      a:=dsolve({$RESPONSE}):
      evalb({$sol}={a}) 


      This code checks that the students system of equations produces the same solution as the teachers. Asking the question in this way allows a more open ended response for the student.

      To finish off make sure the expression type is Maple syntax and Text entry only is selected.
    5. Press OK and then Finish on the Question designer screen.

    That is the question completed. To preview a working copy of the question, have a look here at the live preview of this question. Enter the system of equations and click How did I do?

      

    I have included a downloadable version of the question that contains the .xml file and image for this question. Click this link to download the file. The question can also be found on the Maple T.A. cloud under "System of equations for Couette Flow".

    * Any views or opinions presented are solely those of the author(s) and do not necessarily represent those of the University of Birmingham unless explicitly stated otherwise.

    Disclaimer: This blog post has been contributed by Dr. Nicola Wilkin, Head of Teaching Innovation (Science), College of Engineering and Physical Sciences and Jonathan Watkins from the University of Birmingham Maple T.A. user group*.

     

    If you have arrived at this post you are likely to have a STEM background. You may have heard of or had experience with Maple T.A or similar products in the past. For the uninitiated, Maple T.A. is a powerful system for learning and assessment designed for STEM courses, backed by the power of the Maple computer algebra engine. If that sounds interesting enough to continue reading let us introduce this series of blog posts for the mapleprimes website contributed by the Maple T.A. user group from the University of Birmingham(UoB), UK.

    These posts mirror conversations we have had amongst the development team and with colleagues at UoB and as such are likely of interest to the wider Maple T.A. community and potential adopters. The implementation of Maple T.A. over the last couple of years at UoB has resulted in a strong and enthusiastic knowledge base which spans the STEM subjects and includes academics, postgraduates, undergraduates both as users and developers, and the essential IT support in embedding it within our Virtual Learning Environment (VLE), CANVAS at UoB.

    By effectively extending our VLE such that it is able to understand mathematics we are able to deliver much wider and more robust learning and assessment in mathematics based courses. This first post demonstrates that by comparing the learning experience between a standard multiple choice question, and the same material delivered in a Maple TA context.

    To answer this lets compare how we might test if a student can solve a quadratic equation, and what we can actually test for if we are not restricted to multiple choice. So we all have a good understanding of the solution method, let's run through a typical paper-based example and see the steps to solving this sort of problem.

    Here is an example of a quadratic

    To find the roots of this quadratic means to find what values of x make this equation equal to zero. Clearly we can just guess the values. For example, guessing 0 would give

    So 0 is not a root but -1 is.

    There are a few standard methods that can be used to find the roots. The point though is the answer to this sort of question takes the form of a list of numbers. i.e. the above example has the roots -1, 5. For quadratics there are always two roots. In some cases two roots could be the same number and they are called repeated roots. So a student may want to answer this question as a pair of different numbers 3, -5, the same number repeated 2, 2 or a single number 2. In the last case they may only list a repeated roots once or maybe they could only find one root from a pair of roots. Either way there is quite a range of answer forms for this type of question.

    With the basics covered let us see how we might tackle this question in a standard VLE. Most are not designed to deal with lists of variable length and so we would have to ask this as a multiple choice question. Fig. 1, shows how this might look.

    VLE Question

    Fig 1: Multiple choice question from a standard VLE

    Unfortunately asking the question in this way gives the student a lot of implicit help with the answer and students are able to play a process of elimination game to solve this problem rather than understand or use the key concepts.

    They can just put the numbers in and see which work...

    Let's now see how we may ask this question in Maple T.A.. Fig. 2 shows how the question would look in Maple T.A. Clearly this is not multiple choice and the student is encouraged to answer the question using a simple list of numbers separated by commas. The students are not helped by a list of possible answers and are left to genuinely evaluate the problem. They are able to provide a single root or both if they can find them, and moreover the question is not fussy about the way students provide repeated roots. After a student has attempted the question, in the formative mode, a student is able to review their answer and the teacher's answer as well as question specific feedback, Fig. 3. We'll return to the power of the feedback that can be incorporated in a later post.

    Maple T.A. Question

    Fig. 2: Free response question in Maple T.A.

      

    Maple T.A. Answer

    Fig. 3: Grading response from Maple T.A.

    The demo of this question and others presented in this blog, are available as live previews through the UoB Maple T.A. user group site.

    Click here for a live demo of this question.

    The question can be downloaded from here and imported as a course module to your Maple T.A. instance. It can also be found on the Maple TA cloud by searching for "Find the roots of a quadratic". Simply click on the Clone into my class button to get your own version of the question to explore and modify.

    * Any views or opinions presented are solely those of the author(s) and do not necessarily represent those of the University of Birmingham unless explicitly stated otherwise.

    This post is my attempt to answer the question from   here : how to find all integer points (all points with integer coordinates) in the intersection of two cubes. The following procedure  IntegerPoints  solves a more general problem: it finds all the integer points of a bounded polyhedral region of arbitrary dimension, defined by a system of linear inequalities and / or equations.

    Required parameters of the procedure: SN is a set or a list of linear inequalities and/or equations with any number of variables, the Var is the list of variables. The procedure returns the set of all integer points, satisfying the conditions  SN .

    Code of the procedure:

    restart;

    IntegerPoints := proc (SN::{list, set}, Var::list)

    local SN1, sn, n, Sol, k, i, s, S, R;

    uses PolyhedralSets, SolveTools[Inequality];

    SN1 := convert(evalf(SN), fraction);

    for sn in SN1 do

    if type(sn, `<`) then SN1 := subs(sn = (`<=`(op(sn))), SN1)

    end if; end do;

    if IsBounded(PolyhedralSet(SN1)) = false then error "The region should be bounded" end if;

    n := nops(Var);

    Sol := LinearMultivariateSystem(SN, Var);

    if Sol = {} then return {} else

    k := 0;

    for s in Sol do if nops(indets(s[1])) = 1 then

    S[0] := [[]];

    for i to n do

    S[i] := [seq(seq([op(j1), op(j2)], j2 = [isolve(eval(s[i], j1))]), j1 = S[i-1])] end do;

    k := k+1; R[k] := op(S[n]);

    end if; end do;

    convert(R, set);

    map(t->rhs~(t), %);

    end if;

    end proc:

     

    Examples of use:

    IntegerPoints({x > 0, y > 0, z > 0, 2*x+3*y+z < 12}, [x, y, z]);

           

      {[1, 1, 1], [1, 1, 2], [1, 1, 3], [1, 1, 4], [1, 1, 5], [1, 1, 6], [1, 2, 1], [1, 2, 2], [1, 2, 3], [2, 1, 1], [2, 1, 2],

                                       [2, 1, 3], [2, 1, 4], [2, 2, 1], [3, 1, 1], [3, 1, 2]}

     

    IntegerPoints({x > 0, y > 0, z > 0, 2*x+3*y+z = 12}, [x, y, z]);

                                        {[1, 1, 7], [1, 2, 4], [1, 3, 1], [2, 1, 5], [2, 2, 2], [3, 1, 3], [4, 1, 1]}

     

    IntegerPoints([x > 0, y > 0, z > 0, 2*x+3*y+z = 12, x+y+z <= 6], [x, y, z]);

                                                               {[1, 3, 1], [2, 2, 2], [4, 1, 1]}

    isolve({x > 0, y > 0, z > 0, 2*x+3*y+z < 12});  #  isolve fails with these examples

                  Warning, solutions may have been lost

    isolve({x > 0, y > 0, z > 0, 2*x+3*y+z = 12});

                  Warning, solutions may have been lost

     

    In the following example (with a visualization) we find all integer point in the intersection of a square and a triangle:

    S1 := {x > 0, y > 0, x < 13/2, y < 13/2}:

    S2 := {y > (1/4)*x+1, y < 2*x, y+x < 12}:

    S := IntegerPoints(`union`(S1, S2), [x, y]):

    Region := plots[inequal](`union`(S1, S2), x = 0 .. 7, y = 0 .. 7, color = "LightGreen", nolines):

    Points := plot([op(S)], style = point, color = red, symbol = solidcircle):

    Square := plottools[curve]([[0, 0], [13/2, 0], [13/2, 13/2], [0, 13/2], [0, 0]], color = blue, thickness = 3):

    Triangle := plottools[curve]([[4/7, 8/7], [4, 8], [44/5, 16/5], [4/7, 8/7]], color = blue, thickness = 3):

    plots[display](Square, Triangle, Points, Region, scaling = constrained);

                                               

     

     

    In the following example (with a visualization) we find all integer point in the intersection of two cubes. The second cube is obtained from the first cube by rotation with orthogonal matrix  A  and by a translation:

    A := <1/3, 2/3, 2/3; -2/3, 2/3, -1/3; -2/3, -1/3, 2/3>:

    f := unapply(A^(-1).<x+5, y-4, z-7>, x, y, z):

    S1 := {x > 0, y > 0, z > 0, x < 6, y < 6, z < 6}:

    S2 := eval(S1, {x = f(x, y, z)[1], y = f(x, y, z)[2], z = f(x, y, z)[3]}):

    S := IntegerPoints(`union`(S1, S2), [x, y, z]);

    Points := plots[pointplot3d](S, color = red, symbol = box):

    Cube := plottools[cuboid]([0, 0, 0], [6, 6, 6], color = blue, linestyle = solid):

    F := plottools[transform]((x, y, z)->convert(A.<x, y, z>+<-5, 4, 7>, list)):

    plots[display](Cube,  F(Cube), Points, scaling = constrained, linestyle = solid, transparency = 0.7, orientation = [25, 75], axes = normal);

     

     

     

    In the example below, all the ways to exchange $ 1 coins of 1, 5, 10, 25 and 50 cents, if the number of coins no more than 8, there is no pennies and there is at least one 50-cent coin:

    IntegerPoints({x1 = 0, x2 >= 0, x3 >= 0, x4 >= 0, x5 >= 1,  x1+5*x2+10*x3+25*x4+50*x5 = 100, x1+x2+x3+x4+x5 <= 8}, [x1, x2, x3, x4, x5]);

    nops(%);

                                  {[0, 0, 0, 0, 2], [0, 0, 0, 2, 1], [0, 0, 5, 0, 1], [0, 1, 2, 1, 1], [0, 2, 4, 0, 1],

                                                     [0, 3, 1, 1, 1], [0, 4, 3, 0, 1], [0, 5, 0, 1, 1]}

                                                                                        8

     

    Integer_points.mw

     

    Addition: Below in my comments another procedure  IntegerPoints1  is presented that solves the same problem.

    Some Maple 18 short (and I believe elegant) code for doing gravitational simulations with N bodies in space:

     

    N_body_problem.mw

     

    Initial velocities have been tweaked to keep the system stable for the duration of the animation.

     

    Please feel free to fiddle with its parameters, velocities and positions and/or N itself, to produce more interesting animations or re-use the code therein (You can safely ignore the (c), it's there just for archiving purposes).

     

    The following are animations from three runs with N=4, N=3 and N=2, no other parameters changed.

     

    There has been a spate of Questions posted in the past week about computing eigenvalues. Invariably, the Questioners have computed some eigenvalues by applying fsolve to a characteristic polynomial obtained from a floating-point matrix via LinearAlgebra:-Determinant. They are then surprised when various tests show that these eigenvalues are not correct. In the following worksheet, I show that the eigenvalues computed by the fsolve@Determinant method (when applied to a floating-point matrix) are 100% garbage for dense matrices larger than about Digits x Digits. The reason for this is that computing the determinant introduces too much round-off error into the coefficients of the characteristic polynomial. The best way to compute the eigenvalues is to use LinearAlgebra:-Eigenvalues or LinearAlgebra:-Eigenvectors. Furthermore, very accurate results can be obtained without increasing Digits.

     

    The correct and incorrect ways to compute floating-point eigenvalues

    Carl Love 2016-Jan-18

    restart:

    Digits:= 15:

    macro(LA= LinearAlgebra):

    n:= 2^5:  #Try also 2^3 and 2^4.

    A:= LA:-RandomMatrix(n):

    A is an exact matrix of integers; Af is its floating-point counterpart.

    Af:= Matrix(A, datatype= float[8]):

    P:= LA:-CharacteristicPolynomial(A, x):

    P is the exact characteristic polynomial with integer coefficients; Pf is the floating-point characteristic polynomial computed by the determinant method.

    Pf:= LA:-Determinant(Af - LA:-DiagonalMatrix([x$n])):

    RP:= [fsolve(P, complex)]:

    RP is the list of floating-point eigenvalues computed from the exact polynomial; RPf is the list of eigenvalues computed from Pf.

    RPf:= [fsolve(Pf, complex)]:

    RootPlot:= (R::list(complexcons))->
         plot(
              [Re,Im]~(R), style= point, symbol= cross, symbolsize= 24,
              axes= box, color= red, labels= [Re,Im], args[2..]
         )
    :

    RootPlot(RP);

    RootPlot(RPf);

    We see that the eigenvalues computed from the determinant are completely garbage. The characteristic polynomial might as well have been x^n - a^n for some positive real number a > 1.

     

    Ef is the eigenvalues computed from the floating-point matrix Af using the Eigenvalues command.

    Ef:= convert(LA:-Eigenvalues(Af), list):

    RootPlot(Ef, color= blue);

    We see that this eigenvalue plot is visually indistinguishable from that produced from the exact polynomial. This is even more obvious if I plot them together:

    plots:-display([RootPlot(Ef, color= blue), RootPlot(RP)]);

    Indeed, we can compare the two lists of  eigenvalues and show that the maximum difference is exceedingly small.

     

    The following procedure is a novel way of sorting a list of complex numbers so that it can be compared to another list of almost-equal complex numbers.

    RootSort:= (R::list(complexcons))-> sort(R, key= abs*map2(`@`, signum+2, Re+Im)):


    max(abs~(RootSort(RP) -~ RootSort(Ef)));

    HFloat(1.3258049636636544e-12)

     

     

    ``

     

    Download Eigenvalues.mw

    A new Maple e-book, Multivariate Calculus Study Guide, is now available. Part of the Clickable Calculus collection of interactive Maple e-books, this guide takes full advantage of Maple’s Clickable Math approach. It has over 600 worked examples, the vast majority of which are solved using interactive, Clickable Math techniques. 

    Deisgned to help students taking this course, instructors may also find this e-book useful as a guide to using Clickable Math to teach Multivariate Calculus.

    See Multivariate Calculus Study Guide for more information.

     

    eithne

    In addition to the Maple 2015.2 and MapleSim 2015.2 updates for Mac, we have just released updates to both Maple and MapleSim for Windows and Linux.

    Maple 2015.2a provides a fix for the sum bug reported here.

    MapleSim 2015.a provides a variety of interface improvements, and updates to the MapleSim Battery Library and MapleSim CAD Toolbox.

    For Mac users, these improvements are included with the Maple 2015.2/MapleSim 2015.2 updates.

    All updates are available through the Check for Updates system, and are also available from our website on the downloads section of our website.

    eithne

    We have just released updates to Maple 2015 and MapleSim 2015 that fix the problems on Mac OS X 10.11 (El Capitan).  If you want to use the new OS, you should update your products.

    Updates are available through Check for Updates and from the Downloads section of our website. See Maple 2015.2 and MapleSim 2015.2 for details. MapleSim users, please note that this update also gives you all the new features in MapleSim 2015.2.

    If you are using earlier versions of these products, please read the  Maple and MapleSim on Mac OS X 10.11 FAQ for more information about your options.

     

    eithne

    Consider the well-known Euler's formula  

     eix = cos x + i sin x   

    When we calculate that for  x = π  we get:

    eiπ = cos π + i sin π   or

    eiπ = −1 + i × 0   (because cos π = −1 and sin π = 0)  or

    eiπ = −1  or  eiπ + 1 = 0

    It seems absolutely magical that such a neat equation combines  5  fundamental constants: e ,  i ,  π , 1 , 0

    The purpose of this post - to give a simple visualization of equality  eiπ = −1  (statical and animated) by expanding  eiπ  in a series of complex numbers. These numbers we represent as vectors in the plane. We will see that the partial sums of this series are broken lines like a spiral, twisting around the point -1 steadily approaching to it.

    Euler procedure has one required parameter  n is positive integer - the number of displayed terms of the series  for  eiπ  

    Optional parameter  a  is any symbol (by default  a=NULL). We use this option if  instead of a static spiral want to see an animated spiral. 

    Procedure code can be found in the attached file  Euler.mw

     

    Examples of use.

    The first example shows  8 terms of the series (broken line of 8 units):

    Euler(8);

                    

     

     

    The terms of the series where  n> = 10  on the same plot can not be seen as very small. In this case, we use  the second plot with magnification of  100 : 1 .  

    The second example:

    Euler(14);

     

     

     

    In the third example, we see an animated broken line. It's  first 9 units represented  on the left plot, and then for n> = 10 on the right plot:

    Euler(13, a);

      

     

    Euler.mw

    First 56 57 58 59 60 61 62 Last Page 58 of 292