# Questions tagged [functions]

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

2,812 questions
Filter by
Sorted by
Tagged with
31 views

### Solve for parameters so that a relation is always satisfied

Lets say I have a function parameterized by a number of variables. As a simple example $$F(x,y) = ax^2 +by^2-cxy+1$$ I want to find some set of values (doesnt really matter what they are) for the ...
13 views

### Can't plot derivative of Hankel function [duplicate]

I am trying to plot the first derivative of $H^{(1)}_3 (ix)$ with respect to its argument $ix$, where $H^{(1)}_3 (ix)$ is the Hankel function of the first kind with order $3$, $x \in \mathbb{R}$ is a ...
43 views

...
273 views

### How to use pipe operator in Mathematica?

t = Table[i1 + i2 i3, {i1, 2}, {i2, 3}, {i3, 2}] ArrayDepth[t] How to use "pipe operator" in Mathematica Version 11.0? In R, with library ...
60 views

### Trying to plot a chord with tangential labels

I'm brand new to Mathematica and trying to figure it out, my task is to create a chord with labels on each end (currently using a small section of the sine curve). Currently I've just got ...
34 views

### How to collect results from compiled function in ParallelEvaluate?

I am using Mathematica 12.x and have a compiled function, returning many things. I would like to run several instances of this compiled function, one for each core of my CPU, and then collect all of ...
52 views

### Print function value at specified coordinate

Below is the code to evaluate the function. I am trying to print the function values at a specified coordinate as shown in ActCoor. ...
89 views

### Finding multiple local minimum

I have the following code: ...
54 views

### Is there a way to use identities in Mathematica efficiently? [duplicate]

Imagine I have defined a variable l=p/(a*b) Let's say I perform some operations, and I get the final answer to be p/a. But all I ...
38 views

### Another nesting question

I have a function F[i_Integer,B_List,l_list] which spits out a list {B',l'} where B' and <...
153 views
+50

### Finding periodic cycles of a function

Given a function f[{x,y}] it is rather simple to use, for example, NSolve to find periodic points of period $n$. We simply take ...
171 views

### Elliptical Integration

I have an integral which can be decomposed into three complete elliptical integrals. I want to know the method by which I can achieve this. The integration is the following: (4 (-1 + y)^2)/(c Sqrt[y (-...
16 views

### Assumptions with piecewise problem?

I am trying to apply the assumpion of 0<s<1 throughout the calculation however the piecewise condition does not accept it automatically. Is there any way to avoid the manual choice of x>0. ...
31 views

### I want to maximise my function over a particular domain

I have tried NMaximise. But I am getting an error always. Even if my command is correct. My function is Cos[π E^x] and I want to maximise it over the range (-3,3)
76 views

### How to flip the function f(x) about y-axis

Suppose I have a function W(x). I wanted to flip (reflect) this function about the y-axis. I tried plotting W(-x) but it is not ...
67 views

### Composition of Maps

I want to create a composition of several lists. For example: ...
61 views

### Compute the length of each string in a set [closed]

Say I have done some computation, and it gives me the following set of string: ...
29 views

### How to conveniently evaluate a function at several points when there are way too many points

Say I define a function as follows: pos[n_] := If[Cos[288 ((n Pi)/233)] > 0 && Sin[288 ((n Pi)/233)] > 0, 1, 0] Then I want to evaluate at this ...
34 views

### Using FullSimplify to simplify an expression with assumptions

I am working with Poisson brackets of Angular momentum, and I want Mathematica to be able to return the angular momentum function if the Poisson bracket yields that result. I.e. provided ...
99 views

### Benefits/pitfalls of defining function that is discontinuous at a point “explicitly” vs using piecewise?

For example, suppose I wanted to define a function, f that is $f(x)=x^2$ except at $x=1$, where $f(x)=5$ Two ways I can define this are ...
33 views

### How to change behavior of Echo or turn it off without removing it from code?

I wish to use Echo for output of intermediate results if an OptionValue I call ...
94 views

### Why sometimes an input only return itself rather than the supposed result?

I encountered this problem several times but never managed to understand why. For example, I want to get the maximal value of a parametrized function $\log(c)+ b\log(k-c)$ with respect to $c$. I tried ...
42 views

...
98 views

### How do we take certain elements from a list?

Say we have a list ...
41 views

### Defining a Gaussian mixture distribution for $N$ number of Gaussian distributions

I am experimenting a bit with mixed-Gaussian distributions. If I want to define a mixture of two or three distributions, I do this with: ...
171 views

### Smooth Boxcar function (Rectangle Pulse function)

There are some answers on how to get a smooth squarewave function. But I would like to have a smooth boxcar function or rectangle function with 2 different widths.: ...
62 views

### Vectorization of a function

I would like to calculate the exponential values of the elements of a list / vector. For example, I would like to calculate the Boltzmann distribution over different energy levels where the normalized ...
46 views

### Both Dsolve and NDsolve for a differential equation failed

I tried both Dsolve and NDsolve for the following differential equation, it failed: It contains piecewise function ...
36 views

To reproduce fits which have been done in the framework of a standard, I was reviewing the Interpolation engine of Mathematica (for InterpolationOrder -> 3) to get more information about the ...
34 views

### How to define function in Mathematica

I have a 3 by 3 symbolic matrix M(x,y,z). Question:1 First, I want to find its eigenvalues and eigenvectors. After that I want to make each eigenvalue and eigenvector a function of x,y, and z i.e. <...
128 views

### Performance of pure function - Best way to define a function?

In general, to define a function, we often use f[x_]. Another way is to use pure function (full form and shorthand). I want to test the performance of these ...
62 views

### How &@ and &/@works?

I have the following expression: (Join[#, Reverse[#, {2}]] &@Partition[#, 2, 1, 1]) & /@ Vec (* where: *) Vec={{2,0},{1,1},{0,2}}, but I am not sure how ...
51 views

### Do not evaluate function composition in total derivative

How to achieve that Dt[] does not touch certain function compositions, but still applies all the other derivative transformations. Example: ...
40 views

### Getting error messages form Set while trying to implement the bisection method with a For-loop [duplicate]

My objective is to build a function using modules that runs the bisection method. I have a working bisection method but when I try to implement it as a module I keep getting this error and I can't ...
49 views

### Defining a function in parts

How can I define a piecewise function in Mathematica? I'm trying to define f_{A}(x)=\left\{\begin{aligned} 1, \quad x \in A\\ 0, \quad x\notin A \end{aligned}\right. where $A\subseteq \mathbb{R}$....
45 views

88 views

### Why can't Mathematica evaluate this integral?

I want to work with the rectangle function, which I define by f[x_, m_] := Limit[1/((2*(x - m))^(2*k) + 1), k -> Infinity]; (I know that in theory I can use <...
58 views

### FindGeometricTransform not working properly for a simple problem

I am surprised why FindGeometricTransform is failing to automatically register or align two sets of points that are drawn from a ...
120 views

### How to use a list of indexes as a variables inside a Module?

This is a trivial function, just to show that Module does not recognize the list generated by Table. ...
45 views

### Symbolically evaluating jump conditions of expressions across interfaces

I am dealing with a problem in electromagnetism involving problems in different regions, and there is something that I haven't been able to figure out yet. What I would like to be able to do is take ...
45 views

### Not respected assumptions

I' m writing a function with the following line: ...
31 views

### avoid using protected variable names in defining static pure functions

I will provide one example to show what the problem is. Collatz[m_] := Collatz[m] = 1 + If[EvenQ[m], Collatz[m/2], Collatz[3 m + 1]]; Collatz := 0; this ...
34 views

### Multiple functions compact form

I have a sort of silly question... I need to define two functions in the following way ...
59 views

### How to preserve my constants

\[Sigma] = Constant a = Constant b = Constant \[Epsilon] = Constant T[x_] := (\[Sigma]/(2*\[Epsilon]))[a/(a^2 + x^2)^(1/2) - b/(b^2 + x^2)^(1/2)] In mathematica ...