Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3871732
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T21:51:07+00:00 2026-05-19T21:51:07+00:00

I’m new to Python, and a bit rusty with my linear algebra, so perhaps

  • 0

I’m new to Python, and a bit rusty with my linear algebra, so perhaps this is a simple question. I’m trying to implement a Taylor Series expansion on a Matrix to compute exp(A), where A is just a simple 3×3 matrix. The formula, BTW for this expansion is sum( A^n / n! ).

My routine works alright up to n=9, but at n=10, the numbers in the Matrix suddenly become negative. This is the problem.

A**9
matrix([[ 250130371, 506767656, 688136342],
[ 159014912, 322268681, 437167840],
[ 382552652, 775012944, 1052574077]])

A**10
matrix([[-1655028929, 1053671123, -1327424345],
[ 1677887954, -895075635, 319718665],
[ -257240602, -409489685, -1776533068]])

Intuitively A^9 * A should produce larger numbers for each member of the matrix, but as you can see, A^10 isn’t giving that result.

Any ideas?

from scipy import *
from numpy import *
from numpy.linalg import *
#the matrix I will use to implement exp(A)
A = mat('[1 3 5; 2 5 1; 2 3 8]')
#identity matrix
I = mat('[1 0 0; 0 1 0; 0 0 1]')
#first step in Taylor Expansion (n=0)
B = I
#second step in Taylor Expansion (n=1)
B += A
#start the while loop in the 2nd step
n = 2
x=0
while x<10:
    C = (A**n)/factorial(n)
    print C
    print " "
    n+=1
    B+= C
    print B
    x+=1

print B

Thanks for any help you can give!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T21:51:07+00:00Added an answer on May 19, 2026 at 9:51 pm

    Your matrix is created with elements of type int32 (32-bit integer). You can see this by printing the value of A.dtype. 32-bit integers can only hold values up to about 2 billion, so after that they will wrap around to negative values.

    If 64-bit integers are large enough, you can use them instead:

    A = mat('[1 3 5; 2 5 1; 2 3 8]', dtype=numpy.int64)
    

    Otherwise, you can use floating point numbers. They have a much larger maximum value, but limited precision, so there may be some inaccuracies.

    A = mat('[1 3 5; 2 5 1; 2 3 8]', dtype=float)
    

    In this case floating-point is probably the best choice, since you don’t want your results to be integers after dividing by n!.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm looking for suggestions for debugging... If you view this site in Firefox or
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I've got a string that has curly quotes in it. I'd like to replace
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.