你可以试试「只有法语文档」的luadraw
宏包:
想要优雅地绘制隐函数倾斜椭圆
% https://ask.latexstudio.net/ask/question/7513.html
\documentclass{standalone}
\usepackage{luadraw}
\begin{document}
\begin{luadraw}{name=implicit_function}
local g = graph:new{window={-3,3,-3,3},size={10,10}}
g:Linecap("round")
local F = function(x,y) return x^2+y^2+x*y-1 end
g:Dimplicit(F,{draw_options="thick"})
g:Dgradbox(
{Z(-2,-2),Z(2,2),1,1},{grid=true,title="\\textbf{Implicit Function Plot}"}
)
g:Show()
\end{luadraw}
\end{document}
想要随心所欲地绘制切线,参考nidarfp的回答
\documentclass{standalone}
\usepackage{luadraw}
\begin{document}
\begin{luadraw}{name=implicit_function_tangentline}
local g = graph:new{window={-3,3,-3,3},size={10,10}}
g:Linecap("round")
% https://github.com/pfradin/luadraw/blob/a2759c0aeaf73e023362fac960ffdf704470925a/files/luadraw_lines.lua#L406-L421
local DtangentI = function(f,x0,y0,len,draw_options) -- f:(x,y()) -> f(x,y)
-- We assume that f(x0,y0)=0!
local h = 1e-6
local A = Z(x0,y0) -- 定义复数点(x0,y0)
local a,b = (f(x0+h,y0)-f(x0-h,y0))/(2*h), (f(x0,y0+h)-f(x0,y0-h))/(2*h)
-- 定义 a,b 为f(x0)处的两个偏导数
local v = Z(-b,a)
if len == nil then -- 如果传入的参数为空,则绘制整条直线
g:Dline({A,v},draw_options)
else
local u = len*v/cpx.abs(v)/2 -- 否则往两侧绘制长度为 len/2 的线段
g:Dseg({A-u,A+u},draw_options) -- 绘制线段
end
end
local F = function(x,y) return x^2+y^2+x*y-1 end
g:Dimplicit(F,{draw_options="thick"})
g:Dgradbox(
{Z(-2,-2),Z(2,2),1,1},{grid=true,title="\\textbf{Implicit Function Plot}"}
)
local x0 = 1/2
local L = solve(function(t) return F(x0,t) end,-2,2) -- 求解两个根获得直线的y_i坐标
for _, y in ipairs(L) do -- 循环绘制多条切线
DtangentI(F,x0,y,2,"thick,red") -- This work!
end
g:Show()
\end{luadraw}
\end{document}
问 关于隐函数作图的问题