The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [functions]

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

234 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
0answers
587 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
122 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
128 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
91 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
72 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
143 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
451 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
0answers
70 views

If someone would want to think about the question: mathematical-optimization “Banknote”

I solved the puzzle of IBM Ponder This September 2019 by my code written with mathematica. I would like to share this code after the solution that will come as soon, and discuss it. In the meantime, ...
1
vote
0answers
34 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
1answer
59 views

How to get ReplaceAll to happen before function call

I have a problem I am attempting to solve with NMinimize. I have a scoring function, which will give me a final score. The problem has many variables, so instead of having them as parameters, they ...
1
vote
0answers
93 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),\...
1
vote
0answers
51 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
26 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
47 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
30 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
73 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
55 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
50 views

Changing parameter in a _Mathematica_-defined function

I would like to use EllipticTheta with the sum running on the integers with a specific step. Is there a way to do that? To be more precise, I am trying to expand the following function $$\Theta_{\...
1
vote
0answers
73 views

Using While properly

I am trying to make While[] work with function results and evaluate them at the same time. ...
1
vote
0answers
24 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
39 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
36 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
33 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
52 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
64 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
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
63 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
114 views

Newton's method for nonlinear equations system

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

Dynamic Passing Function as Argument

...
1
vote
0answers
73 views

Possible bugs with InverseFunction in version 11.2

See these two examples ...
1
vote
0answers
47 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
81 views

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

Suppose the function ...
1
vote
0answers
54 views

Operator on a multivariable function in a sum

I need to define an operator that does as follow for any function $h_m$. $\qquad O[h_m](k,M,b,l_{max})=\sum_{l\neq (0,m)}^{l_{max}}il \left (h_l(k,M,b,l_{max}) b_{m-l}(k)- c_l\partial_k h_{m-l}(k,M,...
1
vote
0answers
79 views

Using Two Arguments on the Same Function

I'm having some trouble wrapping my head around how I would go about using two arguments in one function. In the first section of the code below, I have scraped some "tweets" on the Seeking Alpha ...
1
vote
0answers
134 views

Solve a system of time dependent equations where the Unknown variables are time dependent functions

I have to solve a system of time dependent equations ( $eqf1,eqf2,eqf3,...eqm5,eqm6$, inside the equations there are known time dependent functions) where the Unknown variables ($f32,fe3,me3...f47,m47$...
1
vote
0answers
68 views

Computationally Employ Sum over Ordered Partitions?

I have the following function defined, with two inputs $g$ and $h$: ...
1
vote
0answers
87 views

Colorize a 3D plot with given function of dependent variable and add a bar legend

I want to colorize a surface $u(t,x,y)$ generated by Plot3D with a given function of $u$. For example, ...
1
vote
0answers
52 views

Same functions in plot but in different ways get different graph

According the documentation in Wolfram, Plot uses in below way, Plot[f,{x,xmin,xmax}] So, there is my original code. ...
1
vote
0answers
70 views

Very slow Absolute value computation (Improvement need)?

I have to compute the following absolute value. When computing the absolute value of the two pieces separately, everything works fine. When summing up and then evaluating the Abs of the Sum, the code ...
1
vote
0answers
142 views

Find the relations between two parameters

...
1
vote
0answers
551 views

Derivative of Sign[x]

From wikipedia the derivative of the Sign[x] function has the following property: $\qquad \frac{d}{dx}{\rm Sign}[x]=2\delta[x]$ Where $\delta[x]={\rm DiracDelta}[x]$. It seems that Mathematica ...
1
vote
0answers
39 views

FinancialDerivative with a delayed start

Using the function FinancialDerivative with an Asian style option doesn't seem to have a parameter that allows for a contract that averages over a specific time period in the future rather than over ...
1
vote
0answers
90 views

Convolve returns false result

Bug introduced in 9.0 or earlier and fixed in 10.0 I tried to convolve sin with sin and got this unexpected result: Convolve[Sin[x], Sin[x], x, y] (* 0 *) Now I ...
1
vote
0answers
53 views

Different Derivative's output with ComplexExpand

Consider this expression f = Abs[ x + I ] with this assumption $Assumptions = Element[x, Reals] Now there is something ...
1
vote
0answers
77 views

Plotting Asymptotic Series

I apologise for being always here asking for the same questions, but I need to learn. I have to plot this series $$\frac{\pi}{2} - \frac{\cos x}{x}\left(\sum_{k = 0}^{+\infty} (-1)^k \frac{(2k)!}{x^...
1
vote
0answers
47 views

Extracting elements with a certain criteria from a pre existing list

Here I take just a random list of triples of size 10 ...
1
vote
0answers
102 views

ListDensityPlot erroneously showing flat regions (NOT plot range issue)

I have a dataset (listed below). I'm trying to plot the dataset using ListDensity plot; ...
1
vote
0answers
283 views

Defining a piecewise function where the conditions are points

I am trying to define the following function in Mathematica: $$pw=\begin{cases} x y \cos \left(\frac{1}{x^2+y^2}\right) & (x,y)\neq(0,0) \\ 0 & (x,y)=(0,0) \end{cases}$$ I want to use this ...
1
vote
0answers
215 views

An array of functions

I need to define an array which every entry is a function. To be more specific, I want to solve the equation: $$\frac{d \rho}{dt} = -i[H, \rho] + L[\rho]$$ in which $\rho$ is a matrix. This is a ...