Intersection point of two functions - one linear, the other with logarithmic and sqrt terms

370 Views Asked by At

I would like first to appreciate everything that is being done on this forum and to greet you all!

I have namely two functions and the goal is to find the intersection point of them.

  1. $y_1 = a + \dfrac{1}{bc} (x-x_0)$
  2. $y_2=\ln\dfrac{\sqrt{\dfrac{2dx}{c}+1}-1}{d} + {\sqrt{\dfrac{2dx}{c}+1}-1}$

where $a$, $b$, $c$, $d$, $x_0$ are known.

To find the point $x$ where the two functions intersect , firstly I set these two functions equal $y_1 = y_2$: $$\ln\dfrac{\sqrt{\dfrac{2dx}{c}+1}-1}{d} + {\sqrt{\dfrac{2dx}{c}+1}-1} = a + \dfrac{1}{bc} (x-x_0).$$

It is obvious that I must solve this equation numerically in order to find $x$. I've plotted the two equations in Matlab, wrote a code to find the minimum difference between $y_1$ and $y_2$ for different $x$ (ex. from 0 to 0.5 in 1000 steps), and then found the $x$ where $y_1$ nearly equals $y_2$, and I've got results that are near the expected.

One thing is that the term under the sqrt is nearly in all cases negative, so it yields complex numbers and it has to logarithm these complex numbers.

It's now my job to write a program to find the $x$ numerically, and I am at the moment craving for an idea to start with. What algorithm could I use to find the sqrt and ln (able to do the calculation with negative numbers)? How could I start solving the equations?

I am pretty new in this field and I would appreciate and be grateful for every tip.

3

There are 3 best solutions below

2
On BEST ANSWER

Let $t=\dfrac{2dx}{c}+1$, which is a linear function of $x$. As $y_1$ is also a linear function of $x$, you can rewrite after transformations

$$f(t)=\ln(\sqrt t-1)+\sqrt t=pt+q.$$

So this problem has only two independent parameters and can be cast as the intersection of a curve with a straight line.

In addition, the curve is monotonous increasing, and its slope has the simple expression

$$f'(t)=\frac1{2(\sqrt t-1)}.$$

Then for a given positive slope $p$, you can find the value of $t$ where a parallel to the line is tangent to the curve by solving $f'(t_p)=p$. Depending on the value of $f(t_p)$ compared to that of $pt_p+q$, you will known how many roots there are. In the case of two roots, they are in $(1,t_p)$ and $(t_p,\infty)$.

For a negative slope $p$, there is a single intersection.

enter image description here

You can find starting approximations

  • by neglecting the logarithmic term, giving $\sqrt t=pt+q$, a quadratic equation,

  • or by assuming $t$ close to $1$, expressing $\ln(\sqrt{1+s}-1)+\sqrt{1+s}=p(1+s)+q$, or $\ln\left(\dfrac s2\right)+1\approx p+q$.

0
On

Set

$$u=\sqrt{\dfrac{2dx}{c}+1} \ \ \ (1)$$

Let us remark that $u$, if it exists (as a real number) is $\geq 0$.

Extract $$x=\dfrac{(u^2-1)c}{2d}$$

Remark: we must have $x \geq \dfrac{-c}{2d}$.

transforming your problem into the simpler problem

$$\ln(u-1)=\ln(d)-u+a+\dfrac{1}{2b}(\dfrac{(u^2-1)c}{2d}-x_0)$$

Why is it simpler ? Because, on the left, you have a fixed classical function, without any parameter.

On the right, you find a parametric second degree expression.

Depending on the values of the parameters, the $log$ curve intersects the corresponding parabola in $0, 1, 2...$ points that will be the positive roots in variable $u$, yielding solutions in variable $x$ by using (1).

1
On

Functions $y1,$y2 plotted over the needed x

I probably didn't describe the problem clearly as I should. This is the plot of the two functions over the value x, that has yet to be found.

I used both of your answers for the simplification of the problem and I would like to thank you first.

Let's say I plotted x over some range and I got these two plots. In my case, d is nearly always negative in the y2, and then I have to find the natural logarithm of a negative number , what gives me complex numbers as results. In this plot, the imaginary parts of the complex solutions are not shown - so that I could theoretically analyse the difference f1 - f2 = 0 and find the point relatively easy to find it graphically when I know the range of x. My next step would be to find the solution of x analytically or numerically, according to the equations.

If i did understand your method Yves Daoust, then I should calculate the slope of the line function on right (pt+q) that is tangent to the curve, what I did, and find tp from the first derivative. The negative logarithmic term (ln(d)) that should be included in your q confuses me a little bit. What should I do after I've found tp? How to see whether is it one or two roots, by comparing pt+q to the tp inserted in the curve function? Would I start approximating with the Newton-Raphson method?