Ask Your Question

sage_learner's profile - activity

2021-10-23 20:09:10 +0200 received badge  Popular Question (source)
2013-01-14 04:59:09 +0200 commented answer implication

Thank you. Yes you are right , it is my mistake. Mathematics gives False for that implication.

2013-01-08 08:28:30 +0200 asked a question implication

Hello !

I wish to know how implication works in sage. In mathematica "Implies[True, False]" gives true.

In sage I wrote "true.implies(false)" it gives attribute error : "'bool' object has no attribute implies"

May I know How I should use implies in sage ?

Thanks.

2013-01-07 07:09:30 +0200 commented answer Need to improve a function in sage which checks trueness of expressions in an example.

Thanks for the opinion. Yes I am interesting in finding whether computer algebra system like sage could be useful for checking purpose. Again thanks.

2013-01-05 19:24:36 +0200 commented question Need to improve a function in sage which checks trueness of expressions in an example.

Actually I am using mathematical problems from secondary school or high school level and trying to develop a function in sage which can check whether consecutive expressions are logically true or not, and hence we can check whole example whether it is correct or not.

2013-01-05 03:41:57 +0200 commented question Need to improve a function in sage which checks trueness of expressions in an example.

Sorry for improper English. In the preceding post I wanted to know How 'or' works in sage. But I got answer and now I know that. In this post I said I really need comments and suggestions because I want to edit this function and want to make it more reliable.

2013-01-04 10:55:37 +0200 asked a question Need to improve a function in sage which checks trueness of expressions in an example.

Hello !

Here I have made a function in sage which checks equality between consecutive expressions in an example.

This function takes a set of examples as an argument. I want to improve my function and I really need comments and suggestions for correcting this function.

Two examples which I have used are as follows.

Example 1:

(1 - ((1 + sqrt(a))/(sqrt(a)- 1)))

=

(1 + ((1 + sqrt(a))/(-sqrt(a) + 1)))

=

(1 + ((1 + sqrt(a))* (1 + sqrt(a))/((-sqrt(a) + 1) * (sqrt(a) + 1))))

=

(1 + ((1 + 2* sqrt(a) + a)/(1 - a)))

=

(1 + ((1+a + 2* sqrt(a) )/(1-a)))

=

(((1-a)/(1-a)) + ((1+a + 2* sqrt(a))/(1-a)))

=

(1-a+1+a+ 2*sqrt(a))/(1-a)

=

(2+2*sqrt(a))/(1-a)

Example2:

x^2 + 2*x -3 == 0

<=>

x == (-2 + (2^2 -41(-3))^(1/2))/(21) or x == (-2 - (2^2 -41(-3))^(1/2))/(21)

<=>

x == (-2 + (4+12)^(1/2))/(21) or x == (-2 - (4+12)^(1/2))/(21)

<=>

x == (-2 + (16)^(1/2))/(21) or x == (-2 - (16)^(1/2))/(21)

<=>

x == (-2 + 4)/(21) or x == (-2 - 4)/(21)

<=>

x == (2)/(2) or x == (-6)/(2)

<=>

x == 1 or x == -3

The Problem is , following function checks first example correctly but not second example. In the second example, final answer is x == 1 or x == -3 but even if I provide wrong answer x == -1 or x == -3 it gives true. I have already received explanation about how 'or' behaves. see here

---------------Function begins ---------------

var('j,e,exprList,as1,i,lhs,rhs,r,r1,x')

def ComExpr(a):

r1 = []; 

for j in range(0,len(a)):

forget();

    e = a[ZZ(j)]

    exprList = e[0]

    as1 = e[1]
    print len(a)

r = [];

    for i in range(0,len(exprList)-1):

    forget(); 

        lhs = exprList[ZZ(i)]

        rhs = exprList[ZZ(i+1)]

    assume(as1 and lhs);   

    p1 = rhs.full_simplify()

    forget();

        assume(as1 and rhs); 

    p2 = lhs.full_simplify()

    r.append(bool(p1 and p2))

    r1.append(r)    

return r1

e1 is first example containing two elements one is list of expressions and another is assumption. Same for e2.

e1 = [[(1 - ((1 + sqrt(a))/(sqrt(a)- 1))) == (1 + ((1 + sqrt(a))/(-sqrt(a) + 1))), (1 + ((1 + sqrt(a))/(-sqrt(a) + 1))) == (1 + ((1 + sqrt(a))* (1 + sqrt(a))/((-sqrt(a) + 1) * (sqrt(a) + 1)))), (1 + ((1 + sqrt(a))* (1 + sqrt(a))/((-sqrt(a) + 1) * (sqrt(a) + 1)))) == (1 + ((1 + 2* sqrt(a) + a)/(1 - a))), (1 + ((1 + 2* sqrt(a) + a)/(1 - a))) == (1 + ((1+a + 2* sqrt(a) )/(1-a))), (1 + ((1+a + 2* sqrt(a) )/(1-a))) == (((1-a)/(1-a)) + ((1+a + 2* sqrt(a) )/(1-a))), (((1-a)/(1-a)) + ((1+a + 2* sqrt(a))/(1-a))) == (1-a+1+a+ 2*sqrt(a))/(1-a)], a > 1];

sage: ComExpr([e1]) 1 [[True, True, True, True, True]]

e2=[[x^2 + 2x -3 == 0, x == (-2 + (2^2 -41(-3))^(1/2))/(21) or x == (-2 - (2^2 -41(-3))^(1/2))/(21),x == (-2 ... (more)

2013-01-04 09:37:40 +0200 commented answer Behavior of 'or'

Thank you.

2013-01-04 08:24:44 +0200 commented answer Express domain membership

Thank you, answer is very useful to me.

2013-01-04 08:24:13 +0200 commented answer Express domain membership

Thank you very much.

2013-01-04 08:21:45 +0200 received badge  Editor (source)
2013-01-04 08:21:04 +0200 asked a question Behavior of 'or'

Hello !

Here I have observed something in sage.

sage: (x == 1 or x == -3).full_simplify()

x == -3

sage: (x == -1 or x == -3).full_simplify()

x == -3

sage: (x == -1 or x == 3).full_simplify()

x == 3

sage: (x == -1 or x == -3).full_simplify()

x == -3

sage: (x == 1 or x == -3).full_simplify()

x == -3

I wish to know that why sage replies with the second argument. It is very necessary for me to understand this behavior of sage.

Many Thanks !

2013-01-02 07:25:18 +0200 asked a question Express domain membership

Hello I am trying to write an expressing showing its membership in ZZ, RR, QQ. e.g In sage "assume(x in ZZ) "gives me error.

If I want to show that the symbol x belongs to ZZ then how should I express it ?

Best wishes

2012-10-27 04:07:52 +0200 received badge  Student (source)
2012-10-26 17:10:36 +0200 commented answer Equivalence operator

Thank you very much !

2012-10-26 17:10:16 +0200 received badge  Supporter (source)
2012-10-26 11:08:10 +0200 asked a question Equivalence operator

Hi ! Here I have a small sage code.

x = var('x'); assume(x>0); print([x>0] == [1==1])

Sage prints it as "False".

In the above piece of code "[x>0] == [1==1]" is logically true as there is already an assumption, though it gives False.

I wish to know How does comparison operator "==" works ? Specially when comparing two predicates ? Does there any other function exist for such comparison ?

Best regards

2012-10-26 09:14:34 +0200 commented answer Assumptions in sage

I got it.. Thank you. I wish to understand something regarding following code. x = var('x'); assume(x>0); print([x>0] == [1==1]) Sage answers it as "False" In the above piece of code "[x>0] == [1==1]" is logically true but it is gives False. I wish to know How does comparison operator "==" works ? Specially when comparing two predicates ? Does there any other function exist for such comparison ? Best regards

2012-10-25 17:04:20 +0200 asked a question Assumptions in sage

Hello!

I am a sage beginner and I wish to know that How sage handles assumptions ?

My example is as follows.

a= var('a'); solve((a-1)*x ==3, x);

and sage solves and gives correct solution [x==(3 / (a - 1))]. But here how the assumption (a != 1) is handled ? Because solution is not defined for (a=1).

Best regards

Charmi