{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Complex Function" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%plot gnuplot" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "clear all\n", "Lx = 4.0; Ly = 4.0;\n", "dx = 0.1;\n", "x = -Lx:dx:Lx;\n", "y = -Ly:dx:Ly;\n", "\n", "[xx,yy] = meshgrid(x,y);\n", "zz = xx + 1i*yy; %%%Up to this point the complex mesh is created\n", "phi=log(zz);\n", "\n", "figure(1001)\n", "surf(xx,yy,real(phi))\n", "axis([-Lx Lx -Ly Ly])\n", "xlabel('Re(z)-axis')\n", "ylabel('Im(z)-axis')\n", "title('Surface plot of Re(log(z))','fontsize',16)\n", "print -dpng a.png\n", "\n", "figure(1002)\n", "zz = xx + 1i*yy; %%%Up to this point the complex mesh is created\n", "surf(xx,yy,imag(phi))\n", "axis([-Lx Lx -Ly Ly])\n", "xlabel('Re(z)-axis')\n", "ylabel('Im(z)-axis')\n", "title('Surface plot of Im(log(z))','fontsize',16)\n", "print -dpng b.png\n", "\n", "contn = 10; %How may contours you want to plot?\n", "% imag part \n", "figure(12); clf;\n", "contourf(x,y,imag(phi),contn); hold on\n", "contour(x,y,real(phi),contn,'w'); \n", "hold off\n", "colorbar\n", "axis equal\n", "axis([-Lx Lx -Ly Ly])\n", "xlabel('Re(z)-axis')\n", "ylabel('Im(z)-axis')\n", "title('contours of Im(log(z))','fontsize',16)\n", "print -dpng c.png\n", "\n", "% real part\n", "figure(22); clf;\n", "contourf(x,y,real(phi),contn); hold on\n", "contour(x,y,imag(phi),contn,'w'); \n", "colorbar\n", "axis equal\n", "axis([-Lx Lx -Ly Ly])\n", "xlabel('Re(z)-axis')\n", "ylabel('Im(z)-axis')\n", "title('contours of Re(log(z))','fontsize',12)\n", "print -dpng d.png" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", " \"contours\n", "\n", " \"contours\n", "
\n", " \"contours\n", "\n", " \"contours\n", "
\n" ] } ], "metadata": { "kernelspec": { "display_name": "Octave", "language": "octave", "name": "octave" }, "language_info": { "file_extension": ".m", "help_links": [ { "text": "MetaKernel Magics", "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" } ], "mimetype": "text/x-octave", "name": "octave", "version": "0.16.1" } }, "nbformat": 4, "nbformat_minor": 1 }