Post Reply 
Solve() gives wrong answer (r10077)
04-27-2016, 02:19 PM (This post was last modified: 04-27-2016 02:20 PM by toml_12953.)
Post: #5
RE: Solve() gives wrong answer (r10077)
(04-27-2016 01:16 PM)Nigel (UK) Wrote:  
(04-27-2016 09:47 AM)drkosse Wrote:  Hi,

this is probably a stupid question but why does not the following equation give me an answer?

Solve(0.04*x^2-2.4*x+36=0)
Prime answers [[]]

Solving it on paper gives x=30
Wolfram Alpha solves this just fine

Thanks Smile

It's a rounding problem. The exact equation has two equal real roots which the CAS finds perfectly well with 4/100 and 24/10 in place of 0.04 and 2.4. With the approximate numbers in place I'm assuming that b^2-4*a*c is - just! - negative and so no real root exists.

Keeping the approximate numbers and changing 36 to 35.99999999 also works, as does using csolve instead of solve.

What is more annoying is that taking the equation 0.04*x^2-2.4*x+30=0 (which has two real roots that solve finds without difficulty) and multiplying each term by 1e-16 produces an equation that solve (or fsolve or csolve) won't solve. The CAS has a particular aversion to small approximate numbers which other systems do not share. As a physicist I find this frustrating, although once aware of the problem there are work-arounds.

Nigel (UK)

csolve gets {30-5.96046447754E-6*i,30+5.96046447754E-6*i}

Tom L[/b]

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Solve() gives wrong answer (r10077) - toml_12953 - 04-27-2016 02:19 PM



User(s) browsing this thread: 2 Guest(s)