Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

You need to use the value command so that solve can "look inside" the inert Sums. The value command converts inert functions into their active forms.

solve(
     value(simplify(syssub) union {simplify(f[1](0))=2, simplify(f[2](0))=1}),
     {a[0][1], a[0][2], a[1][1], a[1][2], a[2][1], a[2][2]}
);

I had to retype your code, which I hate doing. In the future, please post code in plaintext form and/or include an uploaded worksheet. You can upload worksheets by using the green uparrow tool that is the last item on the second row of the toolbar in the MaplePrimes editor.

The functions' names are f[i], so that is what should appear on the left of the assignment operator.

N:= 3:
for i from 1 to 2 do
     f[i]:= unapply(a[0][i]+Sum(a[j][i]*t, j= 1..N), t)
od;

The command unapply turns an expression into a procedure (or function). It works better than -> in this case because you want i to be evaluated at the time the function is defined rather than the time it is called. The function calls should be made as f[1](0), not f(0)[1].

You simply need to apply the combine command to the result of diff.

w:= x-> Sum(a[j]*x^j, j= 0..infinity);

(By the way, note the preferred syntax for defining a function: w:= x-> ..., rather than w(x):= ....)

diff(w(x), x);

combine(%);

If you declare a Units environment (such as Standard) and give your unknown variable y appropriate units, then the solve will work:

restart:
with(Units:-Standard):
Q:= 20*Unit('m')^3/Unit('s');
I__e:= 0.2e-1;
B:= 2*Unit('m');
k:= 0.3e-2*Unit('m');
g := 9.82*Unit('m')/Unit('s')^2;
M:= 8.1*g^(1/2)/k^(1/6); #Manning's number
Y:= y*Unit('m');
A:= Y*B;
R:= Y*B/(B+2*Y);
V:= M*R^(2/3)*sqrt(I__e);
y__0:= solve(Q = V*A, y);

Do not worry about the datatype issue: It is somewhat misleading, although the error message is true. The source of the error is that dsolve is generating symbolic expressions when it is expecting numeric expressions. It looks like your variable U has not been defined. Certainly it has no definition in the code that you provided. Also, it looks like you are trying to use linalg[grad], but you have referred to it as simply grad. Since linalg is deprecated, you should replace grad with VectorCalculus:-Gradient.

This operation is common enough that there's a single command for it: icontent.

In your initial conditions, ics, you use lowercase f. In the rest of your system, you use uppercase F.

I can't see your original list of strings, but I assume it's something like

L:= ["z", "d", "i", "p", "s", "y"];

If that is so, then do

map(convert, L, symbol);

 

Another option (not necessarily better than the above) for combining two lists is zip:

`+`(zip((x,y)-> x*ln(y), X, Y)[]);
or, better yet,
`+`(zip(`*`, X, ln~(Y))[])

In Maple 2015, make that

add(zip((x,y)-> x*ln(y), X, Y));
or, better yet,
add(zip(`*`, X, ln~(Y)));

Assuming that haa, and bb are suitably defined functions of c, then you need to add undefined at the end of the piecewise. It becomes the "otherwise" clause, thus taking care of the regions that are not covered by your ranges. Then, include the discont option to plot. So,

BB:= piecewise(
     -1.57 < c and c < -1.56, h,
     -0.06< c and  c < -0.05, aa,
     -0.5< c and c < 0.04, bb,
    undefined
);
plot(BB, c= -2..2, discont);

Regarding your first question, see ?piecewise. But your inequalities are nonsense: they imply -2 < -3 and -1 < -2.

Regarding your second question, you'll need to show the code that gives that error.

Statistics:-Sample returns a Vector, even if you ask for a sample of size 1. So, you need to index for the element before you subtract it from 200.

X[1]:= Statistics:-Sample(Binomial(200, .5), 1)[1];
for i to 10 do  X[i+1]:= Statistics:-Sample(Binomial(200-X[i], .5), 1)[1]  end do;

AFAIK, Maple's for loop syntax is pretty much the same as most other languages. It's done like this:

list_A:= table():  list_B:= table():  list_C:= table():
more:= true:
for k while more do
     #Do computation that computes A, B, and C and sets the
     #boolean value `more`.
     list_A[k]:= A;  list_B[k]:= B;  list_C[k]:= C
end do:
list_A:= convert(list_A, list);
list_B:= convert(list_B, list);
list_C:= convert(list_C, list);

You'll get a much smoother ellipsoid if you use regular plot3d and parametric plotting, like this:

plot3d(
     [2*sin(t)*cos(u), 3*cos(t)*cos(u), 4*sin(u)], t= 0..2*Pi, u= -Pi/2..Pi/2,
     scaling= constrained
);

cos(2*t) is the same thing as 2*cos(t)^2 - 1.

First 269 270 271 272 273 274 275 Last Page 271 of 395