Questions tagged [functions]
Questions about the use of built-in Mathematica functions, including pure functions.
401
questions with no upvoted or accepted answers
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 ...
10
votes
0
answers
161
views
URL functions overload
All these functions seem capable of doing the same things: Import, URLFetch, URLSave, ...
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 ...
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 ...
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:
...
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 ...
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 ...
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 ...
6
votes
0
answers
637
views
Totally Antisymmetric Function
My current implementation for a totally antisymmetric function is like this:
...
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
...
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$
...
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.
...
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 ...
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 ...
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 ...
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 (...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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:
...
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 ...
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
...
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 ...
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 ...
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 ...
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 ...
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.
...
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 ...
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
...
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] ?
...
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 ...
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 ...
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 ...
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 ...
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 ...
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)$$
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 ...
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://...
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)...
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 ...
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 ...
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 &...
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. ...
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 <...
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],...}
...