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

learn more… | top users | synonyms

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 ...
3
votes
1answer
244 views

Evaluating a function on permutations of its arguments

Say I have a function "temp" of $n+1$ variables, $y,z1,z2,z3,...,zn$. I want to test if my function has certain symmetries like swapping $y$ with square of any $z$, swapping any two of the zs, ...
0
votes
1answer
132 views

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

I need some helps on NDSolve. Here are my equations: ...
2
votes
2answers
252 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
3answers
389 views

Use elements of Array inside function definition

I'm trying to define a function which modifies and sums over the elements of an array. Here is a very simplified version. myF[kmax_] = Sum[v[[k]]/k, {k, 1, kmax}] ...
10
votes
1answer
276 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 ...
2
votes
1answer
149 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. ...
1
vote
1answer
127 views

Can I get a trace of the complexity of a convergent sum?

Motivation--- I have a glimmer of an idea that a convergent sum could be considered a self-referential number similar to a fractal. I would like to play with it for a while. I have the following ...
6
votes
4answers
1k views

Replacing functions

Given an expresion 'e' in terms of a function 'f' and given another function 'g', how could I write a Module that replaces the function f to g in the expresion e and returns it? An example: ...
3
votes
1answer
138 views

Precise Timing for nested functions, how to? [duplicate]

Possible Duplicate: Profiling from Mathematica How can I easily get fractions of timing for each nested function? Consider a nested call like this: ...
1
vote
2answers
112 views

Saving variables from nested function

There has to be a simple solution for my question: I have three functions and each uses the output from the previous function as its input: ...
4
votes
3answers
606 views

Simplify function notation

I have some calculations with arbitrary functions. In the output, Mathematica always shows the functions with its arguments. I would like to tidy the notation a bit, by hiding the arguments in the ...
1
vote
1answer
93 views

Why function is evaluated backward?

I have a simple function: f[x0_,y0_]:= Module[{x=x0,y=y0},For[i=0,i<2,i++;Print[x],Print[x+y]];] So when I call it: ...
1
vote
1answer
167 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, ...
1
vote
1answer
233 views

Problem with function as an argument

I want to write a function like the following: s[u_, v_, x_, val_] := u[val]/NIntegrate[u'[x] v[x] + u'[x] v'[x], {x, 0, 1}] So I can evaluate something like ...
3
votes
2answers
275 views

Numerically finding a derivative jump of a function

How would I numerically find where a function has derivative jumps? In particular, I'm working with this function: ...
9
votes
4answers
737 views

Moving the location of the branch cut in Mathematica

According to the documentation, Mathematica chooses the branch cut for $\log(z)$ to lie along the negative real axis. It it possible to change this so that it lies along the positive axis or elsewhere ...
3
votes
1answer
309 views

Plot maximum and minimum temperature of a day for range of time interval

How to display (in any graphic representation) the maximum and minimum temperatures for one city in one of these selected time periods over the 5-day period? The time periods are: Morning (06:00 to ...
5
votes
5answers
638 views

Prevent Part[] from trying to extract parts of symbolic expressions

If you have a list, e.g. {1, 2, 3} then you can extract the $k$th part using Part (...
2
votes
1answer
884 views

How to define the Einstein summation convention in Mathematica?

How to define a Einstein summation convention in Mathematica? Say, how to let Mathematica know T[i,i] equals ...
2
votes
1answer
147 views

#[[1]]//FullForm = 1?

I have a set of symbolic algebraic expressions that I'm trying to get some speed into. To illustrate the issue, I'll use a simple form like { k0 X, k1 Y, k1 Z}, ...
1
vote
1answer
273 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 ...
9
votes
3answers
3k views

How can I differentiate Numerically?

Mathematica has two ways to integrate: Integrate and NIntegrate. But what about D? ...
2
votes
1answer
415 views

Cournot Equilibrium

I'm trying to determine reaction functions of a Cournot equilibrium for $n$ firms using the same optimal condition, using the fixed point method. This is the method I'm using: ...
0
votes
1answer
253 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 ...
6
votes
1answer
273 views

GeneralMiniMaxApproximation - Dividing out the zero

MiniMaxApproximation is used to generate minimax approximations. I'm interested in the "dividing out the zero" trick. The documentation discusses a nice example. Suppose we want to construct a ...
1
vote
2answers
848 views

Interpolating a function of two variables

I am trying to create the interpolating function for a function of two variables, over a finite area. Just for consistency we can think of a function: ...
4
votes
3answers
3k views

Passing a function as an argument of another function [duplicate]

Possible Duplicate: Pass function or formula as function parameter I am trying to implement a simple Plot[]-like function, with the same synopsis; my first (and unique so far) try would be ...
2
votes
5answers
405 views

How to leave function unevaluated programmatically?

Is it possible to write a function in such manner, that it can be either evaluated or left unevaluated? This is a general question. Sample below is just a sample. No need to find solution for this ...
6
votes
2answers
331 views

A command for outputting a list of parameter values in a Manipulate interface

I am looking for a command that will output a list of values that correspond to the current parameter values manually set on a particular Manipulate interface. For ...
4
votes
2answers
662 views

How to make a function that evaluates an expression?

I'm trying to make a function where the input is an expression, but somehow it just won't be evaluated. For example, this little function doesn't work: ...
2
votes
1answer
435 views

Plugging values into functions

I am very new to Mathematica, and need to know how to plug values into existing functions. For example, Math World supplies the following code for building a truth table of ...
2
votes
1answer
288 views

About high dimensional integrals

I want to be able to do high dimensional integrals like, (..naively I wrote it as this..) ...
4
votes
3answers
400 views

Generate a Combination of letters by a number

I'm trying to write a function f. example: ...
2
votes
1answer
324 views

Creating a matrix from the output of a variable inside a for loop

I would like to enter the results of the following loop inside a matrix as its elements: ...
1
vote
2answers
148 views

How to mix Unevaluated property of function arguments with expression assignments?

This is a follow-up to my (solved) question How to distribute a generic function of two arguments (without evaluating the arguments) Say, I have a binary function ...
11
votes
1answer
344 views

Better Autocompelete for the Front-End

I wonder if it is possible to improve the front-end's autocomplete capability. Compared with some other more sophisticated editors/IDEs, such as eclipse, Mathematica's front-end does not provide a ...
9
votes
3answers
412 views

Why does Hash return different values in Version 7?

This function does not work correctly for me. The generated Gravatars do not match the ones actually produced by using the corresponding address. The problem was traced to differing output from the ...
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 ...
4
votes
3answers
189 views

How to distribute a generic function of two arguments (without evaluating the arguments)

I guess there is an easy way to do this, but I can't seem to figure it out. What I would like to do is to distribute a generic (i.e. without specifying what this function really does) binary function. ...
0
votes
1answer
365 views

How to create function that classifies sample data

I want to create expression, that classifies samples ( 4 weather features -> decision). Example training data: For the values that i have data for, I can use rules: ...
4
votes
2answers
263 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: ...
1
vote
2answers
84 views

Using non-Graphics primitives when exporting to .cdf

I'm trying to embed a "Manipulate" applet I've created into a webpage by embedding a .cdf. I'm running into a problem with displaying outputs from functions I've written. Here is a simpler example ...
4
votes
3answers
998 views

How to prove an expression by method of mathematical induction?

I want to prove the expression $$1^2 + 2^2 + 3^2 + \cdots + n^2 = \dfrac{n(n+1)(2n+1)}{6}$$ by method of mathematical induction with Mathematica, but I do not know how to start. How do I tell ...
3
votes
3answers
379 views

How to pull scalars out of a function that should act on lists?

Suppose I have A = a vecA B = b vecB where a and b are supposed to be arbitrary scalars ...
3
votes
3answers
204 views

How to set a function as a parameter?

In case I want to know whether a given function $f(t)$ have some property, I tried to write something like this: ...
7
votes
1answer
477 views

Demonstrating Ackermann's Function

The Ackermann function is an extremely fast growing function. There are some slightly different versions of the function, but the one that I am looking for can be defined as: $$ A_0(x)=x+1 \\ ...
29
votes
3answers
664 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 ...
4
votes
1answer
2k views

How can I save and recall my own function?

In MATLAB, I can save and recall my own function using an M-File(function or script) How can I do something similar in Mathematica? I already searched and know how to define functions and modules ...
3
votes
3answers
3k 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 ...