Carl Love

Carl Love

28070 Reputation

25 Badges

13 years, 28 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

The purpose of this Answer is not to address the relationship that you report between kernel crashes and input mode. While that's a very serious issue (which you've reported clearly), I don't feel like going down that rabbit hole at the moment. Rather, the purpose of this Answer is to advocate that sum (with a minor adjustment) is better than add for this computation. So, I disagree with the other respondents on this point.

Your sum is a geometric sum that can easily be put into a very simple closed form. This was known even to medieval bankers, centuries before the invention of calculus. So, it's a shame that Maple's sum automatically converts this to direct addition of terms (sum does that when the number of terms is small). We can avoid that by making the upper limit of summation temporarily symbolic:

restart:
RR:= 4: #return rate PV/C 
n:= 12:
simplify(sum(1/(1+r)^(155/10/365 + k/%n), k= 1..%n)) assuming %n::posint;
                                      r                 
                     -----------------------------------
                                      /            /1 \\
                                      |            |--||
                            (761/730) |            \%n/|
                     (1 + r)          \-1 + (1 + r)    /

fsolve(value(%) = RR, r);
                                 8.161501788

 

The "Length of output exceeds limit" message is not an error or even a warning. Maple has computed your result. It just chooses to not display it in prettyprinted form. If you want to see the result in plaintext form, use lprint(%).

The presence of this message and whether you see the output has no effect whatsoever on any subsequent command that uses that output.

You can increase the output limit to any value that you want. I recommend that you don't do this. 

The best way to convert an expression sequence into a vector or an expression sequence of vectors into a matrix is to use angle-bracket operators:

f:= x-> <x | x+1>: # *row* vector
test:= <seq(f(i), i= 0..1, 0.1)>; #column of row vectors, i.e., a matrix

#You can plot a 2-column matrix without first extracting its x- and y-vectors:
plot(test, style= pointline);

#extraction of sequence of column vectors (don't know why this would be useful, but you asked):
ColVecs:= seq(test[..,k], k= 1..upperbound(test)[2]);


In your worksheet, you've repeatedly made the mistake of attempting to index a structure with parentheses as in S(1). Square brackets should usually be used for indexing, as in S[1] and test[.., k]. With Vectors, Matrices, and Arrays (known collectively as rtables), in some cases you may use parentheses; this is known as programmer indexing. You used it correctly, albeit haphazardly, in your procedure in your worksheet. I'd recommend that you stay away from this for the time being.

The Maple structures for which square-bracket indexing can be used for member extraction are expression sequences, lists, sets, tables, rtables, modules (which includes Records), and objects that overload `?[]`. Modules may also be indexed as A:-B rather than A[B] if is explicitly an export of the module (in which case I recommend using the :- operator).

Implies(And(d1::even, d2::odd), d1+d2 <= 9);

The prettyprinted output of this will be in standard logical notation.

 

Try this:

TypeTools:-AddType(
    special_polynomial,
    (p, x::name)-> 
    local 
        X, k:= 0,
        T:= subsindets(
            p, 
            identical(x)^{constant, And(name, Not({identical(x), X[posint]}))}, 
            ()-> X[++k]
        )
    ;
        type(T, polynom(anything, {x} union indets(T, X[posint])))
);

Usage:

type(expr, special_polynomial(x));

I don't think that your way is good, for two reasons:

  • I don't think that you understand what Maple's type algebraic is. Look up ?type,algebraic. Surely you don't want x^sin(x) + 1 to be considered a special polynomial.
  • The scanning by remove is only through the top level of an expression--the terms in this case. Looking within the terms requires the deeper scan provided by subsindets (or evalindets). For example, your procedure would not call 3*x^(1/2) + 1 a special polynomial because it doesn't see the x^(1/2) because of the 3.

Also note that Pisqrt(3), etc., are type constant but not type numeric.

The operators numer and denom are mathematical, not purely syntactic like lhs and rhs. It's easy enough to write a syntactic operator to do what you want:

Apparent_Numer_Denom:= (e::`*`)-> 
    ((D,N)-> (N,1/D))(selectremove(type, e, anything^negative))
:
Apparent_Numer_Denom(expr);

 

ProductOfDiagonal:= (M::Matrix)-> mul(ArrayTools:-Diagonal(M));

Trying to guess your next Question, the sum of the k-wise products of the diagonal entries is

SumKwiseProducts:= (M::Matrix, k::nonnegint)-> 
    add(mul~(combinat:-choose([seq](ArrayTools:-Diagonal(M)), k)))
:

plots:-odeplot(sol, [t, diff(x(t), t)], t= 0..20);

mySumOfMatrixDiagonal:= (M::Matrix('square'))-> add(M[k,k]^2, k= 1..upperbound(M)[1]):

For each kis a surface, not a curve, so use plot3d:

y:= k*x*sqrt(z*(1-z)):
plot3d(
    [seq([x,y,z], k= 5..100, 5)], x= 0..1, z= 0..1, 
    color= [seq(COLOR(HUE, .85*(k-5)/95), k= 5..100, 5)], 
    transparency= .15
);


 

Your answer[1] is a set, not an equation. Sets don't have right-hand sides. Here are four ways to proceed:

Map over the set:

rhs~(answer[1]);

Extract the first (and only) element from the set:

rhs(answer[1][1]);

Extract all elements from the set (this only works because there's only one element):

rhs(answer[1][]);

Forget about rhs; use eval instead:

eval(U__T2N, answer[1]);

The eval method is probably the one most commonly used by experienced Maple users.

The third form is equivalent to the first form under complex evaluation with appropriate adjustments of the contants of integration. And the second form can be obtained as a limit of the third form. For example,
 

restart:

Sol:= dsolve({
    diff(y(x),x,x)*x^2+3*x*diff(y(x),x)+lambda*y(x),
    y(1)=a, D(y)(1)=b
});

y(x) = -(1/2)*(1-lambda)^(1/2)*((1-lambda)^(1/2)*a+a+b)*x^(-1+(1-lambda)^(1/2))/(-1+lambda)+(1/2)*(1-lambda)^(1/2)*(-(1-lambda)^(1/2)*a+b+a)*x^(-1-(1-lambda)^(1/2))/(-1+lambda)

evalc(rhs(Sol)) assuming x>0, lambda>1;

a*cos((-1+lambda)^(1/2)*ln(x))/x+(a+b)*sin((-1+lambda)^(1/2)*ln(x))/((-1+lambda)^(1/2)*x)

limit(rhs(Sol), lambda=1);

(a*ln(x)+ln(x)*b+a)/x

 


 

Download EulerODE.mw

I don't know all the details of how Grid works, but intuitively Grid:-Set(arg1) seems unnecessary to me, and it seems like it would consume a lot of memory.

If one were required to use Grid:-Set(arg1), that would seem to me to be contrary to the whole idea of dividing the work among multiple processes.

Where you have blocks= [u,v], it should be 

blocks= [[u, v]]

Here is your complete code in the abbreviated "jet" notation:

restart:
DA:= DifferentialAlgebra:  DAT:= DA:-Tools:
R:= DA:-DifferentialRing('blocks'= [[u,v]], 'derivations'= [t]):
p:= u[t$3]*v[t] - u[t]*v[t$3]:
q:= v[t$3]^2*(v[t]*u[t$2] - v[t$2]*u[t]):
s:= DAT:-DifferentialPrem(p, q, R);
           s := 1, -u[t] v[t, t, t] + u[t, t, t] v[t]

 

In addition to sum not working for this, you've made a mistake by indexing the last row as 9. It's actually 10, but you do not need to index it at all. The sum that you want is simply

m1[2.., 1] . m1[2.., 2]

It is expressed above as the dot product of two vectors, i.e., a single operation that does the sum of the elementwise product of two vectors.

First 95 96 97 98 99 100 101 Last Page 97 of 395