Questions tagged [functions]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
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 ...
0
votes
0answers
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 ...
0
votes
1answer
43 views
2
votes
3answers
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 ...
2
votes
1answer
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 ...
1
vote
1answer
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 ...
2
votes
2answers
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. ...
3
votes
2answers
89 views

Finding multiple local minimum

I have the following code: ...
0
votes
1answer
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 ...
2
votes
1answer
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 <...
4
votes
0answers
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 ...
0
votes
1answer
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 (-...
0
votes
0answers
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. ...
0
votes
3answers
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)
1
vote
2answers
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 ...
0
votes
3answers
67 views

Composition of Maps

I want to create a composition of several lists. For example: ...
1
vote
1answer
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: ...
2
votes
1answer
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 ...
1
vote
1answer
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 ...
2
votes
2answers
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 ...
1
vote
0answers
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 ...
3
votes
2answers
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 ...
0
votes
0answers
42 views
2
votes
1answer
98 views

How do we take certain elements from a list?

Say we have a list ...
0
votes
1answer
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: ...
2
votes
1answer
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.: ...
0
votes
2answers
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 ...
1
vote
1answer
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 ...
0
votes
2answers
36 views

Access to Interpolation expression of Mathematica's Interpolate command

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 ...
0
votes
0answers
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. <...
7
votes
0answers
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 ...
2
votes
1answer
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 ...
1
vote
2answers
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: ...
0
votes
1answer
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 ...
2
votes
1answer
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}$....
2
votes
1answer
45 views

Replacing $x,y$ in $f(x,y,z)$ with values from a list

I'm sure there is a simple solution to this using map or apply, but its not occurring to me. Suppose I have a function $f(x,y,z)= x+y+z)$ And I want to evaluate $f(x,y,1)$ for $\{x,y\} ∈ \{\{1,2\},\{3,...
0
votes
1answer
58 views

Solve system of 5 unknowns and 5 nonlinear equations

I attached below the system of 5 equations that I am not able to solve using FindRoot. I also tried without defining the equations as functions but It didn't work. ` ...
0
votes
3answers
60 views

NIntegrate with a function defined with conditions

Good afternoon, I am trying to integrate a function that is defined with a conditional. The simplified code is the following: ...
0
votes
1answer
53 views

Change Replace Rule with Function Input

I am trying to create a function that takes in an input $\mu$ and place that input into the replace rule for a numerical integration, as seen in the code below: ...
1
vote
1answer
54 views

expand function as power series of another function

Suppose I have a well-known function $f(x)$ and I want to know if this function can be expanded into power series of another function $g(x)$, like $f(x)=\sum_n a_n g^n(x)$, where $a_n$ is the ...
1
vote
2answers
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 <...
2
votes
1answer
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 ...
3
votes
2answers
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. ...
0
votes
1answer
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 ...
0
votes
1answer
45 views

Not respected assumptions

I' m writing a function with the following line: ...
1
vote
0answers
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[1] := 0; this ...
1
vote
1answer
34 views

Multiple functions compact form

I have a sort of silly question... I need to define two functions in the following way ...
0
votes
0answers
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 ...
2
votes
0answers
43 views

How to prevent Y axis from rescaling every time I move the slider in manipulate [closed]

I am trying to plot the intensity distribution of Double Slit DIffraction, I have used the manipulate function to manipulate Cos[p] which is for interference in the following code, but when I move the ...
1
vote
0answers
56 views

Is there a reason why “Revolutions” and “Radians” or “AngularDegrees” are not CompatibleUnitQ?

I understand that keeping a consistent unit framework across multiple domains is complicated and not everyone will be satisfied with the choices made, like when people ask why "Radians" are ...

1
2 3 4 5
57