1
votes

Here is an expression to which I’m applying rules:

In[141]:= br1noOutQuadOne /. theThetas /. theMC /. theS
Out[141]= {p1 -> 1/2 (-3.7249*10^6 + p2)}

I’m mystified why the 1/2 doesn’t multiply through. Here's another way that doesn't work:

In[142]:= Simplify[N[br1noOutQuadOne /. theThetas /. theMC /. theS]]
Out[142]= {p1 -> 0.5 (-3.7249*10^6 + p2)}
2
my guess that -3..10^6 is actually a string or similar. Mathematica uses 'x' not '*' in scientific notation for floats. - agentp
Try FullForm[...your replacement expression...] to see what MMA might be hiding from you - Bill
Nope, not a string. Yes, FullForm was what I ended up using to dig through to the culprit. See my answer. - Chris

2 Answers

1
votes

In the first version Mathematica is doing what it does and not reducing the precision of an exact number, such as 1/2, without explicit instruction to do so. Multiplying the term 1/2 * -3.7249*10^6 will lose precision.

In the second version Mathematica is showing that it thinks that 0.5 (-3.7249*10^6 + p2) is simpler than -1.86245*10^6 + 0.5p2. But you have all sorts of functions, such as Expand, you can use to manipulate expressions into the forms you want.

1
votes

Short answer: Both Expand and N appear to be necessary to coax Mathematica into a fully multiplied out version that distributes Times through Rational and across Plus.

Here's the longer answer …

FullForm was helpful in finding the solution.

In[170]:= br4QuadOne
FullForm[br4QuadOne]
Out[170]= {p4 -> 1/2 (mc4 + p3 + (-s3 + s4) \[Theta]max)}
Out[171]/FullForm= List[Rule[p4,Times[Rational[1,2],Plus[mc4,p3,Times[Plus[Times[-1, s3], s4],\[Theta]max]]]]]

It's the Rational inside the Times that appears to make Mathematica think it can't go further. When it's all just numbers, there's no problem.

In[191]:= Times[Rational[1, 2], 3.2]
Out[191]= 1.6

Once there's a variable in there, though, Mathematica is unwilling to distribute Times through Rational and across Plus.

In[209]:= Times[Rational[1, 2], Plus[t1, 5]]
Simplify[N[%]]
Out[209]= (5 + t1)/2
Out[210]= 0.5 (5. + t1)

Expand on its own isn't enough.

In[219]:= Expand[Times[Rational[1, 2], Plus[t1, 5]]]
Out[219]= 5/2 + t1/2

Finally, (and switching the order of N and Expand also works) …

In[212]:= N[Expand[Times[Rational[1, 2], Plus[t1, 5]]]]
Out[212]= 2.5 + 0.5 t1