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

  • Thread starter Thread starter member 428835
  • Start date Start date
  • Tags Tags
    Root
Click For Summary

Homework Help Overview

The original poster is investigating the value of ##p## that results in a double root for the function ##f(x;p) = \cos x - 0.8 + px^2##, utilizing Python for their analysis.

Discussion Character

  • Exploratory, Conceptual clarification, Mathematical reasoning

Approaches and Questions Raised

  • The original poster considers a numerical approach by selecting an interval for ##p## and evaluating the number of roots of the function. They express concerns about the behavior of root-finding algorithms when no roots are found. Another participant suggests an alternative method involving the formulation of the function in terms of a double root and examining the implications through differentiation.

Discussion Status

The discussion includes various approaches to identifying the double root condition. Some participants are seeking clarification on the definition of a double root, while the original poster indicates they have reached a solution after applying the necessary conditions for a double root.

Contextual Notes

There is a mention of the original poster's specific interval for ##p##, as well as their concerns about the effectiveness of root-finding methods when no roots are identified.

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
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.
 
Could you define double root please?
 
  • Like
Likes   Reactions: member 428835
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   Reactions: member 587159

Similar threads

  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
6
Views
2K
  • · Replies 9 ·
Replies
9
Views
10K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
7
Views
3K