I am plotting an epicycloid and trying to find the x values of where the plot intercepts the x-axis. Here’s what I’ve done:
When I solve (setting y = 0), I get an output that I don’t know how to interpret:
Hi Bryan,
Try FindInstance.
Best,
David
PS. If you put your code in a spikey box we can copy/paste from it.
(Remove semicolons and evaluate)
xcoordinate[a_, b_, t_] := (a + b) Cos[t] - b Cos[(a + b)/b t];
ycoordinate[a_, b_, t_] := (a + b) Sin[t] - b Sin[(a + b)/b t];
plot1 = ParametricPlot[{xcoordinate[2/5, 46/35, t],
ycoordinate[2/5, 46/35, t]}, {t, 0, 46 \[Pi]}];
(* Find t for up to 1000 instances *)
tValues =
t /. FindInstance[
ycoordinate[2/5, 46/35, t] == 0 && 0 <= t <= 46 \[Pi], {t},
Reals, 1000] // N;
(* Make points at the intercept coordinates *)
points = {Red,
Point[{xcoordinate[2/5, 46/35, #], ycoordinate[2/5, 46/35, #]}] & /@
tValues};
Show[plot1, Epilog -> points];
You can also use NSolve, like this, with David Keith’s setup:
NSolve[ycoordinate[2/5, 46/35, t] == 0 && 0 <= t <= 46 \[Pi], {t}, Reals]
thank you both very much! i will spikey in the future
You’re welcome, Bryan.
BTW, I like Michaels’s use of NSolve better than my FindInstance. It seems more likely that Mathematica is commited to finding all the solutions.