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

learn more… | top users | synonyms

11
votes
1answer
182 views

What's a good style for inheriting Options[] of built-in function?

Options[myPlot] = Options[Plot]; myPlot[args___] := ... When defining a "wrapper" function like the above, I'd like it to inherit the ...
2
votes
1answer
69 views
0
votes
0answers
60 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
votes
1answer
87 views

Should Read[] not close its Stream? [closed]

I read a record from a file. Read[file,Record]; It reads and opens a stream. Should Read not close its stream after ...
20
votes
3answers
397 views

Parentheses in pure functions: # & vs. ( # &)

I've been using Mathematica for years, and over time I have developed the habit of using: Select[data, (# == 1 &)] instead of ...
2
votes
2answers
139 views

Position function not always retuning an answer even with no apparent problems

I'm having some problems with Position. Sometimes it will give an empty list instead of the actual position of the element I am looking for when that element is ...
2
votes
3answers
115 views

Alternative to using global variables in functions?

Often times I find myself using unevaluated variables (i.e. they show up blue) as dummy variables in whatever I'm returning such that I can evaluate them as needed later on. A simple example is as ...
12
votes
3answers
221 views

Accessing list elements by name

First, a bit of a long introduction to my problem: I only have a few weeks of Mathematica experience. I am creating a mathematica application that calculates some material properties of steel based ...
16
votes
3answers
1k views

Plotting piecewise function with distinct colors in each section

I have a piecewise function that I would like to plot but I was wondering if it is possible that each part of the function that is plotted when its corresponding condition is true be plotted with a ...
8
votes
5answers
264 views

Building a continued fraction

I've completed a problem that involves approximating $e$ by a continued fraction: $$\frac{N_1}{D_1+\frac{N_2}{D_2+\frac{N_3}{\ddots+\frac{N_k}{D_k}}}}$$ with the $N_i$ being the list ...
11
votes
1answer
193 views

Is there a summary of answers Head[] can give?

Sometimes you need to check for the type of an expression. You use Head[data] to get answers. Some data: ...
2
votes
0answers
97 views

Is there documentation on the comparative performance of Mathematica functions?

Recently I have been solving some Project Euler problems. I find there are always several ways to do the same thing. For example, one could join two lists like this: ...
0
votes
1answer
62 views

how to generate functions with changing array size?

I want to write a function in Mathematica which has two inputs 'n' and 'd', and the output should be (in Latex notation) $$F(n,d) = \sum_{i[1],...,i[n] =0; i[1]+...+i[n]\leq d}^{d} C[i[1],...,i[n]] ...
1
vote
1answer
95 views

Define a color function using Piecewise

How can I define a ColorFunction for my ContourPlot using Piecewise? For example after ...
9
votes
2answers
152 views

How can I get the right hand side of a delayed expression?

Imagine there is a given function f, defined with SetDelayed, say f[x_] := Sin[x]^2 + Cos[x]^2. Is it possible to get rhs of ...
0
votes
2answers
165 views

Expansion in Basis Functions

I am trying to create an expansion of the form f[x,y]->Sum[Cn[x] y^n,{n,1,order}] To replace the function f by the ...
6
votes
3answers
162 views

Permanent minors

The function Minors yields the minors of a matrix. Is there a function that yields the permanent minors of a matrix?
2
votes
1answer
201 views

Calculating volume [closed]

I'm new in mathematica and I'm stucked on how I can get the volume of a solid created by the inequation: ...
0
votes
1answer
97 views

Solving a differential equation for a variable in a function

This may sound like a very trivial question, but I need to solve a differential equation as follows: ...
3
votes
2answers
240 views

What is the command to find function invariant?

What is the command to find function invariant? http://demonstrations.wolfram.com/AFunctionInvariantUnderAGroupOfTransformations/ what is algorithm it use to calculate this? Edit there is a book ...
0
votes
0answers
19 views

Define a Plot3D function with custom options [duplicate]

I am trying to define a Plot3D function with custom options, following (this previous SE question), but I'm running into a brick wall. I've narrowed the problem to the following 'toy' code: ...
4
votes
2answers
127 views

How to use ScientificForm in computation

Lets say I want to add 2 values : ...
0
votes
1answer
190 views

How can I define a Step-Wise function in Mathematica (Not using Heaviside Step Function)? [closed]

I need to define a function, which has very different behaviour in different regions. There are about 13 different regions. A sample of my function is the foloowing table: I want to define it as a ...
0
votes
0answers
66 views

Choosing the appropriate solution for the square root [closed]

My problem is the following: given the function myfunc[x_, a_]:= (a^3 - (a^2)^(3/2))/(x) the limit as x goes to 0 should be well defined and = 0. However, ...
1
vote
0answers
39 views

Confusing efficiency and evaluation when returning pure functions? [duplicate]

I have a function that takes some time to evaluate, that's meant to be a polynomial approximation to a function. The polynomial is defined by a list of coefficients, so I have the function ...
2
votes
1answer
138 views

Problem using the DifferentialEvolution method of NMinimize [closed]

I have a function of 20 parameters, which 3 of the parameters are my physical parameters, and the others are pull terms to fix the errors. The goal is finding the global minimum of this function, to ...
1
vote
2answers
62 views

Named patterns as function argument descriptors

I have a function timeToMinutes that takes a 24-hour time as a string argument (in digital clock format, e.g., "15:47") and converts it to the number of minutes ...
5
votes
4answers
192 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 (...
7
votes
3answers
245 views

Radon function result's repeatability

I want to get a Hough transform of some edged image. When I compare the same transformation on the same image I got different results. ...
0
votes
2answers
101 views

Self-defined function to transform row vector into column vector, where am I wrong? [closed]

I defined a function row2col[] to transform row into column, Where am I wrong? ...
3
votes
4answers
202 views

Extract function arguments

Is there a way to extract the arguments of a function? Consider the following example: I have this sum ...
2
votes
3answers
205 views

How make f[{x,y}] evaluate as f[x,y]?

I frequently encounter the situation where I have a function of two real variables defined, e.g.: f[x_, y_] := 9 - x^2 - y^2 But then I need to feed into ...
5
votes
2answers
176 views

Is there an $n^{\text{th}}$ root function in Mathematica?

Is there a way to find $\sqrt[n]{x}$ with Mathematica beside of x^(1/n) as this is something different, because this is not always the same $$(-1)^{\frac{2}{4}}=i ...
1
vote
1answer
149 views

Why does the first derivative of a piecewise continuous function turns out with discontinuities?

I have this piecewise continuous function which is also continuously differentiable over time : ...
20
votes
2answers
515 views

Strange ::usage behavior in v9

Note: This is fixed in 9.0.1. Something has gone wrong with usage in Mathematica 9. Would someone tell me how to fix it? I define a function ...
5
votes
1answer
91 views

Does pass-by-value affect the performance of function calls?

I only have a little coding experience in C, and I remember I was told that pass by reference is more efficient than pass by value since the parameters don't need to be copied. Since there is no pass ...
2
votes
0answers
137 views

Minimization in mathematica [closed]

I have recently had a strange problem with NMinimize. I have a very huge function with respect to 20 parameters. When I ...
4
votes
1answer
137 views

A Faster way to combine two Lists of different structures into one of a different structure [duplicate]

I have the following two lists (each containing over 500,000 elements). Here is a sample: ...
1
vote
3answers
166 views

How do I create a matrix of functions?

I'm trying to create a matrix in which the elements are functions of two variables, but I can't figure out how to do it. Is it possible? The only way I could figure out is to define the matrix in ...
15
votes
4answers
238 views

Enforcing correct variable bindings and avoiding renamings for conflicting variables in nested scoping constructs

Using global variables the following turns an "expression" into a Function: expr = 2 x; Function[x, Evaluate[expr]] Of course ...
2
votes
1answer
116 views

Expression for the real 7/3 power

I need an expression for the real 7/3 power of a real-valued function, i.e., a reformulation of f[x_] := g[x]^(7/3) that works for negative values of ...
6
votes
4answers
284 views

Replacing functions

Given an expresion 'e' in terms of a function 'f' and given another function 'g', how could I write a Module that replaces the function f to g in the expresion e and returns it? An example: ...
1
vote
1answer
99 views

Forcing evaluation of ArgMax

How to force evaluation of ArgMax before its output gets used in Solve? Background: I'm trying to solve for the Nash ...
50
votes
6answers
3k views

List of compilable functions

Is there somewhere a list on the functions that Compile can compile, or the cases in which a particular function can be compiled that I haven't found? I'd be glad ...
2
votes
1answer
98 views
1
vote
0answers
70 views

Solving for vector elements in a function to which the vectors are not passed explicitly

I want to define a function which takes in two integers (indicating the lengths of 2 vectors), and solves a simple set of expressions at a set of points to find all the values in both the vectors. so ...
1
vote
0answers
73 views

How can I obtain the function described by given set of central moments?

I want to investigate how my function P behaves with different probability functions rho as input variables. This means ...
1
vote
1answer
109 views

Speeding up code by avoiding repeated evaluation of a function

I want to speed up my code and I have two ideas, but I don't know how I can implement them. Here is a little part of my code, which I want to improve: ...
1
vote
1answer
102 views

Function definition and delayed assignment

I need to define the following function MyWavelet[n_]["PrimalLowpass", prec_ : MachinePrecision] := Table[(-1)^(j - 1) h[[2*n - j]], {j, 0, 2*n - 1}] which ...
9
votes
2answers
118 views

Function with custom Options and modified Options for built-in Symbols

I couldn't find a more descriptive title, but I guess an example will explain my problem. I set up some customized Grid function including some additional ...

1 2 3 4 5 7