acer

32303 Reputation

29 Badges

19 years, 309 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Another approach is to store the loop index value k and the value of a in a table, and then turn that into a Matrix as a later step.

That allows you to easily handle the situation where some entries are omitted (because, say, they fail some conditional test). You can still have easy access to the accepted indices and values, and plot just those.

Here's an example. There are other ways to accomplish the same thing, some of which are terser, but I've tried to keep it understandable.

restart;

Sol:=proc(  )

  local a,k,tab;

  for k from 1 to 23 do

    a:=evalf(sin(Pi/2+9*k/23));

    if a < 0.1 then

      next;

    end if;

    tab[k]:=a;

   end do;

  return Matrix([seq([t,tab[t]],
                     t=sort([indices(tab,nolist)]))]);

end proc:

M := Sol();

M := Matrix(10, 2, {(1, 1) = 1, (1, 2) = .9244123753, (2, 1) = 2, (2, 2) = .7090764791, (3, 1) = 3, (3, 2) = .3865457698, (4, 1) = 13, (4, 2) = .3658700890, (5, 1) = 14, (5, 2) = .6931657010, (6, 1) = 15, (6, 2) = .9156718148, (7, 1) = 16, (7, 2) = .9997510142, (8, 1) = 17, (8, 2) = .9326926044, (9, 1) = 18, (9, 2) = .7246341575, (10, 1) = 19, (10, 2) = .4070289609})

(1)

plots:-display(
  plot(sin(Pi/2+9*k/23), k=1..23, color=blue),
  plot(M, style=point, symbolsize=20,
          symbol=solidcircle));

 

 

Download table_aug_Matrix.mw

 

I'm not sure how you're expecting the omega(t) values to be used. But this may be a start, or give you some ideas.

The key part here is that I'm using my earlier idea (see Reply above) of using a custom procedure F which can generate each frame.

Once you have such a procedure it is easier to test. You can call it with different arguments and see how it looks. When satisfied you can easily animate it.

[edit] I have adjusted the shape that I plotted with my method.

restart

with(plots)

r1 := .35m := 626g := -9.807
u0 := -20
v0 := -20x0 := 0z0 := 15omega0 := -24J := (2/5)*m*r1^2

eqx1 := m*(diff(u(t), t)) = 0.; eqz1 := m*(diff(v(t), t)) = m*g

eqx0 := diff(x(t), t) = u(t); eqz0 := diff(z(t), t) = v(t)

eqr1 := J*(diff(omega(t), t)) = 5000*sin(t)

ini := x(0) = x0, u(0) = u0, z(0) = z0, v(0) = v0, omega(0) = omega0

sol1 := dsolve({eqr1, eqx0, eqx1, eqz0, eqz1, ini}, {omega(t), u(t), v(t), x(t), z(t)}, type = numeric, output = listprocedure)

animx := subs(sol1, x(t)); animz := subs(sol1, z(t)); animomega := subs(sol1, omega(t))

F := proc (x, z, r, q) plots:-display(plottools:-rotate(plots:-display(plottools:-sector([x, z], q, 0 .. Pi, color = "LightBlue"), plottools:-sector([x, z], q, Pi .. 2*Pi, color = grey)), r, [x, z])) end proc

animate(F, [animx(t), animz(t), animomega(t), .5], t = 0 .. 1, scaling = constrained, frames = 150)

Download how_rot_ac.mw

By calling parse you turn the strings back into Maple expressions, so naturally when you print them as normal output then you get the same effect as for the original, ie. sequences are pretty-printed with spaces after the commas, whether they are in a list or just as a sequence.

If you want to line-print strings, without the quotation marks appearing, then you could use printf (on the strings, with %s format) instead of print or lprint. Note that conversion to strings might be unnecessary -- your particular goal is still unclear.

If you want to export the entries to an external file then you could use the ExportMatrix command, eg.,
    ExportMatrix("myfile.csv", Matrix([ans1]));
That produces a file named myfile.csv with three lines, each with the entries separated by commas and without spaces. That command has some additional flexibility along those aspects.

What are you actually trying to accomplish with sequences of numbers displayed without spaces after the commas? Are you trying to export it to an external file, for some other software? Or are you going to copy&paste from what is displayed on your Maple GUI?

It is a very common phenomenon on this forum for people to have some task they want to solve, then ask about only part of their approach to solving it, without describing the actual underlying goal or full process that they want. This usually leads to guesswork and unnecessary and inefficient back-and-forth.

In the Maple programming language (1D plaintext, also known as Maple Notation) the word for infinity is:

   infinity

That entry box in the popup is a Maplets TextField, and it expects plaintext Maple Notation.

This seems to be a consequence of the result from DiagonalMatrix having shape=diagonal and storage=diagonal.

A workaround is to force off the compact shape/storage (see two ways, below).

I will submit a bug report.

restart

with(LinearAlgebra); alias(`&bigotimes;` = LinearAlgebra:-KroneckerProduct); interface(rtablesize = 16); kernelopts(version)

`&bigotimes;`

[10, 10]

`Maple 2021.2, X86 64 LINUX, Nov 23 2021, Build ID 1576349`

Matrices nonconformable, Maple should give error message:

`&bigotimes;`(Matrix(1, 4, 1), IdentityMatrix(4)); Dimension(%); M := Matrix(4, 4, shape = symmetric, symbol = m); Dimension(%)

Matrix([[1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]])

4, 16

M := Matrix(4, 4, {(1, 1) = m[1, 1], (1, 2) = m[1, 2], (1, 3) = m[1, 3], (1, 4) = m[1, 4], (2, 2) = m[2, 2], (2, 3) = m[2, 3], (2, 4) = m[2, 4], (3, 3) = m[3, 3], (3, 4) = m[3, 4], (4, 4) = m[4, 4]}, storage = triangular[upper], shape = [symmetric])

4, 4

MatrixMatrixMultiply(`&bigotimes;`(Matrix(1, 4, 1), IdentityMatrix(4)), DiagonalMatrix(Diagonal(M), shape = []))

Error, (in LinearAlgebra:-Multiply) first matrix column dimension (16) <> second matrix row dimension (4)

NULLMatrixMatrixMultiply(`&bigotimes;`(Matrix(1, 4, 1), IdentityMatrix(4)), DiagonalMatrix(Diagonal(M), storage = rectangular))

Error, (in LinearAlgebra:-Multiply) first matrix column dimension (16) <> second matrix row dimension (4)

`&bigotimes;`(Matrix(1, 4, 1), IdentityMatrix(4)).DiagonalMatrix(Diagonal(M))

Matrix([[m[1, 1], 0, 0, 0], [0, m[2, 2], 0, 0], [0, 0, m[3, 3], 0], [0, 0, 0, m[4, 4]]])

Download Starnge_ac.mw

Is you lprint the SearchSet you can see that its float values are not what appears in the 2D Input.

I don't know how you managed to get that effect (cut&paste, something with numeric formatting?).

You could re-enter it manually.

But you may still be faced by discrepencies if you expect floats to be matched in the case that they have differing numbers of trailing zeroes.

It might be better if you described precisely what kind of matching you are after, ie. float comparisons to a fixed precision, etc. It may be that verify it a more suitable tool for the comparison, but that depends on what comparison you are after.

Also, you asked about why some sorting occurs. That's how Maple acts with sets of floats. If you don't want them sorted then you could use lists of Vectors instead.

restart; with(ListTools)

Pent := [Vector(3, {(1) = 2.0646, (2) = -1.5000, (3) = 3.3405}), Vector(3, {(1) = -.78860, (2) = -2.4271, (3) = 3.3405}), Vector(3, {(1) = -2.5520, (2) = 0.8100500000e-10, (3) = 3.3405}), Vector(3, {(1) = -.78860, (2) = 2.4271, (3) = 3.3405}), Vector(3, {(1) = 2.0646, (2) = 1.5000, (3) = 3.3405})]

[Vector[column](%id = 36893628814707266132), Vector[column](%id = 36893628814707266252), Vector[column](%id = 36893628814707266372), Vector[column](%id = 36893628814707266492), Vector[column](%id = 36893628814707266612)]

PentSet := ([seq])(convert(Pent[i], set), i = 1 .. 5)

[{-1.5000, 2.0646, 3.3405}, {-2.4271, -.78860, 3.3405}, {-2.5520, 0.8100500000e-10, 3.3405}, {-.78860, 2.4271, 3.3405}, {1.5000, 2.0646, 3.3405}]

PentSetSort := ([seq])(sort(PentSet[i]), i = 1 .. 5)

[{-1.5000, 2.0646, 3.3405}, {-2.4271, -.78860, 3.3405}, {-2.5520, 0.8100500000e-10, 3.3405}, {-.78860, 2.4271, 3.3405}, {1.5000, 2.0646, 3.3405}]

SearchSet := {-2.427050982, -.7885966699, 3.340549093}; BinarySearch(PentSetSort, SearchSet, `subset`); BinarySearch([{-1.500000000, 2.064572880, 3.340549093}, {-2.427050982, -.7885966699, 3.340549093}, {-2.551952424, 3.340549093, 8.100498050*10^(-11)}, {-.7885966673, 2.427050983, 3.340549093}, {1.500000001, 2.064572880, 3.340549093}], {-2.427050982, -.7885966699, 3.340549093}, `subset`)

0

2

lprint(SearchSet)

{-2.427050982, -.7885966699, 3.340549093}

SearchSet := {-2.4271, -.7886, 3.3405}

{-2.4271, -.7886, 3.3405}

BinarySearch(PentSetSort, SearchSet, `subset`)

0

SearchSet := {-2.4271, -.78860, 3.3405}

{-2.4271, -.78860, 3.3405}

BinarySearch(PentSetSort, SearchSet, `subset`)

2

lprint(PentSetSort)

[{-1.5000, 2.0646, 3.3405}, {-2.4271, -.78860, 3.3405}, {-2.5520, .8100500000e-\
10, 3.3405}, {-.78860, 2.4271, 3.3405}, {1.5000, 2.0646, 3.3405}]

([seq])(convert(Pent[i], set), i = 1 .. 5)

[{-1.5000, 2.0646, 3.3405}, {-2.4271, -.78860, 3.3405}, {-2.5520, 0.8100500000e-10, 3.3405}, {-.78860, 2.4271, 3.3405}, {1.5000, 2.0646, 3.3405}]

([seq])(convert(Pent[i], list), i = 1 .. 5)

[[2.0646, -1.5000, 3.3405], [-.78860, -2.4271, 3.3405], [-2.5520, 0.8100500000e-10, 3.3405], [-.78860, 2.4271, 3.3405], [2.0646, 1.5000, 3.3405]]

 

Download Binary_search_ac.mw

An explicitl description of what you're actually trying to accomplish would be a good start to getting best advice.

It would be more helpful and direct if you were to supply the complete example when first submitting the Question.

Hopefully this uses the dsolve solution to produce your line animation in a satisfactory manner.

restart

q1 := 5b1 := 18l1 := 16r1 := .35ms := 626g1 := -9.807
u0 := -19.4

v0 := -17.7x0 := 0z0 := 15xa := 0za := z0+1mu1 := .35omega0 := -24

mn := b1*g1*q1*za+g1*mpfz := mn/zaJs := (2/5)*ms*r1^2

"Lp(t):=sqrt((xn(t)-xa)^(2)+(zn(t)-za)^(2)) :"

"Lr(t):=piecewise((za-Lp(t))>0,za-Lp(t),0) :"

"A1(t):=piecewise((xa-xn(t))>0,xa-xn(t),0) :"

"sinalpha1(t):=piecewise((xa-xn(t))>0,(xa-xn(t))/(Lp(t)),0) :"

"cosalpha1(t):=piecewise((xa-xn(t))>0,((za-zn(t)))/(Lp(t)),1) :"

"alpha2(t):=arccos(cosalpha1(t))+phi(t) :"

``

"S1(t):=piecewise(zn(t)>=0 and xn(t)<=xa,fz*Lr(t),0):"

"S1z(t):=S1(t)*cos(phi(t)):"

"S1x(t):=S1(t)*sin(-phi(t)):"

"S2(t):=piecewise(xn(t)<=xa and zn(t)>0, (-1) S1(t)*exp(mu1*alpha2(t)),0):"

"S2x(t):=S2(t)*sinalpha1(t):"

"S2z(t):=S2(t)*cosalpha1(t):"

"Sx(t):=S2x(t)+S1x(t):"

"Sz(t):=S1z(t)+S2z(t)+ms*g1:"

shape_factor := 0

"Fr(t):=S2(t)+S1(t)+shape_factor:"

NULL

"m(t):=Lr(t)q1*b1:"

mp := 300

"Jp(t):=1/(3)*m(t)*Lr(t)^(2)+mp*Lr(t)^(2) :"

"M(t):=g1*m(t)*(Lr(t))/(2)*sin(phi(t))+g1*mp*sin(phi(t)):"

k := 800*ms

NULL

"Es(t):=(ms*g1*(z0-zn(t)))+1/(2)*ms*(vn(t)^(2)+un(t)^(2))+1/(2)*Js*omega(t)^(2):"

"En(t):=(1)/(2)*Jp(t)*((&DifferentialD;)/(&DifferentialD; t)phi(t))^(2)+-(m(t)+mp)*g1*(Lr(t)-cos(phi(t))*Lr(t)):"

eqx1 := ms*(diff(u(t), t)) = 0.; eqz1 := ms*(diff(v(t), t)) = ms*g1

eqx0 := diff(x(t), t) = u(t); eqz0 := diff(z(t), t) = v(t)

``

eqx1n := ms*(diff(un(t), t)) = Sx(t); eqz1n := ms*(diff(vn(t), t)) = ms*g1+S1z(t)+S2z(t)

eqx0n := diff(xn(t), t) = un(t); eqz0n := diff(zn(t), t) = vn(t)

eqr1 := Js*(diff(omega(t), t)) = (S2(t)+S1(t)+shape_factor)*r1

``

u0n := u0*ms/(ms+(1/3)*m(t)+mp)

NULL

u0n1 := u0*ms/(ms+mn)

phid00 := u0n1/(l1-z0)

phid0 := .7*eval[recurse](-u0n(t)/(l1-z0), [t = 0, xn(0) = x0, zn(0) = z0])

simplify(phid0)

"znb(t):=(Lr(t)-(sin((Pi)/(2)- phi(t))*Lr(t))):"

"xnb(t):=Lr(t)*cos(Pi/(2)-phi(t)):"

eqp := (diff(phi(t), t, t))*Jp(t) = M(t)-k*(diff(phi(t), t))

with(plots)

ini := x(0) = x0, u(0) = u0, z(0) = z0, v(0) = v0, xn(0) = x0, un(0) = u0, zn(0) = z0, vn(0) = v0, omega(0) = omega0, phi(0) = 0, (D(phi))(0) = phid0

sol1 := dsolve({eqp, eqr1, eqx0, eqx0n, eqx1, eqx1n, eqz0, eqz0n, eqz1, eqz1n, ini}, {omega(t), phi(t), u(t), un(t), v(t), vn(t), x(t), xn(t), z(t), zn(t)}, type = numeric, output = listprocedure)

XNB := unapply(subs(xn = XN, zn = ZN, phi = PHI, xnb(t)), t)

ZNB := unapply(subs(xn = XN, zn = ZN, phi = PHI, znb(t)), t)

XN := eval(xn(t), sol1)

ZN := eval(zn(t), sol1)

PHI := eval(phi(t), sol1)

NULL

NULL

NULL

NULL

plots:-animate(plots:-display, [plottools:-line([xa, za], [XN(t), ZN(t)], color = red, thickness = 3), plottools:-line([XN(t), ZN(t)], [XNB(t), ZNB(t)], color = blue, thickness = 3), plot([[XN(t), ZN(t)]], style = point, symbol = solidcircle, symbolsize = 15, color = red), plot([[XNB(t), ZNB(t)]], style = point, symbol = solidcircle, symbolsize = 15, color = blue)], t = 0 .. .7, background = plots:-pointplot([[xa, za]], symbol = solidcircle, symbolsize = 15, color = green))

 

Download anim_ac.mw

You have b assigned as a Matrix. That's your basic mistake, since you were only indexing into it as b[i], as if it had just one dimension.

Try making it b as a Vector instead, ie,

   b := Vector(3, [-1, 7, -7]);

Below, I have removed also the loading of the VectorCalculus package since that rebinds the Vector command which is hardly useful here. I changed the call of Norm to be explicitly a call to LinearAlgebra:-Norm.

I suggest that you check that it works as you intended.

restart

with(plots):

``

SOR := proc (n, A, b, x, w, max_iter, tol) local i, j, k, xGS, err, x1; err := 1; while tol < err do x1 := x; for k to max_iter do for i to n do xGS := (b[i]-add(Typesetting:-delayDotProduct(A[i, j], x[j]), j = 1 .. i-1)-add(Typesetting:-delayDotProduct(A[i, j], x[j]), j = i+1 .. n))/A[i, i]; x[i] := (1-w)*x[i]+w*xGS end do end do; err := LinearAlgebra:-Norm(x-x1); x1 := x end do end proc:

``

A := Matrix(3, 3, [[3, -1, 1], [-1, 3, -1], [1, -1, 3]])

A := Matrix(3, 3, {(1, 1) = 3, (1, 2) = -1, (1, 3) = 1, (2, 1) = -1, (2, 2) = 3, (2, 3) = -1, (3, 1) = 1, (3, 2) = -1, (3, 3) = 3})

(1)

b := Vector(3, [-1, 7, -7]); x := `<,>`(1, 1, 1); x := convert(x, Vector)

b := Vector(3, {(1) = -1, (2) = 7, (3) = -7})

 

x := Vector(3, {(1) = 1, (2) = 1, (3) = 1})

(2)

n := 3;

3

 

.9

 

7

 

0.1e-3

(3)

ans := SOR(3, A, b, x, .9, 15, 0.1e-3)

ans := Vector(3, {(1) = .9999999896, (2) = 1.999999980, (3) = -2.000000006})

(4)

A.ans-b

Vector(3, {(1) = -0.1719999987e-7, (2) = -0.4360000005e-7, (3) = -0.8399999807e-8})

(5)

NULL

Download code_zeineb_ac.mw

It is not necessary to write M:-Pn instead of just Pn (for each n), in the situation you describe.

In my experience is far more common to write the references as just Pn in equivalent situations.

You wrote that using the form M:-Pn somestimes "...saved me a lot of trouble". What trouble was that?

If you store them properly (in a .mla Maple Library Archive file) then you wouldn't need to read any of them in each session you want to access them, and they could all get seen as easily as each other.

To access any of them you'd simply need libname to be augmented with the location of the new personal .mla Library file.

- You could augment libname in a worksheet's Startup code, which would affect just that worksheet.
- Or you could augment libname in a personal initialization file.
- Alternatively you could put the .mla Library file under a new folder with a name like whatever the following returns, and have Maple automatically augment libname upon relaunch:
    cat(kernelopts(':-homedir'),"/maple/toolbox/mypackage/lib")

Personally, I think that reading in the plaintext source files each time you want to run a session or worksheet is an unnecessary, overly complicated burden.

But if for some strange reason I was unable to use an .mla file, then I'd probably just create a single .mpl text file that contained the means to input all the individual procedures. That could contain various (say, five) read calls for each of the individual source files, or it could contain the definition of a package module that accessed the individual sources with, say, the $include directive. In this scenario I could subsequently issue one read call of that master (build) file, and all would be avaliable.

[edit] There is an example of writing a module using the $include directive (and the preprocessor) for its member procedures in Section 11.4 of the Programming Guide.

You may well be satisfied with the right-click context-menu approach.

By the way, there is a Help page for that (it takes a little while to fully load and focus on the approriate section in my webbrowser).

Using the result in the left-hand side of an assignment requires mouse actions to copy&paste, so using the mouse to convert to Atomic Variable may be fine.

If you're interested, your expression can also be converted programmatically:

restart;

kernelopts(version);

`Maple 2022.1, X86 64 LINUX, May 26 2022, Build ID 1619613`

 

`convert/identifier`:=proc(x)
   cat(`#`,convert(:-Typesetting:-Typeset(x),
                   ':-compose',`global`,name));
end proc:

 

 

expr := abs(A[0])^2;

abs(A[0])^2

convert(expr, identifier);

`#msup(mfenced(msub(mi("A"),mn("0")),open = "&verbar;",close = "&verbar;",msemantics = "abs"),mn("2"))`

lprint(%);

`#msup(mfenced(msub(mi("A"),mn("0")),open = "&verbar;",close = "&verbar;",msema\
ntics = "abs"),mn("2"))`

 

I'll use the right-click context menu conversion (explained by Robert)
on the next 2D Input

 

`#msup(mrow(mo("&verbar;"),msub(mi("A"),mn("0")),mo("&verbar;")),mn("2"))`

`#msup(mrow(mo("&verbar;"),msub(mi("A"),mn("0")),mo("&verbar;")),mn("2"))`

lprint(%);

`#msup(mrow(mo("&verbar;"),msub(mi("A"),mn("0")),mo("&verbar;")),mn("2"))`

 

Both of these results are Maple names, to which you can assign values.

 

You should be able to copy&paste their pretty-printed output and use
that as the left-hand side of an assignment.

 

Download atomicvar_constr.mw

ps. In versions before Maple 2017 an Atomic Variable was called an Atomic Identifier.

Try

   ':-b' = b

using single right-ticks (a.k.a. uneval quotes).

The LHS of that equation is an unevaluated reference to the global name b (and not the procedure test1's parameter by a similar name). The RHS evaluates to the value you want to pass along.

test1:=proc(a::posint, {b::posint:=1})::posint:
	return a + b:
end proc:

test2:=proc(a::posint, {b::posint:=1} )::posint:
	return a*test1(a, ':-b' = b);
end proc:

test2(2, b=3);
             10

[edit] I much prefer this approach over using _options['b'], which Joe has suggested.

I would not use remove(has, ..., unit) since that would act quite differently on expressions other than a product. (Your expression assigned to a is of type `*`, but it's unclear that is all you want to be able to handle robustly.)

I would suggest these preliminary steps be part of the process:
1) combine addends into common units
2) optionally convert to a preferred unit (or accept the base unit for the current system, default=SI)
3) use convert(...,unit_free) to strip off the remaning units, as suitable

For example, quoting unprotected global versions of option names for robustness,

restart;

kernelopts(version);

`Maple 2015.2, X86 64 LINUX, Dec 20 2015, Build ID 1097895`

a := 3*Unit(m);

3*Units:-Unit('m')

convert(combine(a, ':-units'), ':-unit_free');

3

b := 7*Unit(mm)+3*Unit(m);

7*Units:-Unit('mm')+3*Units:-Unit('m')

convert(combine(b, ':-units'), ':-unit_free');

3007/1000

Download remove_units.mw

Maple was originally designed for efficient symbolic computation, as opposed to pretty mathematical typesetting.

A key aspect of that original design was the storing in a session (by the Maple engine, a.k.a. "kernel") of only one representation of any sum or product of terms (commuting under usual addition and multiplication). Any other input of an equivalent form of an expression -- with terms commuted -- gets uniquified to the stored form.

Hence, if the form
   -b + a
is first formed in a session then construction/entry of the alternate form,
  a - b
gets automatically recognized as the earlier, stored form.

However, for this kind of expression the terms can be reordered by the sort command. For example,

restart;

expr := -b + a;

-b+a

The order in which I type the entries does not matter.
What matters is that the originally existing form -b+a
is already stored in Maple's internal memory (ie. in its
unquification table of expressions).

a - b;

-b+a

It is possible to resort the items in this sum, forcing a
particular ordering of names. This causes the stored
(uniquified) expression to be replaced in internal memory.

sort(expr, order=plex(a,b));

a-b

a - b;

a-b

-b + a;

a-b

restart;


We can also go the other way...

alt := a - b;

a-b

-b + a;

a-b

sort(alt, order=plex(b,a));

-b+a

-b + a;

-b+a

a - b;

-b+a

Download simpl_examp.mw

As far as mathematical typesetting goes, one could also display the expression (in marked up "2D" math), without the above issues interfering. Here I use so-called inert operators, so avoid those uniquification issues,

restart;

-b + a;

-b+a

a - b;

-b+a

Here I use prefix syntax for the inert operator,

foo := `%+`(a, -b);

`%+`(a, -b)

InertForm:-Display(foo);

0, "%1 is not a command in the %2 package", _Hold, Typesetting

I can also use this infix syntax,

bar := a %+ (-b);

`%+`(a, -b)

InertForm:-Display(bar);

0, "%1 is not a command in the %2 package", _Hold, Typesetting

Download inert_add_ex.mw

If you have other, particular usage scenarios then you should describe them precisely, as a best bet on getting adequate assistance.

You asked about plotting the elements of a sequence, so I'll address that aspect.

You can use the plot command to show a discrete collection of x-y points.

The data can be formed in a list of lists, or a Matrix. (I'll do it as a list of lists, below.)

You can adjust other qualities, such as the symbol, the style, the color, etc. See the Help page plot,coptions for more details.

restart;

L := [seq([n,(-2)^n], n=-2..2)];

[[-2, 1/4], [-1, -1/2], [0, 1], [1, -2], [2, 4]]

plot(L, style=point, symbolsize=15,
        symbol=solidcircle, color=red);

plot(L, style=pointline, symbolsize=15,
        symbol=solidcircle, color=red);

Download point_plot_ex.mw

First 59 60 61 62 63 64 65 Last Page 61 of 336