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

learn more… | top users | synonyms

23
votes
4answers
467 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 ...
1
vote
3answers
1k views

How do I create a matrix of functions?

I'm trying to create a matrix in which the elements are functions of two variables, but I can't figure out how to do it. Is it possible? The only way I could figure out is to define the matrix in ...
2
votes
1answer
146 views

Expression for the real 7/3 power

I need an expression for the real 7/3 power of a real-valued function, i.e., a reformulation of f[x_] := g[x]^(7/3) that works for negative values of ...
4
votes
1answer
307 views

A Faster way to combine two Lists of different structures into one of a different structure [duplicate]

I have the following two lists (each containing over 500,000 elements). Here is a sample: ...
1
vote
1answer
356 views

Forcing evaluation of ArgMax

How to force evaluation of ArgMax before its output gets used in Solve? Background: I'm trying to solve for the Nash ...
2
votes
1answer
259 views

Evaluate Numerator and Denominator Separately

I have this function. ...
1
vote
0answers
89 views

Solving for vector elements in a function to which the vectors are not passed explicitly

I want to define a function which takes in two integers (indicating the lengths of 2 vectors), and solves a simple set of expressions at a set of points to find all the values in both the vectors. so ...
1
vote
1answer
269 views

Speeding up code by avoiding repeated evaluation of a function

I want to speed up my code and I have two ideas, but I don't know how I can implement them. Here is a little part of my code, which I want to improve: ...
1
vote
1answer
216 views

Function definition and delayed assignment

I need to define the following function MyWavelet[n_]["PrimalLowpass", prec_ : MachinePrecision] := Table[(-1)^(j - 1) h[[2*n - j]], {j, 0, 2*n - 1}] which ...
11
votes
2answers
272 views

Function with custom Options and modified Options for built-in Symbols

I couldn't find a more descriptive title, but I guess an example will explain my problem. I set up some customized Grid function including some additional ...
6
votes
3answers
309 views

Permanent minors

The function Minors yields the minors of a matrix. Is there a function that yields the permanent minors of a matrix?
4
votes
3answers
169 views

Creating a nonperiodic function in mathematica

I want to create a non-periodic square wave with values of 1 and -1(not necessarily alternating). For e.g. I want to convert an arbitrary array like {1,-1,-1,1,-1,1,-1} into a function. I tried ...
3
votes
3answers
666 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 ...
3
votes
1answer
142 views

Downvalues vs. Scoping for Functions

Regarding my recent question on using a default value for a function argument when a pattern was not met yielded some interesting answers, but the general consensus was "Yes this can be done, but ...
1
vote
0answers
32 views

Define a second name for a function [duplicate]

I'm working with an own package of functions. During development I noticed, that my naming scheme is not that clever; for example some of my functions are starting with capital letters. But I have ...
2
votes
1answer
203 views

Print out all functions in Mathematica

Sometimes I only remember parts of a function name and I want find that function name quickly, and if I search in the document center, it will give too much informations related to that and difficult ...
8
votes
1answer
270 views

Optimizing the performance of an algorithm

First - a bit of an introduction. If you're only interested in the code, you can skip this section. The following question is drawn from Dennis E. Shasha's Puzzling Adventures, and is listed under ...
7
votes
6answers
621 views

Manipulate and Turning Expressions into Functions

I've been trying to use Manipulate to do interactive plotting, but I've been running into a few problems with saved expressions. I have an expression saved as "func" and I want to work with it and ...
2
votes
1answer
523 views

How to export/import function values [duplicate]

I have a function with two variables: f[x_,y_]:=f[x,y] = ... I calculated some values (they are fractions like 435345345/3424242424) and would like to store the ...
5
votes
2answers
463 views

How to declare a function of variable?

In my program, there are many functions relying on spatial coordinates: x, y, and z, which are also functions of time t, i.e., composite function. I need to differentiate some functions for example f: ...
7
votes
2answers
130 views

Method that can be used to collect the variables of a function

Suppose we have a function f[x, y, z] and we want to get all its variables Sequence[x,y,z], what method can we use then? The ...
8
votes
2answers
189 views

How do I write a function that can be used in a rule to modify both sides of an equation? [duplicate]

I sometimes need fine grain control over equations in Mathematica in order to help me understand how to solve a problem manually. A greatly simplified example of a session might be something like ...
6
votes
4answers
463 views

Function argument to default under certain condition

Inspired by this and this question (and how I handle this in practice), what is the best way to default a function value when a certain condition is met? For example, if a function is defined as: ...
2
votes
1answer
133 views

Plot[] breaks behavior of custom data handling function - Recursion

I am working on a utility to analyze a set of data. I want to process the data with a sliding window, in such a way that there is an output associated with each sample of data. To start, I have a ...
8
votes
1answer
468 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 ...
2
votes
0answers
80 views
2
votes
1answer
134 views

How can I calculate a limit with a free variable?

For example, when I evaluate Limit[(1 + x^n + (x^2/2)^n)^(1/n), n -> Infinity] Mathematica does not output any result. When I evaluate ...
3
votes
1answer
216 views

Help on how to write a function to be used with NMinimize

I need some help to write a proper function to be used as a parameter on NMinimize. Here is the code of the function to be minimized (Please correct, optimize and rewrite the code if you want to - I ...
7
votes
3answers
498 views

FullSimplify does not work on this expression with no unknowns

I can't reproduce this simple example from Habrat, 2010 ("Mathematica : a Problem-Centered Approach"). It is supposed to demonstrate the functionality of ...
8
votes
2answers
249 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 ...
0
votes
1answer
1k views

Given x[u,v], y[u,v], and f[x,y] how do I find D[f,x] in terms of u,v?

I have two functions x = x(u,v) and y = y(u,v). The chain rule says that for a function f(x,y), df/dx = df/du du/dx + df/dv dv/dx, and similarly df/dy = df/du du/dy + df/dv dv/dy. How do I get ...
10
votes
2answers
287 views

Functions that remember their values

Can someone explain what is going on with the following ... func[y_] := func[y] = (Print["Hello world !!!"];) func[1] Hello world !!! ...
3
votes
0answers
120 views

What is the difference between Block and Module? [duplicate]

Possible Duplicate: What are the use cases for different scoping constructs? I don't understand the difference between the Matheamtica functions Block ...
3
votes
1answer
161 views

Efficiently finding the maximum value of a column in a matrix

Imagine I have a matrix of the following form: TestArray = $((a_1,b_1,...),(a_2,b_2,...),(a_3,b_3,...),...)$, where a specific example might be: TestArray = ...
2
votes
1answer
150 views

writing a function using multiple variables

I am fairly new to Mathematica and am trying to write a function for the equation: xx = [x/(Sqrt[h^2 + d^2 + y^2]))*(Sqrt[h^2 + (d + yy)^2]) where h, d are known ...
25
votes
2answers
753 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 ...
20
votes
1answer
381 views

What is PointForm?

I stumbled across a function called PointForm but the only documentation I can find is the pop-up line offered by autocomplete, which contains the same information ...
11
votes
1answer
272 views

Overloading second argument of CountryData

For convenience I'm trying to add an extra property to CountryData ...
6
votes
1answer
156 views

FunctionTreeForm

I'd like to implement a function FunctionTreeForm which takes an arbitrary complex function and renders all the captionable subfunctions in a TreeForm. Explanation If we take e.g. a function: ...
2
votes
1answer
150 views

Representation of product with exclusions

Is there a nice way to define output formatting for my expression, a product from n = k to j with ...
7
votes
2answers
1k views

How to study asymptotic behavior, built-in functions

My question is as follows. Suppose we have a function $f(r)$ and we want to study its asymptotic behavior at infinity ($r\rightarrow \infty$). For example, the function may reduce to $-\frac{a}{r}$ or ...
2
votes
1answer
150 views

Mathematica crashes after evaluating a call to a user-defined function [closed]

I have recently installed Mathematica 9 on my macbook pro, os version 10.6.8. As you can see in the minimal example notebook you can download here: ...
1
vote
1answer
307 views

Plotting Fresnel function

I am trying to plot the partial sums and the cesaro means of the function $\sqrt{|x|}$ and for $a_{n}$, I obtained the following code which contains FresnelS. ...
7
votes
4answers
321 views

Is there a concise form of Which or similar conditional?

Suppose that I want to write a function fun that takes an Integer num as input, and returns ...
11
votes
4answers
2k 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? ...
1
vote
1answer
137 views

need help with finding right syntax for an IF statement

I am working with two multi-variable functions A and B. They depend on some counting factors ...
11
votes
4answers
865 views

Pure Functions with Lists as arguments

Assuming I have two function: example 1: add[{x_, y_, z_}] := x + y - z add[{1, 3, 5}] If use pure function,I know I can write it as : ...
-1
votes
1answer
169 views

Some Problem with WhenEvent!

Anyone knows what's the problem with the following code and how can I fix it? I am not sure that I wrote the WhenEvent section correctly. By the way, I want to solve the equations and then plot y vs. ...
0
votes
2answers
123 views

How to obtain a smaller-sized output from Solve

I am solving a system of 15 simultaneous linear equations using Solve. On running the code, I get a message saying "A very large output was generated" with options ...
0
votes
1answer
123 views

Why am I not getting Indeterminate for f[1] when f[x_] = (x - 1)/(x - 1)? [closed]

In Mathematica 9 If I write: f[x_] = (x - 1)/(x - 1) I get 1 And if then I write: ...