OptimizationContinuousfunction PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Evolutionary Computing

Unit I. Optimization problems


Prof. Miriam Pescador Rojas

Name: Reyes Romero Carlos Adrian Group: 3CM2

Exercise 1. Complete the table with python code and graphic gnuplot for functions below. Consider the examples.

Function 1
( ) ( ),

Instructions graphics
Python code
import math
def f1(x):
f = 0.65 – 0.75/(1+x**2) – (0.65*x*math.atan(1/x))
return f

Gnuplot commands
set terminal png size 400,400 enhanced font "Helvetica,20"
set output 'f1.png'
f1(x) = 0.65 – 0.75/(1+x**2) – (0.65*x*atan(1/x))
set xrange [-5:5]
plot f1(x)
Function 2
( ) ( ) ( ) ,

Instructions Graphics
Python code
import math
def f2(x):
f = (1-x)**4-(2*x+10)**2
return f

Gnuplot commands
set terminal png size 400,400 enhanced font "Helvetica,20"
set output 'f2.png'
f2(x) = (1-x)**4 - (2*x+10)**2
set xrange [-10:10]
plot f2(x)
Function 3
( ) , -10 < x < 10

Instructions Graphics
Python code
import math
def function3(x):
f=3*(x**2)+(12/(x**3))-5
return f

Gnuplot commands
set term png
f3(x)=3*(x**2)+(12/(x**3))-5
set xrange[-10:10]
set output 'f3.png'
plot f3(x)

Function 4
( ) ( ), -5 < x < 5
Instructions Graphics
Python code
import math

def function4(x):
f=x*(x-1.5)
return f

Gnuplot commands
set term png

f4(x)=x*(x-1.5)
set xrange[-5:5]
set output 'f4.png'
plot f4(x)

Function 5
( ) ( ) , -1 < x < 1
Instructions Graphics
Python code
import math

def function5(x):
f=3*(x**4)+(x-1)**2
return f

Gnuplot commands
f5(x)=3*(x**4)+(x-1)**2
set xrange[-1:1]
set output 'f5.png'
plot f5(x)

Function 6
( ) ( ), -6 < x < 6
Instructions Graphics
Python code
import math

def function6(x):
f=10+(x**3)-(2*x)-5*(math.exp(x))
return f

Gnuplot commands
f6(x)=10+(x**3)-(2*x)-5*(exp(x))
set xrange[-6:6]
set output 'f6.png'
plot f6(x)

Function 7
( ) ( ) , -10 < x < 5
Instructions Graphics
Python code
import math

def function7(x):
f=(x**2)-10*(math.exp(0.1*x))
return f

Gnuplot commands
f7(x)=(x**2)-10*(exp(0.1*x))
set xrange[-10:5]
set output 'f7.png'
plot f7(x)

Function 8
( ) ( ) , -2 < x < 2
Instructions Graphics
Python code
import math

def function8(x):
f=(10*(x**3)+3*(x**2)+5)**2
return f

Gnuplot commands
f8(x)=(10*(x**3)+3*(x**2)+5)**2
set xrange[-2:2]
set output 'f8.png'
plot f8(x)

Function 9
( ) √ [ ]

Instructions Graphics
Python code
import math

def function9(x):
f=(0.5/math.sqrt(1+x**2))-math.sqrt(1-x**2)*(1-(0.5/1+(x**2)))+x
return f

Gnuplot commands
f9(x)=(0.5/sqrt(1+x**2))-sqrt(1-x**2)*(1-(0.5/1+(x**2)))+x
set xrange[-1:1]
set output 'f9.png'
plot f9(x)
Function 10
( )

Instructions Graphics
Python code
import math

def function10(x):
f=(math.e)**x-(x**3)
return f

Gnuplot commands
f10(x)=2.71**x- x**3
set xrange[-3:5]
set output 'f10.png'
plot f10(x)

You might also like