Mathematica - (Very) Simple Question

  • Mathematica
  • Thread starter Sosi
  • Start date
  • Tags
    Mathematica
In summary, the conversation discusses using Mathematica to assign a variable to an output and then use it in an expression. The user initially tries using the "Replace" function but it does not provide the desired result. They are then advised to use the "ReplaceAll" function and to pay attention to the structure of the output from "rX1". This solution successfully achieves the desired result.
  • #1
Sosi
13
1
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:

Code:
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:
Code:
In:Replace[Vp, X1 -> rX1]
Out:vprx == kprx2 X1

when it should be
Code:
Out:vprx==(kprx2kp X0)/(catalase kcatl + gpx kgpx + kprx2 prx2)

Thanks a lot for all the help!
 
Physics news on Phys.org
  • #2
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:

Code:
ReplaceAll[Vp, rX1[[1]] ]

This takes the first component of the rX1 list and uses it in the ReplaceAll function.
 
  • #3
jpreed said:
Try using:
Code:
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!
 

1. What is Mathematica?

Mathematica is a computational software program used for various scientific and mathematical computations. It is designed to perform symbolic and numeric calculations, create visualizations, and solve complex equations.

2. Is Mathematica user-friendly?

Yes, Mathematica has a user-friendly interface that allows users to easily input equations and commands, and it provides visual feedback for results. It also has a comprehensive help menu and online resources for additional support.

3. Can Mathematica be used for data analysis?

Yes, Mathematica has powerful data analysis capabilities, including statistical functions, visualization tools, and machine learning algorithms. It can handle large datasets and perform complex analyses efficiently.

4. Can Mathematica be used for programming?

Yes, Mathematica has its own programming language called Wolfram Language, which is used to create and manipulate mathematical functions and objects. It also supports other programming languages, such as Python, Java, and C++, for more advanced programming tasks.

5. Is Mathematica suitable for both beginners and experts?

Yes, Mathematica is suitable for both beginners and experts in mathematics and science. It has a user-friendly interface and intuitive syntax for beginners, and it also offers advanced features and capabilities for experts to perform complex calculations and analyses.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Programming and Computer Science
Replies
26
Views
2K
  • Differential Geometry
Replies
1
Views
1K
Back
Top