# Tag Info

1

A DensityPlot helps in picking good starting values for FindMaximum: DensityPlot[ 1/2*Abs[(o - u)^2/(1 + o^2 + u^2 + 2*o*u + 2*o^2*u^2)]^2, {o, -5, 5}, {u, -5, 5}, PlotRange -> All, PlotPoints -> 50, PlotLegends -> Automatic] Then using the aproximate values from the DensityPlot FindMaximum locates one of the points FindMaximum[ 1/2*Abs[(o ...

1

You can find and exclude the part of the domain where the integrand is discontinuous. To find where the integrand is discontinuous, look for where the argument of Arg is real and negative, since Arg has a branch cut discontinuity there: z[\[Gamma]_,\[Beta]_,\[Omega]_]:=(Times@@(secondOrderDelayedAllPass[#,\[Omega]]&/@\[Gamma]))* ...

2

As I understand your question your are trying to use NMaximize where you want to constrain a parameter to belong to a custom domain. One way to do it is to use Or on the individual elements of the domain list. dom = {1, 2, 3, 4}; Or @@ Map[a == # &, dom] (* a == 1 || a == 2 || a == 3 || a == 4 *) Use this in NMaximize as a constraint. NMaximize[{a^...

2

If you introduce a spherical coordinates parametrization $a=\sin(q)$, $b=\cos(q)\cos(\phi)$, $c=\cos(q)\sin(\phi)$, you can write your problem in much simpler terms: f1 = 1/2 (1 + Sqrt[Sin[q]^2 + k^2 Cos[q]^2]) f2 = 1/2 (1 + Sin[q]^2 + k Cos[q]^2) where $k=\exp(\gamma(t))$ Now for a given value of $k=\exp(\gamma(t))$ you can do the 1d numerical ...

2

Let us simplify your formulas manually first. Let us denote $e^{-\gamma(t)}$ by e, and $a^2, b^2, c^2$ by a2, b2, c2. Then f1 = 1/2 (1 + Sqrt[a2 + b2 e^2 + c2 e^2]); f2 = 1/2 (1 + a2 + e (b2 + c2)); You want to maximize f1 - f2 with the constraints $a^2+b^2+c^2=1$ and $a,b,c \in [0,1]$. From your notation, I also assume that $0 < e^{-\gamma(t)} <... 1 For a given a, b, and t and changing gamma, we can see that the diference between the two functions stops changing for large values of gamma. f1[a_, b_, c_, t_] := 1/2 (1 + Sqrt[ a^2 + (b Exp[-\[Gamma] (t)])^2 + (c Exp[-\[Gamma] (t)])^2]) f2[a_, b_, c_, t_] := 1/2 (1 + a^2 + Exp[-\[Gamma] (t)] (b^2 + c^2)) v = {10., 15., 7.} {a, ... 1 Try this$Assumptions = {w, x, y, z} \[Element] Reals; f = {1/2 (-x - y + Sqrt[4 w^2 + x^2 - 2 x y + y^2]), 1/2 (-x - y - Sqrt[4 w^2 + x^2 - 2 x y + y^2]), -z, x + y - Sqrt[4 w^2 + x^2 - 2 x y + y^2], x + y + Sqrt[4 w^2 + x^2 - 2 x y + y^2], 2 z}; Table[c = f[[i]]; d = Drop[f, {i}]; Simplify[Reduce[And@@Map[c<=#&, d], {w, x, y, z}]], {i, 1, ...

4

Method -> "PrincipalAxis" gives a result: {0.236921, {q -> {-2.27053, -1.95057, -2.27053, -2.30068, -2.30068}}} According to the documentation Direct search methods which do not require derivatives can be helpful in these cases This also means NMinimize might be a good option.

2

I haven't really checked if this produces sensible results. Module[{shops, products, singlePrices, deliveryCosts, amount}, shops = 5; products = 10; (* Bogus data. *) singlePrices = Table[RandomVariate[NormalDistribution[n, 1/5], shops], {n, products}]; deliveryCosts = RandomVariate[NormalDistribution[5, 1], shops]; amount = ...

4

The following is an adaptation of my answer to this question, which focused on the 3D linear least-squares problem. (* Rules to get constants out of sums (or integrals etc) *) outrules = { Sum[f_ + g_, it : {x_Symbol, __}] :> Sum[f, it] + Sum[g, it], Sum[c_ f_, it : {x_Symbol, __}] :> c Sum[f, it] /; FreeQ[c, x], Sum[c_, it : {x_Symbol, __}] :...

2

Just add: NMaximize[{Norm[EField[x, y]], {x, y} ∈ solution["ElementMesh"]}, {x, y}] Which gives: {58.362, {x -> 2.95481, y -> 0.186586}} Showing everything together: {eMax, {xMax, yMax}} = NMaximize[{Norm[EField[x, y]], {x, y} ∈ solution["ElementMesh"]}, {x, y}] /. sol : {__Rule} :> Values[sol] Show[ DensityPlot[solution[x, y], {x, y} ∈ ...

1

Not a real answer, too long to put in a comment... What I would suggest is to use smaller precision goals and restrain NIntegrate's adaptive algorithm. This way you can get an answe in a relatively short time, analyze does it make sense, and continue with refinements that require more computational time. The code below produces results under 35s on my ...

2

I guess you could just do the minimization numerically. f[a_, alpha_, b_, beta_, tau_, t1_, t2_] := (2 (3 a^2 + 3 a alpha t1 + alpha^2 t1^2))/t1^3 + (2 (3 b^2 - 3 b beta t2 + beta^2 t2^2))/t2^3 - (1 - t1 - t2) tau fmin[a_, alpha_, b_, beta_, tau_] := NMinValue[{f[a, alpha, b, beta, tau, t1, t2], t1 >= 0 && t2 >= 0 && t1 + ...

1

Consider pre-evaluating your region descriptor conditions: regiondescriptor = Tr[{{0.09, 0}, {0, 7}}.{{x1^2, x1*x2}, {x1*x2, x2^2}}] <= 1 && Tr[{{7, 0}, {0, 0.09}}.{{x1^2, x1*x2}, {x1*x2, x2^2}}] <= 1 && Tr[{{1.05, -0.95}, {-0.95, 1.05}}.{{x1^2, x1*x2}, {x1*x2, x2^2}}] <= 1 && Tr[{{1.05, 0.95}, {0.95, 1.05}}.{{x1^2, ...

1

Your problem is caused by your trying to use T both as vector and scalar at the same time. That is bound to cause problems. happy fish indicated a quick-and-dirty fix in a comment to your question. Here is an attempt to produce a solution the roots out the structural problem. T = 100; (* modified *) tc = {126.1, 190.6}; pc = {33.94, 46.04}; ω = {0.040, 0....

0

Marsaglia's method: uniform on disk (here rejection method), transform by Lambert azimuthal equal-area projection: http://mathworld.wolfram.com/SpherePointPicking.html uniformDisk[n_] := Take[Select[Table[RandomReal[{-1, 1}], {3 n}, {2}], #.# <= 1 &], n]; diskToSphere[p_] := {2 p[[1]] Sqrt[1 - Dot[p, p]], 2 p[[2]] Sqrt[1 - ...

0

Referring back to my answer regarding the "PrincipalAxis" method, and the documentation: For an $n$-variable problem, take a set of search directions $u_1,u_2,...,u_n$ and a point $x_0$. Take $x_i$ to be the point that minimizes $f$ along the direction $u_i$ from $x_{i-1}$ (i.e. do a line search from $x_{i-1}$), then replace $u_i$ with $u_{i+1}$. ...

Top 50 recent answers are included