# Tag Info

15

Let me first answer your second question, since I can only guess about the main question: I also observed that the syntax colouring (version 10, windows 7) suggests that Trace can be used with only two arguments. It's really just the coloring that goes wrong and has nothing to do with functionality. You can see that it is not even related to ...

13

Normally I like to use On and Off for this kind of tracing as it is easy to set up without modifying any symbols. However, it does not immediately work in this case: On[Roots] Solve[x^3 - 2 x + 12 == 0, x]; Off[] This does not produce any trace messages. Something must be using Quiet to suppress them. We can check this hypothesis: On[Quiet] Solve[x^3 ...

10

Plot[PDF[MixtureDistribution[{6, 3}, {UniformDistribution[{-3, 3 - $MachineEpsilon}], UniformDistribution[{3 +$MachineEpsilon, 6}]}], x], {x, -3, 6}, Filling -> Axis] To generate your data: RandomVariate[ MixtureDistribution[{6,3}, {UniformDistribution[{-3, 3 - $MachineEpsilon}], ... 9 More a comment than an answer, (but I have not enough reputation): This is a well known problem, although by far not solved. (One might not expect, but is of very practical relevance in software testing.) You find a lot of interesting stuff (theory and algorithms) by googling "orthogonal array" or - even better - "mixed orthogonal array". Also the book ... 8 You cannot Quit kernel while evaluation is still running: the Quit[] command will be placed in the queue and executed only after finishing of evaluation of all the previous inputs. In contrast, Evaluation>>Quit Kernel will quit the kernel immediately even if it is still running. UPDATE As Kuba notice in the comments, via "Preemptive" link it is ... 7 Just for fun: f[a_, t_] := a {t - Sin[t], 1 - Cos[t]} Manipulate[ ParametricPlot[{f[1, 4 t], f[2, 2 t], f[4, t]}, {t, 0, 4 Pi}, PlotStyle -> {Red, Green, Blue}, Epilog -> {{Orange, Circle[{4 p, 1}, 1], Black, PointSize[0.015], Point[f[1, 4 p]]}, {Orange, Circle[{4 p, 2}, 2], Black, PointSize[0.015], Point[f[2, 2 p]]}, {Orange, ... 7 a = -0.06; b = 0.04; c = 0.1; d = 0.54; f = (a x^3 + b x^2 + c x + d) Sqrt[1 - x^2]; To view the volume, you can use: RevolutionPlot3D[f, {x, -1, 1}, RevolutionAxis -> {1, 0, 0}] the volume is: v = Integrate[Pi f^2, {x, -1, 1}] (*1.263*) 7 The issue is lack of HoldFirst in attributes of your function, Sow is being called too early otherwise before Reap can capture ClearAll[reap2] SetAttributes[reap2,HoldFirst] reap2[x_]:=Join @@ Reap[x][[2]] idea to use Join@@ taken from @Mr.Wizard from here What is shorthand way of Reap list that may be empty because of zero Sow 6 See : Language Overview: http://reference.wolfram.com/language/guide/LanguageOverview.html and Wolfram Language Syntax: http://reference.wolfram.com/language/guide/Syntax.html Refer to the documentation frequently until you learn the language syntax.$Version "10.0 for Mac OS X x86 (64-bit) (September 10, 2014)" a = -0.06; b = 0.04; c = 0.1; d = ...

6

I do not believe that belisarius's answer, as written, is correct, at least in Mathematica 10.0.1 under Windows. In a simplified example we can see that in machine precision a three is still generated despite subtracting $MachineEpsilon from 3 in the range. I narrow the range make this readily apparent: ϵ =$MachineEpsilon; SeedRandom[1] First /@ ...

5

You can use Fold instead: f[n_Integer] := Fold[#2/(1 + #) &, n, Reverse@Range[n - 1]] f[3] $\frac{1}{1+\frac{2}{1+3}}$ It not very useful analytically, but it allows you to invoke the CPU gods: f /@ Range[50] // ListLinePlot[#, PlotRange -> All] &

5

No, it is not doing a Gram-Schmidt procedure. One way to note that this is distinct from Gram-Schmidt is that Gram-Schmidt produces an orthonormal basis, whereas the example outputs in the Documentation Center page for LatticeReduce are neither normalized nor orthogonal. Instead, LatticeReduce returns a basis $B$ comprised of linear combinations of integer ...

4

Yes, you can use Round. The second argument of Round is the quantization step. Examples: Plot[ Round[Sin[x], 0.2], {x, 0, 2 Pi} ] Plot[ Round[Sin[x], 0.2], {x, 0, 2 Pi}, ExclusionsStyle -> Automatic ]

4

Edit: I accidentally used Identity when I meant Sequence, but on reflection I believe Join @@ is better. My two standard methods are Apply: (reference Formatting text through pattern matching and Quick multiple selections from a list) Join @@ Reap[Sow[1]][[2]] Join @@ Reap[Null][[2]] Join @@ Reap[Sow /@ {1, 2, {}}][[2]] {1} {} {1, 2, {}} And ...

4

bug fixed in 10.0.2. WIndows 7, 64 bit Commonest[{1, 2, 3, 1, 2, 3}, 1] (*should return {1}*)

3

Theoretically, for any continuous distribution ... which includes your Uniform distribution ... $P(X=3) = 0$. So, theoretically, your question leaves you with nothing to worry about. Practically, for RandomReal to hit a perfect 3 ... should be equally impossible. Perhaps, as a matter of machine-precision, you are worried about whether mma might ...

3

Use the n!! function: Table[Factorial2[2 n - 1], {n, 1, 3}] {1, 3, 15}

3

LyapunovSolve and DiscreteLyapunovSolve solve several equations Lyapunov, Sylvester, Stein, generalized versions, etc., and as such there is no one standard form. Since they are linear solvers their design was based on the precedent set by LinearSolve. For $\dot{x}=A.x$ to be stable, $P=\text{LyapunovSolve}\left[A^{\mathsf{T}},-Q\right]$ has to be positive ...

3

I came up with a little algorithm that produces minimal lists of paths. I might be overlooking something, so please let me know if you find any mistakes. I shall focus on the case where the input list has 3 sublists, which I shall call layers henceforth. Cases with more than three layers can be computed recursively. The algorithm is based on three ...

3

The difference is the following: When you call Quit[] as input in a notebook, then the front end sends this command over the main MathLink connection to the Kernel like any other input. If you are already evaluating a long-running (or hanging) command, the Kernel won't quit because (as Alexey already pointed out) the quit command is queued and waits until ...

2

Interpolation in given range: x = Range[62, 70]; y = Range[10, 90, 10]; f = Interpolation@Thread@{x, y}; f'[x0] /. x0 -> 65 10 dom = First@f["Domain"]; Show[Plot[f[x], {x, First@dom, Last@dom}], ListPlot[Thread@{x, y}, PlotStyle -> Red]] Interpolation to produce a usual polynomial: g[xx_] = InterpolatingPolynomial[Thread@{x, y}, xx]; ...

2

This feels quite a bit like an odd mix of systems of distinct representatives and block designs, although this exact problem isn't coming to mind as a particular construction in any of these combinatorial contexts. It would probably help to pull out a book about matroids too -- that's not my forte either. It's important to note that all of your sets will be ...

2

data = DeleteCases[Range[-3, 6], 3]; l = RandomChoice[data, {1000}]

2

Update I've suceeded to find some solutions to particular n-lists (n>3) cases and also I have found a ridiculous short algorithm (2 lines of code) which seems to give the optimal n-tuples lists (==> all the possible pairs are present only once) for a large class of configurations where the input n-lists have all the same number of elements.(And I think ...

2

The problem you face here is that Function does not evaluate your system variable. It takes it as it is without making the transformation of system -> x+y+z. You can see this in the output directly: Function[{x, y, z}, system] (* Function[{x, y, z}, system] *) This comes from how Function treats its arguments. You can prevent this by temporary using ...

2

Another option is to use = instead of := tt = x + y f[x_, y_] = 2*tt f[1, 1] f[x, 4] f[x, y]

2

Try this: A = (Cos[Pi/18 + 2 x] + Cos[Pi/18 - 2 x] /. Pi -> pi // Simplify) /. pi -> \[Pi] (* 2 Cos[\[Pi]/18] Cos[2 x] *) Have fun!

1

That's because you set Psi to accept only real x. Meanwhile symbol x is not generally considered to be real by Mathematica, so just delete _Reals or use it with assumptions: Assuming[x \[Element] Reals , \[Psi][x, 1]]

1

You can use systemFunction[x_, y_, z_] = system Note the use of = instead of := and see What is the difference between Set and SetDelayed?

1

Using memoization f[n_Integer] := f[n] = (2 n - 1) f[n - 1] f[1] = 1; f /@ Range[3] {1, 3, 15}

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