We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [function-construction]

For questions on writing functions (pure or using Set/SetDelayed) for any purpose, including the features that may be incorporated in those functions, such as options, patterns and conditions.

Filter by
Sorted by
Tagged with
0
votes
0answers
48 views

What means the definition F[t_?NumericQ] :=…? [duplicate]

I've come along a function defined in this way: F[t_?NumericQ] := NDSolve[{-u''[x] - u[x]/x == -t^2 u[x], u[x0] == x0, u'[x0] == 1}, u, {x, x0, x1}] What does ...
0
votes
0answers
110 views

Best practices for breaking up functional blocks?

Say I have a main function that does some job, and I'm only interested in the final result of ans, i.e., the local functions are not important and produce no side-...
0
votes
0answers
138 views

How to create a reliable natural integral operator? [duplicate]

Natural integral is one of the antiderivatives of a function, for which the integration conctant is fixed in a natural way. It is defined as follows: $$f^{(-1)}(x)=\frac{i}{2\pi}\int_{-\infty}^{+\...
0
votes
2answers
88 views

Eigenvectors inside a maniupulate function

I am trying to make a physics application and it requires that the eigenvectors be taken for a 3x3 matrix. It is my intention that Mathematica never have to deal with the matrices symbolically. ...
0
votes
0answers
232 views

Using Table[ ] vs using Do[Append [ ] ] [duplicate]

Is it generally better/faster to use the Table function over using Do[Append []]? For example, I have this piece of code: <...
0
votes
0answers
120 views

creating some smooth density functions

I would like to create some density functions based on some distance measure $D$. As a base density function lets say I have a Gaussian density $f$ with mean $-1$ and variance $1$. I would like to ...
0
votes
0answers
42 views

Nested For Loops that result in no output [duplicate]

I am sure that this is not the most elegant code you will have seen, but I am trying to loop through an expression to see if FultonHarrisn] produces any outputs ...
0
votes
1answer
654 views

How to define a pure function with a Module?

I was not able to use a self defined (using Module and For loops) piecewise function to fit data. It seems that the problem is that I have to define a pure function. I would like to learn how to ...
0
votes
0answers
57 views

Question regarding function definition overloading / argument passing test [duplicate]

It is possible to define function dependently to passed argument type or condition this argument fulfills (somewhat like overloading): ...
0
votes
1answer
142 views

Strange function definition result [duplicate]

I'm relatively new to Mathematica, and I'm trying to define a function f(k) that would do the following: For any positive integer $k$, a finite sequence $a_i$ of fractions $\frac{x_i}{y_i}$ is ...
-1
votes
4answers
171 views

Converting an expression to function [duplicate]

I have the following problem. I current can automatically create the variable positionPayload, for instance: ...
-1
votes
1answer
82 views

I have several functions and how I know which one is the maximum in a certain range?

What I did are the followings These lines will generate a piecewise function pw which tells me the corresponding variable given an interval as follows: Now, I want to get: names of variable instead ...
-1
votes
1answer
45 views

Trying to define a function using indexed variables

I have a list of indexed variables, for example xx={x[2],x[4]} and an expression which is a function of those indexed variables, say ...
-1
votes
1answer
138 views

How to directly/conveniently use variable names as filenames?

Purpose To use variable name as file name conveniently. Code Special thanks to @J.M.'s tips! ...
-1
votes
1answer
76 views

Create a list of all functions given a set of arguments

I'm trying to examine some patterns on the permutation of elements in finite element functions. I'd like to create a list of all functions (256 of them) on ...
-1
votes
1answer
144 views

Dynamically show a specific number of the fractional part's digits

What is the fastest way to cut off all n z digits of the fractional part of a real number? (For example 12390.20934230) I came up with this so far: ...
-1
votes
1answer
46 views

Error in If function [closed]

I defined a function which roles as operator and. and[a_, b_] := If[a == true, b, false, "F"]; When the first implement is false the function outputs "F". For ...
-1
votes
1answer
92 views

serious problems with the double factorial of a defined function [duplicate]

I have calculations involving the following sum: Sum[Co f[2n]!! Cos[2(n-l)p] {n, 1, ∞}, {l, 0, n - 1}] where ...
-2
votes
1answer
91 views

Calculate column number from alphabetic column reference in Excel [duplicate]

Here's a fun brain teaser. Can you give me a mathematical equation to calculate the column number of a Microsoft Excel column, given the alphabetic column reference? Let X, Y, & Z represent the ...
-2
votes
1answer
111 views

Calculations in sequence

I have a this calculation, as you can see it is doing a calculation on each list, from list 1 to list 4 of the datafile. My problem is that using Mapthread to do this calculation does not work because ...
-2
votes
1answer
31 views
-2
votes
1answer
154 views

What is the practical use of the form g[x][y][z]?

Consider two functions, f and g. f is a curried function. It takes a single argument and ...
-3
votes
2answers
1k views

How to correctly call a Module within another Module?

How to embed and call the correct embedded modules inside another Module? Say: ...
-3
votes
1answer
689 views

Creating new functions using the names of existing ones

I have a list of functions {G[x_, y_], F[x_, y_], C[x_, y_]} how I can create the list of new functions such as ...
-3
votes
1answer
145 views

Function just gets mapped without any evaluation [closed]

Variable definitions are as follows: eBEG=0.; epBEG=0.; aNEXT = 0; eNEXT=0.; actStrain=0.; epTRIAL=0.; sigTRIAL=Range[0]; sigEND=Range[0]; Constant definitions ...
-4
votes
1answer
145 views

Programming Multipolar Expansions in Spherical Tensors

We have that a density matrix can be written in a basis of spherical tensors: $\rho =\sum _{K=0}^S\sum_{q=-K}^K \rho _{\text{Kq}}^{(S)} T_{\text{Kq}}^{(S)}$ for example for a 3x3 matrix, $S=1$, ...
-5
votes
1answer
128 views

Apply If function to FoldList [closed]

I have defined the following function: cpdz[c0_, m_,s_, r_, t_, n_] := If[c0 > 0, c0*(m*c0\s - (m - 1)*Exp[r*t/n]), c0*Exp[r*t/n]] for s I have a set of ...
-5
votes
1answer
71 views

What is this function aimed to do? [closed]

Table[Sum[tmatrix[[i, j]], {i, 1, 2}], {j, 1, 2}] apparently creates some sort of a table, and it evidently works on a matrix....although it is hard for me to understand what should it do beyond ...