LMD Async Tutoring

Do you mean a way other than how I simplified it here?

Thatā€™s good

I got this solution for or(x, y) that uses a comparison operator:

x + y > 0

Is there also a solution that only uses a comparison operator(s)?

1 Like

Maybe that needs brackets. But Iā€™m not sure of the order of operations with comparators. This is what my solution meant:

(x + y) > 0

No

1 Like

Iā€™m confused about what linear and non linear terms are. You say:

Is multiplication in general non-linear?

Try looking it up

1 Like

I did briefly before I asked but I only found things referring to linear and non-linear equations, I couldnā€™t find reference to nonlinear terms. Now googling ā€˜nonlinear term mathā€™ returns more about equations. I found some things about the concept of multiplication being bilinear when googling ā€˜is multiplication linearā€™ but most things were over my skill level and I couldnā€™t make sense of them. Iā€™m still confused.

Oh, Iā€™ve found some info relating to linear terms:

A linear term has a degree of 1. For example, 5x, -2x and x are all linear terms. These terms are x to the first degree (X^1), where the ā€œ1ā€ isnā€™t written (because any number to the first power is just that number).

Terms that are not linear are called non-linear terms. The most common one youā€™ll come across in calculus is the quadratic term.

So I can see why xx is not a linear term: it is x to the second degree or x^2. Iā€™m not sure why xy would be a non-linear term. Unless x and y are the same value! If x = 1 and y = 1 then xy is 1^2?

Read first paragraph at Degree of a polynomial - Wikipedia

Okay. From that paragraph:

The degree of a term is the sum of the exponents of the variables that appear in it, and thus is a non-negative integer.

The sum of the exponents of the variables x and y in the term xy is 2. So if a linear term has a degree of one, then xy is non-linear. So the answer to my question:

is no. It is the degree of a term not being 1 that makes something non-linear, not the fact that there is multiplication happening.

No luck so far finding a solution that meets this criteria. Iā€™ve been trying to apply the things about number lines to it, but Iā€™ve got no good ideas. I think Iā€™ve spent too long on this though I havenā€™t kept track of the time.

What conceptually do I need to do?

In that mapping, all numbers that arenā€™t 0 map to 1. All positive numbers map to 1. The solution x + y > 0 conceptually does this. It makes all positive numbers map to 1. How do we do something similar, but just with basic arithmetic?

1 is the multiplicative identity. Any number divided by itself equals one (except zero). But we canā€™t use fractions.

anything to the power of zero is 1. But then 0 maps to 1.

how can we check if something is positive using only addition and multiplication?

Iā€™ve scrolled down to see further discussion.

Okay, I hadnā€™t considered integer division. I donā€™t have practise thinking about integer division so Iā€™m gunna practise some more see if I notice anything.

3 / 6 = 0
3 mod 6 = 3

6 / 2 = 3
6 % 2 = 0

12 / 7 = 1
12 % 7 = 5

45 / 4 = 11
45 % 4 = 1

2 / 1 = 2
2 % 1 = 0

1 / 2 = 0
1 % 2 = 1

0 / 2 = 0
2 / 2 = 1
1 / 2 = 0

0 / 2 = 0
0 mod 2 = 0

0 mod 2 = 0
2 mod 2 = 0
1 mod 2 = 1

Stopping for today. Stuck here.

Hint: you donā€™t need to map all positive numbers to 1 to solve this problem. You only need to map a few specific numbers, which is easier.

There are more hints in the Eternity topic.

1 Like

Okay as soon as I saw this prompt I knew how to do it.

1 / 10 = 0
2 / 10 = 0
3 / 10 = 0
4 / 10 = 0
5 / 10 = 0
6 / 10 = 0
7 / 10 = 0
8 / 10 = 0
9 / 10 = 0
10 / 10 = 1
11 / 10 = 1

These last three give me the outputs I want:

9 / 10 = 0
10 / 10 = 1
11 / 10 = 1

so (x + y + 9) / 10 would work.

But I think a smaller one would work. would ā€˜/ 3ā€™ work?

1 / 3 = 0
2 / 3 = 0
3 / 3 = 1
4 / 3 = 1

so (x + y + 1) / 3

or(1, 1): (1 + 1 + 1) / 3 = 1
or(1, 0): (1 + 0 + 1) / 3 = 0

okay no

3 / 2 = 1
2 / 2 = 1
1 / 2 = 0

Okay thatā€™ll do it:

or(x, y) = (x + y + 1) / 2

or(1, 1): (1 + 1 + 1) / 2 = 1
or(1, 0): (1 + 0 + 1) / 2 = 1
or(0, 1): (0 + 1 + 1) / 2 = 1
or(0, 0): (0 + 0 + 1) / 2 = 0

1 Like

This is my working. In it I happen upon a remainder solution to xor. Iā€™m still stuck on a remainder solution to or though.

1 % 5 = 1
2 % 5 = 2
3 % 5 = 3
4 % 5 = 4
5 % 5 = 0

I want to map:

0 ā†’ 0
1 ā†’ 1
2 ā†’ 1

5 % 1 = 0
5 % 2 = 1
5 % 3 = 2
5 % 4 = 1
5 % 6 = 5
5 % 7 = 5
5 % 8 = 5
ā€¦

6 % 1 = 0
6 % 2 = 0
6 % 3 = 0
6 % 4 = 2
6 % 5 = 1
6 % 6 = 0
6 % 7 = 6
ā€¦

3 % 1 = 0
3 % 2 = 1
3 % 3 = 0
3 % 4 = 3
ā€¦

So a first number mod a second and larger number outputs the first number

5 % 1 = 0
6 % 2 = 0
7 % 3 = 1
8 % 4 = 0
9 % 5 = 4
10 % 6 = 4
11 % 8 = 3

3 % 1 = 0
4 % 1 = 0

0 % 2 = 0
1 % 2 = 1
2 % 2 = 0
3 % 2 = 1
4 % 2 = 0
5 % 2 = 1
6 % 2 = 0
7 % 2 = 1
8 % 2 = 0
9 % 2 = 1

Okay so using ā€˜% 2ā€™ can check if something is even or odd. That means you could use it for xor.

xor(x, y) = (x + y) % 2

Okay, so I am conceptually trying to do the same thing as with division. Mapping 0 to 0, and 1 and 2 to 1. The hint was to try n/10. That made me see that anything under 10 output 0 and anything above output 1. So I want a way that I can use remainder do the same thing. Can I use remainder to check primes? I know that 1 and 2 are both primes. if there was a prime check function called ā€˜primeā€™ that output true when prime, i could do:

0 prime 0
1 prime 1
2 prime 1

When is something a prime? When it has no factors except 1 and itself. I think I would maybe need to recursively check that each number below the input wasnā€™t a factor though. What other things maps 0, 1, 2 to 0, 1, 1?

A remainder function subtracts the second number from the first number until it cant and then returns the remainder.

If i could multiply 0, 1, 2 by something, that would spread them out across the number line, keeping 0 at 0. But theyā€™re then all scaled by the same amount.

Hmm. Stuck for now.

Iā€™ve continued in the Eternity topic and found their remainder solution for or(x, y) which is:

  • 1 mod (x + y + 1)

This works because 1 mod anything higher than 1 will output 1.

I couldā€™ve realised this before when I noticed that:

ā€¦a first number mod a second and larger number outputs the first number

So I couldā€™ve seen that if had 1 mod 1 iā€™d get 0, and 1 mod anything higher would return 1. Hmm. Iā€™m not sure why I missed that.

I got xor above: (x + y) mod 2.

Okay. Another remainder one. I can try.

So 1 mod x checks if x is greater than 1. In this configuration it functions as a ā€˜greater thanā€™ comparator that outputs 0 or 1.

In my solution for xor, x mod 2 functions as an even number checker, checking if x is even.

or(x, y): (x + y + xy) mod 2

1, 1: (1 + 1 + (1 * 1)) mod 2 = 1
1, 0: (1 + 0 + (1 * 0)) mod 2 = 1
0, 1: (0 + 1 + (0 * 1)) mod 2 = 1
0, 0: (0 + 0 + (0 * 0)) mod 2 = 0

This is like the remainder xor expression, but it makes the case where both inputs are 1 sum to an odd number by adding xy (which equals 1 only when the inputs are both 1)

Oh cool I got it.

I watched this computerphile video on xor and the half-adder:

I liked idea of the inputs of the two different gates of the half adder being in parallel and so being fed the same inputs. I like electronics, and have some experience with basic analogue circuits. I think for now though Iā€™d like to move on to something different.

I skimmed the first couple pages of the introduction of the Feynman Lectures on Computation and I think Iā€™d like to read it.