Carl Love

Carl Love

28095 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

This is only an Answer to the question that you posed in the title of your Question:

There are a few types of displayed output that a Maple program can have. One type---which is probably most familiar to users of compiled languages---is that generated by explicit output-displaying statements such as print, iolib (printf, etc.), lprint, userinfo, and error (there may be a few other kernel-level commands in that list that I am forgetting).

Another type---which may be more familiar to users of interactive interpretted systems such as Maple---is the return value of the most recently executed statement. It is only this latter type which is suppressed by ending with a colon. The latter type can also be controlled by using the variable printlevel, which is set to 1 by default.

A third type is output generated by including option trace in a procedure. This is a debugging option.

(There might be a few other types of displayed output that I am forgetting.)

To get a result in terms of a hypergeometric function, use definite integration with a variable upper limit. In my experience, Maple is more likely to give an answer when integrals are done this way.

int(cos(t)^n, t= 0..x);

Any string of characters can be a name in Maple. It would be artificial to forbid the string `pi` and allow all others. What does Mathematica do if you use lowercase pi?

Answering only your final question about taylor series, it can be done like this:

eval(taylor(1/(1+y), y=0), y= f(x));

convert(%, polynom);

You have the independent variable entered two different ways, one as the literal character string "eta" and the other as the Greek letter eta. These are treated as two separate variables by Maple (when you use the 2d input). This problem might be caused by using a palette in some cases and the keyboard in the others.

It's easy:

E:= a+b*sqrt(c):
Eminus:= evalindets(E, sqrt(algebraic), x-> -x);

G:= 0.1*(s+0.2)*exp(-4.5*s)/(s+0.5)/(s+0.4)/(s+0.1)/(s+0.02):
(AR,phi):= op(map(simplify@evalc, convert(eval(G, s= I*omega), polar)));

Your problem is that you are using T and X both in indexed and unindexed form. In the header code, you should initialize X[1] and T[1] rather than X and T. In the loop, you should update X and T via

X[k+1] := X[k]+sum(y[i]*h^i/factorial(i), i = 1 .. 2);
T[k+1] := T[k]+h;

To plot it, you need to index from 1 to n+1, not from 0 to 30.

The short answer is that you make a module with option package. Example:

MyPackage:= module()
option package;
export
     MyProc1:= proc(x) x^2 end proc,
     MyProc2:= proc(x) x^3 end proc
;
end module:

with(MyPackage);

MyProc1(2);
     4

MyProc2(3);
     27

convert(1/((1+x)*(1+x^2)), FormalPowerSeries);

You have two problems. The first is trivial: In two places you typed StringTools*IsPrefix instead of StringTools:-IsPrefix.

The next problem is very subtle, and it shows why it is dangerous to use logical operators in prefix form. By prefix form, I mean `implies`(a,b). The safer form is the infix form a implies b. With the infix form, the McCarthy evaluation rules apply (look up "Short-circuit evaluation" in Wikipedia); with the prefix form, all arguments are evaluated. That leads to an error in your case: If P[x] is not assigned, then it is not legal to evaluate the second part of the implies.

Here's an example illustrating the McCarthy rules. The procedure F below just prints a message and returns 0. Thus we can see how many times it is called. The example below must be run in 1D input or CLI.

F:= proc() print("In F."); 0 end proc:

evalb(F(1)=1 implies F(2)=0);

                            "In F."
                              true

So F was only called once, because the truth of the proposition can be determined simply from the antecedent. Now do essentially the same thing with prefix form:

evalb(`implies`(F(1)=1, F(2)=0));
                            "In F."
                            "In F."
                              true

F gets called twice.

Here is your code which I corrected and indented and to which I added a few abbreviations.

macro(ST= StringTools):
Strings:= {
   "buffalo", "zebra", "aardvark", "aardwolf",
   "anteater", "antelope", "bumblebee"
};
CP:= {seq(seq(ST:-Take(x, ST:-CommonPrefix(x, y)), x in Strings), y in Strings)};
P:= table(Strings =~ "");
for x in CP do
     for y in CP minus {x} do
          if ST:-IsPrefix(y, x) and
               (assigned(P[x]) implies ST:-IsPrefix(P[x], y))
          then
               P[x]:= y
          end if
     end do
end do;
P = eval(P);

We can get Maple to do a proof by induction that x_n is rational for all n.

Base case (n=1):

x_1:= 1:
is(x_1, rational);

     true

Induction hypothesis: Assume the proposition is true for some n:

assume(p::integer, q::integer):
x_n:= p/q:
is(x_n, rational);

     true
Induction step: Prove it true for n+1:

R:= x-> 1/2*(x + 3/x):
is(R(x_n), rational);

     true

Thus x_n is rational for all n.

 

Some tips on your Maple syntax:

1. The name x_n is just a simple variable name. The n is not a distinct part of it. Thus you can't substitute for the n. If you want an indexed variable, use x[n] or x(n). Likewise, x_n-1 means 1 less than x_n.

2. Assignment statements are done with := not =    
     x_1:= 1;  (right)
     x_1= 1; (wrong)

3. There is no reason to use evalf in code like this; evalf is for decimal approximations.
   

Look for a command Student:-Calculus1:-RiemannSum. I don't know if it was available in Maple 13. It can handle arbitrary partitions, like this

Student:-Calculus1:-RiemannSum(
     x^3, x= 1..5, partition= [1, 1.3, 2.7, 3.6, 4.2, 5], method= midpoint
);

 

The following procedure will return two large well-separated randomly generated primes. Multiplying them is trivial. The parameter is the approximate number of bits in their product.

TwoPrimes:= proc(bits::posint)
local b:= max(2, iquo(bits,2));
     randomize();
     numtheory:-safeprime(rand(2^(b-2)..2^(b-1))()),
          numtheory:-safeprime(rand(2^b..2^(b+1))())
end proc:

p,q:= TwoPrimes(256);

n:= p*q;

 

m:= 2:  n:= 2:
combinat:-permute([1$n, 0$m]);

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