Questions tagged [functions]

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

Filter by
Sorted by
Tagged with
-1
votes
1answer
99 views

Solve A System of Trigonometric Equations

I tried running the following code on Mathematica Cloud, but it didn't because it was taking long of I have the basic plan. Would someone please run this code for me and share with me the results. it'...
1
vote
1answer
130 views

How to speed up a complex function involving integration and matrix inversion?

Here I have a function $I(V)$ (current with respect to voltage $V$) involving numerical integration of dummy variable $E$ for a given $V$. The whole expression of current is given by the following: $I(...
3
votes
2answers
148 views

How can I set a hidden parameter to a value in Module?

Here is a minimal example: x = 4 + m; g = Sin[x]; Module[{m = 1}, g] Sin[4 + m] So, why is m not replaced inside ...
18
votes
4answers
2k views

How to straighten a curve?

What's the easiest way to get the following animation for a given parabola where the arc length is preserved (that is, for two points in the parabola, I straighten it as follows) My main goal is the ...
3
votes
2answers
151 views

What is the usefulness of adding a colon ":" to arguments in the declaration of a function?

I'm studying a code with the following function declaration : FindChain[ x:__ ,y_?FindChainQ,z:__] := { {x},y,{z} } What is the meaning of the colon ":" after the arguments x and z ? What ...
2
votes
2answers
173 views

How to plot a point in the intersection of two functions?

I'm trying to plot the intersection of a Sum function with a horizontal line and automatically highlight the intersection points. The code below shows my knowledge of Mathematica and for different ...
0
votes
1answer
60 views

How do I set an element of an already-defined vector function to some expression?

I'm defining a vector whose elements depend on time, i.e. I'm defining a real vector function of real elements that depend on the real scalar time variable. The vector function is named ...
5
votes
2answers
589 views

why the two images are different? Are the functions same?

why the second image just has the positive part? Is the problem in the domain of definition? 0.0 The code is here: ...
8
votes
2answers
275 views

How to check the number of function arguments given by the user

Suppose I have defined the following function inside a package that can take 2 arguments. f[x_,y_]:={x,y} So, if the user gives ...
1
vote
2answers
77 views

How to dynamically define matrix with blocks in subdiagonals?

...
2
votes
2answers
107 views

Find the range of a univariate function over a specific interval of the variable

I would like to find the range of the function below, but only for values of $a$ strictly greater than zero. ...
0
votes
0answers
33 views

Going between assignment rules and functions

I am trying to develop a model using Mathematica, and continuously run into difficulties going between the outputs of various functions (Solve, Differentiate, etc.) and back to functions (in the ...
0
votes
0answers
44 views

A Function of Arguments or a Function of a List of those Arguments – Which is Recommended?

Which is recommended from a programming perspective and has better performance in memory and speed given guaranteed identical output – a function taking many arguments and then referring to those ...
3
votes
2answers
85 views

Passing Arguments or Passing a List and Referring to its Parts – Which Gives Better Performance?

Which is better for optimizing speed, memory, and coding "safety" – passing arguments to a function or passing a list to the function and call the list's parts? That is, which of the ...
2
votes
0answers
96 views

How to perform feature selection for machine learning applications?

Feature selection is fairly easy in e.g. Python's scikit-learn which sports a module and tutorials or MATLAB. Mathematica even touts that it uses feature selection ...
0
votes
3answers
117 views

Iterative function

I would like to write a bit of code that does the following. Pick a random number from 1 to 20 (inclusive) then if that number is < 15, stop if that number is > 15 pick 2 numbers from 1-20, and ...
0
votes
0answers
35 views

How to generate the low discrepancy Halton sequence in Mathematica and plot it?

Pre-requisite Definition For any integer $n\geq 0$ and base $b \geq 2$ as follows, we define the following function, known as the radical-inverse function, \begin{align} \phi_b(n)=\sum_{j=1}^m a_j b^{-...
0
votes
0answers
61 views

How to create and store a plot for each iteration of a Do loop

I have created the following code below. Its purpose is for me to divide the plot into grids and for each grid I reterive the center point's co-ordinates. ...
1
vote
1answer
56 views

How to plot a piece-wise function like this: f[x]=1 when -1<=x<=1, and f[x]=0 when x>1 or x<-1

I want to plot a piece-wise function like this: f[x]=1 when -1<=x<=1, and f[x]=0 when <...
0
votes
0answers
36 views

Storing a value in array during a for loop

So I have a piece of code below that is used to make a density plot and make the plot into grids, where I then find the center of each grid and store it in the varible called cp. The code for this is ...
1
vote
0answers
36 views

How do I input n-Dimensional random numbers into a function accepting n variables [closed]

Apologies if this is overly simple but I wasn't able to find an answer online. Question Say I have a function defined as follows (and not two separate instances of random numbers), ...
0
votes
1answer
42 views

Is it possible to do partial fraction expansion with specific degree of the variable?

For example, here is a rational polynomial: $$\frac{8 z^2}{8 z^2-6 z+1}$$ If I using Apart directly, the result is: $$-\frac{1}{4 z-1}+\frac{2}{2 z-1}+1$$ but if I want to using $z^{-1}$ as the ...
0
votes
0answers
38 views

Integral of functions within functions

I define the function Rho, use it in an integration command, store that result as a new function M, then write functions P and Rho1 in terms of M and Rho, and finally integrate Rho1 and store that as ...
0
votes
2answers
54 views

How to create an operator which is a composition of a sequence of operators?

Suppose I have a sequence of operators $\partial_x$, $\partial_x^2$,..., $\partial_x^n$. I want to define an operator which is a composition of these $D_x^{(n)}=\partial_x\circ\partial_x^2\circ\cdot\...
2
votes
2answers
154 views

RecurrenceTable does not work for sequence of function

Consider the following code that repeatedly differentiates a function: test = RecurrenceTable[ {g[n] == D[g[n - 1], x], g[0] == x^10}, g, {n, 0, 5}] This code ...
0
votes
1answer
58 views

Putting arguments of function automatically

This is a snippet of a code that I have: ...
3
votes
1answer
133 views

Setting a function equal to an integral

I am trying to solve for the constant of integration in simple calculus problems. v[t_] := Integrate[-0.08 t, t] + C v[t] gives me ...
0
votes
1answer
45 views

Resizing the graph of a function with radicals , Why?

I am trying to graph this function $c(t)=\frac{2-\sqrt{t+3}}{1-t}$ using this code, to see its behavior at infinity. I need that in the vertical axis appears the value when $t->1$ (The graphs ...
1
vote
2answers
89 views

Im trying to write this in Mathematica. It is a recurrence relation for convolution [duplicate]

I have tried many things, the relation is in the following picture, x' is a dummy variable.
8
votes
1answer
460 views

very simple but unexpected aspect of Function[ ]

I've always thought (2#+1)& and Function[x,2x+1] are interchangeable in common sense. But, ...
0
votes
2answers
190 views

Is it possible to calculate the desired area analytically?

I have the three two-variable curves $f,g,h$ with $0\leq x\leq \frac {\pi}{2} $ and $0 \leq y \leq \pi$ I use ContourPlot as ...
1
vote
0answers
68 views

What does the ## represent when it is used as a function argument in e.g. Manipulate? [closed]

what does the ## represent in following expression: ...
2
votes
1answer
82 views

A function that modifies functions - well-defined operation?

Here's my basic setup: Say I have a list of specific symbols and a function noSymbol, which accepts a mathematica expression and checks whether any symbol from my ...
1
vote
1answer
88 views

Get the list of (x,y) point of a graphic

I have a function like this: E^(-t/0.001)*Cos[t] + E^(-t/0.01)*Cos[1000 t] I used the code below as suggested in the forum to obtain the x,y values for points <...
4
votes
1answer
117 views

High-water marks of a sequence

I need to write a function that is, given a sequence of integers, extracts the subsequence of its high-water marks (i.e. distinct values of its running maximum). Here are some naïve implementations ...
0
votes
0answers
40 views

Parametric plot of a function which cannot be explicitly calculated

I wish to plot a function, but I run into a problem and I cannot find similar questions here. A simplified version of plot is represented by ...
4
votes
1answer
73 views

Refer to OptionValue externally without a specific function name

I want to refer to the actual option values of a function f outside of f, using OptionValue. ...
0
votes
0answers
111 views

Short forms for function-parameter combinations?

I find these to be very convenient, particularly since I use the base-10 log fairly frequently: Log[2, n]=> Log2@n ...
0
votes
1answer
84 views

how can I modify this function to convert to polar form for any complex expression?

The function from another post is to convert a complex number to polar form. polarForm = Expand[# /. z_?NumericQ :> Abs[z] Exp[I Arg[z]]] & Now if I apply ...
2
votes
3answers
119 views

How to collect a polynomial with a specific power

Suppose I have got this polynomial u=x^12-3x^8-x^4+3 Now, I am trying to collect this polynomial with x^4 terms. I need to write it like this: (-1+x^4) (-3 + x^4) (1 + x^4) To evaluate it, I used ...
3
votes
2answers
551 views

How to generate all possible functions combinations

Assume that I have 3 functions like this (total 10 functions in reality). f1[x_] := 3 x; f2[x_] := x^2 - 1; f3[x_] := 2 x + 5; Now I want to generate all possible ...
2
votes
1answer
95 views

Why does this DeleteCases not work? [duplicate]

I believe this is simple but I couldn't figure out why this doesn't work. Everything looks good to me. ...
0
votes
0answers
70 views

Dot Density Plot for 3D Probability Density Function of {x, y, z}

I have been calculating probability density functions for different states in the hydrogen atom, and want to plot them in 3D using a dot density plot like this one. However, I have not figured out how ...
2
votes
1answer
83 views

How can I make this plot easier to see?

How can I make this plot easier to see? In this plot the waverform is not clear. If I plot with w only from 0 to ...
0
votes
1answer
63 views

Plot real zeros regions of the polynomial

Good morning everyone! One problem have appeared. I'm trying to plot regions with different number of real zeros of the polynomial. I have this code: ...
1
vote
1answer
41 views

How to enter multiple inputs into a function? [closed]

I'm sorry for asking such an elementary question but I started learning the Mathematica language just yesterday and I can't seem to find an answer anywhere else. I'm trying to calculate the change in ...
1
vote
1answer
41 views

How to evaluate a function on all solutions given in output of a Reduce function

Say I have a Mathematica programme/function $f[z_,w_{} ] = \mathrm{Reduce}[\cdots]$ which outputs a list of solutions, which looks something like $$a = 1 \&\& ((0\leq b \leq 1000 \&\& ...
6
votes
2answers
156 views

Efficient computation of Hopf invariant

I am trying to check using Mathematica the following result: $$-\frac{1}{4\pi^2}\int_{0}^{2\pi}\int_{0}^{2\pi}\int_{0}^{2\pi} \mathbf{F}\cdot\mathbf{A}\;dk_x dk_y dk_z=1,\quad\text{where}$$ $$z_{\...
0
votes
2answers
48 views

How to make the third parameter optional and adding some condition?

I have a function as follows. The function has 3 parameters. Now I would like to make the third parameter i optional. So you call call it like ...
3
votes
2answers
390 views

How can I make a 3D Bode plot of a function?

I'm trying to do a Bode plot in 3D for the function below, but there is no built-in function for that. How can I do that? It would also be nice if you could use a mesh to make it easier to see. ...

1 2 3
4
5
64