I’ve got the following Visual Basic code:
Dim L16, L23, L45, t As Double
Dim LBase, LAdjacent, LOpposite As Double
L16 = 20
L23 = 10
L45 = 30
t = 1
LBase = L16
LAdjacent = L23
LOpposite = L45
Dim Sum As Double
Sum = t ^ 2 * L16 + 6 * t ^ 3 + 2 * L16 ^ 3 + 3 * L16 ^ 2 * t + 2 * L23 ^ 2 * L16 + L23 ^ 2 * t + 8 * L23 * t * L16 + 4 * L23 * t ^ 2 - L45 ^ 2 * L16 + L45 ^ 2 * t - 4 * L45 * t * L16 + 4 * L45 * t ^ 2
Console.WriteLine("1st Sum: " & Sum)
Sum = t ^ 2 + LBase + 6 * t ^ 3 + 2 * LBase ^ 3 + 3 * LBase ^ 2 * t + 2 * LAdjacent ^ 2 * LBase + LAdjacent ^ 2 * t + 8 * LAdjacent * t * LBase + 4 * LAdjacent * t ^ 2 - LOpposite ^ 2 * LBase + LOpposite ^ 2 * t - 4 * LOpposite * t * LBase + 4 * LOpposite * t ^ 2
Console.WriteLine("2nd Sum: " & Sum)
Both equations should be equivalent: I’ve simply replaced L16 with LBase, L23 with LAdjacent and L45 with LOpposite. Yet the first equation outputs 3586 while the second outputs 3587. Why?
I’m using VS2010
Amr
First Sum calculation:
Second Sum calculation:
One has
*, where the other has+.