# Mathematica 5.2

1. Apr 28, 2007

### danago

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: Apr 28, 2007
2. Apr 28, 2007

### Crosson

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. Apr 29, 2007

### danago

Ahh yes that makes sense. Thanks for that

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: Apr 29, 2007
4. Apr 29, 2007

### Crosson

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. Apr 30, 2007

### cosmicstring1

Try "Part" command as Part[Solve[(t - a)*(t - 4) == 0, t], 2, 1, 2]