# Tag Info

2

Well, let me try to answer the OP's question. And thanks MMA.SE, for reopening this interesting question! DATA To answer this question, you have to get the data using Mathematica's FinancialData function. This was the only thing originally done by the OP! First step: define which stocks will be included in the portfolio: Portfolio = {"AAPL", "BA", ...

4

Mathematica's answer is called an implicit solution. A simpler form the ODE shows the reason. $$\left( e^{f\left( x\right) }+e^{bf\left( x\right) }\right) f^{\prime }\left( x\right) =1$$ The solution $f\left( x\right)$ of the differential equation is given as a solution using inverse function. The reason is that there is no analytical ...

6

You can do the integral symbolically, then minimize numerically: distance = Integrate[(A*Exp[l*(Cos[x] - 1)] - Cos[x])^2, {x, -Pi/2, Pi/2}, Assumptions -> (A | l) \[Element] Reals] {min, sol} = NMinimize[distance, {A, l}] Plot[{A*Exp[l*(Cos[x] - 1)], Cos[x]} /. sol // Evaluate, {x, -Pi/2, Pi/2}, Filling -> {1 -> {2}}, PlotStyle -> ...

4

Unfortunately, as mentioned in the answer in which I presented it, the package does not support constraints at the moment. Since the Nelder-Mead method only deals with unconstrained problems anyway, the most realistic approach is probably to transform your constrained problem into an unconstrained one with the same solution. This is not as easy as it sounds, ...

3

Unfortunately the Method option is not documented in detail on the NonlinearModelFit documentation page. To summarize what we know so far (comments, documentation, etc.): NonlinearModelFit can either use numerical local optimization, or numerical global optimization. Local optimization is the same as used by FindMinimum and related functions. The ...

4

Use With: Table[With[{v = varx[[i]]}, D[#1, v] &], {i, 3}]` (* {D[#1, x1] & , D[#1, x2] & , D[#1, x3] & } *) See the section "Scope" of the documentation page for With. Note that Function (&) has the attribute HoldAll, so that the value of varx[[i]] needs to be inserted into the function. The above gives a list of operators. An ...

1

You can use Slot (#) but the pure function (&) should be at a different position, i.e. varx = {x1, x2, x3}; Table[List[#1, varx[[i]]], {i, 3}] & @@@ {{f, g}, {h, i}} {{{f, x1}, {f, x2}, {f, x3}}, {{h, x1}, {h, x2}, {h, x3}}}

1

For a quadratic function, sometimes the extreme value (max. or min.) occurs at the vertex, at $x = -b/2a$; otherwise, it will occur at one of the endpoints of the interval. In this case $a =5 >0$, so the maximum will occur at an endpoint, the one farthest from the vertex, $x = -b/2a = -1/10$. Thus it will be the right endpoint, $x = 5$. So, in terms of ...

5

Having an exact input we can find an exact solution: Maximize[{ 5 x^2 + x + 2, -5 <= x <= 5}, x] {132, {x -> 5}} We could simply provide appropriate mathematical tools fulfilling expectations (adequate conditions on derivatives of the function, i.e. vanishing of the first derivative (a critical point) and negativity of the second derivative, ...

1

opt = {a -> 5, b -> 1, c -> 2}; y = a x^2 + b x + c FindMaxValue[{y /. opt, -5 < x < 5}, x] (* 131.999999424241 *) If you want the x value also, use opt = {a -> 5, b -> 1, c -> 2}; y = a x^2 + b x + c; r = FindMaximum[{y /. opt, -5 < x < 5}, x]; Plot[y /. opt, {x, -5, 5},Epilog->{Red, PointSize[Large], Point[{x ...

1

It seems that putting NMinimize[Hold[f[x]], x] solved the issue.

8

Following the trend of posting alternative methods and skipping the obvious NMaximize[{t, sol[x, t] == 1, -58 <= x <= 50, 50 <= t <= 58}, {x, t}] max = SortBy[PixelValuePositions[ i = Binarize@Image[ContourPlot[s[x, t] == 1, {x, -50, -58}, {t, 50, 58}, Frame -> False, PlotRangePadding -> None], ImageSize->2500], ...

9

Before any real answer appears: ContourPlot[Evaluate[u[x, t] /. sol] == 1, {x, -50, -58}, {t, 50, 58} ] // Normal // Cases[#, Line[x__] :> x, Infinity][[ 1, ;; , 2]] & // Max 56.0628 ...and the real answer: U = u /. sol[[ 1]] FindRoot[{U[x, t] == 1, D[U[x, t], x] == 0}, {{x, -56}, {t, 54}}] {x -> -56.0326, t -> 56.0635} So ...

3

FindMaximum[loglikelihood[a, b], {{a, 1}, {b, 1.1}}] FindMaximum::lstol:The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient increase in the function. You may need more than MachinePrecision digits of working precision to meet these tolerances. More… {-4.42065, ...

3

Vector-valued variable's input syntax for FindMinimum The Documentation states (emphasis mine): <...> since the value of the function would be meaningless unless x had the correct structure, the definition is restricted to arguments with that structure. For example, if you defined the function for any pattern x_, then evaluating with an ...

Top 50 recent answers are included