Questions tagged [functions]

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

Filter by
Sorted by
Tagged with
2
votes
4answers
108 views

Cut part from function

I try implement cutting some ease function. I have one ease function ease(x) where x (0,1) and result (0,1). I can not ...
0
votes
1answer
25 views

Function isn't adding the 2 matrix [closed]

Having an issue where my function rotMatfromVec won't add the 2 Matrices at the end. It takes in 2 inputs, R and theta, where R is a unit vector. ...
0
votes
0answers
23 views

How to efficiently store the result of a function [duplicate]

Consider the following code: f[x_]:= SomeCodeAbout[x] g[x_]:= f[x] It links g with f, ...
0
votes
0answers
48 views

Optimizing a parameter space search

This is related to my previous question: Solve for parameters so that a relation is always satisfied The Problem I am searching the parameter space of a large (many terms) function to find where the ...
5
votes
2answers
173 views

Solve for parameters so that a relation is always satisfied

Let's 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 (doesn't really matter what they are) for the ...
1
vote
2answers
173 views

How can I check if one expression implies another?

Say I have one expression, for example $x^3-3 + c = y$, and I want to check if it implies another with some set of explicitly stated assumptions. With the previous example, assuming all variables are ...
2
votes
3answers
343 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 ...
0
votes
1answer
48 views

Plot the tow data in one graph

...
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 ...
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 ...
2
votes
2answers
56 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. ...
1
vote
1answer
38 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 ...
5
votes
3answers
1k views

How to get exact coordinate of a point from a plot?

I am using BodePlot[] to plot the magnitude and phase of a function as below. BodePlot[1000/((1 + s/10^3)*(1 + s/10^6))] ...
5
votes
0answers
169 views

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
181 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 (-...
3
votes
2answers
91 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 ...
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: ...
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 <...
1
vote
1answer
88 views

Printing Values Within a Function

Below is a function to calculate the overlap between two gaussian functions. ...
0
votes
0answers
17 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. ...
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
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
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: ...
0
votes
3answers
67 views

Composition of Maps

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

Find maximum of the output from reduce

I am trying to reduce a function in two variables($n_1$ and $n_2$) whose domain is the set of Integers. I get a long list of pairs of values for these two variables(instead of a range). This could be ...
4
votes
2answers
2k views

Evaluate a list

I have a function $f(x_1,\cdots,x_n)$ that takes $n$ arguments, and I would like to evaluate it using a list of lists $\lbrace\lbrace x_1,\cdots,x_n \rbrace,\cdots,\lbrace x_1',\cdots,x_n' \rbrace,\...
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 ...
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 ...
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 ...
2
votes
1answer
99 views

How do we take certain elements from a list?

Say we have a list ...
5
votes
3answers
271 views

Problems with solving PDEs

I am using NDSolve to solve the two equations: ...
3
votes
2answers
96 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
1answer
42 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: ...
0
votes
1answer
144 views

Automating a large operation by making a function

I would like to automate the following operation. To be transparent I shall put my code into separate chunks and explain the process. Suppose I have the following: ...
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 ...
2
votes
1answer
183 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
1answer
27 views

How to substitute part of expression with function variable (Goal: create function that solves expression numerically for one of the variables)

I have a complicated expression that contains N variables. I want to create a function of N-1 that solves for one of those variables Toy example: ...
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
37 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 ...
18
votes
3answers
4k views

Fitting ellipse to 5 given points on the plane

Five points are required to define a unique ellipse. An ellipse has five degrees of freedom: the $x$ and $y$ coordinates of each focus, and the sum of the distance from each focus to a point on 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
130 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 ...
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: ...
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 ...
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 ...
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: ...
2
votes
1answer
50 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}$....

1
2 3 4 5
57