Solve piecewise function
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have two piecewise function
equ1 = Piecewise[0.524324 + 0.0376478x, 0.639464 <= x <= 0.839322]
equ2 = Piecewise[-0.506432 + 1.48068x, 0.658914 <= x <= 0.77085]
Now, I am trying to solve equ1 = equ2
.
Firstly I tried FindRoot
:
FindRoot[equ1 == equ2, x]
But the output is x = 0
. I can only get the correct answer by set search starting point 0.7
. How can I direct get the answer without set starting point?
Secondly, I tried code Reduce:
Reduce[equ1 == equ2, x]
However, the error appear. The good news is Reduce
do provide the correct answer for my equation. The error is:
Reduce::ratnz: Reduce was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result.
Do I have other way to solve those two piecewise function?
equation-solving error piecewise
add a comment |Â
up vote
1
down vote
favorite
I have two piecewise function
equ1 = Piecewise[0.524324 + 0.0376478x, 0.639464 <= x <= 0.839322]
equ2 = Piecewise[-0.506432 + 1.48068x, 0.658914 <= x <= 0.77085]
Now, I am trying to solve equ1 = equ2
.
Firstly I tried FindRoot
:
FindRoot[equ1 == equ2, x]
But the output is x = 0
. I can only get the correct answer by set search starting point 0.7
. How can I direct get the answer without set starting point?
Secondly, I tried code Reduce:
Reduce[equ1 == equ2, x]
However, the error appear. The good news is Reduce
do provide the correct answer for my equation. The error is:
Reduce::ratnz: Reduce was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result.
Do I have other way to solve those two piecewise function?
equation-solving error piecewise
2
What's wrong withSolve[0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, x]
? or evenFindRoot[equ1 == equ2, x, .7]
?
â AccidentalFourierTransform
5 hours ago
1
Try to plot then you see where is root.Plot[equ1 - equ2, x, 1/2, 1], FindRoot[equ1 == equ2, x, 7/10]
.
â Mariusz Iwaniuk
5 hours ago
1
Because at later stages, I need to compara 100 equations to find out solution. It is not possible to set the starting value for each one of them.
â Yubao Deng
4 hours ago
1
YourReduce
command works for me. The message is just a warning, not an error.
â Michael E2
3 hours ago
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have two piecewise function
equ1 = Piecewise[0.524324 + 0.0376478x, 0.639464 <= x <= 0.839322]
equ2 = Piecewise[-0.506432 + 1.48068x, 0.658914 <= x <= 0.77085]
Now, I am trying to solve equ1 = equ2
.
Firstly I tried FindRoot
:
FindRoot[equ1 == equ2, x]
But the output is x = 0
. I can only get the correct answer by set search starting point 0.7
. How can I direct get the answer without set starting point?
Secondly, I tried code Reduce:
Reduce[equ1 == equ2, x]
However, the error appear. The good news is Reduce
do provide the correct answer for my equation. The error is:
Reduce::ratnz: Reduce was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result.
Do I have other way to solve those two piecewise function?
equation-solving error piecewise
I have two piecewise function
equ1 = Piecewise[0.524324 + 0.0376478x, 0.639464 <= x <= 0.839322]
equ2 = Piecewise[-0.506432 + 1.48068x, 0.658914 <= x <= 0.77085]
Now, I am trying to solve equ1 = equ2
.
Firstly I tried FindRoot
:
FindRoot[equ1 == equ2, x]
But the output is x = 0
. I can only get the correct answer by set search starting point 0.7
. How can I direct get the answer without set starting point?
Secondly, I tried code Reduce:
Reduce[equ1 == equ2, x]
However, the error appear. The good news is Reduce
do provide the correct answer for my equation. The error is:
Reduce::ratnz: Reduce was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result.
Do I have other way to solve those two piecewise function?
equation-solving error piecewise
equation-solving error piecewise
edited 3 hours ago
Michael E2
142k11192458
142k11192458
asked 5 hours ago
Yubao Deng
613
613
2
What's wrong withSolve[0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, x]
? or evenFindRoot[equ1 == equ2, x, .7]
?
â AccidentalFourierTransform
5 hours ago
1
Try to plot then you see where is root.Plot[equ1 - equ2, x, 1/2, 1], FindRoot[equ1 == equ2, x, 7/10]
.
â Mariusz Iwaniuk
5 hours ago
1
Because at later stages, I need to compara 100 equations to find out solution. It is not possible to set the starting value for each one of them.
â Yubao Deng
4 hours ago
1
YourReduce
command works for me. The message is just a warning, not an error.
â Michael E2
3 hours ago
add a comment |Â
2
What's wrong withSolve[0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, x]
? or evenFindRoot[equ1 == equ2, x, .7]
?
â AccidentalFourierTransform
5 hours ago
1
Try to plot then you see where is root.Plot[equ1 - equ2, x, 1/2, 1], FindRoot[equ1 == equ2, x, 7/10]
.
â Mariusz Iwaniuk
5 hours ago
1
Because at later stages, I need to compara 100 equations to find out solution. It is not possible to set the starting value for each one of them.
â Yubao Deng
4 hours ago
1
YourReduce
command works for me. The message is just a warning, not an error.
â Michael E2
3 hours ago
2
2
What's wrong with
Solve[0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, x]
? or even FindRoot[equ1 == equ2, x, .7]
?â AccidentalFourierTransform
5 hours ago
What's wrong with
Solve[0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, x]
? or even FindRoot[equ1 == equ2, x, .7]
?â AccidentalFourierTransform
5 hours ago
1
1
Try to plot then you see where is root.
Plot[equ1 - equ2, x, 1/2, 1], FindRoot[equ1 == equ2, x, 7/10]
.â Mariusz Iwaniuk
5 hours ago
Try to plot then you see where is root.
Plot[equ1 - equ2, x, 1/2, 1], FindRoot[equ1 == equ2, x, 7/10]
.â Mariusz Iwaniuk
5 hours ago
1
1
Because at later stages, I need to compara 100 equations to find out solution. It is not possible to set the starting value for each one of them.
â Yubao Deng
4 hours ago
Because at later stages, I need to compara 100 equations to find out solution. It is not possible to set the starting value for each one of them.
â Yubao Deng
4 hours ago
1
1
Your
Reduce
command works for me. The message is just a warning, not an error.â Michael E2
3 hours ago
Your
Reduce
command works for me. The message is just a warning, not an error.â Michael E2
3 hours ago
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
1
down vote
equ1 = Rationalize[
Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322]]
equ2 = Rationalize[
Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085]]
Reduce[equ1 == equ2, x]
x == 0.714299 || x < 79933/125000 || x > 419661/500000
add a comment |Â
up vote
1
down vote
Either:
FindRoot[equ1 == equ2, x, 0.7, 0.639464, 0.839322]
(* x -> 0.714299 *)
Or:
NSolve[equ1 == equ2 && 0.639464 <= x <= 0.839322, x]
NSolve::ratnz
:.... [Unimportant warning.]
(* x -> 0.714299 *)
add a comment |Â
up vote
1
down vote
If you have 100 equations and you want to find the unique solution to the whole set and each of your Piecewise
are written in exactly the same form as the two you showed and the solution must lie in the intersection of all those inequalities then perhaps
equ1 = Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322];
equ2 = Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085];
funs = equ1, equ2;
Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]
will give you
0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, 0.658914 < x < 0.77085
and
x /. Solve[
Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]
, x][[1]]
will give you
0.714299
You can make the list of funs longer and longer and still get the solution.
The Max
part of that is extracting all your lower bounds and finding the largest one. The Min
part of that is extracting all your upper bounds and finding the smallest one. The Equal
part of that is extracting all your equations and setting them equal to each other. We assemble those pieces and give them to Solve.
You should check carefully to make certain that there will always be one unique solution to your set of equations.
You might click on Piecewise
and then Details
in the help pages and read very carefully all the information there. Because you have not given any other information about the value of your functions if x happens to be outside the bounds you have given then the value of that Piecewise
function will be zero for x outside those bounds. That might surprise you.
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
equ1 = Rationalize[
Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322]]
equ2 = Rationalize[
Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085]]
Reduce[equ1 == equ2, x]
x == 0.714299 || x < 79933/125000 || x > 419661/500000
add a comment |Â
up vote
1
down vote
equ1 = Rationalize[
Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322]]
equ2 = Rationalize[
Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085]]
Reduce[equ1 == equ2, x]
x == 0.714299 || x < 79933/125000 || x > 419661/500000
add a comment |Â
up vote
1
down vote
up vote
1
down vote
equ1 = Rationalize[
Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322]]
equ2 = Rationalize[
Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085]]
Reduce[equ1 == equ2, x]
x == 0.714299 || x < 79933/125000 || x > 419661/500000
equ1 = Rationalize[
Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322]]
equ2 = Rationalize[
Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085]]
Reduce[equ1 == equ2, x]
x == 0.714299 || x < 79933/125000 || x > 419661/500000
answered 4 hours ago
Alex Trounev
3,3001313
3,3001313
add a comment |Â
add a comment |Â
up vote
1
down vote
Either:
FindRoot[equ1 == equ2, x, 0.7, 0.639464, 0.839322]
(* x -> 0.714299 *)
Or:
NSolve[equ1 == equ2 && 0.639464 <= x <= 0.839322, x]
NSolve::ratnz
:.... [Unimportant warning.]
(* x -> 0.714299 *)
add a comment |Â
up vote
1
down vote
Either:
FindRoot[equ1 == equ2, x, 0.7, 0.639464, 0.839322]
(* x -> 0.714299 *)
Or:
NSolve[equ1 == equ2 && 0.639464 <= x <= 0.839322, x]
NSolve::ratnz
:.... [Unimportant warning.]
(* x -> 0.714299 *)
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Either:
FindRoot[equ1 == equ2, x, 0.7, 0.639464, 0.839322]
(* x -> 0.714299 *)
Or:
NSolve[equ1 == equ2 && 0.639464 <= x <= 0.839322, x]
NSolve::ratnz
:.... [Unimportant warning.]
(* x -> 0.714299 *)
Either:
FindRoot[equ1 == equ2, x, 0.7, 0.639464, 0.839322]
(* x -> 0.714299 *)
Or:
NSolve[equ1 == equ2 && 0.639464 <= x <= 0.839322, x]
NSolve::ratnz
:.... [Unimportant warning.]
(* x -> 0.714299 *)
answered 4 hours ago
Michael E2
142k11192458
142k11192458
add a comment |Â
add a comment |Â
up vote
1
down vote
If you have 100 equations and you want to find the unique solution to the whole set and each of your Piecewise
are written in exactly the same form as the two you showed and the solution must lie in the intersection of all those inequalities then perhaps
equ1 = Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322];
equ2 = Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085];
funs = equ1, equ2;
Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]
will give you
0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, 0.658914 < x < 0.77085
and
x /. Solve[
Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]
, x][[1]]
will give you
0.714299
You can make the list of funs longer and longer and still get the solution.
The Max
part of that is extracting all your lower bounds and finding the largest one. The Min
part of that is extracting all your upper bounds and finding the smallest one. The Equal
part of that is extracting all your equations and setting them equal to each other. We assemble those pieces and give them to Solve.
You should check carefully to make certain that there will always be one unique solution to your set of equations.
You might click on Piecewise
and then Details
in the help pages and read very carefully all the information there. Because you have not given any other information about the value of your functions if x happens to be outside the bounds you have given then the value of that Piecewise
function will be zero for x outside those bounds. That might surprise you.
add a comment |Â
up vote
1
down vote
If you have 100 equations and you want to find the unique solution to the whole set and each of your Piecewise
are written in exactly the same form as the two you showed and the solution must lie in the intersection of all those inequalities then perhaps
equ1 = Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322];
equ2 = Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085];
funs = equ1, equ2;
Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]
will give you
0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, 0.658914 < x < 0.77085
and
x /. Solve[
Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]
, x][[1]]
will give you
0.714299
You can make the list of funs longer and longer and still get the solution.
The Max
part of that is extracting all your lower bounds and finding the largest one. The Min
part of that is extracting all your upper bounds and finding the smallest one. The Equal
part of that is extracting all your equations and setting them equal to each other. We assemble those pieces and give them to Solve.
You should check carefully to make certain that there will always be one unique solution to your set of equations.
You might click on Piecewise
and then Details
in the help pages and read very carefully all the information there. Because you have not given any other information about the value of your functions if x happens to be outside the bounds you have given then the value of that Piecewise
function will be zero for x outside those bounds. That might surprise you.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
If you have 100 equations and you want to find the unique solution to the whole set and each of your Piecewise
are written in exactly the same form as the two you showed and the solution must lie in the intersection of all those inequalities then perhaps
equ1 = Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322];
equ2 = Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085];
funs = equ1, equ2;
Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]
will give you
0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, 0.658914 < x < 0.77085
and
x /. Solve[
Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]
, x][[1]]
will give you
0.714299
You can make the list of funs longer and longer and still get the solution.
The Max
part of that is extracting all your lower bounds and finding the largest one. The Min
part of that is extracting all your upper bounds and finding the smallest one. The Equal
part of that is extracting all your equations and setting them equal to each other. We assemble those pieces and give them to Solve.
You should check carefully to make certain that there will always be one unique solution to your set of equations.
You might click on Piecewise
and then Details
in the help pages and read very carefully all the information there. Because you have not given any other information about the value of your functions if x happens to be outside the bounds you have given then the value of that Piecewise
function will be zero for x outside those bounds. That might surprise you.
If you have 100 equations and you want to find the unique solution to the whole set and each of your Piecewise
are written in exactly the same form as the two you showed and the solution must lie in the intersection of all those inequalities then perhaps
equ1 = Piecewise[0.524324 + 0.0376478 x, 0.639464 <= x <= 0.839322];
equ2 = Piecewise[-0.506432 + 1.48068 x, 0.658914 <= x <= 0.77085];
funs = equ1, equ2;
Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]
will give you
0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, 0.658914 < x < 0.77085
and
x /. Solve[
Join[Equal @@ Map[#[[1, 1, 1]] &, funs],
Max[Map[#[[1, 1, 2, 1]] &, funs]] < x < Min[Map[#[[1, 1, 2, 3]] &, funs]]]
, x][[1]]
will give you
0.714299
You can make the list of funs longer and longer and still get the solution.
The Max
part of that is extracting all your lower bounds and finding the largest one. The Min
part of that is extracting all your upper bounds and finding the smallest one. The Equal
part of that is extracting all your equations and setting them equal to each other. We assemble those pieces and give them to Solve.
You should check carefully to make certain that there will always be one unique solution to your set of equations.
You might click on Piecewise
and then Details
in the help pages and read very carefully all the information there. Because you have not given any other information about the value of your functions if x happens to be outside the bounds you have given then the value of that Piecewise
function will be zero for x outside those bounds. That might surprise you.
edited 3 hours ago
answered 3 hours ago
Bill
5,15058
5,15058
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184824%2fsolve-piecewise-function%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
What's wrong with
Solve[0.524324 + 0.0376478 x == -0.506432 + 1.48068 x, x]
? or evenFindRoot[equ1 == equ2, x, .7]
?â AccidentalFourierTransform
5 hours ago
1
Try to plot then you see where is root.
Plot[equ1 - equ2, x, 1/2, 1], FindRoot[equ1 == equ2, x, 7/10]
.â Mariusz Iwaniuk
5 hours ago
1
Because at later stages, I need to compara 100 equations to find out solution. It is not possible to set the starting value for each one of them.
â Yubao Deng
4 hours ago
1
Your
Reduce
command works for me. The message is just a warning, not an error.â Michael E2
3 hours ago