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

learn more… | top users | synonyms

1
vote
2answers
218 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
534 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
303 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
260 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
1answer
186 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 ...
7
votes
2answers
280 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
159 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
156 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
151 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
346 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. ...
8
votes
4answers
324 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
141 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
905 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
170 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
952 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
127 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: ...
1
vote
1answer
160 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
315 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
520 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
223 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
2k 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
188 views

How to pass arguments between functions

I have two Functions, f[] and g[]. f is passed some values ,say ...
4
votes
6answers
219 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
444 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
132 views
4
votes
2answers
255 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
148 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
273 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 ...
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 ...
3
votes
1answer
137 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: ...
0
votes
2answers
111 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: ...
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
274 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
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: ...
3
votes
1answer
308 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
873 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
532 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
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}, ...
2
votes
1answer
412 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
252 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
272 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
843 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: ...
11
votes
2answers
976 views
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 ...