Solving Equations in Hopscotch

Hey guys! Today, I have something a bit different for you: A challenge. But this isn't a normal challenge that one person will complete. This is a challenge that we will all have to work together on, because this is quite a big undertaking. So, let me first give some background and then explain the challenge.

So, we can use Hopscotch to solve many math problems, right? You want 100/4, just plug it in and get an answer right out. And the tools that Hopscotch had were sufficient to solve most math problems I wanted solved. That is, until I got to algebra. You can't plug an equation into Hopscotch and have it solve for x (If you don't understand what that means, go to the 'what algebra is' section). Or, can you? This challenge is to make a Hopscotch project where you plug in an equation with one unknown variable, and it will solve for it. It's intimidating, and seemingly impossible, but I've gotten quite close, and I think it can be done.

What Algebra Is

So, I'm sure you know basic arithmetic. If I ask you to solve 3+2, you can tell me 5. We can express that mathematically by saying:
BAS: 3+2=?
You: 3+2=5

Now, in algebra we have varialbes. They are like values in Hopscotch! Instead of putting that question mark, I can say
3+2=x
And since 3+2=5, you can tell me
x=5
Does this make sense so far? If not, just ask and I'll provide clarification.
But, what if the x is on the other side of the equation?
3+x=5
We have to ask ourselves - what can we put as x to make the equation true? 3 doesn't work, because 3+3=6. But, if x=2, then we have
3+2=5
And it works! There are ways to solve for x, which involve getting the x on it's own by doing things to both sides of the equation, but we don't have time to get into that. I'd recommend khanacademy if you want to know more :smiley:

So, what are your thoughts on this project? Is it doable? Any ideas on how to do it?

Some people who might be interested

@oio
@Stradyvarious
@Intellection74
@Mathgirl
@justanerd
@Gilbert189

37 Likes

This is awesome @BuildASnowman!!! I've been wondering the same thing. There are plenty of calculator projects on Hopscotch, but not any that I've seen that will solve for a variable! Nice thinking and explanation. It would definitely involve a ton of variables and values, but I think it could be done. :D

9 Likes

@BuildASnowman- That is so cool! I definitely want to try that! Nice explanation!

6 Likes

I think I've got this! :D

7 Likes

Wait, so you have to just write an equation with one unknown variable and have hopscotch solve it?

2 Likes

This post was flagged by the community and is temporarily hidden.

5 Likes

You can interpret the problem in pretty much any way you want. Just find a way for the user to input an equation (for example x^2=10 or 3x=9) and have Hopscotch solve for x.

4 Likes

Ok, thanks!

Sweet.

This reminds me of a problem I made for myself a long time ago. Not gonna be useful here, Snowman, but I think you'd like it. Basically, I wanted a way to enter math functions and instructions at runtime, when I was a seventh- or eighth-grader, so I made a program that searched for itself in the memory of my computer (it could be in different places each time), then inserted/substituted new lines of code in the native language of the already-running program, downstream of the part that did the self-search. Then, when the program execution pointer hit those new lines, it executed them, as if they had been there all along! Ok, well... I was excited at the time. Not the same, I know, but a problem having the same feel.

You will likely find polynomials the easiest to treat in this problem. Why? because it's so straightforward. It's just coefficients, really. Other, more general stuff... not so much. To go there, you'd wind up wanting a functional pallette - more of a menu or wizard.

15 Likes

Doing polynomial's up to quartic equations are easy enough - it's just a matter of plugging in the equations. But past that, isn't it impossible past 4th degree equations? Is there a (perhaps iterative?) method for solving polynomials of any arbitrary degree?

EDIT: Just found the Newton-Rhapson method. Could we implement this in Hopscotch? I just don't like the idea of having to provide an initial guess and the first derivative.

10 Likes

Hmmm. I have no idea how you would do that. In my experience I would say you could use check once if blocks and change them? I rellay don't know. BUT AWESOME IDEA!!!!

2 Likes

@BuildASnowman Is this right? So far, it only works with addition. Here is the link.
Also, here are some pics-

pics



Edit- It only works with at least one X. I am going to fix that.

3 Likes

@BuildASnowman, I have made a really simple test for one step equations. I think I'll move onto making it work with more complicated formulas.

https://c.gethopscotch.com/p/y1lkvzz2u

6 Likes

@BuildASnowman- I've made it work for addition, subtraction, multiplication, and division! It is complete(sort of) Here is the link

3 Likes

What about inverse op?

1 Like

That seems like the way to do it until you consider things like x^3, x^4th, etc or sin(x) and cos(x), because we don't have inverse operations for them.

BIG UPDATE: I found a way to do it. It is very fickle though, and hard to use. More things coming.

6 Likes

Oh yeah, exponents wouldn't work. Well, at least it works for simple operations

2 Likes

y u gotta wait until my iPad gets completely reset? ;-; welp, I guess I could attempt this in scratch? but the majority of peoples are just on HS ;-;

(PS- SOOOOO doing this)

2 Likes

This is cool! I'm going to play around with it! :D I like algebra!

2 Likes

K, I published a project that can theoretically solve any equation. I also cooked up a youtube video in about 5 minutes xD It explains how to use it and how it works.

6 Likes