Carl Love

Carl Love

28055 Reputation

25 Badges

12 years, 354 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

ErrorPlot(y, xcoords= x);

It is probably the result of assigning to an indexed name and then evaluating the unindexed form. For example,

a[1]:= 2:
eval(a);

If this isn't enough information for you to diagnose your problem, then you should post your code.

I'll answer your second question first because its solution is slightly easier, although the issue is more complex.

Your code contains a definition of a function Spec thus:

Spec:= d-> expression

where expression does not explicitly contain d although it does contain variables that do contain d. Such a construction will not make Spec a function of d. To do that, you need to use unapply:

Spec:= unapply(expression, d);

If you do this, then the computation of the max and the plot will run in under a minute.

To solve your first problem, you need to take the the max from the actual plot rather than from Spec evaluated at only integer points.

P:= plot(Spec(d), d=-15..15, ...the rest of the plot options):

#Note that evalf is not needed in plot.

A:= op([1,1], P):  #The data matrix from the plot
Smax1:= max(A[..,2]):
A[..,2]:= A[..,2]/Smax1:
P:= subsop([1,1]= A, P):
print(P);

One command handles both of your questions.

P:= a_1*x*y^2*z^3+a_2*x^4*y*z^2+a_3:
coeffs(P, [x,y,z], 'M');

M;

Note that the order of the monomials and of the coefficients is not the same as in the polynomial. However, the order of the coefficients and of the monomials are guaranteed to be the same as each other.

ode2:= convert(lhs(ode)=~rhs(ode), list)[];

print~(set_)[];

                             a = 3
                             b = 5
                             c = 9
                             

For example,

plot([sin(t), t, t= -Pi..Pi]);

Here's a procedure that generates the three inequalities that define a triangle in the plane given the three vertices.

TypeTools:-AddType(Point, [realcons,realcons]);

ThreeIneqs:= proc(A::Point, B::Point, C::Point, XY::[name,name])
uses G= geometry;
local p, a, b, c, L, S:= {A,B,C};
     seq(
          (Eq-> `if`(eval(Eq, XY=~p) < 0, 1, -1)*Eq <= 0)
          (lhs(
               G:-Equation(
                    G:-line(
                         L,
                         [
                              G:-point(a, (S minus {p})[1][]),
                              G:-point(b, (S minus {p})[2][])
                         ]
                    ),
                    XY
               )
          )),
          p= S
     )
end proc:

ThreeIneqs([2,3], [4,5], [8,2], [x,y]);

The sum of the variables in the first 100 solutions is constant, and that constant is not 1. The constant is

There seems to be a bug that prevents me from getting past the first 100 solutions.

Procedure M creates such a Matrix of any size n.

M:= n-> Matrix(n, n, (i,j)-> max(i,j));

For example M(2), M(3), M(4).

The following procedure takes two Matrices, C and H, and returns a list of lists. Each sublist corresponds to a column of C and contains the indices of the columns in H that match it.

ColMatch:= proc(C::Matrix, H::Matrix)
uses LA= LinearAlgebra;
local c,h;
     [seq(select(h-> LA:-Equal(C[..,c],H[..,h]), [$1..op([1,2],H)]), c= 1..op([1,2],C))]
end proc:

An example of its use, using your C and H:

ColMatch(C,H);
                       [[2], [], [4], []]

You have

R = a+2*b+3*c;

That should be

R:= a+2*b+3*c;

The following is not a source of your error, but it may cause problems later. The usage

F(x):= R*x;

is incorrect. It should be

F:= x-> R*x;

Unless an author has specifically defined the two terms, do not infer that any difference is intended.

A distinction that is often made is, for example, that sin is a command whereas sin(x) is a function. However, I would not assume that any distinction was intended unless the author points it out.

~list:= x-> convert(x, list):
All:= (P::~list, Ls)-> andmap(L-> eval(L, [x,y]=~P) > 0, Ls):
All(<1,2>, [x+y+1, x+2*y+3, -x+y+2]);
                              true

Try this:

subsindets(expr, And(`+`, satisfies(x-> diff(x,q)=1)), x-> subs(q=0, x));

In words, "For every subexpression of type sum (`+`), check if the derivative with respect to q is 1. If it is, then change q to 0 in that subexpression."

First 338 339 340 341 342 343 344 Last Page 340 of 395