Comments (5)
I'll look into this as soon as I can (likely a couple of weeks). Any help welcome.
from algebrite.
Hi, I think that the problem is in the function Eval_testeq
To compare [1,2] and [3,4], this function calculates the difference between [1,2] and [3,4] and then it does this:
if (iszero(p1))
# if we got to zero then fine
push_integer(1)
else if isnum(p1)
# if we got to any other number then
# we know they are different
push_integer(0)
else
# if we didn't get to a number then we
# don't know whether the quantities are
# different so do nothing
push orig
The problem is that the difference between [1,2] and [3,4] is a TENSOR!!!!!
Is not zero, is not a number, it is a tensor and you can fix the function this way:
if (iszero(p1))
# if we got to zero then fine
push_integer(1)
else if isnum(p1)
# if we got to any other number then
# we know they are different
push_integer(0)
else if istensor(p1)
# if we got to any other tensor then
# we know they are different
push_integer(0)
else
# if we didn't get to a number then we
# don't know whether the quantities are
# different so do nothing
push orig
Please check this commit:
pabloahb@ad3bf87
from algebrite.
Additionally,
I found an error in the "Eval_and" function:
This function searches for zeros and if it does not find them, it returns 1
# and definition
Eval_and = ->
p1 = cdr(p1)
while (iscons(p1))
push(car(p1))
Eval_predicate()
p2 = pop()
if (iszero(p2))
push_integer(0)
return
p1 = cdr(p1)
push_integer(1)
The problem is that when this function receives undefined arguments or arguments different than zero, the function will assume that the argument is true because it is different from 0 and this produces a false positive error.
Algebrite.run("and(undef_a,undef_b,undef_c)")
"1"
Algebrite.run("and(undef_var,10,-20)")
"1"
from algebrite.
@pabloahb thanks, yes, those are the sections that I'm reworking. There are a couple of cases that we also need to look at... for example we can't quite assume this piece:
# if we got to any other tensor then
# we know they are different
because e.g. in the case [0,0]==[0,a]
the result there would be false, while the result should really be push orig
because we don't know about a
, so the equality test should remain unevaluated rather than false.
I just re-worked "and", and I'm going to re-work the others tomorrow morning, so we can all review hopefully tomorrow and see where we are at.
from algebrite.
I think this should fix booleans.
Outline of the changes:
- there is a new routine "isZeroLikeOrNonZeroLikeOrUndetermined" which is important
- then the "check" function has been reworked.
- then "test*" have been changed.
- finally, "and", "or", "not" have been changed.
All other changes are just due to renaming of a couple of functions.
See the three changed test files to see if they convince you.
from algebrite.
Related Issues (20)
- Solving Boolean expressions
- Solving systems of equations
- Absolute value syntax errors
- Solving equations involving fractions
- Simplify
- GUI for user to edit/enter the equation in HTML
- Testing equivalance could be more smart, easily
- Update NPM version
- cann't simpifay apk
- the order of the powers of the polynomial is reversed HOT 1
- How to solve equations? HOT 2
- How to identify if an expression given by a human is in its simplified form HOT 4
- Is there some kind of AST ? HOT 1
- draw function is needed HOT 1
- Can't return numerical results < 1e-6. Can't substitute variables with scientific notation
- Infinite loop when try to inverse a 1x1 matrix
- Computation of binomial
- Display order of polynomial monomials
- simplification with exponents HOT 1
- i raised to exponents bigger than 4 is not calculated correctly
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from algebrite.