Skip to main content
added 626 characters in body
Source Link
eyorble
  • 9.6k
  • 1
  • 25
  • 38

The simplest solution is probably the polynomial one. This satisfies smooth and continuous automatically. You have 4 conditions you want to satisfy, so use a cubic equation (4 parameters).

f[x_] := a x^3 + b x^2 + c x + d;
Solve[{f[0] == 0, f'[0] == 1/2, f[10] == 5, f'[10] == 2/5}, {a, b, c, d}]

{{a -> -(1/1000), b -> 1/100, c -> 1/2, d -> 0}}

Note, however, that this a singular instance of a function meeting these parameters. The reason Solve fails is because there are an infinite number of such functions, many of which cannot be reasonably represented in terms of algebraic manipulations. After all, all that has been defined here is the values at two points and the slopes at two points. So long as whatever happens in-between is smooth and continuous, anything can happen.

J.M. has noted that this process has been implemented in Mathematica already as InterpolatingPolynomial:

InterpolatingPolynomial[{{{0}, 0, 1/2}, {{10}, 5, 2/5}}, x]

To extend this process to alternative forms, just pick an appropriate f. For example, to fit this with a pair of sine curves, the following suffices:

f[x_] := a Sin[b x] + c Sin[x];
NMinimize[Norm[{f'[0] - 1/2, f[10] - 5, f'[10] - 2/5}], {a, b, c}]

NMinimize is used here because the exact solvers seem to have a fair bit of difficulty with this form. The result is reasonably accurate even without fine-tuning. Since there is a zero at the origin and that this function is guaranteed zero at the origin, including that criteria would only confuse the solver in this case and a parameter can be omitted.

The simplest solution is probably the polynomial one. This satisfies smooth and continuous automatically. You have 4 conditions you want to satisfy, so use a cubic equation (4 parameters).

f[x_] := a x^3 + b x^2 + c x + d;
Solve[{f[0] == 0, f'[0] == 1/2, f[10] == 5, f'[10] == 2/5}, {a, b, c, d}]

{{a -> -(1/1000), b -> 1/100, c -> 1/2, d -> 0}}

Note, however, that this a singular instance of a function meeting these parameters. The reason Solve fails is because there are an infinite number of such functions, many of which cannot be reasonably represented in terms of algebraic manipulations. After all, all that has been defined here is the values at two points and the slopes at two points. So long as whatever happens in-between is smooth and continuous, anything can happen.

J.M. has noted that this process has been implemented in Mathematica already as InterpolatingPolynomial:

InterpolatingPolynomial[{{{0}, 0, 1/2}, {{10}, 5, 2/5}}, x]

The simplest solution is probably the polynomial one. This satisfies smooth and continuous automatically. You have 4 conditions you want to satisfy, so use a cubic equation (4 parameters).

f[x_] := a x^3 + b x^2 + c x + d;
Solve[{f[0] == 0, f'[0] == 1/2, f[10] == 5, f'[10] == 2/5}, {a, b, c, d}]

{{a -> -(1/1000), b -> 1/100, c -> 1/2, d -> 0}}

Note, however, that this a singular instance of a function meeting these parameters. The reason Solve fails is because there are an infinite number of such functions, many of which cannot be reasonably represented in terms of algebraic manipulations. After all, all that has been defined here is the values at two points and the slopes at two points. So long as whatever happens in-between is smooth and continuous, anything can happen.

J.M. has noted that this process has been implemented in Mathematica already as InterpolatingPolynomial:

InterpolatingPolynomial[{{{0}, 0, 1/2}, {{10}, 5, 2/5}}, x]

To extend this process to alternative forms, just pick an appropriate f. For example, to fit this with a pair of sine curves, the following suffices:

f[x_] := a Sin[b x] + c Sin[x];
NMinimize[Norm[{f'[0] - 1/2, f[10] - 5, f'[10] - 2/5}], {a, b, c}]

NMinimize is used here because the exact solvers seem to have a fair bit of difficulty with this form. The result is reasonably accurate even without fine-tuning. Since there is a zero at the origin and that this function is guaranteed zero at the origin, including that criteria would only confuse the solver in this case and a parameter can be omitted.

Migrating J.M.'s comment into the answer. Thanks J.M.
Source Link
eyorble
  • 9.6k
  • 1
  • 25
  • 38

The simplest solution is probably the polynomial one. This satisfies smooth and continuous automatically. You have 4 conditions you want to satisfy, so use a cubic equation (4 parameters).

f[x_] := a x^3 + b x^2 + c x + d;
Solve[{f[0] == 0, f'[0] == 1/2, f[10] == 5, f'[10] == 2/5}, {a, b, c, d}]

{{a -> -(1/1000), b -> 1/100, c -> 1/2, d -> 0}}

Note, however, that this a singular instance of a function meeting these parameters. The reason Solve fails is because there are an infinite number of such functions, many of which cannot be reasonably represented in terms of algebraic manipulations. After all, all that has been defined here is the values at two points and the slopes at two points. So long as whatever happens in-between is smooth and continuous, anything can happen.

J.M. has noted that this process has been implemented in Mathematica already as InterpolatingPolynomial:

InterpolatingPolynomial[{{{0}, 0, 1/2}, {{10}, 5, 2/5}}, x]

The simplest solution is probably the polynomial one. This satisfies smooth and continuous automatically. You have 4 conditions you want to satisfy, so use a cubic equation (4 parameters).

f[x_] := a x^3 + b x^2 + c x + d;
Solve[{f[0] == 0, f'[0] == 1/2, f[10] == 5, f'[10] == 2/5}, {a, b, c, d}]

{{a -> -(1/1000), b -> 1/100, c -> 1/2, d -> 0}}

Note, however, that this a singular instance of a function meeting these parameters. The reason Solve fails is because there are an infinite number of such functions, many of which cannot be reasonably represented in terms of algebraic manipulations. After all, all that has been defined here is the values at two points and the slopes at two points. So long as whatever happens in-between is smooth and continuous, anything can happen.

The simplest solution is probably the polynomial one. This satisfies smooth and continuous automatically. You have 4 conditions you want to satisfy, so use a cubic equation (4 parameters).

f[x_] := a x^3 + b x^2 + c x + d;
Solve[{f[0] == 0, f'[0] == 1/2, f[10] == 5, f'[10] == 2/5}, {a, b, c, d}]

{{a -> -(1/1000), b -> 1/100, c -> 1/2, d -> 0}}

Note, however, that this a singular instance of a function meeting these parameters. The reason Solve fails is because there are an infinite number of such functions, many of which cannot be reasonably represented in terms of algebraic manipulations. After all, all that has been defined here is the values at two points and the slopes at two points. So long as whatever happens in-between is smooth and continuous, anything can happen.

J.M. has noted that this process has been implemented in Mathematica already as InterpolatingPolynomial:

InterpolatingPolynomial[{{{0}, 0, 1/2}, {{10}, 5, 2/5}}, x]
Source Link
eyorble
  • 9.6k
  • 1
  • 25
  • 38

The simplest solution is probably the polynomial one. This satisfies smooth and continuous automatically. You have 4 conditions you want to satisfy, so use a cubic equation (4 parameters).

f[x_] := a x^3 + b x^2 + c x + d;
Solve[{f[0] == 0, f'[0] == 1/2, f[10] == 5, f'[10] == 2/5}, {a, b, c, d}]

{{a -> -(1/1000), b -> 1/100, c -> 1/2, d -> 0}}

Note, however, that this a singular instance of a function meeting these parameters. The reason Solve fails is because there are an infinite number of such functions, many of which cannot be reasonably represented in terms of algebraic manipulations. After all, all that has been defined here is the values at two points and the slopes at two points. So long as whatever happens in-between is smooth and continuous, anything can happen.