Questions about the use of built-in Mathematica functions, including pure functions.
51
votes
6answers
3k views
List of compilable functions
Is there somewhere a list on the functions that Compile can compile, or the cases in which a particular function can be compiled that I haven't found?
I'd be glad ...
39
votes
2answers
778 views
Flatten command: matrix as second argument
One thing I could never wrap my head around is how Flatten works when provided with a matrix as the second argument, and the Mathematica help isn't particularly ...
18
votes
3answers
447 views
How to load a package without naming conflicts?
This question applies to any package, but I encountered this problem while working with graphs.
There are symbols in the Combinatorica package (such as ...
44
votes
3answers
641 views
Automatically generating a dependency graph of an arbitrary Mathematica function?
Has anyone written a function to pull the function dependencies of a function? That is, it would be nice to have a function that returns a list of function dependencies as a set of rules, terminating ...
16
votes
3answers
1k views
Plotting piecewise function with distinct colors in each section
I have a piecewise function that I would like to plot but I was wondering if it is possible that each part of the function that is plotted when its corresponding condition is true be plotted with a ...
20
votes
2answers
518 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 ...
6
votes
2answers
418 views
Finding all partitions of a set
I'm looking for straightforward way to find all the partitions of a set.
IntegerPartitions seems to provide a useful start. But then things get a bit complicated.
...
23
votes
2answers
681 views
Block attributes of Equal
I answered “Equating matrices (or higher order tensors) element-wise” with:
...
15
votes
4answers
240 views
Enforcing correct variable bindings and avoiding renamings for conflicting variables in nested scoping constructs
Using global variables the following turns an "expression" into a Function:
expr = 2 x;
Function[x, Evaluate[expr]]
Of course ...
25
votes
2answers
3k views
What is so special about Prime?
When we try to evaluate Prime on big numbers (e.g. 10^13) we encounter the following issue :
...
6
votes
2answers
387 views
Pass function or formula as function parameter
I can write either
Integrate[x^2, {x,0,3}]
or
f[x_] = x^2
Integrate[f[x],{x,0,3}]
and get the same computation. Suppose I ...
6
votes
2answers
399 views
4
votes
1answer
290 views
What is the difference between Set and SetDelayed?
I have a problem with defining a function and most of time I get confused by Set or = and ...
30
votes
2answers
722 views
What is the difference between Reduce and Solve?
Solve and Reduce both can be used for solving equations.
Just by operating them, I know there is little difference between them.
But, the only thing I know is that there is little difference, and I ...
13
votes
3answers
387 views
Is it possible to get the order of inputs when “overloading” an orderless function?
When working with symbolic matrix operations or other objects which don't have commutative multiplication, it would be nice to not have to constantly switch out times for ...
10
votes
3answers
340 views
How to modify function argument?
Usually in programming languages, function arguments are normal local variables, which can be modified.
Is this not true in Mathematica?
...
10
votes
3answers
204 views
How to “ignore” an element of Map or MapIndexed
Say I have some function that I'm applying every element in a list to... if that element matches some criteria:
...
4
votes
1answer
364 views
How Can I use Solve/Reduce Output
Suppose I want x and y to be rationals
Solve[ x^2 + y^2 == 1, {x, y}, Rationals]
I am ...
16
votes
8answers
423 views
Applying And to lists of Booleans
I'd like to take {True,True,False} and {True,False,False} and apply And to get ...
4
votes
2answers
271 views
Evaluating an If condition to yield True/False
I would like to decide whether an option passed to my custom function has the value Automatic or something else. This is my attempt:
...
19
votes
4answers
695 views
Are there “All” and “Any” functions in Mathematica?
In Python, there is a function all which returns true if all of its arguments are true, and any which returns true if at least ...
17
votes
2answers
370 views
Implementing continuous phase/Arg function
In MATLAB there's a function called phase that is just like our Listable friend Arg, but ...
17
votes
3answers
237 views
Why is there no PositionFunction in Mathematica?
Too often I have seen the programs of inexperienced users greatly slowed by using Position in an iterative fashion, when far faster would have been to compute a ...
12
votes
3answers
235 views
Accessing list elements by name
First, a bit of a long introduction to my problem:
I only have a few weeks of Mathematica experience. I am creating a mathematica application that calculates some material properties of steel based ...
10
votes
2answers
352 views
How do I find the elements in a list that return the highest value for a function?
Suppose we have a list of values and a function f. I want to find which of the elements maximizes the return value of the function in Mathematica. Let call the ...
11
votes
1answer
4k 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
...
8
votes
2answers
158 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 ...
2
votes
3answers
592 views
How can I differentiate Numerically?
Mathematica has two ways to integrate: Integrate and NIntegrate.
But what about D? ...
7
votes
3answers
267 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 ...
13
votes
6answers
841 views
Max of a table/list with indeterminate values
Suppose I have a Table:
tab = {1., 2., 3., Indeterminate}
When I type Max[tab] I get ...
9
votes
1answer
133 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 ...
8
votes
1answer
234 views
ReplaceAll[] and Limit[] don't give correct results for this expression under extreme variables [duplicate]
Possible Duplicate:
Funny behaviour when plotting a polynomial of high degree and large coefficients
1/x^2 + (3 + x)/(6 (1 - Exp[x] + x))
——This is a ...
7
votes
2answers
229 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
5answers
214 views
How to nest my own “times” function to get powers
I have a "times" function. I'd like to create a power function using it. It should look like this for an 6th power:
...
6
votes
1answer
295 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 ...
3
votes
2answers
553 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
240 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 ...
2
votes
2answers
139 views
Position function not always retuning an answer even with no apparent problems
I'm having some problems with Position.
Sometimes it will give an empty list instead of the actual position of the element I am looking for when that element is ...
-2
votes
1answer
164 views
How to pass arguments between functions
I have two Functions, f[] and g[]. f is passed some values ,say ...
18
votes
1answer
267 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 ...
20
votes
3answers
398 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
...
14
votes
4answers
458 views
Finding Limits in several variables
Is there a way to find a limit of a multivariable function, like
$$\lim_{(x,y)\to (0,0)} f(x,y)$$
with Mathematica?
When $f$ is continuous, we can use
$$\lim_{(x,y)\to (0,0)} ...
8
votes
1answer
148 views
user defined functions, how to save them for future use?
I need certain user defined functions over and over. I was wondering how can I define and where and how to save them such that each time I start a notebook, these functions are available and need not ...
9
votes
1answer
401 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) ...
20
votes
3answers
374 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
3answers
188 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
289 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 ...
7
votes
3answers
215 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
560 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}
...
5
votes
1answer
92 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 ...


