Ask Your Question
1

Any way to define variables as constant?

asked 2010-11-17 05:39:32 -0500

Shu gravatar image

updated 2010-11-17 06:38:35 -0500

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 flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
2

answered 2010-11-17 07:04:42 -0500

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
edit flag offensive delete link more
1

answered 2010-11-17 06:00:13 -0500

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
edit flag offensive delete link more
0

answered 2010-11-17 06:18:06 -0500

Shu gravatar image

updated 2010-11-17 06:39:50 -0500

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?

edit flag offensive delete link more

Comments

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?

Shu gravatar imageShu ( 2010-11-17 06:20:55 -0500 )edit

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

Evgeny gravatar imageEvgeny ( 2010-11-17 06:22:49 -0500 )edit

will do next time. thanks for letting me know.

Shu gravatar imageShu ( 2010-11-17 06:26:36 -0500 )edit

you can edit your previous posts too :)

Evgeny gravatar imageEvgeny ( 2010-11-17 06:30:12 -0500 )edit

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

Shu gravatar imageShu ( 2010-11-17 06:41:33 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2010-11-17 05:39:32 -0500

Seen: 1,689 times

Last updated: Nov 17 '10