Analytic solution not possible. Can i solve with curve fitting?

4 views (last 30 days)
Hi everyone,
I have four variables:
syms a, b, k, t
I have also two equations:
tan(k)=cos(0.43)*cos(b)/(cos(0.43)*sin(b)*sin(a)+sin(0.43)*cos(a))
tan(t)*sin(k)=cos(0.43)*cos(b)/(cos(0.43)*sin(b)*cos(a)-sin(0.43)*sin(a))
I need to solve a and b with respect to k and t so that i have
a=f1(k,t)
and
b=f2(k,t)
solve() doesn't give an anlytical solution and gives a solution with RootOf. Is there any way to solve analytically?
If not how can i fit a curve for a and b where 0<k<2*pi and 0<t<pi/2
Any help is appreciated in advance.
  10 Comments
Emre Gemici
Emre Gemici on 25 Feb 2018
After Tayloring the equations for 4th order i get the following resutls:
- 0.1667*a^3 + 0.2332*a^2 - 0.5*a*b^2 + a - 1.0*k*b - 0.4663
0.5*a^2*t - 0.4663*a*t - 0.1667*b^3 + 0.5*b^2*t + b + 0.5*k^2*t - 0.3333*t^3 - 1.0*t
These are accurate enough for me. Can we solve these two equations for a and b?
Walter Roberson
Walter Roberson on 25 Feb 2018
Yes.
b = root([625000000000000, 5625000000000000*t, -11250000000000000, -(5625000000000000*(k^2+34*t^2*(1/3)+88860139/6250000))*t, 67500000000000000+22500000000000000*t^4+(-33750000000000000*k^2+1574775000000)*t^2, 225000000*t*(300000000*k^2+90000*k*t+1648944007*t^2+1565286672), -135000000000000000+7500000000000000*t^6+(-22500000000000000*k^2-184896500400000000)*t^4-283338000000000000*k*t^3+(16875000000000000*k^4+277344750600000000*k^2-3155625000000)*t^2, 225000000*t*(225000000*k^4*t^2-300000000*k^2*t^4+100000000*t^6-2700020997*k^2*t^2+13998*t^4-900000000*k^2-540000*k*t-3782978292*t^2-1995860016), -(101250000000000000*(4*t^4*(1/9)-(1/2500)*k*t^3+(-4*k^2*(1/3)-13860139/4687500)*t^2+((3/5000)*k^3-(50877746477/125000000000)*k)*t+k^4+13860139*k^2*(1/3125000)+9323/25000000))*t^2]);
a = 5000*(2333*b^3-6999*b^2*t-90000*b*k*t-6999*k^2*t+4666*t^3-13998*b-27969*t)/(25000000*b^3+150000000*b^2*t-75000000*k^2*t+50000000*t^3-150000000*b-332636337*t);
Note: this is a set of 9 answers, as root() is the roots of a polynomial of degree 9. Chances are high that some of the solutions will be complex valued.
Also note: I approximated your floating point values as rationals. In particular I approximated 0.1667 as 1/6 and 0.3333 as 1/3

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 12 Feb 2018
Edited: John D'Errico on 14 Feb 2018
No, you cannot "fit a curve" to this. At least not anything remotely useful, nor do you need to do so.
That a solution is generated using rootof is not bad actually. Just a statement that no analytical solution was found in the form of roots.
You can use vpa to resolve the rootof forms into numbers.
As an addendum, since this problem seems to be hanging around with no resolution.
Again, this is not the purpose of curve fitting, nor can it easily be used for that purpose. Lets see if we can understand SOME of the problems. To do that, I'll need to look in more depth at your problem.
syms a b k t
E(1) = tan(k)==cos(0.43)*cos(b)/(cos(0.43)*sin(b)*sin(a)+sin(0.43)*cos(a));
E(2) = tan(t)*sin(k)==cos(0.43)*cos(b)/(cos(0.43)*sin(b)*cos(a)-sin(0.43)*sin(a));
pretty(vpa(E(1),5))
0.90897 cos(b)
tan(k) == --------------------------------------
0.41687 cos(a) + 0.90897 sin(a) sin(b)
pretty(vpa(E(2),5))
0.90897 cos(b)
sin(k) tan(t) == - --------------------------------------
0.41687 sin(a) - 0.90897 cos(a) sin(b)
So there WILL be infinitely many solutions, if any solution exists. But if we restrict the domain of a and b to lie within [0,2*pi], can we do anything?
Even that is difficult, since there may STILL be multiple solutions.
Lets pick some arbitrary value of k and t, just to see what is happening. Remember that k and t should also be expected to live in ranges. So lets say that
k lives in the interval [-pi,pi]
t lives in the interval [-pi/2,pi/2]
Create a couple of functions.
fun1 = @(a,b) cos(0.43)*cos(b)./(cos(0.43)*sin(b).*sin(a)+sin(0.43)*cos(a));
fun2 = @(a,b) cos(0.43)*cos(b)./(cos(0.43)*sin(b).*cos(a)-sin(0.43)*sin(a));
And a gridded lattice for a and b.
[A,B] = meshgrid(linspace(0,2*pi,100));
f1AB = fun1(A,B);
f2AB = fun2(A,B);
Now, lets do some plots that will be HIGHLY informative.
contour(A,B,f1AB,[1 1]*tan(k),'b')
hold on
contour(A,B,f2AB,[1 1]*sin(k)*tan(t),'r')
grid on
xlabel 'A'
ylabel 'B'
So in blue, we see the solution locus for equation 1. All points on those curves in clue are the solutions of this problem for that equation.
Likewise, all points on those curves in red form the solution locus for equation 2. Any intersection of those curves is a solution to BOTH equations, and therefore an entirely valid solution to your problem.
This is only approximate, because contour was used to solve the problem, on a grid of limited size. But there are clearly something like 12 distinct solutions, where those curves cross.
Now, you MIGHT be able to decide that some of those solutions might be excluded, trying to find a fundamental solution of some sort. However, it is entirely possible that some other choices of t and k might have a different number of solutions. (By the way, I am quite confidant that I can find sets of k and t that have a different number of solutions.) Anyway, which of those solutions is somehow more fundamental than the others?
One thing I can tell you with certainty: CAN you use curve fitting to resolve this problem? NO WAY. PERIOD.
Worse, does there even exist a function g(k,t) that yields the "solution"? Again, this is a multi-valued function. It looks like there will be something like a dozen branches to that function, a dozen possible solutions. So no, you won't find some simple function, positively NOT using curve fitting.
If you were willing to use a table lookup with interpolation, you might consider spending the time to solve this problem for hundreds of values of k and t, isolating the specific pair for a and b that make you happy. Then create a table over a complete grid for k and t in the ranges I showed above. You might then try to use a tool like interp2 to interpolate. Even that approach can be fraught with problems, since you would need to be incredibly careful to find a consistent choice among the dozen (or more or less) solutions that may exist.
Other ideas might revolve around series approximations. But remember that since tan(k) and tan(t) can take on ANY values from -inf to inf, series approximations of any viability will be difficult as hell to find.
Don't think any of this will be easy to do.
  9 Comments
John D'Errico
John D'Errico on 15 Feb 2018
I think a series approximation is one that simply won't go far here. That we have a tan(k) and tan(t) on the left hand side of those equations means that we need to expect a great deal of variability in the solutions. The 12 solutions will be highly sensitive to moderately small changes in k and t. What does that say about a series solution? BAD news. Any series solution will probably not be a convergent one, or to expect serious problem with that approach.
Emre Gemici
Emre Gemici on 15 Feb 2018
Edited: Emre Gemici on 15 Feb 2018
OK now we know that we can find explicit solutions but they are extremely long so not applicable to real life. Real application needs to adjust a and b angles according to changing k and t values. So it needs to calculate the functions in short time intervals to be accurate enough. Actually these equations are for tip of a some kind of manipulator arm which moves along a spherical surface. I didn't think it would be that complicated since it seems a simple real life problem. Anyway I agree with Mr D'errico that series approximation also won't get us far. I think my best bet is to solve them for constant t values that will be used most(15°, 30°, 45) and hopefully get three different simple enough equations for a and b as a function of k.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!