34,162 reputation
547141
bio website
location
age
visits member for 2 years
seen 9 mins ago

Feb
25
comment Mathematica averaging a big list of large images
Why 0 set[[1]] and not just 0 ?
Feb
25
comment Defining Piecewise Functions in Modules
In this example you could reduce the problem to something like myfunc[] := Module[{rhs, f}, rhs = 2 x; f[x_] := Evaluate[rhs]; f[5]] This is small enough that you could use Trace[myfunc[]] to see exactly what is happening.
Feb
25
comment Defining Piecewise Functions in Modules
It's a good idea to reduce your problem to a Minimal Working Example that people can copy and paste into Mathematica to work on. This has 3 benefits, firstly it makes it easier for people to help you, secondly it makes the question and answers more useful to future visitors who might have the same problem, and thirdly the process of stripping the code down to the core of the problem will often help you to solve it yourself.
Feb
24
comment PDF for Gamma Distribution not what I expect
You're using a shape/scale parametrization (and getting the correct result). Most likely R is using a shape/rate parametrization. Try alpha = 3, beta = 1/5 to get the PDF you are looking for.
Feb
22
comment Extract the left channel from an mp3 file
The supported formats for sound import are here
Feb
22
comment Extract coordinates from a polygon
It looks like your poly expression contains a list of length 2 at a higher level than the individual coordinate pairs that you are trying to reach with Cases. Try making the pattern inside Cases more specific, e.g. {_Real, _Real}
Feb
20
comment Behaviour of Simplify when used with ArcTan and ComplexExpand along with assumptions
The documentation states that "Assuming affects the default assumptions for all functions that have an Assumptions option." Since ComplexExpand does not have an Assumptions option, it does not use the assumptions you specified in Assuming
Feb
20
comment How to customize derivative behavior via upvalues?
@Tom, I had completely forgotten about NonConstants. That means you can use upvalues as you suggested. Update coming up.
Feb
19
comment Testing for arbitrary algebraic expression in given variable
If you restrict Cases to level {-1} then you don't need the AtomQ test. Also DeleteDuplicates followed by Sort is equivalent to Union.
Feb
19
comment Merge two Matrices without Duplicates
I think the left-over duplicates are deliberate. As I understand it the idea is to remove just the elements at the beginning of data2 which are at the end of data1, like stitching together multiple images to make a panorama.
Feb
19
comment Can this function be numerically integrated
Include values for the constants too.
Feb
18
comment Can Mathematica Operators be combined in a linear fashion for readability?
You should look at Through too, e.g. Through[(f + g + h)[x]] gives f[x] + g[x] + h[x].
Feb
18
comment Variable scoping in Module
Regarding the update: The difference is that with Rule the symbol a does not appear on the rhs, because the rhs is evaluated before Rule "sees it". So the rule is: {a_, b_} -> (3 -> b). Since the symbols a and b occur as pattern names in the lhs of this rule, they are indeed treated as local to the rule, but this localisation happens after the evaluation of the rhs. RuleDelayed has the HoldRest attribute, so the rhs doesn't get evaluated and the rule acts as you expect.
Feb
18
comment How to customize derivative behavior via upvalues?
You haven't defined any values for D[X[x] + Y[x], x] so Mathematica computes it as normal, giving X'[x] + Y'[x]. Note that the result is in terms of Derivative not D. I think you will be better off defining your custom derivatives as subvalues of Derivative, e.g. X'[_] := A; Y'[_] := B;
Feb
17
comment Default Chart Color Doesn't Match
@rm-rf, no I'm on version 9. Has this changed in v10 then?
Feb
14
comment Use Simplify option Trig->False when 3rd argument to Collect is Simplify
Either use SetOptions to change the default, or use Simplify[#, Trig -> False] & in the Collect
Feb
13
comment Highlight Pie in PieChart
@halmir, good idea to allow multiple highlighted sections, but I prefer Thread@{1, n, 2}
Feb
13
comment Default Chart Color Doesn't Match
@Mr.Wizard, rogerStyles appears (in v9) in the trace for multi-colour bar charts, e.g. Trace[BarChart[{{1,2,3}}], TraceInternal -> True] but not for single-colour charts (it looks like the light blue is hard coded)
Feb
12
comment Default Chart Color Doesn't Match
@bobthechemist, I found it a while ago, looking for the colours used by CommunityGraphPlot so that I could create a legend. I think I probably used Trace to track it down.
Feb
11
comment Get Coordinates 4 significant digits limitation
Strangely using CoordinatesToolOptions -> {"CopiedValueFunction" -> (# &)} gives 6 digits.