Message Boards Message Boards

0
|
1744 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Linear Equation matches polynom

Posted 11 years ago
Hi, i have a Problem finding a nice solution with mathematica. The Problem: I want to find all coordinates where a linear equation matches a polynom. I tried it with findroot, but that didnt bring the result i need. My Solution so far is shown below. The problem with findroot is that i have to give a starting point and that i only get one point close to the starting point. Maybe somebody can give me a hint what to do. Thank You!           Remove["Global`*"]
Points = {{0,
    0}, {1, -1}, {2, -2}, {3, -4}, {4, -3}, {5, -4}, {6, -1}, {7, \
-4}, {8, 2}, {9, 3}, {10, -1}, {11, -4}};
f = Interpolation[Points,
   InterpolationOrder -> 1](*Polynom from Points*);

\ = 45 °; (*Angle of Linear*)
fg[x_, Pos_] := -x*Tan[\] + Points[][[2]] +
  Points[][[1]]*
   Tan[\] (*Linear equation throug point (Points), gradient \
from \  *)
Plot[{fg[x, 9], f}, {x, 0, 11}, Epilog -> Map[Point, Points],
ImageSize -> Large, AspectRatio -> 1] (*Plot*)

sol = FindRoot[fg[x, 9] == f, {x, 8}, AccuracyGoal -> 8,
   PrecisionGoal -> 8];
solution = x /. sol
(*Check*)
f == fg[solution, 9]
POSTED BY: Matthias Weber
I hope this helps, I am rewriting the problem a little bit.

First the list of points:
points = {{0, 0}, {1, -1}, {2, -2}, {3, -4}, {4, -3}, {5, -4}, {6, -1}, {7, -4}, {8, 2}, {9, 3}, {10, -1}, {11, -4}};

Next the piecewise linear interpolation function:
f = Interpolation[points, InterpolationOrder -> 1]

Visualize them together in a plot:
Plot[f[x], {x, 0, 11}, Epilog -> {AbsolutePointSize[6], Red, Point[points]}]



Next the 'fg' function:
fg[x_, pos_] := -x*Tan[Pi/4] + points[[pos, 2]] + points[[pos, 1]]*Tan[Pi/4]

And visualize again, everything together:
Plot[Join[{f[x]}, Table[fg[x, i], {i, 1, 12}]], {x, 0, 11},
Epilog -> {AbsolutePointSize[6], Red, Point[points]}]



Now solve for one of the intersections:
FindRoot[fg[x, 9] == f[x], {x, 8.5}]  (* returns {x->8.} *)
POSTED BY: Arnoud Buzing
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract