acer

17602 Reputation

29 Badges

14 years, 188 days

On google groups. (comp.soft-sys.math.maple and sci.math.symbolic)

On stackoverflow.

On math.stackexchange.com.

MaplePrimes Activity


These are answers submitted by acer

It's unclear to me what you're asking. The example you've given seems trivial, to the point that I wonder whether I've misunderstood. Perhaps one of these will do for you.

I am guessing that perhaps it may be the second idea below (using F1) that you're after: as a looped operation, storing produced values in table references, so as to be able to convert at the end to a sequence or list. I am guessing that you already have some other procedure or process generating values in a more complicated loop, and you want to know how to store them so that you can convert afterwards to a sequence or list.

restart

F0 := proc () [seq(i^2, i = 1 .. 5)] end proc

F0()

[1, 4, 9, 16, 25]

F1 := proc () local i, T; for i to 5 do T[i] := i^2 end do; convert(T, list) end proc

F1()

[1, 4, 9, 16, 25]

F2 := proc (f::appliable, rng::(range(integer))) local i; [seq(f(i), i = rng)] end proc

F2(proc (i) options operator, arrow; i^2 end proc, 1 .. 5)

[1, 4, 9, 16, 25]

F3 := proc (f, var, rng::(range(integer))) local i; [seq(eval(f, var = i), i = rng)] end proc

F3(x^2, x, 1 .. 5)

[1, 4, 9, 16, 25]

``

Download MaplePrimes_Example_ac.mw

Do you need to be shown how to read in the contents of a text file as a string?

restart;

str := "How to remove all punctuation marks in a string read from a text file

and then store in a list of words according to the ordering of the original text?":

StringTools:-Words(str);

["How", "to", "remove", "all", "punctuation", "marks", "in", "a", "string", "read", "from", "a", "text", "file", "and", "then", "store", "in", "a", "list", "of", "words", "according", "to", "the", "ordering", "of", "the", "original", "text"]

 

Download words.mw

This is a good one to report.

There are several workarounds for fsolve here (you don't even have to resort to using other commands).

My favorite is the first one, where it works simply by renaming the variables (but with reverse lexicographic order).

restart;

kernelopts(version);

`Maple 2016.2, X86 64 LINUX, Jan 13 2017, Build ID 1194701`

sys := {c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55};

{c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55}

new0 := eval(sys,[a=C,c=A]);

{A*exp(-8*C)+18 = 36, A*exp(-2*C)+18 = 55}

fsolve(new0,{C,A});

{A = 47.04478236, C = .1200910258}

new1 := map(isolate,sys,a);
fsolve(new1);

{a = -(1/8)*ln(18/c), a = -(1/2)*ln(37/c)}

{a = .1200910258, c = 47.04478236}

new2 := map(isolate,sys,c);
fsolve(new2);

{c = 18/exp(-8*a), c = 37/exp(-2*a)}

{a = .1200910258, c = 47.04478236}

map(`/`,sys,c);
fsolve(%);

{(c*exp(-8*a)+18)/c = 36/c, (c*exp(-2*a)+18)/c = 55/c}

{a = .1200910258, c = 47.04478236}

fsolve(sys,{a,c},{a=-5..80});

{a = .1200910258, c = 47.04478236}

fsolve(sys,{a,c},{c=0..infinity});

{a = .1200910258, c = 47.04478236}

 

Download fsysolve_sys.mw

You could get the convenience of loading all of the package, and then selectively unload just the export whose name you wished to utilize.

That allows you to use the remaining exports as their short-form names. And the export corresponding to the special name could still be accessed using its long-form.

For example,

restart;

with(NumberTheory):

unwith(NumberTheory,lambda):

lambda:=5;

5

lambda;

5

NumberTheory:-lambda(222);

36

Divisors(28);

{1, 2, 4, 7, 14, 28}

lambda := n -> (-1)^Omega(n);

proc (n) options operator, arrow; (-1)^NumberTheory:-Omega(n) end proc

lambda(667);

1

NumberTheory:-lambda(667);

308

 

Download unwith_example.mw

Alternatively (as Tom mentioned) you could utilize the global reference :-lambda. In that fashion you could still load the whole package, and get a similar effect.

restart;

with(NumberTheory):

:-lambda:=5;

5

:-lambda;

5

NumberTheory:-lambda(222);

36

Divisors(28);

{1, 2, 4, 7, 14, 28}

:-lambda := n -> (-1)^Omega(n);

proc (n) options operator, arrow; (-1)^NumberTheory:-Omega(n) end proc

:-lambda(667);

1

NumberTheory:-lambda(667);

308

 

Download globalname.mw

Applying unprotect on the special name, after loading the whole package, and then assigning to that name, is not good since it prevents any further access to the package export of that name. It would also break any functionality that depended on the original definition of that export. It actually clobbers that export.

 

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

First 9 10 11 12 13 14 15 Last Page 11 of 204