acer

32333 Reputation

29 Badges

19 years, 320 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

First I'll show you an easy way to get a partial method. Then I'll give you some links to related, older Questions in which the answers get it more completely but also require altering how you initially input the example.

An easy way:

You can do something quite close to that, in two context-panel steps.

First, you could apply the command  eval(..., 1)  to the input. You could do this from the context-panel, using the item "Apply a Command". The command to enter in the popup box is eval and the extra argument to it is 1 .

Second, you could choose the context-panel choice "Simplify" -> "Simplify" (ie. in the submenu choices).

Attached is an example. I did it as above.  CM_eval1.mw

Unfortunately it is quite difficult to prevent or delay the numeric coefficient such as 50/10 from reducing down to just 5, on account of automatic simplification of numeric arithmetic.

More complicated ways:

The following approaches mostly require use of the InertForm package and/or wrapping the initial input in a call to a custom procedure (which will do the fancy work). This can avoid the automatic simplification issue.

1) Take a look at this idea, which is closer to your idea I suspect, and not too much extra setup (also coming here).
or,
2) Have a look at this and this (which both show the results across several lines of output).

The minimize command is not strong at multivariate problems. Sometimes it gets confused about computing & using derivatives, and ends up deciding upon end-points (and not necessarily the correct ones).

Sometimes you can get lucky with it. For fun...

minimize(x^3 + y^3 + z^3 - 4*x*y*z, x = 0 .. infinity, y = 0 .. infinity) assuming z>0;
minimize(%, z=0..infinity, location);
minimize(x^3 + y^3 + z^3 - 4*x*y*z, x = 0 .. infinity) assuming y>0, z>0;
minimize(%, y=0..infinity) assuming z>0;
minimize(%, z=0..infinity, location);

Your code calls plottools:-arrow, and it passes 0.4 as its fourth argument. That specifies the width of the arrow head, in an absolute scale.

But the scale of your plot is 0 to 900.  On that scale 0.4 is so tiny that you cannot see the arrow head.

Compare what happens if you simply change your call to, say,

   arrow([0, 0], [725, 350], 0.1, 10.0, 0.1, arrow, color = red, legend = "Vector v")

In the (undocumented?) calling sequence you tried, it has removed all characters from the second argument that are present in the first argument.

The "(", the ")", and the "2" are characters present in the first string, and instances of those characters are removed from the second string.

This seems to make sense and -- even though the first argument is not a predicate as in the documentation -- it's acting analogously by testing each character in the second string. The documentation describes this command as acting individually on all the characters in the second string, ie. it's not just looking for one full contiguous match.

Perhaps you wanted the following, instead. The Substitute command replaces the first instance of an exactly matching substring. (SubstituteAll replaces all such full matches.) Below, I replace the matching substring with the empty string.

L1 := "Methionine = (S)-2-amino-4-(methylsulfanyl)-butanoic acid (2.13)";
acid1 := "Methionine = (S)-2-amino-4-(methylsulfanyl)-butanoic acid ";

StringTools:-SubstituteAll(L1, acid1, "");

                 "(2.13)"

# or even this,
StringTools:-Substitute(L1, acid1, "");

                 "(2.13)"

Perhaps you could first run,

    mint -S -q test.txt

and bail out if there was any output.

If you (correctly) change the
  with(plots)
inside the procedure to instead be
  uses plots;
then you still need to call plots:-display properly outside that procedure.

In the attachment, I call it using its long-form name, plots:-display.

V8_Calculation_of_pH_from_known_values_of_Vb_(Document)_ac.mw

I made some other adjustments. (I changed how the .m file is found, for my own convenience to avoid the Maplet. You can undo that.)
- I added a restart at the start of the Document. A good practice to show check/ensure that the Document runs properly when fully run, to-to-bottom, upon reopening. (We've mentioned this to you before, as a reasonable practice.)
- I moved the definition of the procedure to above (ie. before, under normal execution) the call to it. (We've mentioned this to you before as a reasonable practice.)

note: I think that it would be better programming if your prodecure returned the plot, instead of its declaring A as global. You could make the assignment when calling it. See this additional attachment: V8_Calculation_of_pH_from_known_values_of_Vb_(Document)_ac2.mw

ps. I changed your Question here so it is marked as Product "Maple", but removed the check of the box for Product "Mapleprimes". The Question is about using Maple, and not about using the forum itself.

Try this.

(It could be more efficient.)

restart;

C := proc(A)
  (op@ListTools:-Reverse)~(map(Bits:-Split,
                               convert(A,':-compose',
                                       ':-ByteArray',list)[[4,3,2,1]],
                               ':-bits'=8));
end proc:

f1 := Array([-1.4853515625*2^26], datatype = float[4]):
C(f1);

    [1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0,
     0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

f2 := Array([1.4140625*2^88], datatype = float[4]):
C(f2);

    [0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

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

First 55 56 57 58 59 60 61 Last Page 57 of 336