acer

32587 Reputation

29 Badges

20 years, 37 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Your Document calls myProc before it defines myProc as a procedure, going from top to bottom. So if you rerun the whole thing (!!! from the menubar, say) twice that call will work unless you add a restart.

If you add in the restart then the call to myProc will return unevaluated if you are executing from top to bottom.

I suggest that you move the definition of myProc to some place above where you attempt to call it.

Btw, on my Maple 2022.2 the parser does not like the semicolon (statement terminator) that follows immediately after  proc(pA).

You ought to be able to use the context-panel item,

    Solve -> Numerically Solve (w/complex)

on your example. That makes it call fsolve(..., complex) which gets all three roots.

And, if I retype it into a new paragraph/Document-Block then that approach works as it's supposed to.

But for some reason your worksheet's problematic 2D Input line in question only inserts,
      fsolve(...)
which computes just the real roots (the're only 1). That happens even if I choose the appropriate context-panel items I mentioned at top. It also happens if I remove the previous output. I don't know how it got into that weird state.

It works fine without needing rtable_eval or another special command. (In fact Carl's suggestion to wrap with a call to rtable_eval doesn't solve your problem.)

Your mistake is that your eval call is substituting for _t__3 (which will appear subscripted in 2D Input). But the solution Vector actually contains _t[3], which is an indexed name that also pretty-prints as a subscripted name.

subintomatrix_ac.mw

You can enter an indexed name in its subscripted form (in 2D Input) by using the keyboard shortcut  Ctl-Alt-b  . See here for more of such shortcuts.

[edit] the original version of my answer contains a call to indets that shows you one way to extract the indexed name here. You could then use that for your substitution. It also shows that you can use lprint to line-print it and see how it's actually formed.

If you are using a (deprecated) lowercase matrix then you could try applying evalm or eval to the name, following the read from .m format. A lowercase matrix follows Maple's last name evaluation rules.

I recommend using the capitalized Matrix command instead of the deprecated matrix command, if at all possible. That should work with save&read with .m format, in a way that may be less surprising to you.

Download saveread_matrix.mw

If you are already using the capitalized Matrix command, and are having some other kind of problem, then upload and attach an actual worksheet that reproduces the problem.

The RootOf is a placeholder, an implicit representation of the radical solution(s).

If you want the radical solutions expressed explicitly then you can pass the explicit option to the solve command.

Unrolling the cylinder and applying the Pythagorean theorem, is it, A) 72.6 which is an approximation of,

  5 + sqrt( (2*Pi*10)^2 + (30-5)^2 )

Since a table has last-name-eval behaviour, I don't understand how your line,

   Original["calculations"]["loadcases"]["1"] := loadcase

could be successful after Save/Close/Reopen. It stores & restores the name.

But you want the actual table stored & restored. So why not, instead,

   Original["calculations"]["loadcases"]["1"] := eval(loadcase)

StoreBetweenSessions_ac.mw

Here's one way:

x := omega1*exp(omega1*t1*I) + omega1/exp(omega1*t1*I);

        omega1*exp(I*omega1*t1)+omega1/exp(I*omega1*t1)

evalindets(x, specfunc(exp), u->eval(u,omega1=omega2));

        omega1*exp(I*omega2*t1)+omega1/exp(I*omega2*t1)

subs_spec.mw

One possible alternative is to pass in A & B and have the procedure itself assign to them in the case that the return value is not FAIL.

You could optionally leave A & B alone in the FAIL case, or unassign them if you're into forging your own path.

restart;
interface(warnlevel=4):
kernelopts('assertlevel'=2):

foo:=proc(n, X::evaln,Y::evaln)::{identical(NULL),identical(FAIL)};
      local f := rand(1..1000):
      if n = 0 then
         unassign(X), unassign(Y); # optional, you could leave them unchanged
         return FAIL;
      else
         assign(X,f()); assign(Y,f());
         return NULL;
      fi;
end proc:

ret := foo(13, A, B);

            ret := ()

A,B;

             861, 759

ret := foo(0, A, B);

            ret := FAIL

A, B;

                A, B

ret := foo(17, A, B);

              ret := ()

A,B;

              751, 890

If you are using 2D Input mode then you could do it as,

    tot := tot + z;

From the Compatibility section at the bottom of the Help page for topic assignment:

"Compatibility
Assignments as expressions and operator assignments are currently not supported in 2-D math input in the Standard Interface. They are supported in 1-D math input in the Standard Interface, as well as in all forms of input and output in the Command-line user interface."

@panke In order to extend the library path, you might begin by reading the Help page on `libname`, or the relevent section of the Programming Manual.

The main structural difference between a Worksheet and a Document is that the latter has at least one "Document Block".

A so-called Document can have Document Blocks (structurally a container of Execution Groups, which affects their appearance and behaviour). But a Document can also have traditional/plain Execution Groups on their own, each with the red prompt and red 1D plaintext code or black 2D Input.

If you use the menubar's Edit -> Document Blocks -> Create Document Block you can inject that into a Worksheet, and in such a way turn it into a Document -- which happens to have both Document Block(s) as well as Execution Groups proper.

IIRC there is no GUI easy one-shot facility for turning plain Execution Groups (red prompt) into Document Blocks.

If you use that Edit->... concoction from a plain Execution Group then you can subsequently cut&paste its input in as the newly created Document Block's input. (But I don't think that your can cut&paste both input&output together of such an Execution Group without its simply pasting back again in as a plain Execution Group.)

note: Hopefully you are not confusing Worksheet/Document with 1D/2D input mode. I've guessed that you are not.

note: Since a Document can have both Document Blocks as well as plain (solo) Execution groups, the conversion of Worksheet->Document is not strictly unique. Of course, you may want all plain execution Groups turned into Document Blocks. Such a conversion mechanism could be encoded in a reusable Maple procedure -- but not by me in the next few weeks.

note: I'd agree that the terminology is muddled. I find it better to always (and only) capitalize these words when using them in a Maple technical sense.

Note that the following happens if that target result of yours gets evaluated (without faking it via inert operators or similar):

(10/(3*t + 1250))^(1/3);

                             (1/3)
           (1/3) /    1     \     
         10      |----------|     
                 \3 t + 1250/     

Here are a few alternative approaches. (I could have used assumptions, but since you don't appear to be very concerned about whether the "simplification" is always correct I used the symbolic option.)

Download de_ac.mw

There are several t-values at which abs(u2) tends to infinity with x=0. For example, EllipticK(1/2)/2.

You can fsolve for the six t-values in t=-5..5, for x=0.

The attachment shows how Optimization:-Maximize can be used get some approximate values out, hence to illustrate/hint at that.

It also shows fsolve (and solve, for one exact root) acting on the denominator.

plot_ac.mw

Why would you have thought that? Please explain your thinking.

Take x=Pi/4, and take its sin value.  Now take x=2*Pi+Pi/4, and take its sin value. You should get sqrt(2)/2 or approximately .707 for both.

Now consider how to compute arcsin(sin(2*Pi+Pi/4)).

Do you think that the result ought to be 2*Pi+Pi/4? The arcsin command is just going to recieve sqrt(2)/2 from being passed sin(2*Pi+Pi/4).

Here's the kicker: how do you expect arcsin to know whether the sqrt(2)/2 it receives came from sin(2*Pi+Pi/4) or sin(Pi/4)?

You might review some of the basic concepts of trig functions and their inverses -- paying attention to the restricted ranges of the inverse trig functions.

simplify(arcsin(sin(x))) assuming -Pi/2<=x, x<=Pi/2;

         x

sin(arcsin(x));

         x
First 58 59 60 61 62 63 64 Last Page 60 of 338