Eternity Async Tutoring

yes. ok so can you find the terms on the right side of this?

xor(x,y) = (x&~y) | (~x&y)

It would be the stuff being and’ed together, right?

So x&~y is a term and ~x&y is a term. The two terms are being or’ed together.

yes. terms will probably come up more later.

You can implement logic operators using arithmetic operators or vice versa. Would you like assignments for that? It’s not necessary but it’s a way to get more practice and it could be interesting or useful. Or we could move on to grammar or another topic.

That sounds interesting. I’m still enjoying everything I’m so far, so doing a bit more before moving on to grammar is fine with me.

I’d like some assignments related to implementing logic operators using arithmetic operators or vice versa.

T=1
F=0

and(x,y) = ?
or(x,y) = ?
not(x) = ?

implement with math but no logic operators

hints are available. don’t get stuck for more than around 10min

and(x,y) = xy
x = 1, y = 1, xy = 1
x = 0, y = 1 , xy = 0
x = 1, y = 0, xy = 0
x = 0, y = 0, xy = 0

or(x,y) = x + y

x = 1, y = 1, x + y = 2
x= 1, y = 0, x + y = 1
x = 0, y = 1, x+ y = 1
x = 0, y = 0, x + y = 0

Mmm. I don’t know if having the two there is fine or not. I just assumed that I want to keep all my answers in the realm of 1’s and 0’s, but I don’t know how to fix that.

not(x) =

mmm. we’re looking for something that does something like + 1 when it’s 0 and -1 when it’s 1. My mind immediately goes to making a piecewise function but I don’t think thats what I should be doing here.

Let’s list off some math operations I can do: addition, subtraction, multiplication, division , exponentiation, square root, factorial.

Hmm. I think I’m stuck.

~5 minutes

The 2 does need to be fixed. T is only and exactly 1.

Piecewise functions aren’t necessary. Let’s not use those.

First hint:

For each operator, there are essentially 2 different problems with 2 separate solutions. One is for integer arithmetic and one is for real number arithmetic. (In some simpler cases like for ā€œandā€ there won’t be a difference.)

2 posts were merged into an existing topic: LMD Async Tutoring

Ok. I don’t know what integer arithmetic and real number arithmetic are referring to.

I know the four arithmetic operators: addition, subtraction, multiplication, and division. I did some searching and ended up going down a rabbit hole with integer arithmetic with stuff like signed and unsigned integers. I don’t know if any of the stuff I saw was relevant. The only other thing I found for integer arithmetic was stuff mentioning to drop remainders entirely in division doing integer arithmetic. Searching for real number arithmetic only showed regular arithmetic stuff.

People learn and work with integers before reals. It’s typical to learn that 20/7 = 2 with a remainder of 6 before learning about fractions.

Signed and unsigned integers are complex details. I was just trying to bring up basic stuff.

hint 2:

Integers and reals have some different operations.

With integers, division cannot give the answer 3.5. It gives an integer answer plus a remainder. So when writing expressions we need two separate operations, each of which gives one part of the answer (the quotient or the remainder). 20/7=2 and 20%7=6.

For reals, some important operations are ceil and floor (which round up or down to the nearest integer).

Huh. That makes sense. It could have been a me thing, but the use of the terms integers, whole numbers, real numbers, etc. have had no substantive impact in how I should approach thinking about math. I think when I re-started learning math and used the AOPS textbook, they did some stuff to get you thinking about integers vs. real but only for a few problems I feel. Throughout most of school, they were just kind of terms that had no real affect in how I approached math.

Kk.

Ok.

So integer division just gives the integer answer with no remainder versus real division can give a number with a decimal. Ok. I did look up if there was a function for the percent thing there. It seems its called mod? I vaguely remembering a short period in school of using it, and then never again.

Ok. I looked up what these do. They seem to be a way to convert reals to integers.

After seeing those functions. I came up with this for ā€œorā€:
or(x,y) = ceil((x+y)/2)
or(1,1) = ceil((1+1)/2) = ceil(2/2) = ceil(1) = 1
or(1,0) = ceil((1+0)/2) = ceil(1/2) = ceil(.5) = 1
or(0,1) = ceil((0+1)/2) = ceil(1/2) = ceil(.5) = 1
or(0,0) = ceil((0+0)/2) = ceil(0/2) = ceil(0) = 0

Is this solution ok?

not(x) = 1-x
not(1) = 1 - 1 = 0
not(0) = 1 - 0 = 1

This works.

Mod and remainder are the same thing for positive numbers. The name remainder is more intuitive. With negative numbers its more confusing and you shouldn’t need to deal with that.

Yes that’s correct.

Keep working on the rest. More hints are available.

Yes. The first solution for not(x) that occurred to me is: (x-1) * -1

Simplify that and see what you get.

In terms of general concepts, multiplying by -1 is a way to reverse the order of numbers. Like if you have 1,2,3 and you multiply them all by -1 then put them in order from smallest to largest again, order is now -3,-2,-1 so the 3 came first instead of last. For not(x) you needed to swap the order (the one you needed to have a smaller output had a bigger input). Does that make sense?

(x-1) * -1 = -1(x) + (-1)(-1) = -x + 1 = 1 - x

This part does:

Confused with:

Could this be-reworded? I keep reading it and I’m getting more and more confused.

You start with the inputs 0 and 1. But the goal outputs you want are in the reverse order. 0->1 and 1->0.

This is different than if you were doing e.g. 0->5 and 1->8 (outputs stay in the same order as the inputs).

Ok. That makes sense.

Hmm. f(x) = x - 1, f(0) = -1, f(1) = 0, f(2) = 1. -1, 0, 1. I think I can do this?:
(-1) * f(x). -1* f(0) = 1, -1 * f(1) = 0 -1 * f(2) = -1. 1, 0, -1.

Ahh I see the order flipped.

Take an integer number line (from -5 to 5 is enough) and draw arrows from each number to what it maps to when multiplied by negative 1.

This?

Yeah but do separate arrows. put all the arrows starting from positive numbers above the number line and starting from negative below. And draw an arrow for 0.