# Strange Solutions

Sometimes the solutions given by Sage are weird. For example, the equation below has only one solution, yet sage gives this output.

sage: solve(0.1*1==1*e^(-0.38*t),t)
[t == 50*log(10^(1/19)*e^(2/19*I*pi)),
t == 50*log(10^(1/19)*e^(4/19*I*pi)),
t == 50*log(10^(1/19)*e^(6/19*I*pi)),
t == 50*log(10^(1/19)*e^(8/19*I*pi)),
t == 50*log(10^(1/19)*e^(10/19*I*pi)),
t == 50*log(10^(1/19)*e^(12/19*I*pi)),
t == 50*log(10^(1/19)*e^(14/19*I*pi)),
t == 50*log(10^(1/19)*e^(16/19*I*pi)),
t == 50*log(10^(1/19)*e^(18/19*I*pi)),
t == -900/19*I*pi + 50/19*log(10),
t == -800/19*I*pi + 50/19*log(10),
t == -700/19*I*pi + 50/19*log(10),
t == -600/19*I*pi + 50/19*log(10),
t == -500/19*I*pi + 50/19*log(10),
t == -400/19*I*pi + 50/19*log(10),
t == -300/19*I*pi + 50/19*log(10),
t == -200/19*I*pi + 50/19*log(10),
t == -100/19*I*pi + 50/19*log(10),
t == 50/19*log(10)]
edit retag close merge delete

Sort by ยป oldest newest most voted

[ This smells homework. Therefore, some hints... ]

Ahem ! Your equation has, indeed one real solution... and 18 complex solutions. Its structure will become more transparent if you accept to replace its float coefficient by exact numbers and solve it symbolically...

The numerical values should also give you some hints :

sage: [(E.subs(s).rhs()-E.subs(s).lhs()).n().abs() for s in solve(0.1*1==1*e^(-0.38*t),t)]
[8.88516071398867e-16,
8.97447312850170e-16,
7.34788079488409e-17,
8.93565536393413e-16,
8.96581565195064e-16,
9.00254100846723e-16,
9.04575147216186e-16,
9.09535461462144e-16,
9.15124648438264e-16,
2.22176931601818e-16,
1.97899526057791e-16,
5.39806219580408e-16,
1.49555718205910e-16,
1.25570576985110e-16,
1.01827474616583e-16,
7.85462105727423e-17,
5.63026431885206e-17,
3.70172377524261e-17,
2.77555756156289e-17]

EDIT to answer your further question : another way to solve this is, as I told already, to use an exact ring, i. e. replace 0.1 by 1/10 and 0.38 by 38/100 (or 19/50, according to your tastes), so you will work with rationals (which have an exact representation in Sage) in place of "floats", which are limited-precision approximations).

sage: var("t")
t
sage: E=1/10-1*e^(-38/100*t) ## Left-hand - right-hand
sage: S=solve(1/10-1*e^(-38/100*t),t) ## (Exact) solutions
## Check by substitution that all the proposed solutions are indeed solutions.
sage: [E.subs(s).trig_expand().expand() for s in S]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

And your real solution is :

sage: [s for s in S if s.rhs().is_real()]
[t == 50/19*log(10)]

Clearer ?

more

Thanks for the answer. Is there a function to display the real solution only?

( 2018-04-13 08:06:25 +0200 )edit

## Stats

Seen: 201 times

Last updated: Apr 15 '18