(no subject)
- Posted by "Charles D. Brock" <davep at NAUTICOM.NET> Aug 13, 1996
- 917 views
-- This include file extends the math functions available with the following : -- PI this is the constant 3.1415926 -- e this is also a math constant -- deg convert radian math mode to degrees mode -- rad_deg convert radians to degrees -- abs produces the absolute values of a number -- mod the modulus function -- exp produces the expodential of a number -- sinh hyperbolic sin -- cosh hyperbolic cos -- tanh hyperbolic tan -- also included are a collection of -- formulas for perimeter, area, volume, and surface areas -- the file 'examp.ex ' is a test program which uses this include file -- ----------------------------------------------------------------------------- global constant pi = 3.141592654 global constant e = 2.718281828 global function deg(atom x) --syntax sin(deg(x)) x = x*.0174533 return x end function global function rad_deg(atom x) x = x * 57.29578 return x end function global function abs(atom x) if x<1 then x = floor(-x) else x = floor(x) end if return x end function global function mod(atom x,atom y) x = abs(x -y * abs(x/y)) return x end function global function exp(atom x) x = power (e,x) return x end function global function sinh(atom x) x = .5 * (exp(x)-exp(-x)) return x end function global function cosh(atom x) x = .5 * (exp(x)+exp(-x)) return x end function global function tanh(atom x) x = 1-2*exp(-x)/(exp(x)+exp(-x)) return x end function -- formulas for perimeter, area, and volumes global function area_triangle(atom base,atom height) atom area area = .5 * base * height return area end function global function area_rectange(atom len,atom height) atom area area = len * height return area end function global function area_parallel(atom base, atom height) atom area area = base * height return area end function global function area_square( atom side) atom area area = side * side return area end function global function area_trap(atom height, atom base1,atom base2) atom area area = .5*height*(base1 + base2) return area end function global function area_circle(atom radius) atom area area = pi * radius * radius return area end function global function surface_area_sphere(atom radius) atom surface_area surface_area = 4 * pi * radius * radius return surface_area end function global function volume_sphere(atom radius) atom volume volume = (4 / 3) * pi * (power (radius,3)) return volume end function global function surface_area_right_circular_cone(atom radius,atom height) atom surface_area surface_area = pi * (radius * radius) + (pi * radius * power (((radius * radius) + (height * height)),.5)) return surface_area end function global function volume_right_circular_cone(atom radius,atom height) atom volume volume = (1/3) * pi * radius * radius * height return volume end function global function volume_right_circular_cylinder(atom radius, atom height) atom volume volume = pi * (radius * radius) * height return volume end function global function surface_area_right_circular_cylinder(atom radius, atom height) atom surface_area surface_area = 2 * pi * (radius * radius) + (2 * pi * radius * height) return surface_area end function global function surface_area_cube(atom side) atom surface_area surface_area = 6 * (side * side) return surface_area end function global function volume_cube(atom side) atom volume volume = power(side,3) return volume end function global function surface_area_rect_solid(atom len, atom weight, atom height) atom surface_area surface_area = 2 * weight * height + 2 * height * len + 2 * weight * len return surface_area end function global function volume_rect_solid(atom len, atom weight, atom height) atom volume volume = len * weight * height return volume end function