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

learn more… | top users | synonyms

0
votes
0answers
50 views

Phase Unwrap List Of Points: Implementing continuous phase/Arg function for List of Points [duplicate]

I am looking for a function to unwrap phase of a list of points as done here for the continuous case. I have the Re/Im data as my input and would like the unwrapped phase as the output. Does anyone ...
10
votes
5answers
542 views

How to find first list element that differs from average of N previous elements by more than a given amount?

Given a list of real numbers, I need to write a function that returns the value of the first element in the list that differs from the mean of the previous $N$ elements by greater than $P$ standard ...
10
votes
4answers
1k views

How to find the domain and range of an implicit function?

For example, we have this curve: $$x^2 + y^2 = 1$$ Is there a function in Mathematica for finding out that the ranges for $x$ and $y$ are both $[-1, 1]$? What about implicit functions of more than ...
3
votes
1answer
322 views

NestList with a list inside?

I'm new to Mathematica, and was looking for more efficient ways to implement the Do loop below. a, ...
2
votes
1answer
162 views

User-defined Distance Functions with extra parameters [duplicate]

The Nearest function accepts a customized distance function. For example, a simple case that works well is ...
1
vote
1answer
83 views

Why is a function I defined in a package not visible when I load the package? [duplicate]

I made a package containing some functions in the following way. ...
6
votes
2answers
230 views

Not FullDefinition for Save. MachineID not Protected?

Is there a way to set what symbols's definitions I do not want to store? Consider the following code: ...
1
vote
1answer
224 views

Map a function conditional on elements at multiple relative positions in a list

I figure this question has many solutions, and if an answer already exists it would be nice just to be referred to it. I need a function that 'maps' over my list and produces a list of equal length ...
0
votes
1answer
62 views

Errors in evalauting an expression

I have the following: Constants: b3b = 2; G = (1/eps^2); a1 = 3; a3 = 4; xc = 0.3; Functions: ...
8
votes
3answers
249 views

How can I break through Function's HoldAll attribute to force evaluation of a body element?

The question concerns creating a function. Let consider the following code With[{f = Function[t, Cos[t]]}, {First[#], f'[#]} & ] which returns ...
4
votes
5answers
342 views

How to generalize and speed up this program?

There is a vector whose length is $n*m$, we can part it into $n$ sections in order. I want to define a function to compare the $i$-th and $i+1$-th section and find the minimum. The program for $n=m=3$ ...
1
vote
1answer
221 views

BSplinefunction and its derivative

Hi I am trying to use curve fit some data using the BSplinefunction. I havent been using Mathematica long, so my questions might be quite basic. ...
2
votes
1answer
267 views

How to compute a discrete histogram of a list [duplicate]

I'm trying to compute the discrete histogram of a set of values. By histogram I mean the absolute frequency a value appears on the dataset, by discrete I mean the values are from a discrete set, e.g. ...
0
votes
1answer
167 views

Understanding output of multivariable integration

I'm new to Mathematica and I'm trying to integrate this function: ...
0
votes
1answer
81 views

Scope of expression in a user-defined function

I have the following code: fbasic = A + R + Z*Z *Z*Z; f[A_, Z_, R_] := fbasic + R; f[0, 2, 3] The answer I am getting is ...
0
votes
1answer
190 views

Defining functions with changing number of variables [duplicate]

I am working with a bunch of functions of the form fn[x1_,x2_,x3_,...,xn_] := x1x2+x2x3+...+xnx1 where $n$ changes. Is there a way to create these functions ...
4
votes
4answers
234 views

How to avoid writing $K$ loops?

I want to evaluate a mathematical function of $K$ variables each of variables varying between 1:N. One way to do this is writing $K$ loops and varying variables accordingly, as shown below: ...
2
votes
4answers
228 views

Find time since last 0 in list

When I have a list of data (measured per day), is it possible to define a function that gives the nr of days since the data has been 0? I tried working with...
1
vote
1answer
232 views

Create continuous function from list

I have a list of data (measured per day) that I want to use as imput for another equation (say f). The problem is that the input I need for f needs to be a continuous function of time. Is it possible ...
2
votes
2answers
295 views

Writing a function that returns a (usable) function

I am trying to create a function that returns Arnold's Cat Map of size n iterated k times. I can get something out of the Function command, but I can't figure out ...
1
vote
4answers
209 views

How to use If to select arguments min & max in Range?

I want to call Range[] with its arguments depending on a condition. Say we have ...
0
votes
2answers
188 views

Inverse function

What probably could be the inverse of following function? ...
7
votes
2answers
522 views

How can I define a sequence of functions?

I need to define a function fun, and then re-define this function iteratively. The code is given at the end. First, a function ...
0
votes
0answers
66 views

Defining functions in a loop [duplicate]

I have a symbolic solution to a linear system with respect to some variables a[i,j] which depend on a parameter t. sol=Solve[...,Table[a[i,j],{i,0,n},{j,0,n}]] I ...
1
vote
0answers
224 views

Positive integrand giving negative answer

I'm integrating a positive function f(t) times sin(t) from 0 to pi/5 and get -38. Actually f is slightly negative for a short time (smallest value ~ -0.0005), but far from enough to explain this. ...
30
votes
4answers
539 views

How can the behavior of InterpolationOrder->0 be controlled?

In ListPlot and Interpolation, the option InterpolationOrder->0 uses two different ...
5
votes
1answer
449 views

Counting the number of operations performed during a calculation

I need to know how can I count the number of operations performed during a calculation of a CompoundExpression. In some of these expressions there are ...
2
votes
1answer
291 views

Call Functions From File Without Modifying Context (Sandbox)

Let's say I have file named test.m containing test[arg1_] := ( Print[arg1];) What is the best technique for calling test like ...
1
vote
1answer
176 views

Expansion of functions in the real domain

When I try FullSimplify[FunctionExpand[x^(1/12)(1/12) LerchPhi[x,1,1/12]]] I have a nice answer with many complex numbers. Is there any way to have the ...
2
votes
1answer
261 views

Inverse on a restricted domain

I have a function, whose domain is [0,1]. The function is f = Piecewise[{{Exp[-β * (-Log[#])^α], 0 < # <= 1}}, #]& with ...
1
vote
0answers
129 views

CDF with numerous independent manipulate objects

I have been working on my senior project that involves the creation of a CDF with multiple Manipulateexpressions. I need to protect my code so I have been trying to ...
0
votes
1answer
94 views

Ordering under assumptions

I have a three-element list which contains inverses of a function u, like so: ...
2
votes
1answer
102 views

Replace inverse function

I'm solving an expression like so: Solve[u[x] == u[a] + u[b], x] Mathematica returns {{x->(u^(-1))[u[a]+u[b]]}} If I ...
1
vote
0answers
1k views

How to Output Chi-Squared Statistics when using NonLinearModelFit

I am using NonLinearModelFit for some curve fitting and I was wondering if NLM is able to output chi-squared/leastsquared statistics from the best-fit parameters and confidence intervals. From my ...
13
votes
2answers
326 views

Clever use of DownValues, or failure to understand the “Mathematica Way.”

I needed to look at the changes in the values of about 4000 items from one year to the next. I have a table with identifiers and values for each year. Not all of the items are in each list. The ...
22
votes
1answer
472 views

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

Bug introduced in 5.2 or earlier and fixed in 10.1.0 This is another question on the design choices in Mathematica. I understand that without direct reply from the developers it may not be ...
0
votes
1answer
108 views

Is there such a command like FindZero[f[x],{x,1}]?

I´d like to find the zeros of a function. I know I could find them by Solve[f[x] == 0, x] but that gives me only the x-coordinates. I want to get both the ...
3
votes
1answer
126 views

How can I define a function taking two distinguishable sets of options?

It commonly happens that one wants to define some function foo which in turn calls some other function (e.g., Plot) that can ...
9
votes
2answers
211 views

How can I make Which format its output?

Functions like Piecewise have cool, easy-to-read formatting. In the same vein, I think it would be wonderful if the Which ...
29
votes
2answers
857 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 ...
1
vote
1answer
93 views

Techniques To AutoReplace Browse

Let's say I have a function of the form. Test[File_,text_] What would be the most automated way and flexible way to generate an input cell of the form, such ...
2
votes
1answer
377 views

Problem with Covariance Matrix Output in NonlinearModelFit

I am running NonlinearModelFit based off of some simulated data and trying to fit to a function with more than one parameter. Eventually, I would like to fit to 5 ...
1
vote
0answers
81 views

what is the difference between these definitions? [duplicate]

I define 2 functions: g[s_][x_,y_] := the gaussian (1) g1[s_,x_,y_] := the gaussian (2) I get the same answer using ...
1
vote
1answer
896 views

Computing the fundamental matrix and its monodromy matrix

Assume $\dot x(t)=v(x,t)$ is a $T$-periodic, with respect to $t$ dynamical system. That is: $x\in\mathbb R^n,\quad t\in\mathbb R,\qquad v(x,t+T)=v(x,t)$. Let $x_0$ be a smooth periodic solution in ...
3
votes
0answers
95 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 ...
0
votes
1answer
213 views

Calling functions which take their arguments interactively

Lets say I have a file named test.m containing some functions. ...
9
votes
1answer
310 views

solve ODE with divergencies

The solutions of the second order differential equation $$\frac{1}{\eta}\frac{d}{d\eta}\left(\eta \frac{df}{d\eta}\right)+\left(1-\frac{s^2}{\eta^2}\right)f-f^3=0$$ is shown in Fig. 5.2 below, for ...
0
votes
1answer
71 views

Extracting function variables from a list [duplicate]

Evaluating the following func[x_, y_] := x^2 + y^2 listn = {{a, b}, {c, d}, {e, f}}; Map[func[##] &, listn, {1}] yields {func[{a, b}], func[{c, d}], ...
7
votes
3answers
369 views

Find names of the functions defined in a file

Lets say I have a file named file.m that contains: test[] := ( Print["test"] ) How would I go about extracting the function ...
1
vote
4answers
2k views

Solve trigonometric equation

I'm looking for a solution (graphic, numeric or analytic) for a function of the form: $$a^2\tanh(x)=\tan(ax),\quad a ≥ 1,\ x > 0$$ preferably using Mathematica. Any advice?