Maple 2021 Questions and Posts

These are Posts and Questions associated with the product, Maple 2021

Our user wondered about using PolynomialIdeals:

1.  If we have n+1 polynomials,  f, g1,...,gn,  how to determine if  f  is in the ideal generated by  g1,...,gn?

2.  If so, how to write  f  as a polynomial combination of   g1,...,gn? 

We suggested that;

The nicest interface to answer the first question is given by the ?PolynomialIdeals,Operators page: you can write

with(PolynomialIdeals):
with(Operators):
J := <g1, g2, ..., gn>;
f in J; # true or false

To answer the second question, you need to use the lower level  package (which underlies the  package). This will also answer the first question for you. In particular the  command. You can write:

(Edit Feb 1, 2022 - use  instead of 

with(Groebner):
G := [g1, g2, ..., gn];
ord := tdeg(x,y,z); # replace x, y, z with the appropriate variables; you can also use other variable orders -- see ?Groebner,MonomialOrders

b := Basis(G, ord);
n := NormalForm(f, b, ord, 'Q');
# if n = 0 then f is in the ideal; Q is the list of coefficients:
f - add(Q[i] * b[i], i = 1 .. numelems(b)); # this will be equal to n.

Hello,

     Can you enter debug in a worksheet vs a proc?   

    I have a for loop that is crashing in the middle with a bad calculated number to provide to a thermoprops function.   Is there a way to single step through a for loop (1500 iterations) to see which line is getting tripped up?  I can not post the worksheet as it's private development.   The question is generic to any "for loop".

   I have also tried "porting" into a code edit region, but still can not enter the debugger mode.   Is proper debugger only available if I turn the "for loop" into a proc?   If yes, what is the availability of packages called right after restart for the worksheet for a proc, or do all the pre-calcs developed in the worksheet and the packages to be variables fed into the proc or packages re-declared insde a new proc ???

  Sorry if this is a trival question.

Thanks in advance,
Bill

I am a new user to Maple, but have used PTC's Mathcad and Prime.

I have several matrices that I need to combine both vertically and horizontally.  The command augment will combine the matrices horizontally.  I was unable to find a command to combine the matrices vertically.  I tried the stack command (Prime command).  The Maple stack command appears to have a different functionality.  Could you suggest which command would do the job?  The matrices are large and I would like to limit the number of rows and columns shown in the document.

The next step will be sorting the data. I am researching this at this time.

Thank you for the support,

David Tietje

A user would like to know if it is possible to specify a data set say, x:=[1,2,3,4,5,6] and then extract a random sample from that data set, i.e. xsample:=[3,2,4] for a bootstrapping-type calculation.

We suggested they use something like the following:

restart; with(Statistics); my_data := [1, 2, 4, 5.5, 5.5, 6]; X := RandomVariable(EmpiricalDistribution(my_data)); s := Sample(X, 10); Bootstrap(Mean, X, samplesize = 4, replications = 10000)

HFloat(3.9984625)

(1)

NULL

Download array-random-sample.mw

Hello people in Mapleprimes,
I haven't written in this site for a long time.

I have a question in the below program, which is to write ribbons.
For the implementation of this program, 
I wrote this.
ribbonplot5([cos, sin, cos + sin], -Pi .. Pi,numpoints=20);

In the part of pattern matching, as -Pi .. Pi above is a range, so it is OK.
But, when I changed this part to x=-Pi..Pi, an error message appears.

ribbonplot5([cos, sin, cos + sin],x=-Pi .. Pi,numpoints=20);

brings error messages:
"Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct"

In the code of ribbonplot5,  x=-Pi..Pi which is the type of name=range shoud satisfy the pattern matching, as I wrote in the first part of the program as 
ribbonplot5 := proc(Flist, r1::{range,name=range})

I cannot know why the part of the program:
 
" else
       newFlist := map(unapply, Flist, lhs(r1));
     opts := ['labels'=[lhs(r1), " "," "],
                 args[3 .. nargs]];
    ribbonplot5(newFlist,rhs(r1),op(opts)):
"

wouldn't work well.

I wish I could get an answer to this. 

Thanks in advance.

This is a program in maple9 Advanced Programming Gude p. 253

graphic_ribbonplot.mw

restart;
extend := proc(f)
     local x, y;
     unapply(f(x), x, y);
end proc:
p:=x->cos(2*x):
q:=extend(p);


ribbonplot5 := proc(Flist, r1::{range,name=range})
     local i, m, p, n, opts,newFlist;
     opts := [args[3 .. nargs]];
     if type(r1, range) then
         if not hasoption(opts, 'numpoints', 'n', 'opts')
         then n := 25
         end if; 
         m := nops(Flist);
         p := seq(plot3d(extend(Flist[i]), r1, (i-1) .. i,
                                  grid=[n, 2], op(opts)),
                       i = 1 .. m):
         plots[display](p):
     else
       newFlist := map(unapply, Flist, lhs(r1));
     opts := ['labels'=[lhs(r1), " "," "],
                 args[3 .. nargs]];
    ribbonplot5(newFlist,rhs(r1),op(opts)):
   end if:
end proc:
ribbonplot5([cos, sin, cos + sin], -Pi .. Pi,numpoints=20);

I'd like to get the simplest possible expression when using simplify. The problem is that this is all done in a program, without having the benifit of looking at the expression on the screen and trying things. So I need a method that works for large set of input all the time.

I noticed in this example that simplify did not do what I think it should have.

Given the expression -2*(x^3 + 2)/(x*(x + 1)*(sqrt(3)*I + 2*x - 1)*(sqrt(3)*I - 2*x + 1)) it can be simplified to (x^3 + 2)/(2*x^4 + 2*x) but  I had to go into many tries in order to get this final result.

Is there a better way to do this? I end up now   doing simplify(expand(numer(expr))/expand(denom(expr))) in the hope to get better simplification.  Here is an example

interface(version);

`Standard Worksheet Interface, Maple 2021.2, Windows 10, November 23 2021 Build ID 1576349`

restart;

w:=-2*(x^3+2)/x/(x+1)/(I*3^(1/2)+2*x-1)/(I*3^(1/2)-2*x+1);

-2*(x^3+2)/(x*(x+1)*(I*3^(1/2)+2*x-1)*(I*3^(1/2)-2*x+1))

simplify(w)

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

simplify(evalc(w))

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

simplify(w) assuming x::real

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

simplify(w,size)

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

simplify(w,symbolic)

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

simplify(w,sqrt)

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

simplify(expand(numer(w))/expand(denom(w)))

(x^3+2)/(2*x^4+2*x)


It would be nice if Maple simplify would just do it directly as follows in Mathematica. May be there is a an  option I am overlooking

 

Download simplify.mw

I drew a methane molecula and display three times because I wanted to get two-fold and three-fold symmetry axis. ,I would is that I would like to get a more exact output and doing it without clicking, it's say, using code. Can someone help me?tareaclase6.mw
 

University of Costa Rica 

Course: SP-1493

Student: Lic. Marcus Vinicio Mora Salas

Instructor: Dr. Erick Castellón Elizondo

 

Assigment5

Description

 

In this assigment exercises e2.113,  e2.114, e2.115 and e2.117 was solved.

NULL

***e2.113

   

 

 

 

NULL


 

Download tareaclase6.mw

 

Suppose I have a real function which is defined on these intervals [x0,x1],...[x1,xn], and on each interval it's defined differently, for example f(x):=sqrt(x) if x>=0; f(x):=1/x if x<0.

For the last example I tried my last resort to use the assuming operator the following way:

f := ((x -> sqrt(x)) assuming (0 <= x)) or ((x -> 1/x) assuming (x < 0)) plot(f, x)

But it doesn't seem to be working, how do you propose to define this function? perhaps proc?

I tried looking for an example in maple's help, but didn't find any.

Your help is appreciated.

I read that abs(v) should find the magnitude of complex number. But I find cases where it does not.

Should one then use sqrt( Re(v)^2 + Im(v)^2 ) instead or is there different command to use?  Here is an example

interface(version)

`Standard Worksheet Interface, Maple 2021.2, Windows 10, November 23 2021 Build ID 1576349`

restart;

v:=1/16*(I*5^(1/2)+I-4*sin(1/5*Pi))*2^(3/10)*(5-5^(1/2))^(1/2)-1/8*2^(4/5)*((I*5^(1/2)+I)*sin(1/5*Pi)+1/2*5^(1/2)+3/2)

(1/16)*(I*5^(1/2)+I-4*sin((1/5)*Pi))*2^(3/10)*(5-5^(1/2))^(1/2)-(1/8)*2^(4/5)*((I*5^(1/2)+I)*sin((1/5)*Pi)+(1/2)*5^(1/2)+3/2)

abs(v)

-(1/16)*(I*5^(1/2)+I-4*sin((1/5)*Pi))*2^(3/10)*(5-5^(1/2))^(1/2)+(1/8)*2^(4/5)*((I*5^(1/2)+I)*sin((1/5)*Pi)+(1/2)*5^(1/2)+3/2)

sqrt( Re(v)^2 + Im(v)^2 );

((-(1/4)*2^(3/10)*(5-5^(1/2))^(1/2)*sin((1/5)*Pi)-(1/8)*2^(4/5)*((1/2)*5^(1/2)+3/2))^2+((1/16)*2^(3/10)*(5-5^(1/2))^(1/2)*(5^(1/2)+1)-(1/8)*2^(4/5)*(5^(1/2)+1)*sin((1/5)*Pi))^2)^(1/2)

 

Download complex.mw

Here is the same thing in Mathematica:

I searched help for modulus but could not find one.

Maple 2021.2

question8.mw

In the exercise uploaded I have to plot asymptotes of a function. I know this is possible using definitions of all kind of asymptotes and ploting in a figure. However I would like to know if exists some parameter for plot method that automatically show asymptotes.

question7.mw

NULL

***e2.106

 

Plot this couple of parametric equations, identify the geometric figure known as the folium of Descartes , and relate properties of the figure to numerical coefficients in the equations.

  x = 3*t/(t^3+1), y = 3*t^2/(t^3+1)   

NULL

restart: with(plots):

 

 

 

See how the plot of the folium of Descartes can be built with the following code:

d1 :=

Error, invalid terms in product: -10 .. 10

Error, invalid terms in product: -10 .. 10

Error, (in plots:-pointplot) points cannot be converted to floating-point values

NULL

NULL

Download question7.mw

For this question I need that who help me focus in second block of code in the document. Basically, what I am trying is to get a plot of folium of Dercastes using parametric equation to plot ordered pairs. In order to success, is needed to exclude t=-1. In the block is showed what I tried. I concluded that my approach in solving that part of exercise is wrong. What could be a well approach?

question6.mw
How you can see, in the following exercise I built five plots, every one with the graph of two functions. The exersise say that I must find coordinates of any intersection. I think I can do it with solve command. However, I want point out coordinates of  intersections inside the plots. Probably exists a command or a parameter to success with my objetive. How can I do it?

NULL

*** e2.103

 

Plot the following couples of formulae; note in particular the contrasting forms of two curves in each case, and find the coordinates of any intersections.

i)    {x, x^3},

ii)    {x^2, x^4},

iii)    {1/x, 1/x^2},

 iv)   {x^2, sqrt(x)},

 v)   {x^3, abs(x^(1/3))}

 

restart:

NULL

Thank you for helping me;
Greetings;
Lic. Marcus Vinicio Mora Salas;
Chemist;
Postgraduate student at University of Costa Rica;

Download question6.mw

question5.mw

In document uploaded I tried to write a code to get as output 11 plots. I would like a format as this: 9 plots in 3 columns an 3 rows, and a fourth row with two center plots. To explain me better, I drew a rustic sketch of what I want, basically something like this:

However I tried but I fail and my output is horrible. So, I want to ask: Does exists some option to the plot[display] command or should I try another aproach?

Thank you for helping me;
Greetings;
Lic. Marcus Vinicio Mora Salas;
Chemist;
Postgraduate student.

As part of my course work I've encountered a block wherein I need to convert a 4th order TF to a SmithForm but am unable to do so.

Can anyone help me with the code as attatched.

A := Matrix([[(.3384*x^3-26.13*x^2-.3659*x+0.1678e-1)/(s^4+3.068*s^3-3.362*s^2-.5748*s+.7598), (.4755*s^3-25.3*s^2-51.36*s-1.387)/(s^4+3.068*s^3-3.362*s^2-.5748*s+.7598)], [(-.3349*s^3+18.21*s^2+.3487*s-0.5939e-1)/(s^4+3.068*s^3-3.362*s^2-.5748*s+.7598), (-.3107*s^3+17.81*s^2+35.49*s+1.027)/(s^4+3.068*s^3-3.362*s^2-.5748*s+.7598)]])

Matrix(%id = 36893488152131246308)

(1)

"->"

Error, (in gcdex) invalid arguments

 

"->"

SmithForm(Matrix(%id = 36893488152131266788))``

(2)

with(LinearAlgebra)

NULL

S := SmithForm(A, s)

Error, (in gcdex) invalid arguments

 

with(LinearAlgebra); A := Matrix([[1, 2*x, 2*x^2+2*x], [1, 6*x, 6*x^2+6*x], [1, 3, x]])

Matrix(%id = 36893488152361731844)

(3)

S := SmithForm(A, x)

Matrix(%id = 36893488152348668020)

(4)

NULL

Download SmithForm.mw

This is a simple problem of Chemistry. I solved the exercise, but there are three aspects I don't like about output:
1) Even kg*m2 *s-2 = J (SI unit to energy) and both are correct, one must be explicit with units in order to be totally clear, so I need an output with units of J/mol and not kg*m2 *s-2 mol-1.
2) I had to hardcode number of significant figures, so I had to analize quantitys in order to determine this number, wich as you can see, is three. I think Maple can compute significant figures automatically, but I could not find the command in documentation and even in this case is not totally needed, I would like to learn how do it because it could be very useful for more complex expressions.
3) Finally, output must be expressed using scientific notation, it's say enthalpy = 10.4*104 J/mol.
Therefore: How can I get adecuate output?
Thank you for helping me;
Greetings;
Lic. Marcus Vinicio Mora Sallas;
Chemist;
Postgraduate student. question4.mw

*** e1.501

 

Using this equation attributed to Clausius and Clapeyron,

ln(P[2]/P[1]) = Delta*H[vap]/R 1/T[1]-1/T[2]

and these data for the vapour pressure of liquid mercury at the indicated temperatures,

      P =  1.6 10^(-4) Pa at T = 273.15 K and P = 36.4 Pa at T = 373.15 K

estimate the enthalpy change Delta*H[vap] for vapourization of mercury over this range of temperature.

 

p := [1.6e-4*Unit('Pa'), 36.4*Unit('Pa')]:

Delta(H[vap]) = 0.105e6*Units:-Unit(m^2*kg/(s^2*mol*K))*Units:-Unit(K)

``

Download question4.mw

First 18 19 20 21 22 23 24 Last Page 20 of 38