Matlab online IDE: calculate the upper limit of the definite integral

Previous article: Matlab Online IDE: MATLAB Online Introduction and Calculation of Definite Integral Cases

1. Case introduction

insert image description here

% 定义符号变量 x
syms x;

% 定义函数 f(x) = x
f = x;

% 定义定积分的值 I
I = 2;

% 计算函数 f(x)[0, x] 区间的定积分,并求其反函数 F(x)
F = finverse(int(f, 0, x));

% 使用 vpasolve 函数求解 F(x) - I = 0 的解,并将其转换成浮点数
x_value = double(vpasolve(F - I, x));

% 输出结果 x_value
disp(x_value);

The function of the above code is: calculation function f ( x ) = xf(x)=xf(x)=x in[ 0 , x ] [0,x][0,The value of the definite integral in the interval x ] is 2 2At 2 o'clock, the upper limit of pointsis xxthe value of x . where syms x defines the symbolic variable x, and f = x defines the functionf ( x ) = xf(x)=xf(x)=x , I = 2 defines the value of the definite integral, F = finverse(int(f, 0, x)) evaluates the functionf ( x ) f(x)f ( x ) in[ 0 , x ] [0,x][0,x ] definite integral in the interval, and its inverse functionF ( x ) F(x)F ( x ) , x_value = double(vpasolve(F - I, x)) Use the vpasolve function to solve the equationF ( x ) − I = 0 F(x)-I=0F(x)I=0 solution, and convert it into a floating point number, disp(x_value) outputs the result x_value.

2. Calculation results

insert image description here

Guess you like

Origin blog.csdn.net/weixin_41194129/article/details/130060771