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

learn more… | top users | synonyms

4
votes
3answers
163 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
1answer
134 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 ...
3
votes
3answers
586 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 ...
23
votes
2answers
753 views

Block attributes of Equal

I answered “Equating matrices (or higher order tensors) element-wise” with: ...
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
264 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 ...
1
vote
0answers
29 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
414 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 ...
6
votes
4answers
408 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: ...
5
votes
2answers
426 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
184 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 ...
2
votes
1answer
132 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 ...
2
votes
1answer
128 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 ...
1
vote
1answer
248 views

How do I define functions in TraditionalForm?

I'd like to be able to define functions (at least simple ones that Mathematica can otherwise understand) using TraditionalForm; but this seems to require the use of ...
1
vote
2answers
211 views

While-Loop Linear Projection

I'm would like to do a linear progression for a recursive relation of a consumption function. Combining my program skills and my sparse knowledge of mathematica, I was thinking about doing it in a ...
7
votes
3answers
449 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 ...
10
votes
2answers
272 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 !!! ...
8
votes
2answers
238 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 ...
3
votes
0answers
97 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
138 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
148 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 ...
7
votes
2answers
264 views

What's the purpose of the Unique function?

As the title says: What's the purpose of Unique? I understand that it generates some unique symbol, but when and for what is it to be used? Are there applications ...
6
votes
1answer
154 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
140 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 ...
2
votes
1answer
147 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
287 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
319 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
1k 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
136 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
795 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
166 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. ...
1
vote
3answers
693 views

Variables Inside Functions Not Evaluating

x = 5*y function1[y_] := x function1[5] Am I wrong in thinking that function1[5] should equal 25? Instead this comes out. ...
0
votes
2answers
120 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
491 views

Evaluate multivariable function [closed]

I'm trying to use Mathematica to evaluate many values of $f(x,y) $, like $f(-\pi,\pi) $ for $$f(x,y) = \left( \frac{-1}{4}\sin \left( \frac{x-y}{2} \right)\sin y \right)\left( \frac{-5}{4}\sin ...
0
votes
1answer
121 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: ...
1
vote
1answer
152 views

Random sample with gap sizes

Lets say I have 101 instances of data with multiple attributes. In particular case, one attribute has 7 unique values. I want to get ...
9
votes
2answers
288 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 ...
12
votes
3answers
475 views

How to make the suggestion box appear?

When you type a function in Matlab, quickly a suggestion box comes up showing functions similar to the one you're typing. I thought that Mathematica didn't have this but one day, I typed half of a ...
6
votes
3answers
197 views

How to rename a built-in function?

I want a built-in function renamed without loss of any properties, I want the shorter name to appear in all results and to be recognized as input. Is it possible?
2
votes
1answer
1k views

Filtering Lists in Mathematica [duplicate]

Possible Duplicate: Select/Delete with Sublist elements? I need help in filtering long lists of x,y coordinates.Lets use the following list as an ...
-2
votes
1answer
186 views

How to pass arguments between functions

I have two Functions, f[] and g[]. f is passed some values ,say ...
4
votes
6answers
207 views

Filter list with different list in it

I have a list like: {{{4, 14}, 1}, {{4, 15}, 1}, {{4, 16}, 1}, {{4, 17}, 1}, {{4, 18}, 1}, {{4, 14}, 3}, {4,15}, {{4, 16}, 2},{4,18}} Now I want to ...
10
votes
1answer
303 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 ...
0
votes
1answer
1k views

Loops and subroutines [duplicate]

Possible Duplicate: Alternatives to procedural loops and iterating over lists in Mathematica I am new to Mathematica and not familiar with functional programming. In particular, I have no ...
0
votes
1answer
129 views

Solve 1-D function that has 2-D interpolating functions

I need some helps on NDSolve. Here are my equations: ...
4
votes
2answers
242 views

How can I use Max[] in a function that is passed a list not find the max of the list

For most functions in Mathematica, passing them a list will call the function on each element of the list. For example: ...
2
votes
1answer
133 views

Difference between function definitions [duplicate]

Possible Duplicate: Functions vs. patterns I thought about describing the context in which I faced this problem, but I figured it is general enough and clear enough to pose it as it is. ...
9
votes
1answer
221 views

Get the name of a symbol passed to a function

I'm trying to get the name of a symbol passed to a function with this: f[x_] := {SymbolName[x], x} SetAttributes[f, HoldFirst] x = 5; f[x] But ...