Joe Riel

9660 Reputation

23 Badges

20 years, 12 days

MaplePrimes Activity


These are replies submitted by Joe Riel

with(LinearAlgebra):
M := <<m+lambda|m>,<m|2*m>>:
detM := LinearAlgebra:-Determinant(M):

for l to 2 by 0.2 do
    fsol := [fsolve(eval(detM, lambda=l), {m})];
    Ml := map(subs, fsol, lambda=l, M);
    EM := map([Eigenvectors], Ml); # note that the procedure is enclosed in a list, that wraps its output in a list
    print(l, Ml, EM);
end do:

with(LinearAlgebra):
M := <<m+lambda|m>,<m|2*m>>:
detM := LinearAlgebra:-Determinant(M):

for l to 2 by 0.2 do
    fsol := [fsolve(eval(detM, lambda=l), {m})];
    Ml := map(subs, fsol, lambda=l, M);
    EM := map([Eigenvectors], Ml); # note that the procedure is enclosed in a list, that wraps its output in a list
    print(l, Ml, EM);
end do:

use ?LinearAlgebra[EigenVectors]

use ?LinearAlgebra[EigenVectors]

with(LinearAlgebra):
M := <<m+lambda|m>,<m|2*m>>:
detM := LinearAlgebra:-Determinant(M):

for l to 2 by 0.1 do
    fsol := [fsolve(eval(detM, lambda=l), {m})];
    print(l, map(subs, fsol, lambda=l, M));
end do:
                             [-1.    -2.]  [1     0.]
                         1, [[          ], [        ]]
                             [-2.    -4.]  [0.    0.]

                    [-1.100000000    -2.200000000]  [1.1    0.]
              1.1, [[                            ], [         ]]
                    [-2.200000000    -4.400000000]  [0.     0.]
...
with(LinearAlgebra):
M := <<m+lambda|m>,<m|2*m>>:
detM := LinearAlgebra:-Determinant(M):

for l to 2 by 0.1 do
    fsol := [fsolve(eval(detM, lambda=l), {m})];
    print(l, map(subs, fsol, lambda=l, M));
end do:
                             [-1.    -2.]  [1     0.]
                         1, [[          ], [        ]]
                             [-2.    -4.]  [0.    0.]

                    [-1.100000000    -2.200000000]  [1.1    0.]
              1.1, [[                            ], [         ]]
                    [-2.200000000    -4.400000000]  [0.     0.]
...

A curious mix (the logical negation and superfluous parentheses).  Ignoring that, I'm failing to see how this can work in Maple.  Maybe this is what you had in mind,

cas := proc(x::evaln, tst, new)
    eval(x) = tst and `and`(assign(x,new),true)
end proc:

incr := proc(a::evaln, b)
local tmp;
    tmp := eval(a);
    while not cas( a, tmp, tmp+b ) do
        tmp := a;
    end do;
    NULL;
end proc:

x := 1:
incr(x,1):
x;
                          2

For the ImageTools suggestion, could you expand on it?  Did you see, for example, www.mapleprimes.com/forum/removewatermark#comment-32064, which demonstrates, I think, what you want.  Possibly you have a particular syntax in mind?

Yes, that is easier and is probably appropriate for the user. 

The disadvantage is that f is called repeatedly during the sort process.  Also, user-defined procedures in a sort are significantly slower than the built comparison.  Both those are probably not a concern unless the number of elements to handle is reasonably large. 

Possibly I should prepend a "slightly esoteric technique" disclaimer to my suggestion with an explanation of where it might be useful.  It is good that you suggested a simpler approach.

It might be nice if the min/max functions provided a means to supply a user-defined comparator, that would avoid the modest expense of a full sort.  Say min[(a,b)->f(a)<f(b)](X) would return -1.

 

Yes, that is easier and is probably appropriate for the user. 

The disadvantage is that f is called repeatedly during the sort process.  Also, user-defined procedures in a sort are significantly slower than the built comparison.  Both those are probably not a concern unless the number of elements to handle is reasonably large. 

Possibly I should prepend a "slightly esoteric technique" disclaimer to my suggestion with an explanation of where it might be useful.  It is good that you suggested a simpler approach.

It might be nice if the min/max functions provided a means to supply a user-defined comparator, that would avoid the modest expense of a full sort.  Say min[(a,b)->f(a)<f(b)](X) would return -1.

 

Yes, you are correct.  The O's are distinct local local variables that display the same but are really different.

Yes, you are correct.  The O's are distinct local local variables that display the same but are really different.

Yes, [x,y,x](t) is evaluated by Maple to [x(t),y(t),z(t)], so it is a convenient shortcut.

[{`*`,`+`,list},{}] is the third (optional) argument to ?frontend.  The two sets in the list specify objects not to freeze; the first is a set of types that won't be frozen, the second is a set of names.  What we are trying to accomplish is to freeze all functions, but leave the algebraic structure in place.  That is, x(t), y(t), z(t) are frozen (replaced with names), the procedure is applied to the result, then the frozen names are thawed.

Two alternatives, possibly clearer, are [{'Not(anyfunc(identical(t)))'},{}] and [{'Not(identical(x(t),y(t),z(t)))'},{}].

 

Yes, [x,y,x](t) is evaluated by Maple to [x(t),y(t),z(t)], so it is a convenient shortcut.

[{`*`,`+`,list},{}] is the third (optional) argument to ?frontend.  The two sets in the list specify objects not to freeze; the first is a set of types that won't be frozen, the second is a set of names.  What we are trying to accomplish is to freeze all functions, but leave the algebraic structure in place.  That is, x(t), y(t), z(t) are frozen (replaced with names), the procedure is applied to the result, then the frozen names are thawed.

Two alternatives, possibly clearer, are [{'Not(anyfunc(identical(t)))'},{}] and [{'Not(identical(x(t),y(t),z(t)))'},{}].

 

It probably makes sense to express the burn rate as a differential equation and combine it with the others. Knowing little about rocketry I would think that the burn rate is constant, rather than proportional to the fuel (which the exponential implies).  That could be expressed as

deqs := { v(t) = diff(x(t),t),
          m(t)*diff(v(t),t) + diff(mf(t),t)*u + m(t)*g = 0,
          m(t) = mb + mf(t),
          diff(mf(t),t) = -gamma(t)
        }:

ics := {x(0)=0, v(0)=0, mf(0)=mf0, gamma(0)=gamma0}:

params := [mb=0.2, mf0=1, gamma0=10, g=9.81, u=8]:

sys := eval(deqs union ics, params);

sol:=dsolve(sys,numeric
            , events = [[v(t) = 0 , 'halt'],    # halt simulation at apogee
                        [mf(t) = 0, gamma(t)=0] # fuel is spent, set burn rate to 0
                       ]
            , discrete_variables = [gamma(t) :: float]
           );
tf := eval(t, sol(10)); # determine the time at which rocket reaches apogee
plots:-odeplot(sol, [[t,x(t)],[t,v(t)]], t=0..tf, color=[black,blue,red],legend=["position","velocity", "fuel"]);
plots:-odeplot(sol, [t,mf(t)], t=0..tf, legend=["fuel"]);

The burn rate could be expressed as a piecewise, say gamma(t) = piecewise(mf(t)>0, gamma0, 0), however, I used a second event to switch it off when the fuel (mf) reached zero.  To enable that, gamma(t) is declared a discrete variable (see ?dsolve[Events]).

 

First 97 98 99 100 101 102 103 Last Page 99 of 195