Questions tagged [functions]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
18 views

Plotting 2 functions at the same time with Manipulate[]

Here is a code that works well: ...
0
votes
0answers
39 views

How to check if an expression is real in some domain

I was wondering if it is easy to see if a given expression evaluates to a real number in a given domain? Let e.g. f(x,y,z) be some function depending on three ...
1
vote
1answer
32 views

Get modulus and plot complex function

I have the following function: ...
0
votes
0answers
35 views

Solving integral involving absolute value of a vector

I am trying to integrate the following in mathematica: $\int_0^r \frac{exp(-k_d(|\vec{r}-\vec{r_j}|+|\vec{r}-\vec{r_i}|)}{|\vec{r}-\vec{r_j}|\times|\vec{r}-\vec{r_i}|}r^2dr$. I have first defined, the ...
7
votes
1answer
309 views

Why are more highly nested lists often not more memory and time-intensive?

I would expect more highly nested lists, being deeper and more complex than flatter lists, to take up more space (bytecount) and take more time and memory to operate on in general. Consider the ...
0
votes
0answers
41 views

Plotting a 3D-function with a condition

I am trying to plot a 3D-function in Mathematica as a function of $\beta$ and $\theta$ where $\theta$ is dependent of $\beta$, we will have that $1/2<\beta<1$ and $0<\theta<ArcTan[-(1-2\...
0
votes
0answers
82 views

What does it mean when a function has two square brackets?

I have been solving some partial differential equations with mathematica, and the solution of one involves a function $c_1$ as follows, $f[x,y,z]=e^{x}c_1[y][y+xz].$ I am not sure exactly what it ...
2
votes
0answers
32 views

How to define a function based on an operation with parameters

I would like to define a function as the output of another operation depending on a few parameters. For example s[t1_,t2_]:= Integrate[t^n,{t,t1,t2}] s[0,1] I ...
2
votes
1answer
70 views

Partial fraction decomposition of LTI system's frequency response

I want to perform a partial fraction decomposition of a LTI system's frequency response, and I want it to look like this: $$H(j\omega) = \frac 1 {5 + 2j\omega + (j\omega)^2} = \frac A {\alpha + j\...
3
votes
2answers
159 views

Solving the Shifted Neutral Axis Problem

Problem Description: In solving the "Shifted Neutral Axis" method for the stress distribution of a vertical steel vessel supported on a concrete foundation, we can derive the following ...
0
votes
0answers
28 views

Restricting the range of values in a recursive function

Hello I am relatively new to Mathematica and I have a problem regarding my model. I have the following function: ...
4
votes
2answers
105 views

Help with function accepting real values [closed]

I'm trying to define a function accepting only real values like this: f[x_Real] := x^2 f[0] But it outputs f[0] and doesn't ...
2
votes
2answers
86 views

Shortest way to take first half of list and/or split list into n parts

What is the shortest way to take the first half of a list? Or to split a list into n equal parts? If the length is not 0 mod n, I would prefer to leave out the left ...
2
votes
1answer
63 views

Reduce doesn't work with user defined function with /;

I want to use Reduce to my own function, but it generates the error message: This system cannot be solved with the methods available to Reduce. Here is a simplified example. ...
2
votes
2answers
58 views

Define linear combination of InterpolatingFunctions as new function

Say I have a list of interpolating functions and scales and want to combine them in a new function as in ...
4
votes
2answers
110 views

Re-writing $f(x, y)$ as $g(x)h(y)$ [duplicate]

Is there a general way of re-writing a function of two variables as a product of two functions, $$f(x, y) = g(x)h(y)$$ Specifically, I’m trying to write an expression, $$f(x, y) = \frac{a y - x}{y - 1}...
0
votes
1answer
48 views

Functions inside a Module [closed]

I am trying to define a function inside a Module, whose arguments are not apriori known, but it is known that the function has two variables. ...
3
votes
2answers
37 views

Display `Table` output as a 3D bar chart

Create a simple function with arguments {i,j}, and make a Table for an array of values. For example: ...
4
votes
0answers
110 views

A Curiosity: What is DispatchQ?

As shown below, my autofill in Mathematica showed an interesting function: DispatchQ. Yet, it does not appear in the Mathematica Documentation Center, a search for ...
0
votes
1answer
44 views

Referencing a user defined function in another [closed]

I have defined a time-dependent current as it1[t_] := ((i01*(Exp[-α*t] - Exp[-β*t])))*HeavisideTheta[t] This works fine; it plots correctly and is easy to ...
2
votes
2answers
60 views

How to select parts of a (non)function

I have a set of points ...
2
votes
0answers
50 views

When making a package, how can I make a function that is already used by system?

Obviously, Plus[a,b] is given by Mathematica but say I have a package and I want to name a function Plus[a,b]. How can I go ...
1
vote
0answers
43 views

Making Table with nested SetDelay functions is very slow

I am trying to write a function which returns a list of lists of eigenenergies available for a quantum well. The code is here: ...
3
votes
1answer
74 views

How can I prevent TabView from resetting the current tab?

This is a simplification of a problem that has arisen in a project regarding Euclidean activities for verifying proportions via operations on pairs of magnitudes. In the project, the LocatorPane is ...
3
votes
2answers
57 views

Better way for constant expressions in functions than storing as global variables?

For example, I wrote a function like this: inversions[list_] := Complement[ Subsets[{1, 2, 3, 8, 4, 7, 6, 5}, {2}], Subsets[list, {2}] ] But as you see, ...
2
votes
2answers
72 views

Issues Implementing Pure Function

Thanks in advance for any assistance you may be able to provide. I'm new to Mathematica and running into issues creating a usable function from the code seen below. For context, all of this code works ...
2
votes
1answer
53 views

How to use the Inversions function?

The Inversions function counts the number of inversions in permutation p. More info: https://reference.wolfram.com/language/Combinatorica/ref/Inversions.html When ...
1
vote
0answers
74 views

Approximation of a function by a polynomial (Chebyshev First Kind, Bernstein, etc…) containing only even degrees and constants in a given Range[a,b]

In Mathematica, how can I create a polynomial function containing only even degrees and constants? That is, I have a function: $f(x)=\frac{\pi ^2}{\left(\frac{\pi }{2}-\tan ^{-1}(k (x-1))\right)^2}$ ...
1
vote
3answers
83 views

Limit of a function of three variables [closed]

I am using Mathematica 11.0. I want to find the limit at origin of the following function: ...
7
votes
1answer
110 views

Multi-variable Fixed Point Iteration Command?

We want to find the zeros of a multi-dimensional function f[x_, y_] = {x + 1/4 (-Cos[x] + Sin[y]), x - y - Sin[y]/4} To find the zeros, we can initialize and ...
4
votes
1answer
75 views

how to make my own `PrimeQ` function?

How can I create my own function that verifies if the number is a Prime without using PrimeQ ...
0
votes
0answers
31 views

Generalization of the nested for loop

...
4
votes
1answer
159 views

How can we create a FunctionQ function?

How can we check if an entry to our function is a Function or a Pure Function? For example: ...
3
votes
1answer
51 views

About function with Manipulate and order of evaluation

I have many problems to understand how mathematica evaluates Manipulate[] when I use function before or inside Manipulate[] . ...
0
votes
1answer
23 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: ...
6
votes
2answers
307 views

How can we create functions like Mathematica does?

Simple question. How can we construct functions like Mathematica does? For example, let's say that we want to create our own D function. The ...
2
votes
1answer
57 views

why this simple code is not giving the right answer under Compile

I have two sets of inputs that are to be fed to a simple function. The inputs are essentially a set of triangles and the normal for each triangle. The function will compute the gradient about the ...
3
votes
0answers
78 views

Create my own voice on Mathematica 12 [closed]

I want to create my own voice on Mathematica 12 and use it for this function SpeechSynthesize["Hello"] We can use theses voices on Mathematica ...
8
votes
1answer
158 views

How to construct this matrix in Mathematica

I create a symbolic matrix using the following: mat = ToExpression[Table[StringJoin[{"s", ToString[i], ToString[j]}], {i, 1, d}, {j, 1, d}]] for arbitrary $d$. ...
1
vote
1answer
61 views

How to plot a thermodynamic cycle? [duplicate]

I try to plot a thermodynamic cycle with the data displayed using the tool, "Piecewise", but in the case of isochoric and isobaric processes, Mathematica shows nothing. Could someone please tell me ...
0
votes
1answer
67 views

How can I make dynamically changing functions?

I am trying to do transfer matrix calculations (optics), where I have a layered sample and want to calculate how light propagates through it, depending on some parameters: The charm of the method is ...
2
votes
1answer
29 views

Export data in multiple columns

Let's say I have a function W[x_]; and would like to export the data for xrange -100 to 100 I have tried this ...
0
votes
0answers
37 views

How can I access a list of functions?

I found answers to this question but I don't know how to apply them to the code below. The code below rotates a cube with edges of length 1 by an angle p around the z axis. The origin of the ...
3
votes
4answers
186 views

Applying a multivariate function to lists [closed]

Suppose I have the lists, x, y, and z: x = {-0.30, -0.16, 0.65} y = {-0.28, -0.19, 0.23} z = {-0.15, -0.11, 0.18} Furthermore, I have defined the following ...
1
vote
2answers
77 views

How to run 1000 examples of matrices

I have two functions of matrices, let say $f(A,\,B)$ and $g(A,\,B)$, where $A,\,B$ are positive semidefinite matrices. I want to check if $f(A, B)$ is greater than $g(A,\,B)$ for any $A,\,B > 0$. I ...
1
vote
1answer
36 views

How to define many arguments in function?

Following is my code, you can see that in eq[], its arguments are defined by t and list{xs}, If I expand the ...
5
votes
2answers
225 views

Nesting of a sequence of functions

Suppose I have two functions, f and g. I would like to produce, in an arbitrary fashion, a new function like, say, ...
7
votes
2answers
144 views

Defining a function which is numerical on all vectors of arguments

There is an attribute NumericFunction in Mathematica that can do the following job: ...
1
vote
2answers
45 views

Evaluating part of an expression, but delaying the rest

Say I have an expression g = x^2 + y^3; I tried writing this H[x_, y_] := Eigenvalues[Evaluate[{{0, g}, {g, 0}}]]; The ...

1
2 3 4 5
54