0
|
4564 Views
|
5 Replies
|
2 Total Likes
View groups...
Share

# How do you substitute multiple equations into one expression?

Posted 10 years ago
 Hi All,I am very new at using Matematica and was hoping one of you could help me. I have 4 equations and I am trying to get Matematica to substitue them into the 5th equation. Gs == HVs/HHsGb == HVb/HHbPs == (VVs - VHs*Gs)/(VVs + VHs*Gs)Pb == (VVb - VHb*Gb)/(VVb + VHb*Gb)Pc == (Ps^3 - Pb)I just want the software to combine them for me and give me the expression for Pc in terms of VV, VH, HV and HH.  This was a quick test before I start putting more complex expression together but i cant even get this to work it seems. I tried using replate, solve and some other commands but It doesnt seem to do it or I am not using the right syntax.  Any ideas as to how to do this or where i might be going wrong? I would apreciate any and all help.Thanks,Ves
5 Replies
Sort By:
Posted 10 years ago
 Solve can do this work for you. Give it the equations, tell it to solve for Pc, while eliminating what you don't want:eqs = {Gs == HVs/HHs,   Gb == HVb/HHb,   Ps == (VVs - VHs*Gs)/(VVs + VHs*Gs),   Pb == (VVb - VHb*Gb)/(VVb + VHb*Gb),   Pc == (Ps^3 - Pb)};Solve[eqs, Pc, {Gs, Pb, Ps, Gb}][[1, 1]] // FullSimplifyPc -> (2 HHs HVb VHb VVs (3 HVs^2 VHs^2 + HHs^2 VVs^2) -   2 HHb HVs VHs VVb (HVs^2 VHs^2 + 3 HHs^2 VVs^2))/((HVb VHb +     HHb VVb) (HVs VHs + HHs VVs)^3)
Posted 10 years ago
 I am unsure what difficulty you are having. I try to test the code before I post it. I just scraped each version, pasted them into a notebook, evaluated them and compared the results. Both methods produce the same result for me. Perhaps try each with a fresh start of an empty notebook.For display purposes only, you might tryTraditionalForm[-((-((HVb*VHb)/HHb)+VVb)/((HVb*VHb)/HHb+VVb))+(-((HVs*VHs)/HHs)+VVs)^3/((HVs*VHs)/HHs+VVs)^3]and see if this shows something closer to what you would like to read, but you often cannot then use the result of something displayed in TraditionalForm as the input for a further calculation, so keep a copy of that in a variable and only use a copy for display purposes.
Posted 10 years ago
 Thank you so much. I was able to use the second option Pc=(Ps^3-Pb)//. ....  but not the first. What am i doing wrong or is there a setting i need to change in order to be able to use both inputs? Also is there wasy to Make mathematica display addition first then subtraction aka  (VVb-(HVb*VHb)/HHb)) ?
Posted 10 years ago
 In:= Gs = HVs/HHs;Gb = HVb/HHb;Ps = (VVs - VHs*Gs)/(VVs + VHs*Gs);Pb = (VVb - VHb*Gb)/(VVb + VHb*Gb);Pc = (Ps^3 - Pb)Out= -((-((HVb*VHb)/HHb) + VVb)/((HVb*VHb)/HHb + VVb)) + (-((HVs*VHs)/HHs) + VVs)^3/((HVs*VHs)/HHs + VVs)^3orIn:= Pc=(Ps^3-Pb)//.{Gs->HVs/HHs, Gb->HVb/HHb, Ps->(VVs-VHs*Gs)/(VVs+VHs*Gs), Pb->(VVb-VHb*Gb)/(VVb+VHb*Gb)}Out= -((-((HVb*VHb)/HHb) + VVb)/((HVb*VHb)/HHb + VVb)) + (-((HVs*VHs)/HHs) + VVs)^3/((HVs*VHs)/HHs + VVs)^3
Posted 10 years ago
 How do you substitute multiple equations into one expression?