# How to find the intersection of an straight line and a function?

I have this following function:

$$y\ =\ \sqrt{\left|x\right|^{2}}-\cos\left(3x\right)$$

which represents this: And I need to find the intersection between an straight line created from two coordinates ($$ab$$ and $$cd$$) and this formula, something like this: I only need the first intersection point coordinates ($$ef$$) (the closest).

On the internet I only find how to intersect circles with other straight lines. How do I do with a function?

I only have $$ab$$ and $$cd$$ coords and need to find $$ef$$.

• In general if you have 2 functions $f(x), g(x)$, the points of intersection between them occur at the zeros of $f(x)-g(x)$. – 79037662 Sep 27 '19 at 17:40
• @79037662 how can I represent $ab, cd$ into $g(x)$ ? – CypherPotato Sep 27 '19 at 17:43
• it's a straight line so you can calculate the equation of a line from two points: mathsisfun.com/algebra/line-equation-point-slope.html – graeme Sep 27 '19 at 17:46
• You're asking how to find the equation of a line given two points on it, this website can explain much better than I can: mathsisfun.com/algebra/line-equation-2points.html – 79037662 Sep 27 '19 at 17:47
• You should set equal the equations of the curves (the straight line and the function) which obtains no analytical result in general and should be solved numerically. – Mostafa Ayaz Sep 27 '19 at 18:01

You may use point-slope form of line to find the equation of the line. $${{y-y_1}\over x-x_1} = m$$ $${{y-b}\over x-a} = {{b-d}\over {a-c}}$$ Your equation is $$y=|x|-cos(3x)$$
• Substitute $y$ with what? – CypherPotato Sep 27 '19 at 18:38
• Substitute y with $|x|-cos(3x)$ in the line equation. – Sam Sep 27 '19 at 18:40