Tag Info

Hot answers tagged

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 ...


9

The output looks fine to me. It is, however, relatively complicated. Consider the following simpler example Minimize[x (x - c), x] (* Out: {-c^2/4, {x -> c/2}} *) Thus, there is a minimum value of $y=-c^2/4$ at $x=c/2$, as expected. Now, let's complicate things slightly. Minimize[c x (x - c), x] This is a piecewise expression, which is ...


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

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


7

Manipulate[ p = {x, s@x} /. Last@Minimize[{s@x, l > x > 0}, {x}]; Plot[s@x, {x, 0, l}, Epilog -> {PointSize[Large], Point@p}, PlotLabel -> p], {l, 1, 10}, Initialization :> {s@x_ := 1/2 Sqrt[(l^4 + x^4)^2/(l^4 x^2)]}]


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 /@ ...


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

It takes less work to use the definition of a generating function directly than by typing FindGeneratingFunction: In[1]:= Sum[Mod[n, 2] x^n, {n, 0, Infinity}] Out[1]= -(x/((-1 + x)*(1 + x)))


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

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

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


4

p[z] = GeneratingFunction[Mod[n, 2], n, z] CoefficientList[Normal@Series[p[z], {z, 0, 10}], z] (* -(z/(-1 + z^2)) *) (* {0, 1, 0, 1, 0, 1, 0, 1, 0, 1} *)


4

It is possible to find generating functions using FindGeneratingFunction, but the finite list you provide to it has to be long enough: seq = ConstantArray[{0, 1}, 5] // Flatten Table[FindGeneratingFunction[seq[[;; n]], x], {n, 10}]


4

Since you give the constraint l > x > 0, you should make use of that constraint f[x_] = 1/2 Sqrt[(l^4 + x^4)^2/(l^4 x^2)]; min = FullSimplify[ Minimize[{f[x], l > x > 0}, x], l > x > 0] min[[1]] == Simplify[f[x /. min[[2]]], l > 0] True f'[x] /. min[[2]] 0 Simplify[(f''[x] /. min[[2]]) > 0, l > 0] True


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

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

You can use N f[x_] = 10000 x^5 + 1278 x^4 + 113 x^3 + 89 x^2 + x + 12; ScientificForm[N[f[x]]] equ = N[10000 x^5 + 1278 x^4 + 113 x^3 + 89 x^2 + x + 12] ScientificForm[%, 3] How to | Change the Format of Numbers, is for more reading.


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

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

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

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

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

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!



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