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

learn more… | top users | synonyms

7
votes
4answers
242 views

How do I invoke the default complexity function?

Documentation on ComplexityFunction says: With the default setting ComplexityFunction->Automatic, forms are ranked ...
4
votes
0answers
85 views

Unexpected behavior from Indexed

I was going to include Indexed in this answer, thinking that it operated much as a List-only ...
1
vote
1answer
75 views

How to find the domain of an arbitrary function?

I got stuck here: fuu[x]:= 1/x +2x^2 Reduce[Exists[{x},fuu[x]],Reals] of course it doesn't work like this. How can i check if there will be divided by zero or if ...
5
votes
2answers
690 views

How to plot several functions without jumping? (multiple eigenvalues of a system as functions of 2 parameters)

I've been working on this research problem for months with some success by no global/proper solution to the problem. So I have square, Hermitian matrices of various sizes ($8,20,38$ dimensions) with ...
0
votes
0answers
42 views

Constructing a function for expanding general $n$ products

I have the following quantum mechanically motivated product: $\langle0\vert(A_1b_1 + A_2b_2 + A_3b_3)(B_1b_1 + B_2b_2 + B_3b_3)(C_1b_1 + C_2b_2 + C_3b_3)$, where $b_i$ is an annihilation operator ...
5
votes
1answer
74 views

Shadowing of optional function arguments?

I am trying to define two different packages that process some information in a different way. These packages have functions into them with optional arguments. The names of the optional arguments ...
1
vote
1answer
67 views

Transposing X and Y on a plot [duplicate]

This question has appeared in many forms online, but none directly apply to my problem. I have a quite complicated, albeit bijective function of the form ...
2
votes
0answers
43 views

Computing an inexact derivative with some terms preserved in exact form

I am beginning to learn Mathematica and have the following question: How can I return a derivative with exact numbers instead of one involving numerical approximations? My original, single variable ...
8
votes
3answers
539 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 ...
10
votes
3answers
538 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
69 views

understanding a mathematica equation

I have found the equation below written with Mathematica, I looked at the Mathematica online guide but it is still difficult to understand the equation. Can someone write this (or part of it) in ...
6
votes
4answers
2k views

Replacing functions

Given an expression expresion in terms of a function f and given another function g, how ...
1
vote
2answers
119 views

Expressions containing globally undefined symbols inside a function where they are defined

Consider the following code. f[a_,b_]:=x; Clear[a,b]; x=a+b; f[1,2] It returns a+b. However, from a certain viewpoint, one ...
2
votes
1answer
99 views

Missing zero in the CoefficientList

The following list has a length only 10 (not 11) CoefficientList[Series[ArcTan[x]/(1-x^2),{x,0,10}],x] {0, 1, 0, 2/3, 0, 13/15, 0, 76/105, 0, 263/315} It should ...
6
votes
4answers
8k views

Calling Correct Function for Plotting DiracDelta

I am wondering what is the correct function in Mathematica to plot the true impulse function, better known as the DiracDelta[] function. When using this inside of a ...
5
votes
3answers
116 views

Encapsulated plot function misbehaves

To insure a collection of plots has identical appearance, the plot command is encapsulated in a function. The results are undesirable. The fiducial plot is ...
3
votes
5answers
182 views

Converting multi variable expression into a function

So I have this rather complicated looking expression ...
1
vote
1answer
102 views

Defining Solutions to FindRoot a functions of parameters-Part II

Here's a similar question as the the preceding question with the same title, but this time with vectors, which I need to use. I followed the suggestion in the answer the the previous question, but it ...
10
votes
5answers
3k views

How to plot periodic function's graphic?

How to plot periodic function's graphic? For example, $f(t) = t$ when $-5<t<5$ and $f(t+10) = f(t)$. ...
14
votes
1answer
193 views

Major slowdown when using a ColorFunction with more than one named scheme

Problem remains in 10.1 Earlier Kuba noted a major slowdown with code Simon Woods posted. Here is a simplified example. First a color function using two different named gradient schemes: ...
3
votes
2answers
433 views

Using Functions as Arguments to Function

I am trying to make a function like Norm but defined like so: MyNorm[{x_,y_,z_}]=Sqrt[x^2+y^2+z^2]. Mathematica assumes that x, ...
0
votes
0answers
59 views

Which method to use for finding maximum without actually computing optimization function explicitly?

I am new to Mathematica and I am currently working on an optimization problem. The optimization function that I have easy to calculate for some assignment of variable but it is very difficult to ...
3
votes
1answer
176 views

I want to construct a function than the output is “Sequence”

For example if the input is x and x<10 the output is Sequence[x,0],if x>10 the output is Sequence[0,x] but obviously ...
17
votes
2answers
470 views

Using several anonymous functions mixed together

This works: list // BarChart[#[[2]], ChartLabels -> DateString @@@ #[[1]], ChartStyle -> "Pastel"] & This doesn't: ...
2
votes
1answer
94 views

How can I run a summation numerous times?

I have been working on code for finding the Allan plot of generated white noise, however, I cannot figure out a way to automate it for a different range of numbers. My code is as follows: ...
2
votes
0answers
46 views

Marginal distribution with weight

Given a multi-variate distribution $P(\mathbf{x},\mathbf{y})$, I would like to obtain the marginal distribution $$P_m(\mathbf{x})=\sum\int_{\mathbf{y}}P(\mathbf{x},\mathbf{y})W(\mathbf{y})$$ In my ...
18
votes
1answer
399 views

What are SparseArray Properties? How and when should they be used?

A strange undocumented form of SparseArray is increasingly used in answers on this site: ...
2
votes
3answers
804 views

Output of plots from within Do[ ] Command

I am wondering why the following does not plot the way it's written and exactly how does the Do[] function operate? I think I could be using it incorrectly. ...
4
votes
1answer
92 views

How to create fast functions based on units?

Using units is a good means for rapidly developing code, since it provides some error control. Hovewer, using Mathamatica functions containing units appears to be copmutationally inefficient. ...
0
votes
0answers
92 views

Polynomial interpolation using Neville's Algorithm

Is there an interpolating function in Mathematica which uses Neville's algorithm? I have written a C++ program to do interpolation using Neville's algorithm and I am getting a small difference ...
0
votes
0answers
36 views

Attributes of statistics functions

Do statistics functions have some kind of attribute which ignore non-number (Indeterminate, ComplexInfinity, calculation "errors") elements of a list?
20
votes
2answers
1k views

Scan vs. Map vs. Apply

I cannot understand the difference between Apply, Scan, and Map. I have tried to play with ...
8
votes
1answer
229 views

Prevent Export from overwriting files

Export["filepath1",Expression1] works for me, but if filepath1 already exists, it will be overwritten. I'd like ...
55
votes
4answers
3k views

Using a PatternTest versus a Condition for pattern matching

My last question to the site resulted in several answers that involve using pattern matching in Mathematica, a feature I wasn't very familiar with at the time. I am currently reading Mathematica ...
127
votes
7answers
5k views

What are the use cases for different scoping constructs?

Mathematica includes three functions that I know of which can be used to effectively (if not actually) define a variable and give it a value within a local scope: ...
33
votes
5answers
1k views

Why is there no PositionFunction in Mathematica?

Too often I have seen the programs of inexperienced users greatly slowed by using Position in an iterative fashion, when far faster would have been to compute a ...
16
votes
1answer
270 views

In 10.1.0 BenchmarkPlot doesn't work?

In Mathematica 10.1.0 BenchmarkPlot from the GeneralUtilities package doesn't work; copying Taliesin Beynon's initial use of the function on this site: ...
3
votes
3answers
147 views

truncated square wave input

I'm investigating the response of some dynamic system on Mathematica and I want to generate a tailored square input like the one in the following picture: Does anyone know how to generate such input ...
2
votes
1answer
71 views

Computing large nested values

Is it possible to compute a value for n=10^9; Nest[# + Log[#] &, 2., n] for large n? $10^9$ seems to be the max for me - ...
0
votes
2answers
84 views

Continuity of function-example

I'd like to examine the continuity of the following function: f[x_] := Limit[(n^x - n^(-x) ) / (n^x + n^(-x) ), n -> Infinity] I know that this function isn't ...
0
votes
3answers
110 views

beginner's question: change a parameter while get variable answers [duplicate]

I'm new to Mathematica from R, since R is not quite good at dealing with the following problem. Say, i want to solve the function a x - 10 = 0. Each time I change the value of a, say, from 1 to 10 by ...
18
votes
0answers
308 views

Performance problems in new Sequence functions

The new-in-10.1 Sequence* family of functions should provide newly optimized methods for handling sequence problems. Happily in some cases they do! For example ...
1
vote
2answers
94 views

Get the sum with cases

I have the following list: list = {{1, 2}, {2}, {3, 4, 1}, {5, 4}, {3, 3}, {a, b, c}, {e, f}, {g}, {}, {Sin[a], Cos[b]}}; I should use ...
5
votes
1answer
92 views

Handy dates conversion

I feel like something very basic is missing me, $dateformat = {"Year", "Month", "Day", "Hour"}; date = DateString[$dateformat] DateString["Date"] ...
6
votes
2answers
147 views

Using MovingMap to calculate percentage changes

MovingMap (new in version 10) applies a function to discrete data over a moving window. This is very convenient for calculating the percentage change of a series. ...
8
votes
2answers
268 views

What does IndexBy do and how exactly does it work?

I just saw the function IndexBy in the autocomplete suggestions and I was curious to know exactly how it works. Unfortunately, there's no trace of it in the ...
1
vote
1answer
83 views

How to construct a kernel from a function?

I would like to convolve an image with a mathematical function. I understand that I need to have the mathematical function in a matrix form. How can I build it? Thanks