# Tag Info

8

Not an answer, more of a extended comment. (Since the question requires the use of PeakDetect.) Some (more than half actually) of the local extrema are missed. This becomes obvious using Log plots (modifying the code of ubpdqn): data = Table[{x, (Sin[10 x] + 2) Exp[-x^2]}, {x, -4, 4, .01}]; peaks = Pick[data, PeakDetect[data[[;; , 2]], .01, .0005], 1]; ...

6

It is because there is no general solution for your problem, even for b being a positive integer: When b is odd, the maximum is positive infinity, while for even b it is not. You may want to use things like Maximize[-x^# + a*x, x] & /@ Table[i, {i, 5}] to observe.

6

I wanted to be able to extract the path from your recursive memoized function, but I couldn't make it happen. But here is a function to find the minimum path from the upper left to the bottom right corners of an array of numbers, minimalpathsum[grid_] := Module[{dims, vertcoords, graph, weights, path, indices}, dims = Dimensions@grid; vertcoords = ...

5

findGlobalMin[func_, x_Symbol] := Module[ {min = MinValue[func, x] // Simplify}, {min, Select[ Solve[{ D[func, x] == 0, D[func, {x, 2}] > 0}, x] // Simplify, (func /. #) == min &]}] f[x_] = -5 x^4 + 5 x^6 + x^2; findGlobalMin[f[x], x]

5

You can do the example emulating pen/pencil and paper,e.g.: y[x_] := x^4 - x^2 c = x /. Solve[D[y[x], x] == 0, x] r = D[y[x], {x, 2}]; ans = Pick[c, (r > 0 /. x -> #) & /@ c] Plot[y[x], {x, -1.5, 1.5}, Epilog -> {Red, PointSize[0.02], Point[{#, y@#} & /@ ans]}]

5

The original problem is an interesting example where a direct usage of Solve and NSolve fails. However Reduce can succeed solving it if we set unknowns in an appropriate order, thus there is no need to play with numerical functionality if symbolic one can resolve the given system. We can observe that there is a solution under the given condition with a == ...

5

This is more of a long comment, hopefully you can find some of these ideas helpful because I don't know how to completely implement this. Therefore, I'd really appreciate comments from more experienced users about whether they think this is feasible or not. If we define a list of "switching times" and then define a function that takes this list as an ...

4

For 2D, Just find the Polygon representing the convex hull and just use RegionMember: (* fake data *) rand = Round[RandomReal[{0, 1}, {10, 2}], 1/100]; prims = MeshPrimitives[ConvexHullMesh[rand], 2][[1, 1]]; Refine[RegionMember[Polygon[Round[prims, 1/100]], {x, y}], {x, y} ∈ Reals] 1/25 (1/20 - x) + 18/25 (-(1/50) + y) >= 0 && -(23/25) ...

4

From the FindRoot documentation: FindRoot[lhs == rhs, {x, x0, x1}] searches for a solution using $x_0$ and $x_1$ as the first two values of $x$, avoiding the use of derivatives. ... If you specify two starting values, FindRoot uses a variant of the secant method. Indeed, that does the job pretty much instantly: FindRoot[func[u] - num == 0, {u, -3, 3}] ...

4

datadamped = Import["http://comsics.usm.my/tlyoon/teaching/ZCE111_1516SEM2/data/\ data_A6Q2.dat", "Data"]; max = datadamped[[#]] &@FindPeaks[datadamped[[All, 2]], 0][[All, 1]] min = datadamped[[#]] &@FindPeaks[-datadamped[[All, 2]], 0][[All, 1]] This gives you list of maximums and minimums. If you need a fit you probably want to simplify the ...

4

First, using the rest of your definitions, redefine x3 using Set so that it doesn't recompute the integral for each evaluation: Clear[x3] x3[t_, k_] = Simplify[ Integrate[1/m force[τ] 1/Sqrt[k/m] Sin[Sqrt[k/m] (t - τ)], {τ, 0, t1/2}, Assumptions -> t1 ∈ Reals] + Integrate[1/m force[τ] 1/Sqrt[k/m] Sin[Sqrt[k/m] (t - τ)], {τ, t1/2, t1}, Assumptions ...

3

Oh boy, what a question! This is very similar to some stuff I played a few weeks ago (Kerbal, what a game!). What follows solves (I think) the question you are asking. An approach that seemed to to help was to split the problem into to: before, and after the engine burn. I do this with the knowledge that the most efficient landing will comprise just a ...

2

It seems to me that generating only the valid combinations might be labor-intensive. Instead I first generate all possible combinations of elements, one from each column, labeling them with the indices of the rows from which each element was picked, and calculating the total you want to have minimized: allcombos = MapThread[ {#1, Total@#2} &, { ...

2

I'm assuming the objective is to find "the best" set of models (all with a single common parameter) with potentially different models for each of many data sets. Using NonlinearModelFit one could fit a combined model with all data sets and a specific set of models. One would obtain the AIC value for each of the all possible specific sets of models (one ...

2

By putting x^0.5 in your code, Mathematica assumes that you want to use machine arithmetic, and so will not return a result (since a doesn't have a definite numerical value.) If you use x^(1/2) or Sqrt[x] instead, Mathematica will try to solve the problem symbolically instead of numerically, and actually return a symbolic result. This result can then be ...

2

I think this is just a matter of using the correct syntax. Since Interval[{0, 10}] is a one-dimensional region, its elements have the form {x} instead of just x: RandomPoint[Interval[{0, 10}]] (* {3.23781} *) Element[%, Interval[{0, 10}]] (* True *) The documentation for NArgMax does say NArgMax[... , x ∈ reg] constrains x to be in the region reg ...

2

With a slight modification of your MinPath function so that it takes a matrix as input ClearAll[MinPathF, nextF] MinPathF[mat_][i_, j_] := MinPathF[mat][i, j] = mat[[i, j]] + Piecewise[{{Min[MinPathF[mat][i + 1, j], MinPathF[mat][i, j + 1]], i < Length[mat] && j < Length[mat[[i]]]}, {MinPathF[mat][i + 1, j], i < ...

2

Clear[range] range[v0_, theta_] := v0^2 Sin[2 theta]/g Solve[{D[range[v0, theta], theta] == 0, 0 <= theta <= 90 Degree}, theta] (* Out: {{theta -> π/4}} *)

1

One way to treat this in some very special, low dimensional and friendly cases is to use ParametricRegion (*Dimension and number of points*) d = 5; np = 4; (*Generate data*) data = RandomInteger[{-10, 10}, {np, d}]; (*Convex hull*) ws = Array[w, Length[data]]; reg3 = ParametricRegion[ {Sum[ws[[i]]*data[[i]], {i, Length@data}], Total[ws] == 1} , ...

1

Just another way (but not desired presentation style): grid = {{131, 673, 234, 103, 18}, {201, 96, 342, 965, 150}, {630, 803, 746, 422, 111}, {537, 699, 497, 121, 956}, {805, 732, 524, 37, 331}}; dim = Dimensions[grid]; vw = Catenate@ MapIndexed[ (#2[[2]] - 1) 5 + #2[[1]] -> #1 &, grid, {2}]; s = GridGraph[dim, VertexLabels -> "Name", ...

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