Skip to main content
added 248 characters in body
Source Link
Jason B.
  • 70.2k
  • 3
  • 144
  • 298

You can just round the result, and then they are the same number.

Total[ E^Total[E^(Round[list, 10.^-6]/t)]
 
(* 4 E^(-0.683013/t) + 3 E^(-0.183013/t) + 
 2 E^(0.183013/t) + E^(
 0.683013/t) *)

The Exp and Round function are listable, so you don't need an explicit call to Sum. But if you wanted one,

Sum[ E^(Round[list[[k]], 10.^-6]/t), {k, Length[list]}]

Edit You can also use SetPrecision

Total@Exp[ SetPrecision[list, 6]/t] 

(* 4 E^(-0.683013/t) + 3 E^(-0.183013/t) + 
 2 E^(0.183013/t) + E^(0.683013/t) *)

But I don't see an equivalent to SameTest for Plus

You can just round the result, and then they are the same number.

Total[ E^(Round[list, 10.^-6]/t)]
 
4 E^(-0.683013/t) + 3 E^(-0.183013/t) + 2 E^(0.183013/t) + E^(
 0.683013/t)

The Exp and Round function are listable, so you don't need an explicit call to Sum. But if you wanted one,

Sum[ E^(Round[list[[k]], 10.^-6]/t), {k, Length[list]}]

You can just round the result, and then they are the same number.

Total[E^(Round[list, 10.^-6]/t)]
(* 4 E^(-0.683013/t) + 3 E^(-0.183013/t) + 
 2 E^(0.183013/t) + E^(0.683013/t) *)

The Exp and Round function are listable, so you don't need an explicit call to Sum. But if you wanted one,

Sum[ E^(Round[list[[k]], 10.^-6]/t), {k, Length[list]}]

Edit You can also use SetPrecision

Total@Exp[ SetPrecision[list, 6]/t] 

(* 4 E^(-0.683013/t) + 3 E^(-0.183013/t) + 
 2 E^(0.183013/t) + E^(0.683013/t) *)

But I don't see an equivalent to SameTest for Plus

Source Link
Jason B.
  • 70.2k
  • 3
  • 144
  • 298

You can just round the result, and then they are the same number.

Total[ E^(Round[list, 10.^-6]/t)]

4 E^(-0.683013/t) + 3 E^(-0.183013/t) + 2 E^(0.183013/t) + E^(
 0.683013/t)

The Exp and Round function are listable, so you don't need an explicit call to Sum. But if you wanted one,

Sum[ E^(Round[list[[k]], 10.^-6]/t), {k, Length[list]}]