As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [functions]

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

401 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
43 votes
0 answers
1k 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 ...
Mr.Wizard's user avatar
  • 267k
10 votes
0 answers
161 views

URL functions overload

All these functions seem capable of doing the same things: Import, URLFetch, URLSave, ...
M.R.'s user avatar
  • 30.9k
10 votes
0 answers
186 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 ...
M.R.'s user avatar
  • 30.9k
8 votes
0 answers
247 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 ...
Nam Nguyen's user avatar
  • 1,731
7 votes
0 answers
145 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: ...
thorimur's user avatar
  • 8,835
7 votes
0 answers
244 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 ...
Kuba's user avatar
  • 135k
6 votes
0 answers
255 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 ...
math's user avatar
  • 713
6 votes
0 answers
151 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 ...
Just Some Old Man's user avatar
6 votes
0 answers
637 views

Totally Antisymmetric Function

My current implementation for a totally antisymmetric function is like this: ...
Joe's user avatar
  • 1,278
6 votes
0 answers
98 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 ...
bbgodfrey's user avatar
  • 60k
6 votes
0 answers
122 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$ ...
vsht's user avatar
  • 3,427
6 votes
0 answers
263 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. ...
Hector's user avatar
  • 6,408
5 votes
0 answers
84 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 ...
Lili's user avatar
  • 51
5 votes
0 answers
83 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 ...
Basheer Algohi's user avatar
5 votes
0 answers
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 ...
Kuba's user avatar
  • 135k
4 votes
0 answers
35 views

Efficiently threading with a default value for missing parts / defining custom behavior for addition of expressions with a given head

In short, I would like to be able to "add" expressions with a particular head (call it h for our purposes) which will always appear with a sequence of (...
max's user avatar
  • 61
4 votes
0 answers
173 views

How to perform feature selection for machine learning applications?

Feature selection is fairly easy in e.g. Python's scikit-learn which sports a module and tutorials or MATLAB. Mathematica even touts that it uses feature selection ...
Sterling's user avatar
  • 523
4 votes
0 answers
67 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 ...
xiaohuamao's user avatar
  • 4,594
4 votes
0 answers
201 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 ...
Ali Hashmi's user avatar
  • 8,760
4 votes
0 answers
95 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 ...
Shredderroy's user avatar
  • 4,957
4 votes
0 answers
114 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 ...
Aharon Naiman's user avatar
4 votes
0 answers
174 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 ...
Kuba's user avatar
  • 135k
4 votes
0 answers
114 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 ...
Dr. belisarius's user avatar
4 votes
0 answers
272 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 ...
pMarkov's user avatar
  • 141
4 votes
0 answers
108 views

Using an external Pattern breaks Format

I noted while writing this answer that using an external Pattern on Format doesn't work: ...
Mr.Wizard's user avatar
  • 267k
4 votes
0 answers
484 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 ...
Nicholas Gaffney-Henderson's user avatar
4 votes
0 answers
339 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 ...
Dr. Wolfgang Hintze's user avatar
4 votes
0 answers
157 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 ...
JavierG's user avatar
  • 541
4 votes
0 answers
103 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 ...
Iconoclast's user avatar
4 votes
0 answers
189 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 ...
Murta's user avatar
  • 25.9k
4 votes
0 answers
431 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 ...
Andry's user avatar
  • 421
3 votes
0 answers
52 views

How can one automatically arrange the connections of a circuit with as few crossings as possible, given a set of edges?

Here are two functions to create symbols of dc voltage source and a resistor. ...
hana's user avatar
  • 2,832
3 votes
0 answers
190 views

Using new FoxH function to solve a trinomial equation. Possible issue?

There is a possible issue on solving the following trinomial equation $$x^\alpha+x=y$$ for real $x,y,\alpha$. From Belkic [1], it is known that for $\alpha>1$ a solution is found using the ...
Jorge Zuniga's user avatar
3 votes
0 answers
57 views

Definition of large expression - makes PC freezed

In[1] A=Range[10^4];?A Out[1] (* definition of A*) It works for 10^4. But if I increase the number to 10^6 ...
imida k's user avatar
  • 3,859
3 votes
0 answers
60 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] ? ...
Nitra's user avatar
  • 157
3 votes
0 answers
103 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 ...
sckol's user avatar
  • 31
3 votes
0 answers
182 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 ...
likehust's user avatar
  • 663
3 votes
0 answers
54 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 ...
Theo Tiger's user avatar
  • 1,253
3 votes
0 answers
97 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 ...
Mary's user avatar
  • 31
3 votes
0 answers
121 views

Monitor CUDA function

Is there a way to monitor CUDA function without bringing much performance reduction. For example, Map can be monitored by ...
Louis Yu's user avatar
  • 817
3 votes
0 answers
223 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)$$
Anixx's user avatar
  • 3,441
3 votes
0 answers
535 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 ...
user13999's user avatar
  • 907
3 votes
0 answers
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://...
p-d's user avatar
  • 43
3 votes
0 answers
378 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)...
wonderich's user avatar
  • 843
3 votes
0 answers
109 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 ...
Sparse Pine's user avatar
  • 1,123
3 votes
0 answers
144 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 ...
tba's user avatar
  • 555
2 votes
0 answers
47 views

Mathematica Implementations of Post Quantum Cryptography Algorithms?

Mathematica supports several cryptographic commands like Encrypt, Decrypt and others. This includes support for asymmetric signature ciphers like RSA and Elliptic curves and symmetric ciphers like &...
Moo's user avatar
  • 2,702
2 votes
0 answers
53 views

Is it safe to alias a ResourceFunction with a symbol of the same name?

The following will show how easy I alias Ding which is my very first ResourceFunction and it works very well. ...
Jules Manson's user avatar
  • 2,347
2 votes
0 answers
91 views

sometimes Select / sometimes Position is faster

As you see, For list L, L1(Select method) is slower than L2(Position method). But for list <...
imida k's user avatar
  • 3,859
2 votes
0 answers
42 views

Delete list item if message is thrown

I have a nested list with each element containing FindRoot like this: {FindRoot[a,b], FindRoot[c,d], FindRoot[e,f],...} ...
user2286339's user avatar

1
2 3 4 5
9