acer

32385 Reputation

29 Badges

19 years, 334 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Your call to sort(...) without options actually gets in the way.

restart;

expr := cos(x) - sin(x)/(x^2*y) + 3*x*y;

     cos(x)-sin(x)/x^2/y+3*x*y

simplify(expr, {sin(x)/cos(x)=tan(x)});

  -1/x^2/y*tan(x)*cos(x)+cos(x)+3*x*y

cos(x)*expand(%/cos(x));

  cos(x)*(-1/x^2/y*tan(x)+1+3/cos(x)*x*y)

sort(%, order=plex(x,y));

     cos(x)*(3/cos(x)*x*y-tan(x)/x^2/y+1)

I don't think that your use of ``() merits whatever benefits it might provide here (eg, if trying to yank out a numeric coefficient, say).

I suppose that you are getting the RootOf as result of some command, since otherwise you'd already have the expression x^2-1 at hand and this would all be unnecessary.

The first operand of the RootOf can be extracted using the op command. But the name x is not present in the RootOf.

A:= RootOf(x^2-1);

                               2
                 A := RootOf(_Z  - 1)

op(1,A);

                          2
                        _Z  - 1

This works for some pages, though it is rather roundabout. But it can be handier for long Topics.

1) In the open Help, use the menubar icon with tooltip, "Open the current help page in a worksheet window"

2) In that opened worksheet, use the menubar item, File -> Document Properties

3) Copy the entry for the Topic Property

4) Paste that in to the right-click Convert To -> Hyperlink popup.

@Amir_Maple Different approaches to performing the integration can result in different values for the constant term. (As mentioned, the particular value of some constant term does not make the result invalid.)

poly_int_example.mw

From your description of your display problems I suspect that your session has been accidentally set to use prettyprint level 0 for output.

You can test that using the following command,

   interface(prettyprint);

which should not be executed in the same paragraph or execution group as an restart.

If that is the problem then you may fix it as follows:

a) Execute the command (not directly by any restart),
    interface(prettyprint=3):

b) In the GUI go to the menubar item Tools->Options->Display
    and ensure that the combo-box item "Output display" is set
    to "2-D Math Notation"

c) Press the "Apply Globally" button.  Then close the Maple GUI
    altogether, relaunch, and test it.

This may also help with the "Typesetting" artefacts you showed elsewhere.

The edges of the filled region appear rough unless an accompanying outline curve is also rendered. That's why style=polygonoutline (default) has a border.

You're objecting that the fill color doesn't match the outline's color.

You can get a matching color for both filled region and outline (border) by calling the command twice -- once without border and once with as just a line (curve, as outline border) with forced matching color.

with(plots,display): with(plottools,ellipse):

display(
  ellipse([0, 0], 2, 1, filled=true, color = red, style=polygon),
  ellipse([0, 0], 2, 1, filled=true, color = red, style=line),
  size=[1000,500],scaling=constrained,axes=none)

And if you'd like to compare the variants side-by-side,

with(plots,display): with(plottools,ellipse):

display(Array([

  # One the left, the outline is rendered smoothly.
  display(ellipse([0, 0], 2, 1, filled=true, color = red, style=polygon),
          ellipse([0, 0], 2, 1, filled=true, color = red, style=line)),

  # In the middle, the undesirable black outline.
  display(ellipse([0, 0], 2, 1, filled=true, color = red, style=polygonoutline)),

  # One the right, the lack of any outline makes the filled edges jagged.
  display(ellipse([0, 0], 2, 1, filled=true, color = red, style=polygon))

              ]),size=[400,200],scaling=constrained,axes=none);

You might also see my comment on another Answer, in which I show a similar effect of matching colors using a single call to the plot command with a corresponding parametric form.

The plot may not be necessary.

F__A0 := 20;
X__Af := 0.9;
r__A := -2.52*1^2*X*(1 - X);

eq := V = (R + 1)*F__A0*int(1/(-r__A), X = X__Af*R/(R + 1) .. X__Af)
      assuming 0<X, X<1, 0<R, R<1;

    eq := V = 20 (R + 1) (-0.3968253968 ln(R) + 0.3968253968 ln(R + 10.))

Optimization:-Minimize(V, {eq, 0 <= R, R <= 1})[2];

          [R = 0.429944982482764, V = 36.1887187298120]

Solvingforlimitsofintegrals_ac.mw

I'm not quite sure what you're after. Is it something like this?

restart:

 

alias(X = X(t)):

alias(phi=k*X(t)):

alias(Phi=Phi(X(t))):

 

kin := 1/2*M*Diff(X, t)^2 + 1/2*m*Diff(Phi, t)^2;

(1/2)*M*(Diff(X, t))^2+(1/2)*m*(Diff(Phi, t))^2

eval(kin, Phi=phi);

(1/2)*M*(Diff(X, t))^2+(1/2)*m*(Diff(phi, t))^2

value(%);

(1/2)*M*(diff(X, t))^2+(1/2)*m*k^2*(diff(X, t))^2

convert(%, D);

(1/2)*M*(D(X))(t)^2+(1/2)*m*k^2*(D(X))(t)^2

Download alias_diff_ex.mw

If your goal is simply to print the procedure in way that is formatted suitably as 1D plaintext Maple notation source code then you could try the new %P format descriptor of the printf command.

Eg,

interface(verboseproc=3):
printf("%P",eval(RonanRoutines:-SignedArea));

If you want that exported to a text file then you could use fprintf instead of printf.

Note that showstat does not show "\" line-continuation characters, which may have been part of your problem. But (as used above) printf will include them. That can allow the 1D parser to properly deal with such split lines.

ps. In general you should not try to paste plaintext Maple notation code in as 2D Input. (That doesn't seem to have been your original problem. But I suggest you note it anyway.)

Your given example can also be handled as follows. (But without the bigger picture it's unnecessarily difficult to guess whether this will help with your broader goal.)

convert(a*x+6*x^2-10, 'horner', x);

           -10 + (a + 6 x) x

or perhaps,

sort(convert(a*x+6*x^2-10, 'horner', x), x);

            (6 x + a) x - 10

Your followup comments on other Answers indicate that you have some more involved example (and goal) which you have not yet shown.

A common scenario is that someone concocts their own approach for a larger goal, then gets bogged down in implementing one problematic step of that, and then asks only about how to resolve that particular step. It's often more useful to provide the more complete motivating example.

It did actually substitute, in your first example. It just didn't happen to simplify (in the way you apparently expected).  That can be done in several ways. Eg,

algsubs(n2+n1=n+6,a+(n1-b)*k+a+(n2-b)*k);

    k (-n2 + n + 6 - b) + (n2 - b) k + 2 a

simplify(%);

           k (-2 b + n + 6) + 2 a

If you don't like how algsubs works then you could also use simplify (with side-relations) here. Eg,

simplify(a+(n1-b)*k+a+(n2-b)*k, {n2+n1=n+6});

           k (-2 b + n + 6) + 2 a

By the way, you also mentioned a particular rearrangement of the simplified form. That too can be attained in several straightforward ways. Eg.

ans1 := algsubs(n2+n1=n+6,a+(n1-b)*k+a+(n2-b)*k):

collect(ans1,[a,b],simplify);

        2 a - 2 k b + k (n + 6)

collect(simplify(ans1),[a,b]);

        2 a - 2 k b + k (n + 6)

ans2 := simplify(a+(n1-b)*k+a+(n2-b)*k, {n2+n1=n+6}):

collect(ans2,[a,b]);

        2 a - 2 k b + k (n + 6)

One way is to utilize the showstat command, but using :: instead of :- as separator of the name, eg.

   showstat((Student:-Calculus1:-Roots)::RootsNumeric);

You may need to introduce extra round-brackets there, to resolve ambiguity.

Another way is to set,

   kernelopts(opaquemodules=false):

and then use showstat or print or the debugger as usual.

If you do not know the names of the local members of the module then you may utilize op for inspection, eg.

   op(eval(Student:-Calculus1:-Roots));
   op(3,eval(Student:-Calculus1:-Roots));

 

Another possibility is to use a parameter for the ratio x/r.

That sidesteps having to deal with the case that the x-Slider might have a value greater than the r-Slider.

restart;

A := (x,r) -> 2*sqrt(-x^2 + r^2)*x:

Explore(plots:-display(plot(p -> sqrt(r^2 - p^2), -r..r, color=blue),
                       plottools:-rectangle([-X*r,0], [X*r,sqrt(-(X*r)^2 + r^2)],
                                            style=line, color=red, thickness=4),
                       title=typeset("r = %1\nx = %2, Area = %3\n(Optimal: x=%4, Area=%5)",
                                     r, X*r, A(X*r,r), r/sqrt(2.), r^2 ),
                       axis[1]=[tickmarks=[`if`(X*r>r*0.05 and r-X*r>0.05, X*r="x",
                                                ceil(r)=ceil(r)),
                                           seq(u=u,u=floor(-r)..ceil(r))]],
                       scaling=constrained),
        parameters=[[r = 0.0 .. 4.0, label="r"],
                    [X = 0.0 .. 1.0, label="x/r"]],
        initialvalues=[X=1/sqrt(2.), r=2.0]);

 

Download rect_semicricle_explored.mw

Here are a few ways, involving purely numeric rootfinding (since you asked about that specifically).

r1 := fsolve(x^(1/x)=1.2);

         r1 := 1.257734541

r2 := fsolve(x^(1/x)=1.2, x, avoid={x=r1});

         r2 := 14.76745838

[fsolve(x^(1/x)=1.2, x=0..20, maxsols=2)];

      [1.257734541, 14.76745838]

Student:-Calculus1:-Roots(x^(1/x)=1.2, x=0..20);

      [1.257734541, 14.76745838]

Here's one way to get Maple to cough them up exactly. Note that the _BXXX coming out of solve is a boolean-valued parameter, ie. it has the assumption of having a value of 0 or 1. So we can evaluate using either of those values.

T := solve(x^(1/x)=12/10, real, allsolutions);

-LambertW(-_B6, -ln(6/5))/ln(6/5)

b := indets(T,And(name,Non(constant)));

{_B6}

eval(T, b[1]=1);

-LambertW(-1, -ln(6/5))/ln(6/5)

evalf(%);

14.76745838

eval(T, b[1]=0);

-LambertW(-ln(6/5))/ln(6/5)

evalf(%);

1.257734541

Download rfex.mw

This can be tidied up, but I've deliberately kept some steps separate in order to give you a better idea of what's going on.

You didn't make it clear whether N was a multiple of n, so I'll show a way that chops to length N, and another that pads the Matrix.

restart;

with(StringTools):

raw := "How. doIt   urnate**xtintoaM?\"atrixofle{{12345ttersinth   emostconvenient";

"How. doIt   urnate**xtintoaM?"atrixofle{{12345ttersinth   emostconvenient"

str := Select(IsAlpha,raw);

"HowdoIturnatextintoaMatrixoflettersinthemostconvenient"

n := 7;

7

L := Explode(str);

["H", "o", "w", "d", "o", "I", "t", "u", "r", "n", "a", "t", "e", "x", "t", "i", "n", "t", "o", "a", "M", "a", "t", "r", "i", "x", "o", "f", "l", "e", "t", "t", "e", "r", "s", "i", "n", "t", "h", "e", "m", "o", "s", "t", "c", "o", "n", "v", "e", "n", "i", "e", "n", "t"]

Matrix(iquo(nops(L),n),n,L[1..n*iquo(nops(L),n)]);

Matrix(7, 7, {(1, 1) = "H", (1, 2) = "o", (1, 3) = "w", (1, 4) = "d", (1, 5) = "o", (1, 6) = "I", (1, 7) = "t", (2, 1) = "u", (2, 2) = "r", (2, 3) = "n", (2, 4) = "a", (2, 5) = "t", (2, 6) = "e", (2, 7) = "x", (3, 1) = "t", (3, 2) = "i", (3, 3) = "n", (3, 4) = "t", (3, 5) = "o", (3, 6) = "a", (3, 7) = "M", (4, 1) = "a", (4, 2) = "t", (4, 3) = "r", (4, 4) = "i", (4, 5) = "x", (4, 6) = "o", (4, 7) = "f", (5, 1) = "l", (5, 2) = "e", (5, 3) = "t", (5, 4) = "t", (5, 5) = "e", (5, 6) = "r", (5, 7) = "s", (6, 1) = "i", (6, 2) = "n", (6, 3) = "t", (6, 4) = "h", (6, 5) = "e", (6, 6) = "m", (6, 7) = "o", (7, 1) = "s", (7, 2) = "t", (7, 3) = "c", (7, 4) = "o", (7, 5) = "n", (7, 6) = "v", (7, 7) = "e"})

Matrix(`if`(irem(nops(L),n)=0,nops(L)/n, iquo(nops(L),n)+1), n, L);

Matrix(8, 7, {(1, 1) = "H", (1, 2) = "o", (1, 3) = "w", (1, 4) = "d", (1, 5) = "o", (1, 6) = "I", (1, 7) = "t", (2, 1) = "u", (2, 2) = "r", (2, 3) = "n", (2, 4) = "a", (2, 5) = "t", (2, 6) = "e", (2, 7) = "x", (3, 1) = "t", (3, 2) = "i", (3, 3) = "n", (3, 4) = "t", (3, 5) = "o", (3, 6) = "a", (3, 7) = "M", (4, 1) = "a", (4, 2) = "t", (4, 3) = "r", (4, 4) = "i", (4, 5) = "x", (4, 6) = "o", (4, 7) = "f", (5, 1) = "l", (5, 2) = "e", (5, 3) = "t", (5, 4) = "t", (5, 5) = "e", (5, 6) = "r", (5, 7) = "s", (6, 1) = "i", (6, 2) = "n", (6, 3) = "t", (6, 4) = "h", (6, 5) = "e", (6, 6) = "m", (6, 7) = "o", (7, 1) = "s", (7, 2) = "t", (7, 3) = "c", (7, 4) = "o", (7, 5) = "n", (7, 6) = "v", (7, 7) = "e", (8, 1) = "n", (8, 2) = "i", (8, 3) = "e", (8, 4) = "n", (8, 5) = "t", (8, 6) = 0, (8, 7) = 0})

 

Download str2mat.mw

You didn't mention what you wanted to happen to capital letters. You can easily add a step to turn such into lowercase, utilizing the LowerCase command. Just replace the obvious line above with,

    str := LowerCase(Select(IsAlpha,raw));

str2mat_lower.mw

Naturally you could also throw away any capital letters (instead of converting them to lower-case), by utilized the IsLower command as part of the predicate passed to Select. It isn't clear which you want.

First 77 78 79 80 81 82 83 Last Page 79 of 336