0% found this document useful (0 votes)
31 views1 page

%hameed Ur Rehman %MSC 4 %assingment 4 %question 1

This MATLAB code defines a function f(x) as x*cos(x)^2 + 1, then calculates the integral of f from 0 to pi and stores it in y. It outputs the integral y in symbolic form as (pi*(pi + 4))/4 and numerically evaluates it to be approximately 5.6090.

Uploaded by

Bilal Satti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views1 page

%hameed Ur Rehman %MSC 4 %assingment 4 %question 1

This MATLAB code defines a function f(x) as x*cos(x)^2 + 1, then calculates the integral of f from 0 to pi and stores it in y. It outputs the integral y in symbolic form as (pi*(pi + 4))/4 and numerically evaluates it to be approximately 5.6090.

Uploaded by

Bilal Satti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

%Hameed Ur Rehman

%msc 4
%assingment 4
%question 1
clc
clear all
close all
syms x
f=(cos(x)^2*x+1)
y=int(f,0,pi)
pretty(y)
double(y)

f =
x*cos(x)^2 + 1

y =
(pi*(pi + 4))/4

pi (pi + 4)
-----------
4
ans =
5.6090

Published with MATLAB 7.10

You might also like