Questions tagged [functions]

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

Filter by
Sorted by
Tagged with
14
votes
2answers
329 views

Custom operator form for system functions?

There are some functions for which an operator form would make sense but isn't implemented. For example, I'd like to make this work: RandomSample[3] @ Range[10] ...
14
votes
1answer
259 views

Choosing among different function definitions without sacrificing speed

I'm working on some code that numerically integrates a function, let's call it G, which calls another function, F, that can be ...
13
votes
11answers
2k views

Divide all but the maximal element in a list by 10?

I have a list of numerical data, and I want to write a program that will keep the maximum as it is, but reduce the rest by certain factor (such as 10). For example: ...
13
votes
9answers
5k views

Finding maximum or minimum of implicit functions

is there any built in function that can be used to find maximum or minimum of implicit functions? For example, if we have the equation $$x^2 + y^2 = (2 x^2 + 2 y^2 - x)^2,$$ then we can visualize the ...
13
votes
4answers
922 views

Assessing argument type in set delayed function definitions

I'm wondering how to properly assess the type of arguments passed to functions defined with :=. I want my functions to be the most efficient, unambiguous and clear ...
13
votes
4answers
2k views

Building a Noisy Function

Here's a nice function with a nice plot: f[t_] := Exp[-Abs[t]] Sin[t]; Plot[f[t], {t, -10, 10}, PlotRange -> All] What I would like to do is to make it noisy.....
13
votes
3answers
712 views

How to make the suggestion box appear?

When you type a function in Matlab, quickly a suggestion box comes up showing functions similar to the one you're typing. I thought that Mathematica didn't have this but one day, I typed half of a ...
13
votes
3answers
1k 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 <...
13
votes
3answers
850 views

Finding and visualization of branch cuts and branch points

Is it possible to determine branch cuts and branch points for complicated functions using mathematica Iam trying to determine the brnach cuts and branch points of this complicated function We have ...
13
votes
2answers
3k views

How do I find the elements in a list that return the highest value for a function?

Suppose we have a list of values and a function f. I want to find which of the elements maximizes the return value of the function in Mathematica. Let call the ...
13
votes
2answers
2k views

Which Mathematica function has the longest name (by character length?)

I came across DamerauLevenshteinDistance[u,v] in the documentation center so that got me thinking: Which documented Mathematica function has the longest name? ...
13
votes
1answer
710 views

What is the use of FullForm in Mathematica?

I would like to know where this "FullForm" in Mathematica will be useful. Kindly provide some examples. I just started learning Mathematica. If my question is wrong or not correct. I'm sorry about ...
13
votes
2answers
681 views

Remove versus ClearAll

What is the difference between Remove and ClearAll? I thought that "not being recognized by Mathematica", which is the effect ...
13
votes
3answers
8k views

“do … while” loop equivalent in Mathematica [closed]

Have I missed something or is there no built-in which mimics the behaviour of do ... while loop? I am looking for a construct that evaluates procedure once and ...
13
votes
1answer
24k views

Function that takes another function inside

Looking at this QA, I'm trying the following - 2 functions (r in vector format) using Theta { A, 2 } functions (sorry for the inconsistent names...). ...
13
votes
2answers
1k views

How to add an interpolating point to InterpolatingFunction?

Suppose I have an InterpolatingFunction object defined on $[\epsilon,1]$; let's call it f. What is the best way to construct a ...
13
votes
2answers
394 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 ...
13
votes
1answer
4k views

Using RegionFunction on multiple plots

I realize that the Plot function can plot multiple functions of x at the same time, using { }. I also know that the ...
13
votes
2answers
1k views

How to test if optional argument has been given?

I understand that the last call (f[1]) returns True because arg does not exist and thus <...
13
votes
1answer
1k views

Why is this 2D plot so slow?

I first do a 3D Plot of four surfaces (eigenvalues of a $4\times4$ matrix) over $kx,kz$ (setting $ky=0$ all along). And then I try to give a 2D plot along three connected particular lines in $kx,kz$-...
13
votes
6answers
4k 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 (...
13
votes
1answer
563 views

solve ODE with divergencies

The solutions of the second order differential equation $$\frac{1}{\eta}\frac{d}{d\eta}\left(\eta \frac{df}{d\eta}\right)+\left(1-\frac{s^2}{\eta^2}\right)f-f^3=0$$ is shown in Fig. 5.2 below, for ...
13
votes
1answer
446 views

How do I get a general form for n-th derivative of a function? [duplicate]

I tried the following but it basically returns unevaluated: ...
13
votes
1answer
651 views

Defining Tags in Reap

I am trying to use Sow/Reap to replace Append in my code. The problem is that I need to ...
13
votes
1answer
250 views

KeyDrop does not respect Key in V11

KeyDrop[<|a -> 1|>, Key[a]] <|a -> 1|> ...
12
votes
7answers
781 views

Getting the “root” Head

I have a dynamic list of function names, like {f1, f2, f3, ...}, and they will enter in computation in various forms ...
12
votes
8answers
2k views

Find the minimum integer r such that $(10^r - 1)/37$ is an integer

I know Element[(10^r - 1)/37, Integers] tests the condition. So what is the command that gives me the minimum integer value r ...
12
votes
13answers
1k views

How to find range in which a number falls, from given list of numbers?

How can one find the range in which a number falls, from given list of numbers? ...
12
votes
3answers
383 views

Does function call via @ ignore HoldFirst attribute?

I was trying to test whether using func[x,y] is the same as func[#,y]&@x: ...
12
votes
6answers
1k views

Generating Random Real numbers with certain numbers not included

I'm writing a program that i need 1000 real number between -3 and 6. the code that I used for generating and saving them was l = RandomReal[{-3, 6}, 1000] But I ...
12
votes
3answers
568 views

Why does MatrixFunction with Sinc return this error?

The following: mat = {{1., -3, -2}, {-1, 3, -2}, {0., 0., 0.}} MatrixFunction[Sinc, mat] returns: ...
12
votes
4answers
3k 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 ...
12
votes
3answers
561 views

Map a function of several arguments

I have three lists, e.g. list1 = {{a,b,...}}; list2 = {{1,2},{3,4},...}; list3 = {{x,y},{z,w},...}; and a function ...
12
votes
2answers
2k views

Growth of functions

Does somebody know if Mathematica can be used to calculate the growth of functions, that is in Big O, Theta, and Omega and find proper $n_{0}$ and $c_{1}$, $c_{2}$ respectively?
12
votes
2answers
963 views

Difference between Evaluation ► Quit Kernel and Quit[]

What is the difference between Evaluation ► Quit Kernel and Quit[]? Both seem to quit the kernel (and clearing all definitions)...
12
votes
2answers
450 views

Vertex descendants subgraph

Keywords: vertex, ancestors, descendants, subgraph, directed graph, flow subtree So let's say we have a TreeGraph: ...
12
votes
1answer
471 views

Overloading second argument of CountryData

For convenience I'm trying to add an extra property to CountryData ...
12
votes
2answers
306 views

Why isn't Lookup treated like other symbols?

With Mathematica 10, I wanted to overload Lookup using TagSetDelayed, but it doesn't work. For instance, if I define two objects ...
12
votes
1answer
485 views

Function as an option to a function

I am new to mathematica ,so this question may seem a little naive. I know how to use the option as an argument to a function, we can define an option by using ...
12
votes
1answer
502 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 ...
12
votes
1answer
289 views

Assumption on the range of a function

I'm using value-defined function as set of parameter, i.e. f[1] ===> first parameter f[2] ===> second parameter f[3] ===> third parameter etc. I would ...
12
votes
1answer
2k views

What is the difference between prefix/postfix notations and map?

I am new to Mathematica and just experimenting with the different programming constructs. I have been looking at Map and how to evaluate a function for a list of ...
12
votes
1answer
261 views

How useful is $EvaluationEnvironment?

Bug introduced in 10.0 and persisting through 11.3 A support case with the identification [CASE:3618534] was created. [...] I filed a report with our development team raising the issues [...] ...
11
votes
4answers
402 views

Is there a concise form of Which or similar conditional?

Suppose that I want to write a function fun that takes an Integer num as input, and returns <...
11
votes
5answers
12k views

How to sum over a List

list = {11.5575, 11.397, 5.52734, 4.0878, 2.54815, 1.86652, 2.55028, 2.14952, 1.6242, 1.34117} I have a list of numbers. How do I make a function that creates a ...
11
votes
5answers
477 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 ...
11
votes
4answers
656 views

Set of integers not divisible by smaller set of primes

Let $p_n$ be the sequence of prime numbers, and $s(x,n)=$ the set of integers less or equal than $x$ that are not divisible by $p_1,\dots,p_n.$ I can define it as follows: ...
11
votes
5answers
558 views

Transform a list of functions to a composition

How do I apply a list of functions in a nested way? Example: functionList = {f1,f2,f3} RequiredCommand[functionList,Pi] such that the required command returns ...
11
votes
5answers
738 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 ...
11
votes
3answers
788 views

Does Mathematica have Month Range and Day range?

It is known that CharacterRange["a", "z"] gives list of characters from a to z. Does Mathematica have something similar for weekdays and months of the year? ...

1 2 3
4
5
57