Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [attributes]

Questions on attributes of functions.

2
votes
2answers
60 views

How can one eliminate results in which symbols are assigned constant values?

As an exercise (pertaining to my posting Perform a constrained integration over $[-1,1]^6--yielding a "separability probability"), I issued the command ...
1
vote
2answers
102 views

Computation with arrays of numbers

My code is m = RandomVariate[NormalDistribution[], 100]; c = 0.1; f1 = RandomVariate[NormalDistribution[], 100]; F = Sqrt[c]*m + Sqrt[1 - c]*f1; I would like to ...
2
votes
1answer
88 views

Defining an operator with given properties

In symbolic derivations with Mathematica, one often needs to define an operator with some desired properties, which will be used to stand for a general function or transform. For example, I would ...
0
votes
1answer
18 views

ScrollPosition Synchronization

Two separate Panes. Pane-1 with vertical scroll bars and Pane-2 no scroll bars. Need to sync the scrolling between them. When scrolling Pane-1 vertically, need to have pane 2 automatically scroll to ...
2
votes
1answer
55 views

Fast and Listable Piecewise function

I am writing a simulation where I have an array with ten columns and on the order of millions of rows, for which I need to iterate on the order of ten thousand times, making computation time a major ...
3
votes
1answer
90 views

HoldFirst being overridden by Activate [duplicate]

So here's the problem a=1;a=2 works because of the HoldFirst attribute of Set, so that it ...
6
votes
2answers
147 views

Flat attribute : example I don't understand

I am just beginning to learn about attributes of function in mathematica. I saw the example "Flat". But there is something I don't get : ...
1
vote
1answer
70 views

Problem displaying Killing equations

What I'm trying to do is to compute the Killing equations and then solve them using DSolve to determine their solutions. I have a problem understanding where my Mathematica program doesn't work ...
0
votes
1answer
55 views

How can I get all the order of a list? [closed]

I have a list such as : {1,3,6}, then, I want to get all the orders of it, I do not know which function is easier. I have to try this code, but it is complex. ...
1
vote
1answer
72 views

Pattern matching on Orderless functions

I'm trying the following pattern matching command: ReplaceList[Hold[b + a], Hold[x___ + y___] -> {{x}, {y}}] And Mathematica returns: ...
1
vote
1answer
72 views

Pick the solutions that satisfy certain conditions

I have a large system of ODEs, and I find a large number of steady-state solutions. But many of them do not satisfy the condition that all the variables must have ...
6
votes
4answers
461 views

partial numerical evaluation

Context The following is an issue I have come across many times and still do not have a satisfactory solution for. The context of it is this. Let's say we have an equation, a linear ODE for the ...
2
votes
0answers
52 views

non listable plus and times [duplicate]

I am trying to create my own Plus and Times functions, which are identical to the built in ones with the exception that they are ...
4
votes
1answer
68 views

Subtle order-of-evaluation issues when pattern-matching with attributes

Related question concerning unrolling the tests that are shown below: Big and Little surprises when unrolling tests of pattern-matching and attributes Questions researched before posting this one: ...
3
votes
1answer
68 views

Big and Little surprises when unrolling tests of pattern-matching and attributes

Related question concerning interpretation of the substitutions: Subtle order-of-evaluation issues when pattern-matching with attributes Questions researched before posting this one: Orderless ...
1
vote
0answers
66 views

Is it possible to modify the behavior of Listable?

Is it possible to achieve Thread-like behavior using the Listable attribute either on a symbol or in a pure function (or ...
0
votes
1answer
56 views

Modelling non-commutative products, CenterDot problem

I am trying to model certain non-commutative, but associative, structures with Mathematica. As a notation for the product I take CenterDot and add the attribute Flat since the product is associative. ...
4
votes
1answer
87 views

Concerning the Attribute Flat

Suppose we have a function f with the Attribute Flat. From my understanding, the following command should return all possible ways of rewriting ...
2
votes
2answers
93 views

Make Times non-commutative only for a specific set of expressions

I'm making a small hacky notebook and want to avoid using external libraries. In my notebook, I'd like multiplication to be non-commutative only for a particular family of expressions whilst still ...
4
votes
1answer
98 views

What are Flat Attribute best practices? [duplicate]

I would like, as an example, to build a Times-like function. Take the following example ...
3
votes
1answer
128 views

Define a distributive function?

Here is a related question, but not quite what I'm after. I would like to define a function f[x_] that has the distributive attribute, such that: ...
4
votes
1answer
75 views

Listable function behaving in an unexpected way

For example, if I define a function like this: SetAttributes[func,Listable]; func@{{1,2},{3,4}} it gives the result like: ...
13
votes
2answers
373 views

Why is listable not an attribute of the Set function?

The following is a list of attributes for the Set function: Attributes[Set] ...
0
votes
0answers
49 views

Why Plot is not a listable function but still take input as a list?

By using Attributes I can see that the function Plot is not a Listable function. ...
10
votes
1answer
205 views

FullForm of b/c and c/b with different order

I am studying Mathematica myself and doing some exercises for improvement. Question: Try to guess the internal forms of b/c and ...
4
votes
2answers
82 views

Error changing Attribute of ParabolicCylinderD after unprotecting

This is related to why-changing-the-order-of-format-causes-error but it seems to be a new issue so posting a new question. Of all the symbols that I changed its ...
7
votes
0answers
65 views

What's with the weird HoldRest Attribute of ParallelMap?

Bug introduced in 10.0 or earlier and persisting through 11.1 I have noticed some odd behavior of ParallelMap: When the list, that is mapped over, is not inserted ...
2
votes
0answers
102 views

What is the correct usage of HoldFirst?

I encountered a situation where using HoldFirst seems to do the trick for the specific task, but I am uncertain about the proper use of this attribute. Consider ...
0
votes
1answer
38 views

Why does ReplaceAll change the ordering of expresssions?

I wrote the following replacing statement: ...
10
votes
2answers
440 views

Is it safe to Unprotect everything? What are the implications?

What is the reason for built-in symbols to be Protected? What happens if I Unprotect built-ins and add my own ...
8
votes
2answers
194 views

Confusion about HoldFirst attribute of Set

Set has the attribute HoldFirst. Expectedly the following does not work, i.e. it does not assign the OwnValue of 3 to x: ...
5
votes
1answer
30 views

How to mock up an “NHoldSubset” property

I have a numeric function f for which I would like the action of N to act only on the last two arguments (and more generally, on ...
4
votes
1answer
77 views

Chop in Piecewise function

I'm trying to implement a complex square root with branch cut on the negative real axis; the (real part of the) second argument determines which branch to take. ...
3
votes
2answers
57 views

ClearAll except a data table

How can I ClearAll variables and tables, except a table of data? Suppose the data table is WRR. ...
8
votes
2answers
129 views

Recursion depth exceeded in pattern matching with attribute Flat

I am defining a linear associative multiplication operation Mult[]: ...
8
votes
1answer
194 views

Why can I define N[MySymbol] := …?

As far as I understand, I cannot define the values of built-in functions: Sin[Cat] := Dog will result in error. This is because all built-in symbols have attribute <...
3
votes
1answer
120 views

Make input function listable

I have a function taking a function as input as well as other values, e.g. f2[f_, a_, b_, c_, d_] = f[{a, b}, c, d]; Of course, the behavior differs for f1 being ...
0
votes
1answer
50 views

Set attribute of a function to be a specific equation that it fulfills

I would like to define a function f(x,y,z) by its attribute, namely by the specific equation f(b,c,d)f(a,b+c,d)f(a,b,c)=f(a+b,c,d)f(a,b,c+d) for all a,b,c,d. Is it ...
11
votes
0answers
155 views

Alternatives and the Flat attribute

When a head has the attribute Flat then the pattern matcher is able to pick out a sublist of its arguments, even though the structure doesn't match: ...
0
votes
0answers
27 views

Customise a combination of Quiet and Block [duplicate]

I would like to define a function that shuts up all warnings. My first go was: Silence[x_] := Block[{}, Quiet[x]]; I have also tried working with pure ...
12
votes
3answers
368 views

Does function call via @ ignore HoldFirst attribute?

I was trying to test whether using func[x,y] is the same as func[#,y]&@x: ...
12
votes
1answer
256 views

Why isn't Orderless an Attribute of And?

In standard logic And is a commutative operator. Still, in Mathematica, And doesn't have the ...
2
votes
0answers
82 views

Internal`LocalizedBlock doesn't support Protected symbols and emits weird messages

Protect[x]; Internal`LocalizedBlock[{x[0]}, x[0] = 1; x[0]] ...
5
votes
3answers
158 views

Why does `Block` reset `Attributes`?

Not even "formal symbols" such as \[FormalX] are guaranteed to always be symbolic. Their Protected argument is forgotten when ...
14
votes
1answer
299 views

How to define homogeneous functions that respect Euler's theorem of homogeneous functions?

A homogeneous function of degree $k$ is defined as a function that observes the following specification rule: $f(a x_1, a x_2, ..., a x_n) = a^k f(x_1, x_2, ..., x_n)$ (see Wikipedia entry, ...
9
votes
1answer
139 views

About OneIdentity

The document says: OneIdentity is an attribute that can be assigned to a symbol f to indicate that f[x], f[f[x]], etc. are all equivalent to x for the purpose of pattern matching. Consider the ...
0
votes
1answer
82 views

`Plus` wrongly applies `OneIdentity` to erradicate itself in `Plus[Power[_, 2] ..]`, unreproducible

I was trying to match some polynomials, but this is weird: ...
12
votes
2answers
164 views
0
votes
0answers
150 views

`{Protected, ReadProtected}` System symbols give “Set::write: ”Tag * in *[v_] is Protected" on first try

Run Quit, then Unprotect@AbelianGroup; AbelianGroup[v_] = 0; Protect@AbelianGroup; where instead of ...
2
votes
1answer
65 views

What Heads do not have the attribute NumericFunction, but still give True in NumericQ?

The following expressions give True in the NumericQ test: ...