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

learn more… | top users | synonyms

1
vote
1answer
91 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 ...
4
votes
4answers
221 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: ...
0
votes
1answer
139 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 ...
0
votes
0answers
64 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
1answer
162 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 ...
1
vote
4answers
198 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 ...
4
votes
1answer
398 views

Using DistributionFitTest on custom distributions in Mathematica 8

I originally posted this question on Stack Overflow, but I didn't get any answers, and I'm hoping to have better luck here. I'm trying to compute the goodness-of-fit of a bi-modal Gaussian ...
7
votes
2answers
376 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 ...
26
votes
4answers
339 views

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

In ListPlot and Interpolation, the option InterpolationOrder->0 uses two different ...
26
votes
2answers
772 views

Strange ::usage behavior in v9

Note: This is fixed in 9.0.1. Something has gone wrong with usage in Mathematica 9. Would someone tell me how to fix it? I define a function ...
1
vote
0answers
177 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. ...
4
votes
1answer
355 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 ...
7
votes
3answers
335 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
1answer
156 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
202 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
178 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
118 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
81 views

Ordering under assumptions

I have a three-element list which contains inverses of a function u, like so: ...
2
votes
1answer
92 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 ...
11
votes
2answers
307 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 ...
1
vote
0answers
727 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 ...
0
votes
1answer
196 views

Calling functions which take their arguments interactively

Lets say I have a file named test.m containing some functions. ...
21
votes
0answers
300 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" ...
0
votes
1answer
105 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
111 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
202 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 ...
2
votes
1answer
280 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
67 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 ...
3
votes
0answers
90 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 ...
6
votes
1answer
245 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 ...
4
votes
2answers
567 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, ...
7
votes
4answers
617 views

How make f[{x,y}] evaluate as f[x,y]?

I frequently encounter the situation where I have a function of two real variables defined, e.g.: f[x_, y_] := 9 - x^2 - y^2 But then I need to feed into ...
0
votes
1answer
64 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}], ...
1
vote
4answers
1k 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
1answer
418 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 ...
3
votes
1answer
155 views

Circle as a function parameter

What I want to do is to find a circle which is tanget to the three big ones. I tried the code below: findSmallCircle[c1_Circle, c2_Circle, c3_Circle] := ...
0
votes
1answer
80 views

Function or script which maxes out the CPUs?

I've been using Mathematica for awhile now and have never come even close to maxing out my CPU cycles. Are there any functions which consume lots of CPU cycles? Right now I am running a script which ...
4
votes
1answer
721 views

What do the hashtags represent in the result of Solve, and how should I use them? [duplicate]

There is a function that I'm trying to get the inverse of. My function is a simple polynomial: Tn[T_] := 4/9 T^3/Tc^2 + 5/9 T Now I tried to find ...
0
votes
2answers
194 views

Is there a better way to approximate some graphs of integrals than interpolation?

I'm still pretty new to Mathematica so my apologies if this is a dumb question. I wanted to plot some integrals of functions for no particularly good reason, but the only decent way I could come up ...
0
votes
2answers
87 views

How would I add together any list of arguments as a pure function?

Let's say I have a list of arguments, of any length. How would I add them all together? f = Evaluate[Plus @@ Array[Slot, 3]] & f[1, 2, 3] This would add ...
2
votes
1answer
636 views

How to take the derivative w.r.t. an arbitrary function?

EDIT: The answer posted by @Jens works for built-in functions only. However I'm starting to wonder if this is related to my Mathematica install somehow. I have version 7. Here is an example in the ...
3
votes
2answers
2k views

Define a color function using Piecewise

How can I define a ColorFunction for my ContourPlot using Piecewise? For example after ...
1
vote
1answer
84 views

How can I transform parts of an Integer list to a String list

There is a sorted list of Integers. ilist = PadRight[Sort[ RandomSample[Range[1, 99999], 3], Less], 5] It should become string area codes like: ...
29
votes
3answers
662 views

Parentheses in pure functions: # & vs. ( # &)

I've been using Mathematica for years, and over time I have developed the habit of using: Select[data, (# == 1 &)] instead of ...
5
votes
2answers
162 views

How to check an algebraic number for membership in a list

I need to check an algebraic number for membership in a list of algebraic numbers. The numbers can be expressed in different forms (combinations of radicals, Root ...
1
vote
0answers
24 views

valuation to a function using a list [duplicate]

What I want to do is to evaluate a function as shown below: LessQ[n_] := LessQ[n] = l[n] < 61 In some cases, when I am sure that on a list the ...
10
votes
5answers
749 views

Building a continued fraction

I've completed a problem that involves approximating $e$ by a continued fraction: $$\frac{N_1}{D_1+\frac{N_2}{D_2+\frac{N_3}{\ddots+\frac{N_k}{D_k}}}}$$ with the $N_i$ being the list ...
2
votes
1answer
130 views

making a function of fit results

I have 13*25 datasets consisting each of around 40 points. They are all linear I can easily fit them using fit function but my problem is when I want to call them I want them to be functions. I want ...
4
votes
1answer
250 views
-1
votes
2answers
310 views