Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.9K Views
|
1 Reply
|
1 Total Like
View groups...
Share
Share this post:

FindRoot - can I combine two equations into one?

Hi, I am solving a system of two equations, but the equations themselves change depending on whether one parameter is positive or negative : for x0<0

sol[i1_?NumberQ, i2_?NumberQ, z0_?NumberQ, x0_?NumberQ] :=FindRoot[{i1 == f1[z, x], i2 == -f2[z, x]}, {{z, z0}, {x, x0}}] 

and for x0>0

sol[i1_?NumberQ, i2_?NumberQ, z0_?NumberQ, x0_?NumberQ] :=FindRoot[{i1 == f1[z, x], i2 == f2[z, x]}, {{z, z0}, {x, x0}}]

(for x0<0 there is '-' sign before f2). i1, i2, x0, z0 are constants. (Function sol[] is needed because I have a cycle where the solution is found many times for different values of the numerical parameters). Can I combine these two situation into one, so that I could use a single function sol[] for both x<0 and x>0?

POSTED BY: Lev Dorosinskiy

You could wrap RealSign[x] around f2

https://reference.wolfram.com/language/ref/RealSign.html

POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard