Questions tagged [functions]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
1 view

Additional line in the Plotting

I'm trying to plot a function, the problem is that the plot contains additional lines which originate from the solution itself, but at the same time removing the solutions will delete a whole portion ...
user avatar
1 vote
0 answers
7 views

Find first position satisfying condition, which is true after a certain element

I've made a function called Earliest I believe it is useful and there isn't built-in function like that (at present). The purpose of the post is to try out the code ...
user avatar
  • 2,835
3 votes
3 answers
122 views

How can I plot only legend of this?

How can I plot only lengend of this? ...
user avatar
  • 1,892
0 votes
0 answers
27 views

When a function is defined by other functions [closed]

I have the following functions: x1P[t1_,t2_]:=8/3*1/(1+t1)+(2t2^2-4t1-4t1t2-1)/(2(1+t1)^2) x2P[t1_,t2_]:=(1+2t1-t2)/(1+t1) lP[t1_,t2_]:=1/(2(1+t1)) And I would ...
user avatar
0 votes
2 answers
41 views

Replacement of a variable only for a part of an expression [closed]

I am trying to do a replacement of a variable on a general expression, but only for a part of the expression and not all of it. As a simple example, consider the following expression ...
user avatar
  • 1
1 vote
1 answer
29 views

Additional lines in the plotting graph

I tried to plot the following ...
user avatar
2 votes
2 answers
148 views

How to plot two functions?

a[x_,y_]:=x^3+y^2; b[x_,y_]:=x^2+y^3; I want to plot a[x,y] in x axis and b[x,y] in y axis for different values of x and y say, we fix y=1 and x goes from 1 to 10.
user avatar
  • 115
8 votes
1 answer
101 views

Very simple, unexpected Low Performance of set(=)

...
user avatar
  • 2,835
1 vote
0 answers
65 views

Possible bug: Wrong limit for `EllipticE`?

I encountered problem with computing limits of Elliptic functions E and F. For example, ...
user avatar
0 votes
0 answers
65 views

How to do this recursion relation in Mathematica effectively?

I have a function $h_{\Delta,l}(r,\eta)$ satisfying \begin{equation} h_{\Delta,l}(r,\eta)=\tilde{h}_{l}(r,\eta)+\sum_{k}\frac{c(k)}{\Delta-(1-l-k)}r^{k}h_{1-l+k,l+k}(r,\eta) \end{equation} where $k$ ...
user avatar
  • 51
0 votes
0 answers
41 views

A way to tell mathematica to not alphabetically order second derivatives

I have a frame of vector fields $E_1 ,... ,E_6$ and it's convenient for me to write $E_1(f)$ as Dt[f,e1] where e1 is an ...
user avatar
1 vote
0 answers
46 views

How to simplify a function imposing that it is equal to zero?

I have a function calculated by Mathematica given by $F=\frac{1}{2r^3}sin[\theta]Y^{(1,0)}[\theta, \phi]((-4m+L(1+L)r)h0[t,r]+r(-2m+r)(-rh0^{(0,2)}[t,r]+2h1^{(1,0)}[t,r]+rh1^{(1,1)}[t,r]))$ and I want ...
user avatar
6 votes
1 answer
191 views

Determination of a Function

I have an expression: $5e^{13t} = F(e^{14t})$. I want to use Mathematica to determine $F$ on this function to be $F(q) = 5q^{13/14}$. How do I do this? Sorry if this seems trivial -- I can't quite ...
user avatar
  • 187
9 votes
3 answers
631 views

What is the best method to search pattern for 2D list?

What is the best method to search patterns for 2D list ? Let L be following 2D-list : ...
user avatar
  • 2,835
3 votes
3 answers
621 views

Is there a formula that can quickly calculate the ByteCount of an integer?

...
user avatar
  • 301
0 votes
0 answers
36 views

Using discrete distribution to fit continuous distribution and then reproduce the same discrete distribution, all on the same Plot

I'm using the discrete distribution function to fit the continuous distribution by method of moments, and then, trying to reproduce the same discrete distribution function. The data used to plot the ...
user avatar
3 votes
3 answers
277 views

Is there any way to get nthComposition of a function?

I need to find the nthComposition of a function. I thought there could be something like nthComposition[f,x,5] means five times composition of f with x as input parameter. I don't want to repeat f in ...
user avatar
  • 443
3 votes
2 answers
220 views

Strange behavior of 'SquareFreeQ'

What is the cause of this strange behavior of SquareFreeQ while PrimePowerQ works correctly: ...
user avatar
  • 2,615
1 vote
1 answer
75 views

How to create a matrix with multiple variables defining the elements?

I am a learner start using Mathematica to study quantum mechanics. In many cases, I am try to construct matrix with functions like this: For example, let f be a function taking 4 variables x1,x2,x3,x4,...
user avatar
0 votes
2 answers
71 views

How to take the derivative with respect to a function with more than one variable?

I have a function that includes another function inside. I want to know the derivative at every point x. I have spent a lot of time trying to figure out how to do this, but I am very lost. I have ...
user avatar
1 vote
1 answer
85 views

Value of allegedly infinite limit is different for different values of the variables

I have a $5$-variables function $f(x,y,z,u,v)$ and I want to compute the limit as $x\to\frac{3\pi}u$; using this code for general values of parameters, Mathematica gives the answer ...
user avatar
  • 141
-1 votes
0 answers
37 views

Confused result in RepeatedTiming

RepeatedTiming[expr,t] does repeated evaluation for at least t seconds. I use this function to measure 1+1 for 3 seconds.But it actually took more than 3 seconds. ...
user avatar
5 votes
2 answers
259 views

Why does FindSequenceFunction not work in this case?

Why does this not work? FindSequenceFunction[{1/2, (2/3)^2, (3/4)^4, (4/5)^6, (5/6)^8}, n] (*FindSequenceFunction[{1/2,4/9,81/256,4096/15625,390625/1679616},n]*) I ...
user avatar
  • 2,207
5 votes
1 answer
370 views

How to use PlusMinus properly?

As an easy exercise, I would like to define a function $$f(x)=\pm x$$ and be able to ListPlot the function for some discrete values. Here is what I tried ...
user avatar
1 vote
0 answers
29 views

Efficient construction of a formal polynomial using list manipulations

I have a code which is probably extremely inefficient given my inexperience with Mathematica list manipulation. Take as input data: ...
user avatar
  • 1,307
2 votes
1 answer
107 views

Introduce formal symbols indexed by natural numbers

I'm going to describe a toy example here which I'm hoping with some help, I can then soup up into the more complex application I have in mind. Suppose the input is a list of lists, and for now take ...
user avatar
  • 1,307
5 votes
1 answer
247 views

Why does this Fourier transform not match the formula?

From this page: So I'm trying to get that result in Mathematica. From the fourier formula above, we can see that {a, b} = {1,-1}. However, the code below returns a different result. ...
user avatar
  • 1,892
1 vote
1 answer
100 views

How to plug in an implicit function into another function and evaluate in Mathematica? [closed]

I am wondering how to do the following in Mathematica. Say, we have an implicit function $y=f(x)$ defined by $F(x,y)=0$. I would like to evaluate another function $G(x,y)$ at the implicit function $y=...
user avatar
  • 11
4 votes
2 answers
186 views

Tropical Operation Conversions: Multiple Operations

I apologize if my syntax is bad. I looked around, but didn't see anything on this in the stack exchange. I would like to be able to transform a classical real-valued polynomial to a tropical ...
user avatar
  • 143
2 votes
1 answer
94 views

Why Mathematica does not return explicit output [closed]

I am new to Mathematica. One thing that I don't get is why if I define a matrix and give it a name, then use the name in another function, I get back the function itself. However, When I use an ...
user avatar
11 votes
1 answer
248 views

Association vs Pair - Creation performance, Selection performance

Suppose that we ...
user avatar
  • 2,835
4 votes
1 answer
70 views

Replacement, PatternTest, Module related Question

Let's see how MMA handles following type of expression : Replace[L, {pattTest1->rhs1, pattTest2->rhs2, pattTest3->rhs3}, {1}] Specific example : ...
user avatar
  • 2,835
0 votes
1 answer
79 views

Animate a point that follows a function inside a plot

I'm trying to create a plot that shows an animation of a point moving along a function. The idea behind this is that a I want the point to follow the function until the discontinuity point. For every ...
user avatar
  • 69
3 votes
2 answers
89 views

Find global maximum of InterpolatingFunction in interval but not maximum value

I have InterpolatingFunction generated from experimental data with many local maxima, one major peak I need to find, and the tail that grouse much higher then major peak. I tried to find my peak with ...
user avatar
3 votes
1 answer
79 views

Classifying elements, by the value of a fixed function, using Replace

Let L be a list of several lists. And the length of each list is less than 1000. You can create L by ...
user avatar
  • 2,835
1 vote
3 answers
70 views

Module returns multiple functions

I want to write a module that returns two functions which then can be evaluated later on. I know how to do it with a single function, but I don't know how to make it work for multiple functions. An ...
user avatar
  • 113
1 vote
1 answer
91 views

While inside a function body does not work as expected [closed]

I'm trying to write a function that return a randomly created rational polynomial function that has a discontinuities points. I already have a function that generates random rational polynomial (...
user avatar
  • 69
2 votes
0 answers
74 views

sometimes Select / sometimes Position is faster

As you see, For list L, L1(Select method) is slower than L2(Position method). But for list <...
user avatar
  • 2,835
1 vote
3 answers
77 views

How to define a function of parameters of a DSolve output?

If I have some ODE that has some parameters, say $a$ and $k$, how would I define a function of those parameters of the solution DSolve. For example consider the ...
user avatar
  • 173
0 votes
1 answer
56 views

Find the parameter region where function returns negative value

I have a function $f(m,n)$ where m and n are positive integers. Suppose $f(m,n)$ is like a black box, I can get values of it when I enter values of m and n. I want to scan over a region for example $...
user avatar
  • 51
0 votes
0 answers
66 views

Packed/Unpacked array - what object/like 0 or 1?/how to check/ [duplicate]

In Mathematica, there is a concept called packed array. ...
user avatar
  • 2,835
0 votes
1 answer
34 views

Recursive error encountered when updating rules of assignment [closed]

I'm working on a problem which requires associating a single (complex) number with a pair of binary vectors. I'm doing this by creating a set of assignments through a function I call ...
user avatar
  • 595
3 votes
2 answers
94 views

How to remove duplicates from a pair with some conditions?

Here is a simpler example of my real problem. Assume that I have a groups which includes sublists as follows: ...
user avatar
  • 2,207
0 votes
0 answers
37 views

Extracting function domain from a finite set of assignments

Suppose we define a function through a finite collection of equalities, e.g., f[1] = 1; f[26] = 321 and so on. We can extract the set of output values by running <...
user avatar
  • 595
2 votes
0 answers
39 views

Delete list item if message is thrown

I have a nested list with each element containing FindRoot like this: {FindRoot[a,b], FindRoot[c,d], FindRoot[e,f],...} ...
user avatar
5 votes
4 answers
187 views

Find shortest distance between two functions [closed]

The problem is to find the shortest distance for given functions: y=x^2+7/2 and y=ln(x) without using Minimize. Does anyone have any idea how to approach this ...
user avatar
  • 51
9 votes
4 answers
532 views

How can I use variables instead of slots in DeleteCases?

Here is a toy example to illustrate my problem. I have a list of 3-tuples and I want to delete elements from this list that satisfy a condition shown below. ...
user avatar
  • 1,892
0 votes
0 answers
32 views

Using the recursion index to compare with a value in another list

I am trying to generate an arrivals and departures plot for a signalised junction with the following parameters: lambda: rate of arrival c: cycle length of traffic lights g: length of time signal is ...
user avatar
4 votes
1 answer
126 views

How to get a function from a string?

I'm trying to create a function that takes in input a function written as string and the return it applying a ToExpression and an Evaluate (Code below). The goal of this function is to transform the ...
user avatar
  • 69
4 votes
3 answers
483 views

How to simplify function with Abs?

I'm trying to remove Abs below. ...
user avatar
  • 1,892

1
2 3 4 5
67