0% found this document useful (0 votes)
24 views

Functions in Web Programming Differential Calculus

Functions in programming and mathematical functions share similarities. Both take inputs, perform operations, and return outputs. However, programming functions are attached to classes while mathematical functions operate directly on values. Programming functions can also vary in output depending on implementation, while mathematical functions always produce the same result. Overall, functions in both domains allow for modular and reusable code, though programming functions offer more flexibility through object-oriented design.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Functions in Web Programming Differential Calculus

Functions in programming and mathematical functions share similarities. Both take inputs, perform operations, and return outputs. However, programming functions are attached to classes while mathematical functions operate directly on values. Programming functions can also vary in output depending on implementation, while mathematical functions always produce the same result. Overall, functions in both domains allow for modular and reusable code, though programming functions offer more flexibility through object-oriented design.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

FUNCTIONS IN WEB PROGRAMMING

DIFFERENTIAL CALCULUS

Group 1

1
PROFESSOR
Table of contents

Introduction………………………………………………………………………………………………………………………..……………….….3
Body………………………………………..………………………………………………………………………………………………………..…….5
Conclusion……………..……………………………………………………………………………………………………………..……………..…

2
FUNCTIONS IN WEB PROGRAMMING

Functions (also called ‘‘procedures’’ in some programming languages and ‘’methods’’ in most


object-oriented programming languages) are a set of instructions bundled together to achieve a specific
outcome. Functions are a good alternative to having repeating blocks of code in a program. Functions
also increase the reusability of code. Values can be passed to a function using variables – we call
these parameters or arguments. Functions can also return values.

Web Programming (also known as web development) is the creation of dynamic web
applications. Examples of web applications are social networking sites like Facebook or e-commerce
sites like Amazon. Web programming refers to the writing, markup and coding involved in Web
development, which includes Web content, Web client and server scripting and network security. The
most common languages used for Web programming are XML, HTML, JavaScript, Perl 5 and PHP. Web
programming is different from just programming, which requires interdisciplinary knowledge on the
application area, client and server scripting, and database technology.

In programming, a named section of a program that performs a specific task. In this sense, a
function is a type of procedure or routine. Some programming languages make a distinction between
a function, which returns a value, and a procedure, which performs some operation but does not return
a value. Most programming languages come with a prewritten set of functions that are kept in a library.
You can also write your own functions to perform specialized tasks.

Example of function in PHP programming language.


1 function do double($input) {

2     $output = $input * 2; //double the input value


3     echo $output; //print display $output result
4}
echo do_doubl
5
e(2);

PHP uses the function keyword to tell the language a function is about to be defined. Functions in PHP
are names with underscores (_) instead of empty spaces followed by parentheses () to hold any input
values. The contents of a function in PHP are marked off by curly braces {}. The start of the function
begins with the left curly brace {and ends with the right curly brace {. Every left brace must be matched
with a right brace or PHP will throw an error. ‘’echo’’ is a PHP command that immediately prints
whatever value(s) appear to its right, in this case the $output variable. ‘’echo do double (2)’’ calls and
print outputs the do double () function passing the function the input of 2. The result should be 2 * 2 or
4.

Function in Java language

int find Maximum(int num1, int num2) {


if (num1 > num2)
return num1;
else

3
return num2;
}

The function name is found Maximum. As can be interpreted from the name, the function is written to
find the maximum of two given numbers. num1 and num2 are two integers passed into the function –
these are the parameters. Notice that the function parameters are placed within parenthesis just after
the function name. The int appearing before the function name denotes that the return type of this
function is an integer. There is also a return statement in the function. This statement returns a value
from the function. This value should be of the type defined as the return type of the function.

A function is a block of organized, reusable code that is used to perform a single, related action.
Functions provide better modularity for your application and a high degree of code reusing. You have
already seen various functions like prints () and main (). These are called built-in functions provided by
the language itself, but we can write our own functions as well and this tutorial will teach you how to
write and use those functions in C programming language.
Good thing about functions is that they are famous with several names. Different programming
languages name them differently, for example, functions, methods, sub-routines, procedures, etc. If
you come across any such terminology, then just imagine about the same concept, which we are going
to discuss in this tutorial.
Let's start with a program where we will define two arrays of numbers and then from each array, we
will find the biggest number. Given below are the steps to find out the maximum number from a given
set of numbers.

1. Get a list of numbers L1, L2, L3....LN


2. Assume L1 is the largest, Set max = L1
3. Take next number Li from the list and do the following
4. If max is less than Li
5. Set max = Li
6. If Li is last number from the list then
7. Print value stored in max and come out
8. Else prepeat same process starting from step 3

METHO PURPOSE INPUT OUTPUT


D

The standard library Public class main {


Java methods are built-in Public static void main (string [] args) {
standar methods in Java that are
d readily available for use. // using the sqrt () method Square root of 4 is

4
library These standard libraries System.out.print(“square root of 4 is “+ 2.0
metho come along with the Java Math.sqrt(4));
d Class library that is present }
in Java archive (*. Jar) file }
with JVM and JRE. Hun
11,2021
1. <script>  
It returns the sine of the 2. document.writeln(Math.sin(1)+"<br>");  
sin() given number. 3. document.writeln(Math.sin(2));   0.8414709848078
Syntax - Math.sin(num) </script>   965

0.9092974268256
817

1. <script>  
It returns the tangent of the
2. document.writeln(Math.tan(1)+"<br>");  
given number. 3. document.writeln(Math.tan(2));   1.5574077246549
tan() Syntax - Math.tan(num)   </script>   023

-
2.1850398632615
19
It returns the cosine of the
1. <script>  
given number. 2. document.writeln(Math.cos(-1)+"<br>");  
Syntax - Math.cos(num)   3. document.writeln(Math.cos(-0.5));   0.5403023058681
cos() 4. </script> 398

0.8775825618903
728

It returns maximum value of1. <script>  


the given numbers. 2. document.writeln(Math.max(22,34,12,15)+"<
Syntax - br>");    34
max() Math.max(num1,num2,....,n3. document.writeln(Math.max(-10,-24,-12,-
umN) 20));   -10
4. </script>  

A. What is a method and what are its properties that are mathematical functions?

Methods are functions attached to specific classes where functions are associate to the set value
of x and the set value of y. Programming functions is somehow related to mathematical functions,
where the set of formulas will follow the process.

5
Example of programming function in determining the average using the number of elements.

And the output will be

In the other hand, if values are given in mathematical expressions, we simply use the average method.
Like,
1. Enter number: 45.3
2. Enter number: 67.5

6
3. Enter number: -45.6
4. Enter number: 20.34
5. Enter number: 33
6. Enter number: 45.6

45.3+67.5+ (−45.6 ) +20.34+ 33+45.6


Average =
6
166.14
Average =
6
Average = 27.69
Same functions and properties in programming but different in using method where in program-
ming we used identifiers to the value and in mathematical functions is directly to the point. However,
the main difference if you call f(x) in Math, you will get the same answer, but if you call f'(x) in
programming, the answer may not be the same. And there are also functions in programming that are
not computable. For example, the infinity sets in Math you can define the function, and in programming
you can only define the floating-point numbers that only represent a reduced set of real numbers. So,
there are methods and properties in Math and programming are similar to each other different in
process but they get the same number of values.

B. How do the concepts of domain, codomain, and range apply in a method?

What can go into a function is called a domain. What can possibly result from a function called a
codomain. What actually comes from a function is called a range. What goes out of a scope depends on
what we put in the domain, but we can define the domain in fact, the domain is an integral part of the
function. We change the domain and we have a different function. Although both functions take the
input and square it, they have a different set of outputs. While domain, codomain, and range are
actually three more vocabulary terms to know, they are also useful concepts to master by thinking
about them, you can understand the behavior of a function or relationship to understand. By
determining the range and codomain of a function before you start graphing, you generally develop a
mental picture of a function that can help you avoid mistakes or wasting space on your graph paper
when graphing the function.

You might also like