Tag Info

Hot answers tagged

4

Here's a simple way to enumerate all the conditions: fs = {x, y, z, 0}; conds = Table[{Equal @@ fs1, And @@ Table[First@fs1 >= f, {f, Complement[fs, fs1]}]}, {fs1, Subsets[fs, {2}]}] (* {{x == y, x >= 0 && x >= z}, {x == z, x >= 0 && x >= y}, {x == 0, x >= y && x >= z}, {y == ...


4

For an exact solution: f[k_, x_] = -k^x + x^2; soln = Reduce[{f[k, x] == 0, D[f[k, x], x] == 0, x > 0}, {k, x}, Reals] // ToRules {k -> E^(2/E), x -> E} f[k, x] /. soln 0 k /. soln // N[#, 17] & 2.0870652286345330 Plot[f[k /. soln, x], {x, 2, 3}]


3

Having just one root requires eq1 = -k^x + x^2 == 0; eq2 = D[-k^x + x^2, x] == 0 (* 2*x - k^x*Log[k] *) FindRoot can solve for x and k simultaneously. FindRoot[{eq1, eq2}, {{x, 2.5}, {k, 2}}] (* {x -> 2.71828, k -> 2.08707} *) Plot[(-k^x + x^2) /. %[[2]], {x, 2, 3}]


3

It seems to be a bug, that manifests because of the fact that the answer could be positive or negative. If you look at the Trace of this operation, with TraceInternal -> True, you can see that it gets as far as finding the answer as a rounded version of $\pm720000\sqrt{6}$. It has candidate solutions of either Ceiling[-720000 Sqrt[6]] or Floor[720000 ...


3

Before I begin, a quick note. In the problem as stated, the optimal value of c is $-\infty$, since that makes the value of $f-(-\infty)g=f-\infty=-\infty$ (since $g<0$ for all $x\in(0,1)$). I'll instead work the problem of minimizing $|f-cg|$. First we can evaluate the Maximize statement, just to see what we get: Maximize[{Abs[f[x] - c g[x]], 0 < x ...


2

Just use NMaximize yRx1[a_, b_] := y /. #2 & @@ NMaximize[{Rx1[y, a, b], y > 0}, y] Example: yRx1[1, 1.5] (*0.903322*)


2

Isn't this is a problem of mathematics more than programming? Under the stated conditions, by permutation symmetry of the indexes of $v$ all entries of $v$ should be the same (up to absolute value, because in the problem statement all elements are squared). Thus one answer is $v$ is an array of $c$ entries each of which is $n/c$. This solution is ...


2

I take it you are interested in the minimum in the absolute value of the difference Abs[f[x]-c g[x]]. Otherwise, the answer is trivial: c=-Infinity. Let us define the functions: f[x_] := (-1 + x) Log[1 - x] - x Log[x]; g[x_] := Log[1 + 2 (-1 + x) x]; w[x_, c_] := f[x] - c*g[x]; and plot them: Manipulate[Plot[w[x, c], {x, 0, 1}], {c, -3, -0.1}] ...


1

Try data3 = Flatten[Table[{p[[i]], q[[j]]}, {i, 1, dimp}, {j, 1, dimq}], 1] Export["data3.dat", data3, "Table"];


1

You're like 99% of the way there. You just need to tell Mathematica that z is a vector by feeding it the components: With[{z = Array[v, 3]}, Minimize[{Total[z^4]/Total[z^2]^2, Total[z] == n}, z]] For dimensions 1 and 2 the answers are as expected. For 3 (the code above) Minimize outputs a bunch of ugly Roots. So although there is a symbolic solution, ...


1

From the documentation, StepMonitor is an option for iterative numerical computation functions that gives an expression to evaluate whenever a step is taken by the numerical method used. Meanwhile, EvaluationMonitor is an option for various numerical computation and plotting functions that gives an expression to evaluate whenever functions ...


1

Version 10 has a new function FindPeaks that can be used here: f[x_] := x Sin[x]; list = Range[1, 10, 0.1]; FindPeaks[f /@ list] This returns the location (in the list) and value of the local maxes. Another new function that's related is MaxDetect, which returns a vector of zeros (at all the non-max locations) and ones (at all the max locations). ...



Only top voted, non community-wiki answers of a minimum length are eligible