Register to reply

Mathematica - (Very) Simple Question

by Sosi
Tags: mathematica, simple
Share this thread:
Sosi
#1
Aug13-09, 11:06 AM
P: 11
Hi!
I'm doing my first steps in Mathematica and I've wanted to do something simple like assigning a variable to the output and then use it. Something like this:

In:Vp = vprx == kprx2*X1;
In:dX1 = kp X0 + X1 (-cat kcatl - kgpx gpx - kprx2 prx2);
In:rX1 = Solve[dX1 == 0, X1];
Out:{{X1 -> (kp X0)/(catalase kcatl + gpx kgpx + kprx2 prx2)}}
then i want to Sbustitute X1 in the expression Vp, with the value of the output of rX1.I'm using the function Replace but this doesn't do what I want. The output is:
In:Replace[Vp, X1 -> rX1]
Out:vprx == kprx2 X1
when it should be
Out:vprx==(kprx2kp X0)/(catalase kcatl + gpx kgpx + kprx2 prx2)
Thanks a lot for all the help!
Phys.Org News Partner Science news on Phys.org
Bees able to spot which flowers offer best rewards before landing
Classic Lewis Carroll character inspires new ecological model
When cooperation counts: Researchers find sperm benefit from grouping together in mice
jpreed
#2
Aug13-09, 12:20 PM
P: 37
There are two problems, one is simple, one is more complicated.

First, use "ReplaceAll" instead of "Replace", it uses a deeper algorithm that will properly do what you want it to do.

Second, look at the result of "rX1". It is NOT just a number that can be plugged in. It is a list that has one component with a variable, "X1", being transformed to a larger expression.

Try using:

ReplaceAll[Vp, rX1[[1]] ]
This takes the first component of the rX1 list and uses it in the ReplaceAll function.
Sosi
#3
Aug14-09, 04:19 AM
P: 11
Quote Quote by jpreed View Post
Try using:
ReplaceAll[Vp, rX1[[1]] ]
This takes the first component of the rX1 list and uses it in the ReplaceAll function.
Awsome! It works just as I wanted! Thanks a lot!


Register to reply

Related Discussions
Simple table in Mathematica Engineering, Comp Sci, & Technology Homework 1
Simple problem in Mathematica involving lists Math & Science Software 3
Simple Mathematica Question (Solve Function) Math & Science Software 1
Simple tensor manipulation in Maple or Mathematica Math & Science Software 11
Mathematica help needed, please...(very simple?) Math & Science Software 1