Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have been trying this problems for hours and cannot find any helpful clues.

How can I convert $Sinh[3\theta]+Sinh[\theta]$ to a rational function of x given $2Sinh[\theta] = x-x^{-1}$ by using only a SINGLE pattern replacement rule. I guess what single means is that we are only allowed to use one arrow.

My question is twofold:
1. I have one method but unsure of its correctness, also although I know the method but I am unable to write the code.
2. If my method is wrong, what is the correct one? This is the best method that I can think of.

My method is as follows:
Since we have the hyperbolic trig formula, we can use the rule (I will use Q instead)

Sinh[a Q] -> (x^a - x^-a)/2

I have tried many ways, and below are the 2 best ones that I think are the closest to the correct answers:

In: f := {Sinh[a Q] + Sinh[Q]} /. Sinh[a Q] -> (x^a - x^-a)/2;
In: {Sinh[3 Q]] + Sinh[Q]} // f  

Out: {1/2 (-x^-a + x^a) + Sinh[Q]}[{Sinh[Q] + Sinh[3 Q]}]

In: {Sinh[#1 Q] + Sinh[#2 Q]} /. Sinh[# Q] -> (x^# - x^-#)/2 &[3, 1]  

Out: {1/2 (-(1/x^3) + x^3) + Sinh[Q]]}

I always have troubles putting the rules into one entity such that it will replace every coefficient of Q, including 1. The output that I am looking for (using my method) is

Sinh[3Q] + Sinh[Q] = x^3 - x^-3 + x - x^-1  

Many thanks.

share|improve this question
1  
Would TrigToExp[Sinh[3 Q] + Sinh[Q]] /. Exp[a_. Q] -> 2 x^a work ? –  b.gatessucks May 18 '13 at 13:18
2  
From your sentence " I guess what single means is that we are only allowed to use one arrow." I infer this is homework. Am I right? –  belisarius May 18 '13 at 15:05
    
You might find Alternatives to be useful. –  whuber May 18 '13 at 15:20
    
@b.gatessucks Thanks! yes your method works. I have never used TrigToExp before, but I have learned new things now. –  user71346 May 19 '13 at 1:46
    
@belisarius Yes, this is an exercise. –  user71346 May 19 '13 at 1:47

1 Answer 1

up vote 6 down vote accepted

Using defaults values _. (for multiplication it is 1) works:

{Sinh[3 Q] + Sinh[Q]} /. Sinh[a_. Q] -> (x^a - x^-a)/2
share|improve this answer
1  
You should probably use :> to localize a –  Simon Woods May 18 '13 at 21:27
    
Great! Thanks so much Andrew. This is the first time I learn about defaults values. It is really helpful! –  user71346 May 19 '13 at 2:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.