Group Abstract Group Abstract

Message Boards Message Boards

Can I ReplaceAll and delay calculation OR change interpretation sqrt{a^2}

Posted 9 years ago

After much searching I have found the reason for the bug in my calculation. But I have no idea how to solve it!

I am making a symbolic calculation that I will at a future stage graph for various values. In the calculation the expression \sqrt{(a-b)^2} shows up. Mathematica interprets this as the Abs[a-b] - fine, I get where that is coming from. However I need it to interpret this as (a-b).

I have tried /. to replace all occurrences and that works. However I need it to be possible to delay all calculations in this notebook. I'm planning on making the calculation more complicated and this will make it impossible to compute some of the pieces symbolically. So I need to be able to delay all parts of the calculation until I input the numbers at the end. But still to either replace \sqrt{(a-b)^2} with (a-b) or to fix this part of the calculation in some other way.

I've attached the relevant notebook in case you need to look at it.

Attachments:
POSTED BY: Eleanor Holmes
4 Replies
Posted 9 years ago

Because this sample code is a very simplified case of what I really need to do. In what I really need to do my computer does not have the capacity to calculate the An1[a,kx,l] term and beyond symbolically. So I can't really use a fix that requires anything passed that point to be worked out symbolically. So far as I can tell this rules out any Simplify or Replace statements. The calculation MUST be delayed or it won't work.

If there is a way to Simplify and still delay that I don't know about I could do that. But so far noting has worked.

POSTED BY: Eleanor Holmes

Why do you need to delay the simplification? If it is correct, why not do it at once? In your code I see that, for example, Simplify[Rd1[a, kx, l]] contains a lot of square roots of squares. Why don't you simplify them, if you know in advance the signs?

POSTED BY: Gianluca Gorni
Posted 9 years ago

Yes. And that work, as does replacing the offending part of the equation. My problem with that is that simplify is not a statement that can be delayed and I need a solution that I can delay cos this is going to get a whole lot more complicated before I'm through.

No Simplifys, no PowerExpands, no ReplaceAlls. And ideally I need to deal with the root problem cos these tricky expressions are going to be different as I make my system more complex.

Root problem is that mathematica interprets Sqrt[(a-b)^2] as Abs[a-b] because it evaluates the parentheses first. I need it to evaluate the squareroot first.

POSTED BY: Eleanor Holmes

Have you tried Simplify with the assumption a>=b?

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