- #1

joshmccraney

Gold Member

- 1,934

- 96

## 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?