Preben Alsholm

13471 Reputation

22 Badges

20 years, 249 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

I agree that D(h) ought not return 0. Returning unevaluated would be OK.

restart;
#showstat(D);
f:=k->(y->y^k);
h:=z->f(2)(z);

# In the help page for D it is described as doing something like this:
D(h) = (q -> eval(diff(h(t),t), t=q));
#However, that is only meant to convey the idea as you see in the following (and by looking at the code for D using showstat(D)).
infolevel[D]:=5:
D(h)(w) = (q -> eval(diff(h(t),t), t=q))(w);
D: Applying  D to  h
D: Either a name or a procedure
D: Looking for D/h
D: Looking for diff/h
D: No pre-defined rules
D: Applying  D to  f
D: Either a name or a procedure
D: Looking for D/f
D: Looking for diff/f
D: No pre-defined rules
D: Applying  D to  f(2)
                            0 = 2 w
#If you redefine f in the following way (reminiscent of the way procedures returning procedures had to be handled many versions ago) then D(h) returns unevaluated
f:=proc(k) subs(_k=k,y->y^_k) end proc;

D(h)(w) = (q -> eval(diff(h(t),t), t=q))(w);
D: Applying  D to  h
D: Either a name or a procedure
D: Looking for D/h
D: Looking for diff/h
D: No pre-defined rules
D: Applying  D to  f
D: Either a name or a procedure
D: Looking for D/f
D: Looking for diff/f
D: No pre-defined rules
D: Applying  D to  subs
D: Either a name or a procedure
D: Looking for D/subs
D: Looking for diff/subs
D: No pre-defined rules
                         D(h)(w) = 2 w



You must use a list to break an existing order. Once a particular order like {a,c,b} is chosen, then the command {a,b,c}; results in {a,c,b}.
Suppose that res is the result of your fsolve command.

res:=fsolve(.....);
U:=[u1,u2,u3,u4,u5];
zip(`=`,U,eval(U,res));

# In versions later than Maple 12 you can use elementwise equality.
U=~eval(U,res);


You don't tell us what xi_M, anteil, or ableitung are, so I just made a very simplified version. With the simplified version deltaT remains a Matrix.

deltaT :=Matrix(1..19,1..6,fill=1);
i := 0;
j := 0;
for a from 1 by 1 to 19 do i:=i+1; j:=0;
for b from 1 by 1 to 6 do  j:=j+1;
deltaT(i,j):=i+j;
end do:
end do:

whattype(deltaT);

or why not just

for i from 1 to 19 do
   for j from 1 to 6 do
      deltaT(i,j):=i+j;
   end do:
end do:

whattype(deltaT);

There were typos in H, which is not a procedure/function, but just an expression containing tau.

So try this:

fQ1,fQ2,fP1,fP2 := op(subs(p,[Q1(tau),Q2(tau),P1(tau),P2(tau)])):
H := (1/8)*(fP1^2+fP2^2)/(fQ1^2+fQ2^2)+1/2*(fP1*fQ2-fQ1*fP2)+q*(fQ1^2+fQ2^2)/(1+q)-1/((1+q)*(fQ1^2+fQ2^2))-q/((1+q)*sqrt((fQ1^2-fQ2^2-1)^2+4*fQ1^2*fQ2^2))-q^2/(2*(1+q)^2):
 plot(H, tau = 0.3e-1 .. T);

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);

First 133 134 135 136 137 138 139 Last Page 135 of 158