Documentation / LearningLemur

  • Demos
  • Visit our website
  • Contact us
  • MathType

    • WirisQuizzes

      • LearningLemur

        • CalcMe

          • MathPlayer

            • Store FAQ

              • VPAT for the electronic documentation

                • MathFlow

                  • BF FAQ

                    • Miscellaneous

                      • Wiris Integrations

                        • Home
                        • LearningLemur
                        • Using LearningLemur
                        • Advanced Logic in LearningLemur
                        • Advanced Logic Examples in LearningLemur
                        • Advanced Logic Examples in LearningLemur

                        How to generate linearly independent or dependent 3D vectors

                        Reading time: 2min

                        When to use this: Use this method when you want students to determine whether a set of three 3D vectors is linearly independent or linearly dependent, with a controlled outcome.

                        What you'll achieve: You will generate a set of three 3D vectors that is guaranteed to be either:

                        • Linearly dependent (by construction), or
                        • Linearly independent (by determinant check)

                        See it in action: Watch how this logic is implemented inside LearningLemur:

                        Your browser does not support HTML5 video.

                        Before you begin

                        Requirements

                        • Basic knowledge of how to create a LearningLemur question
                        • Familiarity with adding and editing question algorithms
                        • Basic understanding of determinants and linear dependence

                        Steps

                        Generate two linearly independent base vectors

                        u1 = random([-5..5] / [0])
                        u2 = random([-5..5] / [0])
                        u3 = random([-5..5] / [0])
                        u = [u1, u2, u3]
                        
                        v1 = random([-5..5] / [0])
                        v2 = random([-5..5] / [0])
                        v3 = random([-5..5] / [0])
                        
                        while vectorial_product(u,[v1,v2,v3])==[0,0,0] 
                            v1 = random([-5..5] / [0])
                            v2 = random([-5..5] / [0])
                            v3 = random([-5..5] / [0])
                        end
                        v = [v1, v2, v3]

                        This ensures:

                        • u is a non-zero vector
                        • v is not a scalar multiple of u
                        • So {u, v} is linearly independent.

                        Generate a dependent third vector (controlled dependence)

                        k1 = random([-3..3] / [0])
                        k2 = random([-3..3] / [0])
                        
                        w = k1 * u + k2 * v

                        Since w is a linear combination of u and v, the set {u, v, w} is guaranteed to be linearly dependent.

                        Generate an independent third vector (controlled independence)

                        t1 = random([-5..5] / [0])
                        t2 = random([-5..5] / [0])
                        t3 = random([-5..5] / [0])
                        
                        while determinant([u,v,[t1,t2,t3]]) == 0
                            t1 = random([-5..5] / [0])
                            t2 = random([-5..5] / [0])
                            t3 = random([-5..5] / [0])
                        end
                        t = [t1, t2, t3]

                        This ensures that {u, v, t} is linearly independent.

                        Verify it worked

                        • Preview the question multiple times
                        • For dependent sets, verify that one vector is a linear combination of the others
                        • For independent sets, confirm the determinant of the matrix formed by the vectors is non-zero
                        • Ensure no zero vectors appear

                        Full algorithm (copy-paste version)

                        Use the complete version below if you want to copy the logic directly into your question algorithm:

                        # Generate two linearly independent 3D vectors u and v
                        u1 = random([-5..5] / [0])
                        u2 = random([-5..5] / [0])
                        u3 = random([-5..5] / [0])
                        u = [u1, u2, u3]
                        
                        v1 = random([-5..5] / [0])
                        v2 = random([-5..5] / [0])
                        v3 = random([-5..5] / [0])
                        
                        while vectorial_product(u,[v1,v2,v3])==[0,0,0] 
                            v1 = random([-5..5] / [0])
                            v2 = random([-5..5] / [0])
                            v3 = random([-5..5] / [0])
                        end
                        v = [v1, v2, v3]
                        
                        # Generate dependent third vector
                        k1 = random([-3..3] / [0])
                        k2 = random([-3..3] / [0])
                        w = k1 * u + k2 * v
                        
                        # Generate independent third vector
                        t1 = random([-5..5] / [0])
                        t2 = random([-5..5] / [0])
                        t3 = random([-5..5] / [0])
                        
                        while determinant([u,v,[t1,t2,t3]]) == 0
                            t1 = random([-5..5] / [0])
                            t2 = random([-5..5] / [0])
                            t3 = random([-5..5] / [0])
                        end
                        t = [t1, t2, t3]

                        Options and variations

                        • If you only want dependent sets, you can remove the independent vector generation section
                        • If you only want independent sets, you can remove the dependent vector logic
                        • If you want larger coordinate values, you can increase the interval in the random() calls
                        • If you want 2D vectors instead, you can remove the third coordinate and adapt determinant checks accordingly

                        Common errors

                        Vectorial product is always zero

                        Ensure vectors are regenerated inside the while loop

                        Determinant loop runs too long

                        Broaden the interval to increase variability

                        Unexpected zero vector appears

                        Confirm that zero is excluded in the random interval (/[0])

                        Related

                        • Understanding Advanced Logic in LearningLemur
                        • Common Patterns and Best Practices
                        • Glossary of Commands

                        Was this article helpful?

                        Yes
                        No
                        Give feedback about this article

                        Related Articles

                        • Linear algebra
                        • Vector field

                        How to generate linearly independent or dependent 3D vectors

                        Before you begin Requirements Steps Generate two linearly independent base vectors Generate a dependent third vector (controlled dependence) Generate an independent third vector (controlled independence) Verify it worked Full algorithm (copy-paste version) Options and variations Common errors Vectorial product is always zero Determinant loop runs too long Unexpected zero vector appears Related

                        Making people’s STEM work more meaningful

                        MathType

                        • MathType for Office Tools
                        • MathType for Mac
                        • MathType for Microsoft 365
                        • MathType for Google Workspace
                        • MathType for LMS
                        • MathType for XML Editors
                        • Arabic notation
                        • Our products accessibility
                        • MathType is online

                        WirisQuizzes

                        Learning Lemur

                        Solutions for Education

                        • Blackboard Learn
                        • Brightspace by D2L
                        • Canvas
                        • Google Classroom
                        • Moodle
                        • Schoology

                        Solutions for Publishing Houses

                        Solutions for Technical Writers

                        Solutions for Chemistry

                        Integrations

                        • HTML Editors
                        • MathType in WordPress

                        Pricing

                        Company

                        Careers

                        Blog

                        Contact Us

                        Buy Now

                        Plugin Downloads

                        © Wiris 2025

                        • Cookie Settings
                        • Cookie Policy
                        • Terms of Use
                        • Privacy Policy / GDPR
                        • Student Data Privacy
                        • Compliance
                        • Powered by Helpjuice
                        Expand