hi to everyone!i need help for my assignment in our numerical analysis.our instructor asked us to solve a linear equation using turbo c language.Can anyone help me with this problem,a simple sample code will do.Ex.f(x)=2x^3+x^2

## All 10 Replies

2x is multiplication; you can do it with `2 * x` . The ^ operator exists in C, but not in the way that formulae use it. It means bitwise exclusive-OR instead of exponentiation. Turbo C supports the `pow()` function though, so you can use that:

``````/* f(x)=2x^3+x^2 */
double f(double x)
{
return pow(2 * x, 3) + pow(x, 2);
}``````

First of all, do you understand the maths involved?

By that, I mean can you do this on paper. If you can't, then you first need maths help, not programming help.

If you can do it on paper, try transferring that to a program and post what you can come up with.

thanks for the reply.But what if the function is not fixed,meaning the user could input any function of x or [f(x)] with different value.

Then you need to parse the string first.. That can be pretty hard.

Try to understand how you do it, how you calculate f(x), write that down in steps on paper or on your computer and post it here.

this is the first equation:
f(x)=2x^3 + x^2

then we have to get it's 1st derivative, in math the 2nd equation would be like this:
f'(x)=6x^2 + 2x

my problem now is how to solve for it's derivative.
Note: this is not a fixed program the user is asked to input the f(x) that he wants to be solved,whatever equation that is being inputed by the user must get a correct answer.TY

Hi the Grand Matematical Conclave...

2x^3 + x^2 is not a part of a LINEAR equation!

That's a linear equation:
A*x + B = 0

So ask a user to type A then B - that's all, your program is capable to print this equation solution now...

Are you sure this is linear equation or linear function? I'm pretty sure your examples are linear functions.. Linear equations are solved like so:
Solve for x and y:
x+2y=8
3x-2y=0

Elimination:
x+2y=8
+
3x-2y=0
4x =8
4 4
x=2

Solve for y using x=2:
x+2y=8
2+2y=8
2y=6
2 2

y=3

It's not a LINEAR EQUATION:

x+2y=8
3x-2y=0

It's a SYSTEM of linear equations.
Feel the difference...

Where is a word SYSTEM in the original post?..

other than the fact that you're confusing linear functions with linear equations, a huge problem can be located in the title of your thread:

"Turbo C"

throw that crap away, now, and get a real compiler. and if you have an instructor who insists you use Turbo C, them them to sod off, as well.

all they're doing with Turbo C, in ensuring you will be a worthless programmer and incompetent in the global workplace.

.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.
{"ft_lang_label":"__label__en","ft_lang_prob":0.86435735,"math_prob":0.9663097,"size":1135,"snap":"2022-05-2022-21","text_gpt3_token_len":282,"char_repetition_ratio":0.09018568,"word_repetition_ratio":0.0,"special_character_ratio":0.23348017,"punctuation_ratio":0.12605043,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9977225,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-25T07:23:08Z\",\"WARC-Record-ID\":\"<urn:uuid:e862dcce-15f4-4049-a4ba-c66ed4f95469>\",\"Content-Length\":\"101280\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:429ff9f4-1bcc-438f-8272-6ded428d7043>\",\"WARC-Concurrent-To\":\"<urn:uuid:6d6b3682-3862-492f-8183-3dbcc3142aa5>\",\"WARC-IP-Address\":\"172.66.41.5\",\"WARC-Target-URI\":\"https://www.daniweb.com/programming/software-development/threads/139491/solving-linear-equation-in-turbo-c\",\"WARC-Payload-Digest\":\"sha1:IZVRVVR2IM63YG2FN34DZURRXMT45C5B\",\"WARC-Block-Digest\":\"sha1:B74WWEQ3E6EXT7YVWDAIIWLM7OQMNTEY\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652662580803.75_warc_CC-MAIN-20220525054507-20220525084507-00365.warc.gz\"}"}