acer

32587 Reputation

29 Badges

20 years, 36 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

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

In my Maple 2018.1 the integral of dex for t=0..phi2 can be done symbolically, under assumptions consisting of the bounds of the outer variables' ranges of integration. This leads to a triple integral that can be done quickly and accurately, numerically, without need to specify a particular method.

restart;

with(LinearAlgebra):

r1 := Vector([0, 0, 1]):

r2 := Vector([sin(theta1), 0, cos(theta1)]):

r3 := Vector([sin(theta2)*cos(phi2), sin(theta2)*sin(phi2), cos(theta2)]):

M := Matrix([r1, r2, r3]);

Matrix(3, 3, {(1, 1) = 0, (1, 2) = sin(theta1), (1, 3) = sin(theta2)*cos(phi2), (2, 1) = 0, (2, 2) = 0, (2, 3) = sin(theta2)*sin(phi2), (3, 1) = 1, (3, 2) = cos(theta1), (3, 3) = cos(theta2)})

ex := simplify(Determinant(M)/(1+DotProduct(r1,r2)+DotProduct(r1,r3)+DotProduct(r2,r3)))
      assuming theta1 > 0, theta2 > 0, phi2 > 0;

sin(theta1)*sin(theta2)*sin(phi2)/((cos(theta1)+1)*cos(theta2)+sin(theta1)*sin(theta2)*cos(phi2)+cos(theta1)+1)

dex := eval(simplify(diff(arctan(ex), phi2)), phi2 = t);

(1/2)*sin(theta1)*((cos(theta2)+1)*(cos(theta1)+1)*cos(t)+sin(theta2)*sin(theta1))*sin(theta2)/((cos(theta2)+1)*(cos(theta1)+1)*(sin(theta1)*sin(theta2)*cos(t)+cos(theta2)*cos(theta1)+1))

Q := simplify(int(dex, t = 0 .. phi2))
       assuming theta1 > 0, theta1 < Pi, theta2 > 0, theta2 < Pi, phi2 > 0, phi2<Pi;

(1/2)*phi2-arctan((cos(theta2)*cos(theta1)-sin(theta2)*sin(theta1)+1)*sin((1/2)*phi2)/(cos((1/2)*phi2)*abs(cos(theta2)+cos(theta1))))*signum(cos(theta2)+cos(theta1))

Tother := 2*Int( 2*Q/(4*Pi) * 2*Pi*sin(theta1)*sin(theta2)/(4*Pi*4*Pi),
                 [phi2 = 0 .. Pi, theta2 = 0 .. Pi, theta1 = 0 .. Pi] );

2*(Int((1/16)*((1/2)*phi2-arctan((cos(theta2)*cos(theta1)-sin(theta2)*sin(theta1)+1)*sin((1/2)*phi2)/(cos((1/2)*phi2)*abs(cos(theta2)+cos(theta1))))*signum(cos(theta2)+cos(theta1)))*sin(theta1)*sin(theta2)/Pi^2, [phi2 = 0 .. Pi, theta2 = 0 .. Pi, theta1 = 0 .. Pi]))

alt := simplify(combine(Tother));

Int(-(1/32)*(cos(-theta2+theta1)-cos(theta2+theta1))*(2*arctan((1/2)*(sin((1/2)*phi2+theta2+theta1)+sin((1/2)*phi2-theta2-theta1)+2*sin((1/2)*phi2))/(abs(cos(theta2)+cos(theta1))*cos((1/2)*phi2)))*signum(cos(theta2)+cos(theta1))-phi2)/Pi^2, [phi2 = 0 .. Pi, theta2 = 0 .. Pi, theta1 = 0 .. Pi])

evalf(alt);  # no special method specified

.1250000000

T := 2*Int( 2*Int(dex, t = 0 .. phi2)/(4*Pi) * 2*Pi*sin(theta1)*sin(theta2)/(4*Pi*4*Pi),
              [phi2 = 0 .. Pi, theta2 = 0 .. Pi, theta1 = 0 .. Pi] );

2*(Int((1/16)*(Int((1/2)*sin(theta1)*((cos(theta2)+1)*(cos(theta1)+1)*cos(t)+sin(theta2)*sin(theta1))*sin(theta2)/((cos(theta2)+1)*(cos(theta1)+1)*(sin(theta1)*sin(theta2)*cos(t)+cos(theta2)*cos(theta1)+1)), t = 0 .. phi2))*sin(theta1)*sin(theta2)/Pi^2, [phi2 = 0 .. Pi, theta2 = 0 .. Pi, theta1 = 0 .. Pi]))

# vv's idea
new := IntegrationTools:-Change(T, t=s*phi2, [s]):
new := simplify(IntegrationTools:-CollapseNested(frontend(combine,[%],[{`+`,`*`,specfunc(Int)},{}])));

Int((1/16)*sin(theta2)^2*phi2*((cos(theta2)+1)*(cos(theta1)+1)*cos(s*phi2)+sin(theta2)*sin(theta1))*sin(theta1)^2/((cos(theta2)+1)*(cos(theta1)+1)*Pi^2*(sin(theta1)*sin(theta2)*cos(s*phi2)+cos(theta2)*cos(theta1)+1)), [s = 0 .. 1, phi2 = 0 .. Pi, theta2 = 0 .. Pi, theta1 = 0 .. Pi])

subsindets(new,specfunc(Int),u->Int(op(u),method = _CubaCuhre, epsilon = 1e-5)):
evalf(%);

HFloat(0.12500056725173295)

 

Download multi_int.mw

 

Do you mean something like this?

g := expand( (x+1)*(x-2) )/(x-2);

                    2
                   x  - x - 2
              g := ----------
                     x - 2

discont(g,x);

                    {2}
restart;
sys:={x^2+y^2+z^2=4,x^2+y^2-z^2=4,x+y+z=0}:

solve(sys, explicit, allsolutions);

               1/2       1/2                1/2        1/2
        {x = -2   , y = 2   , z = 0}, {x = 2   , y = -2   , z = 0}

fsolve(sys,{x,y,z=0},{x=0..infinity});

              {x = 1.414213562, y = -1.414213562, z = 0.}

fsolve(sys,{x,y,z=0},{y=0..infinity});

              {x = -1.414213562, y = 1.414213562, z = 0.}


restart;
sys:={x^2+y^2+z^2=4,x^2+y^2-z^2=4,x+y+z=0}:

Digits:=18:
fsolve(sys,{x,y,z});

                                                                                 -13
  {x = 1.41421356237308740, y = -1.41421356237310269, z = 0.152880100390764231 10   }


restart;
sys:={x^2+y^2+z^2=4,x^2+y^2-z^2=4,x+y+z=0}:

fsolve( map(unapply,map(rhs-lhs,sys),[x,y,z]) );

                                                                   -9
   [-1.4142135624826409, 1.4142135622635492, 0.21909169874140413 10  ]

It's unfortunate that there are so many variations for which fsolve fails on this example. It ought to be made more robust. Often it almost gets there, but stops too early. It's a long-standing problem that the working precision and stopping criteria cannot be specified.

restart:
sys:={x^2+y^2+z^2=4,x^2+y^2-z^2=4,x+y+z=0}:
infolevel[fsolve]:=6:
fsolve(sys);

Another numeric approach,

restart;
sys:={x^2+y^2+z^2=4,x^2+y^2-z^2=4,x+y+z=0}:

Optimization:-Minimize(x,sys)[2];

    [x = -1.41422084007315, y = 1.41420628467304, z = 0.0000145554001009322]

eval(map((lhs-rhs),sys),%);

                          -9                       -16                      -9
    {-0.105929931493165 10  , -0.473626942786715 10   , 0.317789794479495 10  }

Digits:=20:
Optimization:-Minimize(x,sys,feasibilitytolerance=1e-13)[2];
                                                                                        -6
    [x = -1.4142136550635758637, y = 1.4142134696826142339, z = 0.18538096162967075298 10  ]

eval(map((lhs-rhs),sys),%);

                      -13                -18             -13
         {-0.171831 10   , -0.12924702 10   , 0.515491 10   }

 

restart;

 

`print/%maximize`:=proc(expr::algebraic,
                        u::name=range)
  local rng;
  uses T=Typesetting;
  if interface(':-prettyprint')<2 then
    return %maximize(args);
  end if;
  rng := lhs(u) in [rhs(u)];
  # "#000000" is black
  T:-mrow(T:-munder(T:-mo("max",':-mathcolor'="#606060"),
                    T:-Typeset(T:-EV(rng))),
          T:-mspace(':-width'="0.3em"),
          T:-Typeset(T:-EV(expr)));
end proc:

`print/%minimize`:=subs(["max"="min",
                         ':-%maximize'=':-%minimize'],
                        eval(`print/%maximize`)):

 

%maximize(f(x), x=2..3);

%maximize(f(x), x = 2 .. 3)

value(%);

maximize(f(x), x = 2 .. 3)

%maximize((2*x-3)/(x-2), x=2..3);

%maximize((2*x-3)/(x-2), x = 2 .. 3)

value(%);

infinity

%minimize((2*x-3)/(x-2), x=2..3);

%minimize((2*x-3)/(x-2), x = 2 .. 3)

value(%);

3

%maximize((2*x-3)/(x-2), x=2..3, location);

%maximize((2*x-3)/(x-2), x = 2 .. 3, location)

value(%);

infinity, {[{x = 2}, infinity]}

 

Download max_typeset_edited.mw

[edited with Carl's suggestions]

It's not clear to me what you are asking for. Is it something like this?

limit( (2*x-3)/(x-2), x=2, right );

                infinity

maximize( (2*x-3)/(x-2), x=2..3 );

                infinity

maximize( (2*x-3)/(x-2), x=2..3, location );

         infinity, {[{x = 2}, infinity]}

It's SetProperty not setProperty .

PolarPlotB_a.mw

First 173 174 175 176 177 178 179 Last Page 175 of 338