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

learn more… | top users | synonyms

7
votes
3answers
483 views

Inverting a function in a certain region

InverseFunction works well for globally invertible functions, like f = 2*# + 2 &; InverseFunction[f] ...
2
votes
3answers
115 views

Creating a function as a table of derivations

Suppose I have function, which is in fact a list of $n$ functions with $n$ parameters f = {#1 + #2^2 + #3^3, #1^2 + #2^3 + #3^4, #1^3 + #2^4 + #3^5}& I want ...
0
votes
2answers
110 views

How to display output as symbols?

I have this piece of code which populates a matrix following different rules depending on row and column number: ...
3
votes
3answers
397 views

For-loop not working as I expect

I want to do this: When 10 <= t < 130, give t -> 1; When 130 <= t<300, give ...
4
votes
3answers
193 views

cross-correlation with time lag

I have two lists with some data. a={1,2,3,4,5} b={5,4,3,2,1} Now I want to compute the cross correlation of the two lists with a time lag of 1, like it is ...
0
votes
2answers
88 views

Handling output that was returned unevaluated from a function

When evaluating functions, including those described in this post, how do Mathematica users handle values returned from a function that are unevaluated? For example (based on 1): ...
0
votes
3answers
268 views

find connectivity

Imagine a chain of 20 rings, labeled by 1-20 sequentially. We want to make random size sets of numbers randomly chosen from these 1-20 rings. No duplicate numbers are allowed. Example of a set: ...
2
votes
3answers
314 views

Generate random points in a region with higher probability in a sub-region

I am trying to generate random samples of points in the unit square in such a way that points inside a given circle are twice as likely to be selected as points outside that circle. I tried to ...
0
votes
2answers
90 views

Define a function on a parameter argument set to zero

Say I have an expression (matrix) that depends on several variables. f= {{a, b+c},{2a-b^2,c^5+a b}} I want to define new matrices with the single parameter ...
1
vote
0answers
67 views

Distinction between 2 NETTypeInfo answers

In a NETLink application I checked all the types offered by LoadedNETTypes[] according to the following: ...
0
votes
4answers
153 views

Evaluate function from a table

I want to define list of functions and also use them for evaluation. But this just doesn't work. For example ...
2
votes
1answer
86 views

Declaration of variables in large Linear Programming model with NMaximize

I want to solve a large LP problem using NMaximize. This is a small instance of my bigger problem: $$max \sum^{4}_{t=1}(\sum^{4}_{c=1} V_{c}*f_{c,t})\\ s.t\quad ...
1
vote
1answer
124 views

How to properly substitute values into variables?

I have an array of functions in terms of a[0] through a[n] and I wish to replace the a[]'s with previously calculated values p[0] through p[n], as in below: ...
1
vote
1answer
113 views

Extract information from function definition returned by DefineDLLFunction

I have an application using DefineDLLFunction whose output is: Function[Null, If[NETLinkDLLPrivatecheckArgCount["DRV_AOVoltageOut", {##1},2], ...
8
votes
0answers
185 views

How is the mysterious Raw function used?

I have never seen an example use for the mysterious Raw function: Raw[h, "hexstring"] constructs a raw data object with head h, and with contents ...
1
vote
1answer
196 views

Detecting a nonlinear edge in a 2D point pattern

Following an earlier post here, I have generated a point pattern on the unit square $[0,1]\otimes[0,1]$, which is described by a piecewise constant intensity function constructed so that (in ...
0
votes
2answers
115 views

How to find intervals in the domain corresponding to intervals in the range?

I want to find the intervals for the argument m1 of this function corresponding to the value for the function lying in given intervals of the range: ...
2
votes
2answers
114 views

how to get a linearized curve in some intervals

in below picture I draw a graph base on weight of a controller system against cost function. I want to linearise and divide this curve to for example 5 five intervals. is there any function in ...
3
votes
1answer
102 views

Count the number of sqrt and 4th powers in a function

This is a simple and short question. I have a function which contains a certain number of square roots and 4th powers, lets take this one: ...
2
votes
2answers
157 views

ImageDifference. Is there an ImageSame, or how would one do that?

Is there an inverse to ImageDifference? What in two images are the same?
12
votes
4answers
1k views

Moving maximum function?

How can I construct a moving maximum function? For example, if I have a list of 12 values: { 5, 6, 9, 3, 2, 6, 7, 8, 1, 1, 4, 7 } and I want to maximize over 3 ...
0
votes
2answers
71 views
-1
votes
1answer
66 views

How to specify a specific range for a loop?

I'm having trouble with setting up a particular range in a loop for my programming. Now I have a defined range of data (not continuous numbers) that needs to be applied in a loop. Since the aim for my ...
0
votes
1answer
117 views

Loop function question [closed]

I'm new to Mathematica. Below is the code I have trouble with. ...
2
votes
4answers
208 views

Find time since last 0 in list

When I have a list of data (measured per day), is it possible to define a function that gives the nr of days since the data has been 0? I tried working with...
0
votes
1answer
64 views

Circumventing the default scoping: Assign a variable inside a function [duplicate]

I'm currently trying very hard to assign a variable inside a function. Therefore I'm using a function like this, which should reassign a predefined variable. ...
1
vote
1answer
138 views

FindMaximum inconsistency

The code below seems to work for n<11. But for n=11, and above, it outputs newa then just outputs "beep" sound. WhyTheBeep says "The kernel Local has quit ...
1
vote
1answer
174 views

Notebook UI: Autocompletion - Display function arguments when typing?

Is there a setting to display the required arguments of a function when typing as Visual Studio, Matlab, etc. does?
6
votes
1answer
109 views

Strange behaviour of Internal`InheritedBlock

I was going to post an answer for fast way to replace all zeros in the matrix. I was even quite happy because timings were the same order of magnitude as others. The idea was to overwrite ...
0
votes
0answers
50 views

Display functions without dependence?

I'm solving systems of equations with a few different functions of time, t, and so I'm getting output with lots of [t] running around. Is there a way to display these functions without the ...
1
vote
2answers
100 views

Add a column to a matrix as a function of the other columns

I was wondering if its possible to add a column to a matrix by a formula that uses all other columns, like this: ...
0
votes
2answers
113 views

Defining a function in terms of matrix elements

Currently trying to use elements from a matrix in defining a function however having some trouble. This is a somewhat simplified version of the problem. Say I have the matrix ...
0
votes
1answer
42 views

Showing result of derivative and other functions [closed]

I have a problem with my Mathematica 7.0 When I write: Derivative[x^2, x] Mathematica returns as result : ...
14
votes
2answers
677 views

Why do certain values in ArcSin not fully evaluate?

This is a continuation of: Why do certain fractional values in TriangleWave not evaluate? The analysis by R.M and rasher revealed that problem to reduce to the behavior of: ...
1
vote
1answer
100 views

Is linear interpolation applicable here

From my understanding about Linear Interpolation especially of that of Newton's Divided Difference Polynomial, we could get the value of F(x) from the given set of ...
0
votes
1answer
86 views

How to distinguish expression from zero [closed]

my question is the following. I have an array, which elements are functions (say, sines of symbolic arguments). Some of the elements are zeros. I want to write code like: ...
0
votes
0answers
20 views

Incorporating Built-In Function Options/Parameters into Shorthand [duplicate]

Shorthand syntax provides an alternate way to apply functions and, in many cases, improves readability. A simple example would be ...
0
votes
1answer
40 views

Extend a function defined for integers to a differentiable function of a real variable

Here is a function that calculates the probability of randomly landing on a Fibonacci number not greater than $n$: ...
7
votes
2answers
328 views

Can you apply the Cellular Automata function to a grid containing numbers?

Im attempting to simulate a simple evacuation model using cellular automata theory.My study aims to determine whether Cellular Automata can effectively represent how people would behave in a fire ...
3
votes
1answer
158 views

The UnitStep function and Intervals

For the input UnitStep[Interval[{-4, 5}]] I get Interval[{0, 1}] Why is this not ...
3
votes
0answers
45 views

Precedence of defined functions [duplicate]

When I define functions in Mathematica like: f[x_] := 3 f[x_Integer] := 6 How is the value of f[6] determined? It seems to ...
6
votes
5answers
277 views

Is it possible to insert arguments into functions when they're used like Function@ or //Function?

Is it possible to insert arguments into functions when they're used like Function@ or //Function? Sometimes I need to do this, but then I have to return to the standard function usage: Function[] ...
2
votes
4answers
177 views

Redefine ArcCot to be inverse of range [0, Pi]

Mathematica implements ArcCot function as an inverse to Cot on range [-Pi/2, Pi/2]. I ...
8
votes
2answers
239 views

Nest , Fold … is there an extension for more than 2 arguments?

Fold is an extension of Nest for 2 arguments. How does one extend this concept to multiple arguments. Here is a trivial example: ...
2
votes
1answer
92 views

Piecewise function with user-input interval

I would like define a function g[data,bins,x] which is a piecewise constant function taking value data[[i]] in the range ...
1
vote
2answers
100 views

How to sort Table/Matrix including legend(Labellings)

I want to sort table including its legend for graph I have table similar to M1 M2 M3 1 5 2 3 1 4 4 2 -10 5 7 11 6 -2 1 ...
6
votes
2answers
207 views

Why does PolynomialQ[x^n, x] return False?

From what I can see PolynomialQ will return False whenever some exponent is another variable such as here: ...
9
votes
4answers
239 views

Refering to global variables inside modules

How do I refer to global variables inside modules if the same name is used for a local one? In code, I want that ...
1
vote
3answers
137 views

professionalize/optimize my code that calls a function

I have the following construction, which defines a function that I subsequently call in a loop multiple times. I use this very often, but I have never looked into if there is a more professional way ...
6
votes
3answers
180 views

Understanding Function and Variable in Mathematica for beginner [closed]

I'm reading the book of Leonid Shifrin, and I love the way the book explains the core in Mathematica. As everything is an expression, now I understand that, there ...