Page 1 of 1
Do you ever use exponentiation (^) in arithmetic comb?
Posted: Sun Sep 01, 2019 7:09 pm
by coppercoil
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?
Re: Do you ever use exponentiation (^) in arithmetic comb?
Posted: Mon Sep 02, 2019 6:34 am
by Oktokolo
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...
Re: Do you ever use exponentiation (^) in arithmetic comb?
Posted: Mon Sep 02, 2019 7:22 am
by DaveMcW
No.
Its main purpose seems to be clarifying that the XOR operator (blue ^) is NOT an exponent.
Re: Do you ever use exponentiation (^) in arithmetic comb?
Posted: Mon Sep 02, 2019 10:05 am
by Optera
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.
Re: Do you ever use exponentiation (^) in arithmetic comb?
Posted: Mon Sep 02, 2019 12:10 pm
by Hannu
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).
Re: Do you ever use exponentiation (^) in arithmetic comb?
Posted: Mon Sep 02, 2019 3:43 pm
by mrvn
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.
Re: Do you ever use exponentiation (^) in arithmetic comb?
Posted: Mon Sep 02, 2019 6:31 pm
by Vegemeister
Re: Do you ever use exponentiation (^) in arithmetic comb?
Posted: Mon Sep 02, 2019 6:35 pm
by coppercoil
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.
Re: Do you ever use exponentiation (^) in arithmetic comb?
Posted: Mon Sep 02, 2019 8:10 pm
by mrvn
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?
Re: Do you ever use exponentiation (^) in arithmetic comb?
Posted: Mon Sep 02, 2019 8:27 pm
by coppercoil
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?
Re: Do you ever use exponentiation (^) in arithmetic comb?
Posted: Fri Sep 06, 2019 5:32 am
by Hannu
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?
Re: Do you ever use exponentiation (^) in arithmetic comb?
Posted: Sat Sep 07, 2019 2:56 pm
by mrvn
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.