I came across an estimation of the relative error between two representations of the same number, one implemented in C++ and another one via a computer algebra program, that was in units of machine epsilon. My question is trivial, though I wasn’t able to find an answer:

If I say that the number has 3 machine epsilons relative error, how many digits does it mean that the approximated number looses compared to the true number?

# Tag: Units

## unity – ShaderLab: correctly using Offset, Factor and Units?

In the documentation of ShaderLab culling and depth testing you have the following:

Offset

Offset Factor, Units

Allows you specify a depth offset with two parameters. factor and units. Factor scales the maximum Z slope, with respect to X or Y of the polygon, and units scale the minimum resolvable depth buffer value. This allows you to force one polygon to be drawn on top of another although they are actually in the same position. For example Offset 0, -1 pulls the polygon closer to the camera

ignoring the polygon’s slope, whereas Offset -1, -1 will pull the polygon even closer when looking at a grazing angle.

I have the following scenery, it’s two cylinders of the **same size**, one being the sky, one being the horizon on the floor, it is shown exactly how it is expected to render:

This is how it actually looks without playing with the offset factor and units, lots of Z-fighting:

I had to put a fairly high value to `Factor`

so Z-fighting stops, around 15.

And setting the value of `Units`

has absolutely no effect.

So I’m a bit at a loss as on how to correctly use both of these parameters.

**Question:**

Can you explain how shall one understand the meaning and correctly use `Factor`

and `Units`

?

## google sheets – How to calculate units with range value of numbers

**We sell greeting cards and this is how it works**

**Scenario 1:**

- if you want to send 1 greeting card up to 10 cities then the price will be 15USD
- if you want to send 1 greeting card up to 25 cities then the price will be 40USD
- if you want to send 1 greeting card up to 50 cities then the price will be 90USD

*the price will increase if cities are over 10 but equal to 25 or less*

**Scenario 2:**

- if you want to send 2 greeting cards upto 10 cities then the price will be 25USD
- if you want to send 3 greeting cards upto 25 cities then the price will be 50USD

*the price will calculate based on 2 greeting cards cities equal to 25 or less*

Here is the Google Sheet link, I am trying to work on but I totally lost it, cannot figure it out at all.

## equation solving – Solve::units: Solve was unable to determine the units of quantities that appear in the input

Avoid the use of subscripted variables, they cause more trouble than they’re worth. Use `Format`

to display variables in any manner desired.

```
Clear("Global`*")
Format(Tday) = Subscript("T", "day");
Format(Teff) = Subscript("T", "eff");
Format(Rs) = Subscript("R", "s");
Format(Rp) == Subscript("R", "p");
Format(ΔFse) = Subscript("ΔF", "SE");
eqns = {T^4 == ((1 - A) (1 - P) Rs^2 Teff^4)/(2 a^2),
ΔFse/F == (Rp^2 * Tday)/(Rs* Teff)}
```

`Solve`

will then work

```
sol = Solve(eqns, {P, Teff}, Reals) // Simplify
```

Verifying the solutions,

```
eqns /. sol((1)) // Simplify
(* {True, True} *)
```

## c++ – How can I avoid coupling between units and their environment?

The target implementation of your Map and entities is very much like a graph, or, more specifically, a tree:

Since the goal is to minimize references to parent nodes, **we will call update methods from parents, as well as have parents pass data to those children that is necessary for them to update.**

Since entities need to be able to move throughout the tree, it’s inevitable that we will need some sort of function in the `Map`

and `Chunk`

to be able to move entities to different nodes. **However, we can separate updating the graph from updating the state of the entities, which will keep them from storing references to one another.**

## Updating the Map Graph

Since your `Entity::move`

method adjusts fields for `x`

and `y`

, it seems that you already locally store the coordinates of your entities. Thus, you have enough information to know when to delete references to entities in your Chunks and Tiles; specifically, when their coordinates are no longer within the bounds of that Chunk or Tile.

For example, in your Tile class (I’m doing this in Javaish-pseudocode since I’m clueless with C++ and don’t want to cause confusion):

```
for(Player player in players) {
if(player.coordinates != this.coordinates) {
player.needsMove = true;
/*Remove reference to player from vector*/;
}
}
```

Then, in your Chunk class:

```
for(Player player in player_need_update) {
if(player.needsMove) {
if(inThisChunk(player.coordinates)) {
/*Add a reference to this player in the appropriate Tile in this Chunk*/;
player.needsMove = false;
}
}
}
```

And you’d have to do the same in your Map class if entities can move between Chunks.

## Detection Among Entities

A similar approach could help the entities detect one another. For example, take the case of Players attacking Enemies. If a Player can only attack Enemies within the same Chunk, then we could do something like this in the Chunk class:

```
for(Player player in player_need_update) {
for(Enemy enemy in enemies) {
if(player.shouldAttack(enemy)) {
player.attack(enemy);
}
}
}
```

From there, calls to `Player::attack()`

can be passed references to enemies without storing them for long-term use.

## unity – How to calculate High Score in game when there are two units in the game?

In my game I am solving a problem, and I am getting certain points for each problem.

Just like collecting numbers falling from the top.

Now I want to calculate a high score on the basis of two items i.e. solved points and time it took to solve until the user get it wrong.

How would I rank any player based on the two events?

## curated data – Units Question for PlanetData[..]

I asked a similar question yesterday, which was answered splendidly, but I missed adding a detail.

Attached is a command, its output, and the issue I have now. This outputs g/cm^3, but I’d rather have the units in kg/m^3.

I guess I don’t know how to handle the command which outputs all the data at once. How can the units be changed for this kind of output?

Thank you (again)

## AngularDegrees^2 and Steradians are incompatible units

It seems you have misspelled “Degrees”. When I correct your misspelling, I get

```
UnitConvert(Quantity(360, "Degrees^2"), "Steradians")
```

Quantity(Pi^2/90, “Steradians”)

It quite a bit less than $4 pi$. To find the angular measure of a complete sphere in angular degrees we can do the following:

```
UnitConvert(Quantity(4 π, "Steradians"), "Degrees")
```

`Quantity(129600/π, ("AngularDegrees")^2)`

Also, note that a steradian is the same as a square radian.

```
UnitConvert(Quantity(1, "Steradians"), "Radians^2")
```

`Quantity(1, "Radians"^2)`

## algorithms – What are the units for time complexity graphs?

We use Big-O notation to describe how “fast” an algorithm runs with respect to the size of the input in the worst case scenario. This input can be a number, a list of numbers, a matrix, etc. By fast, it essentially translates to number of steps the algorithm takes based on the size of the input in the worst case scenario.

I should start by describing the difference between an algorithm and an implementation of an algorithm. An algorithm is just a set of instructions that solves a problem. An implementation of an algorithm is code that is run on hardware that actually performs the set of instructions.

Suppose we have a simple problem, “given a list of numbers of arbitrary size and in no particular order, find the maximum value in the list”. We solve this problem with an algorithm. Below is a solution to the problem.

```
FindMax(ls)
m <- null
for each x in ls
if x > m
m <- x
return m
```

To analyze how good this solution is, we to find what the worst case is for this algorithm to handle. For this algorithm, the worst case would be a sorted list in ascending order. This is because the if statement will always be true (adding more steps).

Let $n$ be the size of the input list. Now let’s count the number of steps our algorithm takes to complete (in the worst case). The initialization is 1 step (`m <- null`

). The for loop will loop $n$ times. The amount it does inside the loop will be 2 steps (1for the if statement check and 1 for its body). Finally, 1 step for `return m`

.

Let $T(n)$ be the worst case runtime for our algorithm. From above we have $T(n) = 1 + 2*n + 1 = 2*n + 2$.

This is where big-O notation will help us. We need to find a function $g(n)$ grows at a similar rate as $T(n)$; this function will be our upper bound. In other words, we need to find a function $g(n)$ where $T(n) leq k*g(n)$ for all $n geq n_0$.

Let’s try $g(n) = 1$. Here we see that no matter what $k$ we try, $T(n)$ will always be greater at some point; more precisely, when $n>k$ then $T(n) > k*g(n)$. This means $g(n) 1$ is not big enough.

Let’s try $g(n) = n$. Here we see that if we choose $k geq 3$ and $n_0 = 1$, $k*g(n) geq T(n)$ for $n geq n_0.

What we proven is that $T(n)$ is bounded above by $g(n) = n$. This means that $T(n) in O(g(n))$; in other words $T(n) in O(n)$. Notice how I used $in$ instead of $=$. This is because $O(g(n))$ is the set of all functions that are bounded above by $g(n)$. However, it is common practice to abuse the notation $T(n) = O(n)$.

The purpose of this example is to show you the context of big-O notation. Big-O notation is purely abstract in that we count the number of steps of the algorithm, not the amount of time (in seconds) it takes to complete. If we implement this algorithm in a program language (like C/C++ or Java) and run it on the computer, then we have many more factors to consider:

- Number of cores of CPU
- Clock speed of CPU
- Amount of memory
- I/O speed of the input
- Language specific performance issues (e.g. C/C++ faster than Java)
- etc.

None of these factors describes how well an algorithm performs; rather they show how well the implementation performs. See Big O Notation for an example and more information.

## ac.commutative algebra – Elliptic Units as Euler systems

I’m trying to understand elliptic units in order to work with the Euler systems of the ableism extensions of quadratic imaginary number fields. I’ve looked at few references about the topic, but they define elliptic units from different perspectives. Can anyone suggest a short and comprehensive definition of elliptic units. Thank you.