Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.1K Views
|
11 Replies
|
5 Total Likes
View groups...
Share
Share this post:

Why does ReplaceAll not recognize pattern in this expression?

Posted 7 months ago

I have an expression where the result displayed in the Mathematica output includes ArcSin[w0/U]. If I append /. w0/U -> 0 or even /. ArcSin[w0/U] ->0 to the expression, the result still contains ArcSin[w0/U].

Can someone explain why the substitution isn't made? I attached a snippet from a notebook that shows what is happening.

Attachments:
POSTED BY: John Dzielski
11 Replies
Posted 7 months ago

That's basically it give or take a sign. What I am doing is two reference frame transformations. Quaternions and Trig functions, but single axis as I am only testing out a workflow right now on a very simple problem. The problem does not originate from a series, but the expression I'm trying to simplify is a term in a Taylor series, so it's not completely unrelated.

POSTED BY: John Dzielski

the reason w->w0 gets in here and not w->0 is because I was getting errors due to a divide by zero error

It's too bad you haven't told us what answer you expect to get, because then I would know whether this is right:

Limit[-((CD U)/Sqrt[((U^2 + w0^2)/U^2)]) - 
  CL\[Alpha] U^2 (1/Sqrt[w0^2] -
  w0/(U^2 Sqrt[(U^2 + w0^2)/U^2])) ArcSin[Sqrt[w0^2]/U],
 w0 -> 0]

(*  -((CD + CL\[Alpha]) U)  *)
POSTED BY: Michael Rogers
Posted 7 months ago
POSTED BY: John Dzielski
POSTED BY: Michael Rogers
Posted 7 months ago

Mathematica doesn't automatically eliminate Abs[w0]/Sqrt[w0^2] from an expression

The elimination can be done if w0 is a real number, but not if it is complex. Tell MMA that w0 is real and it will do the elimination.

Simplify[Abs[w0]/Sqrt[w0^2], Assumptions -> Element[w0, Reals]]
(* 1 *)
POSTED BY: Hans Milton
POSTED BY: Gianluca Gorni
Posted 7 months ago

We need to be able to run your code to see what you see and trace through the computation. Since you don't supply Fc, vb, and several other definitions we can't see what's going on. All we can do is guess blindly. If you really want help, you need to provide more information.

POSTED BY: Eric Rimbey
Posted 7 months ago

Thanks for the suggestions. I thought attaching a snippet from a notebook was the best way to show what was going on. When I cut-and-paste, the result seems to be not intelligible. I tried the suggestion of moving the simplify, but the substitution still doesn't work. One interesting thing that I noticed is elsewhere in the full notebook Mathematica doesn't automatically eliminate Abs[w0]/Sqrt[w0^2] from an expression, but it does use the substitution in what is attached to this post.

What I am trying to do is an order-of-magnitude reduction on the full expression (there are more). Based on limited prior experience, I did not expect Mathematica to do all of the work for me, and figured manual substitutions would be necessary. I'm a little surprised that this one doesn't seem to work.

After trying a few other things, I think it looks like the Abs[] function is maybe a bit of a blind spot for Mathematica. It does recognize and substitute for Sqrt[w0^2] but not Abs[w0].

I've added an update to the notebook snippet.

Attachments:
POSTED BY: John Dzielski

Wild guess: Are you after this?

Normal[Series[{
   {-((U^2 w0 (CD w0 + CL\[Alpha] U ArcSin[Abs[w0]/U]))/(U^2 + w0^2)^(3/2))},
   {0},
   {(U^2 w0 (CD U - CL\[Alpha] w0 ArcSin[Abs[w0]/U]))/(U^2 + w0^2)^(3/2)}},
  w0 -> 0, Assumptions -> w0 > 0 && U > 0]]

(*  {{-(((CD + CL\[Alpha]) w0^2)/U)}, {0}, {CD w0}}  *)

It's slightly different than the result your substitutions imply, so my guess may be wrong. However, asymptotic expansions are common operations, and you seem to be treating w0 as if it were small and approaching zero. I thought it worth suggesting.

In my experience, algebraic manipulation via substitution rules is tricky and bug-prone. Rules of the form variable -> expr that replace all instances of the variable by the same expr are generally safe. But I find it's more often better to ask Mathematica to calculate the mathematical operation I want. There are exceptions, though.

POSTED BY: Michael Rogers

Maybe you call the replacement before Simplify, while your pattern only appears after Simplify. It's hard to tell without the full value of D[Fc[vb], u].

POSTED BY: Gianluca Gorni
Posted 7 months ago

You need to provide the expression you're applying ReplaceAll to.

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