1

Every function has an expression by $X$, like:

$f(x) = x^2 + 2x + 1$

What about cosinus, $\exp$, $\log$ functions ? What is $\log(x) =$ ? $\cos(x) =$ ?

What happens when we pass a value to these functions in our computers ?

Hamou
  • 6,745

2 Answers2

2

Your first statement is false. Not every function has a polynomial expression in $x$. Probably all the functions you have encountered do, but that's like saying "All birds are red" because you've only seen cardinals. :) If you look up the definition of "function", you may notice it doesn't mention polynomials at all.

Cosine, log, exp do happen to have polynomial expressions, sort of. But the polynomials have infinitely many terms. If you look up "Taylor series", you can find them.

In a computer, what typically happens is that very good approximations to these infinite polynomial expressions are used. These approximations can be computed with finitely many operations, and differ from the correct answer by a number smaller than the smallest number representable on the computer. So we take the value computed by this approximation and pretend it's the exact answer.

[The "smaller than the smallest number representable on the computer" is a slight fib; you might someday want to read the first chapter of Trefethen and Bao, Numerical Linear Algebra, to get a very concise and precise description of how numbers are represented in computers, and what we can ensure in the computation of standard functions like log and cosine.]

John Hughes
  • 93,729
1

Not all, however there are some kinds fuctions which can be done.

For example, $$e^x=\sum_{n=0}^\infty\frac{x^n}{n!}, x\in (-\infty,+\infty);$$ and $$\ln (1+x)=\sum_{n=0}^\infty(-1)^{n}\frac{x^{n+1}}{n+1}, x\in (-1,1]$$

You can refer the part of Taylor series in Calculus (II).

May it helps!

Paul
  • 20,553