The line has a general equation #y=ax+b#, so it depends on two parameters - slope #a# and Y-intersect #b#.
The slope of a tangent is the same as the slope of a curve, so we can find it by finding a derivative of a function #y=cos(x)# ar point #x=pi/4#.
The derivative of function #cos(x)# is function #-sin(x)#, at #x=pi/4# the value of the derivative is #-sin(pi/4)=-sqrt(2)/2#. That is the value of a parameter #a# in our general equation of a line #y=ax+b#.
To find a second parameter #b#, let's use the fact that at point #x=pi/4# the line touches the curve and, therefore, has the same value. Since #y=cos(x)# at #x=pi/4# has a value #cos(pi/4)=sqrt(2)/2#, the tangential line also has this value:
#a*pi/4+b=sqrt(2)/2#
Since we have already determined that #a=-sqrt(2)/2#, we have an equation for #b#:
#-sqrt(2)/2*pi/4+b=sqrt(2)/2#,
from which
#b=(1+pi/4)*sqrt(2)/2#
The expression for a tangent is, therefore,
#y=-sqrt(2)/2 x + (1+pi/4) sqrt(2)/2#