Using Solve[] Function in Mathematica 5.2 - Accessing Solutions

  • Context: Mathematica 
  • Thread starter Thread starter danago
  • Start date Start date
  • Tags Tags
    Function Mathematica
Click For Summary

Discussion Overview

The discussion revolves around using the Solve[] function in Mathematica 5.2, particularly focusing on how to access specific solutions from the output and how to handle solutions within a restricted range of values. The scope includes technical explanations and problem-solving strategies related to Mathematica programming.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • Dan expresses difficulty in accessing specific solutions from the output of the Solve[] function, which returns solutions as lists of replacement rules.
  • One participant suggests using the replacement operator " /. " to refer to specific solutions, indicating that this operator is crucial for working with replacement rules.
  • Dan later inquires about solving an equation with a solution constrained to a specific range, indicating that his initial attempt did not yield the expected results.
  • Another participant proposes using the Select function combined with a defined range condition to filter solutions that meet the specified criteria.
  • A different approach is suggested involving the Part command to directly access a specific solution from the output of the Solve function.

Areas of Agreement / Disagreement

Participants provide various methods for accessing solutions and filtering them based on conditions, but there is no consensus on a single best approach. Multiple strategies are discussed without resolving which is superior.

Contextual Notes

Some methods rely on specific definitions and assumptions about the structure of the output from Solve[], and the effectiveness of the proposed solutions may depend on the context of the equations being solved.

danago
Gold Member
Messages
1,118
Reaction score
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
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.
 
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:
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.
 
Try "Part" command as Part[Solve[(t - a)*(t - 4) == 0, t], 2, 1, 2]
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K
Replies
10
Views
3K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 2 ·
Replies
2
Views
3K