如何获得良好的平滑插值?从 mathematica 导入

如何获得良好的平滑插值?从 mathematica 导入

我想要一个平滑的插值,到目前为止我使用

\documentclass[letter,11pt,twoside]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{stmaryrd}
\usepackage{array,booktabs}
\usepackage{placeins}
\pgfplotsset{
    compat=newest,
    xlabel near ticks,
    ylabel near ticks,
    myplot/.style={smooth,tension=0.5,mark=none,very thick}
}    
\begin{document}
\begin{figure}
{%
\begin{tikzpicture}[
labelnode/.style={font=\footnotesize, above},%
  labelline/.style={stealth-stealth,shorten >=0.1pt, shorten <=0.5pt}%
  ]%
\begin{axis}[%
 width=0.95\textwidth,height=0.4\textheight,%
 axis x line=center,%
 xmin=0,%
 xmax=1,%
 xtick={0.115},%
 xticklabels={{H}},%
 axis y line=left,%
 ymin=-115,%
 ymax=115,%
 ytick={0},%
 yticklabels={{0}},
 ylabel={$w$},%
 xlabel={$\beta$},%
 label style={at={(axis description cs:1,-0.02)},anchor=north},
    y label style={at={(axis description cs:-0.02,0.95)},rotate=-90,anchor=south},
 %grid=major,
]% 
   \addplot+[color=black,myplot, thick]
 coordinates {%
(0, 80)%
 (0.1,     70)%
 (0.2,     50)%
 (0.3,     0)%
 (0.5,      -60)%
 (0.6,      -10)%
  (0.65,      -2)%
  (0.7,      0)%
}%
 ;%
\end{axis}%
%
\end{tikzpicture}%
}
\end{figure}
\end{document}

重要的是,该函数似乎趋近于 0 至 0.7。

当我使用 mathematica 和 Splines 方法执行此操作时,它看起来非常漂亮,但在 latex 中却不是这样 :-(

Mathematica 代码:

 F[x_] = Interpolation[{{0, 80}, {0.1, 72}, {0.2, 50}, {0.3, 
    0}, {0.5, -60}, {0.6, -10}, {0.65, -2}, {0.7, 0}}, x, 
  Method -> "Spline"]

是否有一种使用乳胶进行插值的好方法,或者我可以以某种方式将数学函数“绘制”到乳胶中吗?

我想将插值函数(通过 mathematica 或 latex)包含到 latex 文档中。

答案1

我并不是说这是最好的方法,但至少是其中一种方法。我从你的 Mathematica 命令开始

 F[x_] = Interpolation[{{0, 80}, {0.1, 72}, {0.2, 50}, {0.3, 
    0}, {0.5, -60}, {0.6, -10}, {0.65, -2}, {0.7, 0}}, x, 
  Method -> "Spline"]

并使用

 Chop[Map[{#, F[#]} &, Table[x, {x, 0, 0.7, 0.01}]]] // InputForm

将其转换为列表。在此列表中,我替换了{(},获得)可以使用 绘制的列表pgfplots。结果如下:

\documentclass[letter,11pt,twoside]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepackage{pgfplotstable}
\usepackage{stmaryrd}
\usepackage{array,booktabs}
\usepackage{placeins}
\pgfplotsset{
    compat=newest,
    xlabel near ticks,
    ylabel near ticks,
    myplot/.style={smooth,tension=0.5,mark=none,very thick}
}    
\begin{document}
\begin{figure}
{%
\begin{tikzpicture}[
labelnode/.style={font=\footnotesize, above},%
  labelline/.style={stealth-stealth,shorten >=0.1pt, shorten <=0.5pt}%
  ]%
\begin{axis}[%
 width=0.95\textwidth,height=0.4\textheight,%
 axis x line=center,%
 xmin=0,%
 xmax=1,%
 xtick={0.115},%
 xticklabels={{H}},%
 axis y line=left,%
 ymin=-115,%
 ymax=115,%
 ytick={0},%
 yticklabels={{0}},
 ylabel={$w$},%
 xlabel={$\beta$},%
 label style={at={(axis description cs:1,-0.02)},anchor=north},
    y label style={at={(axis description cs:-0.02,0.95)},rotate=-90,anchor=south},
 %grid=major,
]% 
   \addplot+[color=black,myplot, thick]
 coordinates {%
(0,80.)  (0.01,79.21772794339859)  (0.02,78.4888049573029) 
(0.03,77.79174781165672)  (0.04,77.10507327640387)  (0.05,76.40729812148817) 
(0.06,75.67693911685338)  (0.07,74.89251303244338)  (0.08,74.03253663820195) 
(0.09,73.07552670407289) (0.1,72.)  (0.11,70.78447329592713) 
(0.12,69.40746336179808)  (0.13,67.84748696755663)  (0.14,66.08306088314662) 
(0.15,64.09270187851185)  (0.16,61.85492672359615)  (0.17,59.348252188343274) 
(0.18,56.5511950426971)  (0.19,53.442272056601404)  (0.2,49.99999999999999)
(0.21,46.2103788728929)  (0.22,42.089341595504834)  (0.23,37.660304318116786) 
(0.24,32.946683191009676)  (0.25,27.97189436446446)  (0.26,22.759353988762083) 
(0.27,17.332478214183503)  (0.28,11.714683191009652)  (0.29,5.929385069521529)
(0.3,0)  (0.31,-6.0500558672739455)  (0.32,-12.197366382019357) 
(0.33,-18.418515393955303)  (0.34,-24.686604166150378) (0.35000000000000003,
-30.934248891861984) (0.36,-37.06794636446921)  (0.37,-42.99375805402) 
(0.38,-48.617745430562145)  (0.39,-53.84596996414349)  (0.4,-58.584493124811885)
(0.41000000000000003, -62.73937638261518) (0.42,-66.2166812076012) 
(0.43,-68.9224690698178)  (0.44,-70.76280143931285)  (0.45,-71.64373978613416) 
(0.46,-71.47134558032961) (0.47000000000000003, -70.15331061931522)
(0.48,-67.69514634259843)  (0.49,-64.25398463492846) (0.5,-60.) 
(0.51,-55.10336694150778)  (0.52,-49.7342599631465)  (0.53,-44.06285356861086) 
(0.54,-38.259322261595585)  (0.55,-32.49384054579538)  (0.56,-26.93658292490495)
(0.5700000000000001, -21.757723902619016) (0.58,-17.127437982632326) 
(0.59,-13.203529526922042) (0.6,-10.)  (0.61,-7.43807480349707) 
(0.62,-5.437433071329426)  (0.63,-3.917753937413247) 
(0.64,-2.7987165356647132)  (0.65,-1.9999999999999998) 
(0.66,-1.441283464335287)  (0.67,-1.0422460625867518) 
(0.68,-0.7225669286705727) (0.6900000000000001, -0.40192519650292763)
(0.7000000000000001,0)%
}%
 ;%
\end{axis}%
%
\end{tikzpicture}%
}
\end{figure}
\end{document}

在此处输入图片描述

相关内容