Skip to main content

Questions tagged [functions]

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

427 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
  • 272k
10 votes
0 answers
163 views

URL functions overload

All these functions seem capable of doing the same things: Import, URLFetch, URLSave, ...
M.R.'s user avatar
  • 31.5k
10 votes
0 answers
188 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
  • 31.5k
8 votes
0 answers
279 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,761
7 votes
0 answers
166 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
  • 9,020
7 votes
0 answers
248 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
  • 137k
6 votes
0 answers
215 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
  • 553
6 votes
0 answers
277 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
  • 773
6 votes
0 answers
156 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
678 views

Totally Antisymmetric Function

My current implementation for a totally antisymmetric function is like this: ...
Jojo's user avatar
  • 1,278
6 votes
0 answers
101 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
  • 61.6k
6 votes
0 answers
123 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,527
6 votes
0 answers
267 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,438
5 votes
0 answers
118 views

Create custom definition for chain rule of partial derivative of a vector-valued function

I'm trying to calculate derivatives of expressions involving an unknown function $F: \mathbb{R}\times\mathbb{R}^n\times\mathbb{R}^n \rightarrow \mathbb{R}^n$, with respect to a parameter $h \in \...
D__'s user avatar
  • 191
5 votes
0 answers
227 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,960
5 votes
0 answers
86 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
86 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
  • 137k
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
  • 111
4 votes
0 answers
68 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,728
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
  • 5,249
4 votes
0 answers
115 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
186 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
  • 137k
4 votes
0 answers
115 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
273 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
109 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
  • 272k
4 votes
0 answers
516 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
347 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
158 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
104 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
194 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
  • 26.3k
4 votes
0 answers
444 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
42 views

How can I access subsets in manageable chunks?

I have a large subset (as an example). subset = Subsets[Range[8000], {2}] I cannot evaluate this as I don't have enough space. So the question is how can I access ...
internet's user avatar
  • 793
3 votes
0 answers
130 views

How to estimate Lake area and volume in Mathematica?

I have a satellite image of the lake and I want to estimate its area and volume. Actual volume:1.49*10e8 m^3 Actual Area:36.9 km^2 I did the following command to find the volume, but it is not very ...
Erfan's user avatar
  • 169
3 votes
0 answers
78 views

How can I calculate P-Value for a custom distribution?

I used DistributionFitTest but it works only with a defined distribution. This is the distribution that I used: ...
A Day's user avatar
  • 59
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,390
3 votes
0 answers
219 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
58 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
  • 4,295
3 votes
0 answers
128 views

Phonetic Levenshtein Distance

I'm working on some code to try to sort the "Fry" sight words (found here) into 2 lists sorted by similarity to help my daughter learn to read. I've found that when presented with multiple ...
BesselFunct's user avatar
3 votes
0 answers
67 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
  • 347
3 votes
0 answers
112 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
198 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
  • 693
3 votes
0 answers
55 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,273
3 votes
0 answers
137 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
  • 857
3 votes
0 answers
228 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,585
3 votes
0 answers
537 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
409 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
  • 923
3 votes
0 answers
111 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,133

1
2 3 4 5
9