Questions tagged [functions]

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

227 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
32
votes
0answers
832 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
106 views

URL functions overload

All these functions seem capable of doing the same things: Import, URLFetch, URLSave, ...
9
votes
0answers
152 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 ...
7
votes
0answers
423 views

Difference between UnitStep and HeavisideTheta?

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

Totally Antisymmetric Function

My current implementation for a totally antisymmetric function is like this: ...
6
votes
0answers
88 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
119 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
205 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
240 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
75 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
92 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
86 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
106 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
66 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 ...
4
votes
0answers
122 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
106 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
246 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
100 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
348 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
308 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
147 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
91 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
163 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
352 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
50 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
50 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
108 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
263 views

How to Implement a “Function Object” suitable for NDSolve and Finite Element Method?

I have a bunch of methods that shoud return an expression that behave like a function, i.e. an expression that, when supplied with suitable arguments, evaluate to something. A simple ...
3
votes
0answers
193 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
494 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
863 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
284 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
104 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
136 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
70 views

How to prove subspaces of function spaces?

In teaching Linear Algebra, I would like to prove or disprove whether a nonempty subset of a vector space, is a subspace. For this, I would show that the subset is closed under both addition and ...
2
votes
0answers
75 views

Calling a notebook from a different notebook

Basically I have a notebook (let's call it nb1) that when evaluated yields one number when I specify some parameter $\alpha$ (in nb1). I want to call nb1 in a different notebook (nb2) using for ...
2
votes
0answers
62 views

How to store the values of a function in a file

As it is well known, it is possible to define a function that remembers its values once its evaluated, using the following code: f[x_]:=f[x]=rhs During the day ...
2
votes
0answers
114 views

Is $\mathrm{EllipticPi}(n,\varphi, m)$ periodic for $n>1?$

The Wolfram function site lists the quasi-periodicity relation for the incomplete elliptic integral EllipticPi restricted to $-1\le n\le 1$ although actually it seems to work for $n<-1$ and $n \sin^...
2
votes
0answers
52 views

How to get ImageTransformation to not compute the function at *every* pixel

I am using ImageTransformation with a slow function. Is there a way to get ImageTransformation to compute the function at only a ...
2
votes
0answers
23 views

`FunctionDomain` working with real part

Is there any reason why Mathematica evaluates the following FunctionDomain[Re[((I + 1) x)], x] (* False *) as False, where I'...
2
votes
0answers
65 views

Mapping of two functions by stretching and adding

Say you have two functions $f_1(x)$ and $f_2(x)$ that are the interpolation functions of two data sets $d_1$ and $d_2$, with $f_2(x)=Y(x)+f_1(X(x))$. Is it possible to find both functions $X(x)$ and $...
2
votes
0answers
115 views

Making code faster?

I am dealing with a very simple code, which turns to be slow when I try to plot the final Piecewise function. Is the code computing back again the integral iteratively rather than just substituting d=...
2
votes
0answers
60 views

Built-in functions for Homotopy group

Does Mathematica have built-in functions for Homotopy group, for example for computing $$\pi_n(S^m)=?$$ or more generally $n$-th homotopy group, $$\pi_n(X)=?$$ for some $X$. (I search, but I could ...
2
votes
0answers
140 views

Power Series Expansion of Infinite Product

I've defined a function which I call $F$ below, requiring an infinite product. Ultimately, the function $G$ I'm interested in is a finite sum of products and ratios of the infinite product function. ...
2
votes
0answers
148 views

Function output

I would like a function that computes Cartesian product of two sets z=(Tuples@{#1,#2}), and computes the number of elements in this set(list) ...
2
votes
0answers
53 views

Rescale large numerical factors in rational functions

Given a rational function $$ f(x_1,x_2) = \dfrac{r_1 x_1^2 + r_2 x_2}{r_3 x_1 + r_4 x_2}, $$ with $r_i$ arbitrary real or complex numbers, is there a built-in function to get Mathemtica to rewrite as $...
2
votes
0answers
114 views

Covariance matrix estimation when number of variables is larger than number of observations

It is well known that the sample covariance matrix estimator results in a singular matrix if the variables is larger than the number of observations. One solution is to apply shrinkage estimators. ...
2
votes
0answers
55 views

Computing an inexact derivative with some terms preserved in exact form

I am beginning to learn Mathematica and have the following question: How can I return a derivative with exact numbers instead of one involving numerical approximations? My original, single variable ...
2
votes
0answers
126 views

Marginal distribution with weight

Given a multi-variate distribution $P(\mathbf{x},\mathbf{y})$, I would like to obtain the marginal distribution $$P_m(\mathbf{x})=\sum\int_{\mathbf{y}}P(\mathbf{x},\mathbf{y})W(\mathbf{y})$$ In my ...
2
votes
0answers
134 views

Incorrect output from InverseFourierTransform

Bug introduced in 8.0.4 or earlier and fixed in 9.0.1 or earlier I am trying to compute the inverse Fourier transform of this expression ...