Composing functions

This example draws the composition of two functions in a semi-automatic way, using 3d and intersections.

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{intersections}
\usepackage{tikz-3dplot}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This tikz-code allow to "draw" the composition of two functions.
%%
%% The principle is the following: one have to draw y=A(x) and z=S(y),
%% then, for each X, uses projections and intersections to define the
%% point (X,0,S(A(X)).
%%% This is the core command:
%%% It assumes
%%% - the function A is drawn on name path=A
%%% - the same for S
%%% - it exist paths Xaxis, Yaxis, Zaxis
% Parameters:
% #1: X
% #2: name of the point to store (X,0,S(A(X))
\newcommand{\drawDfromX}[2]{
% Set the source
\coordinate (X) at (#1,0,0);
% Goes from (x,0) to (x, A(x))
\path[name path=XtoA] (X) -- ++(0,10,0);
\draw[proj,name intersections={of=A and XtoA}] (X) --
(intersection-1) coordinate (AX);
% Goes to A(X) on Y axis
\path[name path=AtoY] (AX) -- ++(-10,0,0);
\draw[proj, name intersections={of=AtoY and Yaxis}] (AX) --
(intersection-1) coordinate (YfromX);
\path[name path=YtoS] (YfromX) -- ++(0,0,10);
% Goes from (0,y,0) to (0, y, S(y))
\draw[proj, name intersections={of=S and YtoS}] (YfromX) --
(intersection-1) coordinate (SY);
\path[name path=SYtoZ] (SY) -- ++(0,-10,0);
\draw[proj, name intersections={of=SYtoZ and Zaxis}] (SY) --
(intersection-1) coordinate (Z);
% Draw z=S(A(x))=D(x)
\path[name path=XtoD] (X) -- ++(0,0,10);
\path[name path=ZtoD] (Z) -- ++(10,0,0);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Leave a Reply

Your email address will not be published.