3

We can find out easily enough: func[x_] := Pause[1]; Table[KroneckerDelta[M, 0]*func[M], {M, 0, 10}] // AbsoluteTiming Table[If[M == 0, func[M]], {M, 0, 10}] // AbsoluteTiming The first one takes 11 seconds, the second one takes 1 second. So in the one with the KroneckerDelta, it is evaluating the func for each value of M whereas the If[ ] construct only ...


3

Try NSolve to find all of the extrema: gln = D[1 + Sinc[8*(x - 1)]*Sinc[10*(y - 1)], {{x, y}}]; gln = Map[# == 0 &, gln {(x - 1)^2, (y - 1)^2} // Simplify] (* equation without singularity x=y=1*) NSolve is able to solve these equations in the given range 0<x,y<2 extrema =NSolve[{gln, 0 <= x <= 2 && 0 <= y <= 2} // Flatten, {x,...


2

Clear["Global`*"] ω0 = 145199 + 1; f = 1; b = ω0/4; The differential equation can be solved exactly x[t_, ω_] = DSolveValue[ {x''[t] + b x'[t] + ω0^2 x[t] == f Sin[ω t], x[0] == 0, x'[0] == 0}, x[t], t] // FullSimplify[#, 0 <= t <= 2 π/ω0] & EDIT: Use of arbitrary precision is necessary. This is done by specifying a WorkingPrecision ...


2

This is my solution abf = Function[l, Module[{x1, y1, x2, y2}, x1 = l[[1, 1, 1]]; y1 = l[[1, 1, 2]]; x2 = l[[1, 2, 1]]; y2 = l[[1, 2, 2]]; Solve[as x1 + bs y1 == 1 && as x2 + bs y2 == 1, {as, bs}] ]]; n = MeshPrimitives[mesh, 2] // Length; shre0 = Complement[MeshPrimitives[mesh, 1], MeshPrimitives[BoundaryMesh[mesh], 1]];...


2

As far as I understand you want to find x-coordinates of the two maximum peak values. I guess using FindPeaks can be useful in this case: d = Table[{x, f[10][x]}, {x, -5, 5, .01}]; Fp = FindPeaks[d[[All, 2]]] data1 = Map[{d[[All, 1]][[#[[1]]]], #[[2]]} &, Fp]; Now, just sort it sorted=Sort[data1, Last[#2] < Last[#1] &]; ...


2

Why not solve diffequation directly? u[c1_] = u /. First@DSolve[u'[t] == u[t]^2 + 1, u, t] /. C[1] -> c1 (* Function[{t}, Tan[t + c1]] *) Plot[Evaluate@Table[u[c1][t], {c1, -3, 3}], {t, 0, 1}]


1

First try NMinimize to get an impression where to look for. d[k_, a_, L_] = 400*Cos[k*L]^2 + a^2*k^2*(144 + 25*a^2*k^2)*Sin[k*L]^2 - a*k*240*Sin[2*k*L] // Simplify NMinimize[{d[k, a, L], 0 < a < L && k > 0 && L > 0}, {k, a, L}] (* {2.75304*10^-10, {k -> 1.17341, a -> 0.00155245, L -> 1.33773}} *) Guess ...


1

This can be solved by choosing a few arbitrary values of θ: FullSimplify[ Solve[0 == E^t (a x^2 + b y^2 + c z^2) /. {x -> r Cos[θ], y -> r Sin[θ], z -> m} /. θ -> {0, 1, 2}, {a, b}]] (* {{a -> -((c m^2)/r^2), b -> -((c m^2)/r^2)}} *) or Solve[0 == E^t (a x^2 + b y^2 + c z^2) /. {x -> r Cos[θ], y -> r Sin[θ], z -> m} /. ...


1

Firstly, one needs to appreciate that there is no unique solution to the problem at hand, so one cannot ask Mathematica to find the expected answer. At best, it can find the relation between the dependent variables ($a,b,c$ in the simplified example) in terms of independent variables ($r,t,\theta,m$). Fortunately, this is quite doable. The main function ...


1

I have no idea on your actual problem, but your simple example can be solved by choosing a few arbitrary values of θ: FullSimplify[ Solve[0 == E^t (a x^2 + b y^2 + c z^2) /. {x -> r Cos[θ], y -> r Sin[θ], z -> m} /. θ -> {0, 1, 2}, {a, b}]] (* {{a -> -((c m^2)/r^2), b -> -((c m^2)/r^2)}} *)


1

While getting good fits with theoretical models is most desirable/satisfying, if good predictions is the overall objective, why not just fit the data with a simple model? Also the objective in your linked notebook seems to be the estimation of two parameters ($a$ and $b$) which are assumed to be common to 4 datasets. That assumption might not likely be ...


1

data = {{-35., 0.315382}, {-30., 0.510487}, {-25., 0.808823}, {-20., 1.25604}, {-15., 1.91404}, {-10., 2.86533}, {-5., 4.21811}, {0., 6.11213}, {5., 8.7253}, {10., 12.2811}, {15., 17.0568}, {20., 23.3919}, {25., 31.6982}, {30., 42.4692}, {35., 56.2906}, {40., 73.8511}, {45., 95.9534}, {50., 123.525}, {55., 157.628}, {60., 199.474}, {...


1

Try to scale your data! dataS = Map[{#[[1]]/Max[data[[All, 1]]],#[[2]]/Max[data[[All, 2]]]} &, data]; f[t_, a_, b_, c_ ] := Exp[a + b/(c + t)]; fit = NonlinearModelFit[dataS, f[t, a, b, c],{a, b, c }, t]; fit["BestFitParameters"] The fit (scaled coordinates): Show[{ListPlot[dataS],Plot[{Normal[fit] }, {t, Min[dataS[[All, 1]]],Max[dataS[[All, 1]]]}]}]


1

All of the answers in @kglr's comment work: nm = Maximize[{x^0.5 - 2*y^3, 0 < x < 1, 0 < y < 1}, {x, y}]; y /. Last[nm] y /. nm[[-1]] nm[[-1, -1, -1]] (* 0.000023912 *) (* 0.000023912 *) (* 0.000023912 *)


1

Assuming that $(\cdot)'$ is transposition and considering a convenient restriction to avoid unlimited solutions, n = 4 b = 2; SeedRandom[1] PP = Array[a, {n, n}]; KK = RandomReal[{-1, 1}, {n, n}] + 4 b IdentityMatrix[n]; s = Partition[RandomReal[{-1, 1}, n], 1]; t = Partition[RandomReal[{-1, 1}, n], 1]; ones = Partition[Table[1, n], 1]; f = (1/4/b) (...


1

If we can't constrain any of the parameters to a domain like Reals, I'm not sure I would agree that this is easily minimized. What if Lambda is complex? All of a sudden your function is generating complex numbers. Is $4 + 3i < 3 + 4i$? If you want to compare these numbers, you'll have to tell Mathematica how you would like the comparison performed. What ...


1

These constraints are so complicated that it is very easy to get caught in local maxima. Maybe RandomSearch can find a way out. I got a much higher maximum than 0.186, namely 3.7354. (First I did some simplifications). Verification yields "True". d2 = d2 // Simplify[#, Thread[Join[Array[a, 10], Array[b, 10]] \[Element] Reals]] & vcfl = vcf[[1]] // ...


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