cancel
Showing results for
Did you mean:
cancel
Showing results for
Did you mean:

SOLVED
Highlighted

## Solving a Polynomial Equation

I have been playing around using different methods to solve a polynomial equation and need the help of one of the 'symbolic guru's on here.

I have managed to solve the equation and evaluated numerically, but have the following queries:

• Can I force the symbolic result to return only real values

• Is 'float' required to evaluate the symbolic expression numerically

• Is there a more elegant way to solve this equation.

Thanks,

Mike

Tags (5)
1 ACCEPTED SOLUTION

Accepted Solutions

## Re: Solving a Polynomial Equation

 Mike Armstrong wrote:I have been playing around using different methods to solve a polynomial equation and need the help of one of the 'symbolic guru's on here.I have managed to solve the equation and evaluated numerically, but have the following queries:Can I force the symbolic result to return only real values

Not in an easy and natural way ("assume" does not work for this). See attachment.

 Is 'float' required to evaluate the symbolic expression numerically

I guess to evaluate the LambertW function numerically its a requirement. This function can only be evaluated symbolically and thats the reason you can't use the result of the symbolics directly in numeric evaluations without first symbolically evaluate it by using float and turning it that way into numeric results.

 Is there a more elegant way to solve this equation.

Probably the symbolically evaluated solve block is the better solution. I am not sure why the numeric evaluation fails here. 24 REPLIES 24

## Re: Solving a Polynomial Equation

 Can I force the symbolic result to return only real values

In general, I think no.

 Is 'float' required to evaluate the symbolic expression numerically

You can put a floating point number somewhere in your expression, then you will get a floating point answer (for example, put k.6*1.0). If you do use float then 8 digits is not enough though. Remember that float does not just affect the displayed answer, it affects the precision of the calculations. Check how much error you have in your equality with float 8: about 6,000,000. With float 20 the error is 0.03.

 Is there a more elegant way to solve this equation.

I would automate the picking of the real root.

## Re: Solving a Polynomial Equation

 Mike Armstrong wrote:I have been playing around using different methods to solve a polynomial equation and need the help of one of the 'symbolic guru's on here.I have managed to solve the equation and evaluated numerically, but have the following queries:Can I force the symbolic result to return only real values

Not in an easy and natural way ("assume" does not work for this). See attachment.

 Is 'float' required to evaluate the symbolic expression numerically

I guess to evaluate the LambertW function numerically its a requirement. This function can only be evaluated symbolically and thats the reason you can't use the result of the symbolics directly in numeric evaluations without first symbolically evaluate it by using float and turning it that way into numeric results.

 Is there a more elegant way to solve this equation.

Probably the symbolically evaluated solve block is the better solution. I am not sure why the numeric evaluation fails here. ## Re: Solving a Polynomial Equation

 I am not sure why the numeric evaluation fails here.

Big numbers. Change CTOL to 0.1.

## Re: Solving a Polynomial Equation

 Richard Jackson wrote:I am not sure why the numeric evaluation fails here.Big numbers. Change CTOL to 0.1.

That only works when the guess value is close to the actual value of V.b.

## Re: Solving a Polynomial Equation

 Richard Jackson wrote:Can I force the symbolic result to return only real valuesIn general, I think no.Is 'float' required to evaluate the symbolic expression numericallyYou can put a floating point number somewhere in your expression, then you will get a floating point answer (for example, put k.6*1.0). If you do use float then 8 digits is not enough though. Remember that float does not just affect the displayed answer, it affects the precision of the calculations. Check how much error you have in your equality with float 8: about 6,000,000. With float 20 the error is 0.03.Is there a more elegant way to solve this equation.I would automate the picking of the real root.

Cheers Richard,

I thought you and Werner would be the first to offer an explanation.

## Re: Solving a Polynomial Equation

 Richard Jackson wrote: I am not sure why the numeric evaluation fails here.Big numbers. Change CTOL to 0.1.

Ah yes! I see. Thanks

## Re: Solving a Polynomial Equation

Its seems to work for guess value in the range from 580 to 10^11.

## Re: Solving a Polynomial Equation

 Werner Exinger wrote:Mike Armstrong wrote:I have been playing around using different methods to solve a polynomial equation and need the help of one of the 'symbolic guru's on here.I have managed to solve the equation and evaluated numerically, but have the following queries:Can I force the symbolic result to return only real values Not in an easy and natural way ("assume" does not work for this). See attachment.

Why though. That was baffling me all afternoon.

 Werner Exinger wrote:Is 'float' required to evaluate the symbolic expression numericallyI guess to evaluate the LambertW function numerically its a requirement. This function can only be evaluated symbolically and that's the reason you can't use the result of the symbolic's directly in numeric evaluations without first symbolically evaluate it by using float and turning it that way into numeric results

I get it thanks. Is there a way to assess beforehand if a function can be evaluated numerically?

Thanks for spotted the error with the Minerr example. However, the numerical processor is still dependant on the guess values from the user. Sorry for sounding stupid, but why can the symbolic processor solve it?

 Werner Exinger wrote:Is there a more elegant way to solve this equation. Probably the symbolically evaluated solve block is the better solution. I am not sure why the numeric evaluation fails here. Yes is much neater and it does not rely on the guess value.

## Re: Solving a Polynomial Equation

Oh, forgot to mention. I like your REALONLY function 