pagan

5022 Reputation

23 Badges

13 years, 203 days

 

 

"A map that tried to pin down a sheep trail was just credible,

 but it was an optimistic map that tried to fix a the path made by the wind,

 or a path made across the grass by the shadow of flying birds."

                                                                 - _A Walk through H_, Peter Greenaway

 

MaplePrimes Activity


These are answers submitted by pagan

restart:
EQ1:=FIO2->1/(23400/(RootOf(2.370283616*10^32+5.594099736*10^39*FIO2^6
-2.566921293*10^39*FIO2^5+4.499329118*10^38*FIO2^4-3.827035974*10^37*FIO2^3
+1.664505430*10^36*FIO2^2+6.537571995*10^38*FIO2^7-3.517488009*10^34*FIO2
+(3.296297826*10^30-4.050972663*10^36*FIO2^6+1.296151899*10^36*FIO2^5
-1.958906210*10^35*FIO2^4+1.280269633*10^34*FIO2^3+1.516246969*10^32*FIO2^2
+4.190751278*10^36*FIO2^7-7.689026410*10^31*FIO2)*_Z+(-5.821264056*10^33*FIO2^6
+2.589086285*10^33*FIO2^5-4.492526189*10^32*FIO2^4+3.764957922*10^31*FIO2^3
-1.534171806*10^30*FIO2^2+2.167294874*10^28*FIO2+2.591722946*10^26)*_Z^2
+(-3.880842701*10^31*FIO2^6+1.726057524*10^31*FIO2^5-2.995017460*10^30*FIO2^4
+2.509971949*10^29*FIO2^3-1.022781204*10^28*FIO2^2+1.444863247*10^26*FIO2
+1.727815297*10^24)*_Z^4+(2.170577967*10^28-2.095236980*10^34*FIO2^6
+5.948362924*10^33*FIO2^5-8.387147499*10^32*FIO2^4+4.619574644*10^31*FIO2^3
+2.606369988*10^30*FIO2^2+2.793834187*10^34*FIO2^7-5.351416277*10^29*FIO2)*_Z^3)^3
+150*RootOf(2.370283616*10^32+5.594099736*10^39*FIO2^6-2.566921293*10^39*FIO2^5
+4.499329118*10^38*FIO2^4-3.827035974*10^37*FIO2^3+1.664505430*10^36*FIO2^2
+6.537571995*10^38*FIO2^7-3.517488009*10^34*FIO2+(3.296297826*10^30
-4.050972663*10^36*FIO2^6+1.296151899*10^36*FIO2^5-1.958906210*10^35*FIO2^4
+1.280269633*10^34*FIO2^3+1.516246969*10^32*FIO2^2+4.190751278*10^36*FIO2^7
-7.689026410*10^31*FIO2)*_Z+(-5.821264056*10^33*FIO2^6+2.589086285*10^33*FIO2^5
-4.492526189*10^32*FIO2^4+3.764957922*10^31*FIO2^3-1.534171806*10^30*FIO2^2
+2.167294874*10^28*FIO2+2.591722946*10^26)*_Z^2+(-3.880842701*10^31*FIO2^6
+1.726057524*10^31*FIO2^5-2.995017460*10^30*FIO2^4+2.509971949*10^29*FIO2^3
-1.022781204*10^28*FIO2^2+1.444863247*10^26*FIO2+1.727815297*10^24)*_Z^4
+(2.170577967*10^28-2.095236980*10^34*FIO2^6+5.948362924*10^33*FIO2^5
-8.387147499*10^32*FIO2^4+4.619574644*10^31*FIO2^3+2.606369988*10^30*FIO2^2
+2.793834187*10^34*FIO2^7-5.351416277*10^29*FIO2)*_Z^3))+1):

dEQ1:=D(EQ1):

EQ2:=FIO2->1/(23400/(RootOf(1.416081397*10^32+3.517179894*10^38*FIO2^6
-1.948055013*10^38*FIO2^5+4.312473826*10^37*FIO2^4-4.950444248*10^36*FIO2^3
+3.125448541*10^35*FIO2^2+4.170138662*10^37*FIO2^7-1.035529014*10^34*FIO2
+(1.518306073*10^27-1.515386851*10^33*FIO2^6+5.092037515*10^32*FIO2^5
-8.949417768*10^31*FIO2^4+7.902440100*10^30*FIO2^3-1.392139025*10^29*FIO2^2
+1.782110539*10^33*FIO2^7-2.887126086*10^28*FIO2)*_Z^3+(-2.469562710*10^30*FIO2^6
+1.318541071*10^30*FIO2^5-2.884226435*10^29*FIO2^4+3.275520695*10^28*FIO2^3
-2.014303224*10^27*FIO2^2+6.174067249*10^25*FIO2-6.766154976*10^23)*_Z^4
+(2.119131081*10^29-2.850957952*10^35*FIO2^6+1.072344238*10^35*FIO2^5
-2.017321651*10^34*FIO2^4+1.951837857*10^33*FIO2^3-6.801678075*10^31*FIO2^2
+2.673165809*10^35*FIO2^7-2.885957392*10^30*FIO2)*_Z+(-3.704344067*10^32*FIO2^6
+1.977811606*10^32*FIO2^5-4.326339652*10^31*FIO2^4+4.913281042*10^30*FIO2^3
-3.021454835*10^29*FIO2^2+9.261100879*10^27*FIO2-1.014923247*10^26)*_Z^2)^3
+150*RootOf(1.416081397*10^32+3.517179894*10^38*FIO2^6-1.948055013*10^38*FIO2^5
+4.312473826*10^37*FIO2^4-4.950444248*10^36*FIO2^3+3.125448541*10^35*FIO2^2
+4.170138662*10^37*FIO2^7-1.035529014*10^34*FIO2+(1.518306073*10^27
-1.515386851*10^33*FIO2^6+5.092037515*10^32*FIO2^5-8.949417768*10^31*FIO2^4
+7.902440100*10^30*FIO2^3-1.392139025*10^29*FIO2^2+1.782110539*10^33*FIO2^7
-2.887126086*10^28*FIO2)*_Z^3+(-2.469562710*10^30*FIO2^6+1.318541071*10^30*FIO2^5
-2.884226435*10^29*FIO2^4+3.275520695*10^28*FIO2^3-2.014303224*10^27*FIO2^2
+6.174067249*10^25*FIO2-6.766154976*10^23)*_Z^4+(2.119131081*10^29
-2.850957952*10^35*FIO2^6+1.072344238*10^35*FIO2^5-2.017321651*10^34*FIO2^4
+1.951837857*10^33*FIO2^3-6.801678075*10^31*FIO2^2+2.673165809*10^35*FIO2^7
-2.885957392*10^30*FIO2)*_Z+(-3.704344067*10^32*FIO2^6+1.977811606*10^32*FIO2^5
-4.326339652*10^31*FIO2^4+4.913281042*10^30*FIO2^3-3.021454835*10^29*FIO2^2
+9.261100879*10^27*FIO2-1.014923247*10^26)*_Z^2))+1):

dEQ2:=D(EQ2):

plot([EQ1,EQ2,dEQ1,dEQ2],0.0..1.0,view=0..1,legend=[EQ1,EQ2,dEQ1,dEQ2]);

ddEQ1:=(D@@2)(EQ1):
ddEQ2:=(D@@2)(EQ2):

evalf(ddEQ1(0.6));
evalf(ddEQ2(0.6));

plot([ddEQ1,ddEQ2],0.0..1.0,view=-10..10,legend=[ddEQ1,ddEQ2]);

f:=x->(x^2 + 2*m*x + m + 1)/(x -1);

g:=unapply(simplify(diff(f(x),x)),x);

f:=a*(p-ps)+b*(p-ps-b*ys/a+E-ys)=0:

p=map(simplify,collect(rhs(isolate(f,p)),[ps,ys]));

                         b ys         b E 
                     p = ---- + ps - -----
                          a          a + b

One way is to alter the inert form of the procedure, and then convert back. But be careful in that (if you want it saved to re-use) you'd have to savelib the whole package and not just the altered package local (proc).

restart:

f:=x->x^3-3*x^2+2:
g:=x->k*(x+1)+3:

eqs:={f(x) = g(x), diff(f(x),x) = diff(g(x),x)}:

sol:=[solve(eqs,[x,k])]:
map(allvalues,sol):
simplify(fnormal(evalf(%))):
sort(%);

          [[[x = -1.810037930, k = 20.68893950]], 

            [[x = 0.1682544023, k = -0.9245977830]], 

            [[x = 1.641783527, k = -1.764341714]]]

RootFinding:-Isolate(map((rhs-lhs),eqs),[x,k]):
sort(%);

           [[x = -1.810037929, k = 20.68893949], 

             [x = 0.1682544018, k = -0.9245977795], 

             [x = 1.641783527, k = -1.764341712]]

The help topic hotkeys works, from within the Standard GUI's Help browser. Also see here. which seems to be more on topic for the Greek letters. (It looks like there should be more cross-referencing between these pages.)

In 2D Math mode, you can use Ctl-shift-G to get into "Greek mode", in which typing the letter `a` alone gets a typeset alpha. It works in the reverse order from how you describe Mathcad, ie. you type `Ctl+shift+G` and then `a`.

You can also use the command-completion hotkey sequences, to get alpha (typeset or not, in in 1D or 2D mode accordingly) after having typed the first few letters.

Literally, you've asked to see the contents. You might have meant to ask to see a listing of the contents.

If the question is take literally, to see the contents themselves, then the question isn't very well posed. It's like saying you want to see the contents of a zip file in "human readable form". It depends on what was put into it.

You could read the .m file in a Maple session, and then look at some variation on anames().

I'm not sure if I understand what you mean by "iterated". Are you saying that you want to each updated x(t) to be the rhs driving function of the ODE evaluated at the previous solution y(t)?

restart:

sys:= diff(y(t),t) = cos( 1/2*y(t)-x(t)-Pi^2 ):
ini:= y(0)=10*sqrt(2)/2:

F[0]:=sin:

N:=20:

for i from 1 to N do
   newsys:=subs(x=F[i-1],sys);
   #print(newsys);
   sol[i]:=dsolve([newsys, y(0)=10*sqrt(2)/2], numeric,
                  output=listprocedure, known=F[i-1]):
   eval(y(t),sol[i])(0.2);
   F[i]:=unapply('evalf'(subs(y(t)=eval(y(t),sol[i])(t),x=F[i-1],rhs(sys))),
                 t,numeric,proc_options=[remember]):
end do:

plot([seq(F[k],k=1..N)],0.1..2.0,legend=[seq(F[k],k=1..N)],
     color=[seq(RGB(0,1/(N-k+1),0),k=1..N)],thickness=2);

It's not clear which is your particular problem.

It could be that you've omitted with(LinearAlgebra) and so the ZeroMatrix(33) call is not doing anything. You could first load that whole package, or you could call individual commands with their long form such as LinearAlgebra:-ZeroMatrix(33). See the help page on using packages.

Note that the result of a ZeroMatrix() call, by default has 'compact' form (empty storage), and is a 33x33 Matrix whose entries are all zero when accessed, but which cannot subsequently be changed.

If you just want a 33x33 size Matrix whose entries you can assign to and change later on, then just use the command Matrix(33) or Matrix(33,33), or ZeroMatrix(33,compact=false).

Also, by default a Matrix of size larger than 10 will display in the Standard GUi with a terse display, like,

                          [ 33 x 33 Matrix       ]
                          [ Data Type: anything  ]
                          [ Storage: rectangular ]
                          [ Order: Fortran_order ]

That's just a display issue. The Matrix is still there and all available. If you ever want to see the whole thing then you could adjust the display cutoff with the command. Eg.

interface(rtablesize=100);

You can control the size (and resolution) of an exported plot in two ways:

1) use the `plotsetup` command to make Maple display the plot straight to a file, and use that commands options to set the size of the output.

or, keeping the diplsya of the plot inlined in the GUI,

2) increase the actual size of the plot frame. The larger the plot's displayed image, the finer the resoution of what is exported (as well as the greater size) using the right-click context-sensitive menu.

You can downsize the image *AFTER* exporting, and often retain greater resolution.

For example, small symbolsize will show up (no matter how densely clustered in the plot) *ONLY* if the plot's displayed image is large enough. Yes, this is a very bad design.

I don't know how you're exporting it right now (command, or right-click). Perhaps this can help.

As Joe mentions, your implementation is not allowing f to see the value of numccs which was assigned inside conscongs (where it is declared as a local).

There are a number of different ways to deal with that. Here are four below, following a shortened version of the failed attempt. (I would prefer the first two workarounds over the last two.)

restart: # your failure
c:=proc() local numccs;
     numccs:=1;
     f();
   end proc:
f := proc() local i;
       for i from 1 to numccs do print(ok);
       end do;
     end proc:

c();
Error, (in f) final value in for loop must be numeric or character

restart: # passing value
f := proc(num) local i;
       for i from 1 to num do print(ok);
       end do;
     end proc:
c:=proc() local numccs;
     numccs:=1;
     f(numccs);
   end proc:

c();
                               ok

restart: # module local
m:=module() export c, f; local numccs;
   c:=proc() numccs:=1; f(); end proc:
   f := proc() local i;
          for i from 1 to eval(numccs) do print(ok);
          end do;
        end proc:
end module:

m:-c();
                               ok

restart: # lexical scoping
c:=proc() local numccs, f;
     f := proc() local i;
            for i from 1 to eval(numccs) do print(ok);
            end do;
         end proc:
     numccs:=1;
     f();
   end proc:

c();
                               ok

restart: # global
f := proc() global numccs; local i;
       for i from 1 to numccs do print(ok);
       end do;
     end proc:
c:=proc() global numccs;
     numccs:=1;
     f();
   end proc:

c();
                               ok

rtables (ie. Vector, Array, Matrix) evaluate differently. Partly, this is so that they don't get evaluated as full copies when passed as arguments to procedures (thus allowing efficiency, and also allowing inplace operations).

restart:

formula:=Vector([3*i]);
                              formula := [3 i]


seq(formula,i=4..7);
                         [3 i], [3 i], [3 i], [3 i]


seq(rtable_eval(formula),i=4..7);
                           [12], [15], [18], [21]

And using the given example,

formula:=Vector(3, [3,y,11-4*y]);

                                       [   3    ]
                                       [        ]
                            formula := [   y    ]
                                       [        ]
                                       [11 - 4 y]


seq(formula,y=0..10);

  [   3    ]  [   3    ]  [   3    ]  [   3    ]  [   3    ]  [   3    ]  
  [        ]  [        ]  [        ]  [        ]  [        ]  [        ]  
  [   y    ], [   y    ], [   y    ], [   y    ], [   y    ], [   y    ], 
  [        ]  [        ]  [        ]  [        ]  [        ]  [        ]  
  [11 - 4 y]  [11 - 4 y]  [11 - 4 y]  [11 - 4 y]  [11 - 4 y]  [11 - 4 y]  

    [   3    ]  [   3    ]  [   3    ]  [   3    ]  [   3    ]
    [        ]  [        ]  [        ]  [        ]  [        ]
    [   y    ], [   y    ], [   y    ], [   y    ], [   y    ]
    [        ]  [        ]  [        ]  [        ]  [        ]
    [11 - 4 y]  [11 - 4 y]  [11 - 4 y]  [11 - 4 y]  [11 - 4 y]


seq(rtable_eval(formula),y=0..10);

     [ 3]  [3]  [3]  [ 3]  [ 3]  [ 3]  [  3]  [  3]  [  3]  [  3]  [  3]
     [  ]  [ ]  [ ]  [  ]  [  ]  [  ]  [   ]  [   ]  [   ]  [   ]  [   ]
     [ 0], [1], [2], [ 3], [ 4], [ 5], [  6], [  7], [  8], [  9], [ 10]
     [  ]  [ ]  [ ]  [  ]  [  ]  [  ]  [   ]  [   ]  [   ]  [   ]  [   ]
     [11]  [7]  [3]  [-1]  [-5]  [-9]  [-13]  [-17]  [-21]  [-25]  [-29]

You could also do it in a more usual manner by creating a procedure.

formula:=Vector(3, [3,y,11-4*y]):

func:=unapply(formula,:-y):
seq(func(y),y=0..10);

Using a 2-d variant of this post, you can construct a procedure that will take a scalar and return the interpolated value.

restart:

# independent data
indep := Vector([260., 270., 280., 290., 300., 310., 320., 330., 340., 350., 360.]):

# number of independent data points
numindeppts := LinearAlgebra:-Dimension(indep):

# some made up dependent data
dep := Vector(numindeppts, (i)->evalf(sin(indep[i]^2)), datatype=float[8]):

# procedure which interpolates the data, on the fly
B := (a) -> CurveFitting:-ArrayInterpolation(
                               indep, Array(dep),
                               Array(1..1, 1..1, [[a]]),
                               'method' = 'spline')[1]:

ptsplot:=plots:-pointplot(Matrix(11,2,[[indep,dep]])):

plots:-display(plot(B,min(indep)..max(indep)),ptsplot);

restart:
randomize():
interface(rtablesize=100):

N:=3:
number:=4:

L:=[seq(LinearAlgebra:-RandomMatrix(N),i=1..number)];

       [[ 58  -42  -62]  [ 62  -47  -79]  [-78  -85  39]  [ -2  -97   92]]
       [[             ]  [             ]  [            ]  [             ]]
  L := [[ 25   23  -88], [ -8  -71   -6], [-38   -3  56], [-13  -31  -34]]
       [[             ]  [             ]  [            ]  [             ]]
       [[-49  -53  -30]  [-15   57   79]  [-73   58  52]  [-86  -37  -92]]

M:=Matrix((N-1)*number+1):

for i from 1 to number do
   sz := (N-1)*(i-1)+1;
   M[sz..sz+N-1,sz..sz+N-1]:=
   M[sz..sz+N-1,sz..sz+N-1]+L[i];
end do:

M;

                [ 58  -42  -62    0    0    0    0    0    0]
                [                                           ]
                [ 25   23  -88    0    0    0    0    0    0]
                [                                           ]
                [-49  -53   32  -47  -79    0    0    0    0]
                [                                           ]
                [  0    0   -8  -71   -6    0    0    0    0]
                [                                           ]
                [  0    0  -15   57    1  -85   39    0    0]
                [                                           ]
                [  0    0    0    0  -38   -3   56    0    0]
                [                                           ]
                [  0    0    0    0  -73   58   50  -97   92]
                [                                           ]
                [  0    0    0    0    0    0  -13  -31  -34]
                [                                           ]
                [  0    0    0    0    0    0  -86  -37  -92]

And as a procedure,

overlap:=proc(LL::list(Matrix(square)))
  local i, n, numb, m, rng, sz;
  n := op([1,1],LL[1]);
  numb := nops(LL);
  m:=Matrix((n-1)*numb+1):
  for i from 1 to numb do
    sz := (n-1)*(i-1)+1;
    rng := sz..sz+n-1;
    m[rng,rng] := m[rng,rng]+LL[i];
  end do:
  m;
end proc:

overlap(L);

                [ 58  -42  -62    0    0    0    0    0    0]
                [                                           ]
                [ 25   23  -88    0    0    0    0    0    0]
                [                                           ]
                [-49  -53   32  -47  -79    0    0    0    0]
                [                                           ]
                [  0    0   -8  -71   -6    0    0    0    0]
                [                                           ]
                [  0    0  -15   57    1  -85   39    0    0]
                [                                           ]
                [  0    0    0    0  -38   -3   56    0    0]
                [                                           ]
                [  0    0    0    0  -73   58   50  -97   92]
                [                                           ]
                [  0    0    0    0    0    0  -13  -31  -34]
                [                                           ]
                [  0    0    0    0    0    0  -86  -37  -92]

Judging by (what I hope is) text representation of your output, it looks like you might have accidentally created your Matrices with the wrong orientations. Doing A.B for A a 2x1 Matrix and B a 1x2 Matrix will compute an outer product and result in a 2x2 Matrix.

 

This works for me

> restart:

> b2 := zeta -> Matrix([[-y(zeta)], [-x(zeta)]])^%T:

> N0 := zeta -> Matrix([[(1-zeta)], [(zeta)]]):

> b2(zeta); # 1x2

                            [-y(zeta)  -x(zeta)]

> N0(zeta); # 2x1

                                 [1 - zeta]
                                 [        ]
                                 [  zeta  ]

> b2(zeta) . N0(zeta); # 1x1

                    [-y(zeta) (1 - zeta) - x(zeta) zeta]

I don't understand why you're creating b2, N0, and B2 as operators instead of expressions, if you're just going to use them by applying them to the name zeta. It's also a bit unclear whether you mean -x*zeta or -x(zeta) a function application. And did you make a typographic error, using `be` instead of `b2`?

It looks like you might have accidentally done this. Notice the difference in the bracketing inside the calls to the Matrix constructor.

> restart:

> b2 := zeta -> Matrix([[-y(zeta), -x(zeta)]])^%T;

                                                      %T
                    b2 := zeta -> [-y(zeta)  -x(zeta)]  

> N0 := zeta -> Matrix([[(1-zeta), (zeta)]]);

                       N0 := zeta -> [1 - zeta  zeta]

> b2(zeta); # 2x1

                                 [-y(zeta)]
                                 [        ]
                                 [-x(zeta)]

> N0(zeta); # 1x2

                              [1 - zeta  zeta]

> b2(zeta) . N0(zeta); # 2x2

                    [-y(zeta) (1 - zeta)  -y(zeta) zeta]
                    [                                  ]
                    [-x(zeta) (1 - zeta)  -x(zeta) zeta]
5 6 7 8 9 10 11 Last Page 7 of 48