Message Boards Message Boards

0
|
2608 Views
|
1 Reply
|
3 Total Likes
View groups...
Share
Share this post:
GROUPS:

How to use Replace correctly?

Posted 12 years ago
Hello,

I'm new using Mathematica. I'm trying to use Mathematica to follow a demostration where I have to perform transformations in expressions.
I arrive to the following problem: in a part of an expression, I need to use the following replacement: Sin(x) = -Sin(-x). So I apply it as follows:
F1 = 1 + Sin[a - b]
Replace[F1, Sin[x_] -> -Sin[-x]]

I was expecting the following result: F1=1-Sin[b-a]
However, I find Mathematica gives the initial result, that is: F1=1 + Sin[a - b]
I guess Mathematica tries to simplify the expression and arrives to the initial expression.How can I avoid this? I have tried several ways, but without success...

Thank you.
POSTED BY: sergi segador
Posted 12 years ago
You can use Hold to prevent evaluation of an expression:
Hold[1 + Sin[a - b]] /. Sin[x_] :> -Sin[-x]
Hold[1 - Sin[-(a - b)]]
POSTED BY: Alexey Popkov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract