How can I make a general plot like this in Mathematica?
$begingroup$
I want to make two general graphics something like the following.
I want to illustrate the approach to the function by means of a polynomial. I have tried the following.
Plot[{Sin[x] + 2, Sin[2 x] + 2}, {x, 0, 8}, AxesLabel -> {x, y},
Ticks -> {{0.8, 2.4, 4, 5.5, 7.1}, {0, 1, 2, 3}}]
I also want to put $ x_{0}, x_{1}, x_{2},...,x_{n} $ in the points where the graphs differ the most. I appreciate any help.
plotting graphics
$endgroup$
add a comment |
$begingroup$
I want to make two general graphics something like the following.
I want to illustrate the approach to the function by means of a polynomial. I have tried the following.
Plot[{Sin[x] + 2, Sin[2 x] + 2}, {x, 0, 8}, AxesLabel -> {x, y},
Ticks -> {{0.8, 2.4, 4, 5.5, 7.1}, {0, 1, 2, 3}}]
I also want to put $ x_{0}, x_{1}, x_{2},...,x_{n} $ in the points where the graphs differ the most. I appreciate any help.
plotting graphics
$endgroup$
add a comment |
$begingroup$
I want to make two general graphics something like the following.
I want to illustrate the approach to the function by means of a polynomial. I have tried the following.
Plot[{Sin[x] + 2, Sin[2 x] + 2}, {x, 0, 8}, AxesLabel -> {x, y},
Ticks -> {{0.8, 2.4, 4, 5.5, 7.1}, {0, 1, 2, 3}}]
I also want to put $ x_{0}, x_{1}, x_{2},...,x_{n} $ in the points where the graphs differ the most. I appreciate any help.
plotting graphics
$endgroup$
I want to make two general graphics something like the following.
I want to illustrate the approach to the function by means of a polynomial. I have tried the following.
Plot[{Sin[x] + 2, Sin[2 x] + 2}, {x, 0, 8}, AxesLabel -> {x, y},
Ticks -> {{0.8, 2.4, 4, 5.5, 7.1}, {0, 1, 2, 3}}]
I also want to put $ x_{0}, x_{1}, x_{2},...,x_{n} $ in the points where the graphs differ the most. I appreciate any help.
plotting graphics
plotting graphics
asked Feb 5 at 6:55
Jacob SchwartzJacob Schwartz
475
475
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
f[x_] := 1 + x + Sin[10 Sqrt[1 + x]];
g[x_] := 1 + x + Cos[10 Sqrt[2 + x]];
xx = x /. NSolve[{f'[x] == g'[x], 0 <= x <= 8}, x];
ticks = MapIndexed[{#, Style[ Subscript["x", ToString@ #2[[1]]], 16]} &, xx];
Plot[{f[x], g[x]}, {x, 0, 3 Pi}, AxesLabel -> {x, y},
MeshFunctions -> {f'[#] - g'[#] &}, Mesh -> {{0}},
MeshStyle -> Directive[Red, PointSize[Large]],
GridLines -> {xx, None}, Ticks -> {ticks, Automatic},
AxesOrigin -> {0, 0}]
$endgroup$
$begingroup$
How could you put $x_{0}, x_{1}, ..., x_{6}$ instead $x_{1}, x_{2}, ..., x_{7}$?
$endgroup$
– Jacob Schwartz
Feb 5 at 8:10
$begingroup$
@JacobSchwartz, replaceToString@#2[[1]]
withToString[#2[[1]] - 1]
.
$endgroup$
– kglr
Feb 5 at 8:19
add a comment |
$begingroup$
Something like this?
Plot[{Sin[x] + 2, Sin[2 x] + 2}, {x, 0, 8}, AxesLabel -> {x, y},
Ticks -> {{{1, "x[0]"}, {2, "x[1]"}, {3, ""}, {4, "x[3]"}, {5,
""}, {6, ""}, {7, "x[n]"}}, None},
PlotLabels -> Placed[{"y=f(x)", "y=p(x)"}, {Scaled[5], Above}],
AxesStyle -> Arrowheads[{0.0, 0.05}]]
Or
Plot[{Sin[x] + 2, Sin[2 x] + 2}, {x, 0, 8}, AxesLabel -> {x, y},
Ticks -> {{{1, "x[0]"}, {2, "x[1]"}, {3, ""}, {4, "x[2]"}, {5,
""}, {6, ""}, {7, "x[n]"}}, None},
AxesStyle -> Arrowheads[{0.0, 0.05}],
Epilog -> {Text[Style["y=f(x)", 22], Scaled[{0.5, 0.9}]],
Text[Style["y=p(x)", 22], Scaled[{0.25, 0.97}]]}]
$endgroup$
$begingroup$
I put the functions Sin [x] +2, Sin [2x] +2 because I did not find others, but I would like others different from mine.
$endgroup$
– Jacob Schwartz
Feb 5 at 7:56
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f190905%2fhow-can-i-make-a-general-plot-like-this-in-mathematica%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
f[x_] := 1 + x + Sin[10 Sqrt[1 + x]];
g[x_] := 1 + x + Cos[10 Sqrt[2 + x]];
xx = x /. NSolve[{f'[x] == g'[x], 0 <= x <= 8}, x];
ticks = MapIndexed[{#, Style[ Subscript["x", ToString@ #2[[1]]], 16]} &, xx];
Plot[{f[x], g[x]}, {x, 0, 3 Pi}, AxesLabel -> {x, y},
MeshFunctions -> {f'[#] - g'[#] &}, Mesh -> {{0}},
MeshStyle -> Directive[Red, PointSize[Large]],
GridLines -> {xx, None}, Ticks -> {ticks, Automatic},
AxesOrigin -> {0, 0}]
$endgroup$
$begingroup$
How could you put $x_{0}, x_{1}, ..., x_{6}$ instead $x_{1}, x_{2}, ..., x_{7}$?
$endgroup$
– Jacob Schwartz
Feb 5 at 8:10
$begingroup$
@JacobSchwartz, replaceToString@#2[[1]]
withToString[#2[[1]] - 1]
.
$endgroup$
– kglr
Feb 5 at 8:19
add a comment |
$begingroup$
f[x_] := 1 + x + Sin[10 Sqrt[1 + x]];
g[x_] := 1 + x + Cos[10 Sqrt[2 + x]];
xx = x /. NSolve[{f'[x] == g'[x], 0 <= x <= 8}, x];
ticks = MapIndexed[{#, Style[ Subscript["x", ToString@ #2[[1]]], 16]} &, xx];
Plot[{f[x], g[x]}, {x, 0, 3 Pi}, AxesLabel -> {x, y},
MeshFunctions -> {f'[#] - g'[#] &}, Mesh -> {{0}},
MeshStyle -> Directive[Red, PointSize[Large]],
GridLines -> {xx, None}, Ticks -> {ticks, Automatic},
AxesOrigin -> {0, 0}]
$endgroup$
$begingroup$
How could you put $x_{0}, x_{1}, ..., x_{6}$ instead $x_{1}, x_{2}, ..., x_{7}$?
$endgroup$
– Jacob Schwartz
Feb 5 at 8:10
$begingroup$
@JacobSchwartz, replaceToString@#2[[1]]
withToString[#2[[1]] - 1]
.
$endgroup$
– kglr
Feb 5 at 8:19
add a comment |
$begingroup$
f[x_] := 1 + x + Sin[10 Sqrt[1 + x]];
g[x_] := 1 + x + Cos[10 Sqrt[2 + x]];
xx = x /. NSolve[{f'[x] == g'[x], 0 <= x <= 8}, x];
ticks = MapIndexed[{#, Style[ Subscript["x", ToString@ #2[[1]]], 16]} &, xx];
Plot[{f[x], g[x]}, {x, 0, 3 Pi}, AxesLabel -> {x, y},
MeshFunctions -> {f'[#] - g'[#] &}, Mesh -> {{0}},
MeshStyle -> Directive[Red, PointSize[Large]],
GridLines -> {xx, None}, Ticks -> {ticks, Automatic},
AxesOrigin -> {0, 0}]
$endgroup$
f[x_] := 1 + x + Sin[10 Sqrt[1 + x]];
g[x_] := 1 + x + Cos[10 Sqrt[2 + x]];
xx = x /. NSolve[{f'[x] == g'[x], 0 <= x <= 8}, x];
ticks = MapIndexed[{#, Style[ Subscript["x", ToString@ #2[[1]]], 16]} &, xx];
Plot[{f[x], g[x]}, {x, 0, 3 Pi}, AxesLabel -> {x, y},
MeshFunctions -> {f'[#] - g'[#] &}, Mesh -> {{0}},
MeshStyle -> Directive[Red, PointSize[Large]],
GridLines -> {xx, None}, Ticks -> {ticks, Automatic},
AxesOrigin -> {0, 0}]
answered Feb 5 at 7:25
kglrkglr
183k10202417
183k10202417
$begingroup$
How could you put $x_{0}, x_{1}, ..., x_{6}$ instead $x_{1}, x_{2}, ..., x_{7}$?
$endgroup$
– Jacob Schwartz
Feb 5 at 8:10
$begingroup$
@JacobSchwartz, replaceToString@#2[[1]]
withToString[#2[[1]] - 1]
.
$endgroup$
– kglr
Feb 5 at 8:19
add a comment |
$begingroup$
How could you put $x_{0}, x_{1}, ..., x_{6}$ instead $x_{1}, x_{2}, ..., x_{7}$?
$endgroup$
– Jacob Schwartz
Feb 5 at 8:10
$begingroup$
@JacobSchwartz, replaceToString@#2[[1]]
withToString[#2[[1]] - 1]
.
$endgroup$
– kglr
Feb 5 at 8:19
$begingroup$
How could you put $x_{0}, x_{1}, ..., x_{6}$ instead $x_{1}, x_{2}, ..., x_{7}$?
$endgroup$
– Jacob Schwartz
Feb 5 at 8:10
$begingroup$
How could you put $x_{0}, x_{1}, ..., x_{6}$ instead $x_{1}, x_{2}, ..., x_{7}$?
$endgroup$
– Jacob Schwartz
Feb 5 at 8:10
$begingroup$
@JacobSchwartz, replace
ToString@#2[[1]]
with ToString[#2[[1]] - 1]
.$endgroup$
– kglr
Feb 5 at 8:19
$begingroup$
@JacobSchwartz, replace
ToString@#2[[1]]
with ToString[#2[[1]] - 1]
.$endgroup$
– kglr
Feb 5 at 8:19
add a comment |
$begingroup$
Something like this?
Plot[{Sin[x] + 2, Sin[2 x] + 2}, {x, 0, 8}, AxesLabel -> {x, y},
Ticks -> {{{1, "x[0]"}, {2, "x[1]"}, {3, ""}, {4, "x[3]"}, {5,
""}, {6, ""}, {7, "x[n]"}}, None},
PlotLabels -> Placed[{"y=f(x)", "y=p(x)"}, {Scaled[5], Above}],
AxesStyle -> Arrowheads[{0.0, 0.05}]]
Or
Plot[{Sin[x] + 2, Sin[2 x] + 2}, {x, 0, 8}, AxesLabel -> {x, y},
Ticks -> {{{1, "x[0]"}, {2, "x[1]"}, {3, ""}, {4, "x[2]"}, {5,
""}, {6, ""}, {7, "x[n]"}}, None},
AxesStyle -> Arrowheads[{0.0, 0.05}],
Epilog -> {Text[Style["y=f(x)", 22], Scaled[{0.5, 0.9}]],
Text[Style["y=p(x)", 22], Scaled[{0.25, 0.97}]]}]
$endgroup$
$begingroup$
I put the functions Sin [x] +2, Sin [2x] +2 because I did not find others, but I would like others different from mine.
$endgroup$
– Jacob Schwartz
Feb 5 at 7:56
add a comment |
$begingroup$
Something like this?
Plot[{Sin[x] + 2, Sin[2 x] + 2}, {x, 0, 8}, AxesLabel -> {x, y},
Ticks -> {{{1, "x[0]"}, {2, "x[1]"}, {3, ""}, {4, "x[3]"}, {5,
""}, {6, ""}, {7, "x[n]"}}, None},
PlotLabels -> Placed[{"y=f(x)", "y=p(x)"}, {Scaled[5], Above}],
AxesStyle -> Arrowheads[{0.0, 0.05}]]
Or
Plot[{Sin[x] + 2, Sin[2 x] + 2}, {x, 0, 8}, AxesLabel -> {x, y},
Ticks -> {{{1, "x[0]"}, {2, "x[1]"}, {3, ""}, {4, "x[2]"}, {5,
""}, {6, ""}, {7, "x[n]"}}, None},
AxesStyle -> Arrowheads[{0.0, 0.05}],
Epilog -> {Text[Style["y=f(x)", 22], Scaled[{0.5, 0.9}]],
Text[Style["y=p(x)", 22], Scaled[{0.25, 0.97}]]}]
$endgroup$
$begingroup$
I put the functions Sin [x] +2, Sin [2x] +2 because I did not find others, but I would like others different from mine.
$endgroup$
– Jacob Schwartz
Feb 5 at 7:56
add a comment |
$begingroup$
Something like this?
Plot[{Sin[x] + 2, Sin[2 x] + 2}, {x, 0, 8}, AxesLabel -> {x, y},
Ticks -> {{{1, "x[0]"}, {2, "x[1]"}, {3, ""}, {4, "x[3]"}, {5,
""}, {6, ""}, {7, "x[n]"}}, None},
PlotLabels -> Placed[{"y=f(x)", "y=p(x)"}, {Scaled[5], Above}],
AxesStyle -> Arrowheads[{0.0, 0.05}]]
Or
Plot[{Sin[x] + 2, Sin[2 x] + 2}, {x, 0, 8}, AxesLabel -> {x, y},
Ticks -> {{{1, "x[0]"}, {2, "x[1]"}, {3, ""}, {4, "x[2]"}, {5,
""}, {6, ""}, {7, "x[n]"}}, None},
AxesStyle -> Arrowheads[{0.0, 0.05}],
Epilog -> {Text[Style["y=f(x)", 22], Scaled[{0.5, 0.9}]],
Text[Style["y=p(x)", 22], Scaled[{0.25, 0.97}]]}]
$endgroup$
Something like this?
Plot[{Sin[x] + 2, Sin[2 x] + 2}, {x, 0, 8}, AxesLabel -> {x, y},
Ticks -> {{{1, "x[0]"}, {2, "x[1]"}, {3, ""}, {4, "x[3]"}, {5,
""}, {6, ""}, {7, "x[n]"}}, None},
PlotLabels -> Placed[{"y=f(x)", "y=p(x)"}, {Scaled[5], Above}],
AxesStyle -> Arrowheads[{0.0, 0.05}]]
Or
Plot[{Sin[x] + 2, Sin[2 x] + 2}, {x, 0, 8}, AxesLabel -> {x, y},
Ticks -> {{{1, "x[0]"}, {2, "x[1]"}, {3, ""}, {4, "x[2]"}, {5,
""}, {6, ""}, {7, "x[n]"}}, None},
AxesStyle -> Arrowheads[{0.0, 0.05}],
Epilog -> {Text[Style["y=f(x)", 22], Scaled[{0.5, 0.9}]],
Text[Style["y=p(x)", 22], Scaled[{0.25, 0.97}]]}]
edited Feb 5 at 7:41
answered Feb 5 at 7:24
zhkzhk
9,14911433
9,14911433
$begingroup$
I put the functions Sin [x] +2, Sin [2x] +2 because I did not find others, but I would like others different from mine.
$endgroup$
– Jacob Schwartz
Feb 5 at 7:56
add a comment |
$begingroup$
I put the functions Sin [x] +2, Sin [2x] +2 because I did not find others, but I would like others different from mine.
$endgroup$
– Jacob Schwartz
Feb 5 at 7:56
$begingroup$
I put the functions Sin [x] +2, Sin [2x] +2 because I did not find others, but I would like others different from mine.
$endgroup$
– Jacob Schwartz
Feb 5 at 7:56
$begingroup$
I put the functions Sin [x] +2, Sin [2x] +2 because I did not find others, but I would like others different from mine.
$endgroup$
– Jacob Schwartz
Feb 5 at 7:56
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f190905%2fhow-can-i-make-a-general-plot-like-this-in-mathematica%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown