Message Boards Message Boards

0
|
943 Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Maintaining desired denominator during calculations

Posted 4 months ago

Hello ,

I am trying to calculate CS with the condition 0 < b < 1 for b in q1 and q2.

The ultimate goal is to determine whether CS is negative or positive.

However, I am encountering an issue where the desired denominator form is constantly being transformed during the calculation process in Mathematica, preventing me from calculating the final CS value.

Problem:

Desired calculation sequence:

q1 = (-2 c + 2 a α - a b α + b c α^2) / (4 α - b^2 α)

q2 = (b c + 2 a α - a b α - 2 c α^2) / ((4α - b^2 α)

cs = (q1^2 + q2^2 + 2bq1q2) / 2

However, when I input these equations into Mathematica, the denominator is transformed into the form (-4 + b^2) α for an unknown reason.

Question:

Could you please provide a method to calculate CS while maintaining the desired denominator form in Mathematica?
Alternatively, could you please advise if I am approaching the calculation incorrectly?

( Especially, I cannot avoid using the Simplify function. However, this immediately changes the denominator to the unwanted form (-4 + b^2) α. I was unable to utilize Hold either.)

POSTED BY: Tchun Jeeyoung
4 Replies
Posted 4 months ago

Firstly please check your input (or copy mine):

q1 = (-2 c + 2 a \[Alpha] - a b \[Alpha] + 
     b c \[Alpha]^2)/(4 \[Alpha] - b^2 \[Alpha]);

q2 = (b c + 2 a \[Alpha] - a b \[Alpha] - 
     2 c \[Alpha]^2)/(4 \[Alpha] - b^2 \[Alpha]) ;
cs = (q1^2 + q2^2 + 2 b q1 q2)/2

Out: $$\frac{1}{2} \left(\frac{\left(2 a \alpha -a \alpha b+\alpha ^2 b c-2 c\right)^2}{\left(4 \alpha -\alpha b^2\right)^2}+\frac{2 b \left(2 a \alpha -a \alpha b+b c-2 \alpha ^2 c\right) \left(2 a \alpha -a \alpha b+\alpha ^2 b c-2 c\right)}{\left(4 \alpha -\alpha b^2\right)^2}+\frac{\left(2 a \alpha -a \alpha b+b c-2 \alpha ^2 c\right)^2}{\left(4 \alpha -\alpha b^2\right)^2}\right)$$

Secondly it's not clear why form $\alpha \left(4 - b^2\right)^2$ not suitable?

POSTED BY: Denis Ivanov
Posted 4 months ago

enter image description here Thank you for your detailed explanation. I followed your instructions and pasted the provided code into Mathematica. However, as you can see from the attached screenshot, the denominator keeps changing. I'm wondering if perhaps I should consider the result value CS with the reversed sign of the numerator instead. Could you please clarify this for me?

POSTED BY: Tchun Jeeyoung
Posted 4 months ago

Ahh, sorry! You mean prevent denominator changing after Simplify.
I’m afraid it’s not that simple, I’ll try

POSTED BY: Denis Ivanov

When I have a form I wish to keep preserved, I might replace it by its own variable — though it makes doing algebra with it difficult — or do the following, which allows for algebra to be carried out:

denom = Denominator[q1]

Simplify[denom^2*cs]/denom^2

The first way, if you need to do some algebra, is not a way I'd recommend. It's for when I don't need any algebraic simplification. However, it might be done like this:

Clear[\[Alpha]b];
(*\[Alpha]b/:Power[\[Alpha]b,p_?Positive]:=Echo@Power[4 \[Alpha]-b^2 \[Alpha],p];*)
\[Alpha]b /: Plus[\[Alpha]b, c_] := 4  \[Alpha] - b^2  \[Alpha] + c;
\[Alpha]b /: Times[\[Alpha]b, c_] := c (4  \[Alpha] - b^2  \[Alpha]);
\[Alpha]bRule = \[Alpha]b -> 4  \[Alpha] - b^2  \[Alpha];

cs /. Reverse@\[Alpha]bRule // Simplify // ReplaceAll[\[Alpha]bRule]

You can't use the Power definition, because it will get invoked when the fractions are combined by Simplify. The denominator gets expanded, and you end up the same factored denominator that you were trying to avoid. You cannot control or always predict what will go on internally, which is why I don't recommend the approach.

Also the success of the first step, cs /. Reverse@\[Alpha]bRule, relies on the denominator in each term having a form that matches the pattern part of the rule. That happens to be the case here. We were lucky.

POSTED BY: Michael Rogers
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract