MaplePrimes Questions

For instance, here is a list of valid "rules" (given as equations): 

(* restart; *)
rules := [g = d, e = a, a = b, f = d, c = g, b = b, d = c, c = f, a = e]:

But these rules can be represented more compactly as a list of "cycles": 

cycles := [[g, d, c], [e, a], [f, d, c], [b]]:

Is there a efficient way to convert into ? 

Hey guys

I have a question using the piecewise function:

fa := unapply(piecewise(0 < x and x < a, k1, a < x and x < b, k2), x);

simplify(fa(x)) assuming 0 < a, 0 < x and x < a;

It should return k1, but it doesn't. Does anyone have a solution?

Sincerely,

Oliveira

Suppose I have a polynomial:

poly := x^6 - 3*x + 3

And I know one of its roots and its galois group:

firstroot := [solve](poly, x)[1]:
G := GaloisGroup(poly, x):

Since G act transitively on the all roots. How do I get all the other roots of this polynomial just by the firstroot and G, but not by solving the equation.

I would like to set a axis lable as  A (kg/m3)

where A is in italic style, (kg/m3) is in normal style

Is there documentation that tells about what the dollar sign means and how to manage it. It just appears in recent releases and it didn't used to in older releases. It is distracting and seems to appear randomly.

Thanks

I've been using Maple Flow for awhile and generally pleased with its performance...until today.

Going through my normal workflow, the sheet stopped evaluating and a little troubleshooting later it seems that the issue is that once I use a keyboard shortcut to include units, the sheet will not evaluate anything going forward. 

Once

I have to maximize my non linear objective function TBCI (given in attached worksheet) with 4 inequality constraints. The decision variables are i and q.The range of i is 0 to 1 and of q is 0 to 76.

When i tru to solve it using NLP solve it is showing error-"Error, (in Optimization:-NLPSolve) constraints must be specified as a set or list of equalities and inequalities".

Please help me to solve it. please find attached the maple file

restart

with(plots); with(DEtools); with(LinearAlgebra); with(Student[VectorCalculus]); with(linalg); with(Optimization); with(student)

TC := proc (Q) options operator, arrow; O1*(1-beta)*D/Q+(1/2)*h1*Q+(1/2)*h2*(gamma-beta)*Qr/gamma+O2*beta*D/Qr+r*beta*D-q*beta*D-P*(1-i)*beta*D end proc

proc (Q) options operator, arrow; Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(O1, Student:-VectorCalculus:-`+`(1, Student:-VectorCalculus:-`-`(beta))), Student:-VectorCalculus:-D), Q^Student:-VectorCalculus:-`-`(1)), Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(h1, Q), 2^Student:-VectorCalculus:-`-`(1))), Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(h2, Student:-VectorCalculus:-`+`(gamma, Student:-VectorCalculus:-`-`(beta))), Qr), Student:-VectorCalculus:-`*`(2, gamma)^Student:-VectorCalculus:-`-`(1))), Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(O2, beta), Student:-VectorCalculus:-D), Qr^Student:-VectorCalculus:-`-`(1))), Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(r, beta), Student:-VectorCalculus:-D)), Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(q, beta), Student:-VectorCalculus:-D))), Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(P, Student:-VectorCalculus:-`+`(1, Student:-VectorCalculus:-`-`(i))), beta), Student:-VectorCalculus:-D))) end proc

(1)

diff(TC(Q), Q)

-O1*(1-beta)*Student:-VectorCalculus:-D/Q^2+(1/2)*h1

(2)

simplify(isolate(%, Q))

Q = RootOf(2*Student:-VectorCalculus:-D*O1*beta+_Z^2*h1-2*Student:-VectorCalculus:-D*O1)

(3)

diff(TC(Q), Qr)

(1/2)*h2*(gamma-beta)/gamma-O2*beta*Student:-VectorCalculus:-D/Qr^2

(4)

simplify(isolate(%, Qr))

Qr = RootOf((beta*h2-gamma*h2)*_Z^2+2*gamma*O2*beta*Student:-VectorCalculus:-D)

(5)

diff(TC(Q), `$`(Q, 2))

2*O1*(1-beta)*Student:-VectorCalculus:-D/Q^3

(6)

diff(TC(Q), `$`(Qr, 2))

2*O2*beta*Student:-VectorCalculus:-D/Qr^3

(7)

TC1 := proc (Q, Qr) options operator, arrow; O1*(-beta*i+1)*D/Q+(1/2)*h1*Q+(1/2)*h2*(-beta*i+gamma)*Qr/gamma+O2*i*beta*D/Qr+r*i*beta*D-q*i*beta*D-P*(1-i)*i*beta*D end proc

proc (Q, Qr) options operator, arrow; Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(O1, Student:-VectorCalculus:-`+`(1, Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(i, beta)))), Student:-VectorCalculus:-D), Q^Student:-VectorCalculus:-`-`(1)), Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(h1, Q), 2^Student:-VectorCalculus:-`-`(1))), Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(h2, Student:-VectorCalculus:-`+`(gamma, Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(i, beta)))), Qr), Student:-VectorCalculus:-`*`(2, gamma)^Student:-VectorCalculus:-`-`(1))), Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(O2, i), beta), Student:-VectorCalculus:-D), Qr^Student:-VectorCalculus:-`-`(1))), Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(r, i), beta), Student:-VectorCalculus:-D)), Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(q, i), beta), Student:-VectorCalculus:-D))), Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(P, Student:-VectorCalculus:-`+`(1, Student:-VectorCalculus:-`-`(i))), i), beta), Student:-VectorCalculus:-D))) end proc

(8)

diff(TC1(Q, Qr), Q)

-O1*(-beta*i+1)*Student:-VectorCalculus:-D/Q^2+(1/2)*h1

(9)

a1 := isolate(-O1*(-beta*i+1)*D/Q^2+(1/2)*h1, Q)

Q = RootOf(2*Student:-VectorCalculus:-D*O1*beta*i+_Z^2*h1-2*Student:-VectorCalculus:-D*O1)

(10)

diff(TC1(Q, Qr), Qr)

(1/2)*h2*(-beta*i+gamma)/gamma-O2*i*beta*Student:-VectorCalculus:-D/Qr^2

(11)

a2 := isolate(diff(TC1(Q, Qr), Qr), Qr)

Qr = RootOf((beta*h2*i-gamma*h2)*_Z^2+2*gamma*O2*i*beta*Student:-VectorCalculus:-D)

(12)

TC2 := proc (Q) options operator, arrow; O1*(1-gamma)*D/Q+(1/2)*h1*Q+r*gamma*D-q*gamma*D-P*(1-i)*gamma*D end proc

proc (Q) options operator, arrow; Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`+`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(O1, Student:-VectorCalculus:-`+`(1, Student:-VectorCalculus:-`-`(gamma))), Student:-VectorCalculus:-D), Q^Student:-VectorCalculus:-`-`(1)), Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(h1, Q), 2^Student:-VectorCalculus:-`-`(1))), Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(r, gamma), Student:-VectorCalculus:-D)), Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(q, gamma), Student:-VectorCalculus:-D))), Student:-VectorCalculus:-`-`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(Student:-VectorCalculus:-`*`(P, Student:-VectorCalculus:-`+`(1, Student:-VectorCalculus:-`-`(i))), gamma), Student:-VectorCalculus:-D))) end proc

(13)

b1 := isolate(diff(TC2(Q), Q), Q)

Q = RootOf(2*Student:-VectorCalculus:-D*O1*gamma+_Z^2*h1-2*Student:-VectorCalculus:-D*O1)

(14)

E1 := eval(a1, [P = 765, D = 347933, O1 = 30, O2 = 10, h1 = 76.5, h2 = 38.25, beta = 0.5e-1, gamma = 0.4e-1, q = 7.65, r = 382.5, i = .5])

Q = RootOf(76.5*_Z^2-20354080.50)

(15)

simplify(E1)

Q = 515.8162578

(16)

E2 := eval(a2, [P = 765, D = 347933, O1 = 30, O2 = 10, h1 = 76.5, h2 = 38.25, beta = 0.5e-1, gamma = 0.4e-1, q = 7.65, r = 382.5, i = .5])

Qr = RootOf(.57375*_Z^2-6958.66000)

(17)

simplify(E2)

Qr = 110.1289401

(18)

Totcost := eval(TC1(Q, Qr), [Q = 516, Qr = 110, P = 765, D = 347933, O1 = 30, O2 = 10, h1 = 76.5, h2 = 38.25, beta = 0.5e-1, gamma = 0.4e-1, q = 7.65, r = 382.5, i = .5])

-25502.577

(19)

TB1 := B1*D*P*beta*i-D*beta*i*q

B1*Student:-VectorCalculus:-D*P*beta*i-Student:-VectorCalculus:-D*beta*i*q

(20)

TBC := eval(TB1, [B1 = 3.36, P = 765, D = 347933, O1 = 30, O2 = 10, h1 = 76.5, h2 = 38.25, beta = 0.5e-1, gamma = 0.4e-1, r = 382.5])

-17396.65*q*i+44716349.16*i

(21)

Totincent := P*i^2*beta*D

P*i^2*beta*Student:-VectorCalculus:-D

(22)

TI := eval(Totincent, [B1 = 3.36, P = 765, D = 347933, O1 = 30, O2 = 10, h1 = 76.5, h2 = 38.25, beta = 0.5e-1, gamma = 0.4e-1, r = 382.5])

13308437.25*i^2

(23)

NULL

simplify(subs(P = 765, D = 347933, O1 = 30, O2 = 10, h1 = 76.5, h2 = 38.25, gamma = 0.4e-1, q = 7.65, r = 382.5, beta = 0.5e-1, Q = sqrt((2*(-beta*i+1))*O1*D/h1))); simplify(subs(P = 765, D = 347933, O1 = 30, O2 = 10, h1 = 76.5, h2 = 38.25, gamma = 0.4e-1, q = 7.65, r = 382.5, beta = 0.5e-1, Qr = sqrt(2*i*beta*gamma*O2*D/((gamma-beta)*h2))))

Q = 3230.787830*(-0.1307189542e-2*i+0.2614379084e-1)^(1/2)

 

Qr = 190.7489196*(-i)^(1/2)

(24)

TCo := eval(TC1(Q, Qr), [Q = 3230.787830*sqrt(-0.1307189542e-2*i+0.2614379084e-1), Qr = 190.7489196*sqrt(-i), P = 765, D = 347933, O1 = 30, O2 = 10, h1 = 76.5, h2 = 38.25, gamma = 0.4e-1, q = 7.65, r = 382.5, beta = 0.5e-1])

3230.787829*(-0.5e-1*i+1)/(-0.1307189542e-2*i+0.2614379084e-1)^(1/2)+123577.6345*(-0.1307189542e-2*i+0.2614379084e-1)^(1/2)+91201.82720*(-0.5e-1*i+0.4e-1)*(-i)^(1/2)+912.0182718*i/(-i)^(1/2)+6521134.252*i-13308437.25*(1-i)*i

(25)

eq1 := TCo <= 0

3230.787829*(-0.5e-1*i+1)/(-0.1307189542e-2*i+0.2614379084e-1)^(1/2)+123577.6345*(-0.1307189542e-2*i+0.2614379084e-1)^(1/2)+91201.82720*(-0.5e-1*i+0.4e-1)*(-i)^(1/2)+912.0182718*i/(-i)^(1/2)+6521134.252*i-13308437.25*(1-i)*i <= 0

(26)

eq2 := 0 <= q/P and q/P <= 1

0 <= q/P and q/P <= 1

(27)

eq3 := 0 <= i and i <= gamma/beta

0 <= i and i <= gamma/beta

(28)

eq4 := TBC >= 0

0 <= -17396.65*q*i+44716349.16*i

(29)

``

TBCI := TBC-TCo+TI

-17396.65*q*i+38195214.91*i-3230.787829*(-0.5e-1*i+1)/(-0.1307189542e-2*i+0.2614379084e-1)^(1/2)-123577.6345*(-0.1307189542e-2*i+0.2614379084e-1)^(1/2)-91201.82720*(-0.5e-1*i+0.4e-1)*(-i)^(1/2)-912.0182718*i/(-i)^(1/2)+13308437.25*(1-i)*i+13308437.25*i^2

(30)

NLPSolve(TBCI, {eq1, eq2, eq3, eq4}, assume = nonnegative)

Error, (in Optimization:-NLPSolve) constraints must be specified as a set or list of equalities and inequalities

 

``

For instance, Hypergeometric0F1Regularized^(1,0)[1,1.] = -0.113894... as given in Mathematica. I was wondering how this type of regularized hypergeometric function is defined in Maple. 

I incidently(*) discovered that using MatrixPower to find the square root matrix of a relatively small matrix, returns wrong results, even for symetric positive definite matrices.

Trying to understand how MatrixPower proceeds using showstat is not that easy, but something I'm almost sure is that it doesn't ise an Eigenvectors decomposition.

Here is an example where I'm seeking for a matrix M such that C = M^2 and C is symetric definite positive of dimension 40.
(I didn't check if problems already occurs for smaller sizes)

(*)  I was very bored by the prohibitive execution time of MatrixPower and looked for an alternative.

The matrix M that MatrixPower generates is far from verifying C = M^2 (using the option 'shape'='symmetric' doesn't improve anything).
The naive alternative based on an Eigenvectors decomposition works perfectly well while being 200 times faster.

restart:

with(LinearAlgebra):
with(Statistics):

f := proc(p)
  Sample(Uniform(0, 1), [100, p]):
  CorrelationMatrix(%):
end proc:

C := f(40):

M_MP := CodeTools:-Usage( MatrixPower(C, 1/2) ):

memory used=382.38MiB, alloc change=12.01MiB, cpu time=6.05s, real time=6.26s, gc time=386.00ms

 

LE := proc(R)
  local L, E;
  L, E := LinearAlgebra:-Eigenvectors(evalf(R)):
  L    := map(Re, L):
  E    := map(Re, E):
  E . DiagonalMatrix(sqrt~(L)) . E^(-1)
end proc:

IsDefinite(C, query = 'positive_definite');

M_LE := CodeTools:-Usage( LE(C) ):

true

 

memory used=0.90MiB, alloc change=0 bytes, cpu time=29.00ms, real time=10.00ms, gc time=0ns

 

map(fnormal, M_MP . M_MP - C):
%[1..5, 1..5];

Matrix([[-493.2020830, -3096.801269, 3350.121141, -2972.190814, -6160.797678], [-2436.661317, -6415.706483, 208.1172241, -3001.930739, 1332.904551], [202.2560565, 413.4962022, 799.7833045, -179.6552377, -1817.784899], [-2994.580353, -9862.899715, 2543.110865, -5679.831865, -2552.349252], [-98.63574955, 2078.317993, -3118.445704, 2420.432714, 5905.315145]])

(1)

map(fnormal, M_LE . M_LE - C):
%[1..5, 1..5];

Matrix([[0., -0., -0., 0., 0.], [-0., 0., 0., 0., 0.], [-0., 0., -0., 0., -0.], [0., 0., -0., 0., -0.], [-0., 0., -0., -0., -0.]])

(2)

 

Download MatrixPower_bug.mw

Could someone please exlain this behaviour:

indets('combinat:-binomial(i,j)', 'specfunc(combinat:-binomial)');
indets('combinat:-binomial(i,j)', specfunc('combinat:-binomial'));
indets('combinat:-binomial(i,j)', specfunc(combinat:-binomial));
indets(combinat:-binomial(i,j), specfunc(combinat:-binomial));


indets('combinat:-binomial(i,j)', 'specfunc(binomial)');
indets('combinat:-binomial(i,j)', specfunc('binomial'));
indets('combinat:-binomial(i,j)', specfunc(binomial));
indets(combinat:-binomial(i,j), specfunc(binomial));


indets('binomial(i,j)', 'specfunc(binomial)');
indets('binomial(i,j)', specfunc('binomial'));
indets('binomial(i,j)', specfunc(binomial));
indets(binomial(i,j), specfunc(binomial));

indets('binomial(i,j)', 'specfunc(combinat:-binomial)');
indets('binomial(i,j)', specfunc('combinat:-binomial'));
indets('binomial(i,j)', specfunc(combinat:-binomial));
indets(binomial(i,j), specfunc(combinat:-binomial));

 

I was looking for rewriting some expression in simpler forms and ened up getting wrong values from maple

Is something wrong on how I'm using it or is this a bug ?

This is the code with the output:

> NumericStatus(invalid_operation=false):
> simplify(sum(
>         (A-B)
>         *(-1+combinat:-binomial(N-2,i))
>         *(A)^(i)
>         *(B)^(N-2-i)
>     ,i=0..N-2));
                                                    (N - 1)    (N - 1)
                                                   B        - A



> NumericStatus(invalid_operation);
                                                          false

 

This is the wrong answer, is missing the part with the binomial, somehow its set to zero but the NumericStatus is still telling that everythig is fine.
It has not issues when one replaces the N-2 with N,

> simplify(sum(
>         (A-B)
>         *(-1+combinat:-binomial(N,i))
>         *(A)^(i)
>         *(B)^(N-i)
>     ,i=0..N));
                                          (N + 1)    (N + 1)                  N
                                         B        - A        + (A - B) (A + B)

> NumericStatus(invalid_operation);
                                                          false

 

If I drop the (-1) in front I get the right contribution from the binomial regardless of using N or N-2

> simplify(sum(
>         (A-B)
>         *(combinat:-binomial(N-2,i))
>         *(A)^(i)
>         *(B)^(N-2-i)
>     ,i=0..N-2));
                                                   /A + B\N          N
                                                   |-----|  (A - B) B
                                                   \  B  /
                                                   -------------------
                                                               2
                                                        (A + B)

> NumericStatus(invalid_operation);
                                                          false

which is equal to (A+B)^(N-2)*(A-B)

If I use assume(N>2) it still gives the same result but this time is flagged ad an invalid operation (which is not supposed to).
Interesting enough also if I set assume(N>0) in the second example gives me invalid_operation=true but return the correct result.

First 106 107 108 109 110 111 112 Last Page 108 of 2308