A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

Questions tagged [pure-function]

Questions about implementing or applying functions which: (1) always yield the same result for the same input, (2) are independent of outside information, and (3) produce no side effects.

16 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
0answers
149 views

Third syntax version of LogitModelFit: unexpected result of “BestFit”

The third listed syntax version of LogitModelFit allows one to specify input in a simple way: Only a design matrix (with a row of values of the explanatory input ...
4
votes
0answers
48 views

Bug with LinearRecurrence and Slot/SlotSequence?

The code below runs without any error: LinearRecurrence[{##}, {1}, 5] Each term is the previous term squared, times the index of the previous term. If the ...
4
votes
0answers
74 views

Wrong autogenerated package from notebook containing #key and Part as subscript

Bug introduced in 10.0.0 and persisting through 10.1.0 or later Mathematica v10.1.0, under Windows 8.1 x64 Mathematica v10.0.2, under Windows 1) Define a function in an initialization cell: ...
3
votes
0answers
133 views

How to overload and compile pure functions operating on associations

I am writing a small package for myself for operating on zonotopes. I am storing the generator matrix and the center of the zonotope in an association. I decided to write a small constructor: ...
1
vote
0answers
33 views

Issues with Manipulate (or variable assignment)

I am working to take a large manipulator I have built and generalize it, but I keep running into some variable assignment issue. I made a short example of my issues below: Set up: ...
1
vote
0answers
52 views

Mapping over array/matrix the efficient(compact) way

Update In short, I have myCAans[[1 ;; 5]] like this: {{0, 0, 0, True, 0, 0, 0, 0, True, 0, "T0", 39}, {0, 0, 0, True, 0, 0, 0, 1, True, 1, "B", 101500}, {...
1
vote
0answers
87 views

Time-stepping an equation in Mathematica

I have an iterative integral equation of the form $$n(k,t+dt)=n(k,0)+dt\int_{0}^{\infty}dp\int_{0}^{\pi}d\alpha\int_{0}^{2\pi}d\beta\int_{0}^{\pi}da\,p^{2}q^{2}\sin(\alpha)\sin(a)\frac{(n(p,t)+1)}{\...
1
vote
0answers
112 views

Using Solve without introducing extra variables

First post here. I've tried searching for an answer for this for a few days now, but it seems the search terms (solve, slot, etc) are too generic to be helpful. I'm struggling with understanding how ...
1
vote
0answers
102 views

How to Fold (FoldList) this in a more compact (efficient) way?

Example code: x = Table[something[i], {i, 5}] Table[Fold[f1[#1, f2[#2, a], a] &, x[[i]], {c1, c2, c3}], {i, Length[x]}] This above is just an example. I ...
1
vote
0answers
218 views

Defining an operator

Let s be a positive integer and let DifferenceDelta be this function with step = 1. Define <...
0
votes
0answers
43 views

List of function - basis

I would like to define list of function (make polynomial basis as a set of the functions), and then evaluate value of first/ second function in the set. I have made set of the fuctions that I have ...
0
votes
0answers
171 views

Commutator of differential operators

Let $P_x = \frac{\hbar}{i}\frac{d}{dx}$, after specifying the commutator relation symbolically $[X, P_x] = i\hbar$, I can ask Mathematica to calculate commutator algebra. My question: is there a way ...
0
votes
0answers
52 views

How to protect pure functions

I have some pattern functions and pure function in my package. If i set attributes Protected and ReadProtected. My pattern ...
0
votes
0answers
50 views

Max and Mean command produce the same result

I tried to find a point that is nearest to two other points, using both "Max" and "Mean". I wonder why both produce the same value. I tried changing the input, but the results by using "Max" and "Mean"...
0
votes
0answers
38 views

Error in storing the output of a module (subroutine) into an array

For a physics application, I have to compute components of a rank-4 tensor, the Riemann tensor. I do this using a module (subroutine) which looks like this ...
0
votes
0answers
60 views

What makes items with head `Function` different?

I apologize beforehand for the muddleheadedness of this question. It reflects the fact that I'm trying to interpret outward "behaviors" of Mathematica expressions without having any understanding of ...