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

learn more… | top users | synonyms

11
votes
1answer
10k views

How to express trigonometric equation in terms of of given trigonometric function?

How can I express a trigonometric equation / identity in terms of a given trigonometric function? using following trigonometric identities ...
4
votes
3answers
2k views

How can I differentiate Numerically?

Mathematica has two ways to integrate: Integrate and NIntegrate. But what about D? ...
14
votes
2answers
677 views

Why do certain values in ArcSin not fully evaluate?

This is a continuation of: Why do certain fractional values in TriangleWave not evaluate? The analysis by R.M and rasher revealed that problem to reduce to the behavior of: ...
8
votes
2answers
218 views

Tally repeated evaluation of function

How can I tally the result of repeated evaluation of a function? n=100000; f[]:=RandomInteger[{1, 4}] Tally@Table[f[], {n}] When ...
5
votes
1answer
147 views

Does pass-by-value affect the performance of function calls?

I only have a little coding experience in C, and I remember I was told that pass by reference is more efficient than pass by value since the parameters don't need to be copied. Since there is no pass ...
10
votes
1answer
180 views

How to pass composite function list to SortBy?

In order to sort alphanumeric-as-string data of the form {"T3", "T14", "T1", "E2"}, so that "T14" comes after ...
7
votes
3answers
298 views

Why can't D[] be used in place here? [duplicate]

Possible Duplicate: General::ivar is not a valid variable when plotting - what actually causes this and how to avoid it? Beginner question: Why can't I use ...
6
votes
5answers
277 views

Is it possible to insert arguments into functions when they're used like Function@ or //Function?

Is it possible to insert arguments into functions when they're used like Function@ or //Function? Sometimes I need to do this, but then I have to return to the standard function usage: Function[] ...
3
votes
2answers
183 views

Selecting for 2D points that are within a threshold distance of an upper- and lower-bound number of points

I have a very large set of 2D points: numberOf2DPoints = 10^6; pointList = RandomReal[{0, 1000}, {numberOf2DPoints, 2}]; I'd like to find a way to quickly ...
3
votes
0answers
73 views

Gather dependency on list order?

I get intrigued about Gather behavior on this post. I thought that Gather was invariant under list order? Here is the result I ...
3
votes
3answers
512 views

Solve with v9 (issues with Subscript, Overscript, Superscript etc)

The way Solve works has changed in v9 ... in essence, to get the answers that one obtained under v8, one now often has to specify a lot more information about all ...
7
votes
2answers
537 views

Determine whether some expression contains a given symbol

Given a symbol t and an expression expr, how can I determine whether or not the symbol t ...
6
votes
3answers
335 views

Difference between @ and @@

I am confused by the commands @ and @@. From the documentation, I learnt that @@ is the ...
6
votes
1answer
401 views

Evaluate continued fraction

Mathematica has the ContinuedFraction[] function to give the continued fraction expansion of a rational (or approximation of a real) number. I'm interested in the ...
4
votes
2answers
377 views

ArcTan[z] and ArcTan[x,y], Restriction and Conversion

In Mathematica there are two different forms for the arctangent (inverse tangent), namely ArcTan[x,y] which gives the arc tangent of $y/x$, taking into account ...
3
votes
1answer
203 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, ...
3
votes
2answers
2k views

Plot Even Piecewise function

Is it possible in Mathematica to plot an even piecewise function like: $ f(x) = \begin{cases} 3t , 0 \le t \le \frac{\pi}{2} \\ 3t + 6 , \frac{\pi}{2} \le t \le \pi \end{cases}$ which has ...
3
votes
2answers
294 views

What is the command to find function invariant?

What is the command to find function invariant? http://demonstrations.wolfram.com/AFunctionInvariantUnderAGroupOfTransformations/ what is algorithm it use to calculate this? Edit there is a book ...
0
votes
1answer
98 views

Can I force a function to quit and return some value after a certain amount of time has passed during its evaluation?

Imagine I provide some random input to function like FindInstance[], and I observe that, despite the existence of good solutions, the function will, with some ...
-2
votes
1answer
180 views

How to pass arguments between functions

I have two Functions, f[] and g[]. f is passed some values ,say ...
23
votes
1answer
204 views

What does Internal`InheritedBlock do?

What does the function Internal`InheritedBlock do? How is it different from the regular Block?
18
votes
1answer
282 views

What does “EquationalLogic`FindCounterexample[]” do?

I found the undocumented EquationalLogic`FindCounterexample[] by browsing the lists of available symbols, but I have no clue about its purpose. The name is ...
12
votes
4answers
318 views

How to make a function with its own options as well as passing options to other functions

I have a function with many of its own options, but I would also like to pass options to subfunctions using the FilterRules function. Here's a simple example: ...
11
votes
4answers
4k views

How to find the domain and range of a function with Mathematica?

I'm studying calculus and in some exercises I am asked to find the domain and range of a function. Does Mathematica have already a built-in function for this? I can imagine some ways of doing so, ...
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 ...
10
votes
1answer
581 views

Growth of functions

Does somebody know if Mathematica can be used to calculate the growth of functions, that is in Big O, Theta, and Omega and find proper $n_{0}$ and $c_{1}$, $c_{2}$ respectively?
8
votes
1answer
382 views

What is the difference between prefix/postfix notations and map?

I am new to Mathematica and just experimenting with the different programming constructs. I have been looking at Map and how to evaluate a function for a list of ...
7
votes
2answers
328 views

Can you apply the Cellular Automata function to a grid containing numbers?

Im attempting to simulate a simple evacuation model using cellular automata theory.My study aims to determine whether Cellular Automata can effectively represent how people would behave in a fire ...
7
votes
4answers
457 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 ...
11
votes
1answer
773 views

Write C/C++ programs calling Mathematica functions

I need to write a C/C++ program and call some functions in Mathematica especially those like Solve or NDSolve. The problem is ...
11
votes
4answers
396 views

Assessing argument type in set delayed function definitions

I'm wondering how to properly assess the type of arguments passed to functions defined with :=. I want my functions to be the most efficient, unambiguous and clear ...
8
votes
1answer
640 views

(Non-Convex) Polygon Union and Intersection Functions [duplicate]

Possible Duplicate: Intersecting graphics Back in 2009 I posted a question in comp.soft-sys.math.mathematica looking for a function which generates the union of two (not necessarily convex) ...
21
votes
3answers
422 views

Is there a bug in Pick?

I wanted to use the Pick function with a condition. But there seems to be an issue here. Take a look at this: ...
13
votes
5answers
313 views

Partitioning a list of numbers the Mathematica way

I have two sorted lists, one list will be called the "fences" and the other the "values" Fences could be: $\{1, 5, 9, 14\}$ Values could be $\{-1, 1, 3, 4, 6, 9, 10, 13, 14, 15\}$ I want to ...
13
votes
3answers
260 views

How to keep some of the results of the NestList

I'm using some iterative arithmetics to calculate wave propagation with the help of NestList. I have to use a small step size for iteration to guarantee the accuracy, which lead to too much data (e.g, ...
11
votes
4answers
278 views

Using With to scope over pure functions

Consider this example: given an option for a function func as "x" :> (a&), how can one assign different values to ...
10
votes
5answers
317 views

Transform a list of functions to a composition

How do I apply a list of functions in a nested way? Example: functionList = {f1,f2,f3} RequiredCommand[functionList,Pi] such that the required command returns ...
7
votes
3answers
302 views

Making sure that Timing[] isn't thrown off by caching

In playing with and comparing the various answers to my question here, I tried applying Timing[] to see how fast things ran, but it seemed that some of the answers ...
6
votes
3answers
757 views

How do I plot Thomae's function in Mathematica?

I wanted to plot this function $$f(x) =\begin{cases} 1 & \text{if } x= 0 \\ \tfrac1{q} & \text{if } x = \tfrac{p}{q}\\ 0 & \text{if } x \in \mathbb{R}-\mathbb{Q} ...
4
votes
2answers
280 views

Cannot call custom function loaded from script using C/C++ MathLink

I am using MathLink with C/C++ on a Unix system in order to call a Mathematica (version 9) function and get the result. The function I need to call is a personal function of mine ...
4
votes
3answers
276 views

How to cancel floating point factors?

I am currently having problems with some floating points. I have a function, which gives as an intermediate result (for example) ...
3
votes
0answers
108 views

Do a gauge transformation for a Chern-Simons theory?

Suppose we have the following Lagrangian density: $$ L=\epsilon^{\mu\nu\rho}\big(\sum_a A^a_{\mu}(x) \partial_\nu A^a_{\rho}(x)-\sum_{a,b,c}\frac{1}{3} f^{bca} A^a_{\mu}(x) A^b_{\nu}(x) ...
3
votes
3answers
170 views

What is the formula for this numerical series?

I'm developing a questions game. My goal is that the score for each correct answer will increase as the user answers more questions. Initially there are 15 points for each correct answer. Every 4 ...
3
votes
3answers
2k views

Map w/ multiple arguments [duplicate]

Possible Duplicate: How do I use Map for a function with two arguments? If I have a function: F[x_,y_,z_]:=x*y*z and I want to call it with several ...
2
votes
3answers
315 views

Generate random points in a region with higher probability in a sub-region

I am trying to generate random samples of points in the unit square in such a way that points inside a given circle are twice as likely to be selected as points outside that circle. I tried to ...
1
vote
1answer
145 views

How can I create some shorthand notation for a custom control?

Per this question, I have created a custom graphical control object which evaluates to a list of values. I would like to be able to create such an object quickly, rather than typing some command, ...
0
votes
1answer
231 views

How do I numerically solve a custom function?

Whenever I use functions like FindRoot or NDSolve, it sends x through the function and deals ...
11
votes
1answer
227 views

Is there a summary of answers Head[] can give?

Sometimes you need to check for the type of an expression. You use Head[data] to get answers. Some data: ...
9
votes
1answer
212 views

Overloading second argument of CountryData

For convenience I'm trying to add an extra property to CountryData ...
9
votes
2answers
267 views

Define Log so that negative reals evaluate on lower edge of branch

I need to get Mathematica to evaluate the logarithm of a negative real number using the lower branch instead of the upper branch, so that while ...