# Have transformation rules to be explicitly set?

I think this problem is not the hardest one, but I can't hit on it.

I want to NSolve an equation. For this equation I use a transformation rule "ampTimes". First I used it like this:

ampTimes = {tf -> .03, th -> .002}
NSolve[E^(th/t) + E^((tf + th)/t) == 2 E^(tf/t) /. ampTimes, t, Reals]
{tf -> 0.03, th -> 0.002}
{{t -> 0.00288552}}

and it worked. I get a solution for t. Due to clearity, I switched to this expression:

ampTimes = {tf -> (.315 - .285), th -> (.287 - .285)}
NSolve[E^(th/t) + E^((tf + th)/t) == 2 E^(tf/t) /. ampTimes, t, Reals]
{tf -> 0.03, th -> 0.002}
{}

The output for ampTimes stays the same, but I didn't get a solution for my equation. I thought, the transformation rule may couldn't handle the difference, so I changed it to

(.315 - .285);
(.287 - .285);
ampTimes = {tf -> %%, th -> %}
NSolve[E^(th/t) + E^((tf + th)/t) == 2 E^(tf/t) /. ampTimes, t, Reals]
{tf -> 0.03, th -> 0.002}
{}

Again, the output fpr ampTimes seems right, but I didn't get a solution.

It wouldn't be a problem to use the transformation rule explicitly, but as said, wouldn't be supporting for clearity. Plus the problem get me and I realy want to know WHY it doesn't work the way I thought.

EDIT: I guess it has something to do with the precision.

-
I think you are right since the subtraction result is: {tf -> 0.030000000000000027, th -> 0.0020000000000000018} and setting that explicitely won't work too. I hope someone competent will clarify this "feature". –  Kuba Jan 14 '14 at 9:27
Opps, missed Kuba's comment above. First case the FullForm of ampTimes is List[Rule[tf,0.03],Rule[th,0.002]] while in the second case it is List[Rule[tf,0.030000000000000027],Rule[th,0.0020000000000000018]] which has to be (something to do with) the cause. –  Ymareth Jan 14 '14 at 9:37
I fixed the problem with SetAccurancy[], but it bothers me, never to know if what I see is what I get, like you said Nasser. One will have to check accurancy every time a function gives no solution!? –  Phab Jan 14 '14 at 9:38
Funny is that if one makes this: ampTimes = {tf -> (.315 - .285), th -> (.287 - .285)} // Chop, which produces the first example above and then starts to solve the equation, the solving process lasts forever. My question to Phab, however, why not using FindRoot which exhibits no such difficulties? –  Alexei Boulbitch Jan 14 '14 at 10:22
@AlexeiBoulbitch FindRoot[] would not be working, because I never know where my t should be. –  Phab Jan 14 '14 at 10:47

Ok, so my guess wasn't wrong at all ...

if one uses SetAccuracy[] it'll work.

1st approach

(.315 - .285);
(.287 - .285);
ampTimes = {tf -> SetAccuracy[%%, 5], th -> SetAccuracy[%, 5]}
NSolve[E^(th/t) + E^((tf + th)/t) == 2 E^(tf/t) /. ampTimes, t, Reals]

Out= {tf -> 0.0300, th -> 0.0020}
Out= {{t -> 0.0029}}

2nd approach

ampTimes = {tf -> SetAccuracy[(.315 - .285), 5],
th -> SetAccuracy[(.287 - .285), 5]}
NSolve[E^(th/t) + E^((tf + th)/t) == 2 E^(tf/t) /. ampTimes, t, Reals]

Out= {tf -> 0.0300, th -> 0.0020}
Out= {{t -> 0.0029}}

So it looks like the output's accurancy on default is too much for NSolve.

ampTimes = {tf -> (.315 - .285), th -> (.287 - .285)}
ampTimes

Out= {tf -> 0.03, th -> 0.002}
Out= {tf -> 0.03, th -> 0.002}

But with Copy/Paste one'll get

{tf -> 0.030000000000000027, th -> 0.0020000000000000018}
-