vv

14122 Reputation

20 Badges

10 years, 203 days

MaplePrimes Activity


These are answers submitted by vv

This is a maths problem, not a Maple one. See https://en.wikipedia.org/wiki/Cycles_and_fixed_points

Of course it is easy to implement any of the formulae.

Here is a direct solution (based on simplex) asked by the OP who has an older version of Maple.

FacetsOfPolyhedralCone:=proc(L::list)
local i,j,J,A,X,u;
X:=indets(L,name);
A:=LinearAlgebra:-GenerateMatrix(L,X)[1]:
J:={seq(1..nops(L))}:
for j in J do
  add(A[j]-u[i]*A[i],i=J minus {j}); convert(%,list)=~0;
  if simplex[minimize](0, %, NONNEGATIVE) <>{} then J:=J minus {j} fi;
od:
J, L[[J[]]];
end:

L := [y-z, 3*y-2*z, 2*y-2*z, x-2*y+z, x-y, 2*x-y, x-z, x+y-z, x, y, z]:  # >= 0

FacetsOfPolyhedralCone(L);
      
{3, 4, 11}, [2*y-2*z, x-2*y+z, z]

solve({x[5] = x[2]/x[1], x[6] = x[3]/x[2], x[7] = x[1]/x[4],
       x[8] = (2*x[2]+x[4])/(2*x[1]+x[3]+x[4])}, {x[1], x[2], x[3], x[4]}); 

         {x[1] = 0, x[2] = 0, x[3] = 0, x[4] = 0}

It is a bug. The result of eliminate should be:

Mathematically it should be also added: x[5]<>0, x[7]<>0, x[4]<>0,  x[6] <> -(2*x[7]+1)/(x[5]*x[7])

@mmcdara 

Let's do the computations for 3 digits.

restart;
Digits:=3:
a,b,c:= sqrt~([2,3,6])[]:
fa,fb,fc := evalf(%);

                 fa, fb, fc := 1.41, 1.73, 2.45
fa*fb;
                              2.44
# Do you expect  2.45?  How?
141*173;
                             24393

 

 

num1dsubspaces := (p,n) -> (p^n - 1)/(p-1)

 

ineqs:=
y-z >=0,
3*y-2*z >=0,
2*y-2*z >=0,
x-2*y+z >=0,
x-y >=0,
2*x-y >=0,
x-z >=0,
x+y-z >=0,
x>=0,
y>=0,
z>=0:
with(PolyhedralSets):
A := PolyhedralSet([ineqs]);
B := PolyhedralSet([ineqs[3..4],ineqs[-3..-1]]);

evalb(convert(A,string)=convert(B,string));

        true

Add:

f1,f2,f3:=seq(unapply('evalf'(x__||i),t2), i=1..3):
plot([f1,f2,f3], 0..0.2);

You will not be able to plot over  0 .. Pi/2  because the integrals are not convergent here.

I think that for a listlist L, only the following constructs L[u,v] should be accepted

L[i1..i2, j1..j2],  L[i, j1..j2],  L[i1..i2, j],  L[i, j]

(they are consistent with rtables).

The other ones such as L[[i1,i2,...], [j1,j2,...]] should produce exceptions (errors)
because they are not consistent with rtables and they are not needed: L[u,v]  reduces to L[u][v] in these cases.
 


 

MinVal := proc(p :: Array(datatype=integer[4])
               , lg :: Array(datatype=float[8])
               , pmin :: Array(datatype=integer[4])
               , m :: float
               , K :: float
               , n :: posint
               , len :: posint
              )
local i,j,v,x;
    v := 0.0;
    for i from 0 to n-1 by len do
        x := 0.0;
        for j to len do
            x := x + lg[p[i+j]];
        end do;
        v := v + abs(x - K);
    end do;

    # test for minimum
    if m <= v then
        v := m;
    else
        # update pmin
        for i to n do
            pmin[i] := p[i];
        end do;
    end if;
    return v;
end proc:

Var := proc(L::list(positive)
            , len :: posint
            , num :: posint
           )
local M, P, i, j, K, lg, n, p, pmin;
    n := numelems(L);
    if len*num <> n then
        error "invalid partition specification";
    end if;

    # allocate arrays used by MinVal
    pmin := Array(1..n, 'datatype'=integer[4]);

    lg := Array(evalf(ln~(L)),'datatype'=float[8]);
    K := add(i, i=lg)/num;
    M := K*len;

    P := Iterator:-SetPartitionFixedSize([len$num]);

    for p in P do
        M := MinVal(p, lg, pmin, M, K, n, len);
    end do;

    return ListTools:-LengthSplit(convert(pmin,list), len);

end proc:

L := [1829.0, 1644.0, 1594.0, 1576.0, 1520.0, 1477.0, 1477.00, 1404.0
      , 1392.0, 1325.0, 1313.0, 1297.0, 1292.0, 1277.0, 1249.0, 1236.0]:
 

MinVal := Compiler:-Compile(MinVal):
CodeTools:-Usage((Var)(L, 4, 4));

memory used=405.19MiB, alloc change=-1.00MiB, cpu time=8.58s, real time=8.59s, gc time=109.20ms

 

[1, 9, 13, 15], [2, 4, 14, 16], [3, 6, 10, 11], [5, 7, 8, 12]

(1)

indxs:=[%[1..4]]:
vals := [A||(1..16)]:
map(i->vals[i], indxs);
map(i->L[i], indxs);

[[A1, A9, A13, A15], [A2, A4, A14, A16], [A3, A6, A10, A11], [A5, A7, A8, A12]]

 

[[1829.0, 1392.0, 1292.0, 1249.0], [1644.0, 1576.0, 1277.0, 1236.0], [1594.0, 1477.0, 1325.0, 1313.0], [1520.0, 1477.00, 1404.0, 1297.0]]

(2)

 


 

Download compiled.mw

plot3d wants a list of 3 procedures but receives a single procedure (which is list-valued).

Your double series are very delicate to approximate.
If you are really interested in them (and not just trying to crash Maple or even the OS),
you should study carefully the convergence and do not rely on Maple's general algorithms which are not suitable in this case.

The quality and the memory usage are much better if the surfaces are parametrized:

el:=[x=9/2*sin(phi)*cos(theta),y=6*sin(phi)*sin(theta), z=3*cos(phi)]:
sp:=[x=4*sin(phi)*cos(theta),y=4*sin(phi)*sin(theta), z=4*cos(phi)]:
phi1 := arccos(sqrt((63*cos(theta)^2-80)/(63*cos(theta)^2-108))):
phi2:=Pi-phi1:
p1:=plot3d(rhs~(el), theta=0..2*Pi,phi=phi1..phi2,color=blue,style=surface):
p2:=plot3d(rhs~(sp), theta=0..2*Pi,phi=0..Pi,color=red,style=surface):
p3:=plots:-spacecurve( eval(1.02*rhs~(el),phi=phi1), theta=0..2*Pi ,color=yellow, thickness=2):
p4:=plots:-spacecurve( eval(1.02*rhs~(el),phi=phi2), theta=0..2*Pi ,color=yellow, thickness=2):
plots:-display(p1,p2,p3,p4,scaling=constrained);

For b=1 the determinant seems to be

and the coefficients can be expressed wrt Stirling1.
For a general b the expression is for sure more complicated.

(for b=0 it is of course simple).

 

The warnings generated by the interface (as Acer said) are caused by the fact that a string
is spread on multiple lines (it is not related to "\").

As a workaround you may end each line with "\n\"  (no space after \).

process_file := proc()
  local str,fileName;

  fileName := "output.txt";
  
  str:="\n\
   \\begin{align*}\n\
     A =& B  \\\\\n\
       =& 3\n\
   \\end{align*}\n\
  ";
	
  writebytes(fileName, str);
  close(fileName);
end proc:

But (again as Acer said) isn't it more natural to have the (true) latex string in a file,
then read it (e.g. with readbytes), manipulate it if necessary (e.g. with StringTools) and finally write it back in a file?

First 78 79 80 81 82 83 84 Last Page 80 of 121