acer

32373 Reputation

29 Badges

19 years, 334 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

The simple answer to Q1 and Q2 is no, unless you unprotect and reassign a new procedure to the global WARNING.

Q1. The attachment below shows one rough way to reassign to WARNING that will add the name of the calling procedure. (I just did a slight modification of a bit of a package I wrote for redefining userinfo to send its messages to a TextArea component.)

Q2. You could modify and extend that implementation to make command specific suppression possible. Since the procedure redefinition below has access to the name of the caller then that could be tested against a stored table/record. And so you use some name for storing that, eg. warnings[f]:=false or what have you. Alas I don't have time for that right now.

Q3. Likely yes, programmatically manipulating the saved .mw file and writing out to a new .mw file. But that approach would require time to implement.

restart;

Set := proc(id::string) local i, orig;
  global __T, __origW;
  if not assigned('__origW') then
    __origW := eval(:-WARNING);
    unprotect(':-WARNING');
    :-WARNING :=
        proc(n)
          local fullstack, msg, whereami;
              fullstack := debugopts('callstack');
              if convert(eval(fullstack[5],1),`global`) = ':-try_method' then
                whereami := "";
              else
                whereami := cat(fullstack[5], ": ");
              end if;
              msg := convert(cat(whereami,
                                 StringTools:-FormatMessage(args)),
                             string);
              __T[msg] := fullstack[5];
          print(INTERFACE_WARN(1,msg));
        end proc;
    protect(':-WARNING');
  end if;
  return NULL;
end proc:

 

Now, two examples of the usual behavior.

 

WARNING("hey %1", sqrt(x));

Warning, hey x^(1/2)

f := proc() WARNING("hey %1", sqrt(x)); end proc:
f();

Warning, hey x^(1/2)

 

Now, we'll replace the WARNING command, and re-execute
those examples.

 

Set():

 

WARNING("hey %1", sqrt(x));

Warning, TopLevel: hey x^(1/2)

f := proc() WARNING("hey %1", sqrt(x)); end proc:
f();

Warning, f: hey x^(1/2)

 

We stored the information.

 

eval(__T);

table( [( "TopLevel: hey x^(1/2)" ) = TopLevel, ( "f: hey x^(1/2)" ) = f ] )

Download WARNING_redefn.mw


Of course, you could modify or adjust that as needed. You could also unassign that table of results whenever convenient, etc.

Your syntax for calling the plot command seems quite wrong. I cannot imagine what you intended by l = 5*_8, except possibly as a typographical mistake where you intended the range l = 5..8.

Your syntax for invoking solve is wrong. That command does not take an argument of the form name=range.

Note that the error messages you showed do indicate these mistakes. You could also reference the allowed calling sequences of those commands on their respective help pages.

And there is not an explicit exact solution. Therefore I suggest calling fsolve instead here, to get a floating-point result.

plot(cos(l)*cosh(l) - 1, l = 5..8);

fsolve(cos(l)*cosh(l) - 1, l = 5..8);

7.853204624

Download rf_syntax.mw

I don't understand what your intention is, when you write "k=1..4".  The expression cos(k)*cosh(k)-1 does not have a real root for k between 1 and 4.

Here's one way to handle your examples,

restart;

 

R := expr -> subsindets(expr,`+`,
       proc(ee)
         local u:=selectremove(type,ee,specfunc(f));
         if u[1]<>0 then
           f(subsindets(u[1],specfunc(f),op))+u[2];
         else
           u[2];
         end if;
       end proc):

 

R( f(A) );

f(A)

R( f(A)+f(B) );

f(A+B)

R( f(A)+f(B)+f(C) );

f(A+B+C)

R( sin(x)+10*exp(x)/13+cos(x) );

sin(x)+(10/13)*exp(x)+cos(x)

R( sin(x)+f(A)+10*exp(x)/13+cos(x) );

sin(x)+f(A)+(10/13)*exp(x)+cos(x)

R( sin(x)+f(A)+f(B)+10*exp(x)/13+cos(x)+f(C)+f(10*C) );

f(A+B+11*C)+sin(x)+(10/13)*exp(x)+cos(x)

Download subsindets_examp.mw

You could make that more general by having the name (eg. f) be an additional parameter.

Here are some answers.

note: I removed the call to assume. I never use assume if I can get by without it.  I prefer to get by utilizing assuming instead, since it can be used in a more targeted manner. Or, as in this case, one can get by with performing so-called simplification with side-relations (see below).

restart; interface(showassumed = 0)

U := Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = -LinearAlgebra:-HermitianTranspose(b), (2, 2) = LinearAlgebra:-HermitianTranspose(a)})

Matrix(%id = 36893627967393143972)

Is the "with linearAlgebra" statement below always and strictly necessary for a simple 2x2 inverse?

Its dizzying betwween Linalgebra-generic and non generic, Deep learning, and so many packages that have a matrix inverse function: How to choose?

Ans: You don't need any of those specialized packages or subpackages. You
can simply utilize the basic LinearAlgebra package (or raise your Matrix to power -1).

with(LinearAlgebra)

 The assume(a*a + b*b = 1) above seems to do nothing below.     how can we make the assumption stick?

Ans: If you want to "simplify" by performing a substitution then you can use so-called simplify with side-relations.
        See the help page for topic  simplify,siderelations

D1 := Determinant(U); simplify(D1, {LinearAlgebra:-HermitianTranspose(a)*a+LinearAlgebra:-HermitianTranspose(b)*b = 1})

a*conjugate(a)+b*conjugate(b)

1

Why does Inverse fail? is the modulus mandatory?

Ans: You were using an incorrect command name in your attempt at calling LinearAlgebraL-MatrixInverse.
You could also raise U to the power -1.

`#msup(mi("U"),mo("&dagger;"))` := MatrixInverse(U)`#msup(mi("U"),mo("&dagger;"))` := 1/U

Matrix(2, 2, {(1, 1) = conjugate(a)/(a*conjugate(a)+b*conjugate(b)), (1, 2) = -b/(a*conjugate(a)+b*conjugate(b)), (2, 1) = conjugate(b)/(a*conjugate(a)+b*conjugate(b)), (2, 2) = a/(a*conjugate(a)+b*conjugate(b))})

Matrix(%id = 36893627967393110724)

Is it possible to denote the usual inverse with the superscript -1?

Ans: right-click on U^-1 and select 2-D Math -> Convert To -> Atomic Variable
That turns it into a special name (which happens to pretty-print as you wish), to which
you can make the usual kind of assignment.

`#msup(mi("U"),mrow(mo("&uminus0;"),mn("1")))` := MatrixInverse(U)

Matrix(%id = 36893627967393103372)

 The assume(a*a + b*b = 1) above seems to do nothing below

Uinv := MatrixInverse(U); simplify(Uinv, {LinearAlgebra:-HermitianTranspose(a)*a+LinearAlgebra:-HermitianTranspose(b)*b = 1})

Matrix(2, 2, {(1, 1) = conjugate(a)/(a*conjugate(a)+b*conjugate(b)), (1, 2) = -b/(a*conjugate(a)+b*conjugate(b)), (2, 1) = conjugate(b)/(a*conjugate(a)+b*conjugate(b)), (2, 2) = a/(a*conjugate(a)+b*conjugate(b))})

Matrix(%id = 36893627967308692644)

The curly bracket seems to do what I expected Assuming would do (in-line format).

I'd also expect {} to mean a set!! Why is there no mention of {} in the Simplify documentation?

Ans. It is indeed documented! There is a "See Also" cross-reference as well as a hyperlink to
the auxilary Help page for topic  simplify,siderels  on the simplify Help page.

simplify(Uinv, {LinearAlgebra:-HermitianTranspose(a)*a+LinearAlgebra:-HermitianTranspose(b)*b = 1})

Matrix(%id = 36893627967308683252)

help("simplify,siderelations")

Below I use r_t. Can one use  r' (as in transformed r) and not mean it to be the derivative?

Ans: right-click on r' and select 2-D Math -> Convert To -> Atomic Variable
note: you need to do this each time you input r' (or you could assign it to some name,
to get the effect only in the output).

`#mrow(mi("r"),mo("&apos;"))` := U.(Vector(2, {(1) = x+I*y, (2) = z}))

Vector[column](%id = 36893627967308679516)

assume(alpha > 0)

Why does it cc alpha despite the assume statement? and why zero-bar?

Ans: Because subs does not evaluate by default, after performing the substitution.
A better approach here is to use eval.

note. It is generally useful to have some command that does not evaluate following
substitution, so that subsequent operations can be performed on the intermediate,
unevaluated expression (which otherwise might change before we had the chance).
In other words, it's useful in general that subs and eval both exist and behave differently.

 

subs(a = exp(I*alpha*(1/2)), b = 0, `#mrow(mi("r"),mo("&apos;"))`); `~`[eval](%)

Vector(2, {(1) = exp(((1/2)*I)*`&alpha;`)*(x+I*y), (2) = -conjugate(0)*(x+I*y)+conjugate(exp(1))^(((1/2)*I)*`&alpha;`)*z})

Vector[column](%id = 36893627967308664452)

eval(`#mrow(mi("r"),mo("&apos;"))`, [a = exp(I*alpha*(1/2)), b = 0])

Vector[column](%id = 36893627967308649044)

NULL

Download matrix_ops_Qs_ac.mw

The following approach is not fancy, but hopefully you'll find it understandable.

The basic idea here is to form a list of all the indices of the table, and then pare that down according to whether the corresponding values are NULL.

T := table([1 = NULL, 2 = NULL, 3 = NULL, 4 = NULL, 5 = NULL, 6 = NULL, 7 = 5, 9 = NULL, 8 = NULL, 11 = 4, 10 = NULL, 13 = NULL, 12 = NULL, 15 = 9, 14 = NULL, 18 = NULL, 19 = 8, 16 = 9, 17 = NULL, 22 = 9, 23 = NULL, 20 = NULL, 21 = 8, 27 = NULL, 26 = 8, 25 = 4, 24 = NULL, 31 = NULL, 30 = 9, 29 = NULL, 28 = 9, 36 = NULL, 37 = 9, 38 = 9, 39 = NULL, 32 = 5, 33 = NULL, 34 = NULL, 35 = NULL, 45 = NULL, 44 = NULL, 47 = NULL, 46 = NULL, 41 = 8, 40 = NULL, 43 = NULL, 42 = NULL, 54 = NULL, 55 = NULL, 52 = NULL, 53 = NULL, 50 = NULL, 51 = NULL, 48 = 5, 49 = 9, 60 = 8, 59 = NULL, 58 = 7, 57 = 7, 56 = NULL]):
 

select(i->T[i]<>NULL, [indices(T,nolist)]);

[7, 11, 15, 19, 16, 22, 21, 26, 25, 30, 28, 37, 38, 32, 41, 48, 49, 60, 58, 57]

Download table_lk.mw

ps. There are even fancier ways, including some using newly introduced syntax. But the above should work in most/many old versions.

Please see the attached, which I believe is as much as can be recovered from your original attachment. (This is much more than the GUI itself recovers.)

Assignment2_ac.mw

There may now be four or five removed (invalid) 2D inputs:
1) just after, "We only need to consider the eigenvalues of the matrix A of the modelled system"
2) just before "From A__1 we have the first eigenvalue"
3) Just before, "The roots of the polynomium"
4) Just before, "To find the two eigenvalues we solve"
5) Just before, "The roots of the polynomium"

note: I think you might also have some misspellings, eg. "polynomium" for "polynomial", and "Luaponov" for "Lyaponov".

note: Of course, I will add this example to my previous bug reports of similar, reported problems.

note: There is some evidence that use of the Matrix palette in non-executable 2D Math might be related to the underlying GUI problem.

It looks as if there is no multiplication sign (or space, for implicit multiplication with 2D Input) before the brackets in the terms that look like,

   a(x+I*y)  ,  b(x-I*y) 

In that case those terms would be function calls (of a and b), rather than products.

Similarly the terms that look like bz , az would be just two-letter names, rather than products.

It's difficult to tell for sure because you haven't upload and attached your actual worksheet (green up-arrow in the Mapleprimes editor).

If your worksheets use only 1D Maple notation then most text-based utilities will be able to find the text fragment, as that is stored in the .mw file as plaintext.

If you use some 2D Input mode then it's more effort, as that needs to be converted to 1D input as a preliminary step to searching. It could still be done programmatically, by first running such .mw files through the command,
   Worksheet:-WorksheetToMapleText

You could call DocumentTools:-Tabulate one or several times to show the intermediate results, and and optionally call it again with a empty list (and options) to make it look blank.

That all happens (and overwrites) the same & single Task region that gets thusly embedded just below the Group or Block's output region.

You could also do the same thing with the lower level DocumentTools commands that Tabulate calls. It's a convenience to be able to use the single command.

For example,

restart;
proc() local i, opts;
  uses TB=DocumentTools:-Tabulate;
  opts:=':-exterior'=':-none':
  for i from 1 to 10 do
    Threads:-Sleep(0.5); # to mimic long computation
    TB([ sprintf("%ld",i) ], opts);
  end do;
  TB(["Yay, we counted to 10"], opts);
  NULL;
end proc();

A variant:

p := proc() local i, opts;
  uses TB=DocumentTools:-Tabulate;
  opts:=':-exterior'=':-none':
  for i from 1 to 10 do
    Threads:-Sleep(0.5); # to mimic long computation
    TB([ sprintf("%ld",i) ], opts);
  end do;
  TB([[]], opts);
  i-1;
end proc:
res := p();

The following attachment is as much as I can recover. It might be close to complete. There were two invalid "Equation" XML elements in the .mw file:
  1) just before the text "(bliver til et vejet gennemsnit) in subsection,
        "Gradienter forsat, Stigningsgrad i andre retninger en y og x"
   2) just before "Sætning 2 om gradienter:" in that same subsection

C_Users_rosho_Desktop_Uni_2._semestre_Matematik_Maple_Noter_mat_1_MAS_ac.mw

In your input of the system enter exp(t) instead of the literal keystrokes e^t .

Since you are using 2D Input mode you could also be able type the letters exp and then press the Esc key, to get command completion. The first item in the popup should allow you to get the typeset math instance of exp(t).

See also this page (though I'm not sure you'd get the warning about wrong usage in such an old version).

ps. You don't have to assign to the letter e, and the fewer assignments to short names the cleaner your global namespace will be...

You haven't told u which version of Maple you're using, which can make it tricky.

Is this something like what you're after, getting back a usual (non-DG) representation of the things assigned to w?

restart;

with(DifferentialGeometry):

DGsetup([x1, x2, x3, x4], M):

w := evalDG(dx1*x1+dx2*x3);

_DG([["form", M, 1], [[[1], x1], [[2], x3]]])

M > 

hoo := op(2,Typesetting:-Parse(subsindets(`print/_DG`(op(w)),
                                          specfunc(anything,Typesetting:-mcomplete),
                                          u->op(1,u))));

dx1*x1+dx2*x3

M > 

lprint(eval(hoo,1));

dx1*x1+dx2*x3

M > 

latex(eval(hoo,1));

{\it x1}\,{\it dx1}+{\it x3}\,{\it dx2}

M > 

restart;

with(DifferentialGeometry):

with(JetCalculus):

DGsetup([x1, x2, x3], M);

`frame name: M`

w:=evalDG(x2/x4*dx1-dx2);

_DG([["form", M, 1], [[[1], x2/x4], [[2], -1]]])

M > 

hoo := op(2,Typesetting:-Parse(subsindets(`print/_DG`(op(w)),
                                          specfunc(anything,Typesetting:-mcomplete),
                                          u->op(1,u))));

x2*dx1/x4-dx2

M > 

lprint(eval(hoo,1));

x2*dx1/x4-dx2

M > 

latex(eval(hoo,1));

{\frac {{\it x2}\,{\it dx1}}{{\it x4}}}-{\it dx2}

Download DG_ex.mw

Many of the options of the plot3d command can also be used with other 3D plotting commands such as pointplot3d.

Notice that Help page is also cross-referenced by a link from the See Also sidebar of the Help page for topic pointplot3d. Such See Also links are often useful.

More directly, that Help page for topic pointplot3d explicitly mentions that plot3d,options page being relevant, in its Parameters section.

The lightmodel option provides the programmatic means to specify the choices 1-4 or none that you'd see in the right-click popup menu.

The light option provides the programmatic means to specify a custom lighting (ie. with a similar effect to what the popup shows if you interactively select "User").

You could try,

   YFtpt5 := TtT -> eval(solution(TtT, 0.5), Y);
   plot(YFtpt5, 0.01..10);

But it would be easier to check if you uploaded and attached a worksheet showing your equations. You could use the green up-arrow in the Mapleprimes response editor. (It's not immediately clear how the TtT affects the equations.)

If I understand correctly what you're trying to accomplish, then try adding the Document Property with attribute name Active and attribute value true

Then save the .mw file, then save it to your Help database, etc, as usual.

Then try opening it via that link from another Help page, in the Help window. Hopefully it will open as a Worksheet/Document, rather than as yet another Help page.

First 51 52 53 54 55 56 57 Last Page 53 of 336