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
  • The attached worksheet shows a small selection of new and improved results in integration for Maple 2016. Note that integration is a vast topic, so there will always be more improvements that can be made, but be sure that we are working on them.

    Maple2016_Integration.mw

    A selection of new and improved integration results for Maple 2016

    New answers in Maple 2016

     

     

    Indefinite integrals:

     

    int(sqrt(1+sqrt(z-1)), z);

    (4/5)*(1+(z-1)^(1/2))^(5/2)-(4/3)*(1+(z-1)^(1/2))^(3/2)

    (1.1)

    int(arctan((-1+sec(x))^(1/2))*sin(x), x);

    -arctan((-(1/sec(x)-1)*sec(x))^(1/2))/sec(x)+(1/2)*(-1+sec(x))^(1/2)/sec(x)+(1/2)*arctan((-1+sec(x))^(1/2))

    (1.2)

    int(((1+exp(I*x))^2+(1+exp(-I*x))^2)/(1-2*c*cos(x)+c^2), x);

    -x-2*x/c-x/c^2+I*exp(I*x)/c-I*exp(-I*x)/c-I*c*ln(exp(I*x)-1/c)/(c-1)-I*ln(exp(I*x)-1/c)/(c-1)-I*ln(exp(I*x)-1/c)/(c*(c-1))-I*ln(exp(I*x)-1/c)/(c^2*(c-1))+I*c*ln(-c+exp(I*x))/(c-1)+I*ln(-c+exp(I*x))/(c-1)+I*ln(-c+exp(I*x))/(c*(c-1))+I*ln(-c+exp(I*x))/(c^2*(c-1))

    (1.3)

    int(x^4/arccos(x)^(3/2),x);

    (1/4)*(-x^2+1)^(1/2)/arccos(x)^(1/2)-(1/4)*2^(1/2)*Pi^(1/2)*FresnelC(2^(1/2)*arccos(x)^(1/2)/Pi^(1/2))+(3/8)*sin(3*arccos(x))/arccos(x)^(1/2)-(3/8)*2^(1/2)*Pi^(1/2)*3^(1/2)*FresnelC(2^(1/2)*3^(1/2)*arccos(x)^(1/2)/Pi^(1/2))+(1/8)*sin(5*arccos(x))/arccos(x)^(1/2)-(1/8)*2^(1/2)*Pi^(1/2)*5^(1/2)*FresnelC(2^(1/2)*5^(1/2)*arccos(x)^(1/2)/Pi^(1/2))

    (1.4)

     

    Definite integrals:

    int(arcsin(sin(z)), z=0..1);

    1/2

    (1.5)

    int(sqrt(1 - sqrt(1+z)), z=0..1);

    ((4/5)*I)*(2^(1/2)-1)^(3/2)*2^(1/2)+((8/15)*I)*(2^(1/2)-1)^(3/2)

    (1.6)

    int(z/(exp(2*z)+4*exp(z)+10),z = 0 .. infinity);

    (1/20)*dilog((I*6^(1/2)-3)/(-2+I*6^(1/2)))-((1/60)*I)*6^(1/2)*dilog((I*6^(1/2)-3)/(-2+I*6^(1/2)))+(1/20)*dilog((I*6^(1/2)+3)/(2+I*6^(1/2)))+((1/60)*I)*6^(1/2)*dilog((I*6^(1/2)+3)/(2+I*6^(1/2)))+((1/120)*I)*6^(1/2)*ln(2+I*6^(1/2))^2-((1/120)*I)*6^(1/2)*ln(2-I*6^(1/2))^2+(1/40)*ln(2+I*6^(1/2))^2+(1/40)*ln(2-I*6^(1/2))^2+(1/60)*Pi^2

    (1.7)

    simplify(int(sinh(a*abs(x-y)), y=0..c, 'method'='FTOC'));

    (1/2)*(piecewise(x < 0, 0, 0 <= x, 2*exp(-a*x))+piecewise(x < 0, 0, 0 <= x, -4)+2*piecewise(c <= x, -cosh(a*(-x+c))/a, x < c, (cosh(a*(-x+c))-2)/a)*a-exp(-a*x)+piecewise(x < 0, 0, 0 <= x, 2*exp(a*x))+4-exp(a*x))/a

    (1.8)

    int(ln(x+y)/(x^2+y), [x=0..infinity, y=0..infinity]);

    infinity

    (1.9)


    Definite integrals with assumptions on the parameters:

    int(x^(-ln(x)),x=0..b) assuming b > 0;

    (1/2)*erf(ln(b)-1/2)*Pi^(1/2)*exp(1/4)+(1/2)*Pi^(1/2)*exp(1/4)

    (1.10)

    int(exp(-z)*exp(-I*n*z)*cos(n*z),z = -infinity .. infinity) assuming n::integer;

    undefined

    (1.11)


    Integral of symbolic integer powers of sin(x) or cos(x):

    int(sin(x)^n,x) assuming n::integer;

    ` piecewise`(0 < n, -(Sum((Product(1+1/(n-2*j), j = 1 .. i))*sin(x)^(n-2*i-1), i = 0 .. ceil((1/2)*n)-1))*cos(x)/n+(Product(1-1/(n-2*j), j = 0 .. ceil((1/2)*n)-1))*x, n < 0, (Sum((Product(1-1/(n+2*j+1), j = 0 .. i))*sin(x)^(n+2*i+1), i = 0 .. -ceil((1/2)*n)-1))*cos(x)/n+(Product(1+1/(n+2*j-1), j = 1 .. -ceil((1/2)*n)))*ln(csc(x)-cot(x)), x)

    (1.12)

    int(cos(x)^n,x) assuming n::negint;

    -(Sum((Product(1-1/(n+2*j+1), j = 0 .. i))*cos(x)^(n+2*i+1), i = 0 .. -ceil((1/2)*n)-1))*sin(x)/n+(Product(1+1/(n+2*j-1), j = 1 .. -ceil((1/2)*n)))*ln(sec(x)+tan(x))

    (1.13)

    int(cos(x)^n,x) assuming n::posint;

    (Sum((Product(1+1/(n-2*j), j = 1 .. i))*cos(x)^(n-2*i-1), i = 0 .. ceil((1/2)*n)-1))*sin(x)/n+(Product(1-1/(n-2*j), j = 0 .. ceil((1/2)*n)-1))*x

    (1.14)

    Improved answers in Maple 2016

     

    int(sqrt(1+sqrt(x)), x);

    (4/5)*(1+x^(1/2))^(5/2)-(4/3)*(1+x^(1/2))^(3/2)

    (2.1)

    int(sqrt(1+sqrt(1+z)), z= 0..1);

    -(8/15)*2^(1/2)-(8/15)*(1+2^(1/2))^(3/2)+(4/5)*(1+2^(1/2))^(3/2)*2^(1/2)

    (2.2)

    int(signum(z^k)*exp(-z^2), z=-infinity..infinity) assuming k::real;

    (1/2)*(-1)^k*Pi^(1/2)+(1/2)*Pi^(1/2)

    (2.3)

    int(2*abs(sin(x*p)*sin(x)), x = 0 .. Pi) assuming p> 1;

    -2*(sin(Pi*p)*signum(sin(Pi*p))*cos(Pi/p)-p*sin(Pi/p)*cos(Pi*(floor(p)+1)/p)+sin(Pi*(floor(p)+1)/p)*cos(Pi/p)*p-sin(Pi*p)*signum(sin(Pi*p))-sin(Pi*(floor(p)+1)/p)*p+sin(Pi/p)*p)/((cos(Pi/p)-1)*(p^2-1))

    (2.4)

    int(1/(x^4-x+1), x = 0 .. infinity);

    -(sum(ln(-_R)/(4*_R^3-1), _R = RootOf(_Z^4-_Z+1)))

    (2.5)


    In Maple 2016, this multiple integral is computed over 3 times faster than it was in Maple 2015.

    int(exp(abs(x1-x2))*exp(abs(x1-x3))*exp(abs(x3-x4))*exp(abs(x4-x2)), [x1=0..R, x2=0..R, x3=0..R, x4=0..R], AllSolutions) assuming R>0;

    (1/8)*exp(4*R)-29/8+(7/2)*exp(2*R)-5*R*exp(2*R)+2*exp(2*R)*R^2-(5/2)*R

    (2.6)

    Austin Roche
    Mathematical Software, Maplesoft

    A wealth of knowledge is on display in MaplePrimes as our contributors share their expertise and step up to answer others’ queries. This post picks out one such response and further elucidates the answers to the posted question. I hope these explanations appeal to those of our readers who might not be familiar with the techniques embedded in the original responses.

    The Question: Variable Identification

    Don Carota wanted to know the best approach for finding variables that are not assigned to a value within an equation. He wrote:

    I got a set of equations to solve, like this one:

    eq[1]:=W[1,0]*(a*HRa[1,0]+b*ga[1,0]+c)=d*SR[1,1]/grid

    a,b,c,d are numbers, like 2.0458 and so on.

    When I want to solve the set, I need to tell Maple the command solve:

    solve( {seq(eq[i],i=1..N)},{variables});  (N is an integer of course)

    To set the variables, one must check each equation to write: {W[1,0],HRa[1,0],ga[1,0]...} and so on.

    I know that I can use the command is(variable,assignable) to check if a variable has not a value assigned already and, according to true/false I can construct the set {variables} and solve the set of equations.

    That´s an easy solution if I need to check variables under a certain pattern, like: X[1], X[2], X[3] since I can create a loop and check them one after the other. But my problem is that I have different names for variables or that variables change to assignable from assigned according to other conditions, so I can never be sure if W[1,0] is going to be a variable to compute in all steps instead of SR[1,1].

    for example:

    if a>3 then
    SR[1,1]:=1/2;
    else
    W[1,0]:=300:
    end if;

    So, when I need to type solve, the {variables} part is different according to each case. Is there any command that allows me to insert an expression and Maple can return me the variables or parameters in the expression that are not numeric already?

    (note that the link added to the is command above was added by me, not the original author)

    dharr and Carl Love provided solutions that use the indets command.

    The code provided by dharr is as follow:

    1. indets(eq[1],name);

    Result: gives the indeterminates: {a, b, c, d, HRa[1, 0], SR[1, 1], W[1, 0], ga[1, 0]}

    The code provided by Carl Love is as follows:

    1.       indets(eq[1], assignable(name));

    or, doing all equations at once,

    2.       indets({entries(eq, nolist)}, assignable(name));

     

    Further Explaining the indets and type commands.

    Both dharr and Carl Love provided an answer that used the indets command. In essence the indets command used in this example contains two arguments: indets(expr, typename). Expr is a rational expression that only uses the operations such as addition, subtraction, division, and multiplication. Typename is a parameter used when the desired return is a set containing all subexpressions in expr that are of type typename.

    Carl Love used the assignable(name) argument  for the typename parameter in order to return all the variables that can be assigned a value, excluding constants such as Pi that are also considered names. Indeed, assignable is a type and can be used without an additional argument. For example, the command indets(x+f(x)+y=1, assignable) returns {x,y,f(x)} because all three symbols can be assigned values. However, indets(x+f(x)+y=1, assignable(name)) returns just {x,y} because f(x) is of type function, not of type name. Similarly, indets(x+y=Pi, assignable) would return just {x,y} because Pi is not considered to be something that can be assigned to.

    Carl’s second command used ({entries(eq, nolist)} as the expr parameter. In this version, eq is the table whose members are the individual equations. Remember, the syntax x[1] creates a table whose name is x, and whose entry is the object assigned to x[1]. The entries(t) function returns a sequence of the table members, each member being placed in list brackets. By including the option nolist, the return is then a sequence of table members without list brackets. 

    Finally, note that different programmers will use different approaches to finding “indeterminants” in expressions. Dr. Lopez pointed out that some years ago he asked three different programmers about extracting the “assignable names” in an expression such as q:=x+Pi+cos(a). The naive indets(q) returns {a,x,cos(a)}, whereas indets(q,name) returns {Pi,a,x}. However, select(type,indets(q),name) returns {a,x}, as does indets(q,And(symbol,Not(constant))).

    Don Carota’s question is able to showcase some of the different types that are within Maple’s platform. Therefore, it is important to go over what the type-checking function is and what it does. In many contexts, it is not necessary to know the exact value of an expression; instead it is enough to know if the value belongs to a group of expressions that have similarities. Such groups are knows as types.

    Maple’s engine uses the type function in every single procedure to direct and maintain the flow of control in algorithms and to decide if the user’s input is valid. There are about 240 different types that Maple recognizes including: prime, string, symbol, list, etc.  Let’s see some examples of how the function works using elements from this question. 

    Type has two parameters: an expression e, and a valid type expression t. To check that the output of the entries(eq,nolist) is indeed not a list, the type command can be used as follows:

    As expected, the last command returns false! If you want to learn more about the type and indets commands you can visit their corresponding help pages: ?type, ?indets.

     

    This blog was written by Maplesoft’s intern Pia under the supervision of Dr. Robert Lopez. We both hope that you find this useful. If there is a particular question on MaplePrimes that you would like further explained, please let us know. 

    polygon_2_color.mw

    Imitation coloring both sides of the polygon in 3d.  We  build a new polygon in parallel with our polygon on a very short distance t. (We need any three points on the polygon plane, do not lie on a straight line.) This place in the program is highlighted in blue.

    Paint the polygons are in different colors.

    Valery Ochkov and Volodymyr Voloshchuk have developed a series of thermal engineering applications in Maple 2016. The applications explore steam turbine power generation and refrigeration cycles, and use the ThermophysicalData package for fluid properties.

    Their work can be found at the following locations on the Application Center.

    I especially like

    • this application, which optimizes the extraction pressures of a steam turbine to maximize its efficiency,
    • and this application, which plots the state of a two-stage refrigeration cycle on a pressure-enthalpy chart.

    This procedure calculate the equations of motions for Euclidean space and Minkowski space  with help of the Jacobian matrix.

    Procedures
    Calculation the equation of motions for Euclidean space and Minkowski space

    "EQM := proc(eq, g,xup,xa,xu , eta ,var)"

    Calling Sequence

     

    EQM(eq, g, xup, xa, xu, eta, var)

    Parameters

     

    parameterSequence

    -

    eq, g, xup, xa, xu, eta, var

    eq

    out

    equation of motion

    g

    out

    metric

    xup

    out

    velocitiy vector

    xa

    in

    position vector

    xu

    in

    vector of the independet coortinates

    eta

    in

    signature matrix for Minkowski space

    var

    in

    independet variable

     

    ``

     Procedur Code

     

    restart; with(linalg); EQM := proc (eq, g, xup, xa, xu, eta, var) local J, Jp, xdd, l, xupp, ndim; ndim := vectdim(xu); xup := vector(ndim); xupp := vector(ndim); for l to ndim do xup[l] := diff(xu[l](var), var); xupp[l] := diff(diff(xu[l](var), var), var) end do; J := jacobian(xa, xu); g := multiply(transpose(J), eta, J); g := map(simplify, g); Jp := jacobian(multiply(J, xup), xu); Jp := map(simplify, Jp); xdd := multiply(inverse(g), transpose(J), eta, Jp, xup); xdd := map(simplify, xdd); xdd := map(convert, xdd, diff); eq := vector(vectdim(xupp)); for l to ndim do eq[l] := xupp[l]+xdd[l] = 0 end do end proc

    ``

    Input

     

    xa := Vector(3, {(1) = R*sin(`&varphi;`)*cos(`&vartheta;`), (2) = R*sin(`&varphi;`)*sin(`&vartheta;`), (3) = R*cos(`&varphi;`)}); xu := Vector(2, {(1) = `&varphi;`, (2) = `&vartheta;`}); eta := Matrix(3, 3, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 1, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1})

     

    EQM(eq, g, xup, xa, xu, eta, t):

    Output EOM

     

    for i to vectdim(xu) do eq[i] end do;

    diff(diff(`&varphi;`(t), t), t)-cos(`&varphi;`)*sin(`&varphi;`)*(diff(`&vartheta;`(t), t))^2 = 0

     

    diff(diff(`&vartheta;`(t), t), t)+2*cos(`&varphi;`)*(diff(`&vartheta;`(t), t))*(diff(`&varphi;`(t), t))/sin(`&varphi;`) = 0

    (5.1)

    Output Line-Element

     

    ds2 := expand(multiply(transpose(xup), g, xup));

    (diff(`&varphi;`(t), t))^2*R^2+(diff(`&vartheta;`(t), t))^2*R^2-(diff(`&vartheta;`(t), t))^2*R^2*cos(`&varphi;`)^2

    (6.1)

    Output Metric

     

    assume(cos(`&varphi;`)^2 = 1-sin(`&varphi;`)^2); g := map(simplify, g)

    array( 1 .. 2, 1 .. 2, [( 2, 2 ) = (R^2*sin(`&varphi;`)^2), ( 1, 2 ) = (0), ( 2, 1 ) = (0), ( 1, 1 ) = (R^2)  ] )

    (7.1)

    ``

    ``

     

    Download bsp_jacobi.mw

    Procedures
    Calculation the equation of motions for Euclidean space and Minkowski space

    "EQM := proc(eq, g,xup,xa,xu , eta ,var)"

    Calling Sequence

     

    EQM(eq, g, xup, xa, xu, eta, var)

    Parameters

     

    parameterSequence

    -

    eq, g, xup, xa, xu, eta, var

    eq

    out

    equation of motion

    g

    out

    metric

    xup

    out

    velocitiy vector

    xa

    in

    position vector

    xu

    in

    vector of the independet coortinates

    eta

    in

    signature matrix for Minkowski space

    var

    in

    independet variable

     

    ``

     Procedur Code

     

    restart; with(linalg); EQM := proc (eq, g, xup, xa, xu, eta, var) local J, Jp, xdd, l, xupp, ndim; ndim := vectdim(xu); xup := vector(ndim); xupp := vector(ndim); for l to ndim do xup[l] := diff(xu[l](var), var); xupp[l] := diff(diff(xu[l](var), var), var) end do; J := jacobian(xa, xu); g := multiply(transpose(J), eta, J); g := map(simplify, g); Jp := jacobian(multiply(J, xup), xu); Jp := map(simplify, Jp); xdd := multiply(inverse(g), transpose(J), eta, Jp, xup); xdd := map(simplify, xdd); xdd := map(convert, xdd, diff); eq := vector(vectdim(xupp)); for l to ndim do eq[l] := xupp[l]+xdd[l] = 0 end do end proc

    ``

    Input

     

    t := x[0]/c; xa := Vector(4, {(1) = t, (2) = r*cos(`&varphi;`), (3) = r*sin(`&varphi;`), (4) = x[3]}); xu := Vector(4, {(1) = x[0], (2) = r, (3) = `&varphi;`, (4) = x[3]}); eta := Matrix(4, 4, {(1, 1) = -1, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (2, 1) = 0, (2, 2) = 1, (2, 3) = 0, (2, 4) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1, (3, 4) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 1})

     

    EQM(eq, g, xup, xa, xu, eta, tau):

    Output EOM

     

    for i to vectdim(xu) do eq[i] end do;

    diff(diff(x[0](tau), tau), tau) = 0

     

    diff(diff(r(tau), tau), tau)-(diff(`&varphi;`(tau), tau))^2*r = 0

     

    diff(diff(`&varphi;`(tau), tau), tau)+2*(diff(`&varphi;`(tau), tau))*(diff(r(tau), tau))/r = 0

     

    diff(diff(x[3](tau), tau), tau) = 0

    (5.1)

    Output Line-Element

     

    ds2 := expand(multiply(transpose(xup), g, xup));

    -(diff(x[0](tau), tau))^2/c^2+(diff(r(tau), tau))^2+(diff(`&varphi;`(tau), tau))^2*r^2+(diff(x[3](tau), tau))^2

    (6.1)

    Output Metric

     

    assume(cos(`&varphi;`)^2 = 1-sin(`&varphi;`)^2); g := map(simplify, g)

    array( 1 .. 4, 1 .. 4, [( 3, 3 ) = (r^2), ( 3, 4 ) = (0), ( 4, 1 ) = (0), ( 1, 1 ) = (-1/c^2), ( 4, 3 ) = (0), ( 4, 2 ) = (0), ( 2, 2 ) = (1), ( 3, 2 ) = (0), ( 3, 1 ) = (0), ( 2, 4 ) = (0), ( 1, 4 ) = (0), ( 1, 2 ) = (0), ( 2, 3 ) = (0), ( 4, 4 ) = (1), ( 2, 1 ) = (0), ( 1, 3 ) = (0)  ] )

    (7.1)

    ``

    ``

     

    Download bsp_jacobi_minkowski.mw

    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.

     

    First 58 59 60 61 62 63 64 Last Page 60 of 295