Re: problem in minimization of a matrix
- To: mathgroup at smc.vnet.net
- Subject: [mg123023] Re: problem in minimization of a matrix
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Mon, 21 Nov 2011 04:25:29 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201111201038.FAA01248@smc.vnet.net>
- Reply-to: drmajorbob at yahoo.com
That's too much to grasp all at once, but... (a) For speed, I recommend = rather than := when possible, as in s[\[Omega]_, t_] = FullSimplify[ Integrate[ Sin[\[Omega] \[Tau]] Sin[\[Omega]0 \[Tau]], {\[Tau], 0, t}]]; c[\[Omega]_, t_] = FullSimplify[ Integrate[ Cos[\[Omega] \[Tau]] Cos[\[Omega]0 \[Tau]], {\[Tau], 0, t}]]; d[\[Omega]_, t_] = FullSimplify[ Integrate[ Cos[\[Omega] \[Tau]] Sin[\[Omega]0 \[Tau]], {\[Tau], 0, t}]]; J[\[Omega]_, \[Lambda]_] = \[Omega]/(\[Omega]^2 + \[Lambda]^2) It's VERY inefficient to compute Integrate, Simplify, ArrayFlatten, or Det all over again for EVERY call of the function, which is exactly what := causes to occur. (b) When arguments MUST be numeric, say so in the definition, as in: \[CapitalGamma][\[Alpha]_?NumericQ, \[Beta]_?NumericQ, \[Omega]0_? NumericQ, \[Lambda]_?NumericQ, t_?NumericQ] := NIntegrate[ 2*\[Gamma][\[Alpha], \[Beta], \[Omega]0, \[Lambda], s], {s, 0, t}] (c) If Integrate will work with symbolic arguments, instead of NIntegrate with numeric ones, use something like the above definition of d. (d) The example in (b) might be more efficient using NDSolve, since a single call allows computation for ANY t in an interval. That's not as good as using Integrate, which computes all instances at once, but it avoids computing the integral every time t changes. That would go something like: ClearAll[\[CapitalGamma]] \[CapitalGamma][\[Alpha]_?NumericQ, \[Beta]_?NumericQ, \[Omega]0_? NumericQ, \[Lambda]_? NumericQ] := \[CapitalGamma][\[Alpha], \[Beta], \[Omega]0, \ \[Lambda]] = f /. First@ NDSolve[{f'[s] == 2*\[Gamma][\[Alpha], \[Beta], \[Omega]0, \[Lambda], s], f[0] == 0}, f, {s, 0, tUpperLimit}] \[CapitalGamma][\[Alpha]_?NumericQ, \[Beta]_?NumericQ, \[Omega]0_? NumericQ, \[Lambda]_?NumericQ, t_?NumericQ] := \[CapitalGamma][\[Alpha], \[Beta], \[Omega]0, \ \[Lambda]][t] (e) Be careful with Simplify and FullSimplify. They may OVER-simplify, giving an expression that's not valid for every value of the arguments. Integrate may do this as well. The Integrate result generally works if it is continuous in the range of interest. If not, find an expression that eliminates the jump points. Bobby On Sun, 20 Nov 2011 04:38:28 -0600, Herman16 <btta2010 at gmail.com> wrote: > I want to minimize det \tau over all Covariance matrix of > \[Sigma]t[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r] but At and Ct > are depend on real numbers that is, alpha, beta, lambda, t & r are > constants. > please look into the notebook below. > > Many thanks for any comments > > s[\[Omega]_, t_] := > FullSimplify[ > Integrate[ > Sin[\[Omega] \[Tau]] Sin[\[Omega]0 \[Tau]], {\[Tau], 0, t}]] > > > c[\[Omega]_, t_] := > FullSimplify[ > Integrate[ > Cos[\[Omega] \[Tau]] Cos[\[Omega]0 \[Tau]], {\[Tau], 0, t}]] > > > d[\[Omega]_, t_] := > FullSimplify[ > Integrate[ > Cos[\[Omega] \[Tau]] Sin[\[Omega]0 \[Tau]], {\[Tau], 0, t}]] > > J[\[Omega]_, \[Lambda]_] := \[Omega]/(\[Omega]^2 + \[Lambda]^2); > > J1[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, > t_] := (\[Alpha]^2*\[Beta]*\[Pi])/( > 2 (\[Omega]0^2 + \[Lambda]^2)) (Exp [-\[Lambda]* > t] ( \[Omega]0/\[Lambda]*Sin[t \[Omega]0] - > Cos[t \[Omega]0]) + 1); > > \[CapitalDelta][\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_] := > J1[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t]; > > > > J2[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_] := (\[Alpha]^2*\[Pi]*\ > \[Omega]0*\[Beta])/(2 \[Lambda] (\[Omega]0^2 + \[Lambda]^2)); > > J3[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, > t_] := -(\[Alpha]^2*\[Beta]*\[Pi]*Cos[t \[Omega]0])/( > 2 (\[Omega]0^2 + \[Lambda]^2)) (Sin[ > t \[Omega]0] + \[Omega]0/\[Lambda] Exp [-\[Lambda]*t]); > > > J4[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, > t_] := (\[Alpha]^2*\[Beta]*\[Pi]*Sin[t \[Omega]0])/( > 2 (\[Omega]0^2 + \[Lambda]^2)) (Cos[t \[Omega]0] - > Exp [-\[Lambda]*t]); > > J5[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, > t_] := (\[Alpha]^2*\[Beta])/(\[Omega]0^2 + \[Lambda]^2) \ > ((SinIntegral [\[Omega]0 t] + \[Pi]/2) + > 1/2 Exp [-\[Lambda] t] > ExpIntegralEi[\[Lambda] t] (\[Omega]0/\[Lambda] > Cos[t \[Omega]0] - Sin[t \[Omega]0]) - > 1/2 Exp [\[Lambda] t] > ExpIntegralEi[-\[Lambda] t] (\[Omega]0/\[Lambda] > Cos[t \[Omega]0] + Sin[t \[Omega]0])); > > \[CapitalPi][\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_] := > J2[\[Alpha], \[Beta], \[Omega]0, \[Lambda]] + > J3[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t] + > J4[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t]; > > > > \[Gamma][\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_] := > J5[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t]; > > > \[CapitalGamma][\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_] := > NIntegrate[ > 2*\[Gamma][\[Alpha], \[Beta], \[Omega]0, \[Lambda], s], {s, 0, > t}]; > > > \[CapitalDelta]\[CapitalGamma][\[Alpha]_, \[Beta]_, \[Omega]0_, \ > \[Lambda]_, t_] := > NIntegrate[ > J1[\[Alpha], \[Beta], \[Omega]0, \[Lambda], s], {s, 0, t}]; > > > > \[CapitalDelta]co[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_] := > NIntegrate[ > J1[\[Alpha], \[Beta], \[Omega]0, \[Lambda], s]* > Cos[2 \[Omega]0 (t - s)], {s, 0, t}]; > > > > \[CapitalDelta]si[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_] := > NIntegrate[ > J1[\[Alpha], \[Beta], \[Omega]0, \[Lambda], s]* > Sin[2 \[Omega]0 (t - s)], {s, 0, t}]; > > > > \[CapitalPi]co[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_] := > NIntegrate[(J2[\[Alpha], \[Beta], \[Omega]0, \[Lambda]] + > J3[\[Alpha], \[Beta], \[Omega]0, \[Lambda], s] + > J4[\[Alpha], \[Beta], \[Omega]0, \[Lambda], s])* > Cos[2 \[Omega]0 (t - s)], {s, 0, t}]; > > > \[CapitalPi]si[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_] := > NIntegrate[(J2[\[Alpha], \[Beta], \[Omega]0, \[Lambda]] + > J3[\[Alpha], \[Beta], \[Omega]0, \[Lambda], s] + > J4[\[Alpha], \[Beta], \[Omega]0, \[Lambda], s])* > Sin[2 \[Omega]0 (t - s)], {s, 0, t}]; > > > > > Clear[A0] > A0[r_] = {{1/2 Cosh[2 r], 0}, {0, 1/2 Cosh[2 r]}}; > > Clear[At, Ct] > > > > > At[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Re[ArrayFlatten[ > A0[r]*(1 - \[CapitalGamma][\[Alpha], \[Beta], \[Omega]0, \ > \[Lambda], > t]) + {{\[CapitalDelta]\[CapitalGamma][\[Alpha], \[Beta], \ > \[Omega]0, \[Lambda], > t] + (\[CapitalDelta]co[\[Alpha], \[Beta], \[Omega]0, \ > \[Lambda], > t] - \[CapitalPi]si[\[Alpha], \[Beta], \[Omega]0, \ > \[Lambda], > t]), -(\[CapitalDelta]si[\[Alpha], \[Beta], \[Omega]0, \ > \[Lambda], > t] - \[CapitalPi]co[\[Alpha], \[Beta], \[Omega]0, \ > \[Lambda], > t])}, {-(\[CapitalDelta]si[\[Alpha], \[Beta], \[Omega]0, \ > \[Lambda], > t] - \[CapitalPi]co[\[Alpha], \[Beta], \[Omega]0, \ > \[Lambda], > t]), \[CapitalDelta]\[CapitalGamma][\[Alpha], \[Beta], \ > \[Omega]0, \[Lambda], > t] - (\[CapitalDelta]co[\[Alpha], \[Beta], \[Omega]0, \ > \[Lambda], > t] - \[CapitalPi]si[\[Alpha], \[Beta], \[Omega]0, \ > \[Lambda], t])}}]]; > > > Ats[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Re[A0[r]*(1 - \[CapitalGamma][\[Alpha], \[Beta], \[Omega]0, \ > \[Lambda], > t]) + {{\[CapitalDelta]\[CapitalGamma][\[Alpha], \[Beta], \ > \[Omega]0, \[Lambda], t], > 0}, {0, \[CapitalDelta]\[CapitalGamma][\[Alpha], \[Beta], \ > \[Omega]0, \[Lambda], t]}}]; > > > > Ct[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > ArrayFlatten[{{1/ > 2 Sinh[2 r] Cos [ > 2 \[Omega]0 t]*(1 - \[CapitalGamma][\[Alpha], \[Beta], \ > \[Omega]0, \[Lambda], t]), > 1/2 Sinh[2 r] Sin [ > 2 \[Omega]0 t]*(1 - \[CapitalGamma][\[Alpha], \[Beta], \ > \[Omega]0, \[Lambda], t])}, {1/ > 2 Sinh[2 r] Sin [ > 2 \[Omega]0 t]*(1 - \[CapitalGamma][\[Alpha], \[Beta], \ > \[Omega]0, \[Lambda], t]), -1/2 Sinh[2 r] Cos [ > 2 \[Omega]0 t]*(1 - \[CapitalGamma][\[Alpha], \[Beta], \ > \[Omega]0, \[Lambda], t])}}]; > > > \[Sigma]t[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > ArrayFlatten[{{At[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r], > Ct[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r]}, {Ct[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r]\[Transpose], > At[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]}}]; > > > > \[Sigma]ts[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > ArrayFlatten[{{Ats[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r], > Ct[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r]}, {Ct[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r]\[Transpose], > Ats[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]}}]; > > > I1[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Det[At[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]] > > I1s[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Det[Ats[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]] > > I3[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Det[Ct[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]] > > > I4[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Det[\[Sigma]t[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]]; > > I4s[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Det[\[Sigma]ts[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]]; > > C1[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Re[\[Sqrt](1/( > 2 I1[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r]) (I1[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 + > I3[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 - > I4[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r] + > Sqrt[(I1[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 + > I3[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 - > I4[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r])^2 - (2 I1[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r]* > I3[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r])^2 ]))]; > > C1s[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Re[\[Sqrt](1/( > 2 I1s[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r]) (I1s[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 + > I3[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 - > I4s[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r] + > Sqrt[(I1s[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 + > I3[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 - > I4s[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r])^2 - (2 I1s[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r]*I3[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r])^2 ]))]; > > C2 [\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Re[\[Sqrt](1/( > 2 I1[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r]) (I1[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 + > I3[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 - > I4[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r] - > Sqrt[(I1[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 + > I3[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 - > I4[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r])^2 - (2 I1[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r]*I3[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r])^2 ]))]; > > C2s [\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Re[\[Sqrt](1/( > 2 I1s[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r]) (I1s[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 + > I3[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 - > I4s[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r] - > Sqrt[(I1s[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 + > I3[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 - > I4s[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r])^2 - (2 I1s[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r]*I3[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r])^2 ]))]; > > an[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Re[Sqrt[I1[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]]]; > > ans[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Re[Sqrt[I1s[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]]]; > > \[Kappa]1[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Re[Sqrt[(an[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r] - > C1[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r])*(an[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r] - > C2[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r])]] > > \[Kappa]1s[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Re[Sqrt[(ans[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r] - > C1s[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r])*(ans[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r] - > C2s[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r])]] > > xm[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Re[(\[Kappa]1[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 + 1/ > 4)/(2 \[Kappa]1[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r])]; > > xms[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Re[(\[Kappa]1s[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r]^2 + 1/ > 4)/(2 \[Kappa]1s[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r])]; > > g1[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, r_] := > Re[(an[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r] + 1/2) Log [ > an[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r] + 1/ > 2] - (an[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r] - 1/ > 2) Log [ > an[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r] - 1/2]]; > > > > \[Sigma]M[\[Rho]_, \[Phi]_] := > Cosh[2 \[Rho]]/ > 2 ({{1 + Tanh[2 \[Rho]] Cos[\[Phi]], -Tanh [ > 2 \[Rho]] Sin[\[Phi]] }, {-Tanh [2 \[Rho]] Sin[\[Phi]], > 1 - Tanh[2 \[Rho]] Cos[\[Phi]]}}) > > \[Tau][\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, > r_, \[Rho]_, \[Phi]_] := > FindMinimum[{Det At[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r] - > Ct[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, r] > Inverse[(At[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r] + \[Sigma]M[\[Rho], \[Phi]])] > Ct[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r]\[Transpose], \[Rho] >= 0, > 0 <= \[Phi] <= 2 \[Pi]}, {\[Rho], \[Phi]}] > > k[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, > r_, \[Rho]_, \[Phi]_] := > Re[Sqrt[\[Tau][\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r, \[Rho], \[Phi]]]] > > k1[\[Alpha]_, \[Beta]_, \[Omega]0_, \[Lambda]_, t_, > r_, \[Rho]_, \[Phi]_] := > Re[(k[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r, \[Rho], \[Phi]] + 1/2) Log [ > k[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r, \[Rho], \[Phi]] + 1/ > 2] - (k[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r, \[Rho], \[Phi]] - 1/2) Log [ > k[\[Alpha], \[Beta], \[Omega]0, \[Lambda], t, > r, \[Rho], \[Phi]] - 1/2]]; > > > I would like to minimize \[Tau][\[Alpha], \[Beta], \[Omega]0, \ > \[Lambda], t, > r, \[Rho], \[Phi]] the variables \[Alpha], \[Beta], \[Omega]0, \ > \[Lambda], t & r are constants. > -- DrMajorBob at yahoo.com
- References:
- Re: problem in minimization of a matrix
- From: Herman16 <btta2010@gmail.com>
- Re: problem in minimization of a matrix