0

I want to set a symbol (or variable) for an expression. Here is an example:

A x^2 + C x + D

I want to reduce this expression to

x^2 + G x + D/A

but Mathematica can't do this way

A x^2 + C x + D /. C/A -> G

The above was just an simple example, but my problem is in complex expression like:

(c Kϕ Sin[(i π z)/l])/hw + (c EIw i^4 π^4 Sin[(i π z)/l])/(hw l^4) - 
  (c i^2 π^2 (-GJ + r0^2 P[z]) Sin[(i π z)/l])/(hw l^2) + 
  d Dw (6/hw^2 + β μ) Sin[(π z)/λ] + (c i π r0^2 Cos[(i π z)/l] Derivative[1][P][z])/(hw l)

and I want to replace some part like this:

enter image description here

and first expression convert to:

enter image description here

How can I do that?

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Amir
  • 1
  • 1
  • 1
    Welcome to Mathematica.SE! 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! –  Jan 04 '17 at 17:34
  • I am marking this as a duplicate of http://mathematica.stackexchange.com/q/3822/121 -- unfortunately there is no robust built-in solution for this kind of thing but it has been brought up many times before and there are many partial solutions. See my answer to that question for links to many more related questions. Please try the solutions therein, and if they do not work edit this question to describe what you tried and what the result was, including a link to the source post. – Mr.Wizard Jan 07 '17 at 20:41

2 Answers2

0
A x^2 + C x + D /. {A -> 1, C -> G, D -> D/A}

gives what you expect

cyrille.piatecki
  • 4,582
  • 13
  • 26
0

The question is ambiguous, in that what variables (if any) are to be eliminated when introducing H1 and F is not specified. One course of action is to name the original expression ex and then perform,

Solve[H1 == (EIy β^2 λ)/2, EIy][[1, 1]]
Solve[F == (3 Dw λ)/hw^3 - Dw*(2 - μ)/(2 hw) λ β, Dw][[1, 1]]
ex /. {%, %%}
(* -((2 c F hw^3 (-(6/hw^3) + (β (2 - μ))/hw) Sin[(π z)/λ])/(λ (6 - 2 hw^2 β + 
   hw^2 β μ))) + d Kx Sin[(i π z)/λ] + (2 d H1 i^4 π^4 Sin[(i π z)/λ])/(β^2 λ^5) - 
   (d i^2 π^2 P[z] Sin[(i π z)/λ])/λ^2 + (d i π Cos[(i π z)/λ] Derivative[1][P][z])/λ *)
bbgodfrey
  • 61,439
  • 17
  • 89
  • 156