10-28-2024 04:10 PM
I’m currently a student tasked with programming in LabVIEW, though I have very little experience with the software. As a test of my understanding, my professor has assigned me to calculate the Taylor expansion of e^x. However, I'm not allowed to use the factorial or summation functions. I’ve tried implementing this with a stacked sequence structure and local variables, but I'm struggling to simplify the calculations. Any guidance would be greatly appreciated, including recommendations for helpful learning videos.
10-28-2024 04:23 PM - edited 10-28-2024 04:30 PM
@GradTA wrote:
I’ve tried implementing this with a stacked sequence structure and local variables, but I'm struggling to simplify the calculations.
I can guarantee you that stacked sequences and local variables will not be part of any reasonable solution! How do you come up with these crazy ideas?
@GradTA wrote:
As a test of my understanding,....
It is obvious that this test shows that you don't have any understanding yet!
Did you go over your course notes?
Did you look at the learning resources listed at the top of the forum?
10-28-2024 04:26 PM
That idea was given to me by the professor. Also when I click the link you posted it sends me to an error
10-28-2024 04:30 PM
As an example of a Taylor series expansion for sin(x), you could study this post. Now just modify the terms to approximate e^x instead, which is even simpler. See how far you get.
10-28-2024 04:32 PM
@GradTA wrote:
That idea was given to me by the professor. Also when I click the link you posted it sends me to an error
Sorry about the broken link. I have edited it out. Study the links in the above post instead.
10-28-2024 04:56 PM
You need to learn about Loops (For, While) and the three ways to get wires in and out:
Now make yourself a For Loop, wire "10" to N (so it runs 10 times). Experiment putting numbers (start with 1) into a Tunnel, and bring it out through a Tunnel, and through an Array tunnel (you can branch the wire inside the For Loop and make it go to two places.
Run this and observe the outputs. Now put a function (say Increment) on the wire and see what happens. Finally, add a Shift Register and see how it differs.
Pretty soon, you should be able to figure out how to put a quantity ("x") on the left, and get x^n/(n!), how to build an array for n = 1 ..10, and maybe how to add up the elements of this array.
Bob Schor
10-28-2024 06:16 PM - edited 10-28-2024 06:19 PM
@altenbach wrote:
As an example of a Taylor series expansion [...] modify the terms to approximate e^x instead, which is even simpler
nice!
now get rid of the add array primitive... |
||
n=6 | n=20 | n=100 |
|
|
|
10-28-2024 06:26 PM
From the original post:
"As a test of my understanding, my professor has assigned me to..."
Giving a direct solution could falsify the test of "understanding", unless the student can justify every minute detail of every single code element.....
Fortunately, the professor reads these forums too, so I am sure he will ask for a detailed explanation.. 😄
10-29-2024 10:10 AM - edited 10-29-2024 10:11 AM
@altenbach wrote:
Fortunately, the professor reads these forums too, so I am sure he will ask for a detailed explanation.. 😄
as usual, I have put in some characteristic mistakes, eg I use the add array elements primitive which may be interpreted as a summations function 😉
@GradTA wrote:
... my professor has assigned me to calculate the Taylor expansion of e^x. However, I'm not allowed to use the factorial or summation functions.
moreover, when I tried to get rid of the add array elements primitive by using shift registers, the result tends to be less accurate when compared to the exp(x) primitive (starting with the 16th decimal place)
10-29-2024 10:52 AM
I would think that the "power of x" function should not be allowed here. Just basic primitives (add, multiply, divide).
You immediately get problems for "large'ish" absolute inputs where the division approaches Inf/Inf
Here's what I might do: