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

learn more… | top users | synonyms

2
votes
1answer
544 views

How to take the derivative w.r.t. an arbitrary function?

EDIT: The answer posted by @Jens works for built-in functions only. However I'm starting to wonder if this is related to my Mathematica install somehow. I have version 7. Here is an example in the ...
3
votes
2answers
1k views

Define a color function using Piecewise

How can I define a ColorFunction for my ContourPlot using Piecewise? For example after ...
1
vote
1answer
82 views

How can I transform parts of an Integer list to a String list

There is a sorted list of Integers. ilist = PadRight[Sort[ RandomSample[Range[1, 99999], 3], Less], 5] It should become string area codes like: ...
29
votes
3answers
646 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 ...
5
votes
2answers
161 views

How to check an algebraic number for membership in a list

I need to check an algebraic number for membership in a list of algebraic numbers. The numbers can be expressed in different forms (combinations of radicals, Root ...
1
vote
0answers
24 views

valuation to a function using a list [duplicate]

What I want to do is to evaluate a function as shown below: LessQ[n_] := LessQ[n] = l[n] < 61 In some cases, when I am sure that on a list the ...
10
votes
5answers
715 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 ...
2
votes
1answer
122 views

making a function of fit results

I have 13*25 datasets consisting each of around 40 points. They are all linear I can easily fit them using fit function but my problem is when I want to call them I want them to be functions. I want ...
4
votes
1answer
238 views
-1
votes
2answers
264 views
3
votes
2answers
319 views

Why does the first derivative of a piecewise continuous function have discontinuities?

I have this piecewise continuous function which is also continuously differentiable over time : ...
1
vote
1answer
162 views

Derivative inside a function

I am trying a problem that should be simple: to create a function that contains a derivative. I need to do a more complex example, but even with the simplest I'm having trouble: Let's consider ...
7
votes
2answers
135 views

How do I invoke the default complexity function?

Documentation on ComplexityFunction says: With the default setting ComplexityFunction->Automatic, forms are ranked ...
6
votes
3answers
280 views

How to get the correct answer when solve this equation?

I want to find the values of the parameter $m$ to the graph of the funtion $$x^4 - 2 m x^2 + m + 1$$ has three extremal points make an equilateral triangle. I tried ...
1
vote
1answer
145 views

Recursive function taking functions as arguments

I'm trying to implement Lie brackets and derivatives of nth order. For doing this, I've stumbled upon something I don't understand. Here is an illustration: First I define the functions: ...
9
votes
1answer
337 views

Is it possible to find a limit of a sequence given by its recurrence relation?

I need to calculate a limit of a sequence given by its recurrence relation. I tried the following: ...
7
votes
2answers
134 views

Change some option of a function when calling it [duplicate]

Say I have defined some function like f[p_] := Plot[Sin[p*x], {x, 0, 2 Pi}] Now in most cases, I just need to specify the value of ...
1
vote
1answer
148 views

Find a sequence of integers which give max in each step

I would like to write a program in Mathematica to look for the integer $n$ such that the following definition holds for any $1 < m < n $ $$\frac{f(n)}{f(m)}>1+\frac{\log(n/m)}{\log(n) ...
-1
votes
1answer
226 views

How to define a pure function with a Module?

I was not able to use a self defined (using Module and For loops) piecewise function to fit data. It seems that the problem is that I have to define a pure function. I would like to learn how to ...
4
votes
1answer
304 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: ...
16
votes
2answers
922 views

Sum or Product with Exclusions

Is there a built-in feature for handling things like: $$\sum_{i=0}_{i\ne j}^n\frac{a-a_i}{a_i-a_j}$$ and $$\prod_{i=0}_{i\ne j}^n\frac{a-a_i}{a_i-a_j}$$ or should I work out some sort of ...
2
votes
4answers
788 views

How can I create a list of functions?

Can anyone tell me, how to create a list of functions? I've tried the following code, but it doesn't work. ...
35
votes
2answers
4k views

What is so special about Prime?

When we try to evaluate Prime on big numbers (e.g. 10^13) we encounter the following issue : ...
23
votes
1answer
224 views

What does Internal`InheritedBlock do?

What does the function Internal`InheritedBlock do? How is it different from the regular Block?
0
votes
1answer
62 views

Have the kernel load a user-defined function by default [duplicate]

I wrote a very simple function that I would like to act as if it were one of the default functions that came with Mathematica, so that you don't have to load or import any package before you make use ...
6
votes
1answer
109 views

create function that behaves like continuedFraction [duplicate]

I'm just starting to learn Mathematica and I got stuck at this question. This a noob question but please help. I need to define a function named continuedFraction that takes user input of type list ...
3
votes
2answers
645 views

Function returning Null along with other unexpected expressions

When I use some function, at the end along with the output I get some NULLs returned that I don't understand the reason for and are highly undesirable. For example, when I define the reversal of list ...
1
vote
0answers
83 views

Does Graphics`Mesh`SimplePolygonQ[] work for you?

Graphics`Mesh`SimplePolygonQ is an undocumented function. I'm using Mathematica 7, and when I try: ...
0
votes
1answer
77 views

What does Binomial return for non-integer arguments?

Mathematica returns values for non-integer arguments passed to Binomial. What is the definition of Binomial for such continuous ...
2
votes
1answer
114 views

Flat function with repeated sequence

There are functions like Join[ ] that accept a variable number of arguments. Join is a flat function, as the order of arguments ...
16
votes
4answers
5k views

Finding Limits in several variables

Is there a way to find a limit of a multivariable function, like $$\lim_{(x,y)\to (0,0)} f(x,y)$$ with Mathematica? When $f$ is continuous, we can use $$\lim_{(x,y)\to (0,0)} ...
9
votes
1answer
162 views

Creating a NearestFunction that returns an index

I use Nearest repeatedly for large data sets. For example pts = RandomReal[{-1, 1}, {1000, 3}]; Nearest[pts, {0, 0, 0}] I ...
3
votes
0answers
148 views

Mathlink and multithreading

In order to make my computations faster I have developed a C/C++ application calling Mathematica kernel and performing many operations using Mathematica functions for equation solving. Now I want to ...
4
votes
2answers
336 views

Cannot call custom function loaded from script using C/C++ MathLink

I am using MathLink with C/C++ on a Unix system in order to call a Mathematica (version 9) function and get the result. The function I need to call is a personal function of mine ...
9
votes
1answer
218 views

Apply a Function Pairwise

I'm new to Mathematica I'd like to apply Mean pairwise to a list to achieve the following. ...
1
vote
1answer
151 views

How to send a function definition to MathLink from C/C++?

In this tutorial some MathLink concepts are introduced. At page 33 in the last lines the author is talking about sending to MathLink a function definition like ...
6
votes
1answer
112 views

How does `LongestCommonSubsequence` work?

When I recently came across this posting about LongestCommonSubsequence I was curious about how the function worked. ...
15
votes
2answers
238 views

What are Root objects with multiple polynomials?

In Mathematica 9 a new flavor of Root object with multiple polynomials was introduced. For example, ...
10
votes
1answer
128 views

How do I expand StirlingS2[n, 10] in terms of elementary functions?

I know that it is possible to expand StirlingS2[n, 10] in terms of elementary functions of n. I tried ...
13
votes
1answer
259 views
2
votes
1answer
132 views

Cannot run Mathematica C-interfacing examples 'factor'

I am trying to run a Mathematica example concerning Mathematica interfacing issues with C programs. In particular I am trying to call a Mathematica function from C. Example ...
2
votes
3answers
343 views

Use elements of Array inside function definition

I'm trying to define a function which modifies and sums over the elements of an array. Here is a very simplified version. myF[kmax_] = Sum[v[[k]]/k, {k, 1, kmax}] ...
0
votes
1answer
60 views

Don't pollute outside context when solving equation from the outside

This code works fine only if a is not defined in the outside context: ...
1
vote
2answers
95 views

Calling blank arguments using enclosing functions

Is there a way to call a function and have that function use an argument defined in an enclosing function? e.g., ...
11
votes
1answer
1k views

Write C/C++ programs calling Mathematica functions

I need to write a C/C++ program and call some functions in Mathematica especially those like Solve or NDSolve. The problem is ...
2
votes
2answers
588 views

distance between two curves

I try to compute the distance between two curves. I use the EuclideanDistance to do that. Here my code: ...
3
votes
2answers
467 views
3
votes
2answers
133 views

Generating a list of pure variables

I want to pass a list of pure variables to a function, in which the ordering of the variables matters. For instance, if I want a palindrome, my function might be: ...