Using Solve[] Function in Mathematica 5.2 - Accessing Solutions

In summary, when using Mathematica 5.2, if you want to refer to a specific solution from the Solve[] function, you can use the " /. " command to replace the solution with a variable, or use the "Part" command to select a specific solution from the list. Additionally, if you are looking for solutions within a restricted range of values, you can use the "Select" function with a condition to filter out the desired solutions. It is also helpful to use the FullForm function to understand the structure of expressions and refer to the Built-In help for individual functions.
  • #1
danago
Gold Member
1,123
4
Hey. I just started using mathematica 5.2, and having a little trouble. When using the Solve[] function, the solutions are given as lists:

{{t -> a}, {t -> 4}}

In my next step of calculations, i want to use my second solution. How can i refer to it, instead of having to type it out. Now i know that if the solution was infact 4 that it would be easier to type it, but the solutions are not always as simple.

Thanks,
Dan.
 
Last edited:
Physics news on Phys.org
  • #2
the short answer is:

t /. {{t -> a}, {t -> 4}}

The solution is returned in the form of a replacement rule,the " /. " should be read as "replace". (look up the functions Rule and Replace in help). Replacement rules are extremely important.

When you encounter a puzzling expression, try the function FullForm to see what its made of so you can look up the individual parts in the extensive Built-In help.
 
  • #3
Ahh yes that makes sense. Thanks for that :smile:

I now have a new question. I want to solve an equation, but the solution must lie within a restricted range of values. I assumed the following would work:

Solve[ y[t]==0, t, {t,a,b}]

However, it doesnt. I had a look at the built in help browser, and wasnt able to come up with anything. What should i do?
 
Last edited:
  • #4
A simple method in two lines:

rangeQ[x_] = a ≤ x ≤ b;

Select[ t/.Solve[y[t] == 0, t] , rangeQ ]

Using a pure function in one line:

Select[ t/.Solve[y[t] == 0, t] , a ≤ # ≤ b &]

This preserves them as rules, rather then values:

Select[ Solve[y[t] == 0, t] , a ≤ Last[#] ≤ b &]

Hope that helps.
 
  • #5
Try "Part" command as Part[Solve[(t - a)*(t - 4) == 0, t], 2, 1, 2]
 

FAQ: Using Solve[] Function in Mathematica 5.2 - Accessing Solutions

What is the Solve[] function in Mathematica 5.2?

The Solve[] function in Mathematica 5.2 is a built-in function that is used to find solutions to equations and inequalities. It is capable of solving a wide range of mathematical problems, including algebraic equations, differential equations, and systems of equations.

How do I use the Solve[] function in Mathematica 5.2?

To use the Solve[] function, you need to provide the equation or inequality that you want to solve, along with the variables you want to solve for. For example, if you want to solve the equation x^2 + 2x + 1 = 0 for x, you would use the syntax Solve[x^2 + 2x + 1 == 0, x]. The function will then return a list of solutions in the form of rules.

What types of equations can the Solve[] function solve?

The Solve[] function is capable of solving a wide range of equations, including polynomial equations, transcendental equations, and differential equations. It can also solve systems of equations, where multiple equations with multiple variables are involved.

Can I access multiple solutions using the Solve[] function?

Yes, the Solve[] function can return multiple solutions for a given equation or set of equations. If there are multiple solutions, they will be returned as a list of rules. You can then access each individual solution by using the Part[] function.

Are there any limitations to using the Solve[] function in Mathematica 5.2?

While the Solve[] function is powerful and versatile, it does have some limitations. It may not be able to find solutions for extremely complex equations or equations with multiple variables and parameters. In addition, the function may take a long time to compute solutions for very large or complicated equations.

Similar threads

Replies
5
Views
2K
Replies
1
Views
2K
Replies
1
Views
989
Replies
13
Views
2K
Replies
6
Views
3K
Replies
2
Views
6K
Back
Top