Plot graph near zero
I want to plot the following function with TikZ.
begin{tikzpicture}[scale=0.7,
declare function={
func(z) = 1/(2*(abs(z)^3)) * (
(1+abs(z)) - 2*ln(1+abs(z)) - 1/(1+abs(z))
);
}
]
The problem occurs near zero, the function isn't plotted the right way.
tikz-pgf pgfplots plot
New contributor
add a comment |
I want to plot the following function with TikZ.
begin{tikzpicture}[scale=0.7,
declare function={
func(z) = 1/(2*(abs(z)^3)) * (
(1+abs(z)) - 2*ln(1+abs(z)) - 1/(1+abs(z))
);
}
]
The problem occurs near zero, the function isn't plotted the right way.
tikz-pgf pgfplots plot
New contributor
I edited your question a bit so that it is easier for readers to understand your question.
– JouleV
10 hours ago
add a comment |
I want to plot the following function with TikZ.
begin{tikzpicture}[scale=0.7,
declare function={
func(z) = 1/(2*(abs(z)^3)) * (
(1+abs(z)) - 2*ln(1+abs(z)) - 1/(1+abs(z))
);
}
]
The problem occurs near zero, the function isn't plotted the right way.
tikz-pgf pgfplots plot
New contributor
I want to plot the following function with TikZ.
begin{tikzpicture}[scale=0.7,
declare function={
func(z) = 1/(2*(abs(z)^3)) * (
(1+abs(z)) - 2*ln(1+abs(z)) - 1/(1+abs(z))
);
}
]
The problem occurs near zero, the function isn't plotted the right way.
tikz-pgf pgfplots plot
tikz-pgf pgfplots plot
New contributor
New contributor
edited 10 hours ago
JouleV
10.3k22558
10.3k22558
New contributor
asked 11 hours ago
joejoe
161
161
New contributor
New contributor
I edited your question a bit so that it is easier for readers to understand your question.
– JouleV
10 hours ago
add a comment |
I edited your question a bit so that it is easier for readers to understand your question.
– JouleV
10 hours ago
I edited your question a bit so that it is easier for readers to understand your question.
– JouleV
10 hours ago
I edited your question a bit so that it is easier for readers to understand your question.
– JouleV
10 hours ago
add a comment |
1 Answer
1
active
oldest
votes
One way that produces some plot that is reasonably close to the "true" result is to insert the Taylor expansion of the function for smallish x
. Otherwise TikZ will evaluate first the 1/x^3
piece and complain. The Taylor expansion, on the other hand shows that there is no singularity. A true computer algebra system would do the limits on its own, but TeX is not such a computer algebra system.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}[scale=0.7,
declare function={
func(z)=ifthenelse(abs(z)>0.251, 1/(2*(abs(z)^3)) * (
(1+abs(z)) - 2*ln(1+abs(z)) - 1/(1+abs(z))),
1/6 - abs(z)/4 + (3*abs(z)^2)/10 - abs(z)^3/3 + (5*abs(z)^4)/14);
}
]
begin{axis}
addplot[domain=-1:1,samples=31,smooth] {func(x)};
end{axis}
end{tikzpicture}
end{document}
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
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
});
}
});
joe is a new contributor. Be nice, and check out our Code of Conduct.
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%2ftex.stackexchange.com%2fquestions%2f483003%2fplot-graph-near-zero%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
One way that produces some plot that is reasonably close to the "true" result is to insert the Taylor expansion of the function for smallish x
. Otherwise TikZ will evaluate first the 1/x^3
piece and complain. The Taylor expansion, on the other hand shows that there is no singularity. A true computer algebra system would do the limits on its own, but TeX is not such a computer algebra system.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}[scale=0.7,
declare function={
func(z)=ifthenelse(abs(z)>0.251, 1/(2*(abs(z)^3)) * (
(1+abs(z)) - 2*ln(1+abs(z)) - 1/(1+abs(z))),
1/6 - abs(z)/4 + (3*abs(z)^2)/10 - abs(z)^3/3 + (5*abs(z)^4)/14);
}
]
begin{axis}
addplot[domain=-1:1,samples=31,smooth] {func(x)};
end{axis}
end{tikzpicture}
end{document}
add a comment |
One way that produces some plot that is reasonably close to the "true" result is to insert the Taylor expansion of the function for smallish x
. Otherwise TikZ will evaluate first the 1/x^3
piece and complain. The Taylor expansion, on the other hand shows that there is no singularity. A true computer algebra system would do the limits on its own, but TeX is not such a computer algebra system.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}[scale=0.7,
declare function={
func(z)=ifthenelse(abs(z)>0.251, 1/(2*(abs(z)^3)) * (
(1+abs(z)) - 2*ln(1+abs(z)) - 1/(1+abs(z))),
1/6 - abs(z)/4 + (3*abs(z)^2)/10 - abs(z)^3/3 + (5*abs(z)^4)/14);
}
]
begin{axis}
addplot[domain=-1:1,samples=31,smooth] {func(x)};
end{axis}
end{tikzpicture}
end{document}
add a comment |
One way that produces some plot that is reasonably close to the "true" result is to insert the Taylor expansion of the function for smallish x
. Otherwise TikZ will evaluate first the 1/x^3
piece and complain. The Taylor expansion, on the other hand shows that there is no singularity. A true computer algebra system would do the limits on its own, but TeX is not such a computer algebra system.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}[scale=0.7,
declare function={
func(z)=ifthenelse(abs(z)>0.251, 1/(2*(abs(z)^3)) * (
(1+abs(z)) - 2*ln(1+abs(z)) - 1/(1+abs(z))),
1/6 - abs(z)/4 + (3*abs(z)^2)/10 - abs(z)^3/3 + (5*abs(z)^4)/14);
}
]
begin{axis}
addplot[domain=-1:1,samples=31,smooth] {func(x)};
end{axis}
end{tikzpicture}
end{document}
One way that produces some plot that is reasonably close to the "true" result is to insert the Taylor expansion of the function for smallish x
. Otherwise TikZ will evaluate first the 1/x^3
piece and complain. The Taylor expansion, on the other hand shows that there is no singularity. A true computer algebra system would do the limits on its own, but TeX is not such a computer algebra system.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}[scale=0.7,
declare function={
func(z)=ifthenelse(abs(z)>0.251, 1/(2*(abs(z)^3)) * (
(1+abs(z)) - 2*ln(1+abs(z)) - 1/(1+abs(z))),
1/6 - abs(z)/4 + (3*abs(z)^2)/10 - abs(z)^3/3 + (5*abs(z)^4)/14);
}
]
begin{axis}
addplot[domain=-1:1,samples=31,smooth] {func(x)};
end{axis}
end{tikzpicture}
end{document}
edited 7 hours ago
answered 10 hours ago
marmotmarmot
114k5145276
114k5145276
add a comment |
add a comment |
joe is a new contributor. Be nice, and check out our Code of Conduct.
joe is a new contributor. Be nice, and check out our Code of Conduct.
joe is a new contributor. Be nice, and check out our Code of Conduct.
joe is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to TeX - LaTeX 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.
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%2ftex.stackexchange.com%2fquestions%2f483003%2fplot-graph-near-zero%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
I edited your question a bit so that it is easier for readers to understand your question.
– JouleV
10 hours ago