All Questions

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

Creation of a Function

I am trying to create two functions but I am having trouble. The first consists of converting degrees Fahrenheit to Kelvin using this formula (F - 32)*(5/9) + 273 ...
4
votes
1answer
49 views

Inverse of vector-valued function

Having a differentiable function $f : \mathbb{R}^2 \longrightarrow \mathbb{R}^2$ such that $\det D(f)$ (Jacobi determinant) does not vanish. How can we get the inverse function $f^{-1} : \mathbb{R}^2 \...
16
votes
2answers
292 views

Improving Performance of an XY Monte Carlo

I normally write my Monte Carlo codes in Fortran for speed, but I was doing some quick and dirty work and wrote one in Mathematica for the XY model on a square lattice (see Kosterlitz-Thouless ...
0
votes
1answer
84 views

Automating a large operation by making a function

I would like to automate the following operation. To be transparent I shall put my code into separate chunks and explain the process. Suppose I have the following: ...
0
votes
0answers
44 views

Function works outside For loop but not inside, and loop fails spectacularly

I'm building two lists, each to carry a different representation of the same set of objects. One list, list2, is constructed first; then the second list, ...
3
votes
2answers
86 views

Function with string explanation for its arguments with equal signs [duplicate]

I want to write a function using string as explanation for its arguments so that the function becomes intuitive for new users. For example, I want to write a function to compute BMI (just for ...
0
votes
0answers
60 views

How to list all the possible functions of given structure?

I can run this command : Tuples[{ Tuples[{x, y, z}, 2], {a, b, c}}] to list all combinations that looks like: ...
3
votes
3answers
343 views

How do pure functions differ from functions defined with SetDelayed?

Why is it that f[{{a_, b_}, {c_, d_}}] := (a z + b)/(c z + d) will return (2 + z)/(4 + 3 z) on evaluating ...
1
vote
1answer
36 views

Defining a new function to evaluate a previously defined function at specified parameter set, using fewer inputs? [closed]

I have a function in three variables: f[var1_,var2_,var3_]:=expression[var1,var2,var3]; I want to reduce this to g[var3] and ...
2
votes
1answer
49 views

Define a function with specific permutation properties

I want to define a function evaluate[f_[x__]] which acts on an arbitrary function f[a,b,c,d]. The function ...
0
votes
1answer
38 views

Tracking back a variable corresponding to an output

I have a function: ...
0
votes
1answer
46 views

Preventing an output of a function from being assigned a value

Say I have a function Example[n_Integer]:=n{x,y,z} Example@4 {4 x, 4 y, 4 z} Now, let us assign some values to ...
0
votes
0answers
20 views

Error while defining custom matrix function

I'm trying to define a custom matrix Ry with a parameter x, in Mathematica. ...
0
votes
1answer
52 views

Definition of complex conjugate?

I came across the following way of defining complex conjugate in mathematica [a]: SuperStar[y_] := y /. Complex[u_, v_] -> Complex[u, -v] I am able to ...
0
votes
0answers
23 views

Redefining the inbuilt function and its derivative [duplicate]

I want to redefine the DiracDelta functions and its derivatives. I am successful at redefining the DiracDelta function but not ...
11
votes
2answers
400 views

Strange behaviour of Check

...
0
votes
1answer
49 views

Passing a function into another function that integrates the 1st function [closed]

for example I have a = Sin[t] and then I have f[a_] := Integrate[a, {x, 0, pi}] Will it work? Will the ...
0
votes
2answers
71 views

How to write a function of a polynomial

I will illustrate my problem with this example: I want to make a function which, given a polynomial, gives me the value of the integral $\int_0^1(ax+bx^2)dx=a/2+b/3$. Therefore, in this example, I ...
3
votes
1answer
31 views

Applying pure function to rotate the label in a BoxWhiskerChart

Data is available from here https://www.ocr.org.uk/Images/400305-large-data-set-lds_1-h630-2018-h640-2018-2019-pre-release-data-mei.xlsx ...
5
votes
5answers
351 views

Replacing the Zeros of One List by the (i-1)th Element of Another List

My goal is to replace the zeros of one list with the (i-1)th element of a second list. For example, if list1 = {0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0} and <...
3
votes
2answers
643 views

What is wrong with this procedural function to add numbers 1 through n? [closed]

I am trying to write a function to add numbers from 1 through h: function[h_]:= x=0; For[i=1, i=<h, i++, x = x + i]; Print[x] But I am getting some strange ...
0
votes
0answers
24 views

How attribute a restrition for a variable inside a function

I have a function like this way: f[x_] := x + 2; In[148]:= f[b + 2] Out[148]= 4 + b How to impose a condition that the variable ...
1
vote
3answers
75 views

How to make functional rules not depend on an argument?

Consider the following: rule = f[x] -> Sin[x] if I now do, say: f[y] /. rule this does not work, because the rule wants ...
0
votes
0answers
38 views

Imposing conditions on argument for a function definition

Suppose that I wish to use "Piecewise" to merge two different interpolating functions (obtained via a NDSolve of some ODE), defined over negative and positive arguments respectively, like: ...
1
vote
1answer
49 views

Creating a function that performs a “`DotExpand`”

When you make a Dot[a,(a+b+c)] the output will be: a.(a + b + c) I want to make a function that expands the dot product, for ...
3
votes
2answers
93 views

Creating a function for a traditional output for integrates

I'm creating a function (HInt) for a traditional output for integrates. For example: HInt[f, x] If I specify just the domain, ...
0
votes
1answer
67 views

Which built-in DistanceFunction options does Mathematica offer? [closed]

The documentation is not specific at all about which built-in distance functions are implemented in Mathematica: https://reference.wolfram.com/language/ref/DistanceFunction.html For instance, I ...
0
votes
0answers
25 views

Make traditional output for integrates [duplicate]

I want to perform a traditional output for integrates using a new function that I called HInt: ...
0
votes
0answers
31 views

Using `Format` to create a notation for derivatives [duplicate]

I want to create a new function that I called HD to give a visual way to see the derivatives. For example: The objective is apply the function ...
0
votes
0answers
28 views

How to verify if all elements of a list are equal [duplicate]

I have a result in a list form: {1,2,3,4,5,6} How to verify if the elements are equal? If I use Equal doesn't works with a list....
2
votes
3answers
234 views

How to apply `Length` in all elements

I want to apply Length in each element from a list. For example: My list is: {1,{2,3},{4,5,6}} How to apply ...
1
vote
3answers
76 views

Creating a function that checks whether input is an integer (in the mathematical sense)

I am creating an alternative function of IntegerQ[] function. Now I don't want any output. I just want my function to check whether this is integer or not. I'm ...
0
votes
0answers
38 views

Function that once called “erase” every other definition of my notebook

I encounter a really weird effect in Mathematica and I don't know what the wrong thing is nor how to correct it. I work with vectors of four components and I have a minimal set of definitions that I ...
9
votes
1answer
207 views

Force evaluation of user-defined function

Consider a function that sorts its arguments based on a function called order ...
1
vote
2answers
68 views

Defining a function that treats input as two unordered lists

I have a function f2 I'd like to code into Mathematica with the property that it takes in two lists, treats those lists as unordered, and maps to a symbolic value. If I were instead using a function ...
1
vote
3answers
77 views

How to write a discrete function which depends on pairity

Consider the following function for example $$ k = \sum_{n=0}^{\infty} \Gamma(\frac{n+1}{2}) y(n)$$ $$y(n)=\cases{2^{\frac{n}{2}} \text{ even}\\ 2^{\frac{n+1}{2}} \text{ odd}}$$ How can such function ...
5
votes
1answer
158 views

Defining multiple functions

I have a matrix with 4 elements that I want to turn into functions without explicitely defininig all the functions "by hand": ...
1
vote
2answers
89 views

Define a partial derivative of a composite function

I would like to define the function $ \dfrac{\partial}{\partial y}\left(\dfrac{f(x,y)}{g(x,y)}\right)$, for example ...
0
votes
2answers
95 views

How to compute the density of a Inverse Wishart Distribution?

How does one compute the density of the inverse of a Wishart distribution in mathematica? The MultivariateStatistics package only has the Wishart density, and not the inverse Wishart... Any help ...
0
votes
0answers
24 views

Trouble restricting function images

I am following this book https://www.amazon.com/exec/obidos/ASIN/1558606378/ref=nosim/ericstreasuretro with mathematica and I'm having some trouble on my way: 1) Consider the function ...
1
vote
0answers
53 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 ...
0
votes
0answers
40 views

Removing numerical instability in plots of functions over large domains

suppose you have a large domain you wish to plot a function over, which depends on numerical values usually around or above you machine precision e.g. ...
1
vote
2answers
56 views

Switch applying tests to forms

Is it correct that the Select equivalent of Cases is missing for Switch? I mean a function <...
0
votes
1answer
74 views

ListPlot with gradient

I have a dataset in which each element is a list of 3 numbers eg. data={{0,0,0},{1,2,0.7},{3,4,2.3},{3,4,3.3}} I'd like to make a 2 dimensional plot in this way: ...
0
votes
0answers
54 views

Representing an interpolating function

I just want to figure out how to "represent" or to inject an interpolating function into a numerical calculation. So, suppose i have an interpolating function $int$ and then i want to use NDSolve or ...
2
votes
1answer
84 views

Creating a bound method (partial function application)

I want to bind arguments to methods (e.g. for use in OOP creating a bound method--what Java just calls a method). I realized this is basically just a partial function application. Now I want to make ...
0
votes
0answers
55 views

Constructing a user function with an integral

Maybe this is a basic task to perform but I haven't found any literature. I am performing a convolution of two functions: ...
3
votes
1answer
67 views

How to create a function that eliminates repeated elements

I want to create a function that eliminates repeated elements from a list without changing the order. For example: ...
2
votes
1answer
49 views

How to declare derivatives of a multivariable function as real in order to get Re and Im part of the expression?

Re and Im work properly, with appropriate assumptions, in the example like this ...
2
votes
2answers
58 views

Construct a function like Coefficient

I'am trying to construct a function that will work like Coefficient as an exercise. ...