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

learn more… | top users | synonyms

5
votes
1answer
142 views

Why do functions defined with SetDelayed and Function behave differently in callbacks?

It seems to me that functions defined using a simple pattern and SetDelayed (the usual way to define a "function") should be equivalent in all respects to functions ...
0
votes
0answers
38 views

How can I get the covariance result cumulatively?

I am trying to derive the covariance results for n x 4 matrix where n is an arbitrary number. I am trying to derive the covariance for each row cumulatively. For example, I am trying to derive the ...
0
votes
1answer
57 views

Function to find minimum element in array [duplicate]

i have this code: ...
-2
votes
1answer
101 views

plot sum of two function

I am trying to illustrate sum of functions. I have one function x*x - 8*x + 7 and another Log[2*x + 4.5] I understand that I ...
6
votes
2answers
190 views

Built in function without Attributes Listable works as if it has Attributes Listable

Can Built-in function works as if it has Attributes Listable even if it doesn't have that ...
1
vote
4answers
81 views

NestWhileList, control to show the second sequence

For example,each number will end up with 89 or 1, however , How can I generate a sequence with two sub sequence. f[n_] := IntegerDigits[n]^2 // Total One sub ...
14
votes
1answer
193 views

Major slowdown when using a ColorFunction with more than one named scheme

Problem remains in 10.1 Earlier Kuba noted a major slowdown with code Simon Woods posted. Here is a simplified example. First a color function using two different named gradient schemes: ...
1
vote
1answer
56 views

little problem of Thread, List head of second argument

Thread[f[{a, b, c}, 0]] (* {f[a,0],f[b,0],f[c,0]} *) Thread[f[{a, b, c}, pp[0]]] (* {f[a,pp[0]],f[b,pp[0]],f[c,pp[0]]} *) Howerver, the head of pp ...
2
votes
3answers
145 views

Finding minimum of a list of pairs

Sometimes I need to find the Min of a list, whose elements are lists (say of two elements, a pair). Given that Min does not have the option to indicate a sorting function like Sort, I elaborated the ...
1
vote
1answer
66 views

Changing Function Domain of Fourier Series

If I write FourierSinSeries[x, x, 10] Mathematica will output the first 10 terms of the Fourier Sine Series f(x) = x defined for 0 < x < Pi. How do I output the the Fourier Sine Series for ...
8
votes
3answers
298 views

How to build a matrix from a set of vectors and other matrices using ArrayFlatten

I want to build a 6 by 3 matrix, from the following: one vector is 3 by 1, then a matrix, which is 3 by 2. These will go to the top 3 rows. Now the bottom 3 rows, I'll have 3 vectors each is 3 by 1. ...
2
votes
2answers
183 views

Plotting difference between a function and its inverse function

I would like to plot the difference a function and its inverse function. (1/27)*(x^4-6x^3+12x^2+19x) (* where 0<x<5 *) I tried the following: ...
1
vote
1answer
60 views

Function taking arbitrary number of arguments

I have a very similar function to that which a solution was provided by kguler, but am unsure as to how to adapt the solution that was given there. That post can be seen here. The adaptation is only ...
0
votes
3answers
126 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
101 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
47 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 ...
0
votes
1answer
61 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
64 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 ...
8
votes
1answer
229 views

Prevent Export from overwriting files

Export["filepath1",Expression1] works for me, but if filepath1 already exists, it will be overwritten. I'd like ...
1
vote
1answer
155 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 ...
0
votes
2answers
77 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
111 views

Help with functions in Mathematica

I'd like 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 these "pieces", which I want to put into a ...
6
votes
1answer
282 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
64 views

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

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 ...
8
votes
2answers
268 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
99 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
81 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
474 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
65 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
251 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 ...
1
vote
1answer
58 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 ...
-2
votes
2answers
104 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 ...
0
votes
1answer
43 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 ...
6
votes
2answers
147 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. ...
2
votes
1answer
112 views

Dirichlet convolution of two lists [closed]

The Dirichlet convolution of two arithmetic functions f,g is defined by $f\ast g(n) = \sum\limits_{d|n} f(d)\ast g(n/d)$ How can I get the Dirichlet convolution of two lists? For example: Input: ...
0
votes
1answer
43 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
1answer
73 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 ...
0
votes
0answers
64 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 ...
3
votes
2answers
118 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
63 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
50 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
104 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 ...
3
votes
0answers
81 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 ...
3
votes
1answer
242 views

Creating the Nabla operator as a operator

How can I define the nabla-operator as a an operator, acting on everything to the right of the operator! Also taking \[Del]^2 would give the second derivivates. I wish to be able to write ...
5
votes
4answers
202 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
197 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
60 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
23 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 ...
1
vote
1answer
51 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 ...
1
vote
1answer
81 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 ...