Carl Love

Carl Love

28095 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

If f(x) = r*(8-2*x^2) = r*2*(2-x)*(2+x), then |(f@@n)(x)| -> infinity as n -> infinity, for r > 1 and 0 < x < 1. ((f@@n)(x) denotes the nth iterate of f, e.g., (f@@3)(x) = f(f(f(x))).)

The trick is to apply eval to count whenever its value (as opposed to its name) is required. Like this,

xcp:= proc(count)
local i;
     print("nargs=", nargs, "args=", args);
     count:= 0;
     for i from 2 to nargs do
          if isprime(args[i]) then
               count:= eval(count)+1
          end if;
          print("i=", i, "count=", eval(count))
     end do;
     print("count=", eval(count))
end proc ;

Please don't conclude from this exercise that the above is a good way to write Maple code. The purpose of the exercise is, IMO, to show you what one-argument eval is good for. I'd much rather read the original cp procedure.

One error is that you need with(combstruct) before your first call to iterstructs.


macro(LA= LinearAlgebra):

a) The consumption matrix. Index 1 is services and index 2 is foods.

C:= Matrix([[.5, .2], [.4, .2]]);

C := Matrix(2, 2, {(1, 1) = .5, (1, 2) = .2, (2, 1) = .4, (2, 2) = .2})

b) The demand vector...

d:= < 2e6, 12e6 >;

d := Vector(2, {(1) = 2000000., (2) = 12000000.0})

,,, and the production vector

p:= LA:-LinearSolve(LA:-IdentityMatrix(2)-C, d);

p := Vector(2, {(1) = 12500000.00, (2) = 21250000.00})

c)

C[2,1]*p[2];

HFloat(8500000.0)

 


Download Leontief1.mw

Running your code in Maple 17, I get 7 solutions for [A,B], one real and six complex.

What result did you get?

The command that you want is select. See ?select .

Example:

Even:= n-> irem(n,2) = 0:
select(Even, [$1..10]);
                        [2, 4, 6, 8, 10]

Sol:= dsolve({diff(y(x),x)=y(x), y(0)=1}, numeric, output= listprocedure):
theta:= eval(y(x), Sol):
evalf(Int(ln@theta, 0..2));
                   1.999999704723899

The exact answer is 2. So the accuracy is limited to the accuracy of dsolve not the accuracy of numerical integration.

Is this what you had in mind for the second plot?

restart:
b:= 100:
plot([seq(BesselJ(0, BesselJZeros(0,n)*sqrt(z/b)), n= 1..4)], z= 0..100);

And for the animation, I had to assume some values for your constants.

restart:
A:= K[n]*cos(BesselJZeros(0,n)^2/4/b*sqrt(g)*t - sigma[n])*BesselJ(0, BesselJZeros(0,n)*sqrt(z/b)):
n:= 3: K[n]:= 1: b:= 100: g:= 1: sigma[3]:= Pi/3:
plots:-animate(plot, [A, z= 0..100], t= 0..20);

The closest thing to that that is possible is

(A,C,B,F):= convert(Q, list)[];

Note that the order is not (A,B,C,F).

Your list6 is too big to generate the permutations all at once, which is what combinat:-permute does. You need to use the iterator commands, which generate them one at a time. These are combinat:-firstperm, combinat:-nextperm, etc.

You must mean for the cumulative probability to be greater than 0.95, not the one-point probability. For the cumulative probability, you need the sum of the one-point probabilities from k = 0 to n.

restart:
lambda:= 2:
sum(exp(-lambda)*lambda^k/k!, k= 0..n):
fsolve(% = .95, n);
                        4.04766491450491

Since n must be integer, we take n = 5.


restart:

DE:= z*diff(Z(z),z$2)+diff(Z(z),z)+a^2*Z(z) = 0;

z*(diff(diff(Z(z), z), z))+diff(Z(z), z)+a^2*Z(z) = 0

tr:= {z= x^2*b}:

PDEtools:-dchange(tr, DE, [x], params= {a,b});

(1/2)*x*(-(1/2)*(diff(Z(x), x))/(x^2*b)+(1/2)*(diff(diff(Z(x), x), x))/(x*b))+(1/2)*(diff(Z(x), x))/(x*b)+a^2*Z(x) = 0

simplify(%);

(1/4)*(4*a^2*Z(x)*x*b+(diff(diff(Z(x), x), x))*x+diff(Z(x), x))/(x*b) = 0

numer(lhs(%));

4*a^2*Z(x)*x*b+(diff(diff(Z(x), x), x))*x+diff(Z(x), x)

expand(%/x);

4*a^2*Z(x)*b+diff(diff(Z(x), x), x)+(diff(Z(x), x))/x

 


Download dchange.mw

restart:

eq[1]:= 0.223569*c_1+2.35589*c_2*c_1^2+0.002356*c_1*c_2^2;

eq[2]:= 1.277899*c_1*c_3-2.350023*c_2*c_3^2+7.5856*c_3*c_2^2;

eq[3]:= 3.225989*c_1^2-2.35589*c_3*c_1^2-7.28356*c_3*c_2^3;

.223569*c_1+2.35589*c_2*c_1^2+0.2356e-2*c_1*c_2^2

1.277899*c_1*c_3-2.350023*c_2*c_3^2+7.5856*c_3*c_2^2

3.225989*c_1^2-2.35589*c_3*c_1^2-7.28356*c_3*c_2^3

fsolve({eq[1], eq[2], eq[3]}, {c_1, c_2, c_3});

{c_1 = -.288345360009260, c_2 = .329488436747954, c_3 = .587670492604662}

F:= unapply(<eq[1], eq[2], eq[3]>, c_1, c_2, c_3):

NewtonsMethod:= proc(F, x0, {maxiters::posint:= 99}, {epsilon::positive:= 10^(3-Digits)})
local
     x, y, z,
     J:= unapply(VectorCalculus:-Jacobian(F(x,y,z), [x,y,z]), x, y, z),
     X:= x0,
     newX:= <1,1,1>,
     err:= <1+epsilon, epsilon, epsilon>,
     k
;
     for k to maxiters while LinearAlgebra:-Norm(err)/LinearAlgebra:-Norm(newX) > epsilon do
          newX:= X - LinearAlgebra:-LinearSolve(J(X[1],X[2],X[3]), F(X[1],X[2],X[3]));
          err:= newX - X;
          X:= newX
     end do;
     if k > maxiters then  WARNING("Did not converge.")  end if;
     X
end proc:

NewtonsMethod(F, <-1, 2, 2>);

Vector(3, {(1) = -.288345360009260, (2) = .329488436747954, (3) = .587670492604662})

 

That's one solution. There are several others. Obviously < 0, 0, 0 > is a solution.

Download MultiNewton.mw

You have two separate problems. The problem that is preventing the plotting is that Pi in Maple is spelled with a capital P when you mean the well-known mathematical constant; lowercase pi is just a variable that prints the same way.

The problem with s(2) is that you haven't made s a procedure; rather, s is an expression. To make it a procedure, do

s:= theta-> piecewise(...);

and change the plot command to plot(s(theta), theta= 0.01..2*Pi) or plot(s, 0.01..2*Pi).

If you want to keep s as an expression, then to evaluate it at 2 do

eval(s, theta= 2);

Just use the collect command.

P:= (1+1/z)^2*(1+z)^2*(r[1]*z+r[0]+r[1]/z):
collect(%, z);

Maple does not ordinarily show negative exponents, using denominators instead; although the negative exponents do appear in the internal representation.

In some cases, it is necessary to use expand before collect.

First 330 331 332 333 334 335 336 Last Page 332 of 395