All Questions

Filter by
Sorted by
Tagged with
39
votes
4answers
3k views

Compiling more functions that don't call MainEvaluate

I would like to use Compile with functions defined outside Compile. For example if I have the two basic functions ...
31
votes
3answers
6k views

I'd like to display field lines for a point charge in 3 dimensions

I'd like to display field lines for a point charge in 3 dimensions. Not a force field (short arrows) but continuous field lines that start on the charge.
46
votes
4answers
26k views

How to remove redundant {} from a nested list of lists?

There are numerous examples here, whose end result is the removal of empty brackets {} and empty lists. I still can't find an example of simply removing redundant ...
34
votes
6answers
3k views

Partition a set into subsets of size $k$

Given a set $\{a_1,a_2,\dots,a_{lk}\}$ and a positive integer $l$, how can I find all the partitions which includes subsets of size $l$ in Mathematica? For instance, given ...
36
votes
3answers
2k 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?
40
votes
3answers
3k views

Antialiasing in 3D

Is it possible? Is it platform specific? Does it rely on the graphics hardware? Why does the antialiasing slider under Preferences > Appearance > Graphics do nothing? I remember seeing some post-...
39
votes
1answer
1k views

What can I use as the second argument to Return in my own functions?

Having found out about the second argument to Return I played a bit with it, and the following tests all resulted in ...
32
votes
1answer
1k views

Customizing syntax highlighting for private cell styles

Is there any way to set up a cell style with a particular syntax highlighting? For example, I'd like to have a CProgram cell to write in blue the C special words. I have done it by setting ...
30
votes
6answers
5k views

Finding all elements within a certain range in a sorted list

Suppose we have a sorted list of values. Let's use list = Sort@RandomReal[1, 1000000]; for this example. I need a fast function ...
26
votes
6answers
751 views

Constructing symbol definitions for With

I would like to be able to define two arrays, one containing symbol names and one containing the values of those symbols, for use in constructs such as With. For ...
25
votes
5answers
5k 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
28k views

How can I transpose x and y axis on a Plot?

This question has appeared in various forms online, but I have not yet seen a complete answer, so I am posting it here. More specifically, suppose I have a function ...
14
votes
2answers
844 views

How to interpret the FullForm of a SparseArray?

SparseArrays are atomic objects, but they do have a FullForm which reveals information about them. What is the meaning of the ...
40
votes
5answers
1k views

How can the behavior of InterpolationOrder->0 be controlled?

In ListPlot and Interpolation, the option InterpolationOrder->0 uses two different ...
26
votes
4answers
5k views

Plotting piecewise function with distinct colors in each section

I have a piecewise function that I would like to plot but I was wondering if it is possible that each part of the function that is plotted when its corresponding condition is true be plotted with a ...
25
votes
2answers
3k views

Export Plot3D in Mathematica 10.1 is Rasterized by default

When I use Export to export Plot3D to PDF format, I get different behaviour in Mathematica 10.1 compared to 10.0. In particular, ...
22
votes
3answers
902 views

Button action monitored with progress bar

Let's say you have a palette with a button that has to do some time-consuming task when clicked: ...
17
votes
3answers
1k views

Problem with ParametricPlot

I'm plotting gear curves, and I observe that for some parameter values ParametricPlot[] does not plot all the teeth: ...
22
votes
5answers
2k views

How to catch complete error message information, including the message text as it would be printed?

If I evaluate this expression: Module[{}, 1/0;0^0]; msg = $MessageList I get: ...
11
votes
2answers
10k views

Plot 4D data with color as 4th dimension

I have a list of 4D data (x position, y position, amplitude, wavelength). I want to plot x, y, and amplitude on a 3D plot and have the color of the points correspond to the wavelength. I have seen ...
61
votes
3answers
2k views

How to distribute Mathematica packages as paclets?

Mathematica does have a nice package manager. Packages are called paclets, and they can be managed using the functions from the PacletManager` context. How can I ...
50
votes
5answers
9k views

How can I extract data points from a black and white image?

Consider the following graph (source): Is there any way to extract the data points from this image in a semi-automatic way? I have seen, and tried the methods suggested in this question, but they did ...
46
votes
2answers
7k views

How to access new colour schemes in version 10?

Many colour schemes and colour functions can be accessed using ColorData. Version 10 introduced new default colour schemes, and a new customization option using <...
60
votes
7answers
15k views

Saving data inside a notebook so that I don't have to run it again?

Piggybacking on this, I am somehow not fully convinced that I can't save data generated by a calculation in a mathematica file so that when I re-launch said file, I wouldn't have to run my ...
64
votes
6answers
5k views

How to avoid collision between optional arguments and options

Is it possible to create a function with optional arguments that also takes options? Here is a simple example. I have a function f with option "g". It also has ...
32
votes
6answers
24k 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. Sometimes,...
65
votes
6answers
3k views

V10's Operator Forms - what are they good for?

V10 introduces an operator form for several functions perhaps primarily due to their role in queries as part of introducing data science functionality. At first pass it seems a lot of effort to add ...
56
votes
3answers
6k views

How to find out which method Mathematica selected?

There are commands like NonlinearModelFit[] or NDSolve[] that have the option Method it ...
43
votes
4answers
6k views

How can I make an X-Y scatter plot with histograms next to the X-Y axes?

I just saw a nice plot there: How could I implement that in Mathematica — by which I mean the plot structure, not so much the styling.
49
votes
4answers
1k views

How to create expanding summary boxes like the ones displayed for InterpolatingFunction, NearestFunction, etc.?

The display forms for objects like ClassifierFunction are nice clickable summary boxes I like this, and now I'm trying to create my a custom version of this for my ...
48
votes
7answers
8k views

Intersecting graphics

Does the Mathematica graphics system have any concept of intersecting graphics? I've not found much in the documents so far. For example, if I want to show the intersection of two shapes: ...
28
votes
4answers
1k 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 ...
42
votes
7answers
6k views

Efficient way to generate random points with a predefined lower bound on their pairwise Euclidean distance

Using Mathematica what is an efficient way to generate a list of $n$ random two dimensional points $\{x_i,y_i\}$ where $i=1,...,n$ so that no two points $p_1$ and $p_2$ in the list has an Euclidean ...
29
votes
3answers
1k 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 ...
28
votes
2answers
2k views

How can I conveniently call igraph from Mathematica?

Mathematica has lots of functions for working with graphs and networks, but there are still some functionality holes that are provided by other packages. Also, due to the nature of graph theory, ...
28
votes
6answers
2k views

Map-Thread-Through-Apply a list of functions onto a list of (lists of) values

I have a list of functions: fns = {f, g, h} and a list of triples: ...
27
votes
3answers
3k 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: ...
31
votes
2answers
828 views

Copying one symbol into another

I would like to know how can I completely copy one Symbol to another. When I say copy, a refer to UpValues, DownValues, ...
31
votes
2answers
2k views

How does Plot work?

I considered the following function: sin[x_] := Module[{}, Print["x=", x]; Sin[x] ] in Mathematica. Next, I tried to plot it using: ...
37
votes
4answers
939 views

What is the difference between Dynamic[x] and Dynamic[ h[x] ] for DynamicModule variables?

Bug introduced in 9.0 or earlier and persisting through 12.0 In 11.3 it is even worse. An example from the accepted answer with a Slider is now broken too: ...
22
votes
5answers
928 views

Reassign values to symbols

I've got a situation where I have, say 4 symbols, a, b, c and ...
16
votes
5answers
11k views

Matrix Multiplication in context of row and column vectors

I've been looking at some matrices in Mathematica and I've noticed something very weird: they're extremely temperamental when it comes to dot products! For example, if I have the following, ...
10
votes
3answers
4k views

Using D to find a symbolic derivative

I need to do the following: Define a function Take the derivative of this function and have a look at the symoblic representation Substitute in some values With the bonus that I want to use the ...
7
votes
5answers
3k views

sliding a tangent line along a curve

I am confused by Dynamic. I am trying to slide a tangent line along a curve, without using DynamicModule, so that I can include ...
23
votes
2answers
1k views

Ordering problem

Let's look at the following example. Ordering[{0, 20 Sqrt[5], 40 Sqrt[5], 20 Sqrt[5], 20 Sqrt[10]} // N] gives the right answer ...
14
votes
1answer
446 views

Workarounds for a possible bug in the linearity of FourierTransform

This is somewhat similar to this question, except the problem I am encountering is to do with Fourier transforms of scalar multiples of functions and their derivatives. I wish to input ...
14
votes
10answers
5k views

Fibonacci Sequence Generator

I'm trying to write a function in Workbench which will generate a Fibonacci sequence starting with F0 = 0 and F1 = 1. So far I ...
11
votes
2answers
2k 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: ...
130
votes
9answers
11k views

General strategies to write big code in Mathematica?

I think after six months of exposure to Mathematica and the Wolfram Language I am fairly OK with writing short codes and snippets. However, what are some general strategies to use in order to write ...
73
votes
3answers
8k views

Metaprogramming in Mathematica

Being functional, and having no "quotation", i.e. essentially treating data and programs semantically same, Mathematica seems naturally capable of doing metaprogramming. But could anyone construct a ...

15 30 50 per page