Point of intersection of 'symbolic' curves

Consider the code segment
syms e
y1 = sqrt(8-e);
ezplot(y1)
y_sym = sqrt(e) * tan(pi/2 * sqrt(e));
y_ant_sym =-sqrt(e) * cot(pi/2 * sqrt(e));
hold on
ezplot(y_sym)
ezplot(y_ant_sym)
Now consider the curves generated by plotting the functions y1, y_sym and y_ant_sym.
I want to find the point(s) of intersection of the curves y_sym and y_ant_sym with the curve y1.
I know there are work-arounds if one uses ordinary vectors (such as in the post by Loren). But here the curves are symbolic ones generated from ezplot. Any solution?

Answers (2)

Finding the intersection means solving, right? right.
well just do:
solve('sqrt(8-e)=sqrt(e) * tan(pi/2 * sqrt(e))','e')
and
solve('sqrt(8-e)=-sqrt(e) * cot(pi/2 * sqrt(e))','e')
the answer to each is the intersection of each of the two pairs of curves you are plotting.
regards,
p.k.

1 Comment

In MuPAD you are very likely to get "explicit solution cannot be found".

Sign in to comment.

Not really. Finding the intersection of these curves is trying to solve a non-trivial trig formula analytically : there are simply no tools to find the analytic solutions.
You can experiment with tools such as taylor expansion (but then you lose any periodic behavior), but as you do that towards higher orders of accuracy you generate polynomials in higher degrees and as you know there are no general solutions to polynomials of degree 5 or higher.
You can work towards numeric solutions by way of using solve() and then seeking numeric solutions for the expression forms that result. This can yield useful forms in Maple, but MuPAD has not been very good at expressing general forms of solutions to trig expressions; it has perhaps improved in that in later versions.

8 Comments

Sure. But i think it actually does the job.
MuPAD up through R2010a would certainly not be able to create symbolic roots for transcendental equations. I have not seen enough output from R2010b and later to know what it can or cannot handle now.
Well, at least I should be able to get a numeric answer for this. One way is to use numerical solver.
evalin(symengine, 'numeric::solve( sqrt(x) * tan(pi/2 * sqrt(x)) = sqrt(8-x), x = 0..10)')
But even that doesn't give me multiple answers (if there are multiple points of intersection).
yes this is actually a matlab bug if i gather correctly. use fsolve and set x0=0 initially, and when you get the answer use xo>ans and find the second root. your first problem has two roots if i understand correctly and your second problem only one, so solve should do the job.
But fsolve doesn't solve for symbolic functions/equations...
did you try it?
I am using MATLAB R2009A, and the help tells that fsolve accepts only vector. :-(
However, it does work with symbolic too. :-)
Thanks.
If you happen to be using the Maple symbolic engine (an option in R2009A), then solve() of the expression may return incorrect values. I have identified the problem and reported it against Maple.
I do not have MuPAD to test with so I do not know if MuPAD ever suffered the same fault.
For now at least, if you use solve() with trig functions that involve sqrt() in the expression, then cross-check the solutions.

Sign in to comment.

Asked:

on 11 Mar 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!