# Tagged Questions

The tag has no usage guidance.

76 views

### Local modification of built-in command via UpValue

I have a computationally intense function f that returns a matrix. Sometimes only the diagonal is needed, which is faster to compute, thus there's a syntax for f to ...
38 views

### Setting derivative of function equal to 0 at x=0 using UpValues

I'm trying to set the derivative of a function to zero at a specified point. This will act as an initial condition for an algorithm I'm writing: so I'm specifying the value of the function at x=0, and ...
92 views

### Upvalues for Missing do not work with Dataset

Consider the following Dataset: d = Dataset[<| 1 -> Missing[], 2 -> 1.0, 3 -> 4.0 |>] And the following Upvalue for Missing: ...
38 views

### Custom iterable objects

I understand that to create objects with custom behavior with respect to existing code one uses upvalues. However, I'm at loss when it comes to guess what interface is expected from objects fed to ...
115 views

### How to prevent $\text{Quantity}$ calculations from converting units

I have an accrual calculation that I would like to preserve the units even though they are of the same dimension (e.g. time). For example, I would like the following ...
220 views

### How to deal with bad arguments when a function's UpValues is a pure-function?

In practice, I needs to define the UpValues of a user-defined function. For instance, the operation of function like differential formula , expansion and so on. ...
172 views

### Why this upvalue doesn't escape from Sum?

Probably a hard question, but I decide to cry out loud :). This is actually another problem I encountered when answering this question. Consider the following transform rule stored as an upvalue: <...
35 views

214 views

### How to tame the wild MMA?

MMA is a free country. But TOO free sometimes. Just as an example: Clear[a] a[x_] == a[y_] ^:= Round[x] == Round[y] {a[3] == a[3.01], a[3] == a[4]} is {True, ...
128 views

### $\tt AddTo$ regression in v10

As we know we can assign special addition rules to symbols by using UpValues: ...
297 views

### Make Sinc'[0] return 0 instead of Indeterminate

I want Sinc'[0] to return 0, but instead it returns Indeterminate. I've tried Unprotect[Sinc] Unprotect[Derivative] Derivative[1][Sinc][0] ^= 0 But it doesn't ...
207 views

### How to define UpValues in a different context from within a package

I'm trying to create a function (in a package) to import a lot of data and create a symbol with UpValues to return specific results about the data. I've got it working fine in a regular notebook, but ...
44 views

### What workarounds are there to TagSetDelayed::tagpos?

My program creates an object based on an Association, with a custom head: g = Gate[<| "key1" -> val1 |>] I have ...
121 views

### How to create fast functions based on units?

Using units is a good means for rapidly developing code, since it provides some error control. Hovewer, using Mathamatica functions containing units appears to be copmutationally inefficient. ...
613 views

### Copying one symbol into another

I would like to know how can I completely copy one Symbol to another. When I say copy, a refer to UpValues, DownValues, ...
353 views

### Using up-values and down-values

I have a problem I'm trying hard to find a solution for, although I don't know if a solution exists. The following rules produce the result e[2].f[] ...
143 views

### UpValues evaluation with Dot operator

I would like to simplify some database notation, and I'm doing some tests with UpValues for that. For example, if I set this Upvalue fot tab1: ...
51 views

### Upvalues and order of interpretation

I'm trying to use UpValues to improve the usability of some code, but I am running into an issue where the order of the UpValues is important, and I am not sure if it is my understanding or a ...
106 views

### How to assign up-values for Derivative?

I have defined several custom analytic functions. Here is the simplest example: ln[x_, a_?NumericQ] := Piecewise[{{Log[x], Re[a] > 0}, {-Log[1/x], True}}] ...
68 views

### Changing a tag when one function is passed into another using UpValues

I have two complicated functions f[x,y] and g[t]. Before the main evaluation code in g[expr]...
266 views

### Why isn't Lookup treated like other symbols?

With Mathematica 10, I wanted to overload Lookup using TagSetDelayed, but it doesn't work. For instance, if I define two objects ...
113 views

### Strange behaviour of UpSet [duplicate]

Can anyone explain what is going on here? I want to modify TensorRank for IdentityMatrix, but it fails on its first attempt: <...
206 views

### Access curated or locally stored data with curated data functions?

Say I have a toy package, something like: ...
142 views

### Can a Symbol own OwnValues that don't evaluate when it's the head of an expression?

I believe this a question that most of us have encountered when we were beginners but forgot when we got more familiar with Mathematica. We know the notation $y=y(x)$ for functions, where $y$ here ...
3k views

### How to force 2+2=5

I was looking at this question (writing a program such that 2 + 2 = 5) and tried to write something in Mathematica, but I couldn't get something to work without completely replacing ...
205 views

### Inheritance in Mathematica using pattern matching on UpValues

Edit: I think in my original post, I missed emphasizing the main point. This is mainly a pattern matching question. If you're interested in the 'why' of this question, please read the original post ...
2k views

### Do people actually use UpValues?

I know what they are and how to define them. They have to serve some purpose - else why include them? But I never used them and all examples on this site and the docs never show a practical use of <...
249 views

### How to customize derivative behavior via upvalues?

I'm having trouble getting customized derivatives (defined using upvalues) to behave in sane ways. By this I mean that I'd like to define a derivative using an upvalue and then have Mathematica apply ...
120 views

I have some objects that I want to present in TeXForm. Thus, it is easily to do as follows: YoungTableau/:TeXForm[YoungTableau[diagram_]] However, what if I ...
111 views

### Experiment with TagSetDelayed involving Part

Reading Associating Definitions With Different Symbols, I was intrigued by this: You can think of upvalues as a way to implement certain aspects of object-oriented programming. A symbol like ...
101 views

### How do I use a passed-in symbol as a tag to define UpValues?

ClearAll@foo; foo[tag_] := ( tag /: tag[i_] := tag[[i]] ); a = {7, 8, 9}; foo[a]; a[2] I wanted the above to output 8, ...
127 views

### Why is held expression evaluated?

Context: I'm studying non-linear dynamics. As part of a bigger problem, I'd like to generate lists of the form {{deq, ic1}, {deq, ic2}, ...}, where ...
405 views

I trying to modify the behaviour of the built-in Conjugate[] operator on a particular function I have defined, to take into account that some of its variables are ...
548 views

### Upvalues, TagSet and UpSet, what's the difference, when should a use each?

Some of the big mysteries of Universe Mathematica for me is the application of UpValues. I know about this question and know the very poor Mathematica documentation on that. I'm very curious to know ...
142 views

### How do I add options to a built in function, which only apply to a certain class of argument?

I'd like to add an option to a built-in function that only applies when it is given an argument of a certain form. For example, something like this approach to extending ...
165 views

1k views

### Emulating R data frame getters with UpValues

What's the best way to emulate R's data frames functionality? This includes the ability to select rows and columns in a 2-dimensional table by the string identifiers positioned typically in the first ...