Questions tagged [functions]

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

265 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
0answers
55 views

Rescale large numerical factors in rational functions

Given a rational function $$ f(x_1,x_2) = \dfrac{r_1 x_1^2 + r_2 x_2}{r_3 x_1 + r_4 x_2}, $$ with $r_i$ arbitrary real or complex numbers, is there a built-in function to get Mathemtica to rewrite as $...
2
votes
0answers
122 views

Covariance matrix estimation when number of variables is larger than number of observations

It is well known that the sample covariance matrix estimator results in a singular matrix if the variables is larger than the number of observations. One solution is to apply shrinkage estimators. ...
2
votes
0answers
302 views

How to Implement a “Function Object” suitable for NDSolve and Finite Element Method?

I have a bunch of methods that shoud return an expression that behave like a function, i.e. an expression that, when supplied with suitable arguments, evaluate to something. A simple ...
2
votes
0answers
57 views

Computing an inexact derivative with some terms preserved in exact form

I am beginning to learn Mathematica and have the following question: How can I return a derivative with exact numbers instead of one involving numerical approximations? My original, single variable ...
2
votes
0answers
145 views

Marginal distribution with weight

Given a multi-variate distribution $P(\mathbf{x},\mathbf{y})$, I would like to obtain the marginal distribution $$P_m(\mathbf{x})=\sum\int_{\mathbf{y}}P(\mathbf{x},\mathbf{y})W(\mathbf{y})$$ In my ...
2
votes
0answers
138 views

Incorrect output from InverseFourierTransform

Bug introduced in 8.0.4 or earlier and fixed in 9.0.1 or earlier I am trying to compute the inverse Fourier transform of this expression ...
2
votes
0answers
634 views

Maximizing Large Multivariable Function over Region with Parameter Constraints

Brand new Mathematica user here. I have a complicated function to maximize, and thought I would try software like Mathematica instead of taking derivatives by hand. I found some Mathematica ...
2
votes
0answers
126 views

Which functions automatically generate new functions?

In his video http://www.wolfram.com/broadcast/video.php?channel=362&video=1643, Wolfram gives the following example: the output from dict = Nearest[WordData[]] ...
2
votes
0answers
133 views

Find eigenvalues without filling the matrix

Is it possible to find eigenvalues of a matrix without filling it? The matrix elements are given by a known function f[p1,p2]. This is relevant for a matrix too ...
2
votes
0answers
92 views

Complicated output from simple Eigenvalues problem

I have code that uses Eigenvalues on matrices of various sizes. But the output of what should be a very simple problem, namely finding the eigenvalue of a 1x1 matrix, is overly complicated. ...
2
votes
0answers
75 views

Panel size undesired behaviour

This is next question from the series: better avoid Panel if you care about details. previous about FrameMargins In the ...
2
votes
0answers
145 views

Are there some other ways to solve a second PDE except DSolve?

I have a partial differential equation as follows: $$\frac{\partial p(x,t)}{\partial t}=\text{Dp} \frac{\partial ^2p(x,t)}{\partial x^2}-\frac{p(x,t)-\text{p0}}{\tau }$$ What I try to do was to get ...
2
votes
0answers
456 views

Positive integrand giving negative answer

I'm integrating a positive function f(t) times sin(t) from 0 to pi/5 and get -38. Actually f is slightly negative for a short time (smallest value ~ -0.0005), but far from enough to explain this. ...
1
vote
1answer
36 views

FunctionRange giving “false”

I was trying to find the range of a function I obtained in some context. The code is as follows ...
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: ...
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
0answers
61 views

What is the difference between the Discrete Fourier Transform of a 2D list vs a list of 2D (complex) numbers?

What is the difference in Mathematica between the following: ...
1
vote
0answers
23 views

Derivative of a autoregressive process ARMA(6,6)

I want mathematica to derive the derivative of an ARMA(6,6) process with regards to its parameters. How would I define the function and take the derivative.
1
vote
0answers
31 views

settings elements of matrix of functions

I have a work flow that involves initially specifying a matrix function (or a matrix of functions), e.g. f[x_]:={{Exp[x],Sin[x]},{Cos[x],Log[x]}} This works well ...
1
vote
0answers
56 views

How do i get the Mollweide projection of a sphere?

I have defined three angular functions F1[θ_,ϕ_] := (1/2) (1 + Cos[θ] Cos[θ]) Cos[2ϕ] F2[θ_,ϕ_] := -Cos[θ] Sin[2ϕ] F3[θ_,ϕ_] := F1[θ,ϕ]^2 + F2[θ,ϕ]^2 So I can "...
1
vote
0answers
40 views

I want to differentiate partially a vector variable function. My code didn't work

I want to differentiate partially a vector variable function. f[v_] := v[[1]]^2 + v[[2]]^3; D[f[v], v[[1]]] This code didn't work. Please give me an idea. ...
1
vote
0answers
28 views

Do I have to write the independent variable always?

I'm not used to using Mathematica. Please help me. What I want to do is similar to the following: U and V are unknown function ...
1
vote
0answers
52 views

How can I force the output of a computation to be as compact as possible, yet complete, by using functions?

I am computing some derivatives in Wolfram Mathematica 11.3. The functions that I have to differentiate (with respect to the state variables) are the equations of motion of a rocket in the atmosphere. ...
1
vote
0answers
53 views

FindFormula: can I change the standard TargetFunctions?

FindFormula seems to have a limited number of TargetFunctions: Possible functions for TargetFunctions are Plus, Times, Power, Sin, Cos, Tan, Cot, Log, Sqrt, Csc, Sec, Abs, and Exp. Is it ...
1
vote
1answer
75 views

Printing Values Within a Function

Below is a function to calculate the overlap between two gaussian functions. ...
1
vote
0answers
42 views

How to speed up the evaluation of a sum of incomplete Gamma functions?

We need to do a ContourPlot for the following function $H[x,y,n]$: ...
1
vote
0answers
103 views

NDSolve 2 functions 2 variables with intermediate calculation : (1 time-space eq) + (1 space eq)

I have a system of differential equation with this structure : $$\left\{\begin{split}&\partial_t n(t,r) + \nabla. \big(n(t,r)v(t,r)\big)=0 \\ & f\Big(n(t,r),v(t,r),\partial_r n(t,r),\partial_r ...
1
vote
0answers
20 views

Solve, store, and access eigenvalues and eigenstates of M[x,y], for various points {x,y}

I'm interested in solving a position dependent eigenvalue problem for matrix M[x,y], where {x,y} is some discretized set of points. I may need to access the eigenstates and eigenvalues multiple times ...
1
vote
0answers
66 views

Force FindFormula to avoid Piecewise in the result?

Is it possible to provide any arguments to FindFormula to force it to avoid using Piecewise in the result, but instead try to ...
1
vote
0answers
27 views

Finding the positions of minima for a function with algebraic constants

I have a function of several variables: inverse[Qx_, Qy_]:= T - 2 J + 4 J1 Cos[(Qx + Qy)/2 a] Cos[(Qx - Qy)/2 a] - 2 J2 Cos[(Qx - Qy) a] + 2 J3 Cos[(Qx + Qy) a] ...
1
vote
0answers
48 views

How to preserve braces in result

I have a result from equation, for example p={{0<=x<=1/5||x==9/10},{0<=x<=1/5||x==9/10}} and using Cases[p, z_?NumericQ -> z, Infinity] I get {0,1/5,9/10,0,1/5,9/10} But I ...
1
vote
0answers
43 views

Attempting to create a toolbar with notebook tabs, unable to properly integrate functions

I recently learned that all the default Mathematica palettes were actually created in mathematica, and i have been trying to make something similar myself. And since learning that the DockedCell ...
1
vote
0answers
102 views

Is there an in-built function for the multivariate gamma distribution?

The Multivariate Gamma Distribution <- Wikipedia link with a description of the function. Is there an in-built function for the multivariate gamma distribution? I found out that there used to ...
1
vote
0answers
76 views

Series doesn't seem to work on functions

When you try to use the Multivariable option of Series, it doesn't work as intended, since it keeps terms of higher order than intended. Example: Expand a two-variable gaussian exponential to second ...
1
vote
0answers
78 views

Using While properly

I am trying to make While[] work with function results and evaluate them at the same time. ...
1
vote
0answers
29 views

Convolve[…] behaves differently to that of Integrate[…] when numerically integrating the result

I am performing a convolution between two functions, and then I want to numerically integrate the result. If I go: ...
1
vote
0answers
41 views

Determine sign of the remainder for Taylor expansion

Consider the following function $\rho(x)$ (which we define using intermediary variables and functions) for $0 < u, v < 1/4$ and $x$ some positive number ...
1
vote
0answers
37 views

Calculate with general discrete probability functions?

I would like to work with a discrete probability function $P[x\_]$ that only has the property that it is defined for $x\geq0$, such that Sum[P[x],{x,0,Infinity}] ...
1
vote
0answers
36 views

Problem in importing function in NDSolveValue

I have a code for solving a system of 2 differential equations (sol1). Given that what's inside is a bit heavy, I define functions so that I can call them. My issue is that when I write everything ...
1
vote
0answers
66 views

Is there a way to order the QZ(or Gen. Schur) decomposition in mathematica?

Let's imagine I have two matrices $\Gamma_0$ and $\Gamma_1$. The SchurDecomposition function in mathematica will return matrices $Q,\Lambda, Z, \Omega$, such that $...
1
vote
0answers
70 views

Recursive functions with integrals/derivatives return wrong results

I have the following recursive functions: ...
1
vote
0answers
46 views

Multiple Square Bracketed Function definition

I am familiar with the typical way of defining a function--such as f[x_,y_]:=x+y but I have not found a discussion of definitions such as ...
1
vote
0answers
70 views

Function that Generates all Normal Subgroups of a Group

I am trying to create a function which, given a group structure, generates a list of all the normal subgroups contained within it. But I am not sure how to proceed. For now, I have the following: <...
1
vote
0answers
38 views

Store a matrix function for a particular value of its argument and use it without calling the function again?

Suppose I have defined a function as: f[x_]:={{x,x^2},{x^3,x}}; g[x_]:=f[x][[1,2]]+f[x][[2,2]]+f[x][[2,1]] Now if I want to calculate ...
1
vote
0answers
73 views

Take double integral

I'm trying to take a double integral: $\int_0^1\int_0^1 \left[\left(\tilde{B_V}(\alpha_V) \{||\}(\tilde{B_V}(\alpha_V) > \tilde{B_A}(\alpha_A) - 1 - \theta(1 - r))Z\right) + \left(\tilde{B_A}(\...
1
vote
0answers
139 views

Newton's method for nonlinear equations system

My code is: ...
1
vote
0answers
75 views

Dynamic Passing Function as Argument

...
1
vote
0answers
77 views

Possible bugs with InverseFunction in version 11.2

See these two examples ...
1
vote
0answers
48 views

How to handle functions with varying number of arguments

Suppose I have a function that depends on variables $x_1, ... , x_n$. For concreteness I may have $f(x) = v \cdot x$, with $v$ a certain vector. Now I want to do certain operation with this function, ...
1
vote
0answers
86 views

Mathematica can't evaluate the function at the point where it is smooth

Suppose the function ...