Octave

Plotting equations

Plot tanh and sigmoid in the same graph

The two curves represent hyperbolic tangent function y1 and the sigmoid function y2

>> x = [-10:0.1:10];
>> y1 = 1 ./ (1 + exp(-1.5 .* x));
>> y2 = (exp(x) - exp(-x)) ./ (exp(x) + exp(-x));

Then plot using:

>> plot(x,y1,'-',x,y2,'ro');

Plot sigmoid using a function

There is how to plot a sigmoid f(x) = 1 ⁄ (1 + exp( − 1.5*x)) in the range [ − 10;10] using octave:

>> function [y] = f(x)
>>   y = 1 ./ (1 + exp(-1.5 .* x))
>> endfunction
>> X = [-10:0.1:10]
>> plot(X, f(X))