Carl Love

Carl Love

28070 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

The Answer by Georgios shows a fine way to accomplish the same thing without using a for loop.  Instead, I'll correct your code directly. Your foremost problem is that you omitted the word do, which should be part of the for clause. Your next problem is that if you want to use 1-dimensional indexing on a multi-dimensional Matrix or Array, then you need to address the elements as A(k) rather than A[k]. Your next problem is that you switched the indexing variable from i to k. Your final problem is that assignment statements are done with := rather than simply =. Putting that all together, the code should be

for k from 1 to 9 do
     if A(k)=1 then
          A(k):= 0
     end if
end do;

That being said, there are much better ways to accomplish the same thing, as shown in Georgios's Answer.

The angles passed to the arc command should be in radians. You have converted the finishing angle to degrees. 

You can restrict input to any predicate by using satisfies:

f:= (x::satisfies(x-> x>0 and x<1))-> x^3 + (1-x)^3;


Note that it is not proper to code a procedure using

f(x):= ....

The correct syntax is

f:= x-> ...

or

f:= (x:: ... )-> ....

 

 

Yes, the command is PDEtools:-difforder.

You need to explicitly put a multiplication symbol between x and y, and between 3 and x:

implicitplot(x^3+y^3-3*x*y=0,x=-3..3,y=-3..3, scaling=constrained);

Change and to a semicolon (;). Put a colon (:) or semicolon after the end do.

Acer's answer explains why your A3 doesn't work. I will explain why your A2 doesn't work. A2 will match expressions that literally contain `or` and whose left argument is integer and whose right argument is rational. (Since `or` will reject as erroneous any explicitly non-Boolean input such as numbers, this type can never be matched.)

Here's an example of a valid use of lowercase or as a type:

TypeTools:-AddType(A2, symbol or indexed):
type(y or s[2], A2);

     true
type(s[2] or y, A2);
    
false

@smith_alpha 

Yes, I see your PS now. The output generated by "cmaple inputfile > outputfile" is not meant to be reread by a computer; it is strictly for human reading. If you are writing a file that is strictly meant to be reread by Maple, then the save command is by far the easiest way to do it: no formatting necessary and the reread values are automatically assigned to the correct variable names. Otherwise, use writedata or fprintf.

I think that you'd be better off using the command ImportMatrix, which understands the format "comma-separated values" through the parameter source= csv.

The assignment

x[anything]:= anything;

turns x into a table. Change x[s] to x_s or x__s.

A Horner-form for loop is probably the most efficient way, despite your distaste for it.

r:= rand();

L:= convert(r, base, 10):

S:= L[-1]: for k from 2 to nops(L) do S:= S*10+L[-k] end do: S;

     22424170465

However, there is also a library way to do it:

convert(L, base, 10, 10^nops(L))[];

     22424170465

 

N:= proc(m::posint)
local P:= 1, p:= 1, k;
     for k to m do
          p:= nextprime(p);
          P:= P*p
     end do;
     P+1
end proc:
M:= [$1..15]:
P:= N~([$1..15]):
SmallestPrimeFactor:= (n::posint)-> ifactors(n)[2,1,1]:
interface(rtablesize=16):
H:= < m | N[m] | S[m] | p[m] >:
<H, < <M[]> | <P[]> | <SmallestPrimeFactor~(P)> | <ithprime~(M)> >>;

You need to use diff consistently for derivatives. You correctly have diff(C(t), t) but expressions like d/dt and d*diff(n(t),t)/dt are meaningless. For a second derivative, use diff(n(t),t,t) or diff(n(t),t$2).

Yes, it is something simple. Don't use capital D as a variable. It is the functional differentiation operator.

restart:
assume(xi::real, eta::real):
phi:= (2*xi-1)*(xi-1)*(2*eta-1)*(eta-1):
Grad:= <diff(phi, xi), diff(phi, eta)>;

v:= <0,1>:
int(Grad.v, eta);

int(Grad.v, xi);

First 284 285 286 287 288 289 290 Last Page 286 of 395