1

I want to make curve with polynominal function like this figure enter image description here

but only 2 known point to solve this one. I try to used solve function for this one. but the result is not the same like the figure.

here is my code

h1 = 50;
h2 = 80;

[Theta]1 = 5 [Pi]; [Theta]2 = 9 [Pi];

eq1 = a0 + (a1[Theta]1) + (a2[Theta]1^2) + (a3[Theta]1^3) == h1; eq2 = a1 + (a2[Theta]1) + (a3[Theta]1^2) == 0; eq3 = a0 + (a1[Theta]2) + (a2[Theta]2^2) + (a3[Theta]2^3) == h2; eq4 = a1 + (a2[Theta]2) + (a3[Theta]2^2) == 0; va = NSolve[{eq1, eq2, eq3, eq4}, {a0, a1, a2, a3}, Reals, WorkingPrecision -> 7]; eq = (a0 + a1 # + a2 #^2 + a3 #^3) &; P = eq[t] /. va[[1]] // N Plot[P, {t, [Theta]1, [Theta]2}]

this is my curve result with that code

enter image description here

Thank you everyone

user64494
  • 26,149
  • 4
  • 27
  • 56
葉柏樂
  • 157
  • 5

1 Answers1

2

I'm assuming what the OP wants is the lowest order polynomial that goes through two given points and has 0 gradient at those two points. The latter isn't explicitly stated, but I implied it from the diagram and the use of a cubic polynomial.

For this problem, we have 4 constraints, and therefore require a polynomial with 4 coefficients, aka, a cubic. This can then be passed to solved along with the constraints and plotted, giving a graph similar to what was in the question:

h1 = 50;
h2 = 80;
\[Theta]1 = 5 \[Pi];
\[Theta]2 = 9 \[Pi];

f[[Theta]_]:= a [Theta]^3+b [Theta]^2 + c [Theta] + d sols = Solve[{f[[Theta]1] == h1, f[[Theta]2]==h2, f'[[Theta]1]==f'[[Theta]2]==0}, {a, b, c, d}];

fSolve[[Theta]_] = f[[Theta]] /. sols[[1]]

Show[ Plot[fSolve[[Theta]], {[Theta], [Theta]1, [Theta]2}, PlotRange->{{[Theta]1-[Pi], [Theta]2+[Pi]}, {h1-10, h2+10}}], Graphics[{PointSize[Large], Red, Point[{[Theta]1, h1}]}], Graphics[{PointSize[Large], Red, Point[{[Theta]2, h2}]}] ]

out = 4925/16-(2025 [Theta])/(16 [Pi])+(315 [Theta]^2)/(16 [Pi]^2)-(15 [Theta]^3)/(16 [Pi]^3)

enter image description here

ScienceSnake
  • 250
  • 9