Joe Riel

9530 Reputation

23 Badges

20 years, 25 days

MaplePrimes Activity


These are answers submitted by Joe Riel

You can do this with ?VolumeOfRevolution. For example

with(Student[Calculus1]):
y := sqrt(r^2-x^2):
a := int(y, x=-r..r) assuming r>0;
                            1  2   
                            - r  Pi
                            2      
v := VolumeOfRevolution(y,x=-r..r);
                            4  3   
                            - r  Pi
                            3      
solve({a=A,v=V},{V,r},Explicit);
   /           (1/2)       (1/2)         (1/2)       (1/2)\   
   |      8 A 2      (Pi A)             2      (Pi A)     |   
  < V = - ----------------------, r = - ------------------ >,
   |               3 Pi                         Pi        |   
   \                                                      /   

     /         (1/2)       (1/2)       (1/2)       (1/2)\
     |    8 A 2      (Pi A)           2      (Pi A)     |
    < V = ----------------------, r = ------------------ >
     |             3 Pi                       Pi        |
     \                                                  /

Click the component in the MapleSim editor, to view its parameters. In the parameter inspector there is an Advanced Variables Setting section.  It lists the unresolved override, Q[mistura].  Click the garbage can icon adjacent to it to revert it.  You should now be able to simulate with no warnings.

Let eqs be your set of equations.  Then do

eqs1 := subsindets(eqs, indexed, convert, symbol):

pass that set to the RealRootCounting.  To convert the solution back you can do

subsindets(sol, symbol, parse);

You can do this using the Iterator package available in the Application Center

s := hashmset:-new( [ a, 4 ], [ c,3 ] );
S := hashmset:-entries(s):
with(Iterator):
iter := MixedRadixTuples([seq(e[2]+1, e=S)]
                         , transformer = ( V -> {seq}(`if`(V[i]=0
                                                           , NULL
                                                           , [op([i,1],S),V[i]]
                                                          )
                                                      , i=1..upperbound(V)))
                        ):
seq(v, v=iter);
     {}, {[c, 1]}, {[c, 2]}, {[c, 3]}, {[a, 1]}, {[a, 1], [c, 1]}, {[a, 1], [c, 2]},
    {[a, 1], [c, 3]}, {[a, 2]}, {[a, 2], [c, 1]}, {[a, 2], [c, 2]},
    {[a, 2], [c, 3]}, {[a, 3]}, {[a, 3], [c, 1]}, {[a, 3], [c, 2]},
    {[a, 3], [c, 3]}, {[a, 4]}, {[a, 4], [c, 1]}, {[a, 4], [c, 2]},
    {[a, 4], [c, 3]}


plot([seq([i,a[i]], i=0..100);

Be aware that ?length uses a naive computation that doesn't account for common terms. For example

(**) L := [seq(1..100)]:  
(**) length(L);
                                                         295

(**) length([L$100]);
                                                        29603

The "actual" word length of that is significantly smaller, around  300.

Because continuity was not specified

 L:=[f(-6)=2400, f(-4)=432, f(-3)=120, f(-2)=16, f(-1)=0, f(0)=0, f(1)=-8, f(2)=0]:
 f := unapply(piecewise(seq('x=op(lhs(eq)),rhs(eq)', eq=L), x), 0):

Actually, the clever way to do this is

f := ()->0:
assign(op(eval(L,1)));



Events generally occur when conditionals in the model change.  For example, a step is modeled as

y = if time < 1 then 0 else 1;

At time = 1 an event occurs. This snippet is written in Modelica, which MapleSim uses as the model language.  MapleSim parses the Modelica language, generates Maple code with events that can be handled by dsolve (it's significantly more complicated than that, but that's the basic idea).

 

Use simplify with side-relations, see ?simplify[siderels]

p := x^10*y^2+x^9*y^8+x^7*y^3+x^5*y+x*y+y:

eqs := {NULL
        , x^3=a*x+y
        , x^2*y=b*x+c*y
        , x*y^2=x+d*y
        , y^3=e*y
       }:

simplify(p, eqs);
 4    3      4    2      3  4        2  2  3      4          4    2    4
a  d e  y + a  d e  y + a  e  y + 3 a  d  e  y + a  b x y + a  c y  + a  d e y

          2  2  2            4      4          3    2      2  2
     + 6 a  d  e  y + 3 a d e  y + a  d y + 5 a  d y  + 9 a  d  e y

              3      5      4        3           2             2
     + 3 a d e  y + e  y + a  x + 5 a  x y + 12 a  b d y + 12 a  c e y

          2    2            2            2          2        2          2
     + 4 a  e y  + 5 a b d y  + 5 a c e y  + 3 a d e  y + 3 a  b x - 9 a  c y

        2                                      2                2
     + a  x y + 5 a b x y + 3 a d e y + 2 d e y  + 3 a d y + a y  + b x y

          2        2
     + c y  + 2 d y  + 3 a x + 3 x y + y


You can do

A := ImportMatrix("A.txt"):
B := ImportMatrix("B.txt"):
C := ImportMatrix("C.txt"):

with(DynamicSystems):

ss := StateSpace(A,B,C):

BodePlot(ss, range = 0.1..100);

The system has 2 inputs and 14 outputs, so you get 28 superimposed plots.  You can plot just one by doing, say

BodePlot(ss, range = 0..1000, subsystem=[1,2]);

Is the source for the procedures text files or a Maple worksheet?  If the former, just use a text editor to search/replace Return with return. For a Maple worksheet you could do the same provided you used Maple input format rather than 2D format as the input region. That is, edit the *.mw file in text editor and change Return(whatever) to return whatever. If you used 2D format, select everything in the worksheet (Ctrl-A), right click, pick 2D Math -> convert -> 1D Math input.  Save the worksheet, open in an editor, change as described above.  If you prefer the 2D input, then reopen the worksheet, select all, and convert all input back to 2D input.

If you have to convert between 2D and 1D math, I'd be sure to save a backup of the worksheet before changing anything.

 

 

pde := { diff(u(x,t),t) = k*diff(u(x,t),x,x) };
bc := { u(0,t)=0, u(l,t)=0, u(x,0)=exp(-x) };

pdsolve(pde union bc) assuming l>0;
          infinity
           -----
            \
u(x, t) =    )
            /
           -----
          _Z2~ = 1

    /                                        2     2        3                \
    |                           _Z2~      -Pi  _Z2~  k t - l       Pi _Z2~ x |
    |  2 Pi _Z2~ (-exp(l) + (-1)    ) exp(-------------------) sin(---------)|
    |                                              2                   l     |
    |                                             l                          |
    |- ----------------------------------------------------------------------|
    |                                2     2    2                            |
    \                              Pi  _Z2~  + l                             /


I'm not clear on what you are doing (nor how to interpret zero.ta[2]) but you could try the following

cfs := {coeffs}(p,x):
eqs := map(`=`, cfs, zero_ta[2]*beta[3]*beta[4]*omega^2);
sol := [solve(eqs)];

That gives six different solutions, however, I don't know what are parameters and what are constants.

This algorithm returns duplicates and also misses some paths.  To see that execute Routes(4,2) and inspect the first two results (T[1] and T[2]).  With duplicates removed, it returns only 82 paths for Route(4,1), the correct answer is easily computed to be 3*4 + 5*8 + 8*4 = 84.

I believe the correct result, for Routes(4,6), is 68272. I computed that using a simpler approach, an extension to the Iterator package I've recently described.

Addendum

The original code for Routes give the correct answer for Routes(4,1), 84.  It is my modification of it that is flawed for that case. However, the original is incorrect with Routes(4,2), it has the duplicates I've mentioned. 

Further Add

Actually, while the original code does return 84 for Routes(4,1), it returns only 82 unique routes.

Correction

The bug is in the points used for the left side; there is a duplicate.  With that fixed I get the same results as with the Iterator method. Here is the revised procedure

Routes:=proc(N::posint, n::nonnegint)

global T;
local i,j,L, Rule;

    if n>=N^2 then
        T:=[]:
        0;
    else
        Rule := proc(K)  # Continuation of the route by 1 step
        local S, k, r, rk, p, pts, j;

            S := table();
            j := 0;
            k := nops(K[1]);

            for r in K do
                # Assign pts the points to consider
                if r[k]=[1, 1] then
                    # Bottom left corner
                    pts := [[1, 2], [2, 2], [2, 1]];
                elif r[k]=[1, N] then
                    # Top left corner
                    pts := [[1, N-1], [2, N-1], [2, N]];
                elif r[k]=[N, N] then
                    # Top right corner
                    pts := [[N-1, N], [N-1, N-1], [N, N-1]];
                elif r[k]=[N, 1] then
                    # Bottom right corner
                    pts := [[N-1, 1], [N-1, 2], [N, 2]];
                elif r[k,1]=1 and r[k,2]<>1 and r[k,2]<>N then
                    # Left side
                    pts := [[1, r[k,2]-1], [2, r[k,2]-1], [2, r[k,2]], [2, r[k,2]+1], [1, r[k,2]+1]];
                elif r[k,2]=N and r[k,1]<>1 and r[k,1]<>N then
                    # Top side
                    pts := [[r[k,1]-1, N], [r[k,1]-1, N-1], [r[k,1], N-1], [r[k,1]+1, N-1], [r[k,1]+1, N]];
                elif r[k,1]=N and r[k,2]<>1 and r[k,2]<>N then
                    # Right side
                    pts := [[N, r[k,2]+1], [N-1, r[k,2]+1], [N-1, r[k,2]], [N-1, r[k,2]-1], [N, r[k,2]-1]];
                elif r[k,2]=1 and r[k,1]<>1 and r[k,1]<>N then
                    # Bottom side
                    pts := [[r[k,1]-1, 1], [r[k,1]-1, 2], [r[k,1], 2], [r[k,1]+1, 2], [r[k,1]+1, 1]];
                elif r[k,1]<>1 and r[k,1]<>N and r[k,2]<>1 and r[k,2]<>N then
                    # Inside
                    pts := [[r[k,1]-1, r[k,2]-1], [r[k,1]-1, r[k,2]], [r[k,1]-1, r[k,2]+1], [r[k,1], r[k,2]+1], [r[k,1]+1, r[k,2]+1], [r[k,1]+1, r[k,2]], [r[k,1]+1, r[k,2]-1], [r[k,1], r[k,2]-1]];
                fi;
                rk := r[1..k-1];
                j := j+1;
                S[j] := seq(`if`(member(p,rk)
                                 , NULL
                                 , [op(r),p]
                                ), p = pts);
            od;
            [seq(S[j], j=1..j)];
        end proc;

        L:=[seq(seq([[i, j]], j=1..N), i=1..N)];
        T:=(Rule@@n)(L);
        nops(T);  # Number of all the routes
    fi;
end proc:

As Carl points out, this is a weird kernel/gui bug.  To work around it, terminate the call to dsolve with a colon (so nothing is printed). You can then use soltn as desired:

(**) eqn1 := diff(R1(r),r) + I*R2(r) = 0:
(**) eqn2 := diff(R2(r),r) + R1(r) = 0:
(**) st := 1.3:
(**) fn := 4.3:
(**) soltn := dsolve([eqn1,eqn2,R1(st)=0.1,R2(st)=0.2], [R1(r),R2(r)], numeric, range=st..fn): # terminate with a colon
(**) soltn(2);
   [r = 2., R1(r) = 0.110429803108025 - 0.115236213462622 I, R2(r) = 0.128139507027451 + 0.0432522993325482 I]

Correction:

My work-around doesn't really do anything other than prevent the message from being displayed. Originally I hadn't realized that soltn was being assigned correctly, regardless. I've submitted this as an SCR. The bug lies in the display of soltn. To see that, execute

print(soltn);
                       Non-fatal error while reading data from kernel.
First 33 34 35 36 37 38 39 Last Page 35 of 114