lettura simple

How to find antiderivative of a function in Octave

In this lesson I'll explain how to calculate an antiderivative of a mathematical function in Octave with some practical examples.

What do you need? To calculate the anti-derivatives you must have installed the Symbolic module on GNU Octave. To learn more, please click here.

Go to the Octave command line.

Define the independent variable symbol using the syms command. For example, the letter x

syms x

Now compute the antiderivative (indefinite integral) of the function f(x)=1/x

$$ \int \frac{1}{x} \ dx $$

Type int() command with the function expression 1/x as an argument. Then hit enter.

int(1/x)

Octave computes and returns the antiderivative of the function f(x) =1/x

ans = (sym) log(x)

The result is the antiderivative of 1/x is the primitive function F(x)=log(x)

The antiderivative is not a single function, it is a family of functions because you can add any constant (c) to the primitive function (F).

Verify. The antiderivative of 1/x is the logarithm of x plus any constant c. $$ \int \frac{1}{x} \ dx = \log(x) + c $$

Now you can calculate any antiderivative using Octave.




Report a mistake or post a question




FacebookTwitterLinkedinLinkedin