# Tag Info

6

I believe the simplest change to your code is to replace the Return[\$Failed] expressions with Sets that restore the default values of the options: ClearAll[func] Options[func] = {Method -> Automatic, WorkingPrecision -> MachinePrecision, Order -> 2}; func::badval = "1 is not a valid value of option 2"; func[arg1_, arg2_, opts : ...

7

The default option for SoundNote is Options[SoundNote] {SoundVolume -> 1} One can change the default using SetOptions SetOptions[SoundNote, SoundVolume -> 1/2] Now all following SoundNote function calls will use the option SoundVolume -> 1/2.

5

To get a fixed step size with the BDF method you can lower the AccuracyGoal and PrecisionGoal to increase the adaptive step sizes and then use MaxStepSize to limit the step size to any value you want. Get an example stiff system from the documentation: Needs["DifferentialEquationsNDSolveProblems"]; Needs["DifferentialEquationsNDSolveUtilities"]; system ...

2

Following up on my comment, and depending on the exact option whose value you are trying to unset, it may work to set the value of that option to Inherited. In fact, the documentation states that when you set a value to Inherited, "If no explicit setting is given at any level, then a built-in default value is used" (from the second bullet point in the ...

0

Clear[f] f[rules_] := f[Sort[rules]] = (Pause[2]; g[ x , y ] /. rules ) f[{y -> 2, x -> 1}] // AbsoluteTiming f[{x -> 1, y -> 2}] // AbsoluteTiming {2.012387, g[1, 2]} {0., g[1, 2]}

2

Using Orderless: ClearAll[f] SetAttributes[f, Orderless] f[x[x_], y[y_], z[z_]] := {x, y, z} f[x[1], z[3], y[2]] (* Out: {1, 2, 3} *) You have to make sure that the heads (x, y, z) do not have values. If you prefer it you can also write the definition with prefix notation f[x@x_, y@y_, z@z_] := {x, y, z} f[x@1, z@3, y@2] which is just a little bit ...

Top 50 recent answers are included