Hi!
I have a problem, again.
I would like to write a program to integrate functions. If I write to console integrate(polynom, lower limit, upper limit). I already write function which seperate polynom, now I don't know how to calculate whole thing.
Example: integrate(x^2+3,-1,2) solution: 12
AnnA.B 13 Newbie Poster
Recommended Answers
Jump to PostKid if you're not already doing so, then use the trapezium rule.
Your program should take four arguments.
1) The function f(x)
2) The lower limit
3) The upper limit
4) The number of trapeziums to split it into
5) The height of the trapeziums- Unless …
Jump to PostYes well that is about as trivial as integration gets. The problem is when you want to consider trig functions etc.
I'm not sure exactly what you wish to do.
Do you want to enter ANY trivial expression at the command line? If that is the case then …
Jump to PostOkay so...
- Do you wish to enter the expression at the command line?
- Will you definitely be given the upper and lower bounds?
- Are you planning to find the exact answer or an approximate anser?
- An approximate answer implies the use of numerical methods.
Jump to PostOK
Here's the good news. The answers to the last two questions makes this doable. - hence the trapezium rule.
The bad news, because you are inputting the expression at the command line you will have to write a parser or an eval() function.
I don't use …
All 15 Replies
FlamingClaw 98 Posting Pro
AnnA.B 13 Newbie Poster
FlamingClaw 98 Posting Pro
AnnA.B 13 Newbie Poster

iamthwee
AnnA.B 13 Newbie Poster
squeege321 0 Newbie Poster
AnnA.B 13 Newbie Poster

iamthwee
AnnA.B 13 Newbie Poster

iamthwee
AnnA.B 13 Newbie Poster

iamthwee
AnnA.B 13 Newbie Poster
FlamingClaw 98 Posting Pro
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.