acer

32385 Reputation

29 Badges

19 years, 335 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

A:= [ [4,2], [9,1], [6,8] ]:

map[2](op,1,A);                                                                              

             [4, 9, 6]

map[2](op,2,A);

             [2, 1, 8]

Alternatively,

op~(1,A);
                                                                                
             [4, 9, 6]

op~(2,A);

             [2, 1, 8]

map(`?[]`,A,[1]);

             [4, 9, 6]

map(`?[]`,A,[2]);

             [2, 1, 8]

map(u->u[1],A);

             [4, 9, 6]

map(u->u[2],A);

             [2, 1, 8]

(u->u[1])~(A);

             [4, 9, 6]

(u->u[2])~(A);

             [2, 1, 8]

I'm not claiming that this is a general solution, in part because you haven't indicated the general kind of example. But you might get some ideas from it, for your exercise.

(It isn't clear whether you can use expand, as done below. But even that effect could be implemented manually.)

If your expression has a term with (1-y) in its denominator and another term with (1-y)^2 in its own denominator then G may be generated here as (1-y)^3. If that's not what you want to happen then you could correct the code to manage that. That's what I mean when I say that this is just to give you some ideas.

And I don't know whether this code will seem simplistic or complicated to you, as I don't know what Maple familiarity you have.

restart;

ee := -1/(y-1)-y/(y-1)-y^2-2*y-1+y^3/(y-1)+y^2/(y-1);

-1/(y-1)-y/(y-1)-y^2-2*y-1+y^3/(y-1)+y^2/(y-1)

L:=[op(ee)];

[-1/(y-1), -y/(y-1), -y^2, -2*y, -1, y^3/(y-1), y^2/(y-1)]

getdenom:=proc(u)
  local T,TT;
  if u::`*` then
    T:=[op(u)];
    TT:=select(type,T,And(`^`,satisfies(p->op(2,p)::numeric and op(2,p)<0)));
    TT:={op(map(p->op(1,p)^(-op(2,p)),TT))};
  else
    return {1};
  end if;
end proc:

getdenom(L[1]);

{y-1}

`union`(op(map(getdenom,L)));
G:=`*`(op(%));

{1, y-1}

y-1

map(expand@`*`,L,G);
`+`(op(%));

[-1, -y, -y^3+y^2, -2*y^2+2*y, -y+1, y^3, y^2]

0

expr:=2+3*x+3*x^3*y+3*x*y-x^4*y^3-x^3*y^4-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3/(y-1)-2*x^2*y/(y-1)+2*x*y^2/(y-1)-4*x^2/(y-1)-2*x*y/(y-1)+y^2/(y-1)-4*x/(y-1)-2*y/(y-1)-3/(y-1)

targ:=y^6/(y-1)-4*x^3/(y-1)-4*x^2/(y-1)-4*x/(y-1)-3/(y-1)+2*x^3*y^3/(y-1)+2*x^2*y^4/(y-1)+2*x*y^5/(y-1)+y^8/(y-1)+2*y^5/(y-1)+4*x^3*y^2/(y-1)+2*x^2*y^3/(y-1)+2*x*y^4/(y-1)+2*y^2*x^2/(y-1)+2*y^2*x/(y-1)-2*y/(y-1)-2*y*x^3/(y-1)+y^2/(y-1)-2*x*y/(y-1)-2*y*x^2/(y-1);

y^8/(y-1)+2*x^3*y^3/(y-1)+2*x^2*y^4/(y-1)+2*x*y^5/(y-1)+y^6/(y-1)+4*x^3*y^2/(y-1)+2*x^2*y^3/(y-1)+2*x*y^4/(y-1)+2*y^5/(y-1)-2*x^3*y/(y-1)+2*x^2*y^2/(y-1)-4*x^3/(y-1)-2*x^2*y/(y-1)+2*x*y^2/(y-1)-4*x^2/(y-1)-2*x*y/(y-1)+y^2/(y-1)-4*x/(y-1)-2*y/(y-1)-3/(y-1)

ans-targ;

0

 

Download ideas.mw

You might also consider using coeff, if allowed.

I'm not sure why you say "order". It seems more like mapped evaluation-at.

restart;

ST := [`162` = Record(mu = 475, sigma = 41), `70` = Record(mu = 480, sigma = 42),
       `168` = Record(mu = 448, sigma = 103)];

[`162` = Record(mu = 475, sigma = 41), `70` = Record(mu = 480, sigma = 42), `168` = Record(mu = 448, sigma = 103)]

Games:=[[`162`, `70`], [`70`, `168`], [`168`, `162`]];

[[`162`, `70`], [`70`, `168`], [`168`, `162`]]

STO:=[`162` = Record(mu = 475, sigma = 41),`70` = Record(mu = 480, sigma = 42),
       `70` = Record(mu = 480, sigma = 42),`168` = Record(mu = 448, sigma = 103),
     `168` = Record(mu = 448, sigma = 103),`162` = Record(mu = 475, sigma = 41)];

`Non-fatal error while reading data from kernel.`

map(L->map(LL->LL=eval(LL,ST),L)[], Games);

`Non-fatal error while reading data from kernel.`

 

Download ORDERED_ac.mw

Alternatively (but not only),

map(L->L=eval(L,ST),map(op,Games));

(G->G=eval(G,ST))~(op~(Games));

Is this what you mean?

Since your request is to scale the distance between adjacent points, then that works with a simple rescaling of the increment (3rd argument) passed to the seq command.

(You could even scale x and y distances differently from each other. I kept them the same.)

restart

with(plots)

x_min := 1; x_max := 4; y_min := 1; y_max := 3

1

4

1

3

x_range := x_max-x_min; y_range := y_max-y_min

3

2

n[0] := 1

1

Blocks := x_range*y_range*n[0]^2

6

Points1 := [seq(seq([X, Y], X = x_min .. x_max), Y = y_min .. y_max)]; nops(%); (x_max-x_min)*n[0]+1, (y_max-y_min)*n[0]+1; (x_max-x_min)*n[0], (y_max-y_min)*n[0]; (x_max-x_min)*n[0]*((y_max-y_min)*n[0])

[[1, 1], [2, 1], [3, 1], [4, 1], [1, 2], [2, 2], [3, 2], [4, 2], [1, 3], [2, 3], [3, 3], [4, 3]]

12

4, 3

3, 2

6

plot(Points1, style = point, color = red, symbol = solidcircle, symbolsize = 20)

n[1] := 3

3

x_range*y_range*n[1]^2

54

Points2 := [seq(seq([X, Y], X = x_min .. x_max, 1/n[1]), Y = y_min .. y_max, 1/n[1])]; nops(%); (x_max-x_min)*n[1]+1, (y_max-y_min)*n[1]+1; (x_max-x_min)*n[1], (y_max-y_min)*n[1]; (x_max-x_min)*n[1]*((y_max-y_min)*n[1])

70

10, 7

9, 6

54

pointplot(Points2, color = red, symbol = solidcircle, symbolsize = 15)

n[2] := 4

4

x_range*y_range*n[2]^2

96

Points3 := [seq(seq([X, Y], X = x_min .. x_max, 1/n[2]), Y = y_min .. y_max, 1/n[2])]; nops(%); (x_max-x_min)*n[2]+1, (y_max-y_min)*n[2]+1; (x_max-x_min)*n[2], (y_max-y_min)*n[2]; (x_max-x_min)*n[2]*((y_max-y_min)*n[2])

117

13, 9

12, 8

96

pointplot(Points2, color = red, symbol = solidcircle, symbolsize = 15)

 

NULL

Download Grid_Example_ac.mw

If you execute the following then the .mla should be created in a special toolbox location.

You should then be able to execute only the command with(MyMat); in any future session, without having for first augment libname.

(You won't be able to simply test by doing only a restart in that same GUI window/tab. The GUI only scans for such special locations once, and it's already been done for the window/tab in which you execute this code.)

LibFolder:=cat(kernelopts(':-homedir'),"/maple/toolbox/MyMat/lib");
FileTools:-MakeDirectory(LibFolder, ':-recurse');
LibLocation:=cat(LibFolder,"/MyMat.mla");
if FileTools:-Exists(LibLocation) then
  FileTools:-Remove(LibLocation)
end if;
LibraryTools:-Create(LibLocation);
LibraryTools:-Save(MyMat, LibLocation);

If you subsequently ever want that package not to be found then you'd have to either delete (or move aside) that .mla file, or remove its location from libname in the session, or launch with a specifically restricted libname.

The functionality provided by x^n (for x,n integers) is not implemented as merely mul(x, i=1..n).

Your previous comments indicate that you were originally under that mistaken impression.

Following the stricture indicated in the error message, you could make the comps argument (in the call assigned to X) be a Vector rather than a RootedVector.

That is, to have the third argument be Vector((29*N)/155) rather than (29*N)/155 which resolves to a RootedVector. It also computes without error if using VectorCalculus:-Vector((29*N)/155).

p1 := plots[implicitplot3d](5*x-7*y+9*z = 11, x = -5 .. 5, y = -7 .. 5, z = -5 .. 5, style = surface); N := VectorCalculus[RootedVector](root = [0, 0, 11/9], `<,>`(5, -7, 9)); V := VectorCalculus[RootedVector](root = [0, 0, 11/9], `<,>`(2, -3, 1)-`<,>`(0, 0, 11/9)); X := VectorCalculus[RootedVector](root = [33/31, -262/155, -106/155], VectorCalculus:-Vector(29*N*(1/155))); p2 := VectorCalculus[PlotVector]([V, N], color = [green, red], width = .3); p3 := VectorCalculus[PlotVector](X, color = black, width = .3); p4 := plots[display](p1, p2, p3, axes = none, scaling = constrained, lightmodel = none, orientation = [144, 49, -95]); unassign('N', 'V', 'X'); p4

``

Download CodeVectorCalculus_ac.mw

One way is to combine(...,exp) after expanding sums and products (`+` and `*`).

If you choose to expand as a preliminary step then frontend can let you expand sums and products without expanding, say, trig terms.

Applying collect with respect to the trig term happens to be another way to target the expand, for this example.

restart;

ee := -(chi*omega^2+2*omega)*cos(omega*(Upsilon+b1))*P1*(3*exp(-3*omega)*kappa+exp(-omega)*kappa+exp(-omega*(2*d1+1))*kappa^2+3*exp(-omega*(2*d1+3))*kappa^2-2*exp(-omega*(2*d1+3))*omega-4*exp(-3*omega)*omega^2-2*exp(-omega*(2*d1+3))*d1*kappa*nu__p^2*omega+4*exp(-omega*(2*d1+3))*d1*kappa*nu__p*omega+2*exp(-omega*(2*d1+1))*d1*kappa*nu__p^2*omega+4*exp(-omega*(2*d1+1))*d1*kappa*nu__p*omega-exp(-3*omega)*kappa*nu__p^2+exp(-omega)*kappa*nu__p^2+exp(-omega*(2*d1+1))*kappa^2*nu__p^2-exp(-omega*(2*d1+3))*kappa^2*nu__p^2+2*exp(-omega*(2*d1+1))*d1*kappa*omega-8*exp(-omega*(2*d1+3))*d1*nu__p^2*omega^3-16*exp(-omega*(2*d1+3))*d1*nu__p*omega^3-4*exp(-omega*(2*d1+3))*kappa*nu__p^2*omega^2-8*exp(-omega*(2*d1+3))*kappa*nu__p*omega^2+6*exp(-omega*(2*d1+3))*d1*kappa*omega-4*exp(-3*omega)*kappa*nu__p*omega+4*exp(-3*omega)*d1*nu__p^2*omega^2+8*exp(-3*omega)*d1*nu__p*omega^2-2*exp(-3*omega)*kappa*nu__p^2*omega+2*exp(-3*omega)*kappa*nu__p+2*exp(-omega)*kappa*nu__p+2*exp(-omega*(2*d1+1))*kappa^2*nu__p+2*exp(-omega*(2*d1+3))*kappa^2*nu__p-8*exp(-omega*(2*d1+3))*d1*omega^3-4*exp(-omega*(2*d1+3))*nu__p*omega-2*exp(-omega*(2*d1+3))*nu__p^2*omega-4*exp(-omega*(2*d1+3))*kappa*omega^2-2*exp(-3*omega)*kappa*omega-4*exp(-3*omega)*nu__p^2*omega^2+4*exp(-3*omega)*d1*omega^2-8*exp(-3*omega)*nu__p*omega^2)*exp(-omega*(1-d1-chi))/(omega*(4*exp(-2*omega)*nu__p^2*omega^2+8*exp(-2*omega)*nu__p*omega^2-exp(-4*omega)*nu__p^2+2*exp(-2*omega)*nu__p^2+4*exp(-2*omega)*omega^2+2*exp(-4*omega)*nu__p-4*exp(-2*omega)*nu__p-nu__p^2+3*exp(-4*omega)+10*exp(-2*omega)+2*nu__p+3)*(kappa+1)*Pi);

-(chi*omega^2+2*omega)*cos(omega*(Upsilon+b1))*P1*(-4*exp(-3*omega)*nu__p^2*omega^2+2*exp(-omega*(2*d1+1))*kappa^2*nu__p+2*exp(-omega*(2*d1+3))*kappa^2*nu__p-4*exp(-omega*(2*d1+3))*nu__p*omega-8*exp(-omega*(2*d1+3))*d1*omega^3-4*exp(-omega*(2*d1+3))*kappa*omega^2+2*exp(-omega)*kappa*nu__p+2*exp(-3*omega)*kappa*nu__p-2*exp(-3*omega)*kappa*omega+4*exp(-3*omega)*d1*omega^2-8*exp(-3*omega)*nu__p*omega^2-2*exp(-omega*(2*d1+3))*nu__p^2*omega+exp(-omega)*kappa+exp(-omega*(2*d1+1))*kappa^2+3*exp(-3*omega)*kappa+3*exp(-omega*(2*d1+3))*kappa^2-2*exp(-omega*(2*d1+3))*omega-4*exp(-3*omega)*omega^2-2*exp(-omega*(2*d1+3))*d1*kappa*nu__p^2*omega+4*exp(-omega*(2*d1+3))*d1*kappa*nu__p*omega+2*exp(-omega*(2*d1+1))*d1*kappa*nu__p^2*omega+4*exp(-omega*(2*d1+1))*d1*kappa*nu__p*omega-exp(-3*omega)*kappa*nu__p^2+exp(-omega)*kappa*nu__p^2+exp(-omega*(2*d1+1))*kappa^2*nu__p^2-exp(-omega*(2*d1+3))*kappa^2*nu__p^2+2*exp(-omega*(2*d1+1))*d1*kappa*omega-8*exp(-omega*(2*d1+3))*d1*nu__p^2*omega^3-16*exp(-omega*(2*d1+3))*d1*nu__p*omega^3-4*exp(-omega*(2*d1+3))*kappa*nu__p^2*omega^2-8*exp(-omega*(2*d1+3))*kappa*nu__p*omega^2+6*exp(-omega*(2*d1+3))*d1*kappa*omega-4*exp(-3*omega)*kappa*nu__p*omega+4*exp(-3*omega)*d1*nu__p^2*omega^2+8*exp(-3*omega)*d1*nu__p*omega^2-2*exp(-3*omega)*kappa*nu__p^2*omega)*exp(-omega*(1-d1-chi))/(omega*(4*exp(-2*omega)*nu__p^2*omega^2+8*exp(-2*omega)*nu__p*omega^2-exp(-4*omega)*nu__p^2+2*exp(-2*omega)*nu__p^2+4*exp(-2*omega)*omega^2+2*exp(-4*omega)*nu__p-4*exp(-2*omega)*nu__p-nu__p^2+3*exp(-4*omega)+10*exp(-2*omega)+2*nu__p+3)*(kappa+1)*Pi)

simplify(combine(frontend(expand,[ee],[]),exp),size);

4*cos(omega*(Upsilon+b1))*((-2*d1*(nu__p+1)*omega^3-kappa*(nu__p+1)*omega^2+((-(1/2)*d1*kappa-1/2)*nu__p+(3/2)*d1*kappa-1/2)*omega-(1/4)*kappa^2*(nu__p-3))*exp(-omega*(4+d1-chi))+(1/2)*(d1*omega+(1/2)*kappa)*kappa*(nu__p+1)*exp(-omega*(2+d1-chi))+((nu__p+1)*(d1-1)*omega^2-(1/2)*kappa*(nu__p+1)*omega-(1/4)*kappa*(nu__p-3))*exp(omega*(-4+d1+chi))+(1/4)*exp(omega*(-2+d1+chi))*kappa*(nu__p+1))*P1*(chi*omega+2)*(nu__p+1)/(((-4*(nu__p+1)^2*omega^2-2*nu__p^2+4*nu__p-10)*exp(-2*omega)+(nu__p+1)*(nu__p-3)*(exp(-4*omega)+1))*(kappa+1)*Pi)

collect(ee,[cos],u->simplify(combine(expand(u),exp),size));

(1/2)*(chi*omega+2)*((4*d1*(nu__p+1)*omega^3+2*kappa*(nu__p+1)*omega^2+(d1*kappa*nu__p-3*d1*kappa+nu__p+1)*omega+(1/2)*kappa^2*(nu__p-3))*exp(-omega*(4+d1-chi))-(d1*omega+(1/2)*kappa)*kappa*(nu__p+1)*exp(-omega*(2+d1-chi))+(-2*(nu__p+1)*(d1-1)*omega^2+kappa*(nu__p+1)*omega+(1/2)*kappa*(nu__p-3))*exp(omega*(-4+d1+chi))-(1/2)*exp(omega*(-2+d1+chi))*kappa*(nu__p+1))*(nu__p+1)*P1*cos(omega*(Upsilon+b1))/((kappa+1)*(((nu__p+1)^2*omega^2+(1/2)*nu__p^2-nu__p+5/2)*exp(-2*omega)-(1/4)*(nu__p+1)*(nu__p-3)*(exp(-4*omega)+1))*Pi)

collect(numer(ee),[cos],u->collect(combine(expand(u),exp),[exp],simplify))
/collect(denom(ee),[cos],u->collect(combine(expand(u),exp),[exp],simplify));

(2*(nu__p+1)*P1*omega*(chi*omega+2)*(4*d1*(nu__p+1)*omega^3+2*kappa*(nu__p+1)*omega^2+(d1*(nu__p-3)*kappa+nu__p+1)*omega+(1/2)*kappa^2*(nu__p-3))*exp(chi*omega-d1*omega-4*omega)-(2*d1*omega+kappa)*(nu__p+1)^2*P1*omega*(chi*omega+2)*kappa*exp(chi*omega-d1*omega-2*omega)-4*(nu__p+1)*P1*omega*(chi*omega+2)*((nu__p+1)*(d1-1)*omega^2-(1/2)*kappa*(nu__p+1)*omega-(1/4)*kappa*(nu__p-3))*exp(chi*omega+d1*omega-4*omega)-P1*kappa*omega*(nu__p+1)^2*(chi*omega+2)*exp(chi*omega+d1*omega-2*omega))*cos(omega*(Upsilon+b1))/(-omega*Pi*(nu__p+1)*(nu__p-3)*(kappa+1)*exp(-4*omega)+4*Pi*((nu__p+1)^2*omega^2+(1/2)*nu__p^2-nu__p+5/2)*omega*(kappa+1)*exp(-2*omega)-omega*Pi*(nu__p+1)*(nu__p-3)*(kappa+1))

 

Compare:

 

combine( (1+exp(x)) * exp(y), exp );

(1+exp(x))*exp(y)

combine( expand( (1+exp(x)) * exp(y) ), exp );

exp(y)+exp(y+x)

 

Download combine_exp.mw

Here are two ways. One is a CodeGeneration:-Matlab call on a list of a sequence of equations. The other is a loop of CodeGeneration:-Matlab calls on a list with a single equation.

restart

with(CodeGeneration); with(LinearAlgebra)

A := RandomMatrix(3, 3)

Matrix(%id = 18446884456322477342)

Matlab([seq(seq(KNL[ii, jj] = A[ii, jj], jj = 1 .. 3), ii = 1 .. 3)])

KNL(1,1) = 27;
KNL(1,2) = 99;
KNL(1,3) = 92;
KNL(2,1) = 8;
KNL(2,2) = 29;
KNL(2,3) = -31;
KNL(3,1) = 69;
KNL(3,2) = 44;
KNL(3,3) = 67;

for ii to 3 do for jj to 3 do Matlab([KNL[ii, jj] = A[ii, jj]]) end do end do

KNL(1,1) = 27;

KNL(1,2) = 99;
KNL(1,3) = 92;
KNL(2,1) = 8;
KNL(2,2) = 29;
KNL(2,3) = -31;
KNL(3,1) = 69;
KNL(3,2) = 44;
KNL(3,3) = 67;

 

Download Matlab_-_Resultname_ac.mw

The _d01amc method of evalf(Int...)) can do it, although it needs to be forced to not use evalhf mode (which I do with a trick, by using a list within a procedure). And I split the real and imaginary components , since roundoff error produces small but nonzero imaginary components (artefacts).

I did not try converting the integrand to something more tractable.

The result agrees well with that using a chopped moderate finite interval. (The curve goes to zero quickly, as you saw.)

restart

istar := y*sinh(Pi*y)*exp(-alpha*y^2)*LegendreP(-1/2+I*y, 1+u)

y*sinh(Pi*y)*exp(-alpha*y^2)*LegendreP(-1/2+I*y, 1+u)

alpha := 1; u := 2

2

plot(([Re, Im])(istar), y = 0 .. 40, size = [400, 200])

Hre := proc (Y) []; eval(Re(istar), y = Y) end proc

evalf(Int(Hre, 0 .. infinity, method = _d01amc))

-1.707207851

Him := proc (Y) []; eval(Im(istar), y = Y) end proc

evalf(Int(Him, 0 .. infinity, method = _d01amc))

-0.3469635600e-28

evalf(Int(istar, y = 0 .. 100))

-1.707207851-0.1848178275e-27*I

``

Download Istar_ac.mw

In the lines where you seem to be assigning to a__01 and a__10 you have extra spaces in those names, and you are actually assigning to `a__01 ` and `a__10 ` with 1 extra space at the end of the name.

Also, in the expression you are assigning on the very first line you have an instance of `u__2  ` with 2 extra spaces at the end of that name. That is not the same as the u__2 you use elsewhere.

Below I have removed these extra spaces.

a__10 := (1-u__2)*(u__2-m)-q*(u__2+c)+u__2*(1+m-2*u__2)

(1-u__2)*(u__2-m)-q*(u__2+c)+u__2*(1+m-2*u__2)

(1)

a__01 := -u__2*q

-u__2*q

(2)

a__20 := 1/2*(-6*u__2+2*m+2)

-3*u__2+m+1

(3)

a__11 := -q

-q

(4)

a__02 := 0

0

(5)

b__10 := s

s

(6)

b__01 := -s

-s

(7)

b__20 := -s/(u__2+c)

-s/(u__2+c)

(8)

b__11 := 2*s/(u__2+c)

2*s/(u__2+c)

(9)

b__02 := -s/(u__2+c)

-s/(u__2+c)

(10)

b__03 := 0

0

(11)

a__30 := -1

-1

(12)

a__21 := 0

0

(13)

b__12 := s/(u__2+c)^2

s/(u__2+c)^2

(14)

a__12 := 0

0

(15)

b__21 := (-2*(u__2+c)^2-s)/(2*(u__2+c)^3)

(1/2)*(-2*(u__2+c)^2-s)/(u__2+c)^3

(16)

l__1 := ((-3*Pi)*(1/(2*a__01*(q*s*u__2-s^2))))*(a__10*b__10*(a__02*b__11+a__11^2+a__11*b__02)+a__10*a__01*(a__11*b__02+a__20*b__11+b__11^2)+b__10^2*(a__02*a__11+2*a__02*b__02)-2*a__10*b__10*(-a__02*a__20+b__02^2)-2*a__10*a__01*(a__20^2-b__02*b__20)-a__01^2*(2*a__20*b__20+b__11*b__20)+(a__01*b__10-2*a__10^2)*(-a__11*a__20+b__02*b__11)-(a__01*b__10+a__10^2)*(3*(-a__01*a__30+b__03*b__10)+2*a__10*(a__21+b__12)+b__10*a__12-a__01*b__21))

(3/2)*Pi*(((1-u__2)*(u__2-m)-q*(u__2+c)+u__2*(1+m-2*u__2))*s*(q^2+q*s/(u__2+c))-((1-u__2)*(u__2-m)-q*(u__2+c)+u__2*(1+m-2*u__2))*u__2*q*(q*s/(u__2+c)+2*(-3*u__2+m+1)*s/(u__2+c)+4*s^2/(u__2+c)^2)-2*((1-u__2)*(u__2-m)-q*(u__2+c)+u__2*(1+m-2*u__2))*s^3/(u__2+c)^2+2*((1-u__2)*(u__2-m)-q*(u__2+c)+u__2*(1+m-2*u__2))*u__2*q*((-3*u__2+m+1)^2-s^2/(u__2+c)^2)-u__2^2*q^2*(-2*(-3*u__2+m+1)*s/(u__2+c)-2*s^2/(u__2+c)^2)+(-q*s*u__2-2*((1-u__2)*(u__2-m)-q*(u__2+c)+u__2*(1+m-2*u__2))^2)*(q*(-3*u__2+m+1)-2*s^2/(u__2+c)^2)-(-q*s*u__2+((1-u__2)*(u__2-m)-q*(u__2+c)+u__2*(1+m-2*u__2))^2)*(-3*u__2*q+2*((1-u__2)*(u__2-m)-q*(u__2+c)+u__2*(1+m-2*u__2))*s/(u__2+c)^2+(1/2)*u__2*q*(-2*(u__2+c)^2-s)/(u__2+c)^3))/(u__2*q*(q*s*u__2-s^2))

(17)

map(convert, indets(l__1, name), string)

{"Pi", "c", "m", "q", "s", "u__2"}

(18)

 

Download coeff_ac.mw

Another way,

restart;

 

Multiple angle reduction formula (See here) for integer N.

 

eq:=cos(N*t)=Sum((-1)^k*binomial(N,2*k)*cos(t)^(N-2*k)*sin(t)^(2*k),k=0..N/2);

cos(N*t) = Sum((-1)^k*binomial(N, 2*k)*cos(t)^(N-2*k)*sin(t)^(2*k), k = 0 .. (1/2)*N)

value(eval(eq,[N=6]));

cos(6*t) = cos(t)^6-15*cos(t)^4*sin(t)^2+15*cos(t)^2*sin(t)^4-sin(t)^6


An undocumented implementation of that.

eval("full angle reduction",trigsubs(cos(6*t),annotate));

cos(t)^6-15*cos(t)^4*sin(t)^2+15*cos(t)^2*sin(t)^4-sin(t)^6

 

Download multiple_angle_reduction.mw

To assign to x,

   x := log[2](6);

Note the distinction between the exact symbolic result and the float-approximation.

log[2](6);
                                                                                        
                   ln(6)
                   -----
                   ln(2)

log[2](6.0);                                                                                      

                 2.584962501

What version of Maple are you using, and which platform (Operating System)?

restart;
kernelopts(version);

   Maple 2019.1, X86 64 LINUX, May 21 2019, Build ID 1399874

Optimization:-LPSolve(4*x1+5*x2+5*x3+2*x4,
                      {33*x1 + 49*x2 + 51*x3 + 22*x4 <= 120},
                      maximize, assume ={nonnegint},
                      depthlimit=10); 

          [13, [x1 = 2, x2 = 1, x3 = 0, x4 = 0]]

Optimization:-Maximize(4*x1+5*x2+5*x3+2*x4,
                       {33*x1 + 49*x2 + 51*x3 + 22*x4 <= 120},
                       assume=nonnegint, depthlimit=10);

          [13, [x1 = 2, x2 = 1, x3 = 0, x4 = 0]]

I get the same results using Maple 16.02 for 64bit Linux.

Here is one way to do that.
replaceid_example.mw

Here is another way, using readstat for the original query.
readstat_example.mw

I await the followup, "What I actually want to do is..."

First 141 142 143 144 145 146 147 Last Page 143 of 336