Finding all roots to equation [duplicate]
up vote
2
down vote
favorite
This question already has an answer here:
About multi-root search in Mathematica for transcendental equations
8 answers
I'm currently doing some Mathematica exercises, and I'm stuck on this one task where you're supposed to plot the functions h(t)= |3-t^2|+|t-1|-t^2 , g(t)=3sin(t)
in the same grap, and then find all the roots. This is what I've got so far:
The instructions say that I should use FindRoot to exactly decide all the roots, but I don't think I've done it right. What should I change with the function in order to make it find all of the roots?
Thanks in advance.
plotting equation-solving
marked as duplicate by Szabolcs, Daniel Lichtblau, AccidentalFourierTransform, Michael E2
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
13 hours ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
2
down vote
favorite
This question already has an answer here:
About multi-root search in Mathematica for transcendental equations
8 answers
I'm currently doing some Mathematica exercises, and I'm stuck on this one task where you're supposed to plot the functions h(t)= |3-t^2|+|t-1|-t^2 , g(t)=3sin(t)
in the same grap, and then find all the roots. This is what I've got so far:
The instructions say that I should use FindRoot to exactly decide all the roots, but I don't think I've done it right. What should I change with the function in order to make it find all of the roots?
Thanks in advance.
plotting equation-solving
marked as duplicate by Szabolcs, Daniel Lichtblau, AccidentalFourierTransform, Michael E2
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
13 hours ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Solve[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
works for me in V11.3, but notNSolve
for some reason.
– Michael E2
16 hours ago
@MichaelE2 - I would guess thatNSolve
uses a derivative and cannot handleAbs
. Since the values are real, a workaround isNSolve[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t] /. Abs[z_] :> Sqrt[z^2], -5 <= t <= 5}, t]
– Bob Hanlon
9 hours ago
@BobHanlon You can see in the comments to @zhk's answer below thatNSolve
works in earlier versions of Mma. While there's some plausibility in your suggestion, it stills seems a backslide.
– Michael E2
8 hours ago
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
This question already has an answer here:
About multi-root search in Mathematica for transcendental equations
8 answers
I'm currently doing some Mathematica exercises, and I'm stuck on this one task where you're supposed to plot the functions h(t)= |3-t^2|+|t-1|-t^2 , g(t)=3sin(t)
in the same grap, and then find all the roots. This is what I've got so far:
The instructions say that I should use FindRoot to exactly decide all the roots, but I don't think I've done it right. What should I change with the function in order to make it find all of the roots?
Thanks in advance.
plotting equation-solving
This question already has an answer here:
About multi-root search in Mathematica for transcendental equations
8 answers
I'm currently doing some Mathematica exercises, and I'm stuck on this one task where you're supposed to plot the functions h(t)= |3-t^2|+|t-1|-t^2 , g(t)=3sin(t)
in the same grap, and then find all the roots. This is what I've got so far:
The instructions say that I should use FindRoot to exactly decide all the roots, but I don't think I've done it right. What should I change with the function in order to make it find all of the roots?
Thanks in advance.
This question already has an answer here:
About multi-root search in Mathematica for transcendental equations
8 answers
plotting equation-solving
plotting equation-solving
asked 21 hours ago
wznd
182
182
marked as duplicate by Szabolcs, Daniel Lichtblau, AccidentalFourierTransform, Michael E2
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
13 hours ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Szabolcs, Daniel Lichtblau, AccidentalFourierTransform, Michael E2
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
13 hours ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Solve[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
works for me in V11.3, but notNSolve
for some reason.
– Michael E2
16 hours ago
@MichaelE2 - I would guess thatNSolve
uses a derivative and cannot handleAbs
. Since the values are real, a workaround isNSolve[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t] /. Abs[z_] :> Sqrt[z^2], -5 <= t <= 5}, t]
– Bob Hanlon
9 hours ago
@BobHanlon You can see in the comments to @zhk's answer below thatNSolve
works in earlier versions of Mma. While there's some plausibility in your suggestion, it stills seems a backslide.
– Michael E2
8 hours ago
add a comment |
Solve[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
works for me in V11.3, but notNSolve
for some reason.
– Michael E2
16 hours ago
@MichaelE2 - I would guess thatNSolve
uses a derivative and cannot handleAbs
. Since the values are real, a workaround isNSolve[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t] /. Abs[z_] :> Sqrt[z^2], -5 <= t <= 5}, t]
– Bob Hanlon
9 hours ago
@BobHanlon You can see in the comments to @zhk's answer below thatNSolve
works in earlier versions of Mma. While there's some plausibility in your suggestion, it stills seems a backslide.
– Michael E2
8 hours ago
Solve[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
works for me in V11.3, but not NSolve
for some reason.– Michael E2
16 hours ago
Solve[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
works for me in V11.3, but not NSolve
for some reason.– Michael E2
16 hours ago
@MichaelE2 - I would guess that
NSolve
uses a derivative and cannot handle Abs
. Since the values are real, a workaround is NSolve[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t] /. Abs[z_] :> Sqrt[z^2], -5 <= t <= 5}, t]
– Bob Hanlon
9 hours ago
@MichaelE2 - I would guess that
NSolve
uses a derivative and cannot handle Abs
. Since the values are real, a workaround is NSolve[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t] /. Abs[z_] :> Sqrt[z^2], -5 <= t <= 5}, t]
– Bob Hanlon
9 hours ago
@BobHanlon You can see in the comments to @zhk's answer below that
NSolve
works in earlier versions of Mma. While there's some plausibility in your suggestion, it stills seems a backslide.– Michael E2
8 hours ago
@BobHanlon You can see in the comments to @zhk's answer below that
NSolve
works in earlier versions of Mma. While there's some plausibility in your suggestion, it stills seems a backslide.– Michael E2
8 hours ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
5
down vote
You can use NSolve
to find multiple roots,
NSolve[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
{{t -> -4.92954}, {t -> -3.77452}, {t -> 0.762901}, {t -> 3.35745}}
or FindAllCrossings
from here,
FindAllCrossings[Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t], {t, -10, 10},
WorkingPrecision -> 20]
{-4.9295434376879868373, -3.7745180124835511931, 0.76290087955924483126, 3.3574487606850113852}
or FindRoot
providing good initial guesses,
FindRoot[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t]}, {t, #}] & /@ {-5, -3, 1, 4}
{{t -> -4.92954}, {t -> -3.77452}, {t -> 0.762901}, {t -> 3.35745}}
When i try NSolve i get nothing back as output? Also, the FindAllCrossings isn't working either.
– wznd
19 hours ago
@wznd You should input the interval of interest.
– zhk
19 hours ago
@wznd. For meNSolve
andFindAllCrossings
works fine,I checked on Mathematica10.2
and11.3
.
– Mariusz Iwaniuk
19 hours ago
1
@MichaelE2. With little modification works on MMA11.3
:NSolve[{RealAbs[3 - t^2] + RealAbs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
– Mariusz Iwaniuk
17 hours ago
1
@MichaelE2 "11.0.1 for Microsoft Windows (32-bit)"
– zhk
17 hours ago
|
show 2 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
You can use NSolve
to find multiple roots,
NSolve[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
{{t -> -4.92954}, {t -> -3.77452}, {t -> 0.762901}, {t -> 3.35745}}
or FindAllCrossings
from here,
FindAllCrossings[Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t], {t, -10, 10},
WorkingPrecision -> 20]
{-4.9295434376879868373, -3.7745180124835511931, 0.76290087955924483126, 3.3574487606850113852}
or FindRoot
providing good initial guesses,
FindRoot[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t]}, {t, #}] & /@ {-5, -3, 1, 4}
{{t -> -4.92954}, {t -> -3.77452}, {t -> 0.762901}, {t -> 3.35745}}
When i try NSolve i get nothing back as output? Also, the FindAllCrossings isn't working either.
– wznd
19 hours ago
@wznd You should input the interval of interest.
– zhk
19 hours ago
@wznd. For meNSolve
andFindAllCrossings
works fine,I checked on Mathematica10.2
and11.3
.
– Mariusz Iwaniuk
19 hours ago
1
@MichaelE2. With little modification works on MMA11.3
:NSolve[{RealAbs[3 - t^2] + RealAbs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
– Mariusz Iwaniuk
17 hours ago
1
@MichaelE2 "11.0.1 for Microsoft Windows (32-bit)"
– zhk
17 hours ago
|
show 2 more comments
up vote
5
down vote
You can use NSolve
to find multiple roots,
NSolve[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
{{t -> -4.92954}, {t -> -3.77452}, {t -> 0.762901}, {t -> 3.35745}}
or FindAllCrossings
from here,
FindAllCrossings[Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t], {t, -10, 10},
WorkingPrecision -> 20]
{-4.9295434376879868373, -3.7745180124835511931, 0.76290087955924483126, 3.3574487606850113852}
or FindRoot
providing good initial guesses,
FindRoot[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t]}, {t, #}] & /@ {-5, -3, 1, 4}
{{t -> -4.92954}, {t -> -3.77452}, {t -> 0.762901}, {t -> 3.35745}}
When i try NSolve i get nothing back as output? Also, the FindAllCrossings isn't working either.
– wznd
19 hours ago
@wznd You should input the interval of interest.
– zhk
19 hours ago
@wznd. For meNSolve
andFindAllCrossings
works fine,I checked on Mathematica10.2
and11.3
.
– Mariusz Iwaniuk
19 hours ago
1
@MichaelE2. With little modification works on MMA11.3
:NSolve[{RealAbs[3 - t^2] + RealAbs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
– Mariusz Iwaniuk
17 hours ago
1
@MichaelE2 "11.0.1 for Microsoft Windows (32-bit)"
– zhk
17 hours ago
|
show 2 more comments
up vote
5
down vote
up vote
5
down vote
You can use NSolve
to find multiple roots,
NSolve[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
{{t -> -4.92954}, {t -> -3.77452}, {t -> 0.762901}, {t -> 3.35745}}
or FindAllCrossings
from here,
FindAllCrossings[Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t], {t, -10, 10},
WorkingPrecision -> 20]
{-4.9295434376879868373, -3.7745180124835511931, 0.76290087955924483126, 3.3574487606850113852}
or FindRoot
providing good initial guesses,
FindRoot[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t]}, {t, #}] & /@ {-5, -3, 1, 4}
{{t -> -4.92954}, {t -> -3.77452}, {t -> 0.762901}, {t -> 3.35745}}
You can use NSolve
to find multiple roots,
NSolve[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
{{t -> -4.92954}, {t -> -3.77452}, {t -> 0.762901}, {t -> 3.35745}}
or FindAllCrossings
from here,
FindAllCrossings[Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t], {t, -10, 10},
WorkingPrecision -> 20]
{-4.9295434376879868373, -3.7745180124835511931, 0.76290087955924483126, 3.3574487606850113852}
or FindRoot
providing good initial guesses,
FindRoot[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t]}, {t, #}] & /@ {-5, -3, 1, 4}
{{t -> -4.92954}, {t -> -3.77452}, {t -> 0.762901}, {t -> 3.35745}}
edited 19 hours ago
answered 19 hours ago
zhk
8,64911433
8,64911433
When i try NSolve i get nothing back as output? Also, the FindAllCrossings isn't working either.
– wznd
19 hours ago
@wznd You should input the interval of interest.
– zhk
19 hours ago
@wznd. For meNSolve
andFindAllCrossings
works fine,I checked on Mathematica10.2
and11.3
.
– Mariusz Iwaniuk
19 hours ago
1
@MichaelE2. With little modification works on MMA11.3
:NSolve[{RealAbs[3 - t^2] + RealAbs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
– Mariusz Iwaniuk
17 hours ago
1
@MichaelE2 "11.0.1 for Microsoft Windows (32-bit)"
– zhk
17 hours ago
|
show 2 more comments
When i try NSolve i get nothing back as output? Also, the FindAllCrossings isn't working either.
– wznd
19 hours ago
@wznd You should input the interval of interest.
– zhk
19 hours ago
@wznd. For meNSolve
andFindAllCrossings
works fine,I checked on Mathematica10.2
and11.3
.
– Mariusz Iwaniuk
19 hours ago
1
@MichaelE2. With little modification works on MMA11.3
:NSolve[{RealAbs[3 - t^2] + RealAbs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
– Mariusz Iwaniuk
17 hours ago
1
@MichaelE2 "11.0.1 for Microsoft Windows (32-bit)"
– zhk
17 hours ago
When i try NSolve i get nothing back as output? Also, the FindAllCrossings isn't working either.
– wznd
19 hours ago
When i try NSolve i get nothing back as output? Also, the FindAllCrossings isn't working either.
– wznd
19 hours ago
@wznd You should input the interval of interest.
– zhk
19 hours ago
@wznd You should input the interval of interest.
– zhk
19 hours ago
@wznd. For me
NSolve
and FindAllCrossings
works fine,I checked on Mathematica 10.2
and 11.3
.– Mariusz Iwaniuk
19 hours ago
@wznd. For me
NSolve
and FindAllCrossings
works fine,I checked on Mathematica 10.2
and 11.3
.– Mariusz Iwaniuk
19 hours ago
1
1
@MichaelE2. With little modification works on MMA
11.3
: NSolve[{RealAbs[3 - t^2] + RealAbs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
– Mariusz Iwaniuk
17 hours ago
@MichaelE2. With little modification works on MMA
11.3
: NSolve[{RealAbs[3 - t^2] + RealAbs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
– Mariusz Iwaniuk
17 hours ago
1
1
@MichaelE2 "11.0.1 for Microsoft Windows (32-bit)"
– zhk
17 hours ago
@MichaelE2 "11.0.1 for Microsoft Windows (32-bit)"
– zhk
17 hours ago
|
show 2 more comments
Solve[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t], -5 <= t <= 5}, t]
works for me in V11.3, but notNSolve
for some reason.– Michael E2
16 hours ago
@MichaelE2 - I would guess that
NSolve
uses a derivative and cannot handleAbs
. Since the values are real, a workaround isNSolve[{Abs[3 - t^2] + Abs[t - 1] - t^2 == 3*Sin[t] /. Abs[z_] :> Sqrt[z^2], -5 <= t <= 5}, t]
– Bob Hanlon
9 hours ago
@BobHanlon You can see in the comments to @zhk's answer below that
NSolve
works in earlier versions of Mma. While there's some plausibility in your suggestion, it stills seems a backslide.– Michael E2
8 hours ago