3
$\begingroup$

How can I reduce this to real expression?

expr= 1.0000000000000002` - 
 0.001255648708575318` E^(-10.012605635948601` t) + 
 0.17959901255646785` E^(-0.8648909907775479` t) - \
(0.5891716819239463` - 
    0.5616835474433535` I) E^((-0.061418353303592355` - 
     0.06265925347379434` I) t) - (0.5891716819239463` + 
    0.5616835474433535` I) E^((-0.061418353303592355` + 
     0.06265925347379434` I) t);

It looks good when I plot it but I want to simplify to real expression.

Plot[expr, {t, 0, 200}, PlotRange -> All, GridLines -> Automatic]

enter image description here

$\endgroup$

3 Answers 3

3
$\begingroup$
Rationalize[expr, 0] // Im // ComplexExpand

0.

It means that expr is real.

Rationalize[expr, 0] // Re// ComplexExpand
$\endgroup$
2
$\begingroup$

This is a problem created by using machine numbers. These are seldom 100% accurate, they are most of the time an approximation. And if you have an expression like: x - Conjugate[x] it is possible that the imaginary part does not accurately cancel.

Here is an example:

x = 1.23456789012345678;
x - Conjugate[x]
(* 0.*10^-17 *)

But if you are sure that the result is real, you can safely take the real part using: Re.

If you want to avoid such problems, you may use rational numbers.

$\endgroup$
1
$\begingroup$

The last two terms can be simplified to real as follows FullSimplify[-(c - d I) E^((a + b I) t) - (c + d I) E^((a - b I) t)==-2 E^(a t) (c Cos[b t] + d Sin[b t])]/.

1. - 0.00125565 E^(-10.0126 t) + 0.179599 E^(-0.864891 t)-2 E^(a t) (c Cos[b t] + d Sin[b t])
/.{a -> -0.061418353303592355`, b -> -0.06265925347379434`, c -> 0.5891716819239463`, d -> 0.5616835474433535`}

(*1. - 0.00125565 E^(-10.0126 t) + 0.179599 E^(-0.864891 t) - 
 2 E^(-0.0614184 t) (0.589172 Cos[0.0626593 t] - 
    0.561684 Sin[0.0626593 t])*)

Or in one line without doing the algebra...

expr // ComplexExpand // Simplify // Chop // FullSimplify

Chop gets rid of the 0`*I leftovers.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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