# How to get mathematica to give an exact answer rather than a numerical approx

I tried // Rationalize but it just gave the same answer • Use Maximize to get exact answer. Also, Rationalize[_,0] to force rationalization for any number.
– Acus
Jun 2 at 9:28
• @user18792 I tried rationalize[_,0] but it gave me {605021091/95662234, {t -> 80143857/51021164}} I the answer I was looking for was {2 Sqrt, {t -> [Pi]/2}}. Any suggestions what went wrong? Jun 2 at 9:57
• Since Sqrt, which is exact answer is in not a rational number your cannot expect to obtain it with Rationalize. I only wrote last suggestion since your complained that rationalize returned the same answer. And the second argument of Rationalize forces rationalization even if good approximation (with existing precision) is difficult to find.
– Acus
Jun 2 at 10:26

Clear["Global*"]


Maximize is preferred when it works; however, when a numeric technique is required, RootApproximant can find a close approximation that is not necessarily rational.

{max, arg} = FindMaximum[Sqrt[4*Sin[t]^2 + 36 Cos[2 t]^2], t]

(* {6.32456, {t -> 1.5708}} *)

max /. r_Real :> RootApproximant[r]

(* 2 Sqrt *)


And when you expect/suspect a rational factor of a known irrational value

arg /. r_Real :> Pi*RootApproximant[r/Pi]

(* {t -> π/2} *)


Making use of Maximize and the periodicity, we succeed with it.

Maximize[{Sqrt[4*Sin[t]^2 + 36 Cos[2 t]^2], t > -Pi && t <= Pi}, t]


{2 Sqrt, {t -> \[Pi]/2}}`