0
$\begingroup$

I'm attempting to fit the positive domain part of an odd polynomial to even polynomials using the Fit function, and I get incredibly tiny coefficients that are clearly wrong. Now, I've read the "possible issues" section of the documentation that mentions this exact problem, and I have attempted the solution they advise (shifting and scaling your basis set), to no avail. Is there any recourse within Mathematica? I've tried the other fitting functions, with similar results.

Fit[Transpose[{Table[i^3, {i, 0, 10, 0.01}], Range[0, 10, 0.01]}], {x^2, x^4, x^6}, x]

(* Out: (0.0000714209) x^2 + (-1.5437*10^-10) x^4 + (9.69696*10^-17) x^6 *)
$\endgroup$

closed as off-topic by Daniel Lichtblau, MarcoB, Itai Seggev, LCarvalho, m_goldberg Aug 18 '17 at 16:28

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, MarcoB, Itai Seggev, LCarvalho
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 6
    $\begingroup$ You're trying to approximate something with a vertical tangent at the origin with the monomial basis. Such things don't end well. $\endgroup$ – J. M. will be back soon Aug 15 '17 at 14:42
  • $\begingroup$ I'm voting to close this question as off-topic because the issue it raises is not really a Mathematica issue but a matter of the OP not having grasped the mathematics involved. $\endgroup$ – m_goldberg Aug 18 '17 at 16:28
  • $\begingroup$ I'm in favor of closing it as off topic since it was a simple mistake (and I got my answer anyway), but it was a syntax error. I understand the math just fine. $\endgroup$ – Qaziz Aug 19 '17 at 21:00
2
$\begingroup$

$x^{3}$

If you're trying to fit $x^3$ with $a x^2 + b x^4 + c x^6$, with your current setup you're fitting the range rather then function. i.e. you're submitting: {{f[x[1]], x[1]},...} when you want to supply: {{ x[1], f[x[1]]},...}

Try:

Fit[Table[{i, i^3}, {i, 0, 10, 1/100}], {x^2, x^4, x^6}, x]

$x^{1/3}$

If you're really trying to fit $x^{1/3}$ (not technically an odd polynomial), as J.M. points out in his comment, you won't get there with $a x^2 + b x^4 + c x^6$. You can try: $a x^{1/2} + b x^{1/4} + c x^{1/6}$:

soln= Fit[Table[{i^3, i}, {i, 0, 10, 1/100}], {x^(1/2), x^(1/4), x^(1/6)}, x]

Landing on:

-0.88736 x^(1/6) + 1.80165 x^(1/4) + 0.0853975 Sqrt[x]

fitPlot

with deviation plot:

deviationPlot

$\endgroup$
  • 2
    $\begingroup$ Actually, if he's trying to approximate the cube root function, then that's the right table. His choice of approximation method is another kettle of fish altogether. $\endgroup$ – J. M. will be back soon Aug 15 '17 at 14:49
  • $\begingroup$ All the same, this seems to have solved my problem. I flipped the values! Thanks, both of you. $\endgroup$ – Qaziz Aug 15 '17 at 14:53
  • $\begingroup$ He said odd polynomial so I assumed he was trying to fit $x^3$ with $a x^2 + b x^4 + c x^6$. $\endgroup$ – John Joseph M. Carrasco Aug 15 '17 at 14:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.