# Any way to define variables as constant?

I want to come up with a function that will return true when I compare $(x-1)^2+C$ and $x^2-2x+C$ where $C$ is an arbitrary constant. Any way that you know can do this ?

edit retag close merge delete

Sort by ยป oldest newest most voted

So you want to know if a specific mathematical expression (like $(x-1)^2 - (x^2-2x))$ is a constant. Just check whether its derivative is zero:

sage: var('C, C2')
sage: diff(((x-1)^2+C) - (x^2-2*x+C2), x)
0
sage: bool(diff(((x-1)^2+C) - (x^2-2*x+C2), x) == 0)
True

more

There is no such function, because they're not equal. Perhaps the second expression should be x^2-2x+1+C...

What have you tried? Here are two options:

sage: var('C')
sage: expand(((x-1)^2+C) - (x^2-2*x+1+C))
0
sage: bool(expand((x-1)^2+C) == expand(x^2-2*x+1+C))
True

more

I know there is none. But I want to make one if possible at all. Probably you will like the expression with different "C"

$(x-1)^2+C_1$ and $x^2-2x+C_2$

For any value of $C_1$ there is a value of $C_2$ that makes the two equations equal. Anyone else have any idea?

more

one can find indefinite integral of sin(x)cos(x) as (1/2)*(sin(x))^2+C_1 or -(1/2)*(cos(x))^2+C_2 both are right. But can I make a function using sage methods that will consider both as same?

( 2010-11-17 13:20:55 +0200 )edit

hey you can put math between dollar signs and it'll typeset

( 2010-11-17 13:22:49 +0200 )edit

will do next time. thanks for letting me know.

( 2010-11-17 13:26:36 +0200 )edit

you can edit your previous posts too :)

( 2010-11-17 13:30:12 +0200 )edit

I was able to edit the answer, but do not see any edit button for comments.

( 2010-11-17 13:41:33 +0200 )edit