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

learn more… | top users | synonyms

0
votes
3answers
96 views

How to define a function

How can I define a function which depends on a function of x? Something like this f[u[x]_,u[x]']= u[x]' + a [x] u[x] +b[x] I think I wasn't enaugh clear. If I ...
1
vote
1answer
82 views

How to find and verify relationships between functions?

MMa gave me a complicated result involving Hypergeometric0F1's. It was much less complicated after I discovered this identity: ...
0
votes
1answer
34 views

Calling a function on a variable with parameters [duplicate]

I have an equation that contains parameters. I want to use it in a function like NDSolve, but I can't seem to figure out how to do so. Here's an example: I define ...
1
vote
0answers
80 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 ...
0
votes
1answer
48 views

Permanently fixing a variable in the function

I need to define a function let's say f[x_, y_] := x^2 + y^2 such that I need to fix one variable (let's take y = a) and to ...
0
votes
2answers
56 views

Supply a function as an argument to another, and find its minimum

I would like to minimize a function, which is supplied as an argument to another function, and report back the estimates of the values of the variables that result in its minimum. In specific, I would ...
6
votes
1answer
169 views

Prevent Export from overwriting files

Export["filepath1",Expression1] works for me, but if filepath1 already exists, it will be overwritten. I'd like ...
18
votes
3answers
724 views

Can someone explain this snippet: (#[#] &)[#[#][#] &]

A friend showed me this snippet of code today: (#[#] &)[#[#][#] &] I can sort of see that we're constructing an anonymous function that takes a function ...
1
vote
1answer
133 views

General function taking general number of arguments

The following is an edit of this post, for which a working solution was provided by John McGee. I have a different function and am not sure how to adapt the solution for it: I want to construct a ...
6
votes
1answer
194 views

How trustworthy is NMaximize?

Suppose I solve a constrained optimisation problem using NMaximize. How confident can I be of the accuracy of the result? For concreteness, suppose that F,G are ...
0
votes
2answers
62 views

Function that creates a table from two lists

I have two lists shown below: list1 = {(0,0,0,0),(0,0,0,1),(0,0,1,0),...,(1,1,1,1)} list2 = {1,5,5,5,...,5} How can I construct a function that outputs a table similar to this: $$\begin{array}{c|c} ...
0
votes
1answer
92 views

Help with functions in Mathematica

Still learning how to do things in Mathematica. I want to make a function that has many parts. Doing this in something such as Java, which I am familiar with, would be simple. In Mathematica I have ...
-1
votes
1answer
186 views

Find minimum function value in data and give coordinates of minimum

I create with Table an array containing the function value of some function and the n1and ...
0
votes
2answers
50 views

Fitting data in form $f = f_0 + c A^x$

The Fit[] function in Mathematica can fit data in form of $f = f_0+c_1x+c_2x^2+...$ ($f_0$ and $c_i$ are unknown constants), is there a function can fit date in ...
6
votes
2answers
146 views

What does IndexBy do and how exactly does it work?

I just saw the function IndexBy in the autocomplete suggestions and I was curious to know exactly how it works. Unfortunately, there's no trace of it in the ...
0
votes
2answers
79 views

Is there a function that filter positive values x = f(x), and return zero for all negative values? [closed]

I'm searching for f that will comply this definition : x = f(x) where x is natural >= 0 0 = f(x) where x is natural < 0
0
votes
1answer
70 views

How to create a line due to requiriements?

Considering we have three lines, and know the intersection points (How to find intersection points of lines?) How can I draw a line that will cross the intersection point of the two lines and will be ...
1
vote
3answers
321 views

How to find intersection points of lines?

Considering I have three functions f1 = -x + 1; f2 = x - 1; f3 = x + 3; How can I find the intersection points of this functions? Thanks. This didn't work ...
0
votes
0answers
64 views

What is the product of 1+1/p^2 over all primes p? [duplicate]

Can Mathematica Sum or Multiply over the set of all primes? I can get an estimate of my question in the title with: ...
4
votes
3answers
221 views

Problem about an ant walking up a hill

An ant is walking up a hill given by $f(x)$. At what point can it see a blade of grass. I've been working on this problem with Mathematica and by hand. Help with either would be fantastic. The ...
3
votes
0answers
65 views

Using an external Pattern breaks Format

I noted while writing this answer that using an external Pattern on Format doesn't work: ...
1
vote
1answer
48 views

Using Inner to calculate a log likelihood

I am trying to use the function Inner to calculate the sum of log likelihoods of a custom probability distribution 'custom' applied to a vector of data 'vData'. The custom distribution changes ...
20
votes
3answers
748 views

DeleteDuplicatesBy is not performing as I'd hoped. Am I missing something?

Déjà vu: a new-in-v10 function should provide a better solution to an old problem, but my enthusiasm is curbed when I run timings. This time the function is ...
21
votes
1answer
385 views

Why does list assignment with a packed array result in unpacked values?

This is another question on the design choices in Mathematica. I understand that without direct reply from the developers it may not be possible to give a definitive and exhaustive answer to "why" ...
-2
votes
2answers
83 views

Plotting self-made functions [closed]

EDITED AS SUGGESTED I have defined a function, which takes two values and returns a function n(x), like so ...
5
votes
2answers
123 views

Using MovingMap to calculate percentage changes

MovingMap (new in version 10) applies a function to discrete data over a moving window. This is very convenient for calculating the percentage change of a series. ...
0
votes
1answer
39 views

Summation of functions

I want to define a function that is a sum of other functions. For this, I define functions of the form ...
2
votes
1answer
84 views

Dirichlet convolution of two lists [closed]

The Dirichlet convolution of two arithmetic functions f,g is defined by $f*g(n) = Sum_{d|n} f(d)*g(n/d)$ How can I get the Dirichlet convolution of two lists? For example: Input: ...
0
votes
1answer
41 views

How to set a shared variable Power (a modified one)?

Unprotect[Power]; Power[0|0., 0|0.] = 1 ; Protect[Power]; Table[0^0, {i, 5}] No problem at all. ParallelTable[0^0, {i, 5}] ...
0
votes
0answers
49 views

subtlety of self-defined function and its evaluation [duplicate]

I wrote a simple code as follows f[x_,y_]:=NIntegrate[x+z,{z,0,1}]; g[x_,y_]:=NIntegrate[y+z,{z,0,1}]; VectorPlot[{f[x,y],g[x,y]},{x,0,1},{y,0,1}] then ...
0
votes
1answer
59 views

Mathematica function to generate a different 4 digit number [closed]

I m looking for a function that permit me to generate a different 4 digit number (>0) each time (to 4^10 possibilities) corresponding to a parameter that will never be the same (like current ...
15
votes
7answers
581 views

Enumerating tuples from a larger space such that all pairs of values are present at least once

I am trying to write a function that will accept a list of N lists and returns a list of N-tuples that represent all pairs of values from the original N lists at least once. To illustrate with an ...
3
votes
2answers
98 views

How to define a list of symbols as a list of functions?

I have a list in Mathematica for example P={1+t,1+t+t^2,1+t+t^3}; My question is, how I can define each element of this list be a function of ...
1
vote
1answer
38 views

Cannot use Part in Pure Function [duplicate]

I need to select some lists in the nested list of form of {{1,2,3},{2,3,4}}. I have used Select to complete my work. But when I tried Position, it doesn't work. For example, ...
1
vote
1answer
48 views

Mathematica defines a function as list

This might be a very silly question but i'm defining a function as: \[Chi][AR_] := ((AR^(2) - 1)/(AR^(2) + 1)); which is clearly a scalar function of AR; however ...
3
votes
1answer
89 views

Creating an autokey cipher function

Can someone help me with putting what I can say in words into code. I want to create autokey encrypt and decrypt functions (just wanting help encrypting and then can figure out decrypting). Everything ...
2
votes
0answers
64 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 ...
5
votes
4answers
186 views

Sort two lists at the same time, based on another

I am new to using Mathematica and I can not find a solution to what I am wanting to do. I want to take a list such as: x = {1,2,3,4,5,6,7,8} and a second list ...
1
vote
1answer
44 views

Function does not initialise variable as changes are made in the manipulate function

My function "DefineRss[]" takes in three arguments and outputs a plane value. It sits in the first argument of the function plot3D and that in turn sits in the manipulate function The function also ...
2
votes
1answer
175 views

What method does `NIntegrate` uses by default?

There is a variety of algorithm for performing numerical integration (See wiki). What method does NIntegrate uses by default? I looked on the documentation page and I saw that the function ...
1
vote
1answer
177 views

Shorthand for operations?

Mathematica has a large number of built-in symbols, and I am unsure when there is a shorthand for the operation I am trying to perform. Question 1: Is there a shorthand for the function ...
1
vote
0answers
46 views

Can Mathematica return the first few terms of a sequence given the first few terms of a Dirichlet Generating Function?

For example: a=Sum[1/n^s,{n,1,6}]; Expand[a^2] returns a big mess. I want to see something like: 1/1^s + 2/2^s + 2/3^s + 3/4^s + 2/5^s + 4/6^s + ... + 1/36^s.
2
votes
0answers
20 views

Determining default value from previous arguments [duplicate]

How does one specify a default value for an argument which is dependent on the previous arguments of a function? For instance, consider the function ...
5
votes
5answers
230 views

What is primary, function computation or function application?

What is the order of computations here? g[x_]:=x^2; f[x_]:=Sqrt[g[x]]; Map[f, Range[100]] Does this code first get $f(x)=x$ and then gives its values or for ...
1
vote
1answer
52 views

Minimize under constraint on an interval

I want find the minima of a (multivariable) function under a constraint which has to be fulfilled on a whole interval, let's say $$ \nabla f (\underline x) = 0 \ \\ \ c(\underline x,s)\geq0\ \forall ...
2
votes
2answers
132 views

Permanently rounding numbers/values to a given number of significant figures

I am searching for a simple way of rounding and setting an input to a desired number of significant figures. There are a vast number of posts that discuss similar problems, but none address this ...
2
votes
1answer
84 views

PrimitiveRoot function

The function PrimitiveRoot[n] claims to return the smallest primitive root of n. I believe this is not true. For example ...
28
votes
2answers
817 views

Is there a name for #1@#2&?

Why does the pure function # @ #2 & have no name? I'm asking because sometimes I find inelegant to write expressions like ...
4
votes
2answers
95 views

DeleteMissing issues [duplicate]

Has anyone had problems with the DeleteMissing function in Mathematica 10.0.2? I find that it rarely works. Most of the time it returns a list which still contains ...
1
vote
2answers
46 views

Evaluate list of functions at a certain point

I have a list of functions (actually they are derivatives) of the type: {D[g[x,y],x],D[g[x,y],y]} I would like to evaluate all of these functions at a point, ...