Do you ever use exponentiation (^) in arithmetic comb?

Post all other topics which do not belong to any other category.
coppercoil
Long Handed Inserter
Posts: 72
Joined: Tue Jun 26, 2018 10:14 am
Contact:

Do you ever use exponentiation (^) in arithmetic comb?

I wonder if exponentiation (^) operation has any practical use in the arithmetic combinator. The only meaningful case I can imagine is 2 ^ X, that can be replaced to 2 << (X - 1). Anything else?
I never use it, maybe there are some great tricks I don't know?

Oktokolo
Filter Inserter
Posts: 674
Joined: Wed Jul 12, 2017 5:45 pm
Contact:

Re: Do you ever use exponentiation (^) in arithmetic comb?

No. I only use arithmetic combinators for subtracting values, negating values, and as a diode. Anything that needs more quickly becomes a pain in the arse to think about and i try to avoid that.

My problem with the combinators is, that they are only providing the most basic operations. Therefore doing anything more complex with them feels like programming in a language with no standard library and tends to use up vast amounts of space - wich makes the proportions of actual production footprint to control logic footprint look way off.
Whenever there are ways doing something without combinators, that is also almost always the better way to do it. I do use a circuit-optimized kovarex process though...

DaveMcW
Smart Inserter
Posts: 2914
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Do you ever use exponentiation (^) in arithmetic comb?

No.

Its main purpose seems to be clarifying that the XOR operator (blue ^) is NOT an exponent.

Optera
Smart Inserter
Posts: 2226
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: Do you ever use exponentiation (^) in arithmetic comb?

No, each ^ x is pretty useless.
This is one of those functions that where added just to have the full set of operands available.
It might have been useful if we could do x ^ each = each to generate powers of 2 for binary conversions.

Hannu
Filter Inserter
Posts: 670
Joined: Thu Apr 28, 2016 6:27 am
Contact:

Re: Do you ever use exponentiation (^) in arithmetic comb?

No, problem of combinators is that there is no actual use for them in the game. Of course there are systems which are intended to use combinators to produce strange things and some control systems too, but at least for me they are more for use of combinators than actual need.

Combinators would be great to make systems adapt changing situations, like temperatures or non linear effects, but unfortunately devs have never used their potential. That may be too hard for average players and also most of advanced players want to build a megabase with the exact mathematical ratios instead of adaptive and varying systems but I hope there could be more complex difficulty level with varying conditions, side products etc. interesting things from engineering point of view (mods can give side products but not dynamic environment).

mrvn
Smart Inserter
Posts: 3679
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Do you ever use exponentiation (^) in arithmetic comb?

You can use "each ^ 2 => each" to compute a square mean deviation. Too bad there is no sqrt() or "each ^ 0.5" to go along with it.

It's sad that each / everything / anything can't be used as second argument of an arithmetic combinator. Would be useful for - and / too.

Vegemeister
Long Handed Inserter
Posts: 80
Joined: Sun Dec 04, 2016 9:18 pm
Contact:

Re: Do you ever use exponentiation (^) in arithmetic comb?

The main application is elementwise multiplication of all signals on two wires. That is, each = each * each.

I think it can also be used for IIR filters.

coppercoil
Long Handed Inserter
Posts: 72
Joined: Tue Jun 26, 2018 10:14 am
Contact:

Re: Do you ever use exponentiation (^) in arithmetic comb?

mrvn wrote:
Mon Sep 02, 2019 3:43 pm
You can use "each ^ 2 => each" to compute a square mean deviation. Too bad there is no sqrt() or "each ^ 0.5" to go along with it.
If you like circuits, you can build sqrt() by yourself using Babylonian method, it's simple and converge fast, especially if you can precalculate good initial guess. It works with integers too.

mrvn
Smart Inserter
Posts: 3679
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Do you ever use exponentiation (^) in arithmetic comb?

coppercoil wrote:
Mon Sep 02, 2019 6:35 pm
mrvn wrote:
Mon Sep 02, 2019 3:43 pm
You can use "each ^ 2 => each" to compute a square mean deviation. Too bad there is no sqrt() or "each ^ 0.5" to go along with it.
If you like circuits, you can build sqrt() by yourself using Babylonian method, it's simple and converge fast, especially if you can precalculate good initial guess. It works with integers too.
You can do a lot of things. The question is: Would you want to?

coppercoil
Long Handed Inserter
Posts: 72
Joined: Tue Jun 26, 2018 10:14 am
Contact:

Re: Do you ever use exponentiation (^) in arithmetic comb?

mrvn wrote:
Mon Sep 02, 2019 8:10 pm
You can do a lot of things. The question is: Would you want to?
That's a good question. Do I want a square mean deviation?

Hannu
Filter Inserter
Posts: 670
Joined: Thu Apr 28, 2016 6:27 am
Contact:

Re: Do you ever use exponentiation (^) in arithmetic comb?

Vegemeister wrote:
Mon Sep 02, 2019 6:31 pm
I think it can also be used for IIR filters.
mrvn wrote:
Mon Sep 02, 2019 3:43 pm
You can use "each ^ 2 => each" to compute a square mean deviation. Too bad there is no sqrt() or "each ^ 0.5" to go along with it.
Do you really have ideas which need deviations or IIR-filters for control of production of actual factory or are they some kind of special projects which just use Factorio as fun and strange programming language?

mrvn
Smart Inserter
Posts: 3679
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Do you ever use exponentiation (^) in arithmetic comb?

Hannu wrote:
Fri Sep 06, 2019 5:32 am
Vegemeister wrote:
Mon Sep 02, 2019 6:31 pm
I think it can also be used for IIR filters.
mrvn wrote:
Mon Sep 02, 2019 3:43 pm
You can use "each ^ 2 => each" to compute a square mean deviation. Too bad there is no sqrt() or "each ^ 0.5" to go along with it.
Do you really have ideas which need deviations or IIR-filters for control of production of actual factory or are they some kind of special projects which just use Factorio as fun and strange programming language?
I used square to balance recipes to the availability (or lack) of inputs and outputs. In Angels mods there is a recipe to make steel from iron and one for making steel from iron + silicon. For each item I have a goal for how much of it I want to have around in buffer chests. That allows me to calculate a score for every recipe. For example if steel is below the goal then I want to use one of the two steel recipes to make more. If there is few iron but enough silicon then the second recipe is used. If iron starts to back up the first one is used instead.

What I found is that using "buffered - goal" doesn't give the system enough of a feedback. When both iron and silicon are above the goal then it produces twice as much steel until both sides of the recipe balance and the recipe gets a score of 0. But if I used "sign(buffered - goal) * (buffered - goal)^2" even a small amount of steel in excess of iron or silicon will tip the scales the other way.

Who is online

Users browsing this forum: No registered users