2
$\begingroup$

I want to use Expand[(x - 7)^2 + 49]] with TeXForm[HoldForm of the expression Cos[Pi/2 + 5/(Expand[(x - 7)^2 + 49])]. I used

TeXForm[HoldForm[Cos[Pi/2 + 5/(Expand[(x - 7)^2 + 49])]]]

I got

\cos \left(\frac{\pi}{2}+\frac{5}{\text{Expand}\left[(x-7)^2+49\right]}\right)

If I use

TeXForm[Cos[Pi/2 + 5/((x - 7)^2 + 49)]]

I got

-\sin\left(\frac{5}{(x-7)^2+49}\right)

How can I get the result like this $\cos\left (\dfrac{\pi}{2} + \dfrac{5}{98 - 14 x + x^2}\right )$

$\endgroup$

1 Answer 1

4
$\begingroup$

You could use Inactivate instead of HoldForm to avoid evaluating Cos:

TeXForm[StandardForm[Inactivate[Cos[Pi/2 + 5/(Expand[(x - 7)^2 + 49])], Cos]]]

$$\text{cos}\left(\frac{\pi }{2}+\frac{5}{98-14 x+x^2}\right)$$

Now it is easy to change the brackets to parenthesis if you want, as well as the Cos function.

$\endgroup$
2
  • $\begingroup$ Your out put different to which I want. Pi/2+ and +Pi/2. $\endgroup$ Commented Apr 24, 2018 at 9:44
  • $\begingroup$ @minhthien_2016 See my edit $\endgroup$ Commented Apr 24, 2018 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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