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

learn more… | top users | synonyms

3
votes
1answer
205 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, ...
1
vote
1answer
77 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
62 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
208 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
174 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
60 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: ...
7
votes
3answers
162 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 ...
3
votes
5answers
304 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
139 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
115 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
110 views

Understanding output of multivariable integration

I'm new to Mathematica and I'm trying to integrate this function: ...
0
votes
2answers
72 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
100 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
215 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
208 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
131 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
193 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
177 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
151 views

Inverse function

What probably could be the inverse of following function? ...
7
votes
2answers
279 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
60 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
143 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. ...
23
votes
4answers
265 views

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

In ListPlot and Interpolation, the option InterpolationOrder->0 uses two different ...
4
votes
1answer
257 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
220 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
144 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 ...
1
vote
1answer
143 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 ...
3
votes
1answer
111 views

plotting hypergeometric functions

Does anyone know why a plot of a hypergeometric function turns out differently in Mathematica than in Maple? The function I'm plotting between x=-30 and +30 is: ...
1
vote
0answers
94 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
74 views

Ordering under assumptions

I have a three-element list which contains inverses of a function u, like so: ...
2
votes
1answer
86 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 ...
0
votes
0answers
407 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 ...
11
votes
2answers
264 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 ...
19
votes
0answers
228 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" ...
-1
votes
1answer
127 views

Totalling a list including negative values [closed]

I'm trying to use the Total function on a list that includes negative values, and can't seem to figure out how to stop Mathematica from getting hung up on those ...
0
votes
1answer
95 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 ...
2
votes
1answer
94 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
197 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 ...
1
vote
1answer
83 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
199 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 ...
0
votes
0answers
61 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 ...
0
votes
1answer
269 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 periodic solution, and in ...
3
votes
0answers
86 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
181 views

Calling functions which take their arguments interactively

Lets say I have a file named test.m containing some functions. ...
6
votes
1answer
226 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
57 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
301 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
727 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?
3
votes
2answers
375 views

How can I find the range of my function

I am trying to find the range of (3 Sin[x] - 3)/(2 Cos[x] + 10), I tried this, ...
3
votes
1answer
282 views

How do I draw a credible velocity vs. time graph using Locators?

This is partly a math question, partly a Mathematica question. For educational purposes, I'm making a simple demonstration to create a velocity over time graph from six locators. On the basis of ...