# Tag Info

2

A method is to write a message handler, like in this answer. The handler is passed an argument of the form Hold[Message[...], boolean] where the boolean tells the handler if the message is to be displayed, or not. Since you are looking to capture the info passed to NDSolve::ndsz, I would write the handler like Clear[messageHandler, vals]; vals = {}; ...

5

Albert Retey has demonstrated in a similar situation that you can use "EventLocator" to detect an event in NDSolve. For example: eqn = {\!$$\*SubscriptBox[\(∂$$, $$t$$]$$u[t, x]$$\) == 1/100 \!$$\*SubscriptBox[\(∂$$, $$x, x$$]$$u[t, x]$$\) - u[t, x] \!$$\*SubscriptBox[\(∂$$, $$x$$]$$u[t, x]$$\), u[0, x] == Sin[2 π x], u[t, 0] == u[t, 1]}; ...

1

Activate@Replace[Inactive[f][3],3->1, Infinity] 1 or Replace[Hold@f[3], 3 -> 1, Infinity] // ReleaseHold 1

2

Use Mapping multiple parameters of a function to specific values and supply it with the following version of parameters. parameters=Flatten[Table[{a, 1/bInverted}, {a, 1/2, 5, 1/2}, {bInverted, 2, 5}], 1] Update Let's redefine myfunction to be a function of a, b and x. myfunction[a_, b_, x_] := (b/a)*((a/x)^(b + 1)) Now when you generate parameters ...

2

I learned a lot from WReach's and Leonid's answers and I'd like to make a small contribution: It seems worth emphasizing that the primary intention of the list-valued second argument of Flatten is merely to flatten certain levels of lists (as WReach mentions in his List Flattening section). Using Flatten as a ragged Transpose seems like a side-effect of ...

1

ps = Accumulate[(1 + #)^2 (-1)^# & /@ Range[0, 9]] (* or ps = Accumulate[Range[#]^2 (-1)^Range[0, # - 1]] *) {1, -3, 6, -10, 15, -21, 28, -36, 45, -55} sps = Accumulate[ps] {1, -2, 4, -6, 9, -12, 16, -20, 25, -30} means = MapIndexed[#/First[#2] &, sps] {1, -1, 4/3, -(3/2), 9/5, -2, 16/7, -(5/2), 25/9, -3} Combine in single ...

2

This may be an answer. Your code is ill-formed. It does not conform to Mathematica syntax. I have rewritten it to be valid and to better correspond to your pseudocode. There is no guarantee that it actually corresponds to the process you want to simulate, but at least it prints output and terminates. I hope it will help you to move forward. With[{n = 2}, ...

0

Here's a little one-liner without If, probably not fast on large lists: corr = (! MemberQ[elList, #] & /@ els) /. {True -> 1.13, False -> 1.0}

1

If speed is not you concern, may be this can be worth a try common = Intersection[elList, els]; u = Map[ Position[els, # ] &, common ] ; corr[[ Flatten[u] ]] = 1.13 This can be fit in a single line, and is almost readable corr[[ Flatten[ Position[els, # ] & /@ Intersection[elList, els] ] ]] = 1.13 and will seem even more nice if you use (elList ...

11

You can rewrite your idea using If as follows: If[MemberQ[elList, #], 1., 1.13] & /@ els {1.13, 1., 1., 1.13, 1.} However you may find on larger problems that repetitive use of MemberQ is not as fast as you would like, so consider a hash table in the form of an Association, or if using an older version of Mathematica a Dispatch table. Create a ...

1

Define the integrand with the measure as integrand = c*Exp[-m*x^2/ω^m]*1/(Sqrt[2*π]*λ*ω)*Exp[-(Log[B] - μ)^2/(2*λ^2)] Dt[B, Constants -> {λ, m, x, μ, ω}]; where we use Dt[t] to represent the measure, which we will transform using the substitution: subs = Assuming[{μ > 0, λ > 0, B > 0, t ∈ Reals}, First@Solve[t == (Log[B] - μ)/(Sqrt[2] λ), B, ...

0

(z[x, y]@@(Values[data1]))@@(Values[data2]) (* or z[x, y][##&@@(Values[data1])][##&@@(Values[data2])] *) -0.357143+0.5 (x+y) Plot3D[(z[x, y]@@(Values[data1]))@@(Values[data2]), {x, 0, 1}, {y, 0, 1}] (* or Plot3D[z[x, y][##&@@(Values[data1])][##&@@(Values[data2])], {x, 0, 1}, {y, 0, 1}]*)

1

I think you almost did right, but you need to give the distribution rather than the PDF of a distribution when evaluating the expectation. For example: f[x_] := Sqrt[2]/Pi/(1 + x^4) distX = ProbabilityDistribution[f[x], {x, -Infinity, Infinity}]; distY = TransformedDistribution[X^2, X \[Distributed] distX]; distI = TransformedDistribution[2 Y + 1, Y ...

Top 50 recent answers are included