I need to multiply all numbers from 1 to 500 together and all odd numbers from 1 to 1000.
Show older comments
I tried prod(1:500) and prod(1:2:999) and I was given Inf. Is there any way to have this give me an rational number? I also need to plot e^z where z goes from 1-1000 so I tried z=1:1000 e=exp(z) plot(z,e) It gives me the very similar problem of only getting rational numbers for very few entries because it automatically takes the answer to a magnitude of 307. Any help is appreciated.
2 Comments
Image Analyst
on 3 Nov 2015
Why do you need such huge numbers? What are you really trying to do? Give us the big picture here. Maybe there's another way to do it that doesn't involve overflowing.
Aaron Pacheco
on 3 Nov 2015
Answers (1)
Walter Roberson
on 3 Nov 2015
0 votes
Symbolic toolbox.
2 Comments
Aaron Pacheco
on 3 Nov 2015
Walter Roberson
on 3 Nov 2015
Or additional hint:
x = sym(1);
x = x * 2;
x = x * 3;
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!