How do I find a function to fit these criteria?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I want to find a smooth continuous function f[x]
that satisfies the following for real values of x
:
Solve[f[0] == 0 && Derivative[1][f][0] == 1/2 && f[10] == 5 &&
Derivative[1][f][10] == 2/5, f]
This produces , meaning no solutions. But I find this very hard to believe. Some form of sinusoidal curve would surely do the job. Which leads me to believe I am doing something wrong - presumably I'm just not creating the right input and
Solve
is not the right tool.
How do I find a continuous function of x
that fits these criteria?
equation-solving function-construction interpolation
add a comment |Â
up vote
1
down vote
favorite
I want to find a smooth continuous function f[x]
that satisfies the following for real values of x
:
Solve[f[0] == 0 && Derivative[1][f][0] == 1/2 && f[10] == 5 &&
Derivative[1][f][10] == 2/5, f]
This produces , meaning no solutions. But I find this very hard to believe. Some form of sinusoidal curve would surely do the job. Which leads me to believe I am doing something wrong - presumably I'm just not creating the right input and
Solve
is not the right tool.
How do I find a continuous function of x
that fits these criteria?
equation-solving function-construction interpolation
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I want to find a smooth continuous function f[x]
that satisfies the following for real values of x
:
Solve[f[0] == 0 && Derivative[1][f][0] == 1/2 && f[10] == 5 &&
Derivative[1][f][10] == 2/5, f]
This produces , meaning no solutions. But I find this very hard to believe. Some form of sinusoidal curve would surely do the job. Which leads me to believe I am doing something wrong - presumably I'm just not creating the right input and
Solve
is not the right tool.
How do I find a continuous function of x
that fits these criteria?
equation-solving function-construction interpolation
I want to find a smooth continuous function f[x]
that satisfies the following for real values of x
:
Solve[f[0] == 0 && Derivative[1][f][0] == 1/2 && f[10] == 5 &&
Derivative[1][f][10] == 2/5, f]
This produces , meaning no solutions. But I find this very hard to believe. Some form of sinusoidal curve would surely do the job. Which leads me to believe I am doing something wrong - presumably I'm just not creating the right input and
Solve
is not the right tool.
How do I find a continuous function of x
that fits these criteria?
equation-solving function-construction interpolation
equation-solving function-construction interpolation
asked 10 hours ago
Richard Burke-Ward
4249
4249
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
6
down vote
accepted
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.
2
You can useInterpolatingPolynomial
directly:InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]
â J. M. is computer-lessâ¦
10 hours ago
Great. One follow-up question: is there a trigonometric equivalent toInterpolatingPolynomial
?
â Richard Burke-Ward
8 hours ago
@RichardBurke-Ward As far as I am aware, there is no equivalent function defined in Mathematica for trigonometric functions. While there certainly do exist a pair of sine waves that'll match those derivatives and positions, it's rather less clear how to go about finding their parameters. Choosing an appropriatef
is the first step, but subsequently solving it is more difficult. Since there's a zero at the origin, I'd suggestf[x_] := a Sin[b x] + c Sin[d x]
as a starting point.
â eyorble
8 hours ago
2
Altho there are equivalents of Lagrange and Hermite interpolation for trigonometric interpolants, the algorithms are not built-in.@Richard, those will need to be implemented manually if you really need them.
â J. M. is computer-lessâ¦
8 hours ago
Many thanks to both of you. I'll mark as answered :-)
â Richard Burke-Ward
8 hours ago
add a comment |Â
up vote
3
down vote
An another alternative, giving the same result is
DSolve[f''''[x] == 0 && f[0] == 0 && Derivative[1][f][0] == 1/2 &&
f[10] == 5 && Derivative[1][f][10] == 2/5, f, x]
(*f -> Function[x, (500 x + 10 x^2 - x^3)/1000]*)
1
Even more generally,DSolve[f''''[x] == g''''[x], f[0] == 0, Derivative[1][f][0] == 1/2, f[10] == 5, Derivative[1][f][10] == 2/5, f, x]
gives a solution valid for any sufficiently smooth functiong
. (+1)
â Michael E2
5 hours ago
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
accepted
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.
2
You can useInterpolatingPolynomial
directly:InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]
â J. M. is computer-lessâ¦
10 hours ago
Great. One follow-up question: is there a trigonometric equivalent toInterpolatingPolynomial
?
â Richard Burke-Ward
8 hours ago
@RichardBurke-Ward As far as I am aware, there is no equivalent function defined in Mathematica for trigonometric functions. While there certainly do exist a pair of sine waves that'll match those derivatives and positions, it's rather less clear how to go about finding their parameters. Choosing an appropriatef
is the first step, but subsequently solving it is more difficult. Since there's a zero at the origin, I'd suggestf[x_] := a Sin[b x] + c Sin[d x]
as a starting point.
â eyorble
8 hours ago
2
Altho there are equivalents of Lagrange and Hermite interpolation for trigonometric interpolants, the algorithms are not built-in.@Richard, those will need to be implemented manually if you really need them.
â J. M. is computer-lessâ¦
8 hours ago
Many thanks to both of you. I'll mark as answered :-)
â Richard Burke-Ward
8 hours ago
add a comment |Â
up vote
6
down vote
accepted
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.
2
You can useInterpolatingPolynomial
directly:InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]
â J. M. is computer-lessâ¦
10 hours ago
Great. One follow-up question: is there a trigonometric equivalent toInterpolatingPolynomial
?
â Richard Burke-Ward
8 hours ago
@RichardBurke-Ward As far as I am aware, there is no equivalent function defined in Mathematica for trigonometric functions. While there certainly do exist a pair of sine waves that'll match those derivatives and positions, it's rather less clear how to go about finding their parameters. Choosing an appropriatef
is the first step, but subsequently solving it is more difficult. Since there's a zero at the origin, I'd suggestf[x_] := a Sin[b x] + c Sin[d x]
as a starting point.
â eyorble
8 hours ago
2
Altho there are equivalents of Lagrange and Hermite interpolation for trigonometric interpolants, the algorithms are not built-in.@Richard, those will need to be implemented manually if you really need them.
â J. M. is computer-lessâ¦
8 hours ago
Many thanks to both of you. I'll mark as answered :-)
â Richard Burke-Ward
8 hours ago
add a comment |Â
up vote
6
down vote
accepted
up vote
6
down vote
accepted
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]
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.
edited 8 hours ago
answered 10 hours ago
eyorble
4,6301725
4,6301725
2
You can useInterpolatingPolynomial
directly:InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]
â J. M. is computer-lessâ¦
10 hours ago
Great. One follow-up question: is there a trigonometric equivalent toInterpolatingPolynomial
?
â Richard Burke-Ward
8 hours ago
@RichardBurke-Ward As far as I am aware, there is no equivalent function defined in Mathematica for trigonometric functions. While there certainly do exist a pair of sine waves that'll match those derivatives and positions, it's rather less clear how to go about finding their parameters. Choosing an appropriatef
is the first step, but subsequently solving it is more difficult. Since there's a zero at the origin, I'd suggestf[x_] := a Sin[b x] + c Sin[d x]
as a starting point.
â eyorble
8 hours ago
2
Altho there are equivalents of Lagrange and Hermite interpolation for trigonometric interpolants, the algorithms are not built-in.@Richard, those will need to be implemented manually if you really need them.
â J. M. is computer-lessâ¦
8 hours ago
Many thanks to both of you. I'll mark as answered :-)
â Richard Burke-Ward
8 hours ago
add a comment |Â
2
You can useInterpolatingPolynomial
directly:InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]
â J. M. is computer-lessâ¦
10 hours ago
Great. One follow-up question: is there a trigonometric equivalent toInterpolatingPolynomial
?
â Richard Burke-Ward
8 hours ago
@RichardBurke-Ward As far as I am aware, there is no equivalent function defined in Mathematica for trigonometric functions. While there certainly do exist a pair of sine waves that'll match those derivatives and positions, it's rather less clear how to go about finding their parameters. Choosing an appropriatef
is the first step, but subsequently solving it is more difficult. Since there's a zero at the origin, I'd suggestf[x_] := a Sin[b x] + c Sin[d x]
as a starting point.
â eyorble
8 hours ago
2
Altho there are equivalents of Lagrange and Hermite interpolation for trigonometric interpolants, the algorithms are not built-in.@Richard, those will need to be implemented manually if you really need them.
â J. M. is computer-lessâ¦
8 hours ago
Many thanks to both of you. I'll mark as answered :-)
â Richard Burke-Ward
8 hours ago
2
2
You can use
InterpolatingPolynomial
directly: InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]
â J. M. is computer-lessâ¦
10 hours ago
You can use
InterpolatingPolynomial
directly: InterpolatingPolynomial[0, 0, 1/2, 10, 5, 2/5, x]
â J. M. is computer-lessâ¦
10 hours ago
Great. One follow-up question: is there a trigonometric equivalent to
InterpolatingPolynomial
?â Richard Burke-Ward
8 hours ago
Great. One follow-up question: is there a trigonometric equivalent to
InterpolatingPolynomial
?â Richard Burke-Ward
8 hours ago
@RichardBurke-Ward As far as I am aware, there is no equivalent function defined in Mathematica for trigonometric functions. While there certainly do exist a pair of sine waves that'll match those derivatives and positions, it's rather less clear how to go about finding their parameters. Choosing an appropriate
f
is the first step, but subsequently solving it is more difficult. Since there's a zero at the origin, I'd suggest f[x_] := a Sin[b x] + c Sin[d x]
as a starting point.â eyorble
8 hours ago
@RichardBurke-Ward As far as I am aware, there is no equivalent function defined in Mathematica for trigonometric functions. While there certainly do exist a pair of sine waves that'll match those derivatives and positions, it's rather less clear how to go about finding their parameters. Choosing an appropriate
f
is the first step, but subsequently solving it is more difficult. Since there's a zero at the origin, I'd suggest f[x_] := a Sin[b x] + c Sin[d x]
as a starting point.â eyorble
8 hours ago
2
2
Altho there are equivalents of Lagrange and Hermite interpolation for trigonometric interpolants, the algorithms are not built-in.@Richard, those will need to be implemented manually if you really need them.
â J. M. is computer-lessâ¦
8 hours ago
Altho there are equivalents of Lagrange and Hermite interpolation for trigonometric interpolants, the algorithms are not built-in.@Richard, those will need to be implemented manually if you really need them.
â J. M. is computer-lessâ¦
8 hours ago
Many thanks to both of you. I'll mark as answered :-)
â Richard Burke-Ward
8 hours ago
Many thanks to both of you. I'll mark as answered :-)
â Richard Burke-Ward
8 hours ago
add a comment |Â
up vote
3
down vote
An another alternative, giving the same result is
DSolve[f''''[x] == 0 && f[0] == 0 && Derivative[1][f][0] == 1/2 &&
f[10] == 5 && Derivative[1][f][10] == 2/5, f, x]
(*f -> Function[x, (500 x + 10 x^2 - x^3)/1000]*)
1
Even more generally,DSolve[f''''[x] == g''''[x], f[0] == 0, Derivative[1][f][0] == 1/2, f[10] == 5, Derivative[1][f][10] == 2/5, f, x]
gives a solution valid for any sufficiently smooth functiong
. (+1)
â Michael E2
5 hours ago
add a comment |Â
up vote
3
down vote
An another alternative, giving the same result is
DSolve[f''''[x] == 0 && f[0] == 0 && Derivative[1][f][0] == 1/2 &&
f[10] == 5 && Derivative[1][f][10] == 2/5, f, x]
(*f -> Function[x, (500 x + 10 x^2 - x^3)/1000]*)
1
Even more generally,DSolve[f''''[x] == g''''[x], f[0] == 0, Derivative[1][f][0] == 1/2, f[10] == 5, Derivative[1][f][10] == 2/5, f, x]
gives a solution valid for any sufficiently smooth functiong
. (+1)
â Michael E2
5 hours ago
add a comment |Â
up vote
3
down vote
up vote
3
down vote
An another alternative, giving the same result is
DSolve[f''''[x] == 0 && f[0] == 0 && Derivative[1][f][0] == 1/2 &&
f[10] == 5 && Derivative[1][f][10] == 2/5, f, x]
(*f -> Function[x, (500 x + 10 x^2 - x^3)/1000]*)
An another alternative, giving the same result is
DSolve[f''''[x] == 0 && f[0] == 0 && Derivative[1][f][0] == 1/2 &&
f[10] == 5 && Derivative[1][f][10] == 2/5, f, x]
(*f -> Function[x, (500 x + 10 x^2 - x^3)/1000]*)
answered 8 hours ago
mikado
6,2721829
6,2721829
1
Even more generally,DSolve[f''''[x] == g''''[x], f[0] == 0, Derivative[1][f][0] == 1/2, f[10] == 5, Derivative[1][f][10] == 2/5, f, x]
gives a solution valid for any sufficiently smooth functiong
. (+1)
â Michael E2
5 hours ago
add a comment |Â
1
Even more generally,DSolve[f''''[x] == g''''[x], f[0] == 0, Derivative[1][f][0] == 1/2, f[10] == 5, Derivative[1][f][10] == 2/5, f, x]
gives a solution valid for any sufficiently smooth functiong
. (+1)
â Michael E2
5 hours ago
1
1
Even more generally,
DSolve[f''''[x] == g''''[x], f[0] == 0, Derivative[1][f][0] == 1/2, f[10] == 5, Derivative[1][f][10] == 2/5, f, x]
gives a solution valid for any sufficiently smooth function g
. (+1)â Michael E2
5 hours ago
Even more generally,
DSolve[f''''[x] == g''''[x], f[0] == 0, Derivative[1][f][0] == 1/2, f[10] == 5, Derivative[1][f][10] == 2/5, f, x]
gives a solution valid for any sufficiently smooth function g
. (+1)â Michael E2
5 hours ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183838%2fhow-do-i-find-a-function-to-fit-these-criteria%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password