Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [functions]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
37 views

Sum index in function collides with input variable

When I enter the following: Clear["Global`*"] Func[f_, xx_] := Sum[D[f, xx[[s]]], {s, 1, 2}] Func[x^2 + y^2, {x, y}] Func[x^2 + s^2, {x, s}] The first function ...
-3
votes
1answer
54 views

How To Convert A Function Defined Using Mathematica's Block or Module Into Python [on hold]

Lets say I have the following function ...
0
votes
1answer
64 views

Transform function {a,b} ->{x,y} ; how to?

I have a 2D list of values that I want to transform/calibrate to another 2D list. I thought of using a predict function but I couldn’t get it to output 2 values. —...
0
votes
0answers
31 views

Delayed Rule right-hand-side mis-evaluation

Outline I am trying to create a rule that will give me a minus sign if the number of times A is applied on X is odd where A is some οperator and X a random quantity. Some of the configurations of ...
0
votes
1answer
34 views

Find the equilibrium between two functions [on hold]

I have to do all of my work in Mathematica for a class project, the current question tells us to find the equilibrium price between two functions. I can plot both functions at the same time, but ...
1
vote
2answers
40 views

Plot multiple solutions for different t terms

I want to integrate a a simple function for different t values. At the moment I have the following code; ...
0
votes
1answer
47 views

How to make a function linear

I have a linear function, say f, and an expression like f[3x^2 - 8 a y^2 + 4 z b] where I know that ...
2
votes
1answer
49 views

Average value of a function with two variables

How would I determine the average value of a function of two variables over two intervals, both of which have given bounds. Assume the function f[x,y] (below) has ...
0
votes
1answer
39 views

Average value of function of two variables

I'm wondering how to determine the average value of a function of two intervals, both of which have given bounds. Say the function f[x,y] (below) has bounds x,y=[0,5]. How would I go about this? I ...
0
votes
1answer
30 views

NestWhile with input as a list

I'm wondering how I can use NestWhile if my input is a list: NestWhile[function,{1,2,3,4},...] For example, I want NestWhile to stop until the second element of my output list larger than 3. How to ...
1
vote
1answer
38 views

Filter out terms that include any combination of F[X] and G[-X]

I have the following problem which is closely linked to a previous question I asked some time ago (Replacement rule for terms that are separated by operators?). In this specific instance, suppose I ...
-1
votes
0answers
27 views

a question about newton's method [closed]

I tried many times but I still don't know how to solve this problem. Please help me, thanks a lot.
0
votes
1answer
48 views

Calling a function with a vector doesn't work for me

I'm trying to create a simple function that generates a transformation matrix from the partial derivatives of two coordinate systems. It currently works when I have it written like this: ...
2
votes
2answers
130 views

Plotting 3D energy bands

I'm having a problem trying to plot a 3D energy band structure. Having a function of 3 variables (energy) for example: f[x_,y_,z_]:= Cos[x]+Cos[y]+Cos[z] What i ...
1
vote
1answer
48 views

How to define a function having many steps? [duplicate]

I can't transform a simple code into a function. The function should take an integer and return a list of digits in a factorial number system: ...
1
vote
1answer
30 views

Defining a function with For loop within For loop

h[n_] := For[i = 1, i <= n, i++, For[j = 1, j <= n, j++, g = g + i*j]; f = f + g;]; h[10] I want to define a function to calculate the Sum from i ...
0
votes
0answers
41 views

Define a function with a list as input [closed]

f[a_, b_, c_] := N[Max[Abs[list2]]], N[Max[Total[a], Total[b], Total[c]]]; f[list2] Trying to define a function with a list as input. In theory, this should ...
2
votes
2answers
178 views

Find peaks, max and min of an interpolation function?

I'm new in mathematica. I have a list of values and i don't know how to find some poitns, such as peaks, the max and min of an interpolation function. ...
2
votes
0answers
81 views

How to call an old build-in function in a new version of Mathematica?

In order to use the UnitStep of Mathematica 5.2, I have to install two different versions 5.2 and 11.3 at the same time because ...
0
votes
1answer
52 views

Why does the FindFormula result contain Abs in result?

If you look at the first example of FindFormula, why is the result Mathematica produces showing an Abs? Table[{x, N[x Sin[x]]}, {x, 0, 4, .3}] FindFormula[%, x] ...
1
vote
1answer
32 views

How to fix label position inside Manipulate?

I'm trying to make this manipulation. Initially, I use Text to add Happy Wedding. However, the function doesn't allow me to ...
0
votes
1answer
39 views

Chebyshev Generating Function on (x,y) with Arbitrary Unknowns

I'm trying to create a generating function in Mathematica for Chebyshev polynomials with arbitrary unknowns on x and y. So far I was able to come up with ...
0
votes
1answer
47 views

How to ask Mathematica to express variables in terms of each other in an implicit function

How to ask Mathematica to give $y$ in terms of $x$ in this function? Is there a way to obtain a closed form expression for $y$ in terms of $x$? $x=\frac{\left(y^4-1\right) \left(\coth (2 y)-\frac{1}{...
0
votes
1answer
22 views

error for NMinimize with Parameters in the form f[a_]:=NMinimize

I'm trying to write a function of a variable as the argument of a minimization where that variable comes to play. Here is the code : ...
0
votes
0answers
27 views

Creating a special product function

I am having trouble working with lists inside functions with Mathematica. Basically, I have a list of numbers and a special way to multiply them. I want to have a function that is able to create a ...
1
vote
1answer
52 views

Define Function explicitely with List as argument [duplicate]

Background There are multiple ways to define Functions. I would assume all methods are equivalent, and allow for the same options. However, I fail to find the ...
0
votes
1answer
31 views

Order of evaluation of variable

I'd like to control the order of evaluation in a multi-variable function. Example: Suppose I have the function: B[x_, y_] := x + y/x; If I try to evaluate ...
0
votes
0answers
33 views

Get R^2 value between interpolating functions and a list of points

I am looking to compare the degree of accuracy of a theoretical model by comparing my theoretical curve to my experimental data points. My theoretical curve is an interpolating function generated ...
2
votes
1answer
41 views

Use a list with single number for the second input of Table

As you see both inputs below give the same results. Is there any reason to use List[3] instead of just 3 in the first case? <...
3
votes
2answers
95 views

When do functions apply on lists and when they do not

I have read in my lecture notes on Mathematica that functions (in the general sense) can be applied to lists of data and that they can return new lists with data. I have tried this and I have got ...
2
votes
1answer
64 views

NonlinearModelFit won't fit to gaussian data

The form I'm using should be correct because when I input my initial guesses it plots a shape similar to my data. When I use NonlinearModelFit, the fit is not correct at all and is almost flat, then ...
0
votes
1answer
31 views

Derivative of function with large number of arguments

I have a function which depends on more than 30 parameters and I want to symbolically compute the derivatives with respect to the individual parameters. From the documentation of the ...
1
vote
1answer
39 views

I've been try to plot this function but it's not work. It's in the body [closed]

Plot[z^7 - 5*z^4 + 3*z^2 + 6*z - 4, {z, -2 - 2*I, 2 + 2*I}]
1
vote
0answers
41 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 ...
8
votes
2answers
583 views

return {} when the function is given {}

I have a function taking an array as argument and giving an output. However, sometimes my argument is {} (the empty array), then how can I get an output {} when my argument is {}? Actually, I want the ...
0
votes
1answer
67 views

Generalization of code is slower than particular case

I wrote the following Mathematica module: ...
1
vote
1answer
70 views

n derivatives on a function of n variables

I want to derive an expression with respect to each variable of a function $f: \mathbb R^n \rightarrow \mathbb R$. More precisely: $\left(\prod_{i=1}^n\frac{\partial}{\partial_{x_i}}\right) g(f(x_1,...
2
votes
1answer
35 views

Find the two least common positive values that divides both 40131 and 41405 [closed]

I'm completely new to mathematica, and got stuck on a question. If I needed to find the least 2 common dividers for 40131 and 41405, how would I code it? What i want is: Prime Factorization of ...
9
votes
2answers
369 views

Using vtx[] instead of vtx

There're two ways to generate a random tree as 1 and 2 below. Both work fine here. So what's the reason to use vtx[] instead of ...
0
votes
0answers
34 views

Mathematica Function Taxicab Numbers [duplicate]

I have spent days trying to compile this code and I cannot generate a list of taxicab numbers for the Hardy-Ramanujan Theory. Here is the module I wrote earlier: ...
1
vote
1answer
38 views

Printing Values Within a Function

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

Finding Closed form expressions for sums

I am working with the a problem where I need to compute some complicated sums, for which I first define the following inner product. ...
1
vote
1answer
88 views

Alternatives to using LinearSolve

...
0
votes
2answers
52 views

What are equations on mathematica and differences between these errors? [closed]

These are the three errors I was given. I so far wrote the code which was computing the polynomial interpolation but now I am asked to find those three norms: norm error mean norm error maximal ...
1
vote
1answer
38 views

FindInstance confused by CoprimeQ

For some reason when I type FindInstance[a + b == c && CoprimeQ[a, b, c] == True, {a, b, c}, Integers] Mathematica just immediately returns my input as ...
1
vote
0answers
20 views

strange behaviour of Eigensystem and Eigenvectors [duplicate]

consider this: ...
0
votes
0answers
45 views

Define a function including two solve solutions

I'm trying to combine the solutions coming from two NSolves and define a new function that I've to integrate. Basically I've defined two ...
2
votes
1answer
82 views

Quadratic form for specific formula as matrix reprezentation [closed]

So I have problem for specific formula to create Quadratic_form form from $$y = 3 + x_1 - 2 x_4 + 2 x_3 x_4 + x_2 (-x_3 + x_4) $$ as matrix \begin{bmatrix} 1 & 0 & 0 & 0 \\ ...
1
vote
1answer
34 views

Contour Plot not taking previously defined expressions?

I am new to Mathematica so my question might sound a bit silly, but I hope you help me. While learning ContourPlot, I have learned that when I use the previously ...
3
votes
2answers
87 views

How to get the nth value of a function with arbitrary number of arguments

I know that I can define a function of a List and get the nth argument like: f[x_List]:=x[[1]]+x[[2]] What if the argument of ...