miname

15 Reputation

2 Badges

11 years, 177 days

MaplePrimes Activity


These are questions asked by miname

Hi!

 

I still have a problem and im looking forward to any suggestions

this is the previous code that i have wrote

P := array([[8, 4], [8, 3], [8, 2], [7, 1], [6, 0], [5, 0], [4, 0], [2, 1], [1, 1], [1, 4]]);


> for j from 2 to 5 do k[j] := j+1;

x[j] := add(P[j, 1], j = j-1 .. j+2);

X[j] := add(P[j, 1]^2, j = j-1 .. j+2);

y[j] := add(P[j, 2], j = j-1 .. j+2);

Y[j] := add(P[j, 2]^2, j = j-1 .. j+2);

xy[j] := add(P[j, 1]*P[j, 2], j = j-1 .. j+2);

cx[j] := evalf(x[j]/k[j]);

cy[j] := evalf(y[j]/k[j]);

c11[j] := evalf(X[j]/k[j]-cx[j]^2);

c22[j] := evalf(Y[j]/k[j]-cy[j]^2);

c12[j] := evalf(xy[j]/k[j]-cx[j]*cy[j]);

C[j] := evalf(Matrix(2, 2, [[c11[j], c12[j]], [c12[j], c22[j]]]));

E[j] := simplify(fnormal(LinearAlgebra[Eigenvalues](C[j])));

if E[j][1] > E[j][2] then a[j] := E[j][2]/(E[j][1]+E[j][2]) else b[j] := E[j][1]/(E[j][1]+E[j][2])

 end if;

a[j];b[j]

 end do;

 

now, my question is how to put the output from the above looping in a  matrix form.

in my matrix, i need to call a[j],b[j], E[j][1], E[j][2] and the coordinate points. so my matrix dimension 4 x 5

I guess its a simple task but i tried hard and didnt get it worked.

thank you.

 

hi, I have tried to run this program unfortunately the program give some errors.

 

 

anneal < -function(fun, N, rho, t, theta)

{y=NULL  

theta.old=theta repea {  

s=0  for k from 1 to N  

{

f.old=fun(theta.old)

 theta.new=runif(1,-1,1)+theta.old

 f.new=fun(theta.new)  

if(f.new<f.old){

 theta.star=theta.new  

s=s+1

}

 else  

{

u=runif(1)

 b=(u<=exp(-(f.new-f.old)/(t)))

 theta.star=theta.new*b+theta.old*(1-b)

 s=s+b  

}  

theta.old=theta.star

 y=c(y,theta.star)  

}  

write(y,file="anneal.result",ncol=1,append=T)

y=NULL

 if(s==0)break

 t=rho*t  

if(t<0.1)break  }

 return(y)  

}

cauchy.1=function(alpha){x=c(-4.20,-2.85,-2.30,-1.02,0.70,0.98,2.72,3.50)  return(sum(log(0.01+(x-alpha)^(2))))}

x=seq(-6,6,,300)

y=sapply(as.list(x),cauchy.1)

plot(x, y, type = "1", ylab = "cauchy.1(beta=.1,alpha)", xlab = "alpha")

anneal.result=anneal(cauchy.1,300,.95,10,4)

plot(x, y, type = "1", ylab = "cauchy.1(beta=.1,alpha)", xlab = "alpha")

anneal.result=anneal(cauchy.1,300,.95,10,4)

x = scan("anneal.result")

plot(1:length(x),x,type="1"

 

can anyone help me on this? can i do something about it

Many thanks.

Hello every one,

I am facing problem with for loop. Please have a look.

 

let say I have T[0]:= 99 ; X[0]:=0; f(x):=108 + 2 x

  for i from 1 to 2 do f(x[i-1] ):

                              y[i]:=x[i-1] +1 ;

if f(y[i])<f(x[i-1]) then x[i]:=y[i] elif 0.98< e0.99/T[0]  then x[i]:=y[i] else x[i]:=x [i-1]

end if;

end do;

after I got the answer from this loop, now I want to continue the loop for T[1]:= 0.1 T[0], 

 how  to do another loop by using the same  information but in different value of T? in other words, the only change in the looping is the value T so that the next loop I have the set of answer.

thanks.

 

 

Hi there..

I have a question on how to do a pointplot.

 

before plotting, I need to know the value of lambda[j] and  all the values of lambda already have.

so now I need to plot a graph with the values of lambda with different range and different colour,

 

Let say I have


> for j from 17 to 32 do k[j] := j+1;

x[j] := add(P[j, 1], j = j-1 .. j+2);

X[j] := add(P[j, 1]^2, j = j-1 .. j+2);

y[j] := add(P[j, 2], j = j-1 .. j+2);

Y[j] := add(P[j, 2]^2, j = j-1 .. j+2);

xy[j] := add(P[j, 1]*P[j, 2], j = j-1 .. j+2);

cx[j] := evalf(x[j]/k[j]);

cy[j] := evalf(y[j]/k[j]);

c11[j] := evalf(X[j]/k[j]-cx[j]^2);

c22[j] := evalf(Y[j]/k[j]-cy[j]^2);

c12[j] := evalf(xy[j]/k[j]-cx[j]*cy[j]);

C[j] := evalf(Matrix(2, 2, [[c11[j], c12[j]], [c12[j], c22[j]]]));

E[j] := simplify(fnormal(LinearAlgebra[Eigenvalues](C[j])));

if E[j][1] > E[j][2] then lambda[j] := E[j][2]/(E[j][1]+E[j][2]) else lambda[j] := E[j][1]/(E[j][1]+E[j][2])  end if;

lambda[j];

 end do;

the range of lambda [j] are as follows:

 0.02< lambda [j]<0.06

 0.06< lambda [j]<0.12

 0.12< lambda [j]<0.18

 

for i from 17 to 32, do if   0.02< lambda [j]<0.06 then green[i]:=P[i,j]; j:=i+1 elif

 0.06< lambda [j]<0.12 then red[i]:=P[i,j];j:=i+1 ; elif 0.12< lambda [j]<0.18 then blue[i]:=P[i,j];j:=i+1 end if;end do

how to do a point plot with the above situation so that in my plotting all the information are on the same graph.

 

All help is greatly appreciated.

Thanks

 

 

 

Hi, I just want to know if there is simulated annealing programming in maple 14 and where I can get that programming

 

1 2 Page 1 of 2