MaplePrimes Posts

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

Latest Post
  • Latest Posts Feed
  • A 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: How to sketch a line in space?

    vahid65 wanted to know how to sketch the line with equation (x-2)/3 = (y-1)/4 = (z-3)/3 in a three-dimensional space.

    This question was answered using two different approaches that we will discuss.

    The first approach, given by Preben Alsholm, suggested using these commands: solve, subs, and plots:-spacecurve.

    Preben provided the following lines of code:

    1. {(x-2)/3 , (y-1)/4 , (z-3)/3} =~t;
    2. solve(%,{x,y,z});
    3. L:=subs(%,[x,y,z]);
    4. plots:-spacecurve(L,t=-5..5,thickness=3,color=red);

    The first line sets the three expressions equal to t using the element wise operator =~.  This distributes the operation of equality over the elements of the set of expressions, forming a set of equations.

    Result-1: {(x-2)/3=t, (y-1)/4=t, (z-3)/3=t}

    The second line invokes the solve command. The solve command, solve(equations, variables), solves one or more equations or inequalities for their unknowns. So in this line, this command was used to solve each expression for its corresponding unknown.

    Result-2: {(x= 2+3t, y=1+4t, z= 3+3t}

    You may have noticed that the % symbol is used within the command. This symbol is referring to the equation label that was created chronologically last. 

    The third line uses the subs command. The subs command, subs(x=a,expr), substitutes “a” for “x” in the expression expr. In this case, “a” is the reference to the equation label referenced by (%) and expr is the sequence of variables x,y,z. The square brackets around expr forms a list, and the replacement imposed by the subs command replaces each of the three names x, y, and z with their equivalents in the set of equations returned by the solve command.

    Result-3: [2+3t,1+4t, 3+3t ]

    Finally the last line uses the plots:-spacecurve function.  This function, spacecurve(sc,r,opts),  graphs a parametrically defined curve in three-dimensional Cartesian space. 

    In this example the first parameter, sc, is replaced by L since L has the properties of a list. The parameter  r is an equation containing the parameter name and the parameter range; here it is the equation t=-5..5. Last but not least, the opts parameter (which is optional) gives the user the opportunity to specify the optional properties of the graph, properties such as thickness and color of the space curve. 

    Result 4: 

     

    Another contributer, Carl Love, suggested that these commands could be combined using the zip function, zip( f, u, v), which is an unusual application of it. The zip command applies elementwise to corresponding members of the two lists u and v, the binary function f, creating a new list r, whose members are f(uk,vk).

    Carl provided the following code:

    plots:-spacecurve(  zip(solve, [(x-2)/3 , (y-1)/4 , (z-3)/3] =~ t, [x,y,z]),  t= -5..5, thickness= 3, color= red, axes= normal);

     

    In this case zip is applying solve to u, a list of equations, and v, a list of variables. The equations in u are those in Result-1. The zip function returns the solution of each equation for the indicated variable, that is, the new list r is the list in Result-3. This list is the first argument of plots:-spacecurve. Finally, the parameter range and opts are up to the user’s preferences.

    A second approach was suggested by Kitonum. The difference between this approach and the first one is that here we are not using the solve command. Instead, we are treating the line as an intersection of two planes.

    Kitonum's code is as follows:

    1. L := [(x-2)*(1/3), (y-1)*(1/4), (z-3)*(1/3)]:
    2. plots[intersectplot](L[1]-L[2], L[2]-L[3], x = -4 .. 4, y = -4 .. 4, z = -4 .. 4, linestyle = 1, thickness = 3, axes = normal, orientation = [60, 75], view = [-1 .. 3, -4 .. 2, -1 .. 4]);

    The first statement initializes a list L that contains all the desired expressions in the given symmetric form of the line.

    In the second statement Kionum used the plots[intersectplot] command. This command graphs, in three-dimensional Cartesian space, the intersection of a pair of surfaces. This example uses the calling sequence: intersectplot(expr1, expr2, x=a..b, y=c..d, z= e..f, options)

    What are expr1 and expr2 used in Kitonum’s solution? The pairwise differences of L[1] and L[2], and L[2] and L[3] are planes, the intersection of which is the desired line in space.

    expr1 = L[1] – L[2] = (x-2)*(1/3)- (y-1)*(1/4)

    expr2= L[2] - L[3] = (y-1)*(1/4)-(z-3)*(1/3)

    The variables x,y, and z are the coordinate names and define the axes, whereas a, b, c, d, e, f define the ranges. In this case they were taken as -4 or 4.

    In the options parameter Kitonum used linestyle, thickness, axes, orientation, and  view. The help page “plot3d,option” details these and other options that apply.

     

    This blog was written by our 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. 

    eulermac(1/(n*ln(n)^2),n=2..N,1);  #Error
    Error, (in SumTools:-DefiniteSum:-ClosedForm) summand is singular in the interval of summation


    eulermac(1/(n*ln(n)^2+1),n=2..N,1);  #nonsense

     

     

    Spiral (equidistant) around the curve.  In this case, a spiral around the spiral.
    So without any sense. 
    spiral_around_curve.mw 
     
    If we re-save the animation with the program Easy GIF Animator, its size is reduced by about 10 times, and sometimes much more.


    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.

    First 8 9 10 11 12 13 14 Last Page 10 of 245