Finding all roots to equation [duplicate]












2















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:



enter image description here



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.










share|improve this question













marked as duplicate by Szabolcs, Daniel Lichtblau, AccidentalFourierTransform, Michael E2 equation-solving
Users with the  equation-solving badge can single-handedly close equation-solving questions as duplicates and reopen them as needed.

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();
}
);
});
});
Dec 9 at 18:17


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 not NSolve for some reason.
    – Michael E2
    Dec 9 at 15:14










  • @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
    Dec 9 at 22:25












  • @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
    Dec 9 at 23:58
















2















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:



enter image description here



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.










share|improve this question













marked as duplicate by Szabolcs, Daniel Lichtblau, AccidentalFourierTransform, Michael E2 equation-solving
Users with the  equation-solving badge can single-handedly close equation-solving questions as duplicates and reopen them as needed.

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();
}
);
});
});
Dec 9 at 18:17


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 not NSolve for some reason.
    – Michael E2
    Dec 9 at 15:14










  • @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
    Dec 9 at 22:25












  • @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
    Dec 9 at 23:58














2












2








2


1






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:



enter image description here



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.










share|improve this question














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:



enter image description here



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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 9 at 10:58









wznd

315




315




marked as duplicate by Szabolcs, Daniel Lichtblau, AccidentalFourierTransform, Michael E2 equation-solving
Users with the  equation-solving badge can single-handedly close equation-solving questions as duplicates and reopen them as needed.

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();
}
);
});
});
Dec 9 at 18:17


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 equation-solving
Users with the  equation-solving badge can single-handedly close equation-solving questions as duplicates and reopen them as needed.

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();
}
);
});
});
Dec 9 at 18:17


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 not NSolve for some reason.
    – Michael E2
    Dec 9 at 15:14










  • @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
    Dec 9 at 22:25












  • @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
    Dec 9 at 23:58


















  • 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
    Dec 9 at 15:14










  • @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
    Dec 9 at 22:25












  • @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
    Dec 9 at 23:58
















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
Dec 9 at 15:14




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
Dec 9 at 15:14












@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
Dec 9 at 22:25






@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
Dec 9 at 22:25














@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
Dec 9 at 23:58




@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
Dec 9 at 23:58










1 Answer
1






active

oldest

votes


















6














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}}







share|improve this answer























  • When i try NSolve i get nothing back as output? Also, the FindAllCrossings isn't working either.
    – wznd
    Dec 9 at 12:34












  • @wznd You should input the interval of interest.
    – zhk
    Dec 9 at 12:38










  • @wznd. For me NSolve and FindAllCrossings works fine,I checked on Mathematica 10.2 and 11.3.
    – Mariusz Iwaniuk
    Dec 9 at 12:50






  • 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
    Dec 9 at 14:28








  • 1




    @MichaelE2 "11.0.1 for Microsoft Windows (32-bit)"
    – zhk
    Dec 9 at 14:35




















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









6














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}}







share|improve this answer























  • When i try NSolve i get nothing back as output? Also, the FindAllCrossings isn't working either.
    – wznd
    Dec 9 at 12:34












  • @wznd You should input the interval of interest.
    – zhk
    Dec 9 at 12:38










  • @wznd. For me NSolve and FindAllCrossings works fine,I checked on Mathematica 10.2 and 11.3.
    – Mariusz Iwaniuk
    Dec 9 at 12:50






  • 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
    Dec 9 at 14:28








  • 1




    @MichaelE2 "11.0.1 for Microsoft Windows (32-bit)"
    – zhk
    Dec 9 at 14:35


















6














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}}







share|improve this answer























  • When i try NSolve i get nothing back as output? Also, the FindAllCrossings isn't working either.
    – wznd
    Dec 9 at 12:34












  • @wznd You should input the interval of interest.
    – zhk
    Dec 9 at 12:38










  • @wznd. For me NSolve and FindAllCrossings works fine,I checked on Mathematica 10.2 and 11.3.
    – Mariusz Iwaniuk
    Dec 9 at 12:50






  • 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
    Dec 9 at 14:28








  • 1




    @MichaelE2 "11.0.1 for Microsoft Windows (32-bit)"
    – zhk
    Dec 9 at 14:35
















6












6








6






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}}







share|improve this answer














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}}








share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 9 at 12:44

























answered Dec 9 at 12:05









zhk

8,79411433




8,79411433












  • When i try NSolve i get nothing back as output? Also, the FindAllCrossings isn't working either.
    – wznd
    Dec 9 at 12:34












  • @wznd You should input the interval of interest.
    – zhk
    Dec 9 at 12:38










  • @wznd. For me NSolve and FindAllCrossings works fine,I checked on Mathematica 10.2 and 11.3.
    – Mariusz Iwaniuk
    Dec 9 at 12:50






  • 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
    Dec 9 at 14:28








  • 1




    @MichaelE2 "11.0.1 for Microsoft Windows (32-bit)"
    – zhk
    Dec 9 at 14:35




















  • When i try NSolve i get nothing back as output? Also, the FindAllCrossings isn't working either.
    – wznd
    Dec 9 at 12:34












  • @wznd You should input the interval of interest.
    – zhk
    Dec 9 at 12:38










  • @wznd. For me NSolve and FindAllCrossings works fine,I checked on Mathematica 10.2 and 11.3.
    – Mariusz Iwaniuk
    Dec 9 at 12:50






  • 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
    Dec 9 at 14:28








  • 1




    @MichaelE2 "11.0.1 for Microsoft Windows (32-bit)"
    – zhk
    Dec 9 at 14:35


















When i try NSolve i get nothing back as output? Also, the FindAllCrossings isn't working either.
– wznd
Dec 9 at 12:34






When i try NSolve i get nothing back as output? Also, the FindAllCrossings isn't working either.
– wznd
Dec 9 at 12:34














@wznd You should input the interval of interest.
– zhk
Dec 9 at 12:38




@wznd You should input the interval of interest.
– zhk
Dec 9 at 12:38












@wznd. For me NSolve and FindAllCrossings works fine,I checked on Mathematica 10.2 and 11.3.
– Mariusz Iwaniuk
Dec 9 at 12:50




@wznd. For me NSolve and FindAllCrossings works fine,I checked on Mathematica 10.2 and 11.3.
– Mariusz Iwaniuk
Dec 9 at 12:50




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
Dec 9 at 14:28






@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
Dec 9 at 14:28






1




1




@MichaelE2 "11.0.1 for Microsoft Windows (32-bit)"
– zhk
Dec 9 at 14:35






@MichaelE2 "11.0.1 for Microsoft Windows (32-bit)"
– zhk
Dec 9 at 14:35





Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents