acer

32405 Reputation

29 Badges

19 years, 350 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

One way involves using the select command.

L1 := [[1,1,1,1], [1,2,0,0], [0,0,0,0], [1,1,-2,0]]:

select(L->add(L)=0, L1);

        [[0, 0, 0, 0], [1, 1, -2, 0]]

That should work in Maple 2015 and later. In older versions you could do a similar thing as,

select(L->`+`(L[])=0, L1);

Are you saying that you'd like to configure a custom worksheet as your Start Page?

That is documented here.

You could use an empty Table, instead of the one you showed above.

The second case gets automatic simplification of the literal input 2*(x+2*y), but case 1 does not.

Note that automatic simplification occurs between parsing and initial evaluation.

Also, it cannot be prevented through use of unevaluation quotes (single right-ticks):

t^2*( '2*(x+2*y)' );

           2            
          t  (2 x + 4 y)

In your original case 1 the sum B is multiplied by t^2*A which is something that is not purely of type numeric, and that coefficient is not distributed across the sum.

When you alter your case 1 by introducing that eval call you are separating the steps, so that A*B is computed separately. In that case the sum term B gets multipled by the purely numeric value of A and that gets distributed across the sum.

Literal input is not necessarily going to produce the same result as substitution and evaluation after the fact.

note: A bit more on automatic simplification can be had in Section 3.4 "Unevaluated Expressions" of Chapter 3 of the Programming Guide, in the subsection "Evaluation and Automatic Simplification".

The following handles all the examples that you've supplied so far. That includes all the originally provided examples.

common_factor := proc(x::algebraic, ee::algebraic)
  local p, d := gcd(ee, x^frontend(degree,[ee,x]),'p');
  d * p;
end proc:

smthng.mw

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)
First 77 78 79 80 81 82 83 Last Page 79 of 336