Questions tagged [attributes]

Questions on attributes of functions.

Filter by
Sorted by
Tagged with
2
votes
1answer
28 views

Using the value of OptionValue to clear a list

I'm currently using OptionValue inside a function, the Option I passed to the function should be cleared, then populated with ...
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 ...
6
votes
1answer
98 views

Is it possible to make listable Experimental`NumericalFunction?

I have been playing a bit with the undocumented function Experimental`CreateNumericalFunction and I wanted to know if somebody found a way to make generated ...
3
votes
2answers
84 views

Construct a function that maps strings to functions

The main question is the last 5 lines (including codes) of this article. A[x_, y_] := Evaluate[ToExpression["x^2+y^2"]] A[3,4] Then the output becomes ...
2
votes
0answers
33 views

Mathematica: Remove argument from object with flat attribute

I have an object in mathematica with the attributes Flat and OneIdentity. I also defined the following substitutions: ...
6
votes
1answer
156 views

TreeForm and Unevaluated

Bug introduced in 8.0.4 or earlier and persisting through 12.0 or later Check this example: ...
1
vote
1answer
39 views

Mapping function into elements of Sum

I'm trying to set an attribute that's valid for a generic sum, where n and f are arbitrary. de[A_ + B_] := de[A] + de[B] de@Sum[f[i], {i, n}] Is this possible? ...
11
votes
3answers
692 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 ...
2
votes
2answers
125 views

Returning the argument of a function if the argument is not of the right type

Best to give an example. Let us consider the function AdjacencyMatrix. When we pass, say a matrix to it, we get: ...
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
1answer
120 views

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

I was trying to match some polynomials, but this is weird: ...
0
votes
0answers
24 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 ...
2
votes
2answers
70 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
115 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
113 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
30 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 ...
1
vote
1answer
80 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: ...
6
votes
2answers
167 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 : ...
2
votes
1answer
107 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
95 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 ...
1
vote
1answer
80 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
56 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. ...
6
votes
4answers
485 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 ...
1
vote
1answer
87 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 ...
2
votes
0answers
53 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 ...
9
votes
1answer
277 views

DiracDelta attributes

Is there any reason why DiracDelta isn't a NumericFunction but DiracComb is? I just ate a ...
4
votes
1answer
82 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
80 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 ...
8
votes
2answers
149 views

Recursion depth exceeded in pattern matching with attribute Flat

I am defining a linear associative multiplication operation Mult[]: ...
1
vote
0answers
77 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
72 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
3answers
484 views

How do I display function application with square brackets in traditional form?

If I type C[x, y] // TraditionalForm I get something that looks like C[x, y] But if I type ...
4
votes
1answer
93 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
122 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
125 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
238 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
81 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: ...
3
votes
2answers
263 views

Plotting attributes of vertices in WattsStrogatzGraphDistribution[n, p, k]

I have a graph WS = RandomGraph[WattsStrogatzGraphDistribution[n, p, k]]. I need to plot several characteristics of each v: the ...
13
votes
2answers
406 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
58 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
251 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 ...
18
votes
2answers
234 views

Orderless and Sequence

I just ran into the following subtlety. Let us consider a function f with attribute Orderless. ...
4
votes
2answers
83 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 ...
14
votes
1answer
374 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, ...
7
votes
0answers
67 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
118 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: ...
36
votes
7answers
4k views

How to differentiate formally?

I have been wrapping my head around this for a while now and I have not found a solution so far. I want to work with an arbitrary number of variables in Mathematica and use some built in functions. To ...
9
votes
2answers
204 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
31 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 ...