Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

how to plot nminimized result

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113502] how to plot nminimized result
  • From: tarun dutta <tarunduttaz at gmail.com>
  • Date: Sun, 31 Oct 2010 02:09:22 -0500 (EST)

p = 0.01;
q = 1;
n = 5;
CompNum[i_] := a[i] + I b[i];
TCompNum[i_] := a[i] - I b[i];
f = Sum[SetPrecision[
    Sqrt[i + 1] p CompNum[i] TCompNum[i + 1] +
     p CompNum[i + 1] TCompNum[i] + (q*i + i (i - 1)) CompNum[
       i] TCompNum[i], Infinity], {i, 0, n}];
c = \!\(
\*UnderoverscriptBox[\(\[Sum]\), \(i = 0\), \(n\)]
\*SuperscriptBox[\(Abs\ [CompNum[i]]\), \(2\)]\) ==
  1; c // TraditionalForm;
dp = {a[n + 1] -> 0, b[n + 1] -> 0};
var = Table[CompNum[i], {i, 0, n}] /. a_ + I b_ -> {a, b} // Flatten;
prob = Join[ComplexExpand[f] /. a_ + I b_ -> {a^2 + b^2} /. dp, {c}];
{val, res} =
   NMinimize[prob, var, MaxIterations -> 10000,
    AccuracyGoal -> 30]; // AbsoluteTiming

this is my main program.for fixed value of p and q.I got the minimized
value and also the variable like a[o],a[1]..etc for example(from above
program)

In[12]:= val

Out[12]= 5.25767*10^-6
In[13]:= res

Out[13]= {a[0] -> -0.805443, b[0] -> 0.591251, a[1] -> -0.00824279,
 b[1] -> 0.0402093, a[2] -> 0.0000547477, b[2] -> -0.000202243,
 a[3] -> -1.11872*10^-7, b[3] -> 3.84618*10^-7,
 a[4] -> 6.22738*10^-10, b[4] -> 8.88902*10^-11,
 a[5] -> 3.02522*10^-10, b[5] -> 3.02899*10^-10}


now I want to vary the value of p from 0 to 2 for a fixed value of q.q
will also vary from 0 to 5.so, program will start taking the first
value of q as 0 and scan p from 0 to 2 in steps 0.01.every time i will
get the corresponding {val,res}.for example
q=1    p=0.01           val 5.25767*10^-6    res  a[0] -> -0.805443,
b[0] -> 0.591251, a[1] -> -0.00824279,
 
b[1] -> 0.0402093, a[2] -> 0.0000547477, b[2] ->
-0.000202243,
a[3] -> -1.11872*10^-7, b[3] -> 3.84618*10^-7,
 
a[4] -> 6.22738*10^-10, b[4] -> 8.88902*10^-11,
 
a[5] -> 3.02522*10^-10, b[5] -> 3.02899*10^-10}



q=1   p=0.02          val=                              res =


now i want to check the result of res----if any a[i] and b[i] of all
a[i] and b[i] is nearly equal to 1(or > o.1) and other a[i] are zero
then print 'true' and also print the corresponding value of p and q
if more than one a[i] and b[i] have value nearly equal to 1 then print
'false'
from above example..
q=1 p=0.01 res=True because only a[0] and b[0] have nearly = to 1.we
ignore all other a[i] and b[i] cause they have value in order of 10^-2
or more.

so there will be some kind of table as
q=1  p=0.01 res true
q=1  p=0.02 res true
q=1 p=0.03  res true
q=1  p=0.04 res false
now we only consider only the last value of p for which we get
res=true after that point we get false
from above example we note the value of p=0.03 for q=1
similarly
q=1.1 res true p=0.01
q=1.1 res true p=0.02
q=1.1 res false p=0.03
here we note the value p=0.02,q=1.1
in this way we get a table of true value like
q=1 p=0.03
q=1.1 p=0.02
....
.....
now I want to plot(contour) q vs p.......
this is my problem....so how will I do all this in mathematica...
help
if the problem is not clear to you people just mail me...
with regards,
tarun




  • Prev by Date: Re: Assertions in Mathematica?
  • Next by Date: It would be nice to have DiagonalMatrix accept a matrix as building
  • Previous by thread: Re: Adding labels to a GraphicsGrid object
  • Next by thread: It would be nice to have DiagonalMatrix accept a matrix as building