kidjapa/php-goalseek

A simple goalseek function for PHP. Using the goalseek function from Libre Office

Maintainers

Package info

github.com/kidjapa/Php-GoalSeek

Issues

pkg:composer/kidjapa/php-goalseek

Statistics

Installs: 2 103

Dependents: 0

Suggesters: 0

Stars: 7

1.0 2020-11-05 12:52 UTC

This package is auto-updated.

Last update: 2026-04-23 04:53:26 UTC


README

  • Php function to simulate Goal Seek from libre office using the Regula Falsi method.

  • In most cases the result is equal of the Excel formula. Because the Excel do not show what formula are used in goal seak we need to use the similar function in Libre Office.

  • Install

composer require kidjapa/php-goalseek

In Libre office

  • Function in archive: core/sc/source/coredata/dcoumen4.cxx
bool ScDocument::Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab,
                        SCCOL nVCol, SCROW nVRow, SCTAB nVTab,
                        const OUString& sValStr, 
                        double& nX
                        )

Sample

$goalSeek = new SolveGoalSeek();

$getValue = 0;

$getValue = $goalSeek->seekGoal(
    function($value, $data){
        return sqrt($value);
    },
    16,  // The Actual Value
    20   // The Goal Value
);

echo "------------- results ------------- \n";
echo "Result: ".$getValue."\n"; // Expect: 400