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

learn more… | top users | synonyms

0
votes
1answer
220 views

How to combine two usages of # into one and speed up the code?

I have a function num with two variables, matf and matg. How can I combine the last two lines of code below into one? The code is aimed to find out the maxiaml count bel when we give each $i3 = ...
0
votes
4answers
63 views

Don't understand why Do-loop index is not evaluated in Play expression

So here is some weird behavior: When I create a list inside a loop whose elements are Play functions, with arguments that depend on the counter, it is as if the counter is being stored symbolically, ...
1
vote
1answer
207 views

function returning 0

Why is my function returning 0? ...
1
vote
1answer
88 views

Issues with creating functions [duplicate]

Sometimes when I try to create a function inside a function, Mathematica gives me a hard time. I usually just have to play around with the syntax until it gets something it "likes" but I really have ...
5
votes
2answers
883 views

How to find the non-differentiable point(s) of a given continuous function?

For example, the non-differentiable point of the function $f(x)=|x|$ is at $x=0$. How to find the non-differentiable points of a continuous function that is defined numerically?
0
votes
1answer
1k views

Given x[u,v], y[u,v], and f[x,y] how do I find D[f,x] in terms of u,v?

I have two functions x = x(u,v) and y = y(u,v). The chain rule says that for a function f(x,y), df/dx = df/du du/dx + df/dv dv/dx, and similarly df/dy = df/du du/dy + df/dv dv/dy. How do I get ...
14
votes
5answers
2k views

sprintf() or close equivalent, or re-implementation?

Is there a sprintf() command (some command that takes a printf-style format string and a list of values to insert into the ...
3
votes
1answer
77 views

What is the syntax to combine conditions and options? [duplicate]

How can a condition and an option be written on the RHS of a function? I.e. ...
8
votes
3answers
426 views

Create sine function with random increase in phase

I am trying to simulate a signal that randomly increases its phase, so far I have tried two thing but neither worked. I usually use matlab but I want to learn some Mathematica so I thought I would try ...
0
votes
2answers
114 views

Summation limits [closed]

The Sum is a built-in function in Mathematica, so the summation limits must be assigned. What I need to know is how to use a value computed in a separate ...
4
votes
1answer
226 views

Creating a function to simplify WolframAlpha query

When I can't remember an integral I usually just query wolfram and have it show steps. This was my naive attempt at trying to make a simpler function. ...
3
votes
2answers
949 views
3
votes
0answers
93 views

Gather dependency on list order?

I get intrigued about Gather behavior on this post. I thought that Gather was invariant under list order? Here is the result I ...
2
votes
1answer
106 views

How to define a function of z[bar], etc

Using Displaying index as subscript on output: e.g. C[i] -> C_i with Notation[...] or Interpretation[..]? I have often ended up wanting to define functions of annotated variables to better match my ...
5
votes
1answer
160 views

Why does MapIndexed return the index in a list?

MapIndex returns the index in a list instead of as shown in my revised example. I can work with it (or work around it), but what's the design concept? It seems ...
47
votes
2answers
4k views

What is the difference between Reduce and Solve?

Solve and Reduce both can be used for solving equations. Just by working with them, I know there are some differences between ...
4
votes
1answer
141 views

How hide symbolic definition of a function?

How can the actual definition of a function be hidden from a user? I want the user of a notebook to be able to evaluate a real-valued function f of a real variable at any particular numeric input yet ...
2
votes
1answer
264 views

Call Functions From File Without Modifying Context (Sandbox)

Let's say I have file named test.m containing test[arg1_] := ( Print[arg1];) What is the best technique for calling test like ...
4
votes
4answers
355 views

How to find the maximum of a function on a set of discrete points?

How to find the maximum of a function on a set of discrete points? For example, what is the best way to find the maximum of ...
4
votes
1answer
232 views

Simplifying polynomials in non-commutative variables

I would like to be able to simplify a polynomial in two non commuting variables, the desired result being that in every term one variable occurs to the left of the other variable. An example would be ...
6
votes
2answers
460 views

Obtaining the name of a variable as a string [duplicate]

Suppose that I have an arbitrary variable myVariable. Is there some function fun -- either built-in or one that I can define -- ...
0
votes
1answer
116 views

Nested function problem [closed]

I have trouble defining the following function in Mathematica sp[M_, u_] := 1/Sum[u^k M!/(M - k)!, {k, 0, M}] After defining it Mathematica displays an error. ...
15
votes
8answers
396 views

Is it possible to use RandomChoice to choose without other choices being evaluated?

I'm trying to do this: i1 = 1; i2 = 1; RandomChoice[{ (i1 = i1 + 1), (i1 = i1 - 1), (i2 = i1 + 1), (i2 = i2 - 1)}] In order to chose randomly which ...
0
votes
2answers
159 views

Inverse function

What probably could be the inverse of following function? ...
0
votes
2answers
244 views

Apply a function to a matrix of vectors [closed]

I have a matrix containing on each position a pair of numbers $(a,b)$. I would like to compute the norm of each vector $(a,b)$ and keep the result in form of a matrix. So basically, I need to apply ...
2
votes
1answer
108 views

Why the EuclideanDistance of these 2 exact points generates the warning N::meprec?

The two points are: pts = {{1/4 (-1 - Sqrt[5]), Sqrt[5/8 - Sqrt[5]/8]}, {1/4 (-1 - Sqrt[5]), -Sqrt[5/8 - Sqrt[5]/8]}}; EuclideanDistance @@ pts ...
2
votes
2answers
85 views

How to make a function work on symbols in a specific context

Let us say we have two sets of symbols $(x, y, z)$ with the same names that live in two different contexts: ...
1
vote
1answer
318 views

Finding n-th term of a sequence of functions

Lets say, I have the following series of functions, $f_1=a+1$ $f_2=a^2+2a+1$ $f_3=a^3+3a^2+3a+1$ Assume that $f_4, f_5,$ and $f_6$ are also known. However $f_n$ is not known as a function of $n$. ...
3
votes
3answers
232 views

How to find the numbers $a$, $b$, $c$, $d$ of the function?

I want to find four numbers $a$, $b$, $c$, $d$ of the function $f(x)= \dfrac{a x + b}{c x + d}$ satisfying the conditions $f(-6)=4$, $f(-5)=5$, $f(1)=3$ and $f(2)=2$. I tried ...
2
votes
2answers
233 views

Writing a function that returns a (usable) function

I am trying to create a function that returns Arnold's Cat Map of size n iterated k times. I can get something out of the Function command, but I can't figure out ...
19
votes
1answer
193 views

How to get Cases to wrap results in an arbitrary head?

A number of functions provide for results to be wrapped in an arbitrary head. This is very important in cases where the results should not be evaluated. Take ...
0
votes
0answers
48 views

Phase Unwrap List Of Points: Implementing continuous phase/Arg function for List of Points [duplicate]

I am looking for a function to unwrap phase of a list of points as done here for the continuous case. I have the Re/Im data as my input and would like the unwrapped phase as the output. Does anyone ...
10
votes
5answers
502 views

How to find first list element that differs from average of N previous elements by more than a given amount?

Given a list of real numbers, I need to write a function that returns the value of the first element in the list that differs from the mean of the previous $N$ elements by greater than $P$ standard ...
3
votes
1answer
259 views

NestList with a list inside?

I'm new to Mathematica, and was looking for more efficient ways to implement the Do loop below. a, ...
6
votes
2answers
218 views

Not FullDefinition for Save. MachineID not Protected?

Is there a way to set what symbols's definitions I do not want to store? Consider the following code: ...
1
vote
1answer
113 views

User-defined Distance Functions with extra parameters [duplicate]

The Nearest function accepts a customized distance function. For example, a simple case that works well is ...
1
vote
1answer
73 views
1
vote
1answer
199 views

Map a function conditional on elements at multiple relative positions in a list

I figure this question has many solutions, and if an answer already exists it would be nice just to be referred to it. I need a function that 'maps' over my list and produces a list of equal length ...
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, ...
4
votes
5answers
327 views

How to generalize and speed up this program?

There is a vector whose length is $n*m$, we can part it into $n$ sections in order. I want to define a function to compare the $i$-th and $i+1$-th section and find the minimum. The program for $n=m=3$ ...
0
votes
1answer
62 views

Errors in evalauting an expression

I have the following: Constants: b3b = 2; G = (1/eps^2); a1 = 3; a3 = 4; xc = 0.3; Functions: ...
7
votes
3answers
199 views

How can I break through Function's HoldAll attribute to force evaluation of a body element?

The question concerns creating a function. Let consider the following code With[{f = Function[t, Cos[t]]}, {First[#], f'[#]} & ] which returns ...
1
vote
1answer
173 views

BSplinefunction and its derivative

Hi I am trying to use curve fit some data using the BSplinefunction. I havent been using Mathematica long, so my questions might be quite basic. ...
2
votes
1answer
200 views

How to compute a discrete histogram of a list [duplicate]

I'm trying to compute the discrete histogram of a set of values. By histogram I mean the absolute frequency a value appears on the dataset, by discrete I mean the values are from a discrete set, e.g. ...
0
votes
1answer
136 views

Understanding output of multivariable integration

I'm new to Mathematica and I'm trying to integrate this function: ...
0
votes
1answer
80 views

Scope of expression in a user-defined function

I have the following code: fbasic = A + R + Z*Z *Z*Z; f[A_, Z_, R_] := fbasic + R; f[0, 2, 3] The answer I am getting is ...
1
vote
1answer
91 views

Techniques To AutoReplace Browse

Let's say I have a function of the form. Test[File_,text_] What would be the most automated way and flexible way to generate an input cell of the form, such ...
4
votes
4answers
221 views

How to avoid writing $K$ loops?

I want to evaluate a mathematical function of $K$ variables each of variables varying between 1:N. One way to do this is writing $K$ loops and varying variables accordingly, as shown below: ...