acer

32373 Reputation

29 Badges

19 years, 333 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

To prevent  -2*x-3*x from automatically simplifying to -5*x, etc, you can use an inert form.

Here, the inert form only needs to retain inert `%+`.

You can also force the visual display to have + in the usual black, instead of the gray that denotes the inert operator.

restart;

with(InertForm):

p := x^2 - a*x - b*x +a*b ;

a*b-a*x-b*x+x^2

L := [[2,3],[-3,7],[9,10]];

[[2, 3], [-3, 7], [9, 10]]

inexpr := eval(MakeInert(sort(p,x)),[`%^`=`^`,`%*`=`*`]);

`%+`(x^2, -a*x, -b*x, a*b)

temp := eval~(inexpr,map[2](Equate,[a,b],L))

[`%+`(x^2, -2*x, -3*x, 6), `%+`(x^2, 3*x, -7*x, -21), `%+`(x^2, -9*x, -10*x, 90)]

Display~(temp, inert=false);

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

value(temp);

[x^2-5*x+6, x^2-4*x-21, x^2-19*x+90]

Download inert_ex2.mw

If you add
   option remember;
to FirmModelFC and FirmModelPP then it won't waste as much time in duplicate computations, generating both the 3rd and 4th items of their returned expression sequences.

Also, you can guard against premature evaluation by having diffr1 and diffr2 return unevaluated when passed mere symbolic names (not yet numbers) as its arguments. That allows you to use the expression form calling sequence of plots:-inequal, as opposed to operator form calling sequence.

I removed the commented stuff, just to make it more legible to me.

I changed the range for delta to 0..1/2, since I myself didn't see too much of great interest for delta>1/2. Change that back if wanted, of course.

restart

with(plots)

``

c := 1; cr := 0.3e-1*c; u := 1; sExp := 0.6e-1*c; s := .65*c; v := 3*c

``

FirmModelPP := proc (alpha, delta) local p0, xi0, q0, Firmpf0, G0, Recpf0, Unsold0, Environ0; option remember; xi0 := 1; p0 := min(s+sqrt((v-s)*(c-s)), delta*v+sExp); q0 := u*(v-p0)/(v-s); f(N) := 1/u; F(N) := N/u; G0 := int(F(N), N = 0 .. q0); Firmpf0 := (p0-c)*q0-(p0-s)*G0; Recpf0 := (sExp-cr)*xi0*q0; Environ0 := q0+G0; Unsold0 := G0; return p0, q0, Firmpf0, Recpf0, Unsold0, Environ0 end proc

``

FirmModelFC := proc (alpha, beta, delta) local p00, xi00, q00, Firmpf00, G00, Recpf00, Unsold00, Environ00, pr00; option remember; xi00 := 1; p00 := s+sqrt((v-s)*(c-s)); if p00 < delta*v+sExp then q00 := u*(v-p00)/(v-s); f(N) := 1/u; F(N) := N/u; G00 := int(F(N), N = 0 .. q00); Firmpf00 := (p00-c)*q00-(p00-s)*G00; Recpf00 := `&xi;00*q00*`(sExp-cr); Unsold00 := G00; Environ00 := q00+Unsold00 else q00 := alpha*u*(v-p00)/(v-s); f(N) := 1/u; F(N) := N/u; G00 := int(F(N), N = 0 .. q00/alpha); pr00 := p00-delta*v; Firmpf00 := (p00-c)*q00-alpha*(p00-s)*G00; Recpf00 := (beta*(pr00-sExp)+sExp-cr)*xi00*q00-(1/2)*(pr00-sExp)*beta^2*xi00^2*q00^2/(u*(1-alpha)); Unsold00 := G00; Environ00 := q00+Unsold00 end if; return p00, q00, Firmpf00, Recpf00, Unsold00, Environ00 end proc

``

diffr1 := proc (alpha, delta) if not [alpha, delta]::(list(numeric)) then return ('procname')(args) end if; FirmModelPP(alpha, delta)[3]-FirmModelFC(alpha, .2, delta)[3] end proc

diffr2 := proc (alpha, delta) if not [alpha, delta]::(list(numeric)) then return ('procname')(args) end if; FirmModelPP(alpha, delta)[4]-FirmModelFC(alpha, .2, delta)[4] end proc

 

P1 := implicitplot(diffr1, 0 .. 1, 0 .. 1/2, color = black, thickness = 2)

NULL

P2 := implicitplot(diffr2, 0 .. 1, 0 .. 1/2, color = black, thickness = 2)

P3 := inequal({diffr1(alpha, delta) < 0, diffr2(alpha, delta) < 0}, alpha = 0 .. 1, delta = 0 .. 1/2, color = red)

NULL

P4 := inequal({diffr2(alpha, delta) > 0, diffr1(alpha, delta) < 0}, alpha = 0 .. 1, delta = 0 .. 1/2, color = yellow)

NULL

P5 := inequal({diffr1(alpha, delta) > 0, diffr2(alpha, delta) < 0}, alpha = 0 .. 1, delta = 0 .. 1/2, color = green)

NULL

P6 := inequal({diffr1(alpha, delta) > 0, diffr2(alpha, delta) > 0}, alpha = 0 .. 1, delta = 0 .. 1/2, color = "LightBlue")

NULL

display(P1, P2, P3, P4, P5, P6, scaling = constrained)

NULL

Download Code_JN_major_ac.mw

I didn't bother rewriting FirmModelPP and FirmModelAC altogether (eg. making evalhf'able counterparts, resolving the integration steps, etc). I suspect it could be faster still...

You appear to have used Maple 2021, and in that version the above all executed in about 9 seconds on my machine.

Do you mean something like the following?

I also added some sorting of the terms in the generated results, which I think makes the effect clearer.

note: Your given example might be handled by dealing merely with the second index j of the y[i,j] names. And the highest index accepted happens to match your example N values. But I deliberately put in the test of the first index, as well as sorting by the second index, so that it'd also handle a more general example (as you described it in words).

restart;

expr := r*y[0, 1]+y[0, 0]+(1/6)*r*(r-1)*(1+r)*y[-1, 3]+(1/2)*r*(r-1)*y[-1, 2]+(1/120)*r*(r-1)*(r-2)*(1+r)*(2+r)*y[-2, 5]+(1/24)*r*(r-1)*(r-2)*(1+r)*y[-2, 4]+(1/720)*r*(r-1)*(r-2)*(r-3)*(r-4)*(1+r)*y[-3, 8]+(1/360)*r*(r-1)^2*(r-2)*(r-3)*(1+r)*y[-3, 7]+(1/720)*r*(r-1)*(r-2)*(r-3)*(1+r)*(2+r)*y[-3, 6];

r*y[0, 1]+y[0, 0]+(1/6)*r*(r-1)*(1+r)*y[-1, 3]+(1/2)*r*(r-1)*y[-1, 2]+(1/120)*r*(r-1)*(r-2)*(1+r)*(2+r)*y[-2, 5]+(1/24)*r*(r-1)*(r-2)*(1+r)*y[-2, 4]+(1/720)*r*(r-1)*(r-2)*(r-3)*(r-4)*(1+r)*y[-3, 8]+(1/360)*r*(r-1)^2*(r-2)*(r-3)*(1+r)*y[-3, 7]+(1/720)*r*(r-1)*(r-2)*(r-3)*(1+r)*(2+r)*y[-3, 6]

 

T := proc(a,b)
       local anm:=indets(a,specindex(integer,y))[1],
             bnm:=indets(b,specindex(integer,y))[1];
       if op(1,anm)>op(1,bnm) then true;
       elif op(2,anm)<op(2,bnm) then true;
       else false; end if;
     end proc:

L := sort([op(expr)],T):

U := sort([indets(expr,specindex(integer,y))[]],T):

P := proc(n::nonnegint) local i;
       sort(add(L[i],i=1..n+1),order=plex(U[]));
     end proc:

 

P(0);

y[0, 0]

P(1);

y[0, 0]+r*y[0, 1]

P(2);

y[0, 0]+r*y[0, 1]+(1/2)*r*(r-1)*y[-1, 2]

P(3);

y[0, 0]+r*y[0, 1]+(1/2)*r*(r-1)*y[-1, 2]+(1/6)*r*(r-1)*(1+r)*y[-1, 3]

P(4);

y[0, 0]+r*y[0, 1]+(1/2)*r*(r-1)*y[-1, 2]+(1/6)*r*(r-1)*(1+r)*y[-1, 3]+(1/24)*r*(r-1)*(r-2)*(1+r)*y[-2, 4]

P(5);

y[0, 0]+r*y[0, 1]+(1/2)*r*(r-1)*y[-1, 2]+(1/6)*r*(r-1)*(1+r)*y[-1, 3]+(1/24)*r*(r-1)*(r-2)*(1+r)*y[-2, 4]+(1/120)*r*(r-1)*(r-2)*(1+r)*(2+r)*y[-2, 5]

P(6);

y[0, 0]+r*y[0, 1]+(1/2)*r*(r-1)*y[-1, 2]+(1/6)*r*(r-1)*(1+r)*y[-1, 3]+(1/24)*r*(r-1)*(r-2)*(1+r)*y[-2, 4]+(1/120)*r*(r-1)*(r-2)*(1+r)*(2+r)*y[-2, 5]+(1/720)*r*(r-1)*(r-2)*(r-3)*(1+r)*(2+r)*y[-3, 6]

P(7);

y[0, 0]+r*y[0, 1]+(1/2)*r*(r-1)*y[-1, 2]+(1/6)*r*(r-1)*(1+r)*y[-1, 3]+(1/24)*r*(r-1)*(r-2)*(1+r)*y[-2, 4]+(1/120)*r*(r-1)*(r-2)*(1+r)*(2+r)*y[-2, 5]+(1/720)*r*(r-1)*(r-2)*(r-3)*(1+r)*(2+r)*y[-3, 6]+(1/360)*r*(r-1)^2*(r-2)*(r-3)*(1+r)*y[-3, 7]

P(8);

y[0, 0]+r*y[0, 1]+(1/2)*r*(r-1)*y[-1, 2]+(1/6)*r*(r-1)*(1+r)*y[-1, 3]+(1/24)*r*(r-1)*(r-2)*(1+r)*y[-2, 4]+(1/120)*r*(r-1)*(r-2)*(1+r)*(2+r)*y[-2, 5]+(1/720)*r*(r-1)*(r-2)*(r-3)*(1+r)*(2+r)*y[-3, 6]+(1/360)*r*(r-1)^2*(r-2)*(r-3)*(1+r)*y[-3, 7]+(1/720)*r*(r-1)*(r-2)*(r-3)*(r-4)*(1+r)*y[-3, 8]

 

Download sorty_thing.mw


Your given example could also be handled by the following simpler approach. But I think that the sorted effect is nicer. And if this is run in a separate session from the above code then the addends are not necessarily sorted so nicely (IMO), in each result.

expr := r*y[0, 1]+y[0, 0]+(1/6)*r*(r-1)*(1+r)*y[-1, 3]+(1/2)*r*(r-1)*y[-1, 2]+(1/120)*r*(r-1)*(r-2)*(1+r)*(2+r)*y[-2, 5]+(1/24)*r*(r-1)*(r-2)*(1+r)*y[-2, 4]+(1/720)*r*(r-1)*(r-2)*(r-3)*(r-4)*(1+r)*y[-3, 8]+(1/360)*r*(r-1)^2*(r-2)*(r-3)*(1+r)*y[-3, 7]+(1/720)*r*(r-1)*(r-2)*(r-3)*(1+r)*(2+r)*y[-3, 6];

r*y[0, 1]+y[0, 0]+(1/6)*r*(r-1)*(1+r)*y[-1, 3]+(1/2)*r*(r-1)*y[-1, 2]+(1/120)*r*(r-1)*(r-2)*(1+r)*(2+r)*y[-2, 5]+(1/24)*r*(r-1)*(r-2)*(1+r)*y[-2, 4]+(1/720)*r*(r-1)*(r-2)*(r-3)*(r-4)*(1+r)*y[-3, 8]+(1/360)*r*(r-1)^2*(r-2)*(r-3)*(1+r)*y[-3, 7]+(1/720)*r*(r-1)*(r-2)*(r-3)*(1+r)*(2+r)*y[-3, 6]

q := (n::nonnegint)->select(u->op(2,indets(u,indexed)[1])<=n,expr):

q(2);

r*y[0, 1]+y[0, 0]+(1/2)*r*(r-1)*y[-1, 2]

q(4);

r*y[0, 1]+y[0, 0]+(1/6)*r*(r-1)*(1+r)*y[-1, 3]+(1/2)*r*(r-1)*y[-1, 2]+(1/24)*r*(r-1)*(r-2)*(1+r)*y[-2, 4]

q(7);

r*y[0, 1]+y[0, 0]+(1/6)*r*(r-1)*(1+r)*y[-1, 3]+(1/2)*r*(r-1)*y[-1, 2]+(1/120)*r*(r-1)*(r-2)*(1+r)*(2+r)*y[-2, 5]+(1/24)*r*(r-1)*(r-2)*(1+r)*y[-2, 4]+(1/360)*r*(r-1)^2*(r-2)*(r-3)*(1+r)*y[-3, 7]+(1/720)*r*(r-1)*(r-2)*(r-3)*(1+r)*(2+r)*y[-3, 6]

Download sorty_thing2.mw

You could get it with calls to GAMMA instead of WhittakerM.

f := exp(-beta*x)*x^(5-alpha):

simplify(convert(int(f,x),GAMMA));

((beta*x)^alpha*x^(-alpha)*(alpha-5)*(alpha-1)*(alpha-2)*(alpha-3)*(alpha-4)*GAMMA(-alpha+1, beta*x)-exp(-beta*x)*beta*(alpha-5)*(alpha-2)*(alpha-3)*(alpha-4)*x^(-alpha+1)+exp(-beta*x)*beta^2*(alpha-5)*(alpha-3)*(alpha-4)*x^(-alpha+2)-exp(-beta*x)*beta^3*(alpha-4)*(alpha-5)*x^(-alpha+3)+exp(-beta*x)*beta^4*(alpha-5)*x^(-alpha+4)-x^(5-alpha)*exp(-beta*x)*beta^5+x^(-alpha)*(beta*x)^alpha*GAMMA(-alpha+6))/beta^6

Download Wh_ex.mw

You could further collect on, say, exp, GAMMA, beta, etc. But mostly that just rearranges those terms. You haven't said what exactly you mean by less "complicated".

You can use the so-called 2-argument calling sequence of the eval command, to evaluate the expression at specific values for names upon which it depends.

If you are already have the lists of values then you can do it all programmatically, instead of typing out all those individual equations. That'd let you do it more easily if you have further collections of values to use.

expr := (`&varepsilon;__1`*exp(`&zeta;__1`*phi)+`&varepsilon;__2`*exp(zeta__2*phi))/(`&varepsilon;__3`*exp(`&zeta;__3`*phi)+`&varepsilon;__4`*exp(`&zeta;__4`*phi))

eval(expr, [`&varepsilon;__1` = 1, `&varepsilon;__2` = 1, `&varepsilon;__3` = 1, `&varepsilon;__4` = 0, `&zeta;__1` = 0, `&zeta;__2` = 1, `&zeta;__3` = -2, `&zeta;__4` = 0])

(1+exp(phi))/exp(-2*phi)

vars1 := [`&varepsilon;__1`, `&varepsilon;__2`, `&varepsilon;__3`, `&varepsilon;__4`]; vars2 := [`&zeta;__1`, `&zeta;__2`, `&zeta;__3`, `&zeta;__4`]

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

eval(expr, [Equate(vars1, L1)[], Equate(vars2, L2)[]])

(1+exp(phi))/exp(-2*phi)

Download eval_ex_1.mw

note. You could also construct a reusable procedure to do the substitutions, by using unapply on the expression (w.r.t. all those names). That doesn't really seem better to me, especially if you're only going to use it once.

expr := (`&varepsilon;__1`*exp(`&zeta;__1`*phi)+`&varepsilon;__2`*exp(zeta__2*phi))/(`&varepsilon;__3`*exp(`&zeta;__3`*phi)+`&varepsilon;__4`*exp(`&zeta;__4`*phi))

F := unapply(expr, `&varepsilon;__1`, `&varepsilon;__2`, `&varepsilon;__3`, `&varepsilon;__4`, `&zeta;__1`, `&zeta;__2`, `&zeta;__3`, `&zeta;__4`)

F(1, 1, 1, 0, 0, 1, -2, 0)

(1+exp(phi))/exp(-2*phi)

Download eval_ex_2.mw

Hopefully I haven't misunderstood all your goals.

I did the first attempt (with a finer resolution of points) in two ways: one like your original, and one more efficient that stops (for each X value) when it finds the first W value that succeeds.

At the end I also threw in some stuff with going straight for a curve (finding the first W value of equality, for the given range). And also a bit with some extended ranges. Might be useful; I'm not sure. I don't know what the end-point -1.7 might mean to you, as a restriction...

restart;

Digits:=15;

15

Lambda[0]:=2/(1*(5+3*w))

2/(5+3*w)

h:=1*a^(-3/2*(1+w))

a^(-3/2-(3/2)*w)

L:=simplify(int(1/h,a))

2*a^(5/2+(3/2)*w)/(5+3*w)

F:=1/(sqrt(2*Pi)*tau)*exp(-(lambda-Lambda[0])^2/(2*tau^2))

(1/2)*2^(1/2)*exp(-(1/2)*(lambda-2/(5+3*w))^2/tau^2)/(Pi^(1/2)*tau)

F2:=simplify(subs(lambda=L,F)*diff(h,a)*1/a)

-(3/4)*a^(-7/2-(3/2)*w)*2^(1/2)*(1+w)*exp(-2*(a^(5/2+(3/2)*w)-1)^2/((5+3*w)^2*tau^2))/(tau*Pi^(1/2))

F3:=isolate(Lambda[0]-tau=subs(a=A,L),tau)

tau = -2*A^(5/2+(3/2)*w)/(5+3*w)+2/(5+3*w)

F4:=Int(simplify(combine(subs(F3,F2))),a=0.01..10,method=_d01ajc)
     assuming A>0.5, A<1, a>0.01, a<10, w>-1.7, w<-1;

Int((3/8)*a^(-7/2-(3/2)*w)*2^(1/2)*(1+w)*exp(-(1/2)*(a^(5/2+(3/2)*w)-1)^2/(A^(5/2+(3/2)*w)-1)^2)*(5+3*w)/(Pi^(1/2)*(A^(5/2+(3/2)*w)-1)), a = 0.1e-1 .. 10, method = _d01ajc)

valid:= proc(n,b,w,A)
if n<b then #print("ok, n,b",n,b,w,A);
return true:
else
return false
end if:
end proc:

X:=[seq(A,A=0.5..0.99,0.01)]:

nops(X)

50

W:=[seq(w,w=-1.7..-1,0.01)]:

nops(W);

71

forget(evalf); forget(`evalf/int`):
st:=time[real]():
S1:=[seq(ListTools:-Search(true,[seq(valid(evalf(F4),1/(8*rhs(F3)^2),w,A),
                                                       w=W)]),
                           A=X)]:
S1:=eval(S1,0=NULL);
time[real]()-st;

[68, 68, 68, 67, 66, 65, 63, 57, 46, 41, 38, 35, 32, 29, 26, 23, 20, 17, 13, 10, 6, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

2.873

forget(evalf); forget(`evalf/int`):
st:=time[real]():
T := 'T':
for ii from 1 to nops(X) do
  for jj from 1 to nops(W) do
    #print(ii,jj,W[jj],X[ii]);
    if evalf(eval(F4<1/(8*rhs(F3)^2),[w=W[jj],A=X[ii]])) then
      T[ii] := jj;
      #print([X[ii],W[jj]]);
      # value found for this A, bail out of the inner loop
      jj:=nops(W); next;
    end if;
  end do;
end do;
S1alt:=convert(T,list);
time[real]()-st;

[68, 68, 68, 67, 66, 65, 63, 57, 46, 41, 38, 35, 32, 29, 26, 23, 20, 17, 13, 10, 6, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

.887

Y1:=[seq(W[S1[i]],i=1..nops(S1))]:

P1:=plots:-pointplot([X,Y1],view=[0.5..1,-2..0],style=pointline,
              symbol=solidcircle,symbolsize=10,color=red,size=[500,300])

Y1alt:=[seq(W[S1alt[i]],i=1..nops(S1alt))]:

P1:=plots:-pointplot([X,Y1alt],view=[0.5..1,-2..0],style=pointline,
              symbol=solidcircle,symbolsize=10,color=red,size=[500,300])

Digits:=10:
plots:-display(
  plot(-1.7,0.5..1,linestyle=dot,color=gray),
plot(Xval->RootFinding:-NextZero(unapply('Re@evalf'(eval(-F4+1/(8*rhs(F3)^2),A=Xval)),w),-2.7,
                                 maxdistance=2.7,guardDigits=1, signchange=false, abstol=1e-5),
     0.5 .. 0.8, adaptive=true, view=[0.5..1,-2..0], size=[500,300])
);

unapply('evalf'(eval(-F4+1/(8*rhs(F3)^2),A=0.95)),w):
plot([Re@%,Im@%],-5..-1, size=[500,300]);

 

Download NumericScale_ac.mw

By "Gauss-Jordan form" do you mean reduced row echelon form, as produced by Gauss-Jordan elimination?

If so, then consider computing the r.r.e.f. of the Matrix augmented by the identity-matrix. The row operations that take the Matrix to its r.r.e.f. would then also be done to the identity matrix.

Below, if B the r.r.e.f. of M turns out to be the identity-matrix, then A (the result of the same row operations, but done to the identity matrix) is the inverse of M.

See also the subsection "Finding the inverse of a matrix" of this page on Gaussian elimination.

restart;
randomize():
with(LinearAlgebra):

n := 3:
M := RandomMatrix(n,generator=-3..3);

Matrix(3, 3, {(1, 1) = -2, (1, 2) = -1, (1, 3) = 1, (2, 1) = -1, (2, 2) = -3, (2, 3) = 1, (3, 1) = -3, (3, 2) = -3, (3, 3) = -3})

(B,A):=(a->(a[..,..n],
            a[..,n+1..]))(ReducedRowEchelonForm(<M|IdentityMatrix(n)>));

B, A := Matrix(3, 3, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 1, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1}), Matrix(3, 3, {(1, 1) = -1/2, (1, 2) = 1/4, (1, 3) = -1/12, (2, 1) = 1/4, (2, 2) = -3/8, (2, 3) = -1/24, (3, 1) = 1/4, (3, 2) = 1/8, (3, 3) = -5/24})

A.M - B;

Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0})

M^(-1);

Matrix(3, 3, {(1, 1) = -1/2, (1, 2) = 1/4, (1, 3) = -1/12, (2, 1) = 1/4, (2, 2) = -3/8, (2, 3) = -1/24, (3, 1) = 1/4, (3, 2) = 1/8, (3, 3) = -5/24})

M := RandomMatrix(n,generator=-3..3);

Matrix(3, 3, {(1, 1) = -3, (1, 2) = -1, (1, 3) = 1, (2, 1) = 0, (2, 2) = -2, (2, 3) = -1, (3, 1) = -1, (3, 2) = 1, (3, 3) = 1})

(B,A):=(a->(a[..,..n],
            a[..,n+1..]))(ReducedRowEchelonForm(<M|IdentityMatrix(n)>));

B, A := Matrix(3, 3, {(1, 1) = 1, (1, 2) = 0, (1, 3) = -1/2, (2, 1) = 0, (2, 2) = 1, (2, 3) = 1/2, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0}), Matrix(3, 3, {(1, 1) = 0, (1, 2) = -1/2, (1, 3) = -1, (2, 1) = 0, (2, 2) = -1/2, (2, 3) = 0, (3, 1) = 1, (3, 2) = -2, (3, 3) = -3})

A.M - B;

Matrix(3, 3, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0})

M^(-1);

Error, (in rtable/Power) singular matrix

Download some_la.mw

For the case of a plot output you could select (mouse-pointer) and copy the manipulated plot, and then paste in a new exec-group (say), below. Then comment out the input line.

More generally, you could do the following:
  - ensure that the menubar's "View" has "Markers" toggled on.
  - use the left Marker-border to right-click and select the whole exec-group
  - use the left Marker-border to right-click and put an annotation on that exec-group (For me, this gives it a light purple background)
  - comment out the input line
This can be later undone by removing the annotation.

For me these effects side-step the menubar's "Remove Output from Worksheet", or !!! "Execute the entire worksheet".  See attached for example of each, made with Maple 2023.0.
anno_ex.mw

I believe that these are (mostly all) different students.

When I see the same question I delete it as a duplicate.

I believe that it could reduce this behavior if members stopped answering them separately.

restart;

kernelopts(version);

`Maple 2023.0, X86 64 LINUX, Mar 06 2023, Build ID 1689885`

z:=-a*exp(-I*b):

Phi:=simplify(evalc(argument(z)));

arctan(a*sin(b), -a*cos(b))

plot3d([Phi,-b], a=-7..7, b=-2*Pi..2*Pi,
       color=[blue,red], grid=[51,51], axis[3]=[tickmarks=piticks]);

simplify(evalc(argument(z))) assuming a<0, b>=-Pi, b<-Pi/2;

-b

simplify(evalc(argument(z))) assuming a<0, b>=-Pi/2, b<=Pi/2;

-b

simplify(evalc(argument(z))) assuming a<0, b>=Pi/2, b<Pi;

-b

Download arg_ex0.mw

Collapsing those conditions seems not so straightforward.

Are you hoping for an effect that looks something like this?

plots:-polarplot(tan(theta)*sec(theta), theta = 0 .. 2*Pi,
                 style=point, adaptive=false, numpoints=10^4,
                 axiscoordinates=cartesian,
                 view=[-100..100, 0..10^4])

Download pl1.mw

 

plots:-polarplot(tan(theta)*sec(theta), theta = 0 .. Pi,
                 axiscoordinates=cartesian,
                 view=[-100..100, 0..10^4])

Download pl2.mw

By changing the difference of the pair of sin&cos calls into a product we can give solve a helping hand.

Solving the product is, naturally, quite easy.

ee := trigsubs('cos'(3*x - Pi/12) - cos(2*x + Pi/7))

[-2*sin((5/2)*x+(5/168)*Pi)*sin((1/2)*x-(19/168)*Pi)]

solve(ee, allsolutions);
 

{x = (19/84)*Pi+2*Pi*_Z4}, {x = -(1/84)*Pi+(2/5)*Pi*_Z3}

Download sc_solve_2023_2.mw

 

Here's a more programmatic variant of that, but without having to manually enter a cos call within uneval quotes,

restart;

ee := cos(3*x - Pi/12) = cos(2*x + Pi/7):

ff := trigsubs( convert( (lhs-rhs)(ee), sin ) );

[2*cos((5/2)*x+(89/168)*Pi)*sin((1/2)*x-(19/168)*Pi)]

solve(ff, allsolutions);

{x = (19/84)*Pi+2*Pi*_Z2}, {x = -(1/84)*Pi+(2/5)*Pi*_Z1}

Download sc_solve_2023_3.mw


And here's something with another kind of intermediate conversion, but also with a result more readily understandable than your straight solve attempt (which is large, with RootOf's).

restart;

kernelopts(version);

`Maple 2023.0, X86 64 LINUX, Mar 06 2023, Build ID 1689885`

ee := cos(3*x - Pi/12) = cos(2*x + Pi/7);

sin(3*x+(5/12)*Pi) = cos(2*x+(1/7)*Pi)

simplify([solve(convert(ee,exp),allsolutions)]);

[Pi*(2*_Z2+19/84), Pi*(2*_Z1-1/84), Pi*(2*_Z1+163/420), Pi*(2*_Z1+331/420), Pi*(2*_Z1-341/420), Pi*(2*_Z1-173/420)]

Download sc_solve_2023_1.mw

 

I will submit a couple of bug reports about various weaknesses discovered here in solve and trigsubs. That is: the original unwieldy result from solve, and trigsubs not knowing how to handle some variants on the sum/difference forms.

It seems that the (SSL) certificate for this site had expired, preventing https access. (http access was still possible I think.)

It may have been fixed.

In your second question you are missing the multiplication between 10 and Unit(m/s).

As you have it, in 1D plaintext input,
  10Unit(m/s)
it is not valid Maple syntax.

In pretty-printed 2D Output the multiplication is represented implicitly by a space.

with(Units:-Simple)

solve((24.5*Unit('kPa')*250)*Unit('mL')/((8.3145*Unit('J'/('K'*'mol'))*292.5)*Unit('K')) = n)

0.2518512351e-2*Units:-Unit(mol)

NULL

0.1e-2*(24.5*Unit('kPa')*10^3*Unit('Pa'/'kPa')*250)*Unit('mL')*Unit('L'/'mL')*10^(-3)*Unit('m'^3/'L')/((8.3145*Unit('J'/('K'*'mol'))*292.5)*Unit('K'))

0.2518512351e-2*Units:-Unit(mol)

Why is there a difference between the two results above?

 

Second question: I use a shortcut when I want to write units (on my Mac it is CMD+Shift+u). I just found out while writing this worksheet that for Maple input the shortcut does produce something but executing a line where this was used generates an error as can be seen below.

 

10*Unit('m'/'s')

10*Units:-Unit(m/s)

10*Unit(m/s)

10*Units:-Unit(m/s)

 

NULL

Download Units_ac.mw

Performing simplify-with-side-relations does a kind of normal form operation in a polynomial sense.

It doesn't perform every other kind of simplify action. This is documented on the Help page with Topic simplify,details.

In that page's Options section it says,
  "Invokes only the simplification procedures specified by the additional names."
followed by a list of names. The word "siderels" is one of those names listed (and which is a cross-reference I gave at top). Yes, "siderels" itself is not an actual option name proper, but it's listed there since its relevent option names are governed by that same principle.

For example,

simplify(exp(2)*exp(4)-exp(6));

0

simplify(exp(2)*exp(4)-exp(6), {});

exp(2)*exp(4)-exp(6)

simplify(sin(x)^2+cos(x)^2-1);

0

simplify(sin(x)^2+cos(x)^2-1,{});

sin(x)^2+cos(x)^2-1

simplify(exp(2)*exp(4)-exp(6), trig);

exp(2)*exp(4)-exp(6)

simplify(sin(x)^2+cos(x)^2-1, exp);

sin(x)^2+cos(x)^2-1

Download simp_siderels_1.mw

First 39 40 41 42 43 44 45 Last Page 41 of 336