Tag Info

New answers tagged

1

I think GridLineData should be optimized by adding a condition as below: Classify the data that has been sorted by using this condition that the numerical difference is small (i.e., two data is very close to) (classification interval is set to δ), In each class of data, the minimum number of as a representative of the group(the last group must take ...


1

How about this? Grid[Prepend[ Flatten[Table[{a, b, Reverse@NMinimize[{a x + b y, 0.2 x + 0.1 y >= 14, 0.25 x + 0.6 y >= 30, 0.1 x + 0.15 y >= 10, x >= 0, y >= 0}, {x, y}]}, {a, 0, 3, 1}, {b, 0, 3, 1}] /. {ap_, bp_, {{x -> xp_, y -> yp_}, axbyp_}} :> {ap, bp, xp, yp, axbyp}, 1], {"a", "b", "x", ...


1

I'm not sure exactly what you want, but in an effort to demonstrate some possibilities: Join @@ Table[{{a, b}, NMinimize[{a x + b y, 0.2 x + 0.1 y >= 14, 0.25 x + 0.6 y >= 30, 0.1 x + 0.15 y >= 10, x >= 0, y >= 0}, {x, y}][[2]]}, {a, 0, 3, 1}, {b, 0, 3, 1}] // Column Or: Join @@ Table[{{HoldForm[a] -> a, HoldForm[b] -> ...


0

This seems to work: A = Sort@{10, 0, 10, 20, 20, 20, 20, 30, 30}; per = Permutations[A]; tot = Total /@ Abs[Differences /@ per]; pos = First@Flatten@Position[tot, Length@A*10 - 10]; (for other spacings replace 10 by f.e. 5). Partition[per[[pos]], 3] {{0, 10, 20}, {10, 20, 30}, {20, 30, 20}} For odd A: B = Prepend[A, Min@A]; and repeat the ...


3

Mathematica 10 introduces Indexed allowing this without error messages: FindMinimum[(Sum[Indexed[a, i]*Cos[1.3], {i, 1, 2}])^2, {a, {2, 0}}] {3.97214*10^-18, {a -> {1., -1.}}}


2

I think the trick is to use the RandomSeed option as shown below: Do[Print[NMinimize[{fourVertIsoHamilt[x11,x12,x13,x14,x21,x22,x23,x24,x31,x32,x33,x34,x41,x42,x43,x44], ...


2

Using Experimental`NumericalFunction framework directly (FindMinimum uses it under the hood) it is straightforward to get the numerical approximation of the Hessian: f = Experimental`CreateNumericalFunction[{x, y}, Cos[x^2 - 3 y] + Sin[x^2 + y^2], {1}, Hessian -> FiniteDifference]; f["Hessian"[{1.376384972443001`, 1.6786760817546214`}]] ...


1

Several issues: You don't have to OpenWrite a file when you use Export. Export will do everything for you. OpenWrite is for situations where you want to do low-level file operations. You can use Element[{a,b,c},..] to say say that a,b,c should be Integers. When you want to store values of EvaluationMonitor it is maybe easier to use Sow and Reap. {result, ...


2

Task: Minimize Differences[m, {0, 1}] those matrices under the constraint: Total[m,{2}]==Total[moptimized,{2}] First of all, that optimization objective doesn't make much sense: It's a matrix, not a scalar. So which value of the difference matrix should be optimized? The (possibly weighted) mean? The lowest or highest value? The median? ...


2

I apologize if I misunderstand your aim. Here is a first attempt. m = {{8, 23, 1, 3, 19}, {25, 4, 21, 7, 15}, {5, 9, 17, 21, 12}, {10, 3, 5, 15, 15}, {17, 15, 10, 16, 11}}; fun[lst_] := Module[{st, lg, md, mx}, st = Sort[lst]; lg = Length[lst]; md = Floor[lg/2]; If[Mod[lg, 2] == 1, Take[st, md]~Join~{Last@st}~Join~Reverse[Take[Most@st, ...


0

Normally I would use a comment, but I don't have this privilege now Part[#, -{2, 1, 3, 4, 5}] &@Sort@# & /@ m // MatrixForm Is this ok for you?


0

The problem lies in the incorrect use of the E notation for large and small numbers, such as 6.47368e-07. You should indicate powers of 10 explicitly: 6.47368*10^-7 If you want to clean up your notation, you should note that (i) spaces between numbers are always interpreted as products, (ii) you can get nice-looking multiplication signs by typing ...


4

Is this what you are after? Manipulate[ Graphics[{Point[#]}, ImageSize -> 1000, AspectRatio -> Automatic, Frame -> True, GridLinesStyle -> Thin, GridLines -> Composition[ Map[ If[#[[2]] - #[[1]] < 10^δ, ## &[], Mean[#]] &, #, {2}] &, Partition[#, 2, 1] & /@ # &, ...


2

Reduce[x^2+y^2==(2 x^2+2 y^2-x)^2,{y},{x},Reals] -((3 Sqrt[3])/8) <= y <= (3 Sqrt[3])/8


7

In version 10, RegionBounds@ImplicitRegion[x^2 + y^2 == (2 x^2 + 2 y^2 - x)^2, {x, y}] (* {{-(1/8), 1}, {-((3 Sqrt[3])/8), (3 Sqrt[3])/8}} *)


4

Also just for fun (in case you don't like to solve equations): cp = ContourPlot[x^2 + y^2 == (2 x^2 + 2 y^2 - x)^2, {x, -1, 2}, {y, -1, 1}, AspectRatio -> Automatic]; x = Cases[cp, {_Real, _Real}, Infinity]; points = Point /@ {Take[SortBy[x, First], 2], First@SortBy[x, Last], Last@SortBy[x, First], Last@SortBy[x, Last]}; Show[cp, ...


3

I post this just for fun. It does not address the general question of maximizing implicit function but Kuba has shown how to maximize y subject to constraint f(x,y). The problem can (with a small amount of manipulation) converted to explicit polar form: $r=0.5(cos\theta+1)$. Using this: rho[t_] := (Cos[t] + 1)/2; ycrit = Solve[D[Cos[u] Sin[u] + Sin[u], u] ...


6

This implicit equation is simple enough to be converted to explicit equations eqn = x^2 + y^2 == (2 x^2 + 2 y^2 - x)^2; yExpr = (y /. Solve[eqn, y]); yMax = SortBy[Maximize[#, x] & /@ yExpr, N[First[#]] &][[-1, 1]]; yMin = SortBy[Minimize[#, x] & /@ yExpr, N[First[#]] &][[1, 1]]; xExpr = (x /. Solve[{eqn, yMin < y < yMax}, x, ...


16

Maximize[{y, x^2 + y^2 == (2 x^2 + 2 y^2 - x)^2}, {x, y}] {(3 Sqrt[3])/8, {x -> 3/8, y -> (3 Sqrt[3])/8}}


10

You could use Lagrange multipliers to maximize $f(x,y)=y$ subject to the constraint that $$g(x,y) = x^2 + y^2 - (2 x^2 + 2 y^2 - x)^2 = 0.$$ f[x_, y_] = y; g[x_, y_] = x^2 + y^2 - (2 x^2 + 2 y^2 - x)^2; eqs = {D[f[x, y], x] == lambda*D[g[x, y], x], D[f[x, y], y] == lambda*D[g[x, y], y], g[x, y] == 0}; Solve[eqs, {x, y, lambda}] // InputForm (* Out: { ...


1

You function is f = x^2 + y^2 - (2 x^2 + 2 y^2 - x)^2; Then call function Maximize Maximize[f, {x, y}] (*{27/64,{x->3/4,y->0}}*) And here is plot of you function


1

Presumably you are dealing with something like this: x1 = {1, 2, 3, 4, Range[0, 10, 1/3], 5, Sequence @@ Range[6, 99]}; x2 = Shallow[x1] {1,2,3,4,{0,1/3,2/3,1,4/3,5/3,2,7/3,8/3,3,<<21>>},5,6,7,8,9,<<90>>} You may not have an explicit Shallow or Short in your code; rather it may be applied automatically as part of a formatting ...



Top 50 recent answers are included