vv

13832 Reputation

20 Badges

9 years, 317 days

MaplePrimes Activity


These are answers submitted by vv

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?

1) Yes. You must be careful with the escape character \  (see ?backslash)

When a backslash character appears as the last character on an input line, whether typed at the Maple command line, or read from a file, the backslash, and the following line ending, is ignored. In other words, the subsequent line is treated as a continuation of the current line.

So, in your example

str:="
   \\begin{align*}
     A =& B \\\\ # space after the last backslash [delete # and the characters after it]
       =& 3
   \\end{align*}
";

You must also be careful with \b, \t  etc

2)  To read a string from a file you must use e.g.

readbytes(filename, infinity,TEXT)
or
readline(filename);

Note that  read  is designed for Maple code only!

 

Sides w.r.t. altitudes in a triangle

 

# altitudes = [ha,hb,hc]:

sides:=[a,b,c]:

s:=(a+b+c)/2:

formula1 := S=sqrt(s*(s-a)*(s-b)*(s-c)):

formula2 := [a,b,c] =~ [2*S/ha, 2*S/hb, 2*S/hc]:

eval(eval(formula1/S), formula2);

1 = ((S/ha+S/hb+S/hc)*(-S/ha+S/hb+S/hc)*(S/ha-S/hb+S/hc)*(S/ha+S/hb-S/hc))^(1/2)/S

(1)

SS:=solve(factor(normal(%)),S) assuming positive;

ha^2*hb^2*hc^2/(-(ha*hb+ha*hc+hb*hc)*(ha*hb+ha*hc-hb*hc)*(ha*hb-ha*hc+hb*hc)*(ha*hb-ha*hc-hb*hc))^(1/2)

(2)

Vector(eval(formula2,S=SS));

_rtable[18446744074339094270]

(3)

e:=(M/L*T)^a*(M/L^3)^b*(L^2)^c;

simplify(e) assuming positive;
or
combine(expand(e)) assuming positive;

 

It's not a bug (even if eulermac has issues).

 

s := eulermac(1/(n)^(1/3), n, 8)  computes the asymptotic for the indefinite sum.

If you want to obtain the asymptotic for your sum from here, do  eval(s,n=n+1) - eval(s, n=1).

 

But it is better to compute directly:

 

eulermac(1/k^(1/3), k=1..x, 8);

-3/2+(3/2)*x^(2/3)+(1/2)/x^(1/3)-(1/36)/x^(4/3)+(7/4860)/x^(10/3)-(13/26244)/x^(16/3)+(247/590490)/x^(22/3)+O(1/x^(28/3))+_C

(1)

 

Note that now the terms are as expected but a constant _C appears. Actually _C = Zeta(1/3)+3/2 .

We can compute this expansion (including the constant) using:

 

asympt(Sum(1/k^(1/3), k=1..n),n,9);

(3/2)/(1/n)^(2/3)+Zeta(1/3)+(1/2)*(1/n)^(1/3)-(1/36)*(1/n)^(4/3)+(7/4860)*(1/n)^(10/3)-(13/26244)*(1/n)^(16/3)+(247/590490)*(1/n)^(22/3)+O((1/n)^(28/3))

(2)

 

s:=unapply('simplify'(simplify(value(r))),n);

 

This can be done easily but without any benefit for a student!
In order to understand the definition and be able to use it, the student must use pencil+paper+brain; and come back to Maple after that.

You must cut the carpet :-)

a,b,c:=118,58,38;
r:=10;
L:=120;

d:=sqrt(a^2+b^2+c^2):
xt:=a/d*t:
yt:=b/d*t:
zt:=c/d*t: # 0 < t < d
eq:=<x-xt,y-yt,z-zt>^+.<a,b,c> = 0,
    (x-xt)^2+(y-yt)^2+(z-zt)^2 = r^2:
s:=solve({eq,z=0},{x,y,z}, explicit):
t1:=solve(simplify(eval(y,s[1])-eval(y,s[2])), t):
s:=solve({eq,y=0},{x,y,z}, explicit):
t2:=solve(simplify(eval(x,s[1])-eval(x,s[2])), t):
s:=solve({eq,x=0},{x,y,z}, explicit):
t3:=solve(simplify(eval(y,s[1])-eval(y,s[2])), t):
tt:=max(t1,t2,t3) assuming r>0: #(r>0 for symbolics)
maxL=d-2*tt;evalf(%); 'L'=L;

                       a, b, c := 118, 58, 38
                            r := 10
                            L := 120
                 maxL = 2*sqrt(4683)-20*sqrt(4322)*(1/19)
                      maxL = 67.66287620
                            L = 120

So the carpet is too long; for L=120 cm  the max radius is 2.437052665 cm.

 

              

 

                

First 77 78 79 80 81 82 83 Last Page 79 of 120