acer

32717 Reputation

29 Badges

20 years, 83 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

The leading term is determined lexicographically (here, alphabetically, but where lower/uppercase matters).

And so what matters for -v1+a is the coefficient of a , while what matters for -V1+a is the coefficient of V1.  The capital letters are taken first.

Maple needs to use some convention in your usage case where no variable list is supplied as additonal argument. It might make sense (albeit tiresomely) to complain about the particular convention used, but it would make no sense to complain that it has to have some convention.

[edit] I should point out that for important efficiency concerns Maple stores only one instance of a polynomial in memory, regardless of whether it is entered as -v1+a or later as a-v1 . Moreover a polynomial can have its subterms sorted inplace in memory, but that structural change should not affect the result from sign which is mathematical. Therefore its leading term cannot be determined by the order in which you later re-type it or the order in which the subterms are stored in memory. So a convention that considers the leading term lexicographically lets things work.

restart;
p := -V1 + a;
                          p := -V1 + a

sign(p);
                               -1

sort(p,order=plex(V1,a),ascending);
                             a - V1

p;
                             a - V1

sign(p);
                               -1

sort(p,order=plex(V1,a),descending);
                            -V1 + a

p;
                            -V1 + a

sign(p);
                               -1

Since Maple 15 it is even easier to set the default unit for a particular dimension with the UseUnit command. I mean easier than having to use the commands AddSystem and UseSystem as you did above.

This allows other scales of power to be simplified to your desired kWh/day.

You can utilize it with or without loading Units:-Standard, depending on whether you want arithmetic with units to resolve/combine automatically. Or in recent versions you can utilize it alongside Units:-Simple, which does that automatic combining of units while also allow mixed arithmetic of quantities with units attached and unknown quantities (eg. names) without units specified.

restart;

kernelopts(version);

`Maple 2018.0, X86 64 LINUX, Mar 9 2018, Build ID 1298750`

Units:-UseUnit(kWh/day):

expr1 := 4.9*Unit(kW)*3.5*Unit(h/day);

17.15*Units:-Unit(kW)*Units:-Unit(h/d)

combine(expr1, units); # no change, as desired

17.15*Units:-Unit(kWh/d)

expr2 := 1700.1*Unit(W);

1700.1*Units:-Unit(W)

combine(expr2, units);

40.80240000*Units:-Unit(kWh/d)

simplify(expr2);

40.80240000*Units:-Unit(kWh/d)

restart;

Units:-UseUnit(kWh/day):

with(Units:-Standard):

4.9*Unit(kW)*3.5*Unit(h/day);

17.15*Units:-Unit(kWh/d)

simplify(1700.1*Unit(W));

40.80240000*Units:-Unit(kWh/d)

1700.1*Unit(W)*3.4*Unit(days/week);

19.81830857*Units:-Unit(kWh/d)

restart;

Units:-UseUnit(kWh/day):

with(Units:-Simple):

4.9*Unit(kW)*3.5*Unit(h/day) + x;

17.15*Units:-Unit(kWh/d)+x

simplify(1700.1*Unit(W) - u);

1700.1*Units:-Unit(W)-u

1700.1*Unit(W)*3.4*Unit(days/week) + 40.5*k;

19.81830857*Units:-Unit(kWh/d)+40.5*k

 

Download useunit.mw

There are also facilities for right-click units re-formatting in the Maple 2018 GUI. You can also use that (or convert(...,units,W) ) to force display in Watts alone.

@primogen Have you tried,

Physics:-diff~(SimplifiedMassMatrixDot, theta[2](t));

a_ac.mw

I toggled this Question to be marked as "Maple 2017", since that's the release in which your attachment was last saved. (You had it as "Maple 17" which is four major releases earlier.)

I don't know of any easy way to handle 2D Input of units (ie. typeset via command-completion, or from the Units palette).

The following affects 2D Output. (I doubt it will work alongside right-click unit-formatting.)

restart;

kernelopts(version);

`Maple 2018.1, X86 64 LINUX, Jun 8 2018, Build ID 1321769`

 

Unit(88*kg*m/s^2) + Unit(g)*Unit(-3*cm/s^2);

88*Units:-Unit(kg*m/s^2)-3*Units:-Unit(g)*Units:-Unit(cm/s^2)

 

ChangeUnitsColor:=proc(c, {bold::truefalse:=false})
  global `print/Unit`;
  local hexstr;
  uses ColorTools;
  if c = ':-default' then
    `print/Unit`:='`print/Unit`';
    return NULL;
  end if;
  hexstr:=RGB24ToHex(RGBToRGB24([ColorTools:-Color(c)[]]));
  `print/Unit`:=subs(__dummy=hexstr,
      proc(x)
      local r;
      uses T=Typesetting;
      if interface(':-prettyprint')<2 then
        return Units:-Unit(args);
      end if;
      r:=subsindets(T:-Typeset(x),
                    ':-specfunc'({T:-mrow,T:-mi,T:-mo,
                                  T:-mfrac,T:-msup,T:-msqrt}),
                    u->op(0,u)(op(u),
                               "mathcolor"=__dummy));
      r:=subsindets(r,specfunc({T:-mi,T:-mo}),
                    u->T:-mtext(op(u)));
      if bold=true then
        r:=T:-mstyle(r, 'italic'="false", ':-fontweight'="bold");
      end if;
      return r;
    end proc);
  NULL;
end proc:

 

ChangeUnitsColor("Red");

Unit(kg^(1/2));

Units:-Unit(kg^(1/2))

Unit(s/m)+Unit(day/cm);

Units:-Unit(s/m)+Units:-Unit(d/cm)

simplify(Unit(s/m)+Unit(day/cm));

8640001*Units:-Unit(s/m)

ChangeUnitsColor("Green");

sin(x)*Unit(8.8*kg*m/s^2) + Unit(g)*Unit(-3*cm/s^2);

8.8*sin(x)*Units:-Unit(kg*m/s^2)-3*Units:-Unit(g)*Units:-Unit(cm/s^2)

combine(%, units);

(8.8*sin(x)-3/100000)*Units:-Unit(N)

ChangeUnitsColor("Blue", bold);

sin(x)*Unit(8.8*kg*m/s^2) + Unit(-3*g*cm/s^2);

8.8*sin(x)*Units:-Unit(kg*m/s^2)-3*Units:-Unit(g*cm/s^2)

Unit(43*'kg'^2)

43*Units:-Unit(kg^2)

ChangeUnitsColor(default);

sin(x)*Unit(8.8*kg*m/s^2) + Unit(g)*Unit(-3*cm/s^2);

8.8*sin(x)*Units:-Unit(kg*m/s^2)-3*Units:-Unit(g)*Units:-Unit(cm/s^2)

``

Download unitcolorbold.mw

restart;

g := x -> (2*x-7)^('-3');

proc (x) options operator, arrow; (2*x-7)^'-3' end proc

new := InertForm:-MakeInert(g(x)):

InertForm:-Display(new,inert=false);

0, "%1 is not a command in the %2 package", _Hold, Typesetting

g(6);

1/125

other := subs(x=6, new):

InertForm:-Display(other, inert=false);

0, "%1 is not a command in the %2 package", _Hold, Typesetting

value(other);

1/125

map[2](op,2,indets(g(x), `^`));

{-3}

-degree(denom(g(x)),x);

-3

 

Download inertanother.mw

restart;

kernelopts(version);

`Maple 2018.1, X86 64 LINUX, Jun 8 2018, Build ID 1321769`

assume(x>0);

expr := sqrt(x^3*x^(3/4));

(x^(15/4))^(1/2)

new := combine(expr);

x^(15/8)

map[2](op,2,indets(new,identical(x)^anything));

{15/8}

restart;

expr := surd(a*'surd'(a*a^b,2),4);

surd(a*surd(a*a^b, 2), 4)

inertexpr := InertForm:-MakeInert(eval(expr,1)):

new := subs([a=2,b=6,c=4], inertexpr):

ans := InertForm:-Display(new, inert=false);

Typesetting:-mcomplete(Typesetting:-mroot(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("&sdot;"), Typesetting:-mcomplete(Typesetting:-mroot(Typesetting:-mcomplete(Typesetting:-mrow(Typesetting:-mn("2"), Typesetting:-mo("&sdot;"), Typesetting:-mcomplete(Typesetting:-msup(Typesetting:-mrow(Typesetting:-mn("2")), Typesetting:-mn("6"), Typesetting:-msemantics = "^"), Typesetting:-_Hold([`%^`(2, 6)]))), Typesetting:-_Hold([`%*`(2, `%^`(2, 6))])), Typesetting:-mn("2")), Typesetting:-_Hold([%surd(`%*`(2, `%^`(2, 6)), 2)]))), Typesetting:-_Hold([`%*`(2, %surd(`%*`(2, `%^`(2, 6)), 2))])), Typesetting:-mn("4")), Typesetting:-_Hold([%surd(`%*`(2, %surd(`%*`(2, `%^`(2, 6)), 2)), 4)]))

InertForm:-Value(new);

2*2^(1/8)

 

Download inertsurd.mw

The multiple assignment functionality was added in Maple V R5 which was released in 1997.

Have you tried,

display(Array([ display(A,B), C ]));

More importantly, Shouldn't you call it like,

Explore( P(a), parameters=[a=-1.0..1.0] );

so that it explores a function call to P?

Yes, you should be to accomplish this using Embedded Components, as long as the data exists before the plotting begins.

If you're hoping for an asynchronous process that sits there waiting for newly computed data points to be added to the file then the task is much more complicated (if possible at all).

Do you have a sample of data? What kind of plot do you want?

You can map the diff command over the Matrix.

step1calshelper_ac.mw

I also show various simplifications (and their effects on the size of the Matrix entries).

Make a Matrix with the two lists as its columns (ie. column Vectors).

A := [[0, 1, 2, 3, 4, 5], [0, 2, 4, 6, 8, 10]]:
M:=<<A[1]>|<A[2]>>:
ExportMatrix(test, M, delimiter=" "):

Alternatively, create the Matrix with the lists as the rows, and export its transpose.

A := [[0, 1, 2, 3, 4, 5], [0, 2, 4, 6, 8, 10]]:
M:=Matrix(A):
ExportMatrix(test, M^%T, delimiter=" "):

It cannot be done straight from Maple, AFAIK.

It would be interesting if someone proved me wrong by showing a way using the Maple's HTTP or URL (or lower level via Sockets). Its not clear to me how login or authentification might work.

It'd be trickier still, since uploads to Mapleprimes are attachments to posts. It might be more effort to upload without a post (and then somehow post separately and attach the prior raw upload) or to effect both directly from Maple.

Upload and insertion of a link to the worksheet, or inlining of the worksheet, is available from within Mapleprimes using the green up-arrow that appears in the menubar of the Question/Reply/Post editor.

Upload to the Maplecloud is possible, directly from Maple. But I'm not aware that Mapleprimes and the Maplecloud have any functional interchange.

The easiest way is to put both subpackages within a single parent package.

If you really want them distinct then you can utilize an abbreviation scheme. Here are two choices for that:

1) Utilize the $define preprocessor directive in the source. (I prefer to load all my packages from source code stored in plaintext files outside of any worksheet.) For example,

$define OPFCN OriginalPackage:-Function

# alternatively
$define OP OriginalPackage
$define FCN Function

The second of those would be utilized by accessing OP:-FCN in the subsequent code.

At the end of the source file you can utilize the corresponding $undef directives.

2) Utilize the uses syntax at the start of the source for each procedure in the dependent (2nd) package. For example,

NewFunction := proc(x)
  local blah,blech;
  uses OP=OriginalPackage,
       OPFCN=OriginalPackage:-Function;

  blah := OP:-OtherFunction(x);
  blech := OPFCN(blah*x);
end proc;

If the whole equation is assigned to the name eqn , then how about,

collect( expand(lhs(eqn)), Rm, simplify ) = rhs(eqn);

Here are some ideas for reducing the size of the over expression, and one example of substituting names for common subexpressions.

restart;

A:=Matrix([[phi,conjugate(psi),chi,conjugate(rho)],
          [psi,-conjugate(phi),rho,-conjugate(chi)],
          [lambda1*phi,conjugate(lambda1)*conjugate(psi),
           lambda2*chi,conjugate(lambda2)*conjugate(rho)],
          [lambda1*psi,-conjugate(lambda1)*conjugate(phi),
           lambda2*rho,-conjugate(lambda2)*conjugate(chi)]]);

Matrix(4, 4, {(1, 1) = phi, (1, 2) = conjugate(psi), (1, 3) = chi, (1, 4) = conjugate(rho), (2, 1) = psi, (2, 2) = -conjugate(phi), (2, 3) = rho, (2, 4) = -conjugate(chi), (3, 1) = lambda1*phi, (3, 2) = conjugate(lambda1)*conjugate(psi), (3, 3) = lambda2*chi, (3, 4) = conjugate(lambda2)*conjugate(rho), (4, 1) = lambda1*psi, (4, 2) = -conjugate(lambda1)*conjugate(phi), (4, 3) = lambda2*rho, (4, 4) = -conjugate(lambda2)*conjugate(chi)})

d := LinearAlgebra:-Determinant(A):

d; length(%);

-conjugate(lambda2)*conjugate(chi)*conjugate(lambda1)*conjugate(psi)*chi*psi+conjugate(lambda2)*conjugate(chi)*conjugate(lambda1)*conjugate(psi)*phi*rho+conjugate(lambda2)*conjugate(chi)*conjugate(psi)*chi*lambda2*psi-conjugate(lambda2)*conjugate(chi)*conjugate(psi)*lambda1*phi*rho-conjugate(lambda2)*conjugate(chi)*conjugate(phi)*chi*lambda1*phi+conjugate(lambda2)*conjugate(chi)*conjugate(phi)*chi*lambda2*phi+conjugate(lambda2)*conjugate(rho)*conjugate(lambda1)*conjugate(phi)*chi*psi-conjugate(lambda2)*conjugate(rho)*conjugate(lambda1)*conjugate(phi)*phi*rho-conjugate(lambda2)*conjugate(rho)*conjugate(psi)*lambda1*psi*rho+conjugate(lambda2)*conjugate(rho)*conjugate(psi)*lambda2*psi*rho-conjugate(lambda2)*conjugate(rho)*conjugate(phi)*chi*lambda1*psi+conjugate(lambda2)*conjugate(rho)*conjugate(phi)*lambda2*phi*rho+conjugate(chi)*conjugate(lambda1)*conjugate(psi)*chi*lambda1*psi-conjugate(chi)*conjugate(lambda1)*conjugate(psi)*lambda2*phi*rho+conjugate(chi)*conjugate(lambda1)*conjugate(phi)*chi*lambda1*phi-conjugate(chi)*conjugate(lambda1)*conjugate(phi)*chi*lambda2*phi-conjugate(chi)*conjugate(psi)*chi*lambda1*lambda2*psi+conjugate(chi)*conjugate(psi)*lambda1*lambda2*phi*rho+conjugate(rho)*conjugate(lambda1)*conjugate(psi)*lambda1*psi*rho-conjugate(rho)*conjugate(lambda1)*conjugate(psi)*lambda2*psi*rho-conjugate(rho)*conjugate(lambda1)*conjugate(phi)*chi*lambda2*psi+conjugate(rho)*conjugate(lambda1)*conjugate(phi)*lambda1*phi*rho+conjugate(rho)*conjugate(phi)*chi*lambda1*lambda2*psi-conjugate(rho)*conjugate(phi)*lambda1*lambda2*phi*rho

2161

simplify(d,size); length(%);

((conjugate(rho)*conjugate(phi)-conjugate(psi)*conjugate(chi))*(chi*psi-phi*rho)*conjugate(lambda2)+(chi*phi*(lambda1-lambda2)*conjugate(phi)+conjugate(psi)*(chi*lambda1*psi-lambda2*phi*rho))*conjugate(chi)-conjugate(rho)*((chi*lambda2*psi-lambda1*phi*rho)*conjugate(phi)-psi*rho*conjugate(psi)*(lambda1-lambda2)))*conjugate(lambda1)+((-chi*phi*(lambda1-lambda2)*conjugate(phi)+conjugate(psi)*(chi*lambda2*psi-lambda1*phi*rho))*conjugate(chi)-conjugate(rho)*((chi*lambda1*psi-lambda2*phi*rho)*conjugate(phi)+psi*rho*conjugate(psi)*(lambda1-lambda2)))*conjugate(lambda2)+lambda1*lambda2*(conjugate(rho)*conjugate(phi)-conjugate(psi)*conjugate(chi))*(chi*psi-phi*rho)

1045

collect(d,[rho,chi],u->simplify(u,size)); length(%);

((psi*(lambda1-lambda2)*(conjugate(lambda1)-conjugate(lambda2))*conjugate(rho)+phi*conjugate(chi)*(conjugate(lambda2)-lambda2)*(conjugate(lambda1)-lambda1))*conjugate(psi)-conjugate(rho)*phi*conjugate(phi)*(conjugate(lambda2)-lambda1)*(conjugate(lambda1)-lambda2))*rho+((phi*(lambda1-lambda2)*(conjugate(lambda1)-conjugate(lambda2))*conjugate(phi)-psi*conjugate(psi)*(conjugate(lambda2)-lambda1)*(conjugate(lambda1)-lambda2))*conjugate(chi)+conjugate(rho)*psi*conjugate(phi)*(conjugate(lambda2)-lambda2)*(conjugate(lambda1)-lambda1))*chi

761

collect(d,[psi,phi],u->simplify(u,size)); length(%);

((rho*(lambda1-lambda2)*(conjugate(lambda1)-conjugate(lambda2))*conjugate(rho)-chi*conjugate(chi)*(conjugate(lambda2)-lambda1)*(conjugate(lambda1)-lambda2))*conjugate(psi)+chi*conjugate(rho)*conjugate(phi)*(conjugate(lambda2)-lambda2)*(conjugate(lambda1)-lambda1))*psi+((chi*(lambda1-lambda2)*(conjugate(lambda1)-conjugate(lambda2))*conjugate(phi)+rho*conjugate(psi)*(conjugate(lambda2)-lambda2)*(conjugate(lambda1)-lambda1))*conjugate(chi)-conjugate(rho)*rho*conjugate(phi)*(conjugate(lambda2)-lambda1)*(conjugate(lambda1)-lambda2))*phi

761

collect(d,[lambda1,lambda2],u->map(factor,simplify(u,size))); length(%);

(-(conjugate(psi)*conjugate(chi)-conjugate(rho)*conjugate(phi))*(chi*psi-phi*rho)*lambda2+(phi*conjugate(phi)+psi*conjugate(psi))*(chi*conjugate(chi)+conjugate(rho)*rho)*conjugate(lambda1)-conjugate(lambda2)*(conjugate(rho)*psi+phi*conjugate(chi))*(chi*conjugate(phi)+rho*conjugate(psi)))*lambda1+(-(conjugate(rho)*psi+phi*conjugate(chi))*(chi*conjugate(phi)+rho*conjugate(psi))*conjugate(lambda1)+conjugate(lambda2)*(phi*conjugate(phi)+psi*conjugate(psi))*(chi*conjugate(chi)+conjugate(rho)*rho))*lambda2+conjugate(lambda2)*conjugate(lambda1)*(conjugate(rho)*conjugate(phi)-conjugate(psi)*conjugate(chi))*(chi*psi-phi*rho)

983

R1:=abs(lambda1)^2+abs(lambda2)^2-conjugate(lambda2)*lambda1-conjugate(lambda1)*lambda2=K1:
R2:=abs(lambda1)^2+abs(lambda2)^2-conjugate(lambda2)*conjugate(lambda1)-lambda1*lambda2=K2:
R3:=conjugate(psi)*phi*rho*conjugate(chi)=K3:
R4:=chi*conjugate(phi)*conjugate(rho)*psi=conjugate(K3):
temp := simplify(collect(d,[rho,chi],u->simplify(u,size))):
new := simplify(subs([R1,R2,R3,R4],temp),size);
(rhs=lhs)(R1);
(rhs=lhs)(R2);
(rhs=lhs)(R3);

-4*Im(lambda1)*Im(lambda2)*(conjugate(K3)+K3)+(K1*abs(phi)^2+abs(psi)^2*K2)*abs(chi)^2+abs(rho)^2*(K1*abs(psi)^2+K2*abs(phi)^2)

K1 = abs(lambda1)^2+abs(lambda2)^2-conjugate(lambda2)*lambda1-conjugate(lambda1)*lambda2

K2 = abs(lambda1)^2+abs(lambda2)^2-conjugate(lambda2)*conjugate(lambda1)-lambda1*lambda2

K3 = conjugate(chi)*conjugate(psi)*phi*rho

# check
subs([(rhs=lhs)(R1),(rhs=lhs)(R2),(rhs=lhs)(R3)], new):
combine(simplify(eval(simplify((% - d)),
                      [lambda1=Re(lambda1)+I*Im(lambda1),
                       lambda2=Re(lambda2)+I*Im(lambda2)])));

0

 

Download some_simp.mw

First 174 175 176 177 178 179 180 Last Page 176 of 340