Post Reply 
PROBLEM in function PART, part({x,y^2}) returns → "x"
05-26-2016, 05:10 PM (This post was last modified: 06-07-2016 02:56 AM by compsystems.)
Post: #1
PROBLEM in function PART, part({x,y^2}) returns → "x"
Syntax:
part(Expr, Integer)

Returns the nth sub expression of an expression. If the second argument is empty, returns the number of parts.
If the second argument is ZERO, returns the operator if any, otherwise returns the same expression as string

samples OK

part(sin(x)+cos(y)) → 2 // two parts sin(x) & cos(y)
part(sin(x)+cos(y),1) → sin(x) // first part
part(sin(x)+cos(y),2) → cos(y) // second part
part(sin(x)+cos(y),3) → "nonexistent part in the expression"
part(sin(x)+cos(y),0) → "+" // operator between parts

part( part(sin(x)+cos(y),1)) → 1 // number of parts of the first part
part( part(sin(x)+cos(y),2)) → 1 // number of parts of the second part

part( part(sin(x)+cos(y),1),1) → x // firts part of the firts part, sin(x)→ x
part( part(sin(x)+cos(y),2),1) → y // firts part of the second part, cos(y)→ y

part( part(sin(x)+cos(y),1),0) → "sin" // operator of the firts part, sin(x)→ "sin"
part( part(sin(x)+cos(y),2),0) → "cos" // operator of the second part, cos(x)→ "cos"


part(sin(x)) → 1 // one part
part(sin(x),1) → x // first part
part(sin(x),0) → "sin" // operator "sin"

part(part(exp(x)*sin(x) + cos(x),1),2) → sin(x) // second part of the first part exp(x)*sin(x) → sin(x)
part(part(exp(x)*sin(x) + cos(x),1),0) → "*" // operator of the first part exp(x)*sin(x) → "*"
part(part(exp(x)*sin(x) + cos(x),2),0) → "cos" // operator of the second part cos(x)→ "cos"
part(part(exp(x)*sin(x) + cos(x),2),1) → "x"
part(part(exp(x)*sin(x) + cos(x),1)) → 2
part(part(exp(x)*sin(x) + cos(x),1),1) → exp(x)
part(part(part(e^x*sin(x) + cos(x),1),1),1) → x
part(part(part(e^x*sin(x) + cos(x),1),1),0) → "exp"

special cases

part(-X) → 1 // one parts
part(-X,1) → 1 // firts part, X
part(-X,0) → "-" // operator "-"

part(X1) → 0 // No parts
part(X1,0) → "X1"

part(-1) → 0 // No parts OK
part(-X,0) → "-1"

part(-5!) → 0 // No parts OK
part(-5!,0)) → "-120"

--------------

BUG
part(e^x) → 1 // must be 2, e & x, with "^" operator, no consistency with string(e^x) -> "e^x" and not "exp(x)", this generates problems within a program code
Find all posts by this user
Quote this message in a reply
05-26-2016, 05:41 PM
Post: #2
RE: possible BUG in function PART, part(e^x) → 1
not a bug, because e^x is exp(x)
Find all posts by this user
Quote this message in a reply
05-26-2016, 05:50 PM (This post was last modified: 06-06-2016 11:02 PM by compsystems.)
Post: #3
RE
no consistency with

string(e^x) -> "e^x" and not "exp(x)"
Find all posts by this user
Quote this message in a reply
05-26-2016, 06:00 PM (This post was last modified: 06-06-2016 11:04 PM by compsystems.)
Post: #4
RE:
If the function tells me that no parts, why accepts argument 1?

part(X1) → 0 // No parts, OK
part(X1,0) → 0 // "X1" OK
part(X1,1) → X1 ??? this is also an inconsistency
Find all posts by this user
Quote this message in a reply
05-27-2016, 05:56 AM
Post: #5
RE: possible BUG in function PART, part(e^x) → 1
Why? I can consider an object which is not an expression as an expression without root-node operator and argument itself.
Find all posts by this user
Quote this message in a reply
06-02-2016, 03:07 AM (This post was last modified: 06-06-2016 11:03 PM by compsystems.)
Post: #6
RE:
Why returns "x"

part({x,y^2}) returns → "x" BUG? → 2 elements or 2 parts, ok
part([x,y^2]) → "x" BUG? → 1 row or 1 part, ok
part([[9,8],[7,6]]) → "[9,8]" BUG? → 2 rows or 2 parts, ok
Find all posts by this user
Quote this message in a reply
06-06-2016, 01:15 AM (This post was last modified: 06-06-2016 11:03 PM by compsystems.)
Post: #7
RE:
a: part(sin(x)) → 1 // OK 1 part or argument
a1: part(sin(x),1) → x // OK argument of SIN
a2: part(sin(x),0) → "sin" // OK operator "SIN"
a3: part(sin(x),2) → "Error: Bad Argument Value" // OK there is only one part according to previous result ITEM (a)


b: part(exp(y)) → 1 // OK 1 part or argument
b1: part(exp(y),1) → y // OK argument of EXP
b2: part(exp(y),0) → "exp" // OK operator "EXP"
b3: part(exp(y),2) → "Error: Bad Argument Value" // OK there is only one part according to previous result ITEM (b)

c: part(e) → 1 // OK 1 part or argument /! argument exp(1)==e
c1: part(e,1) → 1 //
c2: part(e,0) → "exp" // OK operator "EXP"
c3: part(e,2) → "Error: Bad Argument Value" // OK there is only one part according to previous result ITEM (c)

d: part(i) → 0 // OK 0 parts
d1: part(1,0) → "i" // OK as no operator input is returned as a string
d2: part(i,2) → "Error: Bad Argument Value" // OK there is not parts according to previous result ITEM (d)
d3: part(i,1) → i BUG contradiction with ITEM (d) within a program that causes a bad outing,

d2: part(i,-1) → i
may be valid assume -1 if no parts and if desired return same input,
Find all posts by this user
Quote this message in a reply
06-06-2016, 06:03 AM
Post: #8
RE: possible BUG in function PART, part(e^x) → 1
You should use type before running part. The behaviour of part on non symbolic objects is not warranted.
Find all posts by this user
Quote this message in a reply
06-06-2016, 12:21 PM (This post was last modified: 06-06-2016 11:03 PM by compsystems.)
Post: #9
Re:
(06-06-2016 06:03 AM)parisse Wrote:  You should use type before running part. The behaviour of part on non symbolic objects is not warranted.

I do not understand.

the following part({x,y^2}) is a list of math symbolic objects, the output functions must be guaranteed and must be accurate otherwise a CAS does not work
part("hello") "Error: Bad Argument Value" // OK, "hello" is not a math symbolic object

anyone else think of the examples above
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)