# Tag Info

7

Assume that you have your lists of unique resistor values (resistors) and of unique capacitor values (capacitors). For now, I generate two such lists as follows: resistors = Flatten@ Outer[ Times, PowerRange[1, 10000], {100, 110, 120, 130, 150, 160, 180, 200, 220, 240, 270, 300, 330, 360, 390, 430, 470, 510, 560, 620, 680, 750, 820, ...

7

I took this code out of the examples given in ListSliceContourPlot3D . I only added the option BaseStyle -> Opacity[.6]. data = Table[x + y + z, {z, -1, 1, 0.2}, {y, -1, 1, 0.2}, {x, -1, 1, 0.2}]; Table[ ListSliceContourPlot3D[data, sl, BaseStyle -> Opacity[.6], PlotLabel -> sl], {sl, {"XStackedPlanes", "YStackedPlanes", ...

6

This looks like a numerical precision issue. Various approaches that precisely address this, all yield the same, correct solution: Scaling of the x values: data = {{0, 20}, {20, 10}, {40, 5}, {60, 2.5}, {80, 1.25}}; {xmin, xmax} = MinMax[data[[All,1]]]; data2 = {Rescale[data[[All, 1]]], data[[All, 2]]} // Transpose; fit1 = FindFit[data2, a*Exp[b*x], {a, ...

6

The problem is that during the evaluation process it attempts to numerically integrate using the symbol a. That is the source of the warning message. However, if you persist (and ignore the warning), ArgMin will eventually switch over to using numerical values and output the correct value. ArgMin[{NIntegrate[(Tanh[x] - Erf[x/a])^2, {x, -5, 5}], 0.5 ...

6

In the comments I supposed that the reason why the algorithm stops is obtaining zero derivative with respect to b at the point {a, b} = {0., 1.} returned as the minimum. Let us check this statement by perturbing the actual Jacobian a little bit in order to make all the derivatives non-zero. Proceeding from the code in the question, we find the Jacobian and ...

5

I am one of the many that does not consider this a bug as it is shared by probably the majority of statistical packages. (But there certainly is room for improvement in terms of warnings that could be given.) Iterative procedures work great if the starting values are close enough to the final values. When one doesn't know the final result this requirement ...

4

This basically directly computes the angle that a line drawn from the origin to the point makes with the horizontal axis, and uses this to sort: list = {{100, 200}, {200, 300}, {300, 300}, {320, 150}, {250, 210}, {350, 220}, {380, 100}, {390, 300}}; ordList = SortBy[list, Apply[N[ArcTan[#1, #2]] &]] (* {{380, 100}, {320, 150}, {350, 220}, {390, 300}, ...

4

Your F wrapper function is doing nothing for you in your code, so I removed it and replaced it with direct calls to F1. NIntegrate in the argument to FindMinValue should not be evaluated unless it is passed explicitly numerical arguments, so it is best to wrap it in a function protected by NumericQ (functiontominimize below). Since all the other functions ...

3

This is a fairly common problem to encounter and in this case was a bit subtle due to having an outer and inner function both in need of being defined only for explicitly numeric input. So I'll repost my comment as an answer and make it a Community wiki. The FindMinumum objective itself needs to be defined only for numeric input. Which can be done as ...

3

You can use FindRoot! First, take a look at the contour plot of $f$: ContourPlot[f[h, b], {h, 1, 6}, {b, 0, 6}, PlotPoints -> 100, Contours -> {0.1, 0.3, 0.5, 0.7, 0.9}, ContourLabels -> True, ContourShading -> None, ContourStyle -> GrayLevel@0.7, FrameLabel -> {h, b}] Note that there is a saddle point at $(h, b) = (1.75, ... 3 ParametricNDSolve will return a numerical ODE solution with any number of free parameters. This parametric solution can then be fed into NonLinearModelFit (or whatever home-brew chi-squared algorithm you want to cook up) to find the best-fit values for the parameters. As an example, suppose we want have the ODE$y''(x) = - y(x)$, with initial conditions ... 2 The following minimal change to the code produces results. l = 0; ch = 1; el = -.1; eh = .1; F[e_] = Max[0, Min[(e - el)/(eh - el), 1]]; d = .1; pi = .2; p2g = .05 Array[# &, 6]; p1sg = ConstantArray[0, 6]; Do[ Obj1[p_?NumericQ] := NIntegrate[(c + d - p) (1 - F[(1 - pi) p2g[[i]] + pi c - p]), {c, cl, p2g[[i]]}] + NIntegrate[(c + d - p) ... 2 As already stated in my comment, the solution is to use Set (=) for the "function definition" instead of SetDelayed(:=). The reason is that Set evaluates the r.h.s of l.h.s. = r.h.s. (abbreviations for left- and right-hand-side) once and whenever Mathematica encounters l.h.s it gets replaced with the evaluated form of r.h.s. SetDelayed on the other hand ... 1 Just forbid the symbolic treatment by defining a numerical function: x = {{9.19, -7.67}, {9.59, -7.32}, {9.81, -7.99}, {12.53, -9.98}, \ {7.40, -6.26}, {8.03, -6.94}, {9.40, -7.56}, {9.71, -7.63}, {8.15, \ -6.89}, {11.57, -9.48}, {11.82, -9.67}, {10.97, -9.15}, {7.57, \ -6.20}, {11.50, -8.91}, {8.06, -6.13}, {8.65, -7.17}, {8.39, -7.01}, \ {14.04, -11.65}, ... 1 Since your objective function (sol) is continuously differentiable and you consider an open set for the optimization variables$r_1,r_2,r_3$, if a minimum of sol exists, it must satisfy the first-order necessary conditions. That is, the gradient of sol with respect to$\{r_1,r_2,r_3\}\$ must be zero at the minimum. Therefore, we can solve a system of (in this ...

1

Here are two additional ways to do this. 1. ContourShading ContourShading is an option for ListContourPlot3D that allows one to specify graphics directives for each contour surface. However, such directives have to be specified explicitly, so I found it rather awkward to use: Table[ ListSliceContourPlot3D[ data, sl, ContourShading -> ...

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