Preben Alsholm

13728 Reputation

22 Badges

20 years, 242 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

If you give us the code for euclid we could try the loop ourselves.

Here are two solutions. Both use unapply in the definition of f in order that the variable a in point21 and point22 is seen as the same as the formal variable a.

The first version corrects an old problem in `plots/animate`. The problem is that the occurrences of subs in that procedure ought to be replaced by eval. I hope that problem has been removed in Maple 15. We shall see.

restart;
S := solve([y-a^2 = -(x-a)/(2*a), y = x^2+1], [x, y]);
point1 := [a, a^2];
point21:=eval([x,y],S[1]);
point22:=eval([x,y],S[2]);
f := unapply(piecewise(abs(a)>=1/2, point22, point21),a);
p1 := plot(x^2, x = -2 .. 2, color = green);
p2 := plot(x^2+1, x = -2 .. 2, color = blue, scaling = constrained);
###Correcting the above mentioned problem:
`plots/animate`:=subs(subs=((x,y)->eval(y,x)),eval(`plots/animate`)):
###
anm := plots:-animate(plot, [[point1, f(a)]], a = -2 .. 2);
plots:-display(p1, p2, anm);

##Second version, which also works with the uncorrected animate

#Create a procedure producing just a plot of the line:
pp:=a->plot([[a, a^2], f(a)]);
#Now animate the plot procedure pp:
anm:=plots:-animate(pp, [a], a = -2 .. 2);
plots:-display(p1, p2, anm);

There are two roots. For a between -1/2 and 1/2 you must use S[1].

The result of

5*3 mod 7;

is 1, meaning that the multiplicative inverse of 3 is 5, when you calculate mod 7.

The command

solve(Prob(w,T)=0,w,AllSolutions);

gives you a formula for all solutions. Variables of the form _Z1~ represent integers, variables of the form _B1~ take values 0 or 1. Since sin is squared all the roots have multiplicity 2.

If your Eqs are meant to be equations, then b is an unknown too.

Eqs := [x*b = y*b, b = 0];
                      
solution := solve(Eqs, [x,y,b]);

I haven't examined your worksheet except for syntax and the like. But certainly T1 needs to have a numeric value if the odes are solved numerically.

You can use the parameters option, if T1 cannot be determined from whatever else is in your problem.

try1 := dsolve(eqnew union {ics}, numeric, parameters = [T1]);
try1(parameters=[1.2345]);
odeplot(try1,[t,a(t)],0..0.2);

Although the parameter is called t, in fact the parameter is x. If you make both x and y appropriate functions of time t then you can obtain a reasonable fall and rise of the ball.

The last formal parameter in your procedure Lplot is dl. When you call the procedure with dl as a sequence (as you did: the global dl is a sequence), only the first element is passed to the procedure.

You should consider the formal dl a set and pass a  set, like this: 

Lplot := proc (t0, xt, yt, zt, para, R, dl) global L;
data(t0, xt, yt, zt, para);
L := dsolve(`union`(subs({op(para)}, dl), {op(initial)}), {x(t), y(t), z(t)}, type = numeric, output = listprocedure, range = R)
end proc;
Lplot(0, 1, 1, 1, para, 0 .. 30, {dl});

PT:=LinearAlgebra:-RandomMatrix(3,generator=-9.0..9.);

X0:=<1.,2,3>:
X1:=<4,5,6>:

to 5 while LinearAlgebra:-Norm(X1-X0,2) > 0.0000001 do
X0:=X1;
X1 := PT.X1;
end do;


Or to handle the actual problem:

X0:=<1.,2,3>:
X1:=PT.X0:
for i to 1000 while LinearAlgebra:-Norm(X1-X0,2) > 0.0000001 do
X0:=X1/LinearAlgebra:-Norm(X1,2);
X1 := PT.X0;
print(`/`~(X1,X0));
X1:=X1/LinearAlgebra:-Norm(X1,2)
end do:
i;


The line

eq := z-> H^2=(-1/(12*f1))*(T*Omega+f):

needs to be replaced by

eq :=unapply( H^2=(-1/(12*f1))*(T*Omega+f), z):

or else eq(1.2345) would contain the global z present in Omega. You defined Omega by

Omega := H0^2*Omega0*(1+z)^3/H^2:

Maple distinguishes between a matrix with m rows and 1 column and a column vector with m elements.

You can convert the matrix into a vector, which VectorCalculus:-Jacobian will accept.

Try this:

v:=<x^2*y,y+x>;
M:=convert(v,Matrix);
type(M,Matrix);
type(v,Matrix);
VectorCalculus:-Jacobian(v,[x,y]);
VectorCalculus:-Jacobian(M,[x,y]);
w:=convert(M,Vector);
VectorCalculus:-Jacobian(w,[x,y]);

You can show the two (or more) animations together with display.

An example (not very exciting):

with(plots):
p1:=animate(plot,[sin(t),t=0..T],T=0..6*Pi):
p2:=animate(plot,[cos(t),t=0..T,color=blue],T=0..6*Pi):
display(p1,p2);

If you use assumptions on y, you are OK:

restart;
g := (1-x) * ln(sqrt(x^2 + y^2 + 1) +1 );
h:= subs(y = 0.5, g);

h1 := int(h, x = 0..1);

g2 := int(g, x = 0..1) assuming y>0;
h2 := evalf(subs(y = 0.5, g2));
simplify(h2);

assuming y::real works too, but the result is more messy.

Maple is not doing numerical integration in the session above, not even if wrapped in an evalf. Try setting infolevel[int]:=1: before doing the first integration. If you want numerical integration in the first case, you should do

h1 := evalf(Int(h, x = 0..1));

Notice 'Int' instead of 'int'.

M:=Matrix([[1,1,0],[0,0,1],[1,0,1]]);
Ind:=Matrix(3,(i,j)->if M[i,j]=1 then [i,j] else NULL end if);
convert(Ind,list);

First 137 138 139 140 141 142 143 Last Page 139 of 160