Tag Info

Hot answers tagged

12

As described e.g. in the tutorial Numerical Nonlinear Global Optimization there are different optimization methods available. For your problem "SimulatedAnnealing" seems to work: NMaximize[{Theta[t], 0 <= t <= tmax}, t, Method -> "SimulatedAnnealing"] {0.687071, {t -> 48.2449}} "DifferentialEvolution" will work, if the population is of ...


9

Two approaches: Finding maxima (1) of an InterpolatingFunction and (2) via NDSolve. InterpolatingFunction To find the extrema of an InterpolatingFunction, one should start with the data contained in the function. Let's start with the function itself; ifn = theta /. sol Then ifn["Grid"] and ifn["VaiuesOnGrid"] contain the abscissas (t) and ordinates ...


4

Using Mathematica: (eqn = Inactive[Sum][r^i, {i, 0, n}] == Sum[r^i, {i, 0, n}]) // TraditionalForm eqn // Activate True You can differentiate an equation (eqn2 = D[eqn, r] // FullSimplify) // TraditionalForm eqn2 // Activate // Simplify True More detailed (eqn3 = Inactive[D][Inactive[Sum][r^i, {i, 0, n}], r] == ...


2

One can rewrite first OP's method a bit and obtain up to 500x speedup by using PackedArrays SetSystemOptions["CatchMachineUnderflow" -> False]; x = N@Range[100]; data = func[x, 5., 50., 3.]; n = N@Range[0, 500]; a = 5.; b = 50.; c = 3.; sig = 2.; Total[func[x, a, b, c] - Log@Total@Exp[ Outer[Times, n, Log@func[x, a, b, c]] - Outer[Times, ...


2

I think it is a working precision problem because you work with big numbers (for Factorial, Gamma and HypergeometricU these numbers are big). Therefore, you can simply increase the precision Nprob[α_, γ_, T_, k_] := prob @@ SetPrecision[{α, γ, T, k}, 100] prob[0.145, 1.71, 53, 100] Nprob[0.145, 1.71, 53, 100] 0. ...


1

ClearAll[f, r, obj, x]; f[r_, x_] := Exp[-(x + r*Cos[x])^2] obj[r_?NumericQ] := NIntegrate[f[r, x], {x, -1, 1}] NMaximize[obj[r], r] (* {1.49365,{r->-1.25605*10^-8}} *)



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