Tag Info

Hot answers tagged

10

You could try something like the following. bounded[Indeterminate] := $MaxMachineNumber; bounded[x_?NumericQ] := x This gives a very large number instead of Indeterminate so NMinimize keeps searching. NMinimize[bounded[J[{θ0, θ1, θ2}, X1, y1]], {θ0, θ1, θ2}] (* {0.203498, {θ0 -> -25.1613, θ1 -> 0.206231, θ2 -> 0.201471}} *) Incidentally, ...


5

As it stands the integral does not converge! To see that note that Series[Log[1 + y^2]/Cos[Pi y], {y, 1/2, 0}] returns $$-\frac{\log \left(\frac{5}{4}\right)}{\pi \left(y-\frac{1}{2}\right)}-\frac{4}{5 \pi }+O\left(y-\frac{1}{2}\right)$$ and a simple pole is not integrable. What you maybe want to know is Cauchy's principle value of the integral ...


4

There are two problems with your code: 1. Incorrect Usage of WhenEvent As the name indicates WhenEvent is meant to be used when you want to e.g. switch at certain events, what I think you try to do is to set a'[t] to zero for a whole period (0<=t<=0.1), but that's AFAIK not what WhenEvent can be used for directly. Of course you can reformulate your ...


3

You may try something like: raw = FinancialData["GE", All]; fraw = Flatten[raw]; data = Table[fraw[[4*i]], {i, 1, Length[raw]}];(*extracting just the prices*) model = A + B*Abs[c - x]^z; fit = FindFit[data, {model}, {A, B, c, z}, x]; modelf = Function[{t}, Evaluate[model /. fit]] Show[Plot[modelf[x], {x, 0, 12000}], ListPlot@data]


2

I'm not familiar with the physics so I cannot say whether integrating over this set of 2 real dimension, in C^2, is what is wanted. I think the code below will cover the product space of the contours that are requested. ii = z1*z2/(p/z2 + (1 - p) z1 - 1)*Exp[1/z1 + z1 + 1/z2 + z2]; i1 = (ii /. {z1 -> Exp[I*t1], z2 -> Exp[I*t2]})*I*Exp[I*t1]*I* ...


2

For your first integral, NIntegrate gives warnings or messages about failing to converge when not excluding the singular points. When excluding the singular points I trust the result 13.6216 + 0. I because some alternative methods agree. Monte Carlo sampling: In[76]:= NIntegrate[ 1/Abs[tk], {kx, 0, 2 Sqrt[3] Pi/3}, {ky, 0, 4 Pi/3}, Method -> ...


1

One problem is using NumericQ - see What are the most common pitfalls awaiting new users? Another problem is how many times NIntegrate is being called. To do the 2D integral in FF, f4 will be called tens of thousands of times. Computing f4 in turns does three 1D integrations, which will call f1, f2, f3 several hundred times. And there's still one more ...



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