Carl Love

Carl Love

28070 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love


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.

Use dsolve followed by odeplot.

The next problem is your initial conditions. Clearly there is no solution for u1(0)=0, since u1(t) appears as a denominator in the system.

Sol:= dsolve(sys union {u1(0)=1, u2(0)=1, u3(0)=1}, range= 0..15, numeric):
plots:-odeplot(Sol, [u1(t),u2(t),u3(t)], t= 0..15);

A key observation is that an upper bound for the exponents is the base-2 log of the largest element.

f:= proc(ns::seq(And(posint, Not(identical(1)))), $)
local Ns:= [ns], M:= ilog2(max(Ns)), k, R:= Vector(1, [nops(Ns)]);
     if Ns=[] then  return []  end if;
     for k from 2 to M do
          R(k):= nops(select(n-> iroot(n,k)^k=n, Ns))
     end do;
     for k from M by -1 while R(k)=0 do  R(k):= ()  end do;
     convert(R, list);
end proc:

f(27);
                          
[1, 0, 1]
f(2,3,4,9,81,1024);
                
[6, 4, 0, 1, 1, 0, 0, 0, 0, 1]

Did you recently study a section on Bezier curves?

Start with a piece of graph paper. Write your name in large letters as simply as possible. Designate an arbitrary point on the paper as the origin (0,0). Mark all the significant points: endpoints, intersections, sharp turns. Get their coordinates. For the straight sections, just plot as the line segment between two points. For the curved pieces, pick two more "control points" in addition to the endpoints (the control points are not necessarily on the curves). Parmetrically plot the unique cubic Bezier curve for each group of four points (for each curve). Then put the plots together with plots:-display.

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