Preben Alsholm

13728 Reputation

22 Badges

20 years, 242 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

You could use unevaluation quotes around the procedure (or around the whole input) or use an inert form of the procedure. An inert form you can get by prefixing the name of the procedure with %.

Examples.

'solve'(x^2=1,x);
%;
%solve(x^2=1,x);
value(%);
'plot'(sin(x),x=-Pi..Pi);
%;
%plot(sin(x),x=-Pi..Pi);
value(%);

A statement like a do loop cannot be handled like that but could be handled like in this example.

" for i from 1 to 5 do i^2 end do " ;
parse(%,statement);

By D1 you probably mean D[1].

You don't define pde in pdsolve(pde). You probably meant pdsolve(sys);

After these corrections there are other problems.

The polynomial in n can only change sign where it is zero, although it may not.

Here are two illustrations. Like other people I suggest not using lower case l as it can look like 1 or I depending on the font used. I have retained it below though.

pol:=(2+l^2-4*l)*n^2-(4-4*l)*n+2;
Z:=solve(pol=0,n);
plot([Z],l=-4..10,-4..4,discont=true);
plots:-implicitplot(pol>0,l=-4..10,n=-4..4,gridrefine=2,filledregions=true);

You are using curly brackets { } in place of parentheses ( ). Curly brackets are for sets only.

Try this instead.

solve({G*((1-v)*s1+v)+H*((1-v)*s2+v) = n1, G*((1-v)*s1*w^s1+v*w^s1)/w+H*((1-v)*s2*w^s2+v*w^s2)/w = -p*(1+v)*(1-2*v)/(e*w^beta)+n2}, [G, H]);

Here are some illustrations, but they may not be what you are thinking about.

f:=int(1/sqrt(2*Pi)/sigma*exp(-(x-mu)^2/2/sigma^2),x);    

plot(subs({mu=0,sigma=1},f),x=-4..8);

plot3d(subs(mu=0,f),x=-4..8,sigma=.2..2,axes=boxed);
plots:-spacecurve({seq([x,sigma,subs(mu=0,f)],sigma=[.2,1,2])},x=-4..8,axes=boxed,thickness=3);
plots:-animate(plot,[subs(mu=0,f),x=-4..8],sigma=.1..2);

Clearly f(0)=0. Using that and the assumption that our solution is twice differentiable we get

eq:=f(x+y)=f(x)+f(y)+80*x*y:
diff(eq,x,y):
subs(x+y=x,%):
map(int,%,x)+(0=C):
res:=map(int,%,x):
eval(%,x=1/4):
eval(%,f(1/4)=2):
solve(%,{C}):
eval(res,%):
eval(%,x=4/5);
                            /4\     
                           f|-| = 24
                            \5/     

RanNum seems to be a private procedure. But my guess is that RanNum(1,1) returns a procedure which doesn't require input, but since it is a procedure when you call it you do need the parentheses.

An example of this:

r:=rand(0..9);

r();

fsolve finds a root.

fsolve(A00=0,R3);
                             -19.23670576
plot(A00,R3=-30..20);

Here is a simple example of the problem.

p:=proc(b) b:=b+1 end proc;

Now the result of the command

p(8);

is
Error, (in p) illegal use of a formal parameter

When the call p(8) is made the formal parameter b in p is replaced by 8 everywhere resulting in 8:=8+1, which is not allowed.



You need to replace the equality N = 7 with the assignment N:=7 (and declare i and N local).

I haven't tried to find out exactly what you are trying to do in the loops at the end, but maybe the following rewriting of your initial steps will help.

restart;
with(LinearAlgebra): with(Optimization):
n := 2; p := <2, 3, 3>;
X := Vector(n,symbol=x);
x0 := Vector(n);
st := Vector(n);
for i to n do x0[i] := 0; st[i] := -1 end do;
f:=unapply((x[1]-p[1])^2+p[3]*(x[2]-p[2])^2,x);
lin := -4*x[1]-18*x[2];
fin:=diff~(lin,X);
f0 := DotProduct(X-x0,fin,conjugate=false);
res:=Minimize(f0, {x[1]+2*x[2] <= 4, x[1]^2+x[2]^2 <= 5});
t:=res[1];
xi:=subs(res[2],X);
qwe := evalf(Norm(x0-st, 2));
f(x0+alpha*(xi-x0));
res:=Minimize(f(x0+alpha*(xi-x0)), {alpha >= 0, alpha <= 1});
k := res[1];
f(x0);

As far as I can see, there is no solution.

Try the following.

dsolve({ode2,v(0)=.01});
ode3:=subs(%,ode1);

Now the general solution of ode3 is found by

res:=dsolve(ode3);

and is

u(r) = sinh(sqrt(t)*r)*_C2/r+cosh(sqrt(t)*r)*_C1/r-1/(100*t)

The requirement that u(0)=.5 (i.e. finite for all t) forces _C1 = 0.

By letting r -> 0 we find 0.5=sqrt(t)*_C2-1/(100*t), so that

u(r) = 0.01*sinh(sqrt(t)*r)*(50*t+1)/(r*t^(3/2))-1/(100*t)

which clearly depends on t also when r=0.2, where your second boundary condition is given as independent of t.

The immediate problem is qwe > 0, 1. Did you mean qwe > 0.1 or ?

Next problem is that 'if ... then .." uses evalb which cannot determine if e.g. sqrt(2)>0. You could use evalf(qwe)>0.1 (or use 'is').

The linalg package is deprecated. LinearAlgebra has got what you need.

No need to repeat with(Optimization).

Here is a way. Not particularly elegant, but it works.

A:=LinearAlgebra:-RandomMatrix(3,4);

#This is a way to get the 2nd column
A[1..,2];

#The matrix after applying f to each column
Matrix(f~([seq(A[1..,i],i=1..4)]));

#A very simple example
g:=v->5*v;
Matrix(g~([seq(A[1..,i],i=1..4)]));

You could use of LinearAlgebra:-Column(A,i) instead of A[1..,i].

There must be more to it. I think you need to tell us how B and inter are defined.

The following simpel version works as expected.

for q to 12 do inter[q]:=q end do:
B:=6:
for q  from 1 by 1 to 12 do;
   if inter[q] <= B then xz[q] := inter[q] end if;
end do;

for q to 12 do xz[q] end do;

First 135 136 137 138 139 140 141 Last Page 137 of 160