17,940 reputation
12160
bio website
location
age
visits member for 2 years, 3 months
seen 2 hours ago

Apr
19
comment How to switch elements i,j in a list?
If you do not want to type the reverse list, you can try m = {1, 4, 3, 2, 5}; idx = {1, 2, 4}; m[[idx]] = m[[Reverse[idx]]]; I also do not know why you need to save the actual data in the position affected. You have the index of the positions switched there. So you can always obtain the data that was switched anytime. Save memory ! Just do oldData = m[[Reverse[idx]]] to read the old data
Apr
18
reviewed Approve suggested edit on Few quick Mathematica questions about Dictionary
Apr
18
revised Removing a ProgessIndicator when no longer needed
typo
Apr
14
revised Integrating a half-normal pdf
add note
Apr
14
answered Integrating a half-normal pdf
Apr
14
revised Testing the Erdos square free conjecture
added 106 characters in body
Apr
14
answered Testing the Erdos square free conjecture
Apr
14
comment Mathematica Implementation of Householder’s Method
For the Sum::write: Tag Set in k=j+1 is error, simply change k= to k,. Now Alist is generated. I do not know if it is correct or not.
Apr
14
comment Mathematica Implementation of Householder’s Method
I see now. The Householder matrix is one step used in the Householder method. The code you linked to only generates the Householder matrix, it does not implement the full transformation. Here is a Mathematica implementaion I found: mathfaculty.fullerton.edu/mathews/n2003/HouseholderMod.html
Apr
14
comment Mathematica Implementation of Householder’s Method
@Amzoti I have not looked at the paper result. I verified it using Maple. Same matrix resulted from same input. Will try to look at the paper. May be the paper is using different definition or has a bug :)
Apr
14
answered Mathematica Implementation of Householder’s Method
Apr
14
comment Mathematica Implementation of Householder’s Method
Sorry, but this is bad code :) zeroVector = {}; For[i = 1, i <= n, zeroVector = Append[zeroVector, {0}]; i++]; can be replaced by one Table[] command. I see you copied it from the paper/article. But papers are full of bad code as well. Looks like written by an ex-Fortran programmer.
Apr
13
comment Getting messages Rest::norest and Divide::indet from ContourPlot3D
I Just added == 0 and no such error now. ContourPlot3D[Cos[2*Pi*z] + Cos[2*Pi*y] + Cos[2*Pi*x] == 0, {x, 0, 1}, {y, 0, 1}, {z, 0, 1}] gives !Mathematica graphics
Apr
13
comment Trouble combining planet orbits and positions in Graphics3D and Show
I keep getting $Aborted when running the code. V 9.01 on windows 7.!Mathematica graphics restarted kernel few times. did not make difference. May be it is internet issue reading the data from WRI server
Apr
13
comment Evaluating an expression assuming a value for a variable only in the local context
compare x = 5; With[{q = x}, q = 1; q] with x = 5; Block[{q = x}, q = 1; q] in the first case, M gives error Set::setraw: Cannot assign to raw object 5. >> but not in the second case. This is because with With now q is constant 1, and can't be assigned to.
Apr
13
comment Evaluating an expression assuming a value for a variable only in the local context
This has summary: stackoverflow.com/questions/6661393/… For me, I also think of With as making all the variables being withed as constants during the evaluation of the code inside With. So less chance of an error if you do not need to modify the withed variable, such as q in this case. Mathematica in this case, changes q to x in all the expressions inside With right away, then evaluates the expression. You can't do q=1 for example in this case, inside With later on, since q now is constant.
Apr
13
comment Evaluating an expression assuming a value for a variable only in the local context
With[{q = x}, NIntegrate[x^2*q, {x, 0, 100}] ] works also
Apr
13
comment Replace every Minus to Plus in Expression
Do you really mean every minus? So given this input expr = a - b + Sqrt[-x]; which can be complex depending on x, you want the output to become real (depending on x)? as in expr = a + b + Sqrt[x];
Apr
13
comment Sum does not converge, but I think it should
You can also see this more clearly like this Sum[Boole[Not[IntegerQ[x]]], {x, 1, k}] which gives k. So let k to any value, say Infinity, and you see the problem. It is all due to evaluation of !IntegerQ[x] before the sum even starts. Since you are summing to Infinity, I am not sure how else M will handle this, as the function needs to be analytical for M to figure the sum.
Apr
13
comment Sum does not converge, but I think it should
What seems to happen is that !IntegerQ[x] gets evaluated right away to True, this is before the sum takes hold. Hence the result becomes Boole[True] which is 1 and the whole sum becomes just Sum[1, {x, 1, Infinity}] which diverges. You can see this more clearly like this: !Mathematica graphics need to find a way to tell M to delay this evaluation.