Finding Double Roots for f(x;p) = cos x - 0.8 + px^2 using Python

  • Thread starter member 428835
  • Start date
  • Tags
    Root
In summary, the conversation discusses finding the value of p that results in a double root for the function f(x;p) = cos x - 0.8 + px^2, using python. The attempt at a solution involves choosing a window of values for p and evaluating the number of roots of the function in that interval. It is suggested to set the function equal to p(x-x_0)^2 and examine the consequences, and this approach ultimately leads to a solution. The definition of a double root is also clarified.
  • #1
member 428835

Homework Statement


What value of ##p## gives a double root for ##f(x;p) = \cos x - 0.8+px^2##? I'm using python.

Homework Equations


Nothing comes to mind.

The Attempt at a Solution


I was thinking about choosing a window ##p\in[a,b]## such that ##a=0.3## yields 4 roots and ##b=0.4## yields 0 roots. Then cut this interval in half at ##p = b-0.5(a+b)## and evaluate the number of roots of ##f(x;p)=0##. If no root is found then let ##b = p## and reiterate. If a root is found then let ##a = p## and reiterate.

The issue is, every root finder I see doesn't use a good value when no root is found. It returns an error message with an arbitrary value. I need a way to distinguish when a root is found or not...any ideas?
 
Physics news on Phys.org
  • #2
How about setting ##f(x;p)=p(x-x_0)^2## and examination of the consequences either by comparison of the terms or differentiation? Not sure how far you get with this approach, but it's an idea.
 
  • #3
Could you define double root please?
 
  • Like
Likes member 428835
  • #4
Math_QED said:
Could you define double root please?
Sorry, I can see I've been somewhat inaccurate. A double root implies the multiplicity of a root is 2. If a double root occurs at ##x=a## for a given ##p##, then ##f(a;p) = f'(a;p) = 0##. This is a necessary condition...

So I just solved it! Following your question I applied the above two equation equalities and out came a good answer!
 
Last edited by a moderator:
  • Like
Likes member 587159

1. What is the purpose of finding double roots for a given function?

Finding the double roots of a function allows us to identify the points where the function intersects the x-axis twice, indicating that the function has two equal solutions or roots. This can provide valuable information about the behavior of the function and can be useful in solving equations and analyzing data.

2. How does Python help in finding double roots of a function?

Python has powerful built-in tools and libraries for mathematical computations and data analysis. Specifically, the NumPy and SciPy libraries provide functions for finding roots of a given function, including double roots. These libraries also allow for efficient and accurate numerical calculations, making it a useful tool for scientific research and analysis.

3. What does the "p" parameter represent in the function f(x;p) = cos x - 0.8 + px^2?

The "p" parameter in this function represents a constant or coefficient that is multiplied by the term x^2. This term can affect the shape and position of the function's graph, potentially leading to changes in the number of roots and their values.

4. Is there a specific method or algorithm used for finding double roots in Python?

There are various methods and algorithms that can be used to find double roots of a function in Python. Some common methods include the Newton-Raphson method, the bisection method, and the secant method. The appropriate method to use may depend on the function and the specific problem at hand.

5. How can I interpret the results of finding double roots for a given function using Python?

The results of finding double roots in Python will typically provide the values of the roots as well as any other relevant information, such as the number of iterations required or the accuracy of the results. These results can be interpreted to determine the solutions to the function and how they may relate to the function's graph and behavior. Additionally, the results can be used to verify the accuracy of the function or to make predictions about its behavior in different scenarios.

Similar threads

  • Calculus and Beyond Homework Help
Replies
7
Views
2K
  • Calculus and Beyond Homework Help
Replies
4
Views
849
Replies
2
Views
762
  • Precalculus Mathematics Homework Help
Replies
6
Views
709
  • Topology and Analysis
Replies
2
Views
2K
  • Calculus and Beyond Homework Help
Replies
9
Views
7K
  • Calculus and Beyond Homework Help
Replies
9
Views
1K
  • Calculus and Beyond Homework Help
Replies
2
Views
1K
  • Calculus and Beyond Homework Help
Replies
4
Views
1K
Back
Top