14
votes
4answers
4k views

How to calculate scalar curvature Ricci tensor and Christoffel symbols in Mathematica?

I am seeking a convenient and effective way to calculate such geometric quantities. I've used packages like TensoriaCalc, but they don't work at all time. ...
37
votes
2answers
942 views

Head and everything except Head?

I have been working on picking expressions apart using Head and Part and encountered a little mystery. Consider the canonical ...
19
votes
5answers
1k views

How to pass a symbol name to a function with any of the Hold attributes?

Given a function with the attribute HoldFirst, HoldAll or similar, and a variable, list, how ...
14
votes
3answers
1k views

Way to improve “show me this decimal number to M places, don't use scientific notation”?

The best way I can come up with to say "show me this fraction as a decimal number to M places, don't use scientific notation" is: ...
11
votes
4answers
1k views

How to modify function argument?

Usually in programming languages, function arguments are normal local variables, which can be modified. Is this not true in Mathematica? ...
12
votes
1answer
466 views

Funny behaviour when plotting a polynomial of high degree and large coefficients

I am trying to plot a polynomial of degree 29 on the domain [0,1], with fairly large coefficients: ...
11
votes
3answers
329 views

Why do buttons with ChoiceDialog freeze the front end?

Pressing the button below will freeze my front end. An unpainted white dialog box comes up, then it completely freezes, and I need to forcibly kill the front end. CPU usage stays at zero during ...
14
votes
6answers
921 views

Annoying display truncation of numerical results

I have a lot of data to inspect. An example of a number in my program is 123.189094 This gets displayed as 123.189 ...
51
votes
5answers
3k views

Minimal effort method for integrating C++ functions into Mathematica

As of Mathematica 8, what is the minimal effort way to integrate an existing C++ function into Mathematica? I think we have these: MathLink (it was quite long ago I used it last time) communication ...
48
votes
3answers
4k views

Recovering data points from an image

Unfortunately, some data can only be obtained in picture form (Japanese publications anyone?). Since this cannot be worked with, it has to be converted to a dataset that can; I was wondering whether ...
32
votes
3answers
2k views

Calling MATLAB from Mathematica

How can I call MATLAB functions directly from Mathematica and transfer data/variables between the two systems?
23
votes
3answers
2k views

How to find circular objects in an image?

How could I use morphological processing to find circular objects in an image? More specifically, I need to detect road signs. I need to get the "80 speed limit" sign from this image:
28
votes
2answers
3k views

Plotting implicitly-defined space curves

It is known that space curves can either be defined parametrically, $$\begin{align*}x&=f(t)\\y&=g(t)\\z&=h(t)\end{align*}$$ or as the intersection of two surfaces, ...
25
votes
4answers
520 views

How to make MapAt work with Span?

Span (;;) is very useful, but doesn't work with a lot of functions. Given the following input ...
25
votes
4answers
1k views

Aborting evaluation when the memory exceeds a certain limit

Sometimes when generating a lot of data the memory usage shoots beyond its physical realm and my laptop freezes. There is no way to stop Mathematica when this happens. Task manager (or its equivalent ...
21
votes
3answers
634 views

Prepend Information to Warning Messages

I have a function running within a Do loop that sometimes issues a warning. I'd like to prepend the warning with the loop ctr so that I can go back and debug that instance later. Basically, I would ...
14
votes
2answers
1k views

Open Excel file with Mathematica

I would like to open an Excel file and manipulate it as a COM object. While I'm able to open an instance of excel with ...
25
votes
4answers
3k views

Density plot on the surface of sphere

I would like to make density plots of a list of (size 2 or 3) spherical harmonics on the surface of a sphere. I'd like to plot it so that each element of that list is using a different color (red ...
15
votes
3answers
332 views

How can I get the unchanged Box form of an arbitrary expression?

One may observe that MakeBoxes does not give the actual Box form of various expressions: MakeBoxes[{1*^4, 000123, a*b c}] ...
19
votes
3answers
1k views

Reading periodic elements from a large file

I have a large binary data file (big endian) with 100+ million "rows" of 11 elements, combination of floats and integers. This is the format: ...
22
votes
2answers
2k views

Generating a broken or snipped axis in ListPlot

I have two data sets, data1 and data2. For example: ...
2
votes
4answers
2k views

Delete duplicate elements from a list

If a list contains duplicate elements, for example list = {a, 1, 5, 3, 5, x^2, x^2}, how can the duplicate elements be removed? The result would be ...
13
votes
5answers
684 views

How to perform a depth-first preorder traversal of an expression?

Due to confusion of terminology on my part I asked the wrong question before. Since it has already received other answers I shall not edit it, but instead ask the question I meant to in the first ...
8
votes
4answers
494 views

Problem with ContourPlot

I tried these ...
10
votes
1answer
950 views

Combined numerical minimization and maximization

I want to numerically calculate the maximum of a function defined by the minimization of another function, like the following: ...
5
votes
1answer
245 views

Alternative to overloading Set

In the ideas shared in my answer to this post Struct equivalent in Mathematica? at the end I propose a solution that changes the way Set works in a particular case that can be expressed in plain words ...
7
votes
2answers
762 views

ParallelTable and Table do not give same result

I have a question regarding the use of Parallelize. In the help one can read that “Parallelize[Table[expr,iter, …]] (which is ...
6
votes
1answer
2k views

Fixed color scale in multiple density plots

I think there should be a simple solution for my current problem, but neither StackOverflow (or the help of Mathematica) or Google have it. I have to plot multiple density plots with a color ...
5
votes
2answers
425 views

Evaluating an If condition to yield True/False

I would like to decide whether an option passed to my custom function has the value Automatic or something else. This is my attempt: ...
2
votes
2answers
211 views

Question about MapThread and Dynamic

I don't understand the following: f[a_, b_] := a + b ls = {1, 2, 3}; MapThread[f, {ls, {10, 20, 30}}] This yields ( as expected ) {11,22,33} If I change ...
54
votes
5answers
7k views

$\LaTeX$ and Mathematica

I quite often would like to draw graphics in my $\LaTeX$ documents using Mathematica. I have encountered three problems. I would like to know if there are any workarounds to these problems I would ...
41
votes
1answer
1k views

Profiling from Mathematica

I've always wished I could do some profiling like you get in Wolfram Workbench, but directly from Mathematica, without using or having Workbench. If it is possible, how can I do it?
43
votes
4answers
4k views

How can I generate this “domain coloring” plot?

I found this plot on Wikipedia: Domain coloring of $\sin(z)$ over $(-\pi,\pi)$ on $x$ and $y$ axes. Brightness indicates absolute magnitude, saturation represents imaginary and real magnitude. ...
41
votes
4answers
4k views

How to make a 3D globe?

There are many ways to create a 3D Earth that is rotatable (see here, here, related here), but most of them have some drawbacks. These issues mainly stem from either ...
39
votes
1answer
1k views

How to generally match, unify and merge patterns?

This question was split from this one. While that question is now about how to match two particular patterns (mostly using Verbatim or ...
30
votes
1answer
986 views

How can all those tiny polygons generated by RegionPlot be joined into a single FilledCurve?

RegionPlot will usually generate a large number of tiny polygons for filling the region: ...
24
votes
2answers
730 views

Can a Trie be implemented efficiently?

What is the most space and time efficient way to implement a Trie in Mathematica? Will it be practically faster than what is natively available in appropriate cases?
32
votes
4answers
3k views

How to change the default ColorData used in Mathematica's Plot?

This question leads on from the recent question What are the standard colors for plots in Mathematica? There it was determined that the default color palette used by ...
24
votes
6answers
1k views

How to select minimal subsets?

I am a newbie, so please point me in the right direction if you feel this question has been answered somewhere else before. Here goes: Suppose I have a list like this: ...
26
votes
4answers
1k views

Generating evenly spaced points on a curve

In the KnotData package a simple command such as points = Table[KnotData[{3, 1}, "SpaceCurve"][t], {t, 0, 2 Pi, 0.1}]; will ...
26
votes
2answers
471 views

Are there guidelines for avoiding the unpacking of a packed array?

Packed arrays are very useful because they save memory and generally allow speedier and more efficient calculation times. If a list of data currently stored as a packed array is unpacked, it can slow ...
24
votes
3answers
661 views

How do I add new menuitems to menus?

What are some complete examples of what one would include in a FrontEnd init.m that would make use of FrontEnd`AddMenuCommands ...
19
votes
3answers
965 views

“Covering up” text in Graphics

Consider the following code: ...
18
votes
2answers
573 views

Resource management in Mathematica

I am using a library that has functions like createSomeObject[] and deleteSomeObject[obj]. It is an interface to a C language ...
23
votes
4answers
743 views

Can I simplify an expression into form which uses my own definitions?

This seems like a simple thing to do, but I couldn't find anything relevant from Mathematica documentation. So suppose I have an expression: a*b/(a + a*Cos[a/b]) ...
21
votes
1answer
329 views

What can be used as the second argument to Return on your own functions?

Having found out about the second argument to Return I played a bit with it, and the following tests all resulted in ...
21
votes
7answers
3k views

Sizing cells in a GraphicsGrid/GraphicsRow

I would like to add a colour bar to a plot. I tried to use GraphicsRow for this. In a GraphicsRow, each item is given the same ...
6
votes
3answers
1k views

Assigning values to a list of variable names

As part of a calculation I need to do something like this Evaluate[{aaa, bbb, ccc}[[ index]]] = {1, 2, 3, 4, 5} so if index is ...
18
votes
4answers
1k views

Can 2D and 3D plots be combined so that the 2D plot is the bottom surface of the 3D plot boundary?

I have a ListlinePlot function, that I would like to combine with both a Graphics3D plot and a ...
17
votes
7answers
480 views

How do I obtain an intersection of two or more list of lists conditioned on the first element of each sub-list?

Given two lists like list1 = {{1, 1}, {2, 4}, {3, 9}, {4, 16}}; list2 = {{2, 6}, {3, 9}, {4, 12}, {5, 15}}; I would like to produce an output like ...

15 30 50 per page