## 202 Reputation

7 years, 106 days

## @tomleslie I think it is better to put t...

@tomleslie I think it is better to put the output of diff(f(x),x) instead of just diff(f(x),x). Is it?

## @9009134 I think maple global optimizati...

@9009134 I think maple global optimization package or stochastic optimization techniques (if the problem is written as an optimization problem) can solve this issue.

http://sciencedirect.com/science/article/abs/pii/S036054421400560X

## @Carl Love What about using map function...

@Carl Love What about using map function here

## @Gillee great great...

@Gillee great great

## @acer Thanks a lot. Sorry for not p...

@acer Thanks a lot. Sorry for not providing the information that nn is an integer.

@Mac Dude Thanks for your reply. I am trying to optimize a function where the variables are nn and xx[ii]s. The second and third argument inside Minimize function ie nn=1..5 and seq(xx[ii]=1..10,ii=1..nn) are the bounds for those variables. Here nn itself is a variable rather than a constant. That is why it is showing error. How to solve this problem?

Suppose nn is a constant i.e., let us say nn=5

restart;

W := proc ()

global rf;

rf := add(xx[ii]^2-5, ii = 1 .. 5);

return rf ;

end proc;

Optimization:-Minimize(W(), xx[1] = 1 .. 10, xx[2] = 1 .. 10, xx[3] = 1 .. 10, xx[4] = 1 .. 10, xx[5] = 1 .. 10);

[-20.,  [xx[1] = 1., xx[2] = 1., xx[3] = 1., xx[4] = 1., xx[5] = 1.]]

But the issue i am facing in my original question is nn is a variable

## @Carl Love Thanks a lot for your co...

@Carl Love Thanks a lot for your comments. I will try to make the following changes. In future, I will be posting different optimization algorithms including both deterministic as well as non-deterministic. Hope your help and cooperation.

## @acer In the new example, I am not ...

@acer In the new example, I am not using a random array. Instead, I am using a different array i.e

With this why I am getting the above error. Can you please modify the code such that i can use it for the new array.

## @ If that is the case better would ...

@ If that is the case better would be genetic algorithm, artificial bee colony algorithm etc.

## @acer so how can i use it for new e...

@acer I removed float[8] still getting error. so how can i use it for new example where I am inserting arrays

## @Carl Love Will this algorithm work...

@Carl Love Will this algorithm works for multivariable functions. Thank you

## @acer  Iam getting following error....

@acer  Iam getting following error. thread.mw

 >
 >
 memory used=0.56MiB, alloc change=0 bytes, cpu time=1000.00us, real time=0ns, gc time=0ns
 >
 >

## restart; tt := -0.689609e-3; T_c := .24...

restart;

tt := -0.689609e-3; T_c := .242731; mu := .365908; k := 1; N := 1; II := 2; q := 5; m := 3:

R1 := a*tanh((a^2-mu)/(2*T_c))*ln((-2*II*N*Pi+2*a^2+2*a*q+q^2-2*mu)/(-2*II*N*Pi+2*a^2-2*a*q+q^2-2*mu))/q-2;

R2 := evalf(Int(R1, a = 0 .. 10000));

R3 := evalf(q*ln((-q^2-k^2+mu+II*(2*N*Pi*T_c-(2*m+1)*Pi*T_c)+k*q)/(-q^2-k^2+mu+II*(2*N*Pi*T_c-(2*m+1)*Pi*T_c)-k*q))/(k*(tt+R2)))

Result:               R2 := -0.08174801869 + 1.984664086 I
R3 := 0.03164888870 + 0.7619386260 I

## @acer Can I use add function inside...

@acer Can I use add function inside FFG procedure?