Questions tagged [functions]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
36 views

What to input for Nested ANOVA on Mathematica (SS-Subgroup B)

Does anyone know how to run a nested ANOVA on Mathematica, given a dataset? For example: PCB Level 1, Sample 1: {1,2,3}; PCB Level 1, Sample 2: {4,3,2}; PCB Level 2, Sample 1: {1,5,7}; and PCB Level 2,...
4
votes
1answer
102 views

How to find the operand of a sinusoid?

For a function $\sin[2x]$, the operand is $2x$. If we want know the value of the operand by hand, the function is simply $\arcsin(\sin[2x])=2x$. How to do this with Mathematica? Here's what I tried: ...
0
votes
2answers
80 views

Use Alphabet[] as a variable in a function

I'm trying to figure out if I can use the letters contained in Alphabet[] as variables for a function. As a simplified example, I'd like to do something like: ...
3
votes
1answer
147 views

Trying to understand Electromagnetism using mathematica

I was wondering if there was a possible way to animate electric and magnetic field lines using Mathematica? I'm currently doing a physics major and taking an upper level electromagnetism course. I'm ...
4
votes
3answers
128 views

How to implement an integration filter on arrays?

I have the discrete integration filters: $$y(n) = Ax(n) + By(n−p) , \text{$A$, $B$ real constants, $p$ positive integer}$$ EDIT: in the initial version of this question I focussed only on the case $...
8
votes
2answers
106 views

How can I reduce the number of function calls in my code?

Consider the code shown below. I was expecting e1[x1_, x2_, x3_] to be called same number of times as g1[x1_, x2_, x3_], but it ...
0
votes
1answer
47 views

How to turn a matrix into a 'function'? [duplicate]

I have some codes to turn a set of equations into a matrix. Suppose the matrix Lis expressed in terms of variables $\epsilon$, $K$, $M$, and I want to make a ...
1
vote
1answer
44 views

Nearest returning s different length of output with same input data [closed]

I am trying to classify a list of 2D data points into different clusters based on the Euclidean distance between the points and the clusters' centroids, i.e. the point will be classify into the ...
0
votes
3answers
111 views

Function which returns a symbolic jump between two ordinates, e.g. $[f(a,b,c)]^+_- = f(a^+,b^+,c^+)-f(a^-,b^-,c^-)$

I want to create a function in Mathematica which accomplishes the following: $$[f(a,b,c)]^+_- = f(a^+,b^+,c^+)-f(a^-,b^-,c^-)$$ where $f$ is any function (has 3 arguments above but this need not be ...
1
vote
1answer
50 views

How to Double integrate a function Separately?

I have function f[x,y] where i need to integrate f[x,y] with x first and then later i need to integrate that f[x,y]dx with y. I will be getting f[x,y]dx from another notebook after using Get["ffile"] ...
1
vote
1answer
62 views

Plotting average of a function

I plotted a function and a certain horizontal line as a benchmark. After time t = 2 my function goes below the line, which is ok. But I need to show when the AVERAGE of this function goes below the ...
3
votes
1answer
133 views

How to make a discontinuous function a continuous function?

I want to make function a[t] a continuous which has indeterminate form at some points. ...
1
vote
0answers
51 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
40 views

Why Head of Integrate of a expression is not Integrate? [closed]

I was checking TreeForm of some expressions, What i'm thinking is TreeForm will give picture showing the main function acting in expression at top and sub main functions and so on and at the end only ...
4
votes
4answers
198 views

How can I plot the two functions below with same color for each value of k?

How can I plot the two functions below with same color for each value of k? ...
0
votes
1answer
78 views

Limit of a two variable function at the origin

How can I show that the limit of the following function, when the variables {x, y} tend to zero, is zero? Mathematica gives the error {x,y} is not a valid ...
5
votes
1answer
226 views

Pass arguments to the list of functions?

Suppose I have a list of functions: functions = {f, g, h, ...} And all of those functions are in form of f[x_ , y_]. For ...
1
vote
1answer
37 views

Function and patterns. FixedPointList doesn't work with function [closed]

There is a function: Clear[sort]; sort[{a___, b_, c_, d___}] := {a, c, b, d} /; b > c; It perfectly works with NestList function: ...
1
vote
0answers
38 views

What is wrong with this input? [closed]

I've followed the examples from the introduction to mathematica for math students: https://www.wolfram.com/language/fast-introduction-for-math-students/en/more-plots-in-2d/ ...
1
vote
1answer
45 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
64 views

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

Lets say I have the following function ...
0
votes
1answer
83 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
46 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 ...
1
vote
2answers
44 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
76 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
56 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
96 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
61 views

NestWhile with input as a list [closed]

I'm wondering how I can use NestWhile if my input is a list: NestWhile[function,{1,2,3,4},...] For example, I want ...
1
vote
1answer
39 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 ...
0
votes
1answer
50 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: ...
3
votes
2answers
157 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
52 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
33 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 ...
2
votes
2answers
194 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
99 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
55 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
40 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
53 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
30 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
30 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
63 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
36 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
48 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
43 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
100 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
75 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
36 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
40 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
48 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
603 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 ...

1 2
3
4 5
53