Questions tagged [functions]

Questions about the use of built-in Mathematica functions, including pure functions.

328 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
37
votes
0answers
939 views

Performance problems in new Sequence functions

The new-in-10.1 Sequence* family of functions should provide newly optimized methods for handling sequence problems. Happily in some cases they do! For example ...
10
votes
0answers
902 views

Difference between UnitStep and HeavisideTheta?

In Mathematica, UnitStep[0] == 1 and HeavisideTheta[0] remains unevaluated. In addition, ...
10
votes
0answers
133 views

URL functions overload

All these functions seem capable of doing the same things: Import, URLFetch, URLSave, ...
10
votes
0answers
176 views

Is there a documentation generator for Mathematica?

I'm looking for a way to document the functions of my packages inline, preferably inside comments. There should be a Doxygen type tool for this that takes comments and that generates html from markup ...
8
votes
0answers
159 views

Performance of pure function - Best way to define a function?

In general, to define a function, we often use f[x_]. Another way is to use pure function (full form and shorthand). I want to test the performance of these ...
7
votes
1answer
143 views

TimeSeriesShift seems broken — is there a stable workaround?

Issue 1: Certain dates shift into the same date, leading to duplicated keys, rendering the time series unusable: ...
7
votes
0answers
91 views

Plot[Im[f[x]],…] incorrectly gives graph of identical zero function

Consider Plot[Im[(1 + (-1)^(2/3)*x)/((-1)^(2/3) + x)], {x, 0, 1}] At least in Mma 11 it gives the following picture: Meanwhile, ...
7
votes
0answers
230 views

What is the difference between GenerateDocument and TemplateApply[NotebookTemplate[

Bug introduced in V10.0 and persisting through V10.4 Since V10.3 the bug still remains but additionally the Genarate and ...
6
votes
0answers
517 views

Totally Antisymmetric Function

My current implementation for a totally antisymmetric function is like this: ...
6
votes
0answers
94 views

When does Root have a third argument

In Mathematica "11.0.1 for Microsoft Windows (64-bit) (September 20, 2016)", Root[#^4 + 1 &, 2]; actually has three arguments, as can be seen from ...
6
votes
0answers
121 views

Different behavior of Power between versions 9 and 10

Rather by accident I've noticed that the following trivial code produces different output in Mathematica 9 and 10: -((-1)^n) Mathematica 9: $-(-1)^n$ ...
6
votes
0answers
246 views

Strange Integrate behavior (a bug!)

The following two calculations should give the same result. After all, integration is a linear operation. I have pasted the code below in case you want to play with it. ...
5
votes
0answers
85 views

Exceeding recursion limit with no obvious recursion: Optional pattern-matching causing nonlocal behavior

So, I've come across something strange, and wanted to get a deeper understanding of what was going on. Consider the following code: ...
5
votes
1answer
85 views

Behaviour of Coefficient[] for negative exponents in rational expressions

I've observed a puzzling behaviour of Coefficient[] for negative exponents and I'm wondering if I was always just relying on undefined behaviour or if there is a ...
5
votes
0answers
197 views

Finding periodic cycles of a function

Given a function f[{x,y}] it is rather simple to use, for example, NSolve to find periodic points of period $n$. We simply take ...
5
votes
0answers
120 views

A Curiosity: What is DispatchQ?

As shown below, my autofill in Mathematica showed an interesting function: DispatchQ. Yet, it does not appear in the Mathematica Documentation Center, a search for ...
5
votes
0answers
79 views

How to specify halting states when using function TuringMachine?

The function TuringMachine generates a list that represents the evolution of a Turing Machine given a rule that specifies its behaviour (i.e. set of instructions). For example, the following rule ...
5
votes
0answers
78 views

How to know the string data/settings, of some options/functions

It is known that several functions and options take some sort of input in this form: option->"something" function["something"] The simple example for this is ...
5
votes
0answers
93 views

Is there something like MaxProcessorUsed?

For standard procedures it is easy to test if the implementation is better or worse than other by using Timing etc. It does not help us with creating ...
4
votes
0answers
56 views

Cannot access ColorFunction in ListVectorDensityPlot

Working on a vector field, I'd like to use a ColorFunction dependent on both the vector direction and its norm. According to the documentation of ...
4
votes
0answers
91 views

Are functions labelled “experimental” to be avoided while writing code?

A number of functions are currently labelled "experimental" on the official Wolfram Language Documentation Centre. (An example is AskFunction, which appears to be especially suited to my specific ...
4
votes
0answers
108 views

Order of evaluation of FunctionDomain, Reduce, Solve, etc

For the input (mine is much more complicated, this is a toy example): x/x /. x -> 0 the output of 1 (as opposed to ...
4
votes
0answers
140 views

RealDigits and functional style

So while thinking about Replacing numbers of which you only know certain digits I have faced, again, a problem that I find hard to extract from RealDigits' output ...
4
votes
0answers
107 views

Why does FromDigits transpose its argument (sometimes)?

a = {{1, 2}, {3, 4}, {5, 6}} ; FromDigits /@ Transpose@ a == FromDigits @ a (* True *) The only "strange" syntax I've found in the docs is But it doesn't ...
4
votes
0answers
256 views

Input List of Images into a cloud deployed API function

I'm new to APIFunction and CloudDeploy, but essentially, here's my situation: I have a function (let's call it ...
4
votes
0answers
104 views

Using an external Pattern breaks Format

I noted while writing this answer that using an external Pattern on Format doesn't work: ...
4
votes
0answers
420 views

Extracting an equation from an interpolated function

Im trying to use LibraryLink to do some calculations in C but part of the expression i want to calculate is an Interpolating Function. C cant use that obviously so I'm trying to shift it to a data ...
4
votes
0answers
320 views

Strange behaviour of MMA in derivatives of some standard functions

There are some peculiar things to be discovered in derivatives of some standard functions in MMA: Strange behaviour Example 1: Abs We have ...
4
votes
0answers
152 views

Make Mathematica show function template's arguments in different lines (i.e. in column) by default?

I feel a bit uncomfortable with Mathematica 10's layout. I mean, I'm impressed how powerful functional programming can be and so on, but it's me or those programs are often just a bunch of nested ...
4
votes
0answers
100 views

Can BreadthFirstScan be modified?

I would like to obtain a "slick" implementation of A*-search algorithm on Graph objects, using the built-in BreadthFirstScan (if that is possible at all). I noticed that BreadthFirstScan is static in ...
4
votes
0answers
177 views

Gather dependency on list order?

I get intrigued about Gather behavior on this post. I thought that Gather was invariant under list order? Here is the result I ...
4
votes
0answers
398 views

Mathlink and multithreading

In order to make my computations faster I have developed a C/C++ application calling Mathematica kernel and performing many operations using Mathematica functions for equation solving. Now I want to ...
3
votes
0answers
30 views

Unexpected behaviour with Coefficient

If I run expr = (CF G[0, zb])/(1 - zb) + (CF zb^2 G[0, zb])/(1 - zb) + (2 CF G[1, zb])/(1 - zb) + (2 CF zb^2 G[1, zb])/(1 - zb); Coefficient[expr, zb, -1] in ...
3
votes
0answers
122 views

FindGeometricTransform not working properly for a simple problem

I am surprised why FindGeometricTransform is failing to automatically register or align two sets of points that are drawn from a ...
3
votes
0answers
48 views

Differences between u[x,y,t] vs. u[x,y][t] vs. u[x][y][t]

Is there any difference between defining a variable by u[x,y,t] or u[x,y][t] or u[x][y][t] ? ...
3
votes
0answers
79 views

InverseFunction doesn't work well with ConditionalExpression

I have a polynomial constructed with InterpolatingPolynomial. It is not a one-to-one function but I want to have its inverse on some range where it is monotonously ...
3
votes
0answers
141 views

How to call an old build-in function in a new version of Mathematica?

In order to use the UnitStep of Mathematica 5.2, I have to install two different versions 5.2 and 11.3 at the same time because ...
3
votes
0answers
52 views

Conditional application of a function (looking for a built-in solution)

Is there a built-in function which will apply a function f to x when test yields true? A ...
3
votes
0answers
56 views

Applying a function along the desired dimensions of a n-dimensional array

I am trying to apply an arbitrary function f that takes several inputs and returns a scalar along some specific dimensions of an n-dimensionnal array. Here is an ...
3
votes
0answers
115 views

Monitor CUDA function

Is there a way to monitor CUDA function without bringing much performance reduction. For example, Map can be monitored by ...
3
votes
0answers
210 views

Generating function for Newton series?

The function GeneratingFunction gives generating function for Taylor series. Is there a similar function for Newton's series? $$f(x) = \sum_{k=0}^\infty \binom{x}k \Delta^k [f]\left (0\right)$$
3
votes
0answers
523 views

Speeding Up Image Processing Functions

I am working with stacks of 1024x1024 timelapse microscopy images that I am performing a series of image processing functions on to help segment each image. These functions include ...
3
votes
0answers
1k views

Slow mixture fitting when having ill-conditioned covariance matrices. How to make it faster?

I'm using Mathematica 9.0 to fit multidimensional observations with a gaussian mixture. To do so I first adapted these steps to ensure that the mixture parameters are well defined (see https://...
3
votes
0answers
319 views

Do a gauge transformation for a Chern-Simons theory?

Suppose we have the following Lagrangian density: $$ L=\epsilon^{\mu\nu\rho}\big(\sum_a A^a_{\mu}(x) \partial_\nu A^a_{\rho}(x)-\sum_{a,b,c}\frac{1}{3} f^{bca} A^a_{\mu}(x) A^b_{\nu}(x) A^c_{\rho}(x)...
3
votes
0answers
108 views

Finding the argument set for internal functions in Mathematica v9.0

I've recently run into a problem with importing TIF stacks in Mathematica: Slow import of multigigabyte TIF image stacks On the advice of Simon Woods and others, I've been looking into the behavior ...
3
votes
0answers
137 views

ProbabilityDistribution PDF on boundary points

I would like to evaluate the PDF of a custom ProbabilityDistribution at the min and max values. However, PDF[...] returns 0 at ...
2
votes
0answers
54 views

Syntax highlighting for own functions only for certain symbols

For simplicity, let's say I have defined my own function f that takes in exactly one input argument which is of the Symbol type ...
2
votes
2answers
105 views

Restrict kinds of heads when dealing with level concept

In[1] Map[(# + 7) &, {a, 3 b, {c, d}, e}, {2}] Out[1] {a, 10 (7 + b), {7 + c, 7 + d}, e} But I want feature like ListMap : ...
2
votes
0answers
42 views

ParallelTry Hangs on previously working code

When I run the below ParallelTry command, it just sits on it and says its being evaluated, but I cant abort it, it doesn't return what I am expecting, and I have to ...
2
votes
0answers
35 views

Why is RotationTransform 100x slower than manually specifying the transformation?

I'm plotting an implicit surface using RegionPlot3D. I have two descriptions of the surface which I believe are (or should be) conceptually and functionally ...

1
2 3 4 5
7