nateowami / solve4x Goto Github PK
View Code? Open in Web Editor NEWAn algebra solver that shows its work
Home Page: http://nateowami.github.io/Solve4x/
License: GNU General Public License v3.0
An algebra solver that shows its work
Home Page: http://nateowami.github.io/Solve4x/
License: GNU General Public License v3.0
I'm happy with Solve4x as a name, but I really can't come up with any good logo ideas. Almost every idea is a variation of Solve
written smallish and 4x
front-n-center. Very bland. If you have better ideas say on.
I'm considering two other options.
I cans do maths?
call-out with a puppy. You'll see I've already put Epsilon in the README. I've also thought a doghouse could be used for the website's home button, an ASCII dog for a link to the code on GitHub, etc. A bone would be perfect for a "donate" button, if donations are accepted.Even with those ideas there's no great logo. I was thinking of using a paw print, possibly constructed from lower-case epsilon. Rachel came up with a way to draw a dog face with epsilon in it, by turning them sideways (similar to how Google does doodles). It worked much better than my idea to use them to make a paw print (--> fail
).
Thoughts? Suggestions? I'm open to sticking to exactly what we already have, or something different altogether.
Using the image you sent as the base, I've created a basic custom LAF and GUI Mockup. that attempts to follow it as closely as possible. All the controls are usable, and the yellow panel can be drawn on.
Do you think that idea will work?
Btw, I used the Unicode gear character instead of a wrench image, sorry!
I won't do a lot of explaining because I want to keep this as an open-ended question. This is purely a theoretical question, but I may use it in Solve4x, since it is inspired by a real problem I am having. What would you say is the proper syntax tree for some of these expressions?
BTW, the 2 on the end of the second two expressions are powers.
Any ideas? This isn't a quiz, it's "How would you logically think to represent these?"
Knowing you've gotten Travis CI to work I was wondering what you did. It compiles on my end but it fails every time with Travis CI.
EDIT: Now my local repo has conflicts because I tried to update .travis.yml and it REFUSED to notice edits. So I did it on GitHub and pulled and THEN (oh of course THEN it noticed). It wouldn't let me pull (even with --force) or push (even with --force). Now the repo state is "conflicsts" and it can't do ANYTHING. And this is because I did what git said to do... (commit changes to continue).
Previously the 0.1.0 milestone had a nice markdown checklist. Then GitHub changed how they render milestones and the list broke. Hence I have copied milestone 0.1.0 verbatim below:
Basic solving functionality with a basic GUI. Needs to be able to solve and explain most first degree equations, and simplify and factor first degree expressions.
2(x+6)
)This issue will be used to tracker further progress on the milestone, due to better Markdown support.
By using swing buttons and UTF8, we can avoid the special characters issue.
This page may help:
http://en.wikibooks.org/wiki/Unicode/List_of_useful_symbols#Mathematical
GUI layout Concept:
|Enter Equation: __________________| |
| ________|
| _ √ _ | _ ± _ | _ ≠ _ | |
||Evaluate| |
|---------------------------------------------------------|
I'm just opening this as an issue. We've already discussed it some. Our main two options seem to be:
Conclusion:
If the regexes you're using can tell us if the expression is valid, then it's definitely the better option. Otherwise I think using the later option would not be too difficult.
What it boils down to: Can regexes tell us if this is valid:
45(45< 6x2>/< mt>)
I've been working on the solver lately. It should be done in a couple of days (depending on how things go). After that I intend to write a wiki article explaining how to define a solving strategy. We'll need lots of those in order to power the solver.
More updates to come.
Currently the way I've been handling square roots is like this:
√5^
Means the square root of 5
But what about cubic and higher roots? For example, we could use ∛ and ∜, but then we're limited from going higher than four. These symbols are certainly useful, but I think they're a temporary solution at best. You might think we could just use 5√, but how do you differentiate between that and this: (4)√
? Ideas?
This has been an issue ever since I rewrote the parser. The problem is when AlgebraicParticle.getInstance()
or AlgebraicParticle.parseable()
are called. The parser thinks things like 2x²
mean the whole term is raised to the second power, when in reality only x
should be raised to the second power. Here's the current implementation (at least what I think it is) compared with what it should be:
String to parse | Type parsed | Correct Exponent | Parsed Exponent |
---|---|---|---|
2x+6² | Expression | 1* | 2 |
(2x+6)² | Expression | 2 | error |
(2x+6²) | Expression | 1* | 2 |
2x² | Term | 1* | 2 |
(2x)² | Term | 2 | error |
(2x²) | Term | 1* | 2 |
5² | Number | 2 | 2 |
(2)/(4)² | Fraction | error or 2** | 2 |
2(3)/(6)² | Mixed number | error or 2** | 2 |
√(3)² | Root | error or 2** | 2 |
x² | Variable | 2 | 2 |
* Any number raised to the first power is itself, hence, a power of 1 is the same as not raising it to any power.
** Could be an error because really it doesn't seem like this should be allowed (because for the fractions it would look like it raises the bottom to a power, when in reality it would raise the whole fraction to the power). It should be written as ((3)/(4))²
instead. Same goes for the root.
It should be clear that anything in the form of (<some expression here>)²
is the whole expression raised to the power of 2, while <some expression here>²
may be the whole expression, or just the last part (such as the last term, or last variable in a term), depending on context.
Currently the sign is removed first (-2x²
becomes 2x²
and the sign is set to negative), then any parentheses are removed ((3x+4)
becomes 3x+4
), and finally any superscripts are removed (2x²
becomes 2x
and the power is set to 2). Obviously this is a problem because the whole term is not supposed to be raised to a power, just the x
. This is also a problem if we have (2x+3)²
. Parentheses won't be removed, and the power will be set to 2, and then (2x+3)
isn't parseable because the parentheses are there but they shouldn't be.
We should remove superscripts first, then remove parentheses ((2x)²
becomes (2x)
, then 2x
). This doesn't solve everything though. 2x²
will still be seen as raising the whole term to the second power. Somehow we have to ignore the exponent, only if it's a term or expression and the power isn't on the outside of parentheses.
Looks like I've got my work cut out for me.
If you're wondering why I'm writing this issue, well, it makes me think things out much more clearly. My head is still half spinning, but I think I know an ugly solution for something that's really ugly to begin with.
Introduced in 0b24351 when the tests got moved. The directory structure changed, which was important for the sake of the unit tests, but now it can no longer load the GUI resources. I've tried modifying the URL a bit, but so far haven't figured out what works (haven't put a lot of effort into it). This is a reminder to look into it sometime. The code that needs to change is in com.github.nateowami.solve4x.ui/gui.java.
The problem is how to represent expressions like ((2x)²)²
or -(-(2x))
. The first is a term raised to the second power, raised to the second power. The current parser would crash over either of these, because it expects everything to be expression, term, number, fraction, mixed number, root, or variable. What it would do is remove the exponent and sign, and then the parentheses, giving it (2x)²
for the first (actually due to #23 it doesn't, but that's irrelevant), and -(2x)
for the second. When it tries to make one of the above mentioned types (expresion, term, etc.) parse it, none of them can, because they expect the sign and exponent to be handled by the superclass. This wouldn't be an issue for something like (2x²)²
, because after you remove the superscript and the parentheses, you get 2x²
, which is a valid term (without the 2
in there it would be a variable, and Variable
would complain about having to parse x²
).
Here's a little insight into how the expressions are represented:
Value | toString() |
---|---|
2x² |
Term [parts=[Number [integer=2, sign()=true, exponent()=1], Variable [var=x, sign()=true, exponent()=1]], exponent()=2] |
(2x)²+4 |
Expression [parts=[Term [parts=[Number [integer=2, sign()=true, exponent()=1], Variable [var=x, sign()=true, exponent()=1]], exponent()=2], Number [integer=4, decimal=0]]] |
To be clear, this is not just an issue with the parser, this is an incompatibility with the internal representation.
Possible solution: Create yet another subclass of AlgebraicParticle
called "Parentheses" or something, that only holds a sign and exponent, plus an inner AlgebraicParticle
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.