Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #11742 > unrolled thread

Substitute variable name for value (reverse of simplification)

Started bymr.hagak@gmail.com
First post2012-09-14 04:19 +0000
Last post2012-09-15 07:45 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Substitute variable name for value (reverse of simplification) mr.hagak@gmail.com - 2012-09-14 04:19 +0000
    Re: Substitute variable name for value (reverse of simplification) daniel.lichtblau0@gmail.com - 2012-09-15 07:45 +0000

#11742 — Substitute variable name for value (reverse of simplification)

Frommr.hagak@gmail.com
Date2012-09-14 04:19 +0000
SubjectSubstitute variable name for value (reverse of simplification)
Message-ID<k2ub90$ha5$1@smc.vnet.net>
I need this to happen:
var1 = 3*a
var2 = 189*a^3
output = 7*var1^3

I can do it in very simple and specific equations doing something like

substituteName2[var_,exp_] := Module[ {},
	Solve[p==exp&&"test"==var,{p},{a}]
];
test=3*a;
substituteName2[test,7*test^3]

But i need a WAY more general form of that...any ideas?

[toc] | [next] | [standalone]


#11753

Fromdaniel.lichtblau0@gmail.com
Date2012-09-15 07:45 +0000
Message-ID<k31bmt$mo3$1@smc.vnet.net>
In reply to#11742
On Thursday, September 13, 2012 11:20:59 PM UTC-5, mr.h...@gmail.com wrote:
> I need this to happen:
> 
> var1 = 3*a
> 
> var2 = 189*a^3
> 
> output = 7*var1^3
> 
> 
> 
> I can do it in very simple and specific equations doing something like
> 
> 
> 
> substituteName2[var_,exp_] := Module[ {},
> 
> 	Solve[p==exp&&"test"==var,{p},{a}]
> 
> ];
> 
> test=3*a;
> 
> substituteName2[test,7*test^3]
> 
> 
> 
> But i need a WAY more general form of that...any ideas?

Check the dox for PolynomialReduce.

In[68]:= PolynomialReduce[189*a^3, var1 - 3*a, {a, var}][[2]]

Out[68]= 7*var1^3

Daniel Lichtblau
Wolfram Research

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web