Processing math: 100%
Ask Your Question
1

Any way to define variables as constant?

asked 14 years ago

Shu gravatar image

updated 14 years ago

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

Preview: (hide)

3 Answers

Sort by » oldest newest most voted
2

answered 14 years ago

So you want to know if a specific mathematical expression (like (x1)2(x22x)) 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
Preview: (hide)
link
1

answered 14 years ago

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
Preview: (hide)
link
0

answered 14 years ago

Shu gravatar image

updated 14 years ago

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

(x1)2+C1 and x22x+C2

For any value of C1 there is a value of C2 that makes the two equations equal. Anyone else have any idea?

Preview: (hide)
link

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 ( 14 years ago )

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

Evgeny gravatar imageEvgeny ( 14 years ago )

will do next time. thanks for letting me know.

Shu gravatar imageShu ( 14 years ago )

you can edit your previous posts too :)

Evgeny gravatar imageEvgeny ( 14 years ago )

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

Shu gravatar imageShu ( 14 years ago )

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: 14 years ago

Seen: 3,088 times

Last updated: Nov 17 '10