Skip to main content
14-Alexandrite
July 11, 2023
Solved

Solving equation with conditional statements

  • July 11, 2023
  • 1 reply
  • 3030 views

Hello All,

 

I am trying to solve an equation that has condition statements and find the roots.

fahmed2_0-1689100240566.png

Please help,

 

Thanks

 

 

Best answer by Werner_E

So you should solve the equation for q0 and not for B.f. You can make the solution a function of B_f as explained in my previous answer.

You may use either a solve block or the root function - its up to you.

Werner_E_0-1689117265946.png

 

You can speedup the calculation significantly (factor 5) by using the approach which I already showed in a previous posting

Werner_E_1-1689118331005.png

Werner_E_2-1689118347669.png

 

1 reply

25-Diamond I
July 11, 2023
  • The symbolics can't do well with conditional expressions, so you should rather use Primes numeric methods (either a solve block with "find" or the "root" command.
  • I guess you rather want to solve for B.f and not for the function Deltaq(B.f)
  • Again you used function names as if it were simple variables! If you use a function, you have to provide the function argument!

Werner_E_1-1689101534910.png

 

You could also do it that way:

Werner_E_2-1689102183634.png

or maybe even that way

Werner_E_0-1689102916019.png

Werner_E_1-1689102943463.png

 

fahmed-214-AlexandriteAuthor
14-Alexandrite
July 11, 2023

What if I have two variables to solve!!

fahmed2_0-1689105346676.png

 

25-Diamond I
July 11, 2023

@fahmed-2 wrote:

What if I have two variables to solve!!

 

 


Then you would have to use a solve block.

But two variables and just one equation????

 

BTW, do you really expect non-real results here?

Werner_E_0-1689108527721.png