# Tag Info

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 ...

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], ...

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 -> ...

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, ...

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 ...

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 ...

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 ...

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 ...

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