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
  •  

    How to prove the inequality x^(4*y)+y^(4*x) <= 2 provided x^2+y^2 = 2, 0 <= x, 0 <= y? That problem was posed  by Israeli mathematician nicked by himself as arqady in Russian math forum and was not answered there.I know how to prove that with Maple and don't know how to prove that without Maple. Neither LagrangeMultipliers nor extrema work here. The difficulty consists in the nonlinearity both the target function and the main constraint. The first step is to linearize the main constraint and the second step is to reduce the number of variables to one.

    restart; A := eval(x^(4*y)+y^(4*x), [x = sqrt(u), y = sqrt(v)]);

    (u^(1/2))^(4*v^(1/2))+(v^(1/2))^(4*u^(1/2))

    (1)

     

    B := expand(A);

    u^(2*v^(1/2))+v^(2*u^(1/2))

    (2)

    C := eval(B, u = 2-v);

    (2-v)^(2*v^(1/2))+v^(2*(2-v)^(1/2))

    (3)

    It is more or less clear that the plot of F is symmetric wrt  the straight line v=1. This motivates the following change of variable  to obtain an even function.

    F := simplify(expand(eval(C, v = z+1)), symbolic, power);

    (1-z)^(2*(z+1)^(1/2))+(z+1)^(2*(1-z)^(1/2))

    (4)

    NULL

    The plots suggest the only maximim of F at z=0 and its concavity.

    Student[Calculus1]:-FunctionPlot(F, z = -1 .. 1);

     

    Student[Calculus1]:-FunctionPlot(diff(F, z, z), z = -1 .. 1);

     

    As usually, numeric global solvers cannot prove certain inequalities. However, the GlobalSearch command of the DirectSearch package indicates the only local maximum of  F and F''.NULL

    Digits := 25; DirectSearch:-GlobalSearch(F, {z = -1 .. 1}, maximize, solutions = 3, tolerances = 10^(-15)); DirectSearch:-GlobalSearch(diff(F, z, z), {z = -1 .. 1}, maximize, solutions = 3, tolerances = 10^(-15));

    Array([[0.8e-23, [z = -0.1980181305884928531875965e-12], 36]])

    (5)

    The series command confirms a local maximum of F at z=0.

    series(F, z, 6);

    series(2-(2/3)*z^4+O(z^6),z,6)

    (6)

    The extrema command indicates only the value of F at a critical point, not outputting its position.

    extrema(F, z); extrema(F, z, 's');

    {2}

    (7)

    solve(F = 2);

    RootOf((1-_Z)^(2*(_Z+1)^(1/2))+(_Z+1)^(2*(1-_Z)^(1/2))-2)

    (8)

    DirectSearch:-SolveEquations(F = 2, {z = -1 .. 1}, AllSolutions, solutions = 3);

    Matrix(1, 4, {(1, 1) = 0., (1, 2) = Vector(1, {(1) = 0.}), (1, 3) = [z = -0.5463886313e-6], (1, 4) = 27})

    (9)

    DirectSearch:-SolveEquations(F = 2, {z = -1 .. 1}, AllSolutions, solutions = 3, assume = integer);

    Matrix(1, 4, {(1, 1) = 0., (1, 2) = Vector(1, {(1) = 0.}), (1, 3) = [z = 0], (1, 4) = 30})

    (10)

    NULL

     PS. I see my proof needs an additional explanation. The DirectSearch command establishes the only both local and global  maximum of F is located at z= -1.98*10^(-13) up to default error 10^(-9). After that  the series command confirms a local maximum at z=0. Combining these, one draws the conclusion that the global maximum is placed exactly at z=0 and equals 2. In order to confirm that the only real root of F=2 at z=0  is found approximately and exactly by the DirectSearch.

    Download maxi.mw

    I thought I would share some code for computing sparse matrix products in Maple.  For floating point matrices this is done quickly, but for algebraic datatypes there is a performance problem with the builtin routines, as noted in http://www.mapleprimes.com/questions/205739-How-Do-I-Improve-The-Performance-Of

    Download spm.txt

    The code is fairly straightforward in that it uses op(1,A) to extract the dimensions and op(2,A) to extract the non-zero elements of a Matrix or Vector, and then loops over those elements.  I included a sparse map function for cases where you want to map a function (like expand) over non-zero elements only.

    # sparse matrix vector product
    spmv := proc(A::Matrix,V::Vector)
    local m,n,Ae,Ve,Vi,R,e;
    n, m := op(1,A);
    if op(1,V) <> m then error "incompatible dimensions"; end if;
    Ae := op(2,A);
    Ve := op(2,V);
    Vi := map2(op,1,Ve);
    R := Vector(n, storage=sparse);
    for e in Ae do
    n, m := op(1,e);
    if member(m, Vi) then R[n] := R[n] + A[n,m]*V[m]; end if;
    end do;
    return R;
    end proc:
    # sparse matrix product
    spmm := proc(A::Matrix, B::Matrix)
    local m,n,Ae,Be,Bi,R,l,e,i;
    n, m := op(1,A);
    i, l := op(1,B);
    if i <> m then error "incompatible dimensions"; end if;
    Ae := op(2,A);
    Be := op(2,B);
    R := Matrix(n,l,storage=sparse);
    for i from 1 to l do
    Bi, Be := selectremove(type, Be, (anything,i)=anything);
    Bi := map2(op,[1,1],Bi);
    for e in Ae do
    n, m := op(1,e);
    if member(m, Bi) then R[n,i] := R[n,i] + A[n,m]*B[m,i]; end if;
    end do;
    end do;
    return R;
    end proc:
    # sparse map
    smap := proc(f, A::{Matrix,Vector})
    local B, Ae, e;
    if A::Vector then
    B := Vector(op(1,A),storage=sparse):
    else
    B := Matrix(op(1,A),storage=sparse):
    end if;
    Ae := op(2,A);
    for e in Ae do
    B[op(1,e)] := f(op(2,e),args[3..nargs]);
    end do;
    return B;
    end proc:


    As for how it performs, here is a demo inspired by the original post.

    n := 674;
    k := 6;
    A := Matrix(n,n,storage=sparse):
    for i to n do
      for j to k do
        A[i,irem(rand(),n)+1] := randpoly(x):
      end do:
    end do:
    V := Vector(n):
    for i to k do
      V[irem(rand(),n)+1] := randpoly(x):
    end do:
    C := CodeTools:-Usage( spmv(A,V) ):  # 7ms, 25x faster
    CodeTools:-Usage( A.V ):  # 174 ms
    B := Matrix(n,n,storage=sparse):
    for i to n do
      for j to k do
        B[i,irem(rand(),n)+1] := randpoly(x):
      end do:
    end do:
    C := CodeTools:-Usage( spmm(A,B) ):  # 2.74 sec, 50x faster
    CodeTools:-Usage( A.B ):  # 2.44 min
    # expand and collect like terms
    C := CodeTools:-Usage( smap(expand, C) ):

    CameraProfiler.mw

    D700_Profile.xlsx

    This Application uses the xrite color checker to obtain Forward and Color Matrices as defined by Adobe.

    It compares the camera gamut based on the above matrices to the 1931 Standard Observer using LEDs.

     

     

     

      Continuation.
      One way to get rolling without slipping animation in 3d. The trajectory and circle are divided into segments of equal length. In the next segment of the trajectory we construct circle, taking into account the fact that it turned on one segment. Rolling sphere or cylinder can be simulated, if we take plottools templates of the same radius, and replace them on the site of our circle.

    ROLLING_WITHOUT_3d.mw













    Maple is a scientific software based on Computational Algebraic System (SAC) which has enabled this work entirely solve applied to Civil Engineering, Mechanical and Mecatrónica.The present problems in education, research and engineering are developed with static work sheets ie coding used innecesaria.Maple proposed models are shown below with an innovative structure; with the method of graphics algorithms and embedded components; putting aside the traditional and obsolete syntax; using dynamic worksheets as viable and optimal solutions to interpret and explain problems Ingineering.Design Advanced Analysis Tools (Applied Mathematics) Sophisticated Applications (efficient algorithms) and Multiple deployment options (different styles); this allowed generate math apps (applications engineering); can be interactive on the internet without the need to have the software installed on our computer; This way our projects can be used with a vision of sustainability around the world. Resulting in the generation of data and curves; which in turn will help you make better decisions analytical and predictive modeling in manufacturing and 3D objects; which would lead to new patterns of contrasting solutions.

    ECI_2016.pdf

    ECI_2016v_full.mw

    Lenin Araujo Castillo

    Ambassador of Maple - Perú

     

     

     

    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






    First 68 69 70 71 72 73 74 Last Page 70 of 305