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

learn more… | top users | synonyms

1
vote
1answer
90 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
162 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
217 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
254 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: ...
0
votes
1answer
333 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: ...
3
votes
1answer
270 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 ...
2
votes
1answer
705 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 ...
6
votes
1answer
474 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 ...
2
votes
1answer
144 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}, ...
2
votes
1answer
322 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
242 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
246 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
745 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: ...
10
votes
2answers
898 views
4
votes
3answers
2k 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 ...
10
votes
1answer
649 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?
7
votes
0answers
178 views

What Method options does FindInstance accept?

While answering Trouble getting FindInstance to return multiple results for certain constraints it became clear that for this problem FindInstance would be better ...
4
votes
3answers
364 views
6
votes
2answers
287 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
551 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
366 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
260 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: ...
7
votes
3answers
307 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 ...
2
votes
1answer
270 views

About high dimensional integrals

I want to be able to do high dimensional integrals like, (..naively I wrote it as this..) ...
1
vote
2answers
146 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 ...
9
votes
3answers
371 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
173 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. ...
1
vote
2answers
82 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 ...
7
votes
1answer
439 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 \\ ...
3
votes
3answers
192 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: ...
3
votes
3answers
303 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 ...
4
votes
1answer
1k 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
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 ...
3
votes
2answers
285 views

Plotting two functions with dependent input function

I have defined a function: myJ2[n_] := 1/n* Total[RandomVariate[NormalDistribution[0, 1], n]^2] This is basically an approximation to the gaussian integral. I ...
3
votes
1answer
2k views

Nested If statements

When I do this: Apply[(If[#2 == what, "yay", If[#2 == whoops, "nay"]]) &, {-5, what}] I get: yay But when I do this: ...
3
votes
2answers
295 views

Handling Indeterminate Forms

I'm running a sum, the elements of which are calculated by calling functions that I wrote. The only issue is, I've implemented this pretty stupid solution where I have 4 or 5 (nested!) if statements ...
4
votes
1answer
248 views

How to organize and run functions?

I am very new to Mathematica. I thought I would try it out for my first assignment in my computer science class. Until now I have only used C-base languages including C#, Java, Objective-C, and ...
8
votes
1answer
301 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 ...
1
vote
1answer
165 views

Computing a logarithmic function

Possibly this is a very lame question for this site. There is a function $f(n)=-\ln(a*n); \space \Bbb Z \to \Bbb R$, and I want to define $a$ for pairs of values. For example: $f_1(n_1)=15; ...
4
votes
4answers
563 views

How to define and use a linear function

I have the following equation $T = -800n + 12000$. I know that this is a linear function and that the two points $(0, 12000)$ and $(15,0)$ lie on the line. When I have 2 other values of n between 0 ...
1
vote
2answers
340 views

Piecewise function with a function as argument

I want to define a piecewise function, which has two arguments, one of which is a function of the other's piecewise argument. I am giving an example ...
1
vote
2answers
135 views

How can define a set of nested parameters

I would like to know how I to define a function with a nested set of parameters (or whatever you would like to call it). For example, how would I get the following function ...
1
vote
1answer
151 views

Using an InputField to define a function to compose with a sequence

I am still trying to figure out Mathematica (started early August). I am trying to write a program that will accept an arbitrary function and an arbitrary sequence that can start at an arbitrary ...
5
votes
3answers
244 views

First evaluation fails

I am fairly new to Mathematica (version 7), so please bear with me... I have duplicated, in Mathematica, a program that I originally wrote in C (it generates OEIS sequence A191837). The problem is ...
17
votes
8answers
553 views

Applying And to lists of Booleans

I'd like to take {True,True,False} and {True,False,False} and apply And to get ...
13
votes
7answers
367 views

Get the first element after the first sequence of length N of consecutively increasing values

I'm looking for an efficient way of extracting the first element after the first sequence of N consecutive elements in which the values are increasing. If these are the data of a toy example: ...
8
votes
2answers
665 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 ...
1
vote
1answer
115 views

How to explain the results of the following integrals?

Why does the following program lead to different results of a21 and a211? ...
2
votes
3answers
348 views

How can `SquareWave` be used as the input in `OutputResponse`?

I'd like to compute the response of a TransferFunctionModel when driven by a SquareWave. Here's a simple example, ...