Polynomial problem-help me please

this post is deleted for nother topic

You probably want to use either Interpolations.jl or Data Interpolations.jl here. Maybe even BSplineKit.jl

It would be helpful to show us what your student has tried up to now.

this post is deleted for another topic

I would recommend your student come here directly - he or she will find the community here very helpful and welcoming. Here’s one solution with Polynomials.jl:

using Plots
using Polynomials

M = [148 61
151 58
150 64
168 65
160 55
162 57
188 100
193 91
141 46
184 85
192 112
176 77
183 83
172 64
178 100
181 92
181 86
175 88
194 88];

xs = Float64.(M[:, 1])
ys = Float64.(M[:, 2])
fits = [fit(xs, ys, o) for o ∈ (2,4,6,8,12,18)]
o2 = scatter(xs, ys)
plot!(o2, fits[1], extrema(xs)..., legend=false, title="Order 2")
o4 = scatter(xs, ys)
plot!(o4, fits[2], extrema(xs)..., legend=false, title="Order 4")
o6 = scatter(xs, ys)
plot!(o6, fits[3], extrema(xs)..., legend=false, title="Order 6")
o8 = scatter(xs, ys)
plot!(o8, fits[4], extrema(xs)..., legend=false, title="Order 8")
o12 = scatter(xs, ys)
plot!(o12, fits[5], extrema(xs)..., legend=false, title="Order 12")
o18 = scatter(xs, ys)
plot!(o18, fits[6], extrema(xs)..., legend=false, title="Order 18")


I’m not sure what’s going on with the last one…I’m getting NaNs in the result of the fitted polynomial…that would be something to explore further and potentially seek help here on Discourse for.

1 Like

the teacher want the code how i write.

what i need fix for do the line how i send you the picture before.


I count 19 datapoints, so 18 polynomial terms plus one intercept means no more degrees of freedom?

1 Like

Just out of curiosity, as an Italian academic living abroad: who’s using Julia in university teaching in Italy? Would like to connect

University of Pisa

1 Like

You may also want to check with your mentee if the prof or institution have a policy about asking for help online — it’s not uncommon for professors to be active here (anyone wanna find the post from the time that a prof dropped in on a student’s thread? :)).

We don’t explicitly prohibit asking for homework help here, but we do ask that you take time to format your posts and present what you’ve tried in a readable manner: