Question

4.30 Write a MATLAB program that uses implicit Euler to integrate dx Use an initial condition y(0)-1 and integrate until x 2. What equations are needed for Newtons methiod? Is this solution becoming unstable?

0 0
Add a comment Improve this question Transcribed image text
Answer #1
    .text

#calculates sum of digits recursively
SumDigits:

    sub     $sp,    $sp,    12                  #alloocate 12B on stack
    sw      $ra 0($sp)                      #save return address
    sw      $a0,    4($sp)                      #save argument

    beq     $a0,    $0, exit_sumdigits      #when there is no more digits return 0
    rem     $t0,    $a0,    10                  #get last digit
    sw      $t0,    8($sp)                      #save it on stack
    div     $a0,    $a0,    10                  #divide argument by 10
    jal     SumDigits                       #repeat procedure
    lw      $t0,    8($sp)                      #read digit from stack
    add     $v0,    $v0,    $t0             #add digit to previous result
    lw      $ra,    0($sp)                      #load return address
    addi    $sp,    $sp,    12                  #free stack
    jr      $ra                             #return

exit_sumdigits:
    li      $v0,    0                           #there are no more digits, return 0
    lw      $ra,    0($sp)                      #load return address
    addi    $sp,    $sp,    12                  #free stack
    jr      $ra                             #return

main:
    li      $a0,    75080                       #load number in $a0
    jal     SumDigits                           #call SumDigits

    move    $a0,    $v0                         #set a0 = result of SumDigits
    li      $v0,    1                           #set $v0 for print int system call
    syscall

    li      $v0,    10                          #set $v0 for exit system call
    syscall

.data
Add a comment
Know the answer?
Add Answer to:
4.30 Write a MATLAB program that uses implicit Euler to integrate dx Use an initial condition...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT