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

learn more… | top users | synonyms

3
votes
0answers
114 views

What is the difference between Block and Module? [duplicate]

Possible Duplicate: What are the use cases for different scoping constructs? I don't understand the difference between the Matheamtica functions Block ...
4
votes
4answers
252 views

How can I get the number of slots in Function?

Suppose that I define f = Function[#1 + #2]; And I want to define a new function, argsNum, so that it returns a number of ...
2
votes
3answers
79 views

Problem with InverseFunction of Sqrt

I want to build a table of InverseFunctions, f.e.: ...
0
votes
1answer
58 views

Problem with Maximize

As $\{p1,p2,p3,p4,p5\}$ represents a probability distribution and $l1,l2$ are the eigenvalues of a stochastic matrix, the function $f$, as defined below, has to be maximized over a certain region. ...
2
votes
1answer
80 views

How to generate specific function using BSpline command/

I want to generate an approximation function that fits a curve to points. My goal is to obtain an actual formula. Is this possible with the BSpline function? Using the following code: ...
4
votes
3answers
196 views
0
votes
1answer
28 views
1
vote
1answer
102 views

Solving a trigonometric equation with one parameter

I have the following equation: 2 a^2 k^2 Sin[b k] - 6 a (k Cos[b k] - Sin[b k]/b) == 0 I set the value of b to 1, and I want ...
10
votes
5answers
290 views

How to prevent function from passing values to slot

For the following example: {#, #} & /@ {1, 2} I am trying to find a method to hold one of the slots (or both ) so that the function do not pass the values to ...
4
votes
1answer
198 views

Use of Strassen's algorithm

Strassen's algorithm is an algorithm for matrix multiplication that is asymptotically faster than the naive one. In practice, the matrices involved have to be quite large before Strassen's algorithm ...
0
votes
2answers
73 views

prime-palindromic number selected from a list

I want to find all prime-palindromic numbers up to 5000. Prime-palindromic numbers are numbers that themselves and their reverse digits are both primes. For example, 31 is a prime-palindromic number ...
-2
votes
4answers
165 views

Compare elements in a list

Assume that there are three different points in x-y coordinate like: p1={4, -1}; p2={5, -2}; p3={1, 5}; In order to compare these points to each other in a ...
2
votes
1answer
74 views

How to determine Fixed Point of a function? [closed]

A function is defined as f[x_]=Sqrt[1-x^2]. How can I determine the fixed point of f? I've tried this: ...
7
votes
2answers
120 views

Probable Bug in HighlightMesh with 2D Convex Hulls created via ConvexHullMesh

One nice way to view the new and exciting Mesh objects introduced in Version 10 is by utilizing the function HighlightMesh, so ...
0
votes
0answers
31 views

How can Mathematica solve 7 equations and want to find 7 variables [duplicate]

I have 7 equations as below * e1 := (1 - a) p Subscript[A, 0] Subscript[s, K ] ! *SubsuperscriptBox[(s), (L), (-a)] = (1 - b) Subscript[B, 0] (1 - Subscript[s, K]) (1 - Subscript[s, ...
1
vote
2answers
95 views

An argument pattern that my function can treat as Times[constant, variable]

I want to define a function of two variables, func[f_, g_], such that when it sees a general constant multiplying one of the variables, say ...
1
vote
0answers
124 views

Speeding Up Image Processing Functions

I am working with stacks of 1024x1024 timelapse microscopy images that I am performing a series of image processing functions on to help segment each image. These functions include ...
4
votes
1answer
70 views

How do I constrain variables to a user-defined domain in ArgMax?

I am trying to ArgMax a function over x, but x is only defined between ...
3
votes
2answers
335 views

Is there a function for nearest power of 2 in Mathematica like nextpow2 in MATLAB?

I am looking for something like nextpow2 in MATLAB like this: P = nextpow2(A) returns the exponents for the smallest powers of two that satisfy $2^P \geq\left|A\right|$.
3
votes
1answer
144 views

why Level does not sort output according to their levels

Consider this example: Level[a + f[x, y^n], {0, Infinity}] (*{a, x, y, n, y^n, f[x, y^n], a + f[x, y^n]}*) Why the output is sorted in this way. why not ...
32
votes
2answers
625 views

Why is the new PositionIndex horribly slow?

Disconcertingly I have discovered that the new (v10) PositionIndex is horribly slow. Using Szabolcs's clever GatherBy inversion ...
2
votes
1answer
64 views

About Compile Function

I have a function that take p as a parameter, p is a 2X3X3 list, ( a 2X3X3 list can like { {{2,3},{1,2.},{1,1.}}, {{2,3.},{1,2},{1,1}}, {{2,3},{1,2},{1,1}} } ) the function just as: ...
1
vote
1answer
114 views

Computational complexity of symbolic determinant

I'm using the Det function in Mathematica to compute the determinant of an $n\times n$ matrix $A$ with entries of the form $a+bt$ with $a,b$ integers and $t$ a variable, and I would like to know what ...
0
votes
0answers
67 views

Problems with NMinimize

I have written some functions that take a matrix and find its minimum inner product with a specific set of vectors ...
7
votes
1answer
243 views

Is there a list of Octave functions mapped to the related Mathematica one? [closed]

I am just wondering if there is a list of the related Mathematica functions that correspond to Octave functions. For example. ones(n) maps to ...
3
votes
1answer
75 views
0
votes
1answer
124 views

Plot3D unable to understand input function

I'm attempting to plot the Wigner Function of the Morse Oscillator defined as ...
0
votes
0answers
58 views

Trouble outputting Plot

I am trying to solve a system of ODEs and plot them with Manipulate but I keep getting blank outputs. Below is my code: ...
1
vote
1answer
72 views

Convolving data set with gaussian profile

I have a spectrum looking like List, and I want to convole it with a gaussian of the form PDF[NormalDistribution[μ, σ], x] (where σ also depends on x). The raw ...
4
votes
0answers
81 views

Make Mathematica show function template's arguments in different lines (i.e. in column) by default?

I feel a bit uncomfortable with Mathematica 10's layout. I mean, I'm impressed how powerful functional programming can be and so on, but it's me or those programs are often just a bunch of nested ...
0
votes
1answer
55 views
0
votes
0answers
53 views

deleteduplicates Delete elements of a list [duplicate]

I have a math problem about Mathematica, I am looking help from you. I hope that you could help me. The Math Problem: list= { {0,0,1},{1,0,0},{0,1,0} ,{1,2,3}}; ...
2
votes
3answers
106 views

Speeding Up Replacing of Labels in Large Matrix?

I am Mathematica novice and am trying to find a fast way to replace labels in some rather large matrices (512x512 or 1024x1024) that have resulted from segmenting images with WatershedComponents or ...
6
votes
1answer
145 views

Why is AllTrue much slower than VectorQ?

This seems to be a theme with V10, a new function dedicated to a specific task doesn't live up to expectation performance-wise. Mr. Wizard has already uncovered 2 such functions here and here. So how ...
19
votes
3answers
604 views

DeleteDuplicatesBy is not performing as I'd hoped. Am I missing something?

Déjà vu: a new-in-v10 function should provide a better solution to an old problem, but my enthusiasm is curbed when I run timings. This time the function is ...
5
votes
5answers
533 views

Prevent Part[] from trying to extract parts of symbolic expressions

If you have a list, e.g. {1, 2, 3} then you can extract the $k$th part using Part (...
29
votes
5answers
902 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 ...
1
vote
1answer
86 views

Using Map in a function definition

I want to calculate the hessian of a matrix. So each element gets replaced by a 2 by 2 matrix. ...
0
votes
0answers
51 views

Is it possible to calculate with declarations only?

simple Example: maximize $u(x), x$ solution would show constraints: $\frac{\partial u(x)}{\partial x} = 0$ $\frac{\partial^2 u(x)}{\partial x} < 0$ etc... or do I always have to explicitly ...
-1
votes
2answers
71 views

How to fix the “Module” function, for implicit funcitons? [closed]

I wanted to make a function which gives the frequencies of a number in a specific list, when I came accros this problem. This is what I tried: ...
10
votes
2answers
204 views

Why doesn't a Composition[] hold its arguments and what can be done about it?

Now that Composition (also RightComposition) has shorthand syntax I am more inclined to use it, however what I feel should be ...
11
votes
4answers
402 views

Plot the minimum of a list of functions

This is my first question on any stack-exchange site and I'm also very new to using Mathematica software so please excuse/correct me if I mess up. I would like to take a list of functions of a single ...
0
votes
0answers
82 views

How to be faster at making a frequency list of increasing steps

I want to find propabilities of having a sequence in a list, by using frequencies. The case is that you will bet on an increase when the last event had an increased and bet on derease when the last ...
0
votes
0answers
88 views

Timing: how make a program to work faster using built in functions and tables

I want to improve my code to make it working faster even for very large numbers. ...
1
vote
2answers
65 views

FindRoot: getting number of iteration [closed]

I'm using FindRoot to solve a nonlinear system. I'd like to see what FindRoot is doing while computation, something like the display option for Matlab fsolve. At the end of the day, I want the number ...
0
votes
1answer
108 views

Fixed Point Math in MMA

I am working with a library that needs input in a Fixed Point notation. I’d like to figure out a way to convert the floating point results into fixed point representation. The fixed point length is ...
1
vote
1answer
68 views

Bug in NDSolve (Mathematica 9.0.1)? [duplicate]

The following code performs many times the same identical operation, but the time it takes increases systematically. This seems to be a problem of Mathematica 9.0.1 and above. Mathematica 9.0.0 does ...
0
votes
1answer
47 views

Combining functions - is this a case for Piecewise?

I have a function $Eb1$ which was the subject of a question I asked recently - you can see it here on stack exchange. Now, in that example it's specified between a boundary $r_n$ and $r_o$ where $r_o ...
0
votes
1answer
76 views

How can I represent this automorphism of Q(i,a)?

Let $a$ represent some real irrational number. I am trying to perform computations with an automorphism $f:\mathbb{Q}(i,a)\to\mathbb{Q}(i,a)$ which fixes $\mathbb{Q}(i)$ pointwise and maps $a$ to $i ...
3
votes
2answers
78 views

Function pattern to support listed and non-listed arguments

I often want to write functions that take as an argument either a) a rule or b) a list of rules. As an example, when using Replace with just one rule, it does not ...