Tag Info

New answers tagged

2

Here is a method using Off and On triggered by the first appearance of the message. I avoid unprotecting any System Symbols by using TagSetDelayed. I use $Post to turn the message back on. Modification of your function is not required; this operates via the low-level Message system. Code: badness::oops = "Watch out! Result could be ...


3

It's been a day and no has posted a truly elegant, natural, and general solution, so I'll post a narrow one. By default, a message is stopped when it occurs three times in $MessageList. One can reduce the number of times a message is printed by pre-loading $MessageList with it. Block[{$MessageList}, Unprotect[$MessageList]; $MessageList = ...


0

This is a bit ugly, but it seems to do what you want. ClearAll[badness]; badness::oops = "Watch out! Result could be misinterpreted."; badness[0] /; badness[] := (Message[badness::oops]; badness[] = False; 0); badness[_] := 0 Clear[reduction] f[0] = 0; badness[] = True; reduction = {f[x_] :> x + f[x - 1] + badness[0]}; All it does it keep track of ...


4

We can use Hold to prevent message names from being evaluated until the time is right: g[a_, verbose_:False] := Module[{messageList} , messageList = If[verbose, {}, Hold[FindRoot::lstol]] ; messageList /. _[m___] :> Quiet[FindRoot[x^2 + x + a, {x, 3}], {m}] ]


1

another workaround example: problem msg = {General::argx, Power::infy} Quiet[1/0 + Sqrt[], Evaluate@msg] example: workaround msg = {General::argx::English, Power::infy} Quiet[1/0 + Sqrt[], Evaluate@msg] it seems: messages, which take arguments are problematic


3

I have found a workaround which works for my purposes, though it is not particularly pretty, and the weird behaviour of Evaluate on error messages remains a mystery to me. It is possible to switch between different Quiet behaviours by setting a custom message group and then switching that within the logic. The following code works, as far as I can tell. ...


4

NDSolve has already detected the largest such intervals for you, which is why the resulting InterpolatingFunctions have restricted domains. You can use InterpolatingFunctionDomain to extract those domains. I'd do something like so Clear[x1, x2, y] eqn = {x1'[t] == -x1[t]^2 - x2[t] + y[t]^3, x2'[t] == x1[t] - x2[t] + x1[t]^2 x2[t]^2, y'[t] == x2[t]^2 ...


1

This seems to work for me: thisstep = 0; laststep = 0; eqn = {x1'[t] == -x1[t]^2 - x2[t] + y[t]^3, x2'[t] == x1[t] - x2[t] + x1[t]^2 x2[t]^2, y'[t] == x2[t]^2 + y[t] + x1[t]^2 y[t]^2 + 0.5` y[t]^3, x1[0] == 1, x2[0] == 1, y[0] == 1}; {tmin, tmax} = {-1,1}; First@NDSolve[eqn, {x1[t], x2[t], y[t]}, {t, tmin, tmax}, MaxStepFraction -> 1/150, ...


9

One possible solution is using Quiet: ds[All, Quiet[#a/#b]&] Another possible solution is using the FailureAction option: ds[All, #a/#b, FailureAction -> None]


1

To answer the first question: ListAnimate[list] stores the list in the output, while Animate[code,...] stores only the code. Animate does not store the definitions of symbols referenced by code. If code is not self-contained, then the definitions will have to be executed before Animate will run properly. To answer the second question, which is also ...


2

I think I solved this problem. The error message was due to the fact that Mathematica cannot perform the internal integration, so I split the two integrations and used NIntegrate instead of the symbolic integration: p[z1_?NumericQ, R_?NumericQ, z_?NumericQ] := -NIntegrate[ BesselK[0, x/Ld]*x* ArcSin[(2*x)/( Sqrt[(z1)^2 + (x + 7.6)^2] + ...



Top 50 recent answers are included